Skip to content

feat(4144): per-dapp-selected-networks #14539

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

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ad76b03
feat: Add a temporary picker to test if per-dapp-selected-networks fe…
EtherWizard33 Feb 11, 2025
01a81e0
fix: fix permissisons network switch
salimtb Feb 11, 2025
d878587
style: remove console.logs
EtherWizard33 Feb 11, 2025
82b5521
style: remove console.log from permission summary
EtherWizard33 Feb 11, 2025
fc966a9
style: remove console.log from network selector
EtherWizard33 Feb 11, 2025
9521bf4
feat: remove console.log from chain utils
EtherWizard33 Feb 11, 2025
36a536c
refactor(network): use isPerDappSelectedNetworkEnabled helper
EtherWizard33 Feb 12, 2025
e0b6548
feat(permissions): add interactive favicon with network switching
EtherWizard33 Feb 13, 2025
cadfc88
style(lint): cleanup
EtherWizard33 Feb 13, 2025
27a6e8c
feat: remove temporary network picker from AcounntPermissionsConnecte…
EtherWizard33 Feb 13, 2025
e9e3fba
refactor: Move domain logo container behind per-dapp network feature …
EtherWizard33 Feb 13, 2025
6e17a0b
fix(permission-summary): When the dapp is not yet connected, and the …
EtherWizard33 Feb 13, 2025
e379088
chore: in engine.ts, make use of the local feature flag isMultichainV…
EtherWizard33 Feb 17, 2025
4193532
feat: remove non-permitted network flow check for dapps
EtherWizard33 Feb 26, 2025
4b9210e
feat(AddressFrom): get network info per dapp origin
EtherWizard33 Feb 26, 2025
71ce34d
feat(TransactionReview): pass origin prop to AccountFromToInfoCard
EtherWizard33 Feb 26, 2025
05f6617
Use provided chainId to determine balance in useAddressBalance hook
OGPoyraz Mar 5, 2025
e9f7712
feat: make the chain fallback logic worth in both on and off state of…
EtherWizard33 Mar 13, 2025
c64169c
feat: ensure that when checkActiveAccountAndChainId it checks the per…
EtherWizard33 Mar 24, 2025
3e72ab6
doc: log the transactionMeta for debugging purposes, currently undefined
EtherWizard33 Mar 25, 2025
10f1ed0
fix: per-dapp also gets the request vs dapp chain comparison
EtherWizard33 Mar 26, 2025
a4d8212
fix: pass the network client id in hopes of fixing the stx error when…
EtherWizard33 Apr 1, 2025
8086b32
refactor: use selectEvmNetworkConfigurationsByChainId instead of sele…
EtherWizard33 Apr 7, 2025
bcac90d
wip
pedronfigueiredo Apr 3, 2025
42c5fe0
Switch TransactionDetails usage to transaction specific chainId
EtherWizard33 Apr 7, 2025
fa59824
wip
pedronfigueiredo Apr 4, 2025
72757e0
fix(TransactionNotification): use chain-specific ticker for transacti…
EtherWizard33 Apr 4, 2025
a664c1d
fix: get the ticker using a selector from the component, rather than …
EtherWizard33 Apr 9, 2025
7f69a6a
chore: cleanup debug console.log statements
EtherWizard33 Apr 9, 2025
1c24adf
chore: remove unused imports and console.logs
EtherWizard33 Apr 9, 2025
46e1c0b
Merge branch 'main' into feat-4144-per-dapp-updated-from-main-april-7th
EtherWizard33 Apr 10, 2025
96ab92c
chore: remove redundant ts-expect-error comments
EtherWizard33 Apr 10, 2025
55910b1
fix(smart-public-hook-test): since the networkClientId was added to a…
EtherWizard33 Apr 10, 2025
23f4075
Revert "feat: remove non-permitted network flow check for dapps"
EtherWizard33 Apr 10, 2025
b9db74f
feat(browser): skip network check when per-dapp network selection is …
EtherWizard33 Apr 10, 2025
655f4d0
Use chainId as a second param for selectShouldUseSmartTransaction
dan437 Apr 15, 2025
4c7ef10
Use chainId when calling shouldUseSmartTransaction
dan437 Apr 15, 2025
400d5e7
Always pass a chainId into the shouldUseSmartTransaction selector
dan437 Apr 16, 2025
4633736
Use a globalChainId if transaction.chainId is not there on the Send C…
dan437 Apr 16, 2025
f4e0783
Update the RPC URL check for STX
dan437 Apr 16, 2025
3b787ab
Enable feature flag check for STX
dan437 Apr 16, 2025
0c1449a
fix: remove networks from allowed for dev, they should be enabled loc…
EtherWizard33 Apr 17, 2025
aeaee23
Merge branch 'main' into feat-4144-per-dapp-updated-from-main-april-7th
EtherWizard33 Apr 23, 2025
ebc4726
fix: bad merge in previous commit, first fix
EtherWizard33 Apr 23, 2025
e4e3720
fix(bad-merge): from previous commit, second fix, remove duplicate im…
EtherWizard33 Apr 23, 2025
ecce75e
test(WalletActions): fix the tests that broke following the addtion o…
EtherWizard33 Apr 29, 2025
c59ee43
test(WalletConnectV2): fix the tests that broke following the addtion…
EtherWizard33 Apr 29, 2025
4a8e72b
test(smart-tx-constants): remove networks from allowed for dev, they …
EtherWizard33 Apr 30, 2025
09e5500
test(AccountActions): fix the tests that broke following the addtion …
EtherWizard33 Apr 30, 2025
c613749
test(TransactionDetails): Update one test's mocked NetworkController…
EtherWizard22 Apr 30, 2025
b7cd5b5
test(tx-controller-init): fix the unit test to match what was expected.
EtherWizard22 Apr 30, 2025
6a19d08
test(wc-utils): add missing mock that are now necessary.
EtherWizard22 Apr 30, 2025
6327dd2
Merge branch 'main' into feat-4144-per-dapp-updated-from-main-april-7th
EtherWizard22 May 2, 2025
d44d5e3
Merge branch 'main' into feat-4144-per-dapp-updated-from-main-april-7th
EtherWizard22 May 2, 2025
2981fb1
chore: temp comment
EtherWizard22 May 2, 2025
ca013b7
chore: lint fixes
EtherWizard22 May 2, 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
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
20 changes: 12 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 {
selectEvmNetworkImageSource,
selectEvmNetworkName,
} 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,32 @@ 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(selectEvmNetworkName);
const { networkName, networkImageSource } = useNetworkInfo(origin);

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

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

