@1delta/providers 0.0.42 → 0.0.44

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.42",
3
+ "version": "0.0.44",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -17,15 +17,13 @@
17
17
  "author": "",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "lodash": "^4.17.21",
21
- "vitest": "^4.0.15",
22
- "@1delta/chain-registry": "0.0.4",
23
- "@1delta/data-sdk": "0.0.11"
20
+ "vitest": "^4.0.18",
21
+ "@1delta/data-sdk": "0.0.14",
22
+ "@1delta/chain-registry": "0.0.4"
24
23
  },
25
24
  "devDependencies": {
26
- "@types/lodash": "^4.17.21",
27
- "typescript": "^5.9.3",
28
- "tsup": "^8.5.1"
25
+ "tsup": "^8.5.1",
26
+ "typescript": "^5.9.3"
29
27
  },
30
28
  "scripts": {
31
29
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -68,6 +68,7 @@ import {
68
68
  taraxa,
69
69
  meter,
70
70
  morph,
71
+ worldchain,
71
72
  moonbeam,
72
73
  zkLinkNova,
73
74
  vana,
@@ -265,7 +266,15 @@ export function getEvmChain(chain: string) {
265
266
  case Chain.KATANA:
266
267
  return katana
267
268
  case Chain.TARAXA_MAINNET:
268
- return taraxa
269
+ return {
270
+ ...taraxa,
271
+ contracts: {
272
+ multicall3: {
273
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
274
+ blockCreated: 1,
275
+ },
276
+ },
277
+ }
269
278
  case Chain.METER_MAINNET:
270
279
  return {
271
280
  ...meter,
@@ -288,6 +297,8 @@ export function getEvmChain(chain: string) {
288
297
  return plasma
289
298
  case Chain.MOONBEAM:
290
299
  return moonbeam
300
+ case Chain.WORLD_CHAIN:
301
+ return worldchain
291
302
  case Chain.MONAD_MAINNET:
292
303
  return customChains.monadMainnet
293
304
  case Chain.ZKLINK_NOVA_MAINNET:
@@ -1,12 +1,9 @@
1
1
  import { chains } from '@1delta/data-sdk'
2
2
  import { createPublicClient, PublicClient } from 'viem'
3
- import lodash from 'lodash'
4
3
  import { getEvmChain } from '../chains/chainMapping'
5
4
  import { LIST_OVERRIDES } from '../rpc/rpcOverrides'
6
5
  import { createTransport } from '../transport/transport'
7
- import { trimTrailingSlash } from '../utils/utils'
8
-
9
- const { uniq } = lodash
6
+ import { trimTrailingSlash, uniq } from '../utils/utils'
10
7
 
11
8
  function getEvmClientInternal(chain: string, rpcId = 0): PublicClient {
12
9
  const chainInfo = getEvmChain(chain)
@@ -3,12 +3,20 @@ import {
3
3
  ContractFunctionExecutionError,
4
4
  ContractFunctionRevertedError,
5
5
  } from 'viem'
6
- import lodash from 'lodash'
7
6
  import { LIST_OVERRIDES } from '../rpc/rpcOverrides'
8
7
  import { getEvmClientWithCustomRpcsUniversal } from '../client/client'
9
- import { DEFAULT_BATCH_SIZE, deepCompare } from '../utils/utils'
8
+ import { DEFAULT_BATCH_SIZE, deepCompare, isArray } from '../utils/utils'
10
9
 
11
- const { isArray } = lodash
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
+ }
12
20
 
13
21
  /** Return true if it is a revert case */
14
22
  function isContractRevert(e: unknown): boolean {
@@ -59,6 +67,7 @@ export function createMulticallRetry(
59
67
  allowFailure = true,
60
68
  logErrors = false,
61
69
  revertedIndices: Set<number> = new Set(),
70
+ maxSkips = 3,
62
71
  ): Promise<any[]> {
63
72
  const abiIsArray = isArray(abi[0])
64
73
 
@@ -153,6 +162,24 @@ export function createMulticallRetry(
153
162
  }
154
163
  }
155
164
 
165
+ // Transport/environment errors (e.g. WebSocket not available):
166
+ // skip to next RPC without consuming a retry
167
+ if (isTransportError(e) && maxSkips > 0) {
168
+ if (logErrors) console.debug(e)
169
+ return await multicallRetry(
170
+ chain,
171
+ calls,
172
+ abi,
173
+ batchSize,
174
+ maxRetries,
175
+ providerId + 1,
176
+ allowFailure,
177
+ logErrors,
178
+ revertedIndices,
179
+ maxSkips - 1,
180
+ )
181
+ }
182
+
156
183
  if (maxRetries === 0) {
157
184
  if (!allowFailure) throw e
158
185
  if (logErrors) console.debug(e)
@@ -171,6 +198,7 @@ export function createMulticallRetry(
171
198
  allowFailure,
172
199
  logErrors,
173
200
  revertedIndices,
201
+ maxSkips,
174
202
  )
175
203
  }
176
204
  }
@@ -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',
@@ -45,3 +45,11 @@ export function deepCompare(a: any, b: any): boolean {
45
45
 
46
46
  return true
47
47
  }
48
+
49
+ export function uniq<T>(array: T[]): T[] {
50
+ return [...new Set(array)]
51
+ }
52
+
53
+ export function isArray(value: any): boolean {
54
+ return Array.isArray(value)
55
+ }