@1delta/providers 0.0.2 → 0.0.3

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/evm.d.ts CHANGED
@@ -111,5 +111,8 @@ export declare function getEvmClient(chain: string, rpcId?: number): PublicClien
111
111
  export declare function createMulticallRetry(customRpcs?: {
112
112
  [chainId: string]: string[];
113
113
  }): (chain: string, calls: any[], abi: any, batchSize?: number, maxRetries?: number, providerId?: number, allowFailure?: boolean) => Promise<any[]>;
114
+ export declare function getEvmClientWithCustomRpcs(chain: string, rpcId?: number, customRpcs?: {
115
+ [chainId: string]: string[];
116
+ }): PublicClient;
114
117
  export declare function multicallRetry(chain: string, calls: any[], abi: any, batchSize?: number, maxRetries?: number, providerId?: number): Promise<any[]>;
115
118
  //# sourceMappingURL=evm.d.ts.map
package/dist/evm.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../src/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyC,YAAY,EAAE,MAAM,MAAM,CAAA;AAkE1E,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBlB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBlB,CAAC;AAGH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AA8MH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,YAAY,CAmBnE;AAID,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,IAEzE,OAAO,MAAM,EACb,OAAO,GAAG,EAAE,EACZ,KAAK,GAAG,EACR,kBAA8B,EAC9B,mBAAc,EACd,mBAAc,EACd,sBAAmB,oBA6B1B;AA0CD,wBAAsB,cAAc,CAChC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,EAAE,EACZ,GAAG,EAAE,GAAG,EACR,SAAS,SAAqB,EAC9B,UAAU,SAAI,EACd,UAAU,SAAI,kBAIjB"}
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../src/evm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyC,YAAY,EAAE,MAAM,MAAM,CAAC;AAiE3E,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBlB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AA6MH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,YAAY,CAmBnE;AAID,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE;IAChD,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,IAEG,OAAO,MAAM,EACb,OAAO,GAAG,EAAE,EACZ,KAAK,GAAG,EACR,kBAA8B,EAC9B,mBAAc,EACd,mBAAc,EACd,sBAAmB,oBAwCtB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,KAAK,SAAI,EACT,UAAU,CAAC,EAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,GAC3C,YAAY,CAuCd;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,EAAE,EACZ,GAAG,EAAE,GAAG,EACR,SAAS,SAAqB,EAC9B,UAAU,SAAI,EACd,UAAU,SAAI,kBAWf"}
package/dist/evm.js CHANGED
@@ -4,19 +4,19 @@ import { createPublicClient, defineChain, http } from "viem";
4
4
  import { mantle, mainnet, optimism, arbitrum, bsc, avalanche, taiko, metis, polygon, zksync, scroll, gnosis, base, blast, kaia, opBNB, fantom, sonic, linea, hemi, neonMainnet, degen, gravity, lightlinkPhoenix, plume, abstract, peaq, flowMainnet, soneium, goat, berachain, rootstock, ink, vanar, fuse, superposition, story, apeChain, telos, flare, aurora, kava, iota, coreDao, unichain, mode, xLayer, zircuit, corn, bob, manta, harmonyOne, celo, bitlayer, merlin, sei, iotex, bsquared, zetachain, ronin, inEVM, } from "viem/chains";
5
5
  export const crossfi = defineChain({
6
6
  id: 4158,
7
- name: 'CrossFi Mainet',
7
+ name: "CrossFi Mainet",
8
8
  nativeCurrency: {
9
9
  decimals: 18,
10
- name: 'XFI',
11
- symbol: 'XFI',
10
+ name: "XFI",
11
+ symbol: "XFI",
12
12
  },
13
13
  rpcUrls: {
14
14
  default: {
15
- http: ['https://rpc.mainnet.ms/'],
15
+ http: ["https://rpc.mainnet.ms/"],
16
16
  },
17
17
  },
18
18
  blockExplorers: {
19
- default: { name: 'Explorer', url: 'https://xfiscan.com/' },
19
+ default: { name: "Explorer", url: "https://xfiscan.com/" },
20
20
  },
21
21
  // contracts: {
22
22
  // multicall3: {
@@ -27,37 +27,37 @@ export const crossfi = defineChain({
27
27
  });
28
28
  export const botanix = defineChain({
29
29
  id: 3637,
30
- name: 'Botanix',
30
+ name: "Botanix",
31
31
  nativeCurrency: {
32
32
  decimals: 18,
33
- name: 'BTC',
34
- symbol: 'BTC',
33
+ name: "BTC",
34
+ symbol: "BTC",
35
35
  },
36
36
  rpcUrls: {
37
37
  default: {
38
38
  http: [
39
39
  "https://rpc.ankr.com/botanix_mainnet",
40
- "https://rpc.botanixlabs.com"
40
+ "https://rpc.botanixlabs.com",
41
41
  ],
42
42
  },
43
43
  },
44
44
  blockExplorers: {
45
- default: { name: 'Explorer', url: 'https://botanixscan.io/' },
45
+ default: { name: "Explorer", url: "https://botanixscan.io/" },
46
46
  },
47
47
  contracts: {
48
48
  multicall3: {
49
49
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
50
50
  blockCreated: 1,
51
- }
52
- }
51
+ },
52
+ },
53
53
  });
