Skip to content

feat(wallets): connect MetaMask via multichain#105

Open
towanTG wants to merge 6 commits into
developfrom
pr/metamask-multichain
Open

feat(wallets): connect MetaMask via multichain#105
towanTG wants to merge 6 commits into
developfrom
pr/metamask-multichain

Conversation

@towanTG

@towanTG towanTG commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Merge GiMa-SwapKit:feat/metamask-multichain onto current origin/develop.
  • Add the MetaMask multichain connector for EVM + Solana and expose/load it for WalletOption.METAMASK.
  • Add focused tests for CAIP scope mapping, the EIP-1193 shim, loadWallet, and user rejection handling.

Validation

  • bun run build:ci
  • bun run type-check:ci
  • bun test
  • bun biome check packages/wallets/src/metamask/index.ts packages/wallets/test/metamask.test.ts packages/wallets/src/types.ts packages/wallets/src/utils.ts packages/sdk/src/index.ts playgrounds/vite-lite/vite.config.ts packages/wallets/package.json

SwapKit and others added 6 commits June 25, 2026 16:15
… + 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants