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
Open
fix(send): bind send flow chain to selected asset instead of ambient wallet context#8030clarion-by-cantina[bot] wants to merge 1 commit into
clarion-by-cantina[bot] wants to merge 1 commit into
Conversation
…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>
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
The web send flow's transaction builder (
useDerivedSendInfo) sourcedchainIdfromuseMultichainContext(), 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: DerivechainIdfrominputCurrency.chainId(falling back to multichain context when no asset is selected). ReplaceuseWeb3React().providerwithuseEthersProvider({ chainId })to get a chain-specific provider.apps/web/src/features/Swap/state/send/hooks.test.tsx: Add two cross-chain tests verifying thatuseCreateTransferTransactionreceives the asset'schainId(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
useSendCallbackto 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