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: 5 additions & 0 deletions .changeset/quiet-owls-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly/mobile": patch
---

🥅 globally suppress expected kyc api errors
13 changes: 7 additions & 6 deletions src/utils/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import type { PersistedClient } from "@tanstack/query-persist-client-core";
import type { Address } from "viem";

const INVALIDATE_ON_UPGRADE = new Set(["kyc", "card", "pax"]);
const expected = (error: unknown) =>
error instanceof APIError &&
(error.text === "no kyc" ||
error.text === "not started" ||
error.text === "bad kyc" ||
error.text === "kyc required");

function versionAwareDeserialize(cache: string): PersistedClient {
const persistedClient: PersistedClient = deserialize(cache);
Expand All @@ -40,10 +46,7 @@ const queryClient = new QueryClient({
if (error instanceof Error && error.message === "don't refetch") return;
if (error instanceof APIError) {
if (error.code === 401 && error.text === "unauthorized") return;
if (query.queryKey[0] === "card" && query.queryKey[1] === "details") {
if (error.text === "kyc required") return;
if (error.text === "bad kyc") return;
}
if (expected(error)) return;
}
reportError(error);
},
Expand Down Expand Up @@ -268,8 +271,6 @@ queryClient.setQueryDefaults<EmbeddingContext>(["embedding-context"], {
return null;
},
});
const expected = (error: unknown) =>
error instanceof APIError && (error.text === "no kyc" || error.text === "not started" || error.text === "bad kyc");
queryClient.setQueryDefaults(["kyc", "status"], {
staleTime: 5 * 60_000,
gcTime: 60 * 60_000,
Expand Down