diff --git a/.changelog/679.bugfix.md b/.changelog/679.bugfix.md new file mode 100644 index 000000000..a3e4a7e4f --- /dev/null +++ b/.changelog/679.bugfix.md @@ -0,0 +1 @@ +Don't die on ERC-721 tokens diff --git a/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx b/src/app/pages/TokenDashboardPage/TokenTypeCard.tsx index 62e50e556..e6f8fc2c0 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 c336336be..965932554 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 aa4787cb9..0bcffc0d6 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 13554054b..f3540a92d 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) diff --git a/src/oasis-nexus/generated/api.ts b/src/oasis-nexus/generated/api.ts index f639de694..c88a05655 100644 --- a/src/oasis-nexus/generated/api.ts +++ b/src/oasis-nexus/generated/api.ts @@ -122,7 +122,7 @@ limit?: number; */ offset?: number; /** - * A filter on the name, the name must contain this value as a substring. + * A filter on the name, the name or symbol must contain this value as a substring. */ name?: string; }; @@ -649,6 +649,7 @@ export type EvmTokenType = typeof EvmTokenType[keyof typeof EvmTokenType]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const EvmTokenType = { ERC20: 'ERC20', + ERC721: 'ERC721', } as const; export interface RuntimeStatus { @@ -760,6 +761,14 @@ May be null if the transaction was malformed or encrypted. method?: string; /** The method call body. May be null if the transaction was malformed. */ body?: RuntimeTransactionBody; + /** Whether this transaction likely represents a native token transfer. +This is based on a heuristic, and can change at any time without warning and possibly without updating the documentation. +The current heuristic sets this to `true` for: + - Transactions with method "accounts.Transfer". Those are always native token transfers. + - Transactions with method "evm.Call" that have no `data` field in their `body`. Those tend to be transfers, but the runtimes provides no reliable visibility into whether a transfer happened. +Note: Other transactions with method "evm.Call", and possibly "evm.Create", may also be (or include) native token transfers. The heuristic will be `false` for those. + */ + is_likely_native_token_transfer?: boolean; /** A reasonable "to" Oasis address associated with this transaction, if applicable. The meaning varies based on the transaction method. Some notable examples: - For `method = "accounts.Transfer"`, this is the paratime account receiving the funds. @@ -837,7 +846,7 @@ to a direct `Create` call. */ creation_bytecode?: string; /** The runtime bytecode of the smart contract. This is the code stored on-chain that -descibes a smart contract. Every contract has this info, but Nexus fetches +describes a smart contract. Every contract has this info, but Nexus fetches it separately, so the field may be missing for very fresh contracts (or if the fetching process is stalled). */