Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore all account name fetching errors at the same level #1585

Merged
merged 1 commit into from
Oct 22, 2024
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
1 change: 1 addition & 0 deletions .changelog/1585.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore all account name fetching errors at the same level
4 changes: 2 additions & 2 deletions src/app/data/oasis-account-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const getOasisAccountsMetadata = async (network: Network, layer: Layer): Promise
}
}

export const useOasisAccountsMetadata = (
const useOasisAccountsMetadata = (
network: Network,
layer: Layer,
queryOptions: UseQueryOptions<AccountData, unknown, AccountData, string[]>,
Expand Down Expand Up @@ -101,7 +101,7 @@ export const useSearchForOasisAccountsByName = (
isError: isMetadataError,
error: metadataError,
data: namedAccounts,
} = useOasisAccountsMetadata(network, layer, { useErrorBoundary: false, ...queryOptions })
} = useOasisAccountsMetadata(network, layer, queryOptions)
if (isMetadataError) {
console.log('Failed to load Oasis account metadata', metadataError)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/data/pontusx-account-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const useSearchForPontusXAccountsByName = (
isError: isMetadataError,
error: metadataError,
data: namedAccounts,
} = usePontusXAccountsMetadata({ useErrorBoundary: false, ...queryOptions })
} = usePontusXAccountsMetadata(queryOptions)
if (isMetadataError) {
console.log('Failed to load Pontus-X account names', metadataError)
}
Expand Down
12 changes: 10 additions & 2 deletions src/app/hooks/useAccountMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ import { getOasisAddress } from '../utils/helpers'
*
* This is the entry point that should be used by the application,
* since this function also includes caching.
*
* Doesn't throw if it fails.
*/
export const useAccountMetadata = (scope: SearchScope, address: string): AccountMetadataInfo => {
const isPontusX = scope.layer === Layer.pontusxtest || scope.layer === Layer.pontusxdev
const pontusXData = usePontusXAccountMetadata(address, { enabled: isPontusX })
const oasisData = useOasisAccountMetadata(scope.network, scope.layer, getOasisAddress(address), {
const pontusXData = usePontusXAccountMetadata(address, {
enabled: isPontusX,
useErrorBoundary: false,
})
const oasisData = useOasisAccountMetadata(scope.network, scope.layer, getOasisAddress(address), {
enabled: !isPontusX,
useErrorBoundary: false,
})
return isPontusX ? pontusXData : oasisData
}

/** Doesn't throw if it fails. */
export const useSearchForAccountsByName = (
scope: SearchScope,
nameFragment = '',
Expand All @@ -29,10 +35,12 @@ export const useSearchForAccountsByName = (
const isValidPontusXSearch = isPontusX && !!nameFragment
const pontusXResults = useSearchForPontusXAccountsByName(scope.network, nameFragment, {
enabled: isValidPontusXSearch,
useErrorBoundary: false,
})
const isValidOasisSearch = !isPontusX && !!nameFragment
const oasisResults = useSearchForOasisAccountsByName(scope.network, scope.layer, nameFragment, {
enabled: isValidOasisSearch,
useErrorBoundary: false,
})
return {
isLoading:
Expand Down
Loading