const accountTypeLabel = getLabelTextByAddress(activeAddress);

Expand All @@ -95,7 +99,7 @@ const AddressFrom = ({
badgeProps={{
variant: BadgeVariant.Network,
name: networkName,
imageSource: networkImage,
imageSource: networkImageSource,
}}
useBlockieIcon={useBlockieIcon}
/>
Expand Down
13 changes: 10 additions & 3 deletions app/components/UI/Notification/TransactionNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { collectibleContractsSelector } from '../../../../reducers/collectibles'
import { useTheme } from '../../../../util/theme';
import {
selectChainId,
selectEvmTicker,
selectTickerByChainId,
} from '../../../../selectors/networkController';
import {
selectConversionRate,
Expand All @@ -36,6 +36,7 @@ import { selectContractExchangeRates } from '../../../../selectors/tokenRatesCon
import { selectAccounts } from '../../../../selectors/accountTrackerController';
import { speedUpTransaction } from '../../../../util/transaction-controller';
import { selectSelectedInternalAccountFormattedAddress } from '../../../../selectors/accountsController';
import { selectCurrentTransactionMetadata } from '../../../../selectors/confirmTransaction';

const WINDOW_WIDTH = Dimensions.get('window').width;
const ACTION_CANCEL = 'cancel';
Expand Down Expand Up @@ -219,7 +220,9 @@ function TransactionNotification(props) {
const tx = transactions.find(
({ id }) => id === currentNotification.transaction.id,
);

if (!tx) return;

const {
selectedAddress,
ticker,
Expand All @@ -234,6 +237,7 @@ function TransactionNotification(props) {
swapsTransactions,
swapsTokens,
} = props;

const [transactionElement, transactionDetails] = await decodeTransaction({
...props,
tx,
Expand Down Expand Up @@ -431,7 +435,7 @@ TransactionNotification.propTypes = {
primaryCurrency: PropTypes.string,
};

const mapStateToProps = (state) => {
const mapStateToProps = (state, ownProps) => {
const chainId = selectChainId(state);

const {
Expand All @@ -445,11 +449,14 @@ const mapStateToProps = (state) => {
chainId
] || [];

const tx = TransactionController.transactions.find(
({ id }) => id === ownProps?.currentNotification.transaction.id,
);
return {
accounts: selectAccounts(state),
selectedAddress: selectSelectedInternalAccountFormattedAddress(state),
transactions: TransactionController.transactions,
ticker: selectEvmTicker(state),
ticker: selectTickerByChainId(state, tx.chainId),
chainId,
tokens: selectTokensByAddress(state),
collectibleContracts: collectibleContractsSelector(state),
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 @@ -51,6 +54,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 @@ -84,7 +93,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 @@ -115,12 +124,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 @@ -370,7 +429,7 @@ const PermissionsSummary = ({
</TextComponent>
<TextComponent variant={TextVariant.BodySMMedium}>
{isNonDappNetworkSwitch
? networkInfo?.networkName || providerConfig.nickname
? networkName || providerConfig.nickname
: chainName}
</TextComponent>
</TextComponent>
Expand All @@ -380,7 +439,7 @@ const PermissionsSummary = ({
size={AvatarSize.Xs}
name={
isNonDappNetworkSwitch
? networkInfo?.networkName || providerConfig.nickname
? networkName || providerConfig.nickname
: chainName
}
imageSource={
Expand Down
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 @@ -59,6 +59,7 @@ const TabThumbnail = ({
(account) => account.address.toLowerCase() === activeAddress?.toLowerCase(),
);
const { networkName, networkImageSource } = useNetworkInfo(tabTitle);

const faviconSource = useFavicon(tab.url);

return (
Expand Down
Loading
Loading