From 04c71151d0c9f4da420e81502af1f38bd554dbe1 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Tue, 26 Mar 2024 12:38:41 +0700 Subject: [PATCH] testnet env var --- env.d.ts | 1 + src/hooks/useChains.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/env.d.ts b/env.d.ts index aca3e5bc..1355c2e2 100644 --- a/env.d.ts +++ b/env.d.ts @@ -12,6 +12,7 @@ declare namespace NodeJS { readonly RESEND_API_KEY?: string; readonly WALLETCONNECT_VERIFY_KEY?: string; readonly WORD_PHRASE_KEY?: string; + readonly NEXT_PUBLIC_IS_TESTNET?: boolean; } } diff --git a/src/hooks/useChains.ts b/src/hooks/useChains.ts index c5d8a467..94f25289 100644 --- a/src/hooks/useChains.ts +++ b/src/hooks/useChains.ts @@ -16,7 +16,6 @@ export type UseChainsQueryArgs = { export function useChains(args: UseChainsQueryArgs = {}) { const { select = (t) => t as T } = args; - const skipClient = useSkipClient(); return useQuery({ @@ -25,6 +24,7 @@ export function useChains(args: UseChainsQueryArgs = {}) { const chains = await skipClient.chains({ includeEVM: true, includeSVM: true, + includeTestnets: process.env.NEXT_PUBLIC_IS_TESTNET ? true : false, }); return chains @@ -36,6 +36,7 @@ export function useChains(args: UseChainsQueryArgs = {}) { logoURI: chain.logoURI || "/logo-fallback.png", }; }) + .filter((chain) => (process.env.NEXT_PUBLIC_IS_TESTNET ? chain.isTestnet : true)) .sort((chainA, chainB) => { return chainA.prettyName.localeCompare(chainB.prettyName); });