54
54
  export const GraphLinq = defineChain({
55
55
  id: 614,
56
- name: 'GraphLinq Chain',
56
+ name: "GraphLinq Chain",
57
57
  nativeCurrency: {
58
58
  decimals: 18,
59
- name: 'GLQ',
60
- symbol: 'GLQ',
59
+ name: "GLQ",
60
+ symbol: "GLQ",
61
61
  },
62
62
  rpcUrls: {
63
63
  default: {
@@ -65,7 +65,7 @@ export const GraphLinq = defineChain({
65
65
  },
66
66
  },
67
67
  blockExplorers: {
68
- default: { name: 'Explorer', "url": "https://explorer.graphlinq.io", },
68
+ default: { name: "Explorer", url: "https://explorer.graphlinq.io" },
69
69
  },
70
70
  // contracts: {
71
71
  // multicall3: {
@@ -121,8 +121,8 @@ function getEvmChain(chain) {
121
121
  multicall3: {
122
122
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
123
123
  blockCreated: 1,
124
- }
125
- }
124
+ },
125
+ },
126
126
  };
127
127
  case Chain.NEON_EVM_MAINNET:
128
128
  return neonMainnet;
@@ -133,8 +133,8 @@ function getEvmChain(chain) {
133
133
  multicall3: {
134
134
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
135
135
  blockCreated: 1,
136
- }
137
- }
136
+ },
137
+ },
138
138
  };
139
139
  case Chain.GRAVITY_ALPHA_MAINNET:
140
140
  return gravity;
@@ -165,8 +165,8 @@ function getEvmChain(chain) {
165
165
  multicall3: {
166
166
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
167
167
  blockCreated: 1,
168
- }
169
- }
168
+ },
169
+ },
170
170
  };
171
171
  case Chain.FUSE_MAINNET:
172
172
  return fuse;
@@ -179,8 +179,8 @@ function getEvmChain(chain) {
179
179
  multicall3: {
180
180
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
181
181
  blockCreated: 1,
182
- }
183
- }
182
+ },
183
+ },
184
184
  };
185
185
  case Chain.APECHAIN:
186
186
  return apeChain;
@@ -231,8 +231,8 @@ function getEvmChain(chain) {
231
231
  multicall3: {
232
232
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
233
233
  blockCreated: 1,
234
- }
235
- }
234
+ },
235
+ },
236
236
  };
237
237
  case Chain.SEI_NETWORK:
238
238
  return sei;
@@ -243,8 +243,8 @@ function getEvmChain(chain) {
243
243
  multicall3: {
244
244
  address: "0x46063722c010AF39E465d286B84936A12aFb81F0",
245
245
  blockCreated: 1,
246
- }
247
- }
246
+ },
247
+ },
248
248
  };
249
249
  case Chain.X_LAYER_MAINNET:
250
250
  return xLayer;
@@ -260,7 +260,8 @@ function getEvmChain(chain) {
260
260
  // return rariChain
261
261
  // case Chain.GLUE_MAINNET:
262
262
  // return glue
263
- default: throw new Error("Not in VIEM: " + chain);
263
+ default:
264
+ throw new Error("Not in VIEM: " + chain);
264
265
  }
265
266
  }
