From fc2fdba4603a221182e6ae59f3831c35b35a797b Mon Sep 17 00:00:00 2001 From: shane-moore Date: Thu, 26 Oct 2023 16:51:40 -0700 Subject: [PATCH] chore: mapBySymbol support multiple token types --- .../src/tokens/mappings/mapBySymbol.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/token-metadata/src/tokens/mappings/mapBySymbol.ts b/packages/token-metadata/src/tokens/mappings/mapBySymbol.ts index 47e88ae01..0d15f88e9 100644 --- a/packages/token-metadata/src/tokens/mappings/mapBySymbol.ts +++ b/packages/token-metadata/src/tokens/mappings/mapBySymbol.ts @@ -8,9 +8,13 @@ export const getMappedTokensBySymbol = (tokens: Record) => const symbol = tokenMeta.symbol.toUpperCase() const symbolDiffs = symbol !== symbolKey + let ibcResults = {} + let cw20Results = {} + let splResults = {} + let cw20sResults = {} + if (tokenMeta.ibc && tokenMeta.ibc.baseDenom) { - return { - ...result, + ibcResults = { [tokenMeta.ibc.baseDenom.toUpperCase()]: tokenMeta, [symbol.toUpperCase()]: tokenMeta, ...(symbolDiffs && { @@ -23,8 +27,7 @@ export const getMappedTokensBySymbol = (tokens: Record) => } if (tokenMeta.cw20 && tokenMeta.cw20.address) { - return { - ...result, + cw20Results = { [tokenMeta.cw20.address.toUpperCase()]: tokenMeta, [symbol.toUpperCase()]: tokenMeta, ...(symbolDiffs && { @@ -34,8 +37,7 @@ export const getMappedTokensBySymbol = (tokens: Record) => } if (tokenMeta.spl && tokenMeta.spl.address) { - return { - ...result, + splResults = { [tokenMeta.spl.address.toUpperCase()]: tokenMeta, [symbol.toUpperCase()]: tokenMeta, ...(symbolDiffs && { @@ -53,8 +55,7 @@ export const getMappedTokensBySymbol = (tokens: Record) => {} as Record, ) - return { - ...result, + cw20sResults = { ...cw20Maps, [symbol.toUpperCase()]: tokenMeta, ...(symbolDiffs && { @@ -65,6 +66,10 @@ export const getMappedTokensBySymbol = (tokens: Record) => return { ...result, + ...ibcResults, + ...cw20Results, + ...splResults, + ...cw20sResults, [symbol.toUpperCase()]: tokenMeta, ...(symbolDiffs && { [symbolKey.toUpperCase()]: tokenMeta,