Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/2163.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Swallow any errors when opportunistically looking up token names
1 change: 1 addition & 0 deletions src/app/hooks/useAccountMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const useAccountMetadata = (scope: SearchScope, address: string): Account
// The type cast is OK because whenever we are on consensus, we will set enabled to false
enabled: !registryData?.metadata && scope.layer !== 'consensus',
useCaching: true,
swallowError: true,
})
const tokenData: AccountMetadataInfo = {
metadata: token ? { address: token.contract_addr, name: token.name, source: 'SelfProfessed' } : undefined,
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/TokenDashboardPage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ interface UseTokenInfoParams {
/** Defaults to true */
enabled?: boolean
useCaching?: boolean
swallowError?: boolean
}

export const useTokenInfo = (scope: RuntimeScope, address: string, params: UseTokenInfoParams = {}) => {
const { network, layer } = scope
const { enabled, useCaching } = params
const { enabled, useCaching, swallowError = false } = params
const query = useGetRuntimeEvmTokensAddress(network, layer, address, {
query: {
enabled,
staleTime: useCaching ? 3600000 : undefined,
},
request: swallowError ? ({ swallowError } as any) : undefined,
})
const token = query.data?.data
const { isLoading, isError, isFetched } = query
Expand Down
14 changes: 14 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ import './locales/i18n'
import { LocalSettingsContextProvider } from './app/providers/LocalSettingsProvider'
import { AdaptiveTrimmerContextProvider } from './app/components/AdaptiveTrimmerContext/AdaptiveTrimmerProvider'

const customLogger = {
log: console.log.bind(console),
warn: console.warn.bind(console),
error: (error: any) => {
// Suppress error messages when swallowError is set
if (typeof error === 'object' && error?.config.swallowError) return
// We don't need the warning about custom logger feature being deprecated.
// When we migrate to the next major version of react-query, we can simply drop this
if (typeof error === 'string' && error.startsWith('Passing a custom logger has been deprecated')) return
console.error(error) // Log any other errors
},
}

const queryClient = new QueryClient({
logger: customLogger, // This can be dropped when support is removed
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
Expand Down