Skip to content

Commit

Permalink
add testnet chains flag
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed Mar 21, 2024
1 parent 1689f20 commit d947ba7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export type UseChainsQueryArgs<T = Chain[]> = {

export function useChains<T = Chain[]>(args: UseChainsQueryArgs<T> = {}) {
const { select = (t) => t as T } = args;

const skipClient = useSkipClient();

return useQuery({
queryKey: ["USE_CHAINS"],
queryFn: async () => {
const chains = await skipClient.chains({
includeEVM: true,
includeTestnets: process.env.NEXT_PUBLIC_IS_TESTNET ? true : false,
});

return chains
Expand All @@ -35,6 +35,7 @@ export function useChains<T = Chain[]>(args: UseChainsQueryArgs<T> = {}) {
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);
});
Expand Down

0 comments on commit d947ba7

Please sign in to comment.