feat: Use AccountGroup metadata for sorting in core permission helpers#29295
feat: Use AccountGroup metadata for sorting in core permission helpers#29295jiexi wants to merge 46 commits into
Conversation
There was a problem hiding this comment.
we can remove if in fact it's unused
There was a problem hiding this comment.
we can remove if in fact it's unused
Co-authored-by: ffmcgee <51971598+ffmcgee725@users.noreply.github.com>
Co-authored-by: ffmcgee <51971598+ffmcgee725@users.noreply.github.com>
…r-sorting-in-core-permission' into jl/use-account-group-metadata-for-sorting-in-core-permission
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2341564. Configure here.
| jest.advanceTimersByTime(1000); | ||
| expect(PermissionController.getCaveat).toHaveBeenCalledTimes(1); | ||
| expect(notifySpy).toHaveBeenCalledWith(mockCaveatValue); | ||
| }); |
There was a problem hiding this comment.
Test name contradicts its actual assertion
Medium Severity
The test is named "does not call notifyCaipAuthorizationChange if the caveat is revoked before the setTimeout fires" but line 1830 asserts expect(notifySpy).toHaveBeenCalledWith(mockCaveatValue), confirming it WAS called. Since the setTimeout was removed and the function now fires synchronously, the assertion body is correct for the new behavior, but the test name claims the opposite — providing false documentation of the contract.
Reviewed by Cursor Bugbot for commit 2341564. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Affected E2E areas:
Dependent tags per descriptions:
Performance Test Selection: |
|





Description
Replaces EVM InternalAccount based sorting with
AccountGroupbased sorting in the core permission helpers.NOTE: This does not update the selectors which still rely on the EVM InternalAccount
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Nothing should be different. Use the IAB to connect to a dapp, then change the selected account around and ensure the ordering is correct
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes account-ordering behavior used when returning/announcing permitted accounts and removes a delay in
wallet_sessionChangedemission, which could affect dapp-observed ordering/timing across lock/unlock and account-group changes.Overview
Updates permission helpers to sort permitted EVM and CAIP-10 account lists using
AccountTreeController/AccountGroupmetadata.lastSelected(with caching and fallbacks) instead of InternalAccount metadata, and removes thesortEvmAccountsByLastSelectedpath.BackgroundBridge.handleSessionChangedFromSelectedAccountGroupChangesnow emitswallet_sessionChangedimmediately using the current CAIP-25 caveat (nosetTimeout/refetch), and tests/mocks are updated to cover the new sorting behavior, fallback cases, and error handling.Reviewed by Cursor Bugbot for commit 94f075e. Bugbot is set up for automated code reviews on this repo. Configure here.