-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: Add page to review gator permissions granted to sites #36734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…regatedGatorPermissionByChainId selector
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (7 files, +2013 -8)
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [7cf702e]
UI Startup Metrics (1212 ± 69 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [e48f6ff]
UI Startup Metrics (1245 ± 60 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [35b302c]
UI Startup Metrics (1239 ± 68 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [a2e9579]
UI Startup Metrics (1229 ± 50 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small comments but otherwise lgtm!
| /** | ||
| * Converts a hex value to a decimal value | ||
| * | ||
| * @param value - The hex value to convert | ||
| * @param decimals - The number of decimals to shift the value by | ||
| * @returns The decimal value | ||
| */ | ||
| const getDecimalizedHexValue = useCallback( | ||
| (value: Hex, decimals: number) => | ||
| new Numeric(value, 16).toBase(10).shiftedBy(decimals).toString(), | ||
| [], | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this function would benefit from living inside a number utils file and having its own tests. Or perhaps '@metamask/utils' also has something e.g. hexToNumber that could be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this function to a numbers util file under shared/lib/gator-permissions and added comprehensive test coverage.
| /** | ||
| * Returns the unknown token amount text | ||
| * | ||
| * @returns The unknown token amount text | ||
| */ | ||
| const getUnknownTokenAmountText = useCallback(() => { | ||
| return t('gatorPermissionUnknownTokenAmount'); | ||
| }, [t]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like unnecessary overhead for such a simple function. t is stable and fast and you could probably just inline t('gatorPermissionUnknownTokenAmount') where you need it instead of adding this complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call out, I dropped this helper function in replacement of an inline call to t
| /** | ||
| * Handles the click event for the expand/collapse button | ||
| */ | ||
| const handleExpandClick = useCallback(() => { | ||
| setIsExpanded(!isExpanded); | ||
| }, [isExpanded]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useCallback is useful to prevent triggering unnecessary re-renders when the function is being used in expensive and slow memoized components or useEffects. Here it's only being used in simple (I think) UI library components, so arguably isn't better than just doing:
const handleExpandClick = () => {
setIsExpanded(!isExpanded);
};
Just something to bear in mind as often we add useCallbacks with good intentions but if there isn't a performance issue we're trying to solve, they often just add overhead with no real benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insight. In this case, the handleExpandClick() is indeed simple and only toggles a stateful boolean value. I dropped useCallback.
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [7e5a8a6]
UI Startup Metrics (1287 ± 75 ms)
|
…with test coverage, and drop unnecessary usage of useCallback in ReviewGatorPermissionItem
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [255d258]
UI Startup Metrics (1258 ± 90 ms)
|
| const year = date.getFullYear(); | ||
|
|
||
| return `${month}/${day}/${year}`; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [21c316f]
UI Startup Metrics (1259 ± 83 ms)
|
Description
This PR expands on the gator permissions revocation feature. Enabling users to view/revoke gator permissions.
Manual testing steps
.metamaskrcfile, ensure the following env values are set:All Permissions Page.DelegationManagercontract.Screenshots/Recordings
Before
review-permissions-before.mov
After
review-permissions-after.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces a review page listing gator token-transfer permissions with detailed per-item views and revoke actions, powered by new time/number utilities, selectors, and i18n strings.
ReviewGatorPermissionsPageto list token-transfer permissions per chain usingReviewGatorPermissionItem, with expand details and revoke action.ReviewGatorPermissionItemfromcomponents/index.PermissionsCellTooltip(removethemeprop).getAggregatedGatorPermissionByChainIdto fetch aggregated token-transfer permissions bychainId.shared/lib/gator-permissionsutilities:time-utils(frequency key derivation, ms↔sec, per-period conversion, timestamp formatting, expiry extraction).numbers-utils(hex-to-decimal string with decimals).index.shared/constants/time.tswith documentation comments.enanden_GB.Written by Cursor Bugbot for commit 21c316f. This will update automatically on new commits. Configure here.