Skip to content

fix(send): bind send flow chain to selected asset instead of ambient wallet context#8030

Open
clarion-by-cantina[bot] wants to merge 1 commit into
mainfrom
fix/send-chain-bind-to-selected-asset
Open

fix(send): bind send flow chain to selected asset instead of ambient wallet context#8030
clarion-by-cantina[bot] wants to merge 1 commit into
mainfrom
fix/send-chain-bind-to-selected-asset

Conversation

@clarion-by-cantina
Copy link
Copy Markdown

Summary

The web send flow's transaction builder (useDerivedSendInfo) sourced chainId from useMultichainContext(), which resolves to the wallet's active network — not the prefilled asset's chain. When a user opens a send for a chain-A token while the wallet is connected to chain-B, the transaction was built and submitted on chain-B, producing wrong-network native transfers or ERC-20 calls against the chain-A token address on chain-B.

Changes

  • apps/web/src/features/Swap/state/send/hooks.tsx: Derive chainId from inputCurrency.chainId (falling back to multichain context when no asset is selected). Replace useWeb3React().provider with useEthersProvider({ chainId }) to get a chain-specific provider.
  • apps/web/src/features/Swap/state/send/hooks.test.tsx: Add two cross-chain tests verifying that useCreateTransferTransaction receives the asset's chainId (not the ambient wallet chain), and that fallback to multichain context works when no currency is selected.

Impact

Fixes recipient validation, gas estimation, transfer transaction building, and chain-switch guard in useSendCallback to all operate on the correct network when the selected asset differs from the wallet's active chain.

Finding

GIGA-53 — Apex/Bedrock scanner finding with high impact / medium likelihood (confidence 0.91).

Tracking

…wallet context

The send derivation layer used useMultichainContext() to source chainId,
which resolves to the wallet's active network rather than the prefilled
asset's chain. When a user opens send for a chain-A token while the
wallet is on chain-B, the transaction was built and submitted on chain-B.

Derive chainId from inputCurrency.chainId (falling back to multichain
context when no asset is selected) and use useEthersProvider({ chainId })
so that recipient validation, gas estimation, transfer transaction
building, and the chain-switch guard in useSendCallback all operate on
the correct network.

Co-Authored-By: Clarion <noreply@clarion.sh>
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.

1 participant