-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: Extract Gator Permission Expiry From Delegation Context #37874
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
Fixes #464 - Permission with expiry showing 'No expiration' - Extract expiry timestamp from permissionResponse.context by decoding delegation - Find TimestampEnforcer caveat and decode the terms field (last 32 hex chars) - Convert BigInt timestamp to readable date format - Add comprehensive test coverage for all edge cases: - Valid expiry extraction - No TimestampEnforcer caveat - Invalid delegation count (0 or >1) - Invalid terms length - Zero timestamp - Decoding errors - Remove unused imports and debug logs
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (2 files, +179 -29)
|
...mponents/multichain/pages/gator-permissions/components/review-gator-permission-item.test.tsx
Show resolved
Hide resolved
Builds ready [542ada2]
UI Startup Metrics (1214 ± 97 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…missionItem tests - Add beforeEach hooks to configure decodeDelegations and getDeleGatorEnvironment mocks for NATIVE and ERC20 token test suites - Update test assertions to verify actual expiration date content instead of just element presence - Fix variable naming conflicts in edge case tests to avoid scope shadowing - Ensures tests correctly validate expiration date extraction from delegation context
Builds ready [9261685]
UI Startup Metrics (1261 ± 86 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
MoMannn
left a comment
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.
Some tests are failing. Run yarn test:unit:coverage --shard=4/6 locally to check.
ui/components/multichain/pages/gator-permissions/components/review-gator-permission-item.tsx
Outdated
Show resolved
Hide resolved
|
Would it make sense to merge this into: #37768 and have a single PR? |
- Created extractExpiryTimestampFromDelegation() in time-utils.ts - Returns expiry timestamp or 0, making it reusable across components - Simplified review-gator-permission-item.tsx from ~60 lines to ~10 lines - Moved comprehensive tests from component to utility tests - Component tests now focus on UI behavior only
Builds ready [741e6c2]
UI Startup Metrics (1213 ± 79 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Jest's it() function doesn't accept timeout as third parameter with async callbacks. Removed invalid timeout arguments from two test cases that were causing TypeScript errors.
Builds ready [d790d8a]
UI Startup Metrics (1223 ± 91 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Jest's beforeAll/afterAll don't accept timeout as second parameter with async callbacks. Removed invalid timeout arguments that were causing issues.
Builds ready [8596ba0]
UI Startup Metrics (1242 ± 101 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9e54655]
UI Startup Metrics (1234 ± 101 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…ssions-controller
…e utility - Use extractExpiryToReadableDate from time-utils instead of manual extraction - Remove UTC zone specification from convertTimestampToReadableDate - Reduce getExpirationDate function from 26 to 9 lines - Import GatorPermissionRule type for proper typing
Builds ready [574f87a]
UI Startup Metrics (1166 ± 95 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Fixes #464 - Gator permissions with expiry were displaying "No expiration" in the UI.
Root Cause: The expiry timestamp was excluded as part of a sanitization of the permissions response because it was stored in the permission.
Solution:
Changelog
CHANGELOG entry: Fixed gator permissions displaying "No expiration" when expiry timestamp exists
Related issues
Fixes: #464
Manual testing steps
jeff.dripfund.xyzjeff.dripfund.xyzScreenshots/Recordings
Before
Permission showed "No expiration" despite having an expiry timestamp in the delegation context.
After
Permission now correctly displays the expiration date (e.g., "11/13/2026") extracted from the
TimestampEnforcercaveat.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Display correct expiration dates for Gator permissions using
permissionResponse.rules; add tests and bump@metamask/gator-permissions-controllerto ^0.5.0.permissionResponse.ruleswithextractExpiryToReadableDateto render expiration inui/components/multichain/pages/gator-permissions/components/review-gator-permission-item.tsx.getExpirationDate()and remove unused warning.review-gator-permission-item.test.tsx):ruleswithexpiryto mocks and assert exact dates for native/ERC20 stream and periodic permissions.@metamask/gator-permissions-controllerfrom^0.4.0to^0.5.0(updatepackage.jsonandyarn.lock).Written by Cursor Bugbot for commit 574f87a. This will update automatically on new commits. Configure here.
Depends on this one MetaMask/core#7195 Pending to upgrade to the gator-permissions-controller: ^0.6.0