feat(4173): Send flow with contextual chain selector#13938
Conversation
…ature can work when its feature flags are enabled make sure to include all env vars: export MM_MULTICHAIN_V1_ENABLED="true" export MM_CHAIN_PERMISSIONS="true" export MM_PER_DAPP_SELECTED_NETWORK="1" export MULTICHAIN_V1="true"
- Replace direct checks of process.env.MM_PER_DAPP_SELECTED_NETWORK in AccountPermissionsConnected.tsx with the isPerDappSelectedNetworkEnabled function. - Update ethereum-chain-utils.js to use isPerDappSelectedNetworkEnabled when switching networks. - Modify selectedNetworkController selectors to use isPerDappSelectedNetworkEnabled for feature flag checks. - Add the isPerDappSelectedNetworkEnabled utility in util/networks/index.js. This change centralizes the per-DApp network logic for better consistency and maintainability.
Add a touchable favicon to the permission summary header that enables network switching for dapps. This combines the dapp's identity (favicon/token) with network selection in a single interactive component. - Replace static WebsiteIcon with touchable BadgeWrapper pattern - Add network badge to indicate current network - Enable network switching via network selector bottom sheet - Add fallback to AvatarToken when favicon unavailable - Guard implementation behind per-dapp network selection feature flag - Preserve original WebsiteIcon when feature disabled This matches the interaction pattern from AccountPermissionsConnected, providing a consistent way to manage dapp-specific networks across the app.
…flag The domain logo container view was incorrectly placed outside the per-dapp network feature flag check. This change moves the container view inside the feature flag condition to ensure consistent UI behavior when the feature is enabled/disabled. - Moved View wrapper inside isPerDappSelectedNetworkEnabled() check - Simplified conditional rendering logic - Maintains existing functionality but with proper feature flag control
…permission sumamry is displayed, keep showing the WebsiteIcon rather than the AvatarFavicon.
…1Enabled rather than its 'corresponding' env variable MULTICHAIN_V1
Remove the permission check for non-permitted network flows in dapps, paving the way for the per-dapp-selected-network feature. Temporary screens handling these flows are pending removal upon feature completion.
- Replace global network selectors with origin-specific useNetworkInfo hook - Update network name and image source to be origin-aware - Update test snapshot for network name changes
- Add origin prop to AccountFromToInfoCard for per-dapp network info - Add debug logs for transaction review flow
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
This commit: - Adds redux state to track chain ID specifically in send flow context - Dispatches chain ID updates when switching networks from send flow - Adds selector and logging to monitor contextual chain ID changes - Only tracks chain ID when network selector is used from send flow
…r reducer - Move contextual chain ID from transaction to networkSelector reducer - Update selectors to read from new location - Add debug logging for state transitions - Reset contextual chain ID when canceling transaction - Initialize contextual chain ID in SendTo component - Display network name in navbar using contextual chain ID BREAKING CHANGE: sendFlowContextualChainId moved from transaction to networkSelector reducer
…4173-send-flow-with-contextual-chain-selector
|
…4173-send-flow-with-contextual-chain-selector
Prithpal-Sooriya
left a comment
There was a problem hiding this comment.
Changes look okay, some minor nit comments which I'll polish up.
I'll also try to get the code coverage higher.
| const hexChainId = useMemo( | ||
| () => (chainId ? toHex(chainId) : null), | ||
| [chainId], | ||
| ); |
There was a problem hiding this comment.
Bug: Hexadecimal Strings Passed to Conversion Functions
The chainId and contextualChainId variables, which are already in hexadecimal format, are incorrectly passed to conversion functions like toHex() and toHexadecimal(). These functions expect a number or decimal string, not an already hex-formatted string, which can lead to conversion errors or unexpected behavior.
Additional Locations (1)
…4173-send-flow-with-contextual-chain-selector
…github.com:MetaMask/metamask-mobile into feat-4173-send-flow-with-contextual-chain-selector
|
| isContextualNetworkEnabled, | ||
| sendFlowNetworkData, | ||
| globalNetworkImage, | ||
| ]); |
There was a problem hiding this comment.
NIT: we can make dependency more specific here like perDappNetworkInfo.networkImageSource, sendFlowNetworkData.imageSource .
There was a problem hiding this comment.
Good catch, let me refactor that now
| // The line `!isContextualChainId && renderNonEvmNetworks(false)` should be tested to ensure: | ||
| // 1. Non-EVM networks render when isContextualChainId is false (source != SEND_FLOW || no contextual chain ID) | ||
| // 2. Non-EVM networks do NOT render when isContextualChainId is true (source == SEND_FLOW && contextual chain ID exists) | ||
| // This requires complex mocking of selectors that causes import chain issues |
There was a problem hiding this comment.
NIT: is this todo to be merged to main ?
There was a problem hiding this comment.
Ah yes, this needs to be removed. Will do so here in a moment
jpuri
left a comment
There was a problem hiding this comment.
Great work, code changes look good 👍
|
There was a problem hiding this comment.
Bug: Network Mismatch in Contextual Send Flow
When the "Remove Global Network Selector" (contextual send flow) feature is enabled, AccountFromToInfoCard computes the correct chainId (contextual or global) but fails to pass it to AddressFrom. The AddressFrom component still receives an incorrect or undefined chainId because the prop is gated by isPerDappSelectedNetworkEnabled(). This leads to AddressFrom displaying the wrong network name/icon and balances on the confirm screen. The computed chainId should be passed to AddressFrom when the contextual feature is enabled.
app/components/UI/AccountFromToInfoCard/AccountFromToInfoCard.tsx#L183-L207
app/components/UI/AccountFromToInfoCard/AccountFromToInfoCard.tsx#L30-L50
|
Sonar cloud coverage is skipped as we've added a decent amount of tests and coverage. |
|
There was a problem hiding this comment.
Bug: Contextual Chain ID Not Passed to Address Component
When the contextual send flow is enabled (isRemoveGlobalNetworkSelectorEnabled), the AccountFromToInfoCard component computes a contextual chainId. However, this computed chainId is not passed to the AddressFrom component. AddressFrom consequently falls back to using the global chainId (based on isPerDappSelectedNetworkEnabled logic), causing the 'From' card to display the global network name and balance instead of the contextual network's information.
app/components/UI/AccountFromToInfoCard/AccountFromToInfoCard.tsx#L46-L50
app/components/UI/AccountFromToInfoCard/AccountFromToInfoCard.tsx#L159-L179
| : undefined | ||
| } | ||
| /> | ||
| ), |
There was a problem hiding this comment.
Bug: Navbar Displays Hex Instead of Network Name
The getSendFlowTitle function has two issues:
- It passes
sendFlowContextualChainId(a hex chain ID) as thenetworkNameprop toNavbarTitle. WhenshowSelectedNetworkis enabled, this incorrectly displays the hex chain ID instead of a human-readable network name in the header. - It uses
isRemoveGlobalNetworkSelectorEnabled()without importing the function, which will cause aReferenceErroror runtime crash.
| accounts: selectAccounts(state), | ||
| contractExchangeRates: selectContractExchangeRatesByChainId(state, chainId), | ||
| contractBalances: selectContractBalances(state), | ||
| contractBalancesByChainId: selectContractBalancesByContextualChainId(state), |
There was a problem hiding this comment.
Bug: Global Chain ID Misused in Send Flow
On the Confirm screen, when isRemoveGlobalNetworkSelectorEnabled is true, mapStateToProps incorrectly derives conversionRate, contractExchangeRates, ticker, and providerType using the global chainId instead of the sendFlowContextualChainId. This results in incorrect fiat conversions and network metadata being displayed.
| const currentNetworkClientId = isRemoveGlobalNetworkSelectorEnabled() | ||
| ? NetworkController.findNetworkClientIdByChainId(chainId) || | ||
| globalNetworkClientId | ||
| : globalNetworkClientId; |
There was a problem hiding this comment.
Bug: Network Selector Uses Incorrect Chain ID
When the contextual network selector feature is enabled, the addTransaction call in the Confirm component incorrectly derives the networkClientId from the global chainId instead of the sendFlowContextualChainId. This can result in transactions being submitted on the wrong network. The networkClientId should be resolved from the contextual chain configuration (e.g., sendFlowContextualNetworkConfiguration), similar to how getGasLimit is handled.
|
|
Hi @EtherWizard33, on the day following Author validation checklist
PM validation checklist
|


Description
This PR introduces contextual chain selection to the send flow, moving away from the global network selector pattern to enable users to select networks specifically within the context of sending assets. This change allows users to filter and send assets based on their chosen chain without affecting the global application state.
Changelog
CHANGELOG entry: Added contextual network selector in send flow
Related issues
Contributes to: #13674
Manual testing steps
Screenshots/Recordings
Before
NA
After
NA
Pre-merge author checklist
Pre-merge reviewer checklist