From 7f5058ba46409eae36fc264da7df6e38bcec8d04 Mon Sep 17 00:00:00 2001 From: AtelyPham Date: Sat, 29 Jul 2023 19:33:51 +0700 Subject: [PATCH] chore: adding multiple providers for getViemClient fn --- libs/web3-api-provider/src/utils/getViemClient.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/web3-api-provider/src/utils/getViemClient.ts b/libs/web3-api-provider/src/utils/getViemClient.ts index 23b4222d29..2c624e6516 100644 --- a/libs/web3-api-provider/src/utils/getViemClient.ts +++ b/libs/web3-api-provider/src/utils/getViemClient.ts @@ -1,5 +1,5 @@ import { parseTypedChainId } from '@webb-tools/sdk-core'; -import { PublicClient, createPublicClient, http } from 'viem'; +import { PublicClient, createPublicClient, fallback, http } from 'viem'; import { VIEM_NOT_SUPPORTED_MULTICALL_CHAINS, defineViemChain, @@ -19,7 +19,9 @@ function getViemClient(typedChainId: number): PublicClient { batch: { multicall: !!chain.contracts?.multicall3, }, - transport: http(undefined, { timeout: 60_000 }), + transport: fallback( + chain.rpcUrls.public.http.map((url) => http(url, { timeout: 60_000 })) + ), }); }