feat(wallets): connect MetaMask via multichain#105
Open
towanTG wants to merge 6 commits into
Open
Conversation
… + Solana)
Route WalletOption.METAMASK through MetaMask's multichain CAIP-25 SDK so a single
session/approval covers EVM and Solana (and future ecosystems). A dedicated
metamaskWallet connector opens one session over all requested scopes, then adapts
invokeMethod into each existing SwapKit toolbox:
- EVM: an EIP-1193 shim over invokeMethod -> ethers BrowserProvider ->
getWeb3WalletMethods (reused unchanged).
- Solana: a SolanaProvider-style signer whose signTransaction calls
solana_signTransaction (sign-only; SwapKit broadcasts) -> getSolanaToolbox.
Also registers metamaskWallet in the SDK defaultWallets + re-exports, repoints the
METAMASK types, adds @metamask/connect-multichain and @solana/web3.js deps plus the
./metamask subpath export, and adds the Vite optimizeDeps config the connect SDK needs.
Import Chain as a value, drop the readonly->mutable EVMChains cast, use the Chain.Solana enum in chainToScope, and pass supportedChains as a plain Chain[] ([...EVMChains, Chain.Solana]) with directSigningSupport — mirroring the phantom and evmWallet connectors. Removing the 'as EVMChain[]' cast restores createWallet's generic inference, which also clears the cascaded 'name is missing' (index.ts) and 'possibly undefined' (types.ts) errors.
getWeb3WalletMethods always wraps the toolbox in prepareNetworkSwitch, which is built for injected wallets that switch an active chain before signing. In a CAIP-25 multichain session the scope already pins the chain, so answer wallet_switchEthereumChain / wallet_addEthereumChain locally as no-ops instead of forwarding them into invokeMethod (where they're meaningless and may throw).
…into pr/metamask-multichain
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.
Summary
Validation