Skip to content
Merged
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
5 changes: 3 additions & 2 deletions packages/curve-ui-kit/src/lib/api/cache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { type Mutation, MutationCache, QueryCache } from '@tanstack/react-query'
import { logError, logMutation, logSuccess } from '@ui-kit/lib/logging'
import { QUERY_KEY_IDENTIFIER as USD_RATE_KEY_IDENTIFER } from '../model/entities/token-usd-rate'

// disable logging for queries that are too verbose
const disableCacheQueryKeys = new Set<unknown>(['readContracts']) // add more query keys here to disable logging
const disableCacheQueryKeys = new Set<unknown>(['readContracts', USD_RATE_KEY_IDENTIFER])

export const queryCache = new QueryCache({
onError: (error: Error, query) => logError(query.queryKey, error, error.message),
onSuccess: (data, { queryKey }) => {
if (!disableCacheQueryKeys.has(queryKey[0])) {
if (!queryKey.some((key) => disableCacheQueryKeys.has(key))) {
logSuccess(queryKey, ...[data ? [data] : []])
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { combineQueriesToObject, createValidationSuite } from '@ui-kit/lib'
import { queryFactory, rootKeys, type ChainParams, type TokenParams, type TokenQuery } from '@ui-kit/lib/model/query'
import { tokenValidationGroup } from '@ui-kit/lib/model/query/token-validation'

const QUERY_KEY_IDENTIFIER = 'usdRate' as const
export const QUERY_KEY_IDENTIFIER = 'usdRate' as const

/**
* Hook to fetch the USD rate for a specific token on a specific blockchain.
Expand Down