Skip to content

Commit

Permalink
Don't attempt to get tokens on consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 27, 2025
1 parent 03c3d15 commit 825fcb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/app/hooks/useAccountMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export const useAccountMetadata = (scope: SearchScope, address: string): Account
token,
isLoading: isTokenLoading,
isError: isTokenError,
} = useTokenInfo(scope, address, { enabled: !registryData?.metadata, useCaching: true })
} = useTokenInfo(scope, address, {
enabled: !registryData?.metadata && scope.layer !== Layer.consensus,
useCaching: true,
})
const tokenData: AccountMetadataInfo = {
metadata: token ? { address: token.contract_addr, name: token.name, source: 'SelfProfessed' } : undefined,
isLoading: isTokenLoading,
Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/TokenDashboardPage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useGetRuntimeEvmTokensAddressNftsId,
RuntimeEventType,
GetRuntimeEventsParams,
Runtime,
} from '../../../oasis-nexus/api'
import { AppErrors } from '../../../types/errors'
import { SearchScope } from '../../../types/searchScope'
Expand All @@ -25,11 +26,11 @@ interface UseTokenInfoParams {
export const useTokenInfo = (scope: SearchScope, address: string, params: UseTokenInfoParams = {}) => {
const { network, layer } = scope
const { enabled, useCaching } = params
if (layer === Layer.consensus) {
if (enabled && layer === Layer.consensus) {
// There can be no ERC-20 or ERC-721 tokens on consensus
throw AppErrors.UnsupportedLayer
}
const query = useGetRuntimeEvmTokensAddress(network, layer, address, {
const query = useGetRuntimeEvmTokensAddress(network, layer as Runtime, address, {
query: {
enabled,
staleTime: useCaching ? 3600000 : undefined,
Expand Down

0 comments on commit 825fcb7

Please sign in to comment.