From 045a7d84b4166e20a1625b2a3604fffee13ba548 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Thu, 6 Jul 2023 13:19:54 +0200 Subject: [PATCH] Don't die on ERC-721 tokens It needs more work to actually display them properly, but after this change, at least we are not throwing any more exceptions when encountering them. --- src/app/pages/TokenDashboardPage/TokenTypeCard.tsx | 2 ++ src/app/utils/route-utils.ts | 1 + src/locales/en/translation.json | 1 + src/oasis-nexus/api.ts | 1 + 4 files changed, 5 insertions(+) diff --git a/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx b/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx index 62e50e5567..e6f8fc2c04 100644 --- a/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx +++ b/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx @@ -15,6 +15,8 @@ export const getTokenTypeName = (t: TFunction, type: EvmTokenType): string => { switch (type) { case 'ERC20': return t('account.ERC20') + case 'ERC721': + return t('account.ERC721') default: exhaustedTypeWarning('Unknown token type', type) return type diff --git a/src/app/utils/route-utils.ts b/src/app/utils/route-utils.ts index c336336bed..965932554c 100644 --- a/src/app/utils/route-utils.ts +++ b/src/app/utils/route-utils.ts @@ -66,6 +66,7 @@ export abstract class RouteUtils { ) => { const map: Record = { ERC20: `${this.getAccountRoute(scope, account)}/tokens/erc-20`, + ERC721: `${this.getAccountRoute(scope, account)}/tokens/erc-721`, } const tokenRoutes = map[tokenType] if (!tokenRoutes) throw new Error('Unexpected token type') diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index aa4787cb9e..0bcffc0d61 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -5,6 +5,7 @@ "emptyTransactionList": "There are no transactions on record for this account.", "emptyTokenTransferList": "There are no token transfers on record for this account.", "ERC20": "ERC-20", + "ERC721": "ERC-721", "noTokens": "This account holds no tokens", "showMore": "+ {{counter}} more", "title": "Account", diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index 13554054bd..f3540a92d7 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -75,6 +75,7 @@ export const isAccountNonEmpty = (account: RuntimeAccount) => !isAccountEmpty(ac export const groupAccountTokenBalances = (account: Omit): RuntimeAccount => { const tokenBalances: Record = { ERC20: [], + ERC721: [], } account.evm_balances.forEach(balance => { if (balance.token_type) tokenBalances[balance.token_type].push(balance)