266
267
  const RPC_OVERRIDES = {
@@ -272,7 +273,7 @@ const RPC_OVERRIDES = {
272
273
  function trimTrailingSlash(url) {
273
274
  if (!url)
274
275
  return undefined;
275
- return url.endsWith('/') ? url.slice(0, -1) : url;
276
+ return url.endsWith("/") ? url.slice(0, -1) : url;
276
277
  }
277
278
  export function getEvmClient(chain, rpcId = 0) {
278
279
  const chainInfo = getEvmChain(chain);
@@ -280,16 +281,15 @@ export function getEvmClient(chain, rpcId = 0) {
280
281
  if (rpcId === 0)
281
282
  rpc = chainInfo.rpcUrls.default.http[0];
282
283
  else {
283
- const rpcsChain = CHAIN_INFO[chain].rpc?.filter(a => !a.includes("wss://"));
284
- const rpcs = chainInfo.rpcUrls.default.http.map(a => trimTrailingSlash(a));
285
- const rpcsAdded = rpcsChain.map(a => trimTrailingSlash(a));
284
+ const rpcsChain = CHAIN_INFO[chain].rpc?.filter((a) => !a.includes("wss://"));
285
+ const rpcs = chainInfo.rpcUrls.default.http.map((a) => trimTrailingSlash(a));
286
+ const rpcsAdded = rpcsChain.map((a) => trimTrailingSlash(a));
286
287
  const allRpcs = uniq([...rpcs, ...rpcsAdded]);
287
288
  rpc = allRpcs[rpcId];
288
289
  }
289
290
  return createPublicClient({
290
291
  chain: chainInfo,
291
- transport: http(RPC_OVERRIDES[chain] ??
292
- rpc)
292
+ transport: http(RPC_OVERRIDES[chain] ?? rpc),
293
293
  });
294
294
  }
295
295
  const DEFAULT_BATCH_SIZE = 4096;
@@ -310,7 +310,7 @@ export function createMulticallRetry(customRpcs) {
310
310
  allowFailure,
311
311
  });
312
312
  if (allowFailure) {
313
- return data.map(({ result, status }) => status !== "success" ? '0x' : result);
313
+ return data.map(({ result, status }) => status !== "success" ? "0x" : result);
314
314
  }
315
315
  return data;
316
316
  }
@@ -323,15 +323,15 @@ export function createMulticallRetry(customRpcs) {
323
323
  }
324
324
  };
325
325
  }
326
- function getEvmClientWithCustomRpcs(chain, rpcId = 0, customRpcs) {
326
+ export function getEvmClientWithCustomRpcs(chain, rpcId = 0, customRpcs) {
327
327
  const chainInfo = getEvmChain(chain);
328
328
  let rpc;
329
329
  if (customRpcs && customRpcs[chain]) {
330
330
  // Use custom RPC list if any (make sure that they are unique and valid)
331
331
  const customRpcList = uniq(customRpcs[chain]
332
332
  .filter(Boolean) // Remove empty ones
333
- .filter(a => !a.includes("wss://")) // filter websocket ones (like the default impl)
334
- .map(url => trimTrailingSlash(url))
333
+ .filter((a) => !a.includes("wss://")) // filter websocket ones (like the default impl)
334
+ .map((url) => trimTrailingSlash(url))
335
335
  .filter((url) => Boolean(url)) // Type-safe filter for defined URLs
336
336
  );
337
337
  if (customRpcList.length === 0) {
@@ -344,17 +344,16 @@ function getEvmClientWithCustomRpcs(chain, rpcId = 0, customRpcs) {
344
344
  if (rpcId === 0)
345
345
  rpc = chainInfo.rpcUrls.default.http[0];
346
346
  else {
347
- const rpcsChain = CHAIN_INFO[chain].rpc?.filter(a => !a.includes("wss://"));
348
- const rpcs = chainInfo.rpcUrls.default.http.map(a => trimTrailingSlash(a));
349
- const rpcsAdded = rpcsChain.map(a => trimTrailingSlash(a));
347
+ const rpcsChain = CHAIN_INFO[chain].rpc?.filter((a) => !a.includes("wss://"));
348
+ const rpcs = chainInfo.rpcUrls.default.http.map((a) => trimTrailingSlash(a));
349
+ const rpcsAdded = rpcsChain.map((a) => trimTrailingSlash(a));
350
350
  const allRpcs = uniq([...rpcs, ...rpcsAdded]);
351
351
  rpc = allRpcs[rpcId];
352
352
  }
353
353
  }
354
354
  return createPublicClient({
355
355
  chain: chainInfo,
356
- transport: http(RPC_OVERRIDES[chain] ??
357
- rpc)
356
+ transport: http(RPC_OVERRIDES[chain] ?? rpc),
358
357
  });
359
358
  }
360
359
  export async function multicallRetry(chain, calls, abi, batchSize = DEFAULT_BATCH_SIZE, maxRetries = 3, providerId = 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/providers",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",