@1delta/providers 0.0.43 → 0.0.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/providers",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -18,8 +18,8 @@
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
20
  "vitest": "^4.0.18",
21
- "@1delta/chain-registry": "0.0.4",
22
- "@1delta/data-sdk": "0.0.14"
21
+ "@1delta/data-sdk": "0.0.14",
22
+ "@1delta/chain-registry": "0.0.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.1",
@@ -68,9 +68,11 @@ import {
68
68
  taraxa,
69
69
  meter,
70
70
  morph,
71
+ worldchain,
71
72
  moonbeam,
72
73
  zkLinkNova,
73
74
  vana,
75
+ confluxESpace,
74
76
  } from 'viem/chains'
75
77
  import { customChains, katana, plasma } from './customChains'
76
78
 
@@ -264,6 +266,8 @@ export function getEvmChain(chain: string) {
264
266
  return customChains.hyperEvm
265
267
  case Chain.KATANA:
266
268
  return katana
269
+ case Chain.CONFLUX_ESPACE:
270
+ return confluxESpace
267
271
  case Chain.TARAXA_MAINNET:
268
272
  return {
269
273
  ...taraxa,
@@ -296,6 +300,8 @@ export function getEvmChain(chain: string) {
296
300
  return plasma
297
301
  case Chain.MOONBEAM:
298
302
  return moonbeam
303
+ case Chain.WORLD_CHAIN:
304
+ return worldchain
299
305
  case Chain.MONAD_MAINNET:
300
306
  return customChains.monadMainnet
301
307
  case Chain.ZKLINK_NOVA_MAINNET:
@@ -7,6 +7,17 @@ import { LIST_OVERRIDES } from '../rpc/rpcOverrides'
7
7
  import { getEvmClientWithCustomRpcsUniversal } from '../client/client'
8
8
  import { DEFAULT_BATCH_SIZE, deepCompare, isArray } from '../utils/utils'
9
9
 
10
+ /** Return true if the error is a transport/environment issue (not an RPC or contract error) */
11
+ function isTransportError(e: unknown): boolean {
12
+ const msg =
13
+ e instanceof Error ? (e.message ?? '') + ((e as any).details ?? '') : ''
14
+ return (
15
+ msg.includes('is not a constructor') ||
16
+ msg.includes('Dynamic require') ||
17
+ msg.includes('is not supported')
18
+ )
19
+ }
20
+
10
21
  /** Return true if it is a revert case */
11
22
  function isContractRevert(e: unknown): boolean {
12
23
  if (!(e instanceof BaseError)) return false
@@ -56,6 +67,7 @@ export function createMulticallRetry(
56
67
  allowFailure = true,
57
68
  logErrors = false,
58
69
  revertedIndices: Set<number> = new Set(),
70
+ maxSkips = 3,
59
71
  ): Promise<any[]> {
60
72
  const abiIsArray = isArray(abi[0])
61
73
 
@@ -82,9 +94,17 @@ export function createMulticallRetry(
82
94
  functionName: call.name,
83
95
  args: call.args ?? call.params ?? [],
84
96
  })),
85
- allowFailure: false,
97
+ allowFailure,
86
98
  })
87
99
 
100
+ // When allowFailure is true, viem returns { result, status } per call.
101
+ // Extract results and convert failures to '0x'.
102
+ const resolvedData = allowFailure
103
+ ? (data as any[]).map(({ result, status }: any) =>
104
+ status !== 'success' ? '0x' : result,
105
+ )
106
+ : data
107
+
88
108
  if (revertedIndices.size > 0) {
89
109
  const finalResults: any[] = []
90
110
  let filteredIndex = 0
@@ -93,13 +113,13 @@ export function createMulticallRetry(
93
113
  if (revertedIndices.has(i)) {
94
114
  finalResults.push('0x')
95
115
  } else {
96
- finalResults.push(data[filteredIndex++])
116
+ finalResults.push(resolvedData[filteredIndex++])
97
117
  }
98
118
  }
99
119
  return finalResults
100
120
  }
101
121
 
102
- return data
122
+ return resolvedData
103
123
  } catch (e) {
104
124
  if (isContractRevert(e)) {
105
125
  const error = e as ContractFunctionExecutionError
@@ -150,6 +170,24 @@ export function createMulticallRetry(
150
170
  }
151
171
  }
152
172
 
173
+ // Transport/environment errors (e.g. WebSocket not available):
174
+ // skip to next RPC without consuming a retry
175
+ if (isTransportError(e) && maxSkips > 0) {
176
+ if (logErrors) console.debug(e)
177
+ return await multicallRetry(
178
+ chain,
179
+ calls,
180
+ abi,
181
+ batchSize,
182
+ maxRetries,
183
+ providerId + 1,
184
+ allowFailure,
185
+ logErrors,
186
+ revertedIndices,
187
+ maxSkips - 1,
188
+ )
189
+ }
190
+
153
191
  if (maxRetries === 0) {
154
192
  if (!allowFailure) throw e
155
193
  if (logErrors) console.debug(e)
@@ -168,6 +206,7 @@ export function createMulticallRetry(
168
206
  allowFailure,
169
207
  logErrors,
170
208
  revertedIndices,
209
+ maxSkips,
171
210
  )
172
211
  }
173
212
  }
@@ -1,5 +1,16 @@
1
1
  import { Chain } from '@1delta/chain-registry'
2
2
 
3
+ export function filterHttpRpcs(
4
+ rpcs: Record<string, string[]>,
5
+ ): Record<string, string[]> {
6
+ return Object.fromEntries(
7
+ Object.entries(rpcs).map(([chain, urls]) => [
8
+ chain,
9
+ urls.filter((url) => !url.startsWith('wss://')),
10
+ ]),
11
+ )
12
+ }
13
+
3
14
  export const LIST_OVERRIDES: Record<string, string[]> = {
4
15
  [Chain.BASE]: [
5
16
  'https://base-rpc.publicnode.com',
@@ -16,7 +27,6 @@ export const LIST_OVERRIDES: Record<string, string[]> = {
16
27
  'https://endpoints.omniatech.io/v1/base/mainnet/public',
17
28
  'https://base.lava.build',
18
29
  'https://0xrpc.io/base',
19
- 'https://base.therpc.io',
20
30
  ],
21
31
  [Chain.POLYGON_MAINNET]: [
22
32
  'https://polygon-bor-rpc.publicnode.com',
@@ -24,7 +34,6 @@ export const LIST_OVERRIDES: Record<string, string[]> = {
24
34
  'https://polygon.drpc.org',
25
35
  'https://gateway.tenderly.co/public/polygon',
26
36
  'https://endpoints.omniatech.io/v1/matic/mainnet/public',
27
- 'https://polygon.therpc.io',
28
37
  'https://rpc-mainnet.matic.quiknode.pro',
29
38
  'https://polygon-pokt.nodies.app',
30
39
  'https://polygon.gateway.tenderly.co',
@@ -80,13 +89,11 @@ export const LIST_OVERRIDES: Record<string, string[]> = {
80
89
  'https://scroll.api.onfinality.io/public',
81
90
  'https://endpoints.omniatech.io/v1/scroll/mainnet/public',
82
91
  'https://scroll-rpc.publicnode.com',
83
- 'https://scroll.therpc.io',
84
92
  ],
85
93
  [Chain.SONIC_MAINNET]: [
86
94
  'https://sonic.api.onfinality.io/public',
87
95
  'https://sonic-rpc.publicnode.com',
88
96
  'https://rpc.soniclabs.com',
89
- 'https://sonic.therpc.io',
90
97
  'https://sonic.drpc.org',
91
98
  'https://sonic-json-rpc.stakely.io',
92
99
  ],
@@ -149,7 +156,6 @@ export const LIST_OVERRIDES: Record<string, string[]> = {
149
156
  'https://1rpc.io/arb',
150
157
  'https://arbitrum.api.onfinality.io/public',
151
158
  'https://0xrpc.io/arb',
152
- 'https://arbitrum.therpc.io',
153
159
  ],
154
160
  [Chain.LINEA]: [
155
161
  'https://rpc.linea.build',