Draft
Conversation
- Add PrefixedStoreAdapter to prefix all storage keys with instanceId - Add createIsolatedStorage utility for consistent storage creation - Add generateInstanceId for deterministic instance IDs - Add instanceId option to MultichainOptions for explicit control - Fix beforeunload listener bug (was using different function references) - Update tests to use instanceId: '' for backwards compatibility This enables multiple SDK clients to coexist without storage collisions. Each client instance gets its own storage namespace based on dapp.name and SDK type (e.g., 'mydapp-multichain:', 'mydapp-evm:').
- Add sdkType option to MultichainOptions for proper isolation - Fix EVM client to pass sdkType: 'evm' to multichain core - Increment IndexedDB version to force schema upgrade - Add experiments pages to browser playground for testing isolation - Add StateVisualizer component for inspecting storage state
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.
POC: SDK Client Isolation
Problem
When a dApp uses multiple MetaMask Connect SDK clients (Multichain, EVM, Solana, Wagmi), they can interfere with each other and enter weird states. This happens because:
Approach
This POC explores storage-level isolation using key prefixing. Each SDK type gets its own storage namespace so they don't overwrite each other's data.
What this design does:
instanceIdfromdapp.name+ SDK type (e.g.,myapp-evm,myapp-multichain)PrefixedStoreAdapterthat prefixes all keysdapp.namein different browser tabs shares state (multi-tab consistency)Files changed:
PrefixedStoreAdapter- new adapter wrapper for key prefixingcreateIsolatedStorage- utility to set up prefixed storagesdkTypeoption added toMultichainOptionssdkType: 'evm'to multichain coreKey Findings
Extension creates one connection per website - The MetaMask browser extension does not support separate sessions per SDK client. All clients share the same session. This means storage isolation alone doesn't fully solve the problem when using the extension.
MWP (QR code) flow supports true isolation - Each QR scan creates an independent session. Storage prefixing works correctly here.
Inconsistent behavior between flows - Extension and mobile flows behave differently, which may need further investigation.
Testing
The browser playground now includes an experiments page (
?experimentsURL param) with dedicated test scenarios:Next Steps