Skip to content

Commit

Permalink
Don't die on ERC-721 tokens
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
csillag committed Jul 6, 2023
1 parent 130449d commit 045a7d8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/pages/TokenDashboardPage/TokenTypeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export abstract class RouteUtils {
) => {
const map: Record<EvmTokenType, string | undefined> = {
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')
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const isAccountNonEmpty = (account: RuntimeAccount) => !isAccountEmpty(ac
export const groupAccountTokenBalances = (account: Omit<RuntimeAccount, 'tokenBalances'>): RuntimeAccount => {
const tokenBalances: Record<generated.EvmTokenType, generated.RuntimeEvmBalance[]> = {
ERC20: [],
ERC721: [],
}
account.evm_balances.forEach(balance => {
if (balance.token_type) tokenBalances[balance.token_type].push(balance)
Expand Down

0 comments on commit 045a7d8

Please sign in to comment.