@1delta/providers 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_esm-NMEXBKYZ.mjs → _esm-BLSSJTMS.mjs} +33 -33
- package/dist/{ccip-3Y4YD27I.mjs → ccip-P6QKYDYG.mjs} +1 -1
- package/dist/{chunk-7BYOX3YW.mjs → chunk-GGVKF6RL.mjs} +175 -129
- package/dist/index.d.mts +582 -160
- package/dist/index.d.ts +582 -160
- package/dist/index.js +1424 -1193
- package/dist/index.mjs +815 -640
- package/package.json +5 -6
- package/src/chains/chainMapping.ts +314 -0
- package/src/chains/customChains.ts +202 -0
- package/src/client/client.ts +110 -0
- package/src/evm.ts +7 -1067
- package/src/multicall/multicall.ts +250 -0
- package/src/rpc/rpcOverrides.ts +248 -0
- package/src/transport/transport.ts +17 -0
- package/src/utils/utils.ts +55 -0
- package/test/contract.ts +204 -0
- package/test/multicallRetry.test.ts +808 -0
- package/test/multicallRetry.testUtils.ts +181 -0
- package/vitest.config.ts +8 -0
package/src/evm.ts
CHANGED
|
@@ -1,1067 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
webSocket,
|
|
9
|
-
} from 'viem'
|
|
10
|
-
import {
|
|
11
|
-
mantle,
|
|
12
|
-
mainnet,
|
|
13
|
-
optimism,
|
|
14
|
-
arbitrum,
|
|
15
|
-
bsc,
|
|
16
|
-
avalanche,
|
|
17
|
-
taiko,
|
|
18
|
-
metis,
|
|
19
|
-
polygon,
|
|
20
|
-
zksync,
|
|
21
|
-
scroll,
|
|
22
|
-
gnosis,
|
|
23
|
-
base,
|
|
24
|
-
blast,
|
|
25
|
-
kaia,
|
|
26
|
-
opBNB,
|
|
27
|
-
fantom,
|
|
28
|
-
sonic,
|
|
29
|
-
linea,
|
|
30
|
-
hemi,
|
|
31
|
-
neonMainnet,
|
|
32
|
-
degen,
|
|
33
|
-
gravity,
|
|
34
|
-
lightlinkPhoenix,
|
|
35
|
-
plume,
|
|
36
|
-
abstract,
|
|
37
|
-
peaq,
|
|
38
|
-
flowMainnet,
|
|
39
|
-
soneium,
|
|
40
|
-
goat,
|
|
41
|
-
berachain,
|
|
42
|
-
rootstock,
|
|
43
|
-
ink,
|
|
44
|
-
vanar,
|
|
45
|
-
fuse,
|
|
46
|
-
superposition,
|
|
47
|
-
story,
|
|
48
|
-
apeChain,
|
|
49
|
-
telos,
|
|
50
|
-
flare,
|
|
51
|
-
aurora,
|
|
52
|
-
kava,
|
|
53
|
-
iota,
|
|
54
|
-
coreDao,
|
|
55
|
-
unichain,
|
|
56
|
-
mode,
|
|
57
|
-
xLayer,
|
|
58
|
-
zircuit,
|
|
59
|
-
corn,
|
|
60
|
-
bob,
|
|
61
|
-
manta,
|
|
62
|
-
harmonyOne,
|
|
63
|
-
celo,
|
|
64
|
-
bitlayer,
|
|
65
|
-
merlin,
|
|
66
|
-
sei,
|
|
67
|
-
iotex,
|
|
68
|
-
bsquared,
|
|
69
|
-
zetachain,
|
|
70
|
-
ronin,
|
|
71
|
-
inEVM,
|
|
72
|
-
pulsechain,
|
|
73
|
-
xdc,
|
|
74
|
-
cronos,
|
|
75
|
-
cronoszkEVM,
|
|
76
|
-
taraxa,
|
|
77
|
-
meter,
|
|
78
|
-
morph,
|
|
79
|
-
moonbeam,
|
|
80
|
-
zkLinkNova,
|
|
81
|
-
vana,
|
|
82
|
-
} from 'viem/chains'
|
|
83
|
-
import lodash from 'lodash'
|
|
84
|
-
|
|
85
|
-
// pull the functions you need
|
|
86
|
-
const { uniq, isArray } = lodash
|
|
87
|
-
|
|
88
|
-
const crossfi = defineChain({
|
|
89
|
-
id: 4158,
|
|
90
|
-
name: 'CrossFi Mainet',
|
|
91
|
-
nativeCurrency: {
|
|
92
|
-
decimals: 18,
|
|
93
|
-
name: 'XFI',
|
|
94
|
-
symbol: 'XFI',
|
|
95
|
-
},
|
|
96
|
-
rpcUrls: {
|
|
97
|
-
default: {
|
|
98
|
-
http: ['https://rpc.mainnet.ms/'],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
blockExplorers: {
|
|
102
|
-
default: { name: 'Explorer', url: 'https://xfiscan.com/' },
|
|
103
|
-
},
|
|
104
|
-
// contracts: {
|
|
105
|
-
// multicall3: {
|
|
106
|
-
// address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
107
|
-
// blockCreated: 1,
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
const botanix = defineChain({
|
|
113
|
-
id: 3637,
|
|
114
|
-
name: 'Botanix',
|
|
115
|
-
nativeCurrency: {
|
|
116
|
-
decimals: 18,
|
|
117
|
-
name: 'BTC',
|
|
118
|
-
symbol: 'BTC',
|
|
119
|
-
},
|
|
120
|
-
rpcUrls: {
|
|
121
|
-
default: {
|
|
122
|
-
http: [
|
|
123
|
-
'https://rpc.ankr.com/botanix_mainnet',
|
|
124
|
-
'https://rpc.botanixlabs.com',
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
blockExplorers: {
|
|
129
|
-
default: { name: 'Explorer', url: 'https://botanixscan.io/' },
|
|
130
|
-
},
|
|
131
|
-
contracts: {
|
|
132
|
-
multicall3: {
|
|
133
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
134
|
-
blockCreated: 1,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const hyperEvm = defineChain({
|
|
140
|
-
id: 999,
|
|
141
|
-
name: 'Hyper EVM',
|
|
142
|
-
nativeCurrency: {
|
|
143
|
-
decimals: 18,
|
|
144
|
-
name: 'HYPE',
|
|
145
|
-
symbol: 'HYPE',
|
|
146
|
-
},
|
|
147
|
-
rpcUrls: {
|
|
148
|
-
default: {
|
|
149
|
-
http: ['https://rpc.hyperliquid.xyz/evm'],
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
blockExplorers: {
|
|
153
|
-
default: { name: 'Explorer', url: 'https://hypurrscan.io/' },
|
|
154
|
-
},
|
|
155
|
-
contracts: {
|
|
156
|
-
multicall3: {
|
|
157
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
158
|
-
blockCreated: 1,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
export const katana = defineChain({
|
|
164
|
-
id: 747474,
|
|
165
|
-
name: 'Katana',
|
|
166
|
-
nativeCurrency: {
|
|
167
|
-
decimals: 18,
|
|
168
|
-
name: 'Ether',
|
|
169
|
-
symbol: 'ETH',
|
|
170
|
-
},
|
|
171
|
-
rpcUrls: {
|
|
172
|
-
default: {
|
|
173
|
-
http: ['https://rpc.katana.network'],
|
|
174
|
-
webSocket: [],
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
blockExplorers: {
|
|
178
|
-
default: { name: 'Explorer', url: 'https://katanascan.com/' },
|
|
179
|
-
},
|
|
180
|
-
contracts: {
|
|
181
|
-
multicall3: {
|
|
182
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
183
|
-
blockCreated: 0,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
const GraphLinq = defineChain({
|
|
189
|
-
id: 614,
|
|
190
|
-
name: 'GraphLinq Chain',
|
|
191
|
-
nativeCurrency: {
|
|
192
|
-
decimals: 18,
|
|
193
|
-
name: 'GLQ',
|
|
194
|
-
symbol: 'GLQ',
|
|
195
|
-
},
|
|
196
|
-
rpcUrls: {
|
|
197
|
-
default: {
|
|
198
|
-
http: ['https://glq-dataseed.graphlinq.io'],
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
blockExplorers: {
|
|
202
|
-
default: { name: 'Explorer', url: 'https://explorer.graphlinq.io' },
|
|
203
|
-
},
|
|
204
|
-
// contracts: {
|
|
205
|
-
// multicall3: {
|
|
206
|
-
// address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
207
|
-
// blockCreated: 1,
|
|
208
|
-
// }
|
|
209
|
-
// }
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
const artela = defineChain({
|
|
213
|
-
id: 11820,
|
|
214
|
-
name: 'Artela Mainnet',
|
|
215
|
-
nativeCurrency: {
|
|
216
|
-
decimals: 18,
|
|
217
|
-
name: 'ART',
|
|
218
|
-
symbol: 'ART',
|
|
219
|
-
},
|
|
220
|
-
rpcUrls: {
|
|
221
|
-
default: {
|
|
222
|
-
http: ['https://node-euro.artela.network/rpc'],
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
blockExplorers: {
|
|
226
|
-
default: { name: 'Explorer', url: 'https://artscan.artela.network' },
|
|
227
|
-
},
|
|
228
|
-
contracts: {
|
|
229
|
-
multicall3: {
|
|
230
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
231
|
-
blockCreated: 1,
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
export const plasma = defineChain({
|
|
237
|
-
id: 9745,
|
|
238
|
-
name: 'Plasma Mainnet',
|
|
239
|
-
nativeCurrency: {
|
|
240
|
-
decimals: 18,
|
|
241
|
-
name: 'XPL',
|
|
242
|
-
symbol: 'XPL',
|
|
243
|
-
},
|
|
244
|
-
rpcUrls: {
|
|
245
|
-
default: {
|
|
246
|
-
http: ['https://rpc.plasma.to'],
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
blockExplorers: {
|
|
250
|
-
default: { name: 'Explorer', url: 'https://plasmascan.to/' },
|
|
251
|
-
},
|
|
252
|
-
contracts: {
|
|
253
|
-
multicall3: {
|
|
254
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
255
|
-
blockCreated: 1,
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
const monadMainnet = defineChain({
|
|
261
|
-
id: 143, // Chain ID for Monad Mainnet
|
|
262
|
-
name: 'Monad Mainnet',
|
|
263
|
-
network: 'monad',
|
|
264
|
-
nativeCurrency: {
|
|
265
|
-
name: 'Monad',
|
|
266
|
-
symbol: 'MON',
|
|
267
|
-
decimals: 18,
|
|
268
|
-
},
|
|
269
|
-
blockExplorers: {
|
|
270
|
-
default: { name: 'Explorer', url: 'https://monadvision.com/' },
|
|
271
|
-
},
|
|
272
|
-
rpcUrls: {
|
|
273
|
-
default: {
|
|
274
|
-
http: [
|
|
275
|
-
'https://rpc-mainnet.monadinfra.com',
|
|
276
|
-
'https://rpc.monad.xyz',
|
|
277
|
-
'https://rpc1.monad.xyz',
|
|
278
|
-
'https://rpc2.monad.xyz',
|
|
279
|
-
'https://rpc3.monad.xyz',
|
|
280
|
-
'https://rpc4.monad.xyz',
|
|
281
|
-
],
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
contracts: {
|
|
285
|
-
multicall3: {
|
|
286
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
287
|
-
blockCreated: 1,
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
export function getEvmChain(chain: string) {
|
|
293
|
-
switch (chain) {
|
|
294
|
-
case Chain.ARBITRUM_ONE:
|
|
295
|
-
return arbitrum
|
|
296
|
-
case Chain.ETHEREUM_MAINNET:
|
|
297
|
-
return mainnet
|
|
298
|
-
case Chain.MANTLE:
|
|
299
|
-
return mantle
|
|
300
|
-
case Chain.BNB_SMART_CHAIN_MAINNET:
|
|
301
|
-
return bsc
|
|
302
|
-
case Chain.OPBNB_MAINNET:
|
|
303
|
-
return opBNB
|
|
304
|
-
case Chain.TAIKO_ALETHIA:
|
|
305
|
-
return taiko
|
|
306
|
-
case Chain.AVALANCHE_C_CHAIN:
|
|
307
|
-
return avalanche
|
|
308
|
-
case Chain.OP_MAINNET:
|
|
309
|
-
return optimism
|
|
310
|
-
case Chain.METIS_ANDROMEDA_MAINNET:
|
|
311
|
-
return metis
|
|
312
|
-
case Chain.POLYGON_MAINNET:
|
|
313
|
-
return polygon
|
|
314
|
-
case Chain.ZKSYNC_MAINNET:
|
|
315
|
-
return zksync
|
|
316
|
-
case Chain.SCROLL:
|
|
317
|
-
return scroll
|
|
318
|
-
case Chain.GNOSIS:
|
|
319
|
-
return gnosis
|
|
320
|
-
case Chain.BASE:
|
|
321
|
-
return base
|
|
322
|
-
case Chain.BLAST:
|
|
323
|
-
return blast
|
|
324
|
-
case Chain.KAIA_MAINNET:
|
|
325
|
-
return kaia
|
|
326
|
-
case Chain.FANTOM_OPERA:
|
|
327
|
-
return fantom
|
|
328
|
-
case Chain.SONIC_MAINNET:
|
|
329
|
-
return sonic
|
|
330
|
-
case Chain.LINEA:
|
|
331
|
-
return linea
|
|
332
|
-
case Chain.HEMI_NETWORK:
|
|
333
|
-
return {
|
|
334
|
-
...hemi,
|
|
335
|
-
contracts: {
|
|
336
|
-
multicall3: {
|
|
337
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
338
|
-
blockCreated: 1,
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
}
|
|
342
|
-
case Chain.NEON_EVM_MAINNET:
|
|
343
|
-
return neonMainnet
|
|
344
|
-
case Chain.DEGEN_CHAIN:
|
|
345
|
-
return {
|
|
346
|
-
...degen,
|
|
347
|
-
contracts: {
|
|
348
|
-
multicall3: {
|
|
349
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
350
|
-
blockCreated: 1,
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
}
|
|
354
|
-
case Chain.GRAVITY_ALPHA_MAINNET:
|
|
355
|
-
return gravity
|
|
356
|
-
case Chain.LIGHTLINK_PHOENIX_MAINNET:
|
|
357
|
-
return lightlinkPhoenix
|
|
358
|
-
case Chain.PLUME_MAINNET:
|
|
359
|
-
return plume
|
|
360
|
-
case Chain.ABSTRACT:
|
|
361
|
-
return abstract
|
|
362
|
-
case Chain.PEAQ:
|
|
363
|
-
return peaq
|
|
364
|
-
case Chain.EVM_ON_FLOW:
|
|
365
|
-
return flowMainnet
|
|
366
|
-
case Chain.SONEIUM:
|
|
367
|
-
return soneium
|
|
368
|
-
case Chain.GOAT_NETWORK:
|
|
369
|
-
return goat
|
|
370
|
-
case Chain.BERACHAIN:
|
|
371
|
-
return berachain
|
|
372
|
-
case Chain.ROOTSTOCK_MAINNET:
|
|
373
|
-
return rootstock
|
|
374
|
-
case Chain.VANAR_MAINNET:
|
|
375
|
-
return vanar
|
|
376
|
-
case Chain.INK:
|
|
377
|
-
return {
|
|
378
|
-
...ink,
|
|
379
|
-
contracts: {
|
|
380
|
-
multicall3: {
|
|
381
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
382
|
-
blockCreated: 1,
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
}
|
|
386
|
-
case Chain.FUSE_MAINNET:
|
|
387
|
-
return fuse
|
|
388
|
-
case Chain.SUPERPOSITION:
|
|
389
|
-
return superposition
|
|
390
|
-
case Chain.STORY:
|
|
391
|
-
return {
|
|
392
|
-
...story,
|
|
393
|
-
contracts: {
|
|
394
|
-
multicall3: {
|
|
395
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
396
|
-
blockCreated: 1,
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
}
|
|
400
|
-
case Chain.APECHAIN:
|
|
401
|
-
return apeChain
|
|
402
|
-
case Chain.IOTEX_NETWORK_MAINNET:
|
|
403
|
-
return iotex
|
|
404
|
-
case Chain.TELOS_EVM_MAINNET:
|
|
405
|
-
return telos
|
|
406
|
-
case Chain.FLARE_MAINNET:
|
|
407
|
-
return flare
|
|
408
|
-
case Chain.AURA_MAINNET:
|
|
409
|
-
return aurora
|
|
410
|
-
case Chain.KAVA:
|
|
411
|
-
return kava
|
|
412
|
-
case Chain.IOTA_EVM:
|
|
413
|
-
return iota
|
|
414
|
-
case Chain.AURORA_MAINNET:
|
|
415
|
-
return aurora
|
|
416
|
-
case Chain.UNICHAIN:
|
|
417
|
-
return unichain
|
|
418
|
-
case Chain.CORE_BLOCKCHAIN_MAINNET:
|
|
419
|
-
return coreDao
|
|
420
|
-
case Chain.MODE:
|
|
421
|
-
return mode
|
|
422
|
-
case Chain.CORN:
|
|
423
|
-
return corn
|
|
424
|
-
case Chain.BOB:
|
|
425
|
-
return bob
|
|
426
|
-
case Chain.RONIN_MAINNET:
|
|
427
|
-
return ronin
|
|
428
|
-
case Chain.MANTA_PACIFIC_MAINNET:
|
|
429
|
-
return manta
|
|
430
|
-
case Chain.ZIRCUIT_MAINNET:
|
|
431
|
-
return zircuit
|
|
432
|
-
case Chain.GRAPHLINQ_BLOCKCHAIN_MAINNET:
|
|
433
|
-
return GraphLinq
|
|
434
|
-
case Chain.ZETACHAIN_MAINNET:
|
|
435
|
-
return zetachain
|
|
436
|
-
case Chain.BITLAYER_MAINNET:
|
|
437
|
-
return bitlayer
|
|
438
|
-
case Chain.CROSSFI_MAINNET:
|
|
439
|
-
return crossfi
|
|
440
|
-
case Chain.INEVM_MAINNET:
|
|
441
|
-
return inEVM
|
|
442
|
-
case Chain.XDC_NETWORK:
|
|
443
|
-
return xdc
|
|
444
|
-
case Chain.CRONOS_MAINNET:
|
|
445
|
-
return cronos
|
|
446
|
-
case Chain.CRONOS_ZKEVM_MAINNET:
|
|
447
|
-
return cronoszkEVM
|
|
448
|
-
case Chain.B2_MAINNET:
|
|
449
|
-
return {
|
|
450
|
-
...bsquared,
|
|
451
|
-
contracts: {
|
|
452
|
-
multicall3: {
|
|
453
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
454
|
-
blockCreated: 1,
|
|
455
|
-
},
|
|
456
|
-
},
|
|
457
|
-
}
|
|
458
|
-
case Chain.SEI_NETWORK:
|
|
459
|
-
return sei
|
|
460
|
-
case Chain.MERLIN_MAINNET:
|
|
461
|
-
return {
|
|
462
|
-
...merlin,
|
|
463
|
-
contracts: {
|
|
464
|
-
multicall3: {
|
|
465
|
-
address: '0x46063722c010AF39E465d286B84936A12aFb81F0',
|
|
466
|
-
blockCreated: 1,
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
}
|
|
470
|
-
case Chain.X_LAYER_MAINNET:
|
|
471
|
-
return xLayer
|
|
472
|
-
case Chain.CELO_MAINNET:
|
|
473
|
-
return celo
|
|
474
|
-
case Chain.BOTANIX_MAINNET:
|
|
475
|
-
return botanix
|
|
476
|
-
case Chain.HARMONY_MAINNET_SHARD_0:
|
|
477
|
-
return harmonyOne
|
|
478
|
-
case Chain.HYPEREVM:
|
|
479
|
-
return hyperEvm
|
|
480
|
-
case Chain.KATANA:
|
|
481
|
-
return katana
|
|
482
|
-
case Chain.TARAXA_MAINNET:
|
|
483
|
-
return taraxa
|
|
484
|
-
case Chain.METER_MAINNET:
|
|
485
|
-
return {
|
|
486
|
-
...meter,
|
|
487
|
-
contracts: {
|
|
488
|
-
multicall3: {
|
|
489
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
490
|
-
blockCreated: 1,
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
}
|
|
494
|
-
case Chain.ARTELA_MAINNET:
|
|
495
|
-
return artela
|
|
496
|
-
case Chain.MORPH:
|
|
497
|
-
return morph
|
|
498
|
-
case Chain.VANA:
|
|
499
|
-
return vana
|
|
500
|
-
// case Chain.RARI_CHAIN_MAINNET:
|
|
501
|
-
// return rariChain
|
|
502
|
-
// case Chain.GLUE_MAINNET:
|
|
503
|
-
// return glue
|
|
504
|
-
case Chain.PULSECHAIN:
|
|
505
|
-
return pulsechain
|
|
506
|
-
case Chain.PLASMA_MAINNET:
|
|
507
|
-
return plasma
|
|
508
|
-
case Chain.MOONBEAM:
|
|
509
|
-
return moonbeam
|
|
510
|
-
case Chain.MONAD_MAINNET:
|
|
511
|
-
return monadMainnet
|
|
512
|
-
case Chain.ZKLINK_NOVA_MAINNET:
|
|
513
|
-
return {
|
|
514
|
-
...zkLinkNova,
|
|
515
|
-
contracts: {
|
|
516
|
-
multicall3: {
|
|
517
|
-
address: '0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5',
|
|
518
|
-
blockCreated: 1,
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
}
|
|
522
|
-
// case Chain.AILAYER_MAINNET:
|
|
523
|
-
// return ailayer
|
|
524
|
-
default:
|
|
525
|
-
throw new Error('Not in VIEM: ' + chain)
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Get correct transport according to the input url with optional config
|
|
531
|
-
*/
|
|
532
|
-
export function createTransport(url: string, config?: any) {
|
|
533
|
-
if (!url) throw new Error('URL is required for transport')
|
|
534
|
-
if (url.startsWith('wss://')) {
|
|
535
|
-
return webSocket(url, config)
|
|
536
|
-
}
|
|
537
|
-
return http(url, config)
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Get correct transport according to the input url
|
|
542
|
-
*/
|
|
543
|
-
export function getTransport(url: string) {
|
|
544
|
-
return createTransport(url)
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
const LIST_OVERRIDES: { [c: string]: any[] } = {
|
|
548
|
-
[Chain.BASE]: [
|
|
549
|
-
'https://base-rpc.publicnode.com',
|
|
550
|
-
'https://base.llamarpc.com',
|
|
551
|
-
// 'https://base-mainnet.diamondswap.org/rpc',
|
|
552
|
-
'https://base.public.blockpi.network/v1/rpc/public',
|
|
553
|
-
'https://1rpc.io/base',
|
|
554
|
-
'https://base-pokt.nodies.app',
|
|
555
|
-
'https://base.meowrpc.com',
|
|
556
|
-
// 'https://base.gateway.tenderly.co',
|
|
557
|
-
// 'https://gateway.tenderly.co/public/base',
|
|
558
|
-
// 'https://rpc.notadegen.com/base',
|
|
559
|
-
'https://developer-access-mainnet.base.org',
|
|
560
|
-
'https://base.drpc.org',
|
|
561
|
-
'https://base.api.onfinality.io/public',
|
|
562
|
-
// 'https://public.stackup.sh/api/v1/node/base-mainnet',
|
|
563
|
-
// 'https://base-mainnet.gateway.tatum.io', // 5 req per min is too low
|
|
564
|
-
'https://base.rpc.subquery.network/public',
|
|
565
|
-
'https://api.zan.top/base-mainnet',
|
|
566
|
-
'https://endpoints.omniatech.io/v1/base/mainnet/public',
|
|
567
|
-
'https://base.lava.build',
|
|
568
|
-
// 'https://rpc.numa.network/base',
|
|
569
|
-
'https://0xrpc.io/base',
|
|
570
|
-
'https://base.therpc.io',
|
|
571
|
-
],
|
|
572
|
-
[Chain.POLYGON_MAINNET]: [
|
|
573
|
-
'https://polygon-bor-rpc.publicnode.com',
|
|
574
|
-
'https://polygon.lava.build',
|
|
575
|
-
'https://polygon.drpc.org',
|
|
576
|
-
'https://gateway.tenderly.co/public/polygon',
|
|
577
|
-
// 'https://polygon-mainnet.gateway.tatum.io',
|
|
578
|
-
'https://endpoints.omniatech.io/v1/matic/mainnet/public',
|
|
579
|
-
'https://polygon.therpc.io',
|
|
580
|
-
'https://rpc-mainnet.matic.quiknode.pro',
|
|
581
|
-
'https://polygon-pokt.nodies.app',
|
|
582
|
-
'https://polygon.gateway.tenderly.co',
|
|
583
|
-
'https://polygon-rpc.com',
|
|
584
|
-
'https://polygon.api.onfinality.io/public',
|
|
585
|
-
'https://api.zan.top/polygon-mainnet',
|
|
586
|
-
// 'https://1rpc.io/matic',
|
|
587
|
-
'https://polygon.rpc.subquery.network/public',
|
|
588
|
-
'https://polygon-mainnet.nodereal.io/v1/f510fc4d083b49d1ab383d25246cc7de',
|
|
589
|
-
'wss://polygon-mainnet.nodereal.io/ws/v1/f510fc4d083b49d1ab383d25246cc7de',
|
|
590
|
-
],
|
|
591
|
-
[Chain.HEMI_NETWORK]: [
|
|
592
|
-
'https://rpc.hemi.network/rpc',
|
|
593
|
-
// 'https://hemi.drpc.org'
|
|
594
|
-
],
|
|
595
|
-
[Chain.MANTLE]: [
|
|
596
|
-
'https://rpc.mantle.xyz',
|
|
597
|
-
'https://1rpc.io/mantle',
|
|
598
|
-
'https://api.zan.top/mantle-mainnet',
|
|
599
|
-
'https://mantle-public.nodies.app',
|
|
600
|
-
'https://mantle.drpc.org',
|
|
601
|
-
],
|
|
602
|
-
[Chain.XDC_NETWORK]: [
|
|
603
|
-
'https://rpc.ankr.com/xdc',
|
|
604
|
-
'https://earpc.xinfin.network',
|
|
605
|
-
'https://rpc.xinfin.network',
|
|
606
|
-
'https://rpc.xdc.org',
|
|
607
|
-
'https://rpc.xdc.network',
|
|
608
|
-
'https://erpc.xdcrpc.com',
|
|
609
|
-
],
|
|
610
|
-
[Chain.ETHEREUM_MAINNET]: [
|
|
611
|
-
'https://eth.llamarpc.com',
|
|
612
|
-
'https://api.zan.top/eth-mainnet',
|
|
613
|
-
'https://rpc.flashbots.net/fast',
|
|
614
|
-
'https://eth.merkle.io',
|
|
615
|
-
'https://rpc.payload.de',
|
|
616
|
-
'https://ethereum-rpc.publicnode.com',
|
|
617
|
-
'https://eth-mainnet.g.alchemy.com/v2/demo',
|
|
618
|
-
// 'https://go.getblock.io/aefd01aa907c4805ba3c00a9e5b48c6b',
|
|
619
|
-
'https://rpc.flashbots.net',
|
|
620
|
-
'https://public-eth.nownodes.io',
|
|
621
|
-
'https://ethereum-json-rpc.stakely.io',
|
|
622
|
-
'https://eth.blockrazor.xyz',
|
|
623
|
-
'https://eth.drpc.org',
|
|
624
|
-
'https://ethereum.public.blockpi.network/v1/rpc/public',
|
|
625
|
-
'https://ethereum-public.nodies.app',
|
|
626
|
-
'https://0xrpc.io/eth',
|
|
627
|
-
// 'https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7',
|
|
628
|
-
// 'wss://eth-mainnet.nodereal.io/ws/v1/1659dfb40aa24bbb8153a677b98064d7',
|
|
629
|
-
// 'https://rpc.owlracle.info/eth/70d38ce1826c4a60bb2a8e05a6c8b20f',
|
|
630
|
-
],
|
|
631
|
-
[Chain.PLASMA_MAINNET]: ['https://rpc.plasma.to', 'https://plasma.drpc.org'],
|
|
632
|
-
[Chain.SCROLL]: [
|
|
633
|
-
'https://rpc.scroll.io',
|
|
634
|
-
'https://1rpc.io/scroll',
|
|
635
|
-
'https://scroll.drpc.org',
|
|
636
|
-
'https://scroll.api.onfinality.io/public',
|
|
637
|
-
'https://endpoints.omniatech.io/v1/scroll/mainnet/public',
|
|
638
|
-
'https://scroll-rpc.publicnode.com',
|
|
639
|
-
'https://scroll.therpc.io',
|
|
640
|
-
],
|
|
641
|
-
[Chain.SONIC_MAINNET]: [
|
|
642
|
-
'https://sonic.api.onfinality.io/public',
|
|
643
|
-
'https://sonic-rpc.publicnode.com',
|
|
644
|
-
'https://rpc.soniclabs.com',
|
|
645
|
-
'https://sonic.therpc.io',
|
|
646
|
-
'https://sonic.drpc.org',
|
|
647
|
-
'https://sonic-json-rpc.stakely.io',
|
|
648
|
-
],
|
|
649
|
-
[Chain.KAIA_MAINNET]: [
|
|
650
|
-
// 'https://go.getblock.io/d7094dbd80ab474ba7042603fe912332',
|
|
651
|
-
'https://public-en.node.kaia.io',
|
|
652
|
-
'https://klaytn.api.onfinality.io/public',
|
|
653
|
-
'https://kaia-mainnet.gateway.tatum.io',
|
|
654
|
-
'https://kaia-public.nodies.app',
|
|
655
|
-
'https://kaia.blockpi.network/v1/rpc/public',
|
|
656
|
-
'https://rpc.ankr.com/kaia',
|
|
657
|
-
'https://klaytn.drpc.org',
|
|
658
|
-
'https://1rpc.io/klay',
|
|
659
|
-
],
|
|
660
|
-
[Chain.MOONBEAM]: [
|
|
661
|
-
'https://moonbeam.unitedbloc.com',
|
|
662
|
-
'https://1rpc.io/glmr',
|
|
663
|
-
'https://moonbeam-rpc.dwellir.com',
|
|
664
|
-
'https://moonbeam-rpc.publicnode.com',
|
|
665
|
-
'https://moonbeam.drpc.org',
|
|
666
|
-
'https://endpoints.omniatech.io/v1/moonbeam/mainnet/public',
|
|
667
|
-
'https://rpc.api.moonbeam.network',
|
|
668
|
-
'https://rpc.poolz.finance/moonbeam',
|
|
669
|
-
'https://moonbeam.rpc.grove.city/v1/01fdb492',
|
|
670
|
-
'https://moonbeam.api.onfinality.io/public',
|
|
671
|
-
],
|
|
672
|
-
[Chain.OP_MAINNET]: [
|
|
673
|
-
'https://optimism.public.blockpi.network/v1/rpc/public',
|
|
674
|
-
'https://optimism-rpc.publicnode.com',
|
|
675
|
-
'https://optimism.drpc.org',
|
|
676
|
-
'https://0xrpc.io/op',
|
|
677
|
-
'https://1rpc.io/op',
|
|
678
|
-
'wss://optimism-rpc.publicnode.com',
|
|
679
|
-
'wss://0xrpc.io/op',
|
|
680
|
-
'wss://optimism.drpc.org',
|
|
681
|
-
'https://optimism.api.onfinality.io/public',
|
|
682
|
-
'https://api.zan.top/opt-mainnet',
|
|
683
|
-
],
|
|
684
|
-
[Chain.BNB_SMART_CHAIN_MAINNET]: [
|
|
685
|
-
'https://bsc-dataseed.bnbchain.org',
|
|
686
|
-
'https://binance.nodereal.io',
|
|
687
|
-
'https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3',
|
|
688
|
-
'wss://bsc-mainnet.nodereal.io/ws/v1/64a9df0874fb4a93b9d0a3849de012d3',
|
|
689
|
-
'https://bsc-dataseed.binance.org',
|
|
690
|
-
'https://bsc-dataseed1.binance.org',
|
|
691
|
-
'https://bsc-dataseed1.defibit.io',
|
|
692
|
-
'https://bsc-dataseed2.defibit.io',
|
|
693
|
-
'https://bsc-dataseed3.defibit.io',
|
|
694
|
-
'https://bsc-dataseed4.defibit.io',
|
|
695
|
-
'https://1rpc.io/bnb',
|
|
696
|
-
'https://bsc-rpc.publicnode.com',
|
|
697
|
-
'https://bsc.drpc.org',
|
|
698
|
-
'https://bsc.api.onfinality.io/public',
|
|
699
|
-
],
|
|
700
|
-
[Chain.ARBITRUM_ONE]: [
|
|
701
|
-
'https://arb1.lava.build',
|
|
702
|
-
'https://arb1.arbitrum.io/rpc',
|
|
703
|
-
'https://arbitrum-one-rpc.publicnode.com',
|
|
704
|
-
'https://arbitrum.drpc.org',
|
|
705
|
-
'https://arbitrum.public.blockpi.network/v1/rpc/public',
|
|
706
|
-
'https://1rpc.io/arb',
|
|
707
|
-
'https://arbitrum.api.onfinality.io/public',
|
|
708
|
-
'https://0xrpc.io/arb',
|
|
709
|
-
'https://arbitrum.therpc.io',
|
|
710
|
-
],
|
|
711
|
-
[Chain.LINEA]: [
|
|
712
|
-
'https://rpc.linea.build',
|
|
713
|
-
'https://1rpc.io/linea',
|
|
714
|
-
'https://linea.drpc.org',
|
|
715
|
-
'https://linea-rpc.publicnode.com',
|
|
716
|
-
'https://linea.decubate.com',
|
|
717
|
-
'https://linea.api.onfinality.io/public',
|
|
718
|
-
],
|
|
719
|
-
[Chain.AVALANCHE_C_CHAIN]: [
|
|
720
|
-
'https://avalanche.drpc.org',
|
|
721
|
-
'https://1rpc.io/avax/c',
|
|
722
|
-
'https://avalanche-c-chain-rpc.publicnode.com',
|
|
723
|
-
'https://avalanche.api.onfinality.io/public/ext/bc/C/rpc',
|
|
724
|
-
'https://api.avax.network/ext/bc/C/rpc',
|
|
725
|
-
'https://avalanche.public-rpc.com',
|
|
726
|
-
'https://avax-rpc.gateway.pokt.network',
|
|
727
|
-
],
|
|
728
|
-
[Chain.CELO_MAINNET]: [
|
|
729
|
-
'https://forno.celo.org',
|
|
730
|
-
'https://1rpc.io/celo',
|
|
731
|
-
'https://celo.drpc.org',
|
|
732
|
-
'https://celo-rpc.publicnode.com',
|
|
733
|
-
],
|
|
734
|
-
[Chain.BLAST]: [
|
|
735
|
-
'https://rpc.blast.io',
|
|
736
|
-
'https://blast.drpc.org',
|
|
737
|
-
'https://blast-rpc.publicnode.com',
|
|
738
|
-
],
|
|
739
|
-
[Chain.TAIKO_ALETHIA]: [
|
|
740
|
-
'https://rpc.taiko.xyz',
|
|
741
|
-
'https://rpc.ankr.com/taiko',
|
|
742
|
-
'https://rpc.mainnet.taiko.xyz',
|
|
743
|
-
'https://taiko-rpc.publicnode.com',
|
|
744
|
-
],
|
|
745
|
-
[Chain.GNOSIS]: [
|
|
746
|
-
'https://gnosis.oat.farm',
|
|
747
|
-
'https://rpc.gnosischain.com',
|
|
748
|
-
'https://gnosis.drpc.org',
|
|
749
|
-
'https://gnosis-rpc.publicnode.com',
|
|
750
|
-
'https://1rpc.io/gnosis',
|
|
751
|
-
],
|
|
752
|
-
[Chain.CORE_BLOCKCHAIN_MAINNET]: [
|
|
753
|
-
'https://rpc.coredao.org',
|
|
754
|
-
'https://core.drpc.org',
|
|
755
|
-
'https://core-rpc.publicnode.com',
|
|
756
|
-
],
|
|
757
|
-
[Chain.MODE]: [
|
|
758
|
-
'https://mainnet.mode.network',
|
|
759
|
-
'https://mode.drpc.org',
|
|
760
|
-
'https://mode-rpc.publicnode.com',
|
|
761
|
-
],
|
|
762
|
-
[Chain.METIS_ANDROMEDA_MAINNET]: [
|
|
763
|
-
'https://andromeda.metis.io/?owner=1088',
|
|
764
|
-
'https://metis.drpc.org',
|
|
765
|
-
'https://metis-rpc.publicnode.com',
|
|
766
|
-
'https://metis.api.onfinality.io/public',
|
|
767
|
-
],
|
|
768
|
-
[Chain.FANTOM_OPERA]: [
|
|
769
|
-
'https://rpc.fantom.network',
|
|
770
|
-
'https://fantom.drpc.org',
|
|
771
|
-
'https://fantom-rpc.publicnode.com',
|
|
772
|
-
'https://1rpc.io/ftm',
|
|
773
|
-
'https://fantom.api.onfinality.io/public',
|
|
774
|
-
],
|
|
775
|
-
[Chain.OPBNB_MAINNET]: [
|
|
776
|
-
'https://opbnb-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3',
|
|
777
|
-
'wss://opbnb-mainnet.nodereal.io/ws/v1/64a9df0874fb4a93b9d0a3849de012d3',
|
|
778
|
-
],
|
|
779
|
-
[Chain.X_LAYER_MAINNET]: ['https://xlayerrpc.okx.com'],
|
|
780
|
-
[Chain.MANTA_PACIFIC_MAINNET]: [
|
|
781
|
-
'https://manta.nirvanalabs.xyz/mantapublic',
|
|
782
|
-
'https://manta-pacific-gascap.calderachain.xyz/http',
|
|
783
|
-
'https://manta-pacific.calderachain.xyz/http',
|
|
784
|
-
'https://pacific-rpc.manta.network/http',
|
|
785
|
-
'https://r1.pacific.manta.systems/http',
|
|
786
|
-
'wss://manta-pacific.calderachain.xyz/ws',
|
|
787
|
-
'https://1rpc.io/manta',
|
|
788
|
-
],
|
|
789
|
-
[Chain.SEI_NETWORK]: [
|
|
790
|
-
'https://evm-rpc.sei-apis.com',
|
|
791
|
-
'https://sei.drpc.org',
|
|
792
|
-
'https://sei-evm-rpc.stakeme.pro',
|
|
793
|
-
'https://sei-public.nodies.app',
|
|
794
|
-
'wss://sei.drpc.org',
|
|
795
|
-
'wss://evm-ws.sei-apis.com',
|
|
796
|
-
],
|
|
797
|
-
[Chain.MONAD_MAINNET]: [
|
|
798
|
-
'https://rpc-mainnet.monadinfra.com',
|
|
799
|
-
'https://rpc.monad.xyz',
|
|
800
|
-
'https://rpc1.monad.xyz',
|
|
801
|
-
'https://rpc2.monad.xyz',
|
|
802
|
-
'https://rpc3.monad.xyz',
|
|
803
|
-
'https://rpc4.monad.xyz',
|
|
804
|
-
],
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function trimTrailingSlash(url?: string) {
|
|
808
|
-
if (!url) return undefined
|
|
809
|
-
return url.endsWith('/') ? url.slice(0, -1) : url
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
function getEvmClientInternal(chain: string, rpcId = 0): PublicClient {
|
|
813
|
-
const chainInfo = getEvmChain(chain)
|
|
814
|
-
let rpc: string
|
|
815
|
-
if (rpcId === 0)
|
|
816
|
-
// use base one - or use override if not available
|
|
817
|
-
rpc = chainInfo.rpcUrls.default.http[0] ?? LIST_OVERRIDES[chain]?.[0]
|
|
818
|
-
else {
|
|
819
|
-
const rpcsChain = LIST_OVERRIDES[chain] ?? chains()?.[chain]?.rpc
|
|
820
|
-
const rpcs = chainInfo.rpcUrls.default.http.map((a) => trimTrailingSlash(a))
|
|
821
|
-
const rpcsAdded = rpcsChain.map((a) => trimTrailingSlash(a))
|
|
822
|
-
const allRpcs = uniq([...rpcsAdded, ...rpcs])
|
|
823
|
-
const currId = Math.min(allRpcs.length - 1, rpcId)
|
|
824
|
-
rpc = allRpcs[currId] as any
|
|
825
|
-
}
|
|
826
|
-
if (!rpc)
|
|
827
|
-
throw new Error('Failed to get RPC at index ' + rpcId + ' for ' + chain)
|
|
828
|
-
return createPublicClient({
|
|
829
|
-
chain: chainInfo as any,
|
|
830
|
-
transport: createTransport(rpc),
|
|
831
|
-
}) as any
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* @deprecated Use getEvmClientUniversal instead
|
|
836
|
-
*/
|
|
837
|
-
export function getEvmClient(chain: string, rpcId = 0): PublicClient {
|
|
838
|
-
return getEvmClientInternal(chain, rpcId)
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
export function getEvmClientUniversal({
|
|
842
|
-
chain,
|
|
843
|
-
rpcId = 0,
|
|
844
|
-
}: {
|
|
845
|
-
chain: string
|
|
846
|
-
rpcId: number
|
|
847
|
-
}): PublicClient {
|
|
848
|
-
return getEvmClientInternal(chain, rpcId)
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
const DEFAULT_BATCH_SIZE = 4096
|
|
852
|
-
|
|
853
|
-
export function createMulticallRetry(
|
|
854
|
-
customRpcs: {
|
|
855
|
-
[chainId: string]: string[]
|
|
856
|
-
} = LIST_OVERRIDES,
|
|
857
|
-
) {
|
|
858
|
-
return async function multicallRetry(
|
|
859
|
-
chain: string,
|
|
860
|
-
calls: any[],
|
|
861
|
-
abi: any,
|
|
862
|
-
batchSize = DEFAULT_BATCH_SIZE,
|
|
863
|
-
maxRetries = 3,
|
|
864
|
-
providerId = 0,
|
|
865
|
-
allowFailure = true,
|
|
866
|
-
logErrors = false,
|
|
867
|
-
) {
|
|
868
|
-
try {
|
|
869
|
-
const provider = getEvmClientWithCustomRpcs(chain, providerId, customRpcs)
|
|
870
|
-
const abiIsArray = isArray(abi[0])
|
|
871
|
-
const data = await provider.multicall({
|
|
872
|
-
batchSize,
|
|
873
|
-
contracts: calls.map((call, i) => ({
|
|
874
|
-
abi: abiIsArray ? abi?.[i] : abi,
|
|
875
|
-
address: call.address as any,
|
|
876
|
-
functionName: call.name,
|
|
877
|
-
// @ts-ignore
|
|
878
|
-
args: call.args ?? call.params ?? [],
|
|
879
|
-
})),
|
|
880
|
-
allowFailure,
|
|
881
|
-
})
|
|
882
|
-
if (allowFailure) {
|
|
883
|
-
return (data as any[]).map(({ result, status }: any) =>
|
|
884
|
-
status !== 'success' ? '0x' : result,
|
|
885
|
-
)
|
|
886
|
-
}
|
|
887
|
-
return data
|
|
888
|
-
} catch (e) {
|
|
889
|
-
// error if max retries achieved
|
|
890
|
-
if (maxRetries === 0) throw e
|
|
891
|
-
|
|
892
|
-
if (logErrors) console.log(e)
|
|
893
|
-
|
|
894
|
-
return await multicallRetry(
|
|
895
|
-
chain,
|
|
896
|
-
calls,
|
|
897
|
-
abi,
|
|
898
|
-
batchSize,
|
|
899
|
-
maxRetries - 1,
|
|
900
|
-
providerId + 1,
|
|
901
|
-
false,
|
|
902
|
-
logErrors,
|
|
903
|
-
)
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
function getEvmClientWithCustomRpcsInternal(
|
|
909
|
-
chain: string,
|
|
910
|
-
rpcId = 0,
|
|
911
|
-
customRpcs: { [chainId: string]: string[] } = LIST_OVERRIDES,
|
|
912
|
-
): PublicClient {
|
|
913
|
-
const chainInfo = getEvmChain(chain)
|
|
914
|
-
let rpc: string
|
|
915
|
-
|
|
916
|
-
if (customRpcs && customRpcs[chain]) {
|
|
917
|
-
// Use custom RPC list if any (make sure that they are unique and valid)
|
|
918
|
-
const customRpcList = uniq(
|
|
919
|
-
customRpcs[chain]
|
|
920
|
-
.filter(Boolean) // Remove empty ones
|
|
921
|
-
.map((url) => trimTrailingSlash(url))
|
|
922
|
-
.filter((url): url is string => Boolean(url)), // Type-safe filter for defined URLs
|
|
923
|
-
)
|
|
924
|
-
|
|
925
|
-
if (customRpcList.length === 0) {
|
|
926
|
-
throw new Error(`No valid custom RPCs provided for chain ${chain}`)
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
rpc = customRpcList[rpcId % customRpcList.length]
|
|
930
|
-
} else {
|
|
931
|
-
// Fallback to existing logic
|
|
932
|
-
if (rpcId === 0)
|
|
933
|
-
rpc = chainInfo.rpcUrls.default.http[0] ?? LIST_OVERRIDES[chain]?.[0]
|
|
934
|
-
else {
|
|
935
|
-
const rpcsChain = chains()?.[chain]?.rpc
|
|
936
|
-
const rpcs = chainInfo.rpcUrls.default.http.map((a) =>
|
|
937
|
-
trimTrailingSlash(a),
|
|
938
|
-
)
|
|
939
|
-
const rpcsAdded = rpcsChain?.map((a) => trimTrailingSlash(a))
|
|
940
|
-
const allRpcs = uniq([...rpcs, ...rpcsAdded])
|
|
941
|
-
const currId = Math.min(allRpcs.length - 1, rpcId)
|
|
942
|
-
rpc = allRpcs[currId] as any
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
if (!rpc)
|
|
946
|
-
throw new Error('Failed to get RPC at index ' + rpcId + ' for ' + chain)
|
|
947
|
-
return createPublicClient({
|
|
948
|
-
chain: chainInfo as any,
|
|
949
|
-
transport: createTransport(rpc),
|
|
950
|
-
}) as any
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* @deprecated Use getEvmClientWithCustomRpcsUniversal instead
|
|
955
|
-
*/
|
|
956
|
-
export function getEvmClientWithCustomRpcs(
|
|
957
|
-
chain: string,
|
|
958
|
-
rpcId = 0,
|
|
959
|
-
customRpcs: { [chainId: string]: string[] } = LIST_OVERRIDES,
|
|
960
|
-
): PublicClient {
|
|
961
|
-
return getEvmClientWithCustomRpcsInternal(chain, rpcId, customRpcs)
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
export function getEvmClientWithCustomRpcsUniversal({
|
|
965
|
-
chain,
|
|
966
|
-
rpcId = 0,
|
|
967
|
-
customRpcs = LIST_OVERRIDES,
|
|
968
|
-
}: {
|
|
969
|
-
chain: string
|
|
970
|
-
rpcId: number
|
|
971
|
-
customRpcs: { [chainId: string]: string[] }
|
|
972
|
-
}): PublicClient {
|
|
973
|
-
return getEvmClientWithCustomRpcsInternal(chain, rpcId, customRpcs)
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
async function multicallRetryInternal(
|
|
977
|
-
chain: string,
|
|
978
|
-
calls: any[],
|
|
979
|
-
abi: any,
|
|
980
|
-
batchSize = DEFAULT_BATCH_SIZE,
|
|
981
|
-
maxRetries = 5,
|
|
982
|
-
providerId = 0,
|
|
983
|
-
allowFailure = false,
|
|
984
|
-
overrdies: {
|
|
985
|
-
[chainId: string]: string[]
|
|
986
|
-
} = LIST_OVERRIDES,
|
|
987
|
-
logErrors = false,
|
|
988
|
-
) {
|
|
989
|
-
const defaultMulticallRetry = createMulticallRetry(overrdies)
|
|
990
|
-
return defaultMulticallRetry(
|
|
991
|
-
chain,
|
|
992
|
-
calls,
|
|
993
|
-
abi,
|
|
994
|
-
batchSize,
|
|
995
|
-
maxRetries,
|
|
996
|
-
providerId,
|
|
997
|
-
allowFailure,
|
|
998
|
-
logErrors,
|
|
999
|
-
)
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* @deprecated Use multicallRetryUniversal instead
|
|
1004
|
-
*/
|
|
1005
|
-
export async function multicallRetry(
|
|
1006
|
-
chain: string,
|
|
1007
|
-
calls: any[],
|
|
1008
|
-
abi: any,
|
|
1009
|
-
batchSize = DEFAULT_BATCH_SIZE,
|
|
1010
|
-
maxRetries = 5,
|
|
1011
|
-
providerId = 0,
|
|
1012
|
-
allowFailure = false,
|
|
1013
|
-
overrdies: {
|
|
1014
|
-
[chainId: string]: string[]
|
|
1015
|
-
} = LIST_OVERRIDES,
|
|
1016
|
-
logErrors = false,
|
|
1017
|
-
) {
|
|
1018
|
-
return multicallRetryInternal(
|
|
1019
|
-
chain,
|
|
1020
|
-
calls,
|
|
1021
|
-
abi,
|
|
1022
|
-
batchSize,
|
|
1023
|
-
maxRetries,
|
|
1024
|
-
providerId,
|
|
1025
|
-
allowFailure,
|
|
1026
|
-
overrdies,
|
|
1027
|
-
logErrors,
|
|
1028
|
-
)
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
export interface MulticallRetryParams {
|
|
1032
|
-
chain: string
|
|
1033
|
-
calls: any[]
|
|
1034
|
-
abi: any
|
|
1035
|
-
batchSize?: number
|
|
1036
|
-
maxRetries?: number
|
|
1037
|
-
providerId?: number
|
|
1038
|
-
allowFailure?: boolean
|
|
1039
|
-
overrdies?: {
|
|
1040
|
-
[chainId: string]: string[]
|
|
1041
|
-
}
|
|
1042
|
-
logErrors?: boolean
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
export async function multicallRetryUniversal({
|
|
1046
|
-
chain,
|
|
1047
|
-
calls,
|
|
1048
|
-
abi,
|
|
1049
|
-
batchSize = DEFAULT_BATCH_SIZE,
|
|
1050
|
-
maxRetries = 5,
|
|
1051
|
-
providerId = 0,
|
|
1052
|
-
allowFailure = false,
|
|
1053
|
-
overrdies = LIST_OVERRIDES,
|
|
1054
|
-
logErrors = false,
|
|
1055
|
-
}: MulticallRetryParams) {
|
|
1056
|
-
return multicallRetryInternal(
|
|
1057
|
-
chain,
|
|
1058
|
-
calls,
|
|
1059
|
-
abi,
|
|
1060
|
-
batchSize,
|
|
1061
|
-
maxRetries,
|
|
1062
|
-
providerId,
|
|
1063
|
-
allowFailure,
|
|
1064
|
-
overrdies,
|
|
1065
|
-
logErrors,
|
|
1066
|
-
)
|
|
1067
|
-
}
|
|
1
|
+
export * from './chains/customChains'
|
|
2
|
+
export * from './chains/chainMapping'
|
|
3
|
+
export * from './rpc/rpcOverrides'
|
|
4
|
+
export * from './transport/transport'
|
|
5
|
+
export * from './utils/utils'
|
|
6
|
+
export * from './client/client'
|
|
7
|
+
export * from './multicall/multicall'
|