fix: enhance session comparison (SDK V2)#1365
Merged
Merged
Conversation
ffmcgee725
marked this pull request as ready for review
October 10, 2025 10:39
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1365 +/- ##
=======================================
Coverage 74.99% 74.99%
=======================================
Files 184 184
Lines 4519 4519
Branches 1108 1108
=======================================
Hits 3389 3389
Misses 1130 1130 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
wenfix
reviewed
Oct 10, 2025
Comment on lines
+166
to
+171
| const existingAccountIds: CaipAccountId[] = []; | ||
| for (const scopeObject of Object.values(walletSession.sessionScopes)) { | ||
| if (scopeObject.accounts) { | ||
| existingAccountIds.push(...scopeObject.accounts); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| const existingAccountIds: CaipAccountId[] = []; | |
| for (const scopeObject of Object.values(walletSession.sessionScopes)) { | |
| if (scopeObject.accounts) { | |
| existingAccountIds.push(...scopeObject.accounts); | |
| } | |
| } | |
| const existingAccountIds: CaipAccountId[] = Object.values(walletSession.sessionScopes) | |
| .filter(({accounts}) => Boolean(accounts)) | |
| .flatMap(({accounts}) => accounts) |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Explanation
When we are managing session upgrade in both transports, we currently check is
sessionScopeshave changes but we should also be checking if the accounts are the same ones as well, and if not, upgrade the session.This PR creates an enhanced scope checking utility function to be used in both transports.
References
Checklist
Note
Adds
isSameScopesAndAccountsand updates transports to recreate sessions when scopes or proposed accounts differ; includes comprehensive tests.isSameScopesAndAccounts(currentScopes, proposedScopes, walletSession, proposedCaipAccountIds)to validate both scopes and CAIP accounts against existingsessionScopes.multichain/transports/defaultandmultichain/transports/mwpnow useisSameScopesAndAccountswhen connecting/resuming; recreate (create + revoke) session if mismatch.isSameScopesAndAccounts, covering exact matches, mismatched scopes, subset accounts, empty/absent accounts, ordering differences, and multiple accounts per scope.Written by Cursor Bugbot for commit 21a6ce2. This will update automatically on new commits. Configure here.