diff --git a/@shared/api/helpers/getIconUrlFromIssuer.ts b/@shared/api/helpers/getIconUrlFromIssuer.ts index dfa26dd340..fb5f2fa0de 100644 --- a/@shared/api/helpers/getIconUrlFromIssuer.ts +++ b/@shared/api/helpers/getIconUrlFromIssuer.ts @@ -42,7 +42,7 @@ export const getIconUrlFromIssuer = async ({ try { /* First, check our localStorage cache in Background to see if we've found this url before */ ({ iconUrl } = await sendMessageToBackground({ - assetCode: code, + assetCanonical: `${code}:${key}`, type: SERVICE_TYPES.GET_CACHED_ASSET_ICON, })); if (iconUrl) { @@ -88,7 +88,7 @@ export const getIconUrlFromIssuer = async ({ iconUrl = image; /* And also save into the cache to prevent having to do this process again */ await sendMessageToBackground({ - assetCode: code, + assetCanonical: `${code}:${key}`, iconUrl, type: SERVICE_TYPES.CACHE_ASSET_ICON, }); diff --git a/@shared/api/internal.ts b/@shared/api/internal.ts index ac5ebcc51f..a194e66777 100644 --- a/@shared/api/internal.ts +++ b/@shared/api/internal.ts @@ -322,7 +322,7 @@ export const getAssetIcons = async ({ } = token; // eslint-disable-next-line no-await-in-loop icon = await getIconUrlFromIssuer({ key, code, networkDetails }); - assetIcons[code] = icon; + assetIcons[`${code}:${key}`] = icon; } } } @@ -343,7 +343,7 @@ export const retryAssetIcon = async ({ const newAssetIcons = { ...assetIcons }; try { await sendMessageToBackground({ - assetCode: code, + assetCanonical: `${code}:${key}`, iconUrl: null, type: SERVICE_TYPES.CACHE_ASSET_ICON, }); @@ -351,7 +351,7 @@ export const retryAssetIcon = async ({ return assetIcons; } const icon = await getIconUrlFromIssuer({ key, code, networkDetails }); - newAssetIcons[code] = icon; + newAssetIcons[`${code}:${key}`] = icon; return newAssetIcons; }; diff --git a/@shared/api/types.ts b/@shared/api/types.ts index 7b259c557a..3af59cccdd 100644 --- a/@shared/api/types.ts +++ b/@shared/api/types.ts @@ -34,6 +34,7 @@ export interface Response { allAccounts: Array; accountName: string; assetCode: string; + assetCanonical: string; iconUrl: string; network: string; recentAddresses: Array; diff --git a/extension/src/background/messageListener/popupMessageListener.ts b/extension/src/background/messageListener/popupMessageListener.ts index 0a6afebd3a..69db25d924 100644 --- a/extension/src/background/messageListener/popupMessageListener.ts +++ b/extension/src/background/messageListener/popupMessageListener.ts @@ -637,24 +637,24 @@ export const popupMessageListener = (request: Request) => { }; const getCachedAssetIcon = () => { - const { assetCode } = request; + const { assetCanonical } = request; const assetIconCache = JSON.parse( localStorage.getItem(CACHED_ASSET_ICONS_ID) || "{}", ); return { - iconUrl: assetIconCache[assetCode] || "", + iconUrl: assetIconCache[assetCanonical] || "", }; }; const cacheAssetIcon = () => { - const { assetCode, iconUrl } = request; + const { assetCanonical, iconUrl } = request; const assetIconCache = JSON.parse( localStorage.getItem(CACHED_ASSET_ICONS_ID) || "{}", ); - assetIconCache[assetCode] = iconUrl; + assetIconCache[assetCanonical] = iconUrl; localStorage.setItem(CACHED_ASSET_ICONS_ID, JSON.stringify(assetIconCache)); }; diff --git a/extension/src/popup/components/account/AccountAssets/index.tsx b/extension/src/popup/components/account/AccountAssets/index.tsx index 918ade3389..ff0b5fb383 100644 --- a/extension/src/popup/components/account/AccountAssets/index.tsx +++ b/extension/src/popup/components/account/AccountAssets/index.tsx @@ -5,6 +5,7 @@ import { BigNumber } from "bignumber.js"; import { AssetIcons } from "@shared/api/types"; import { retryAssetIcon } from "@shared/api/internal"; +import { getCanonicalFromAsset } from "helpers/stellar"; import StellarLogo from "popup/assets/stellar-logo.png"; import { settingsNetworkDetailsSelector } from "popup/ducks/settings"; @@ -21,11 +22,15 @@ export const AssetIcon = ({ issuerKey: string; retryAssetIconFetch?: (arg: { key: string; code: string }) => void; }) => - assetIcons[code] || code === "XLM" ? ( + assetIcons[getCanonicalFromAsset(code, issuerKey)] || code === "XLM" ? ( {`${code} { if (retryAssetIconFetch) { retryAssetIconFetch({ key: issuerKey, code }); @@ -77,7 +82,10 @@ export const AccountAssets = ({ return ( <> {sortedBalances.map(({ token: { issuer, code }, total }) => ( -
+
{ collection.push({ code, issuer: issuer?.key || "", - image: assetIcons[code], + image: assetIcons[getCanonicalFromAsset(code, issuer?.key)], domain, }); } diff --git a/extension/src/popup/components/manageAssets/ManageAssetRows/index.tsx b/extension/src/popup/components/manageAssets/ManageAssetRows/index.tsx index c26ca9c2b5..e12084c9f2 100644 --- a/extension/src/popup/components/manageAssets/ManageAssetRows/index.tsx +++ b/extension/src/popup/components/manageAssets/ManageAssetRows/index.tsx @@ -143,9 +143,9 @@ export const ManageAssetRows = ({ const isActionPending = submitStatus === ActionStatus.PENDING; return ( -
+
diff --git a/extension/src/popup/components/sendPayment/SendAmount/index.tsx b/extension/src/popup/components/sendPayment/SendAmount/index.tsx index 322c526afe..1a9db1a132 100644 --- a/extension/src/popup/components/sendPayment/SendAmount/index.tsx +++ b/extension/src/popup/components/sendPayment/SendAmount/index.tsx @@ -338,7 +338,7 @@ export const SendAmount = ({ previous }: { previous: ROUTES }) => {
{getAssetFromCanonical(formik.values.asset).code}
- {destinationAsset && ( + {destinationAsset && formik.values.amount !== "0" && ( void }) => { code: destAsset.code, networkDetails, }); - setDestAssetIcons({ [destAsset.code]: iconURL }); + setDestAssetIcons({ + [getCanonicalFromAsset(destAsset.code, destAsset.issuer)]: iconURL, + }); })(); }, [destAsset.code, destAsset.issuer, networkDetails]); @@ -205,7 +208,10 @@ export const TransactionDetails = ({ goBack }: { goBack: () => void }) => { assetIcons={assetIcons} sortedBalances={[ { - token: { issuer: sourceAsset.issuer, code: sourceAsset.code }, + token: { + issuer: { key: sourceAsset.issuer }, + code: sourceAsset.code, + }, total: amount || "0", }, ]} @@ -218,7 +224,7 @@ export const TransactionDetails = ({ goBack }: { goBack: () => void }) => { sortedBalances={[ { token: { - issuer: destAsset.issuer, + issuer: { key: destAsset.issuer }, code: destAsset.code, }, total: destinationAmount || "0",