Skip to content

feat(4173): Send flow with contextual chain selector #13938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 41 commits into
base: feat-4144-per-dapp-updated-from-main-april-7th
Choose a base branch
from

Conversation

EtherWizard33
Copy link
Contributor

@EtherWizard33 EtherWizard33 commented Mar 10, 2025

Description

Send flow to use contextual chain selector, WIP.

Related issues

Contributes to: #13674

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

EtherWizard33 and others added 19 commits February 19, 2025 19:05
…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
@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise team-wallet-ux labels Mar 10, 2025
Copy link
Contributor

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.

@EtherWizard33 EtherWizard33 changed the base branch from main to feat-4144-per-dapp-selected-network-poc-2 March 10, 2025 13:57
@EtherWizard33 EtherWizard33 added No QA Needed Apply this label when your PR does not need any QA effort. and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 10, 2025
@EtherWizard33 EtherWizard33 added No E2E Smoke Needed If the PR does not need E2E smoke test run and removed No QA Needed Apply this label when your PR does not need any QA effort. labels Mar 10, 2025
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
- Move network switch logic inside conditional block in NetworkSelector
- Only update active network when not in send flow context
- Keep network refresh and update logic outside conditional
- Add contextual chain ID logging in Confirm component

This prevents the global network from changing when selecting a network
during the send flow, maintaining transaction context integrity.
@@ -1597,7 +1623,7 @@ Confirm.contextType = ThemeContext;

const mapStateToProps = (state) => {
const transaction = getNormalizedTxState(state);
const chainId = transaction?.chainId;
const chainId = selectSendFlowContextualChainId(state);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the chain id is actually and used to set all state of this component, which is then used when the Confirm button is clicked

…esnt switch global all the time. Note, sending currently only works for linea and mainnet, not for others like arb1
…nent to use the contextual chainId when used in the context of the send flow in order to highlight the the current active network (thecontexual one) among the other network in the list of the NetworkSelector component.
console.log(
'>>> Confirm component - contextualNetworkClientId',
contextualNetworkClientId,
);
let result, transactionMeta;
try {
({ result, transactionMeta } = await TransactionController.addTransaction(
transactionParams,
{
deviceConfirmedOn: WalletDevice.MM_MOBILE,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

networkClientId set from contextual chain id here

… and acountBalance.

In more detail, use the contextual chainId to get the networkConfiguration and ultimately the accountBalance, networkName, and networkImage, for the contextual chain rather than the global chain.
…e first token is still showing global network stuff but the tokens below it in the list look like they are specific to the chain
…ed in the token list and the balance displayed in the addressFrom of the SendTo screen.

In other words, add the ability for the token list displayed in the contextual send-flow, to display the correct native token and balance. Also in the SendFrom compoment used from the send-to component, ensure it displays the balance of the native token for the contextual chain rather than the wallet chain.
…e token balance to be displayed per contextual chain.

In other words, for the displayed balance on the Amount screen, it was using the global chain, it now takes into consideration the contextual chain id which can be used in the send flow.
…ated to take into consideration the contexual chain rather than global chain.
…firmation to validate the amout for the token on the contextual.

In orther words, it is now validating the expected token coming from the expected chain, which is the contextual chain rather than the global chain.
…at-4173-send-flow-with-contextual-chain-selector
(all these changed occured over a long period, now this is from a squashed commit, sicne merging was made impossible since the file was moved without proper git mv)

- Add sendFlowContextualChainId to manage chain context in send flow
- Initialize contextual chain ID with global chain ID on mount
- Update component to use contextual chain ID for address display
- Modify reset behavior to clear contextual chain ID
- Fix relative import paths
- Rename selectEvmChainId to selectChainId
…token balances

   (all these changed occured over a long period, now this is from a squashed commit, sicne merging was made impossible since the file was moved without proper git mv)

- Add network-specific selectors for tokens and balances
- Update token balance handling to be chain-specific
- Add UI improvements for Max button disabled state
- Improve network configuration handling with contextual chain ID
- Add proper cleanup of contextual chain ID on reset
…ID support

       (all these changed occured over a long period, now this is from a squashed commit, since merging was made impossible because the file was moved without proper git mv)

- Replace global network client ID with contextual network client ID for transactions
- Update prop types and state management for transaction metrics
- Add new selectors for tokens, accounts, and network configuration
- Integrate sendFlowContextualChainId for chain-specific operations
- Update transaction validation to use contextual account balances
…duced conflicts and some of them resulted in a bad merge.

This commit fixes chunks of code impacted by the bad merge.
@EtherWizard33 EtherWizard33 changed the base branch from feat-4144-per-dapp-selected-network-poc-2 to main April 25, 2025 18:33
@EtherWizard33 EtherWizard33 changed the base branch from main to feat-4144-per-dapp-selected-network-poc April 25, 2025 18:34
@EtherWizard33 EtherWizard33 changed the base branch from feat-4144-per-dapp-selected-network-poc to feat-4144-per-dapp-updated-from-main-april-7th April 25, 2025 18:35
…rc-20 token other than the native token.

Without this fix, the confirmation screen kept displaying a balance of zero and a caught error,  Error in trying to fetch token balance, could be seen in the logs. While adding the networkClientId fixed didnt throw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No E2E Smoke Needed If the PR does not need E2E smoke test run team-wallet-ux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants