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
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
988bdf1
feat: Add a temporary picker to test if per-dapp-selected-networks fe…
EtherWizard33 Feb 11, 2025
84a8171
fix: fix permissisons network switch
salimtb Feb 11, 2025
21bc3a2
style: remove console.logs
EtherWizard33 Feb 11, 2025
421fc5c
style: remove console.log from permission summary
EtherWizard33 Feb 11, 2025
ae28079
style: remove console.log from network selector
EtherWizard33 Feb 11, 2025
b82b7ac
feat: remove console.log from chain utils
EtherWizard33 Feb 11, 2025
dd41af7
refactor(network): use isPerDappSelectedNetworkEnabled helper
EtherWizard33 Feb 12, 2025
bd097ce
feat(permissions): add interactive favicon with network switching
EtherWizard33 Feb 13, 2025
5c02c47
style(lint): cleanup
EtherWizard33 Feb 13, 2025
339d998
feat: remove temporary network picker from AcounntPermissionsConnecte…
EtherWizard33 Feb 13, 2025
ae30f01
refactor: Move domain logo container behind per-dapp network feature …
EtherWizard33 Feb 13, 2025
1aa5cc5
fix(permission-summary): When the dapp is not yet connected, and the …
EtherWizard33 Feb 13, 2025
e7fa261
chore: in engine.ts, make use of the local feature flag isMultichainV…
EtherWizard33 Feb 17, 2025
2589252
Merge branch 'main' into feat-4144-per-dapp-selected-network-poc-2
EtherWizard33 Feb 24, 2025
f49d889
feat: remove non-permitted network flow check for dapps
EtherWizard33 Feb 26, 2025
3c2de6e
feat(AddressFrom): get network info per dapp origin
EtherWizard33 Feb 26, 2025
f6783d3
feat(TransactionReview): pass origin prop to AccountFromToInfoCard
EtherWizard33 Feb 26, 2025
f3dfe54
Use provided chainId to determine balance in useAddressBalance hook
OGPoyraz Mar 5, 2025
9a035d6
feat: enable network selector in send flow recipient screen, show dis…
EtherWizard33 Mar 10, 2025
029c8c6
feat: track network switches from send flow
EtherWizard33 Mar 10, 2025
d27e30f
feat: track contextual chain id for send flow
EtherWizard33 Mar 10, 2025
d576e9d
refactor(send-flow): move contextual chain ID state to networkSelecto…
EtherWizard33 Mar 12, 2025
2bd90ef
feat(send-flow): prevent network switch during send flow
EtherWizard33 Mar 12, 2025
33a2d67
feat: use contextual chain if set, and adjust onSetRpcTarget so it do…
EtherWizard33 Mar 20, 2025
0386876
feat(contextual-send-flow): display the contextual send flow in the h…
EtherWizard33 Apr 14, 2025
2b6fb0b
feat(selected-network): add the ability for the NetworkSelector compo…
EtherWizard33 Apr 14, 2025
9deebb8
feat(get-gas-limit): get the gas limit for the contextual networkClie…
EtherWizard33 Apr 15, 2025
fba46ec
feat(get-gas-limit): for the confirm screen get the contextual client…
EtherWizard33 Apr 15, 2025
2e8dd51
feat(send-flow): use the contextual chainId to get networkName, image…
EtherWizard33 Apr 17, 2025
cf77c14
chore: cleanup consol.logs
EtherWizard33 Apr 17, 2025
978147d
feat: improve the assets modal, the getEther(ticker) which renders th…
EtherWizard33 Apr 18, 2025
921ac12
feat(send-flow-with-contextual-network): fix the native token display…
EtherWizard33 Apr 22, 2025
4c0ac75
feat(send-flow-balance): on the Amount screen, add the ability for th…
EtherWizard33 Apr 23, 2025
fddfbad
feat(send-flow-validate-amount): add the ability for the amount valid…
EtherWizard33 Apr 23, 2025
d0d5af9
feat(send-flow-validate-amout): add the ability for the send-flow con…
EtherWizard33 Apr 23, 2025
2bdf568
Merge branch 'feat-4144-per-dapp-updated-from-main-april-7th' into fe…
EtherWizard33 Apr 24, 2025
a88807a
feat(SendTo): add contextual chain ID support
EtherWizard33 Apr 24, 2025
f311a50
refactor(Amount): update Amount component to handle network-specific …
EtherWizard33 Apr 24, 2025
d77cec3
refactor(Confirm): update transaction handling with contextual chain …
EtherWizard33 Apr 24, 2025
8a2ed80
fix(send-flow): the previous merge commit and following commits intro…
EtherWizard33 Apr 25, 2025
56149d0
feat(Confirm-balance): add the ability to display the balance of an e…
EtherWizard33 Apr 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/actions/transaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,13 @@ export function setTransactionValue(value) {
value,
};
}

export const SET_TRANSACTION_SEND_FLOW_CONTEXTUAL_CHAIN_ID =
'SET_TRANSACTION_SEND_FLOW_CONTEXTUAL_CHAIN_ID';

export function setTransactionSendFlowContextualChainId(chainId) {
return {
type: SET_TRANSACTION_SEND_FLOW_CONTEXTUAL_CHAIN_ID,
chainId,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ const AccountFromToInfoCard = (props: AccountFromToInfoCardProps) => {
return (
<View style={styles.container}>
{fromAddress && (
<AddressFrom asset={selectedAsset} from={fromAddress} origin={origin} />
<AddressFrom
chainId={transactionState?.chainId}
asset={selectedAsset}
from={fromAddress}
origin={origin}
/>
)}
{existingToAddress === undefined && confusableCollection.length ? (
<TouchableOpacity onPress={() => setShowWarningModal(true)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Transaction {
transactionFromName: string;
selectedAsset: SelectedAsset;
ensRecipient?: string;
chainId?: string;
}

export interface AccountFromToInfoCardProps {
Expand Down
17 changes: 9 additions & 8 deletions app/components/UI/AccountFromToInfoCard/AddressFrom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import { BadgeVariant } from '../../../component-library/components/Badges/Badge
import Text from '../../../component-library/components/Texts/Text';
import { useStyles } from '../../../component-library/hooks';
import { selectAccountsByChainId } from '../../../selectors/accountTrackerController';
import {
selectNetworkImageSource,
selectNetworkName,
} from '../../../selectors/networkInfos';
import {
getLabelTextByAddress,
renderAccountName,
} from '../../../util/address';
import useAddressBalance from '../../hooks/useAddressBalance/useAddressBalance';
import stylesheet from './AddressFrom.styles';
import { selectInternalAccounts } from '../../../selectors/accountsController';
import { useNetworkInfo } from '../../../selectors/selectedNetworkController';

interface Asset {
isETH?: boolean;
Expand All @@ -37,25 +34,29 @@ interface AddressFromProps {
dontWatchAsset?: boolean;
from: string;
origin?: string;
chainId?: string;
}

const AddressFrom = ({
asset,
chainId,
dontWatchAsset,
from,
origin,
}: AddressFromProps) => {
const [accountName, setAccountName] = useState('');

const { styles } = useStyles(stylesheet, {});
const { addressBalance } = useAddressBalance(asset, from, dontWatchAsset);
const { addressBalance } = useAddressBalance(asset, from, dontWatchAsset, chainId);

const accountsByChainId = useSelector(selectAccountsByChainId);

const internalAccounts = useSelector(selectInternalAccounts);
const activeAddress = toChecksumAddress(from);

const networkName = useSelector(selectNetworkName);
// FIXME: this could be the wrong selector, probably needs to be per dapp (per origin)
// console.log('>>> AddressFrom origin', origin);
const { networkName, networkImageSource } = useNetworkInfo(origin);

const useBlockieIcon = useSelector(
// TODO: Replace "any" with type
Expand All @@ -74,7 +75,7 @@ const AddressFrom = ({
}
}, [accountsByChainId, internalAccounts, activeAddress, origin]);

const networkImage = useSelector(selectNetworkImageSource);
// const networkImage = useSelector(selectNetworkImageSource);

const accountTypeLabel = getLabelTextByAddress(activeAddress);

Expand All @@ -95,7 +96,7 @@ const AddressFrom = ({
badgeProps={{
variant: BadgeVariant.Network,
name: networkName,
imageSource: networkImage,
imageSource: networkImageSource,
}}
useBlockieIcon={useBlockieIcon}
/>
Expand Down
13 changes: 12 additions & 1 deletion app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ export function getSendFlowTitle(
themeColors,
resetTransaction,
transaction,
disableNetwork = true,
showSelectedNetwork = false,
sendFlowContextualChainId = '',
) {
const innerStyles = StyleSheet.create({
headerButtonText: {
Expand Down Expand Up @@ -594,7 +597,15 @@ export function getSendFlowTitle(
const titleToRender = title;

return {
headerTitle: () => <NavbarTitle title={titleToRender} disableNetwork />,
headerTitle: () => (
<NavbarTitle
title={titleToRender}
disableNetwork={disableNetwork}
showSelectedNetwork={showSelectedNetwork}
networkName={sendFlowContextualChainId}
source="SendFlow"
/>
),
headerRight: () => (
// eslint-disable-next-line react/jsx-no-bind
<TouchableOpacity
Expand Down
9 changes: 9 additions & 0 deletions app/components/UI/NavbarTitle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class NavbarTitle extends PureComponent {
* Content to display inside text element
*/
children: PropTypes.node,
/**
* Source of the network selector
*/
source: PropTypes.string,
};

static defaultProps = {
Expand All @@ -86,13 +90,18 @@ class NavbarTitle extends PureComponent {
this.animating = true;
this.props.navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.NETWORK_SELECTOR,
params: {
source: this.props.source,
},
});

this.props.metrics.trackEvent(
this.props.metrics
.createEventBuilder(MetaMetricsEvents.NETWORK_SELECTOR_PRESSED)
.addProperties({
// TODO: if contextual chainId is used, the providerConfig is the chain needed for this tracking
chain_id: getDecimalChainId(this.props.providerConfig.chainId),
source: this.props.source,
})
.build(),
);
Expand Down
69 changes: 64 additions & 5 deletions app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import Routes from '../../../constants/navigation/Routes';
import ButtonIcon, {
ButtonIconSizes,
} from '../../../component-library/components/Buttons/ButtonIcon';
import { getNetworkImageSource } from '../../../util/networks';
import {
getNetworkImageSource,
isPerDappSelectedNetworkEnabled,
} from '../../../util/networks';
import Engine from '../../../core/Engine';
import { SDKSelectorsIDs } from '../../../../e2e/selectors/Settings/SDK.selectors';
import { useSelector } from 'react-redux';
Expand All @@ -48,6 +51,12 @@ import { useNetworkInfo } from '../../../selectors/selectedNetworkController';
import { ConnectedAccountsSelectorsIDs } from '../../../../e2e/selectors/Browser/ConnectedAccountModal.selectors';
import { PermissionSummaryBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Browser/PermissionSummaryBottomSheet.selectors';
import { NetworkNonPemittedBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Network/NetworkNonPemittedBottomSheet.selectors';
import BadgeWrapper from '../../../component-library/components/Badges/BadgeWrapper';
import Badge, {
BadgeVariant,
} from '../../../component-library/components/Badges/Badge';
import AvatarFavicon from '../../../component-library/components/Avatars/Avatar/variants/AvatarFavicon';
import AvatarToken from '../../../component-library/components/Avatars/Avatar/variants/AvatarToken';

const PermissionsSummary = ({
currentPageInformation,
Expand Down Expand Up @@ -80,7 +89,7 @@ const PermissionsSummary = ({
() => new URL(currentPageInformation.url).hostname,
[currentPageInformation.url],
);
const networkInfo = useNetworkInfo(hostname);
const { networkName, networkImageSource } = useNetworkInfo(hostname);

// if network switch, we get the chain name from the customNetworkInformation
let chainName = '';
Expand Down Expand Up @@ -111,12 +120,62 @@ const PermissionsSummary = ({
onEditNetworks?.();
};

const switchNetwork = useCallback(() => {
navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.NETWORK_SELECTOR,
});
}, [navigate]);

const renderTopIcon = () => {
const { currentEnsName, icon } = currentPageInformation;
const url = currentPageInformation.url;
const iconTitle = getHost(currentEnsName || url);

return (
if (!isAlreadyConnected) {
return (
<WebsiteIcon
style={styles.domainLogoContainer}
viewStyle={styles.assetLogoContainer}
title={iconTitle}
url={currentEnsName || url}
icon={typeof icon === 'string' ? icon : icon?.uri}
/>
);
}

return isPerDappSelectedNetworkEnabled() ? (
<View style={[styles.domainLogoContainer, styles.assetLogoContainer]}>
<TouchableOpacity
onPress={switchNetwork}
testID={ConnectedAccountsSelectorsIDs.NETWORK_PICKER}
>
<BadgeWrapper
badgeElement={
<Badge
variant={BadgeVariant.Network}
name={networkName}
imageSource={networkImageSource}
/>
}
>
{icon ? (
<AvatarFavicon
imageSource={{
uri: typeof icon === 'string' ? icon : icon?.uri,
}}
size={AvatarSize.Md}
/>
) : (
<AvatarToken
name={iconTitle}
isHaloEnabled
size={AvatarSize.Md}
/>
)}
</BadgeWrapper>
</TouchableOpacity>
</View>
) : (
<WebsiteIcon
style={styles.domainLogoContainer}
viewStyle={styles.assetLogoContainer}
Expand Down Expand Up @@ -361,7 +420,7 @@ const PermissionsSummary = ({
</TextComponent>
<TextComponent variant={TextVariant.BodySMMedium}>
{isNonDappNetworkSwitch
? networkInfo?.networkName || providerConfig.nickname
? networkName || providerConfig.nickname
: chainName}
</TextComponent>
</TextComponent>
Expand All @@ -371,7 +430,7 @@ const PermissionsSummary = ({
size={AvatarSize.Xs}
name={
isNonDappNetworkSwitch
? networkInfo?.networkName || providerConfig.nickname
? networkName || providerConfig.nickname
: chainName
}
imageSource={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface PermissionsSummaryProps {
accounts?: Account[];
accountAddresses?: string[];
networkAvatars?: ({ name: string; imageSource: string } | null)[];
// TODO: remove isNonDappNetworkSwitch prop once the per-dapp network switch is implemented
isNonDappNetworkSwitch?: boolean;
onChooseFromPermittedNetworks?: () => void;
}
1 change: 1 addition & 0 deletions app/components/UI/Tabs/TabThumbnail/TabThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const TabThumbnail = ({
(account) => account.address.toLowerCase() === activeAddress?.toLowerCase(),
);
const { networkName, networkImageSource } = useNetworkInfo(tabTitle);

const faviconSource = useFavicon(tab.url);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface AccountPermissionsProps {
};
isRenderedAsBottomSheet?: boolean;
initialScreen?: AccountPermissionsScreens;
// TODO: remove isNonDappNetworkSwitch prop once the per-dapp network switch is implemented
isNonDappNetworkSwitch?: boolean;
};
};
Expand Down
Loading
Loading