File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 88 RpcSchema ,
99 Transport ,
1010} from "viem" ;
11+ import { AVALANCHE_CHAIN_IDS } from "../methods/consts.js" ;
1112import { AvalanchePublicRpcSchema } from "../methods/public/avalanchePublicRpcSchema.js" ;
1213import { createAdminApiClient } from "./createAdminApiClient.js" ;
1314import { createCChainClient } from "./createCChainClient.js" ;
@@ -23,6 +24,8 @@ import {
2324 AvalancheClientConfig ,
2425} from "./types/createAvalancheClient.js" ;
2526import { createAvalancheTransportClient } from "./utils.js" ;
27+
28+ const AVALANCHE_CHAIN_ID_VALUES = Object . values ( AVALANCHE_CHAIN_IDS ) as number [ ] ;
2629/**
2730 * Creates an Avalanche Client with a given transport configured for a Chain.
2831 *
@@ -120,7 +123,7 @@ export function createAvalancheClient<
120123 } ) ;
121124 const extendedClient = client . extend ( avalanchePublicActions ) as any ;
122125
123- if ( chainConfig ?. id !== 43_112 && chainConfig ?. id !== 43_113 && chainConfig ? .id !== 43_114 ) {
126+ if ( ! chainConfig ?. id || ! AVALANCHE_CHAIN_ID_VALUES . includes ( chainConfig . id ) ) {
124127 return {
125128 ...extendedClient ,
126129 } ;
Original file line number Diff line number Diff line change 99} from "viem" ;
1010import { commonHeaders } from "./common.js" ;
1111import { AvalancheTransportConfig , ClientType } from "./types/types.js" ;
12+ import { AVALANCHE_CHAIN_IDS } from "../methods/consts.js" ;
13+
14+ const AVALANCHE_CHAIN_ID_VALUES = Object . values ( AVALANCHE_CHAIN_IDS ) as number [ ] ;
1215
1316export function createAvalancheTransportClient <
1417 transport extends Transport ,
@@ -94,7 +97,7 @@ function getClientURL(
9497 clientType : ClientType = "public" ,
9598 transportType : "http" | "webSocket" = "http"
9699) : string | undefined {
97- if ( chain ?. id !== 43_112 && chain ?. id !== 43_113 && chain ? .id !== 43_114 ) {
100+ if ( ! chain ?. id || ! AVALANCHE_CHAIN_ID_VALUES . includes ( chain . id ) ) {
98101 return url ?? chain ?. rpcUrls . default [ transportType ] ?. [ 0 ] ;
99102 }
100103
You can’t perform that action at this time.
0 commit comments