Skip to content

Commit

Permalink
Fix: fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Nov 21, 2024
1 parent 3310074 commit ef4f2aa
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
12 changes: 11 additions & 1 deletion ui/components/app/assets/asset-list/asset-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getAllDetectedTokensForSelectedAddress,
getDetectedTokensInCurrentNetwork,
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
getNetworkConfigurationsByChainId,
getPreferences,
getSelectedAccount,
} from '../../../../selectors';
Expand Down Expand Up @@ -77,8 +78,17 @@ const AssetList = ({ onClickAsset, showTokensLinks }: AssetListProps) => {
const isTokenDetectionInactiveOnNonMainnetSupportedNetwork = useSelector(
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
);

const allNetworks = useSelector(getNetworkConfigurationsByChainId);
const { tokenNetworkFilter } = useSelector(getPreferences);
const allNetworksFilterShown = Object.keys(tokenNetworkFilter ?? {}).length;
const allOpts: Record<string, boolean> = {};
Object.keys(allNetworks || {}).forEach((chainId) => {
allOpts[chainId] = true;
});

const allNetworksFilterShown =
Object.keys(tokenNetworkFilter || {}).length !==
Object.keys(allOpts || {}).length;

const [showFundingMethodModal, setShowFundingMethodModal] = useState(false);
const [showReceiveModal, setShowReceiveModal] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getCurrentChainId,
getCurrentNetwork,
getDetectedTokensInCurrentNetwork,
getNetworkConfigurationsByChainId,
getPreferences,
} from '../../../../selectors';

Expand All @@ -37,8 +38,16 @@ const DetectedTokenSelectionPopover = ({
const chainId = useSelector(getCurrentChainId);

const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const allNetworks = useSelector(getNetworkConfigurationsByChainId);
const { tokenNetworkFilter } = useSelector(getPreferences);
const allNetworksFilterShown = Object.keys(tokenNetworkFilter ?? {}).length;
const allOpts = {};
Object.keys(allNetworks || {}).forEach((networkId) => {
allOpts[networkId] = true;
});

const allNetworksFilterShown =
Object.keys(tokenNetworkFilter || {}).length !==
Object.keys(allOpts || {}).length;

const currentNetwork = useSelector(getCurrentNetwork);

Expand Down
14 changes: 10 additions & 4 deletions ui/components/app/detected-token/detected-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
getAllDetectedTokensForSelectedAddress,
);
const currentChainId = useSelector(getCurrentChainId);
const allNetworks = useSelector(getNetworkConfigurationsByChainId);
const { tokenNetworkFilter } = useSelector(getPreferences);
const allNetworksFilterShown = Object.keys(tokenNetworkFilter ?? {}).length;
const allOpts = {};
Object.keys(allNetworks || {}).forEach((chainId) => {
allOpts[chainId] = true;
});

const configuration = useSelector(getNetworkConfigurationsByChainId);
const allNetworksFilterShown =
Object.keys(tokenNetworkFilter || {}).length !==
Object.keys(allOpts || {}).length;

const totalDetectedTokens = useMemo(() => {
return process.env.PORTFOLIO_VIEW && !allNetworksFilterShown
Expand Down Expand Up @@ -148,7 +154,7 @@ const DetectedToken = ({ setShowDetectedTokens }) => {

const importPromises = Object.entries(tokensByChainId).map(
async ([networkId, { tokens }]) => {
const chainConfig = configuration[networkId];
const chainConfig = allNetworks[networkId];
const { defaultRpcEndpointIndex } = chainConfig;
const { networkClientId: networkInstanceId } =
chainConfig.rpcEndpoints[defaultRpcEndpointIndex];
Expand Down Expand Up @@ -202,7 +208,7 @@ const DetectedToken = ({ setShowDetectedTokens }) => {

const promises = Object.entries(groupedByChainId).map(
async ([chainId, tokens]) => {
const chainConfig = configuration[chainId];
const chainConfig = allNetworks[chainId];
const { defaultRpcEndpointIndex } = chainConfig;
const { networkClientId: networkInstanceId } =
chainConfig.rpcEndpoints[defaultRpcEndpointIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getPreferences,
getSelectedInternalAccount,
getAllDetectedTokens,
getNetworkConfigurationsByChainId,
} from '../../../selectors';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
Expand All @@ -26,9 +27,16 @@ export const DetectedTokensBanner = ({
}) => {
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const allNetworks = useSelector(getNetworkConfigurationsByChainId);
const { tokenNetworkFilter } = useSelector(getPreferences);
const allOpts = {};
Object.keys(allNetworks || {}).forEach((chainId) => {
allOpts[chainId] = true;
});

const allNetworksFilterShown = Object.keys(tokenNetworkFilter ?? {}).length;
const allNetworksFilterShown =
Object.keys(tokenNetworkFilter || {}).length !==
Object.keys(allOpts || {}).length;

const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const { address: selectedAddress } = useSelector(getSelectedInternalAccount);
Expand Down Expand Up @@ -58,7 +66,7 @@ export const DetectedTokensBanner = ({
? Object.values(detectedTokensMultichain)
.flat()
.map(({ address, symbol }) => `${symbol} - ${address}`)
: detectedTokens.map(({ address, symbol }) => `${symbol} - ${address}`);
: detectedTokens?.map(({ address, symbol }) => `${symbol} - ${address}`);

const totalTokens =
process.env.PORTFOLIO_VIEW && !allNetworksFilterShown
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4975,7 +4975,7 @@ __metadata:

"@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A44.1.0#~/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch":
version: 44.1.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A44.1.0#~/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch::version=44.1.0&hash=611d79"
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A44.1.0#~/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch::version=44.1.0&hash=423db2"
dependencies:
"@ethereumjs/util": "npm:^8.1.0"
"@ethersproject/abi": "npm:^5.7.0"
Expand Down Expand Up @@ -5008,7 +5008,7 @@ __metadata:
"@metamask/keyring-controller": ^18.0.0
"@metamask/network-controller": ^22.0.0
"@metamask/preferences-controller": ^14.0.0
checksum: 10/6927a6af16d6e83a488a3f82e71fbf78b016728009672df12937411cfe7fa087bef34fd2642e04e2038c0baba91d64b9315c54800059e8dddeb31a06ebf25e1e
checksum: 10/5e3b0109e6b5c0d65338a18b2c590d15229003e05c55cf0013d8e32687bbe774de05872a7b61038aa90177a6ce01b32814c3c680ee3c10cbad8cba9db2d796aa
languageName: node
linkType: hard

Expand Down

0 comments on commit ef4f2aa

Please sign in to comment.