Conversation
|
@metamaskbot preview-build |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| notifications = []; | ||
| } | ||
|
|
||
| const sortedAccounts = sortAccountIdsByLastSelected |
There was a problem hiding this comment.
[nit] this name can be misleading, since we are not always sorting these accounts, sortedAccounts could actually be unsorted if sortAccountIdsByLastSelected is not provided.
we could name the function param caipAccountIds, and this variable accounts for example (open to other suggestions)
There was a problem hiding this comment.
fair point. I've actually had to move this sorting to a different helper based on a bug that cursorbot caught. Mind reviewing again and seeing if you still feel the function param name change still makes sense?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
packages/chain-agnostic-permission/src/operators/caip-permission-operator-session-scopes.ts
Outdated
Show resolved
Hide resolved
… into jl/sortAccountIdsByLastSelected
packages/multichain-api-middleware/src/handlers/wallet-getSession.ts
Outdated
Show resolved
Hide resolved
|
|
Co-authored-by: Alex Donesky <adonesky@gmail.com>
…ion.ts Co-authored-by: Alex Donesky <adonesky@gmail.com>
|
yeah, let's sort them. There are places in extension where we do not need to sort, but i agree that it makes sense to sort them here |
## @metamask/chain-agnostic-permissions ## [1.5.0] ### Added - Add optional `sortAccountIdsByLastSelected` parameter to `getSessionScopes` function to enable custom account ordering within session scopes ([#8255](#8255)) ### Changed - Bump `@metamask/permission-controller` from `^12.2.0` to `^12.2.1` ([#8225](#8225)) - Bump `@metamask/controller-utils` from `^11.17.0` to `^11.19.0` ([#7583](#7583), [#7995](#7995)) ## @metamask/multichain-api-middleware ## [2.0.0] ### Added - **BREAKING:** Add required `sortAccountIdsByLastSelected` hook to `wallet_getSession`, `wallet_createSession`, and `wallet_invokeMethod` handlers to enable custom account ordering in session scopes ([#8255](#8255)) ### Changed - Bump `@metamask/permission-controller` from `^12.2.0` to `^12.2.1` ([#8225](#8225)) - Bump `@metamask/json-rpc-engine` from `^10.2.2` to `^10.2.3` ([#8078](#8078)) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Primarily a release/version bump, but it includes a major version bump for `@metamask/multichain-api-middleware` and updated dependency constraints that may break downstream consumers expecting the previous API contract. > > **Overview** > Bumps the monorepo version to `880.0.0` and publishes new package versions: `@metamask/chain-agnostic-permission` `1.5.0` and **breaking** `@metamask/multichain-api-middleware` `2.0.0`. > > Updates dependent packages (notably `@metamask/eip1193-permission-middleware` and `@metamask/multichain-api-middleware`) to require `@metamask/chain-agnostic-permission@^1.5.0`, and refreshes associated changelog entries and `yarn.lock` mappings. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 879c9d7. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->

Explanation
@metamask/chain-agnostic-permissionsortAccountIdsByLastSelectedparameter togetSessionScopesfunction(accounts: CaipAccountId[]) => CaipAccountId[]accountsarray within each scope (both required and optional scopes)@metamask/multichain-api-middlewaresortAccountIdsByLastSelectedhook towallet_getSessionhandlergetSessionScopeswhen building session responsesortAccountIdsByLastSelectedhook towallet_createSessionhandlergetSessionScopeswhen building session scopes for approvalReferences
See: MetaMask/metamask-extension#41068
Checklist
Note
Medium Risk
Medium risk because it changes handler hook contracts in
multichain-api-middleware(breaking for integrators) and alters ordering of accounts returned in session scopes, which could impact downstream UI/logic expectations.Overview
Adds an optional
sortAccountIdsByLastSelectedhook to@metamask/chain-agnostic-permissiongetSessionScopes, applying it to theaccountslist for every merged scope before returning session scopes.Updates
wallet_getSession,wallet_createSession, andwallet_invokeMethodhandlers in@metamask/multichain-api-middlewareto require and pass through this new sorting hook, with corresponding test updates and changelog entries noting the breaking hook requirement.Written by Cursor Bugbot for commit 4fc3d03. This will update automatically on new commits. Configure here.