Skip to content

Commit

Permalink
Merge pull request #253 from InjectiveLabs/chore/symbol-mapping-enhan…
Browse files Browse the repository at this point in the history
…cement
  • Loading branch information
bangjelkoski authored Oct 27, 2023
2 parents 1316c59 + fc2fdba commit 4f961f6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/token-metadata/src/tokens/mappings/mapBySymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export const getMappedTokensBySymbol = (tokens: Record<string, TokenMeta>) =>
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 && {
Expand All @@ -23,8 +27,7 @@ export const getMappedTokensBySymbol = (tokens: Record<string, TokenMeta>) =>
}

if (tokenMeta.cw20 && tokenMeta.cw20.address) {
return {
...result,
cw20Results = {
[tokenMeta.cw20.address.toUpperCase()]: tokenMeta,
[symbol.toUpperCase()]: tokenMeta,
...(symbolDiffs && {
Expand All @@ -34,8 +37,7 @@ export const getMappedTokensBySymbol = (tokens: Record<string, TokenMeta>) =>
}

if (tokenMeta.spl && tokenMeta.spl.address) {
return {
...result,
splResults = {
[tokenMeta.spl.address.toUpperCase()]: tokenMeta,
[symbol.toUpperCase()]: tokenMeta,
...(symbolDiffs && {
Expand All @@ -53,8 +55,7 @@ export const getMappedTokensBySymbol = (tokens: Record<string, TokenMeta>) =>
{} as Record<string, TokenMeta>,
)

return {
...result,
cw20sResults = {
...cw20Maps,
[symbol.toUpperCase()]: tokenMeta,
...(symbolDiffs && {
Expand All @@ -65,6 +66,10 @@ export const getMappedTokensBySymbol = (tokens: Record<string, TokenMeta>) =>

return {
...result,
...ibcResults,
...cw20Results,
...splResults,
...cw20sResults,
[symbol.toUpperCase()]: tokenMeta,
...(symbolDiffs && {
[symbolKey.toUpperCase()]: tokenMeta,
Expand Down

0 comments on commit 4f961f6

Please sign in to comment.