Skip to content

Commit

Permalink
chore: cherry-pick to asset picker network commit
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Aug 28, 2024
1 parent 021800c commit cdfa820
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ import {
Modal,
Box,
} from '../../../component-library';
import {
CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP,
RPCDefinition,
} from '../../../../../shared/constants/network';
import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP } from '../../../../../shared/constants/network';
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
import { useI18nContext } from '../../../../hooks/useI18nContext';
///: END:ONLY_INCLUDE_IF
import { NetworkListItem } from '../../network-list-item';
import { getAllNetworks } from '../../../../selectors';
import { getNetworkConfigurations } from '../../../../selectors';
import { getProviderConfig } from '../../../../ducks/metamask/metamask';

/**
Expand All @@ -47,8 +44,8 @@ export const AssetPickerModalNetwork = ({
}: {
isOpen: boolean;
network?: ProviderConfig;
networks?: (ProviderConfig | RPCDefinition)[];
onNetworkChange: (network: ProviderConfig | RPCDefinition) => void;
networks?: ProviderConfig[];
onNetworkChange: (network: ProviderConfig) => void;
onClose: () => void;
onBack: () => void;
}) => {
Expand All @@ -57,8 +54,7 @@ export const AssetPickerModalNetwork = ({
///: END:ONLY_INCLUDE_IF

const currentNetwork = useSelector(getProviderConfig);
const allNetworks: (ProviderConfig | RPCDefinition)[] =
useSelector(getAllNetworks);
const allNetworks: ProviderConfig[] = useSelector(getNetworkConfigurations);

const selectedNetwork: ProviderConfig = network ?? currentNetwork;
const networksList = networks ?? allNetworks ?? [];
Expand Down Expand Up @@ -98,7 +94,7 @@ export const AssetPickerModalNetwork = ({
iconSrc={
networkConfig?.rpcPrefs &&
'imageUrl' in networkConfig.rpcPrefs
? networkConfig.rpcPrefs.imageUrl
? (networkConfig.rpcPrefs.imageUrl as string)
: CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[
networkConfig.chainId as keyof typeof CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import { getTopAssets } from '../../../../ducks/swaps/swaps';
import { getRenderableTokenData } from '../../../../hooks/useTokensToSearch';
import { getSwapsBlockedTokens } from '../../../../ducks/send';
import { isEqualCaseInsensitive } from '../../../../../shared/modules/string-utils';
import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP } from '../../../../../shared/constants/network';
import {
ERC20Asset,
NativeAsset,
Expand Down Expand Up @@ -327,16 +326,14 @@ export function AssetPickerModal({
</Text>
</Box>
)}
{network && onNetworkPickerClick && (
{onNetworkPickerClick && (
<Box className="network-picker">
<PickerNetwork
label={network.nickname ?? 'Select network'}
label={network?.nickname ?? 'Select network'}
src={
network?.rpcPrefs && 'imageUrl' in network.rpcPrefs
? (network.rpcPrefs.imageUrl as string)
: CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[
network.chainId as keyof typeof CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP
]
: undefined
}
onClick={onNetworkPickerClick}
data-testid="multichain-asset-picker__network"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function AssetPicker({
setShowAssetPickerModal(false);
}}
sendingAsset={sendingAsset}
network={networkProps ? networkProps.network : undefined}
network={networkProps?.network ? networkProps.network : undefined}
onNetworkPickerClick={() => {
setShowAssetPickerModal(false);
setIsSelectingNetwork(true);
Expand Down

0 comments on commit cdfa820

Please sign in to comment.