@covalenthq/client-sdk 2.0.0 → 2.0.2

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.
Files changed (51) hide show
  1. package/dist/cjs/index.d.ts +17 -0
  2. package/dist/cjs/index.js +2862 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/dist/cjs/src/GoldRushClient.d.ts +20 -0
  5. package/dist/cjs/src/services/BalanceService.d.ts +125 -0
  6. package/dist/cjs/src/services/BaseService.d.ts +161 -0
  7. package/dist/cjs/src/services/NftService.d.ts +157 -0
  8. package/dist/cjs/src/services/PricingService.d.ts +25 -0
  9. package/dist/cjs/src/services/SecurityService.d.ts +28 -0
  10. package/dist/cjs/src/services/TransactionService.d.ts +128 -0
  11. package/dist/cjs/src/utils/functions/bigIntParser.d.ts +1 -0
  12. package/dist/cjs/src/utils/functions/calculatePrettyBalance.d.ts +1 -0
  13. package/dist/cjs/src/utils/functions/debugOutput.d.ts +2 -0
  14. package/dist/cjs/src/utils/functions/endpointGenerator.d.ts +4 -0
  15. package/dist/cjs/src/utils/functions/execution.d.ts +11 -0
  16. package/dist/cjs/src/utils/functions/isValidApiKey.d.ts +1 -0
  17. package/dist/cjs/src/utils/functions/paginateEndpoint.d.ts +7 -0
  18. package/dist/cjs/src/utils/functions/prettifyCurrency.d.ts +2 -0
  19. package/dist/cjs/src/utils/types/BalanceService.types.d.ts +442 -0
  20. package/dist/cjs/src/utils/types/BaseService.types.d.ts +326 -0
  21. package/dist/cjs/src/utils/types/Generic.types.d.ts +477 -0
  22. package/dist/cjs/src/utils/types/NftService.types.d.ts +273 -0
  23. package/dist/cjs/src/utils/types/PricingService.types.d.ts +39 -0
  24. package/dist/cjs/src/utils/types/SecurityService.types.d.ts +122 -0
  25. package/dist/cjs/src/utils/types/TransactionService.types.d.ts +474 -0
  26. package/dist/esm/index.d.ts +17 -0
  27. package/dist/esm/index.js +2854 -0
  28. package/dist/esm/index.js.map +1 -0
  29. package/dist/esm/src/GoldRushClient.d.ts +20 -0
  30. package/dist/esm/src/services/BalanceService.d.ts +125 -0
  31. package/dist/esm/src/services/BaseService.d.ts +161 -0
  32. package/dist/esm/src/services/NftService.d.ts +157 -0
  33. package/dist/esm/src/services/PricingService.d.ts +25 -0
  34. package/dist/esm/src/services/SecurityService.d.ts +28 -0
  35. package/dist/esm/src/services/TransactionService.d.ts +128 -0
  36. package/dist/esm/src/utils/functions/bigIntParser.d.ts +1 -0
  37. package/dist/esm/src/utils/functions/calculatePrettyBalance.d.ts +1 -0
  38. package/dist/esm/src/utils/functions/debugOutput.d.ts +2 -0
  39. package/dist/esm/src/utils/functions/endpointGenerator.d.ts +4 -0
  40. package/dist/esm/src/utils/functions/execution.d.ts +11 -0
  41. package/dist/esm/src/utils/functions/isValidApiKey.d.ts +1 -0
  42. package/dist/esm/src/utils/functions/paginateEndpoint.d.ts +7 -0
  43. package/dist/esm/src/utils/functions/prettifyCurrency.d.ts +2 -0
  44. package/dist/esm/src/utils/types/BalanceService.types.d.ts +442 -0
  45. package/dist/esm/src/utils/types/BaseService.types.d.ts +326 -0
  46. package/dist/esm/src/utils/types/Generic.types.d.ts +477 -0
  47. package/dist/esm/src/utils/types/NftService.types.d.ts +273 -0
  48. package/dist/esm/src/utils/types/PricingService.types.d.ts +39 -0
  49. package/dist/esm/src/utils/types/SecurityService.types.d.ts +122 -0
  50. package/dist/esm/src/utils/types/TransactionService.types.d.ts +474 -0
  51. package/package.json +31 -18
@@ -0,0 +1,2854 @@
1
+ import Big from 'big.js';
2
+
3
+ var version = "2.0.2";
4
+
5
+ const bigIntParser = (val) => {
6
+ if (val === null || val === undefined) {
7
+ return null;
8
+ }
9
+ return BigInt(val);
10
+ };
11
+
12
+ const baseUrl = "https://api.covalenthq.com/v1";
13
+ const endpointGenerator = (extension = "", params = []) => {
14
+ extension = extension.replace(baseUrl, "");
15
+ if (extension.startsWith("/")) {
16
+ extension = extension.slice(1);
17
+ }
18
+ if (!extension.endsWith("/")) {
19
+ extension = `${extension}/`;
20
+ }
21
+ const urlParams = new URLSearchParams();
22
+ params.forEach((param) => {
23
+ if (param.value !== undefined) {
24
+ urlParams.append(param.key, param.value.toString());
25
+ }
26
+ });
27
+ return new URL(`${baseUrl}/${extension}?${urlParams}`);
28
+ };
29
+
30
+ async function* paginateEndpoint(endpoint, execution, parseData, implementation) {
31
+ let _endpoint = new URL(endpoint);
32
+ let hasMore = true;
33
+ let page_number = +_endpoint.searchParams.get("page-number") ?? 0;
34
+ while (hasMore) {
35
+ try {
36
+ if (implementation === "pagination") {
37
+ _endpoint.searchParams.set("page-number", page_number.toString());
38
+ const parsedData = await execution.execute(_endpoint, parseData);
39
+ if (parsedData.error) {
40
+ throw parsedData;
41
+ }
42
+ if (!parsedData.data?.pagination?.has_more) {
43
+ hasMore = false;
44
+ }
45
+ else {
46
+ page_number++;
47
+ }
48
+ yield parsedData;
49
+ }
50
+ else if (implementation === "links") {
51
+ const parsedData = await execution.execute(_endpoint, parseData);
52
+ const prevLink = parsedData.data?.links?.prev || null;
53
+ if (!prevLink) {
54
+ hasMore = false;
55
+ }
56
+ else {
57
+ _endpoint = new URL(`${prevLink}?${_endpoint.searchParams}`);
58
+ }
59
+ yield parsedData;
60
+ }
61
+ }
62
+ catch (error) {
63
+ hasMore = false;
64
+ yield {
65
+ data: null,
66
+ error: true,
67
+ error_code: error?.cause?.code || error?.error_code || 500,
68
+ error_message: error?.cause?.message ||
69
+ error?.error_message ||
70
+ "Internal server error",
71
+ };
72
+ }
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Balances APIs
78
+ *
79
+ */
80
+ class BalanceService {
81
+ constructor(execution) {
82
+ this.execution = execution;
83
+ }
84
+ /**
85
+ *
86
+ * Commonly used to fetch the native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address. Response includes spot prices and other metadata.
87
+ *
88
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
89
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
90
+ * @param {GetTokenBalancesForWalletAddressQueryParamOpts} queryParamOpts
91
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
92
+ * - `nft`: If `true`, NFTs will be included in the response.
93
+ * - `noNftFetch`: If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
94
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
95
+ * - `noNftAssetMetadata`: If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
96
+ *
97
+ */
98
+ async getTokenBalancesForWalletAddress(chainName, walletAddress, queryParamOpts) {
99
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/balances_v2`, [
100
+ {
101
+ key: "quote-currency",
102
+ value: queryParamOpts?.quoteCurrency,
103
+ },
104
+ {
105
+ key: "nft",
106
+ value: queryParamOpts?.nft,
107
+ },
108
+ {
109
+ key: "no-nft-fetch",
110
+ value: queryParamOpts?.noNftFetch,
111
+ },
112
+ {
113
+ key: "no-spam",
114
+ value: queryParamOpts?.noSpam,
115
+ },
116
+ {
117
+ key: "no-nft-asset-metadata",
118
+ value: queryParamOpts?.noNftAssetMetadata,
119
+ },
120
+ ]);
121
+ const parseData = (data) => {
122
+ data.data.updated_at = data.data.updated_at
123
+ ? new Date(data.data.updated_at)
124
+ : null;
125
+ data.data.items = data.data.items
126
+ ? data.data.items.map((balanceItem) => ({
127
+ ...balanceItem,
128
+ balance: bigIntParser(balanceItem.balance),
129
+ balance_24h: bigIntParser(balanceItem.balance_24h),
130
+ last_transferred_at: balanceItem.last_transferred_at
131
+ ? new Date(balanceItem.last_transferred_at)
132
+ : null,
133
+ nft_data: balanceItem.nft_data
134
+ ? balanceItem.nft_data.map((nftItem) => ({
135
+ ...nftItem,
136
+ token_id: bigIntParser(nftItem.token_id),
137
+ token_balance: bigIntParser(nftItem.token_balance),
138
+ token_price_wei: bigIntParser(nftItem.token_price_wei),
139
+ }))
140
+ : null,
141
+ }))
142
+ : null;
143
+ return data;
144
+ };
145
+ return await this.execution.execute(endpoint, parseData);
146
+ }
147
+ /**
148
+ *
149
+ * Commonly used to render a daily portfolio balance for an address broken down by the token. The timeframe is user-configurable, defaults to 30 days.
150
+ *
151
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
152
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
153
+ * @param {GetHistoricalPortfolioForWalletAddressQueryParamOpts} queryParamOpts
154
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
155
+ * - `days`: The number of days to return data for. Defaults to 30 days.
156
+ *
157
+ */
158
+ async getHistoricalPortfolioForWalletAddress(chainName, walletAddress, queryParamOpts) {
159
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/portfolio_v2`, [
160
+ {
161
+ key: "quote-currency",
162
+ value: queryParamOpts?.quoteCurrency,
163
+ },
164
+ {
165
+ key: "days",
166
+ value: queryParamOpts?.days,
167
+ },
168
+ ]);
169
+ const parseData = (data) => {
170
+ data.data.updated_at = data.data.updated_at
171
+ ? new Date(data.data.updated_at)
172
+ : null;
173
+ data.data.items = data.data.items.map((portfolioItem) => ({
174
+ ...portfolioItem,
175
+ holdings: portfolioItem.holdings.map((holdingItem) => ({
176
+ ...holdingItem,
177
+ timestamp: holdingItem.timestamp
178
+ ? new Date(data.data.updated_at)
179
+ : null,
180
+ close: {
181
+ ...holdingItem.close,
182
+ balance: bigIntParser(holdingItem.close.balance),
183
+ },
184
+ high: {
185
+ ...holdingItem.high,
186
+ balance: bigIntParser(holdingItem.high.balance),
187
+ },
188
+ low: {
189
+ ...holdingItem.low,
190
+ balance: bigIntParser(holdingItem.low.balance),
191
+ },
192
+ open: {
193
+ ...holdingItem.open,
194
+ balance: bigIntParser(holdingItem.open.balance),
195
+ },
196
+ })),
197
+ }));
198
+ return data;
199
+ };
200
+ return await this.execution.execute(endpoint, parseData);
201
+ }
202
+ /**
203
+ *
204
+ * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
205
+ *
206
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
207
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
208
+ * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
209
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
210
+ * - `contractAddress`: The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
211
+ * - `startingBlock`: The block height to start from, defaults to `0`.
212
+ * - `endingBlock`: The block height to end at, defaults to current block height.
213
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
214
+ * - `pageNumber`: 0-indexed page number to begin pagination.
215
+ *
216
+ */
217
+ async *getErc20TransfersForWalletAddress(chainName, walletAddress, queryParamOpts) {
218
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transfers_v2`, [
219
+ {
220
+ key: "quote-currency",
221
+ value: queryParamOpts?.quoteCurrency,
222
+ },
223
+ {
224
+ key: "contract-address",
225
+ value: queryParamOpts?.contractAddress,
226
+ },
227
+ {
228
+ key: "starting-block",
229
+ value: queryParamOpts?.startingBlock,
230
+ },
231
+ {
232
+ key: "ending-block",
233
+ value: queryParamOpts?.endingBlock,
234
+ },
235
+ {
236
+ key: "page-size",
237
+ value: queryParamOpts?.pageSize,
238
+ },
239
+ {
240
+ key: "page-number",
241
+ value: queryParamOpts?.pageNumber,
242
+ },
243
+ ]);
244
+ const parseData = (data) => {
245
+ data.data.updated_at = data.data.updated_at
246
+ ? new Date(data.data.updated_at)
247
+ : null;
248
+ data.data.items = data.data.items
249
+ ? data.data.items.map((ercItem) => ({
250
+ ...ercItem,
251
+ block_signed_at: ercItem.block_signed_at
252
+ ? new Date(ercItem.block_signed_at)
253
+ : null,
254
+ value: bigIntParser(ercItem.value),
255
+ fees_paid: bigIntParser(ercItem.fees_paid),
256
+ transfers: ercItem.transfers
257
+ ? ercItem.transfers.map((transferItem) => ({
258
+ ...transferItem,
259
+ balance: bigIntParser(transferItem.balance),
260
+ block_signed_at: transferItem.block_signed_at
261
+ ? new Date(transferItem.block_signed_at)
262
+ : null,
263
+ delta: bigIntParser(transferItem.delta),
264
+ }))
265
+ : null,
266
+ }))
267
+ : null;
268
+ return data;
269
+ };
270
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
271
+ yield data;
272
+ }
273
+ }
274
+ /**
275
+ *
276
+ * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
277
+ *
278
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
279
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
280
+ * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
281
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
282
+ * - `contractAddress`: The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
283
+ * - `startingBlock`: The block height to start from, defaults to `0`.
284
+ * - `endingBlock`: The block height to end at, defaults to current block height.
285
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
286
+ * - `pageNumber`: 0-indexed page number to begin pagination.
287
+ *
288
+ */
289
+ async getErc20TransfersForWalletAddressByPage(chainName, walletAddress, queryParamOpts) {
290
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transfers_v2`, [
291
+ {
292
+ key: "quote-currency",
293
+ value: queryParamOpts?.quoteCurrency,
294
+ },
295
+ {
296
+ key: "contract-address",
297
+ value: queryParamOpts?.contractAddress,
298
+ },
299
+ {
300
+ key: "starting-block",
301
+ value: queryParamOpts?.startingBlock,
302
+ },
303
+ {
304
+ key: "ending-block",
305
+ value: queryParamOpts?.endingBlock,
306
+ },
307
+ {
308
+ key: "page-size",
309
+ value: queryParamOpts?.pageSize,
310
+ },
311
+ {
312
+ key: "page-number",
313
+ value: queryParamOpts?.pageNumber,
314
+ },
315
+ ]);
316
+ const parseData = (data) => {
317
+ data.data.updated_at = data.data.updated_at
318
+ ? new Date(data.data.updated_at)
319
+ : null;
320
+ data.data.items = data.data.items
321
+ ? data.data.items.map((blockTxItem) => ({
322
+ ...blockTxItem,
323
+ block_signed_at: blockTxItem.block_signed_at
324
+ ? new Date(blockTxItem.block_signed_at)
325
+ : null,
326
+ fees_paid: bigIntParser(blockTxItem.fees_paid),
327
+ transfers: blockTxItem.transfers.map((transferItem) => ({
328
+ ...transferItem,
329
+ balance: bigIntParser(transferItem.balance),
330
+ block_signed_at: transferItem.block_signed_at
331
+ ? new Date(transferItem.block_signed_at)
332
+ : null,
333
+ delta: bigIntParser(transferItem.delta),
334
+ })),
335
+ value: bigIntParser(blockTxItem.value),
336
+ }))
337
+ : null;
338
+ return data;
339
+ };
340
+ return await this.execution.execute(endpoint, parseData);
341
+ }
342
+ /**
343
+ *
344
+ * Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
345
+ *
346
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
347
+ * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
348
+ * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
349
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
350
+ * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
351
+ * - `pageNumber`: 0-indexed page number to begin pagination.
352
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
353
+ *
354
+ */
355
+ async *getTokenHoldersV2ForTokenAddress(chainName, tokenAddress, queryParamOpts) {
356
+ const endpoint = endpointGenerator(`${chainName}/tokens/${tokenAddress}/token_holders_v2`, [
357
+ {
358
+ key: "block-height",
359
+ value: queryParamOpts?.blockHeight,
360
+ },
361
+ {
362
+ key: "page-size",
363
+ value: queryParamOpts?.pageSize,
364
+ },
365
+ {
366
+ key: "page-number",
367
+ value: queryParamOpts?.pageNumber,
368
+ },
369
+ {
370
+ key: "date",
371
+ value: queryParamOpts?.date,
372
+ },
373
+ ]);
374
+ const parseData = (data) => {
375
+ data.data.updated_at = data.data.updated_at
376
+ ? new Date(data.data.updated_at)
377
+ : null;
378
+ data.data.items = data.data.items
379
+ ? data.data.items.map((tokenItem) => ({
380
+ ...tokenItem,
381
+ balance: bigIntParser(tokenItem.balance),
382
+ total_supply: bigIntParser(tokenItem.total_supply),
383
+ }))
384
+ : null;
385
+ return data;
386
+ };
387
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
388
+ yield data;
389
+ }
390
+ }
391
+ /**
392
+ *
393
+ * Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
394
+ *
395
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
396
+ * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
397
+ * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
398
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
399
+ * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
400
+ * - `pageNumber`: 0-indexed page number to begin pagination.
401
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
402
+ *
403
+ */
404
+ async getTokenHoldersV2ForTokenAddressByPage(chainName, tokenAddress, queryParamOpts) {
405
+ const endpoint = endpointGenerator(`${chainName}/tokens/${tokenAddress}/token_holders_v2`, [
406
+ {
407
+ key: "block-height",
408
+ value: queryParamOpts?.blockHeight,
409
+ },
410
+ {
411
+ key: "page-size",
412
+ value: queryParamOpts?.pageSize,
413
+ },
414
+ {
415
+ key: "page-number",
416
+ value: queryParamOpts?.pageNumber,
417
+ },
418
+ {
419
+ key: "date",
420
+ value: queryParamOpts?.date,
421
+ },
422
+ ]);
423
+ const parseData = (data) => {
424
+ data.data.updated_at = data.data.updated_at
425
+ ? new Date(data.data.updated_at)
426
+ : null;
427
+ data.data.items = data.data.items
428
+ ? data.data.items.map((balanceItem) => ({
429
+ ...balanceItem,
430
+ balance: bigIntParser(balanceItem.balance),
431
+ total_supply: bigIntParser(balanceItem.total_supply),
432
+ }))
433
+ : null;
434
+ return data;
435
+ };
436
+ return await this.execution.execute(endpoint, parseData);
437
+ }
438
+ /**
439
+ *
440
+ * Commonly used to fetch the historical native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
441
+ *
442
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
443
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
444
+ * @param {GetHistoricalTokenBalancesForWalletAddressQueryParamOpts} queryParamOpts
445
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
446
+ * - `nft`: If `true`, NFTs will be included in the response.
447
+ * - `noNftFetch`: If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
448
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
449
+ * - `noNftAssetMetadata`: If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
450
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
451
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
452
+ *
453
+ */
454
+ async getHistoricalTokenBalancesForWalletAddress(chainName, walletAddress, queryParamOpts) {
455
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/historical_balances`, [
456
+ {
457
+ key: "quote-currency",
458
+ value: queryParamOpts?.quoteCurrency,
459
+ },
460
+ {
461
+ key: "nft",
462
+ value: queryParamOpts?.nft,
463
+ },
464
+ {
465
+ key: "no-nft-fetch",
466
+ value: queryParamOpts?.noNftFetch,
467
+ },
468
+ {
469
+ key: "no-spam",
470
+ value: queryParamOpts?.noSpam,
471
+ },
472
+ {
473
+ key: "no-nft-asset-metadata",
474
+ value: queryParamOpts?.noNftAssetMetadata,
475
+ },
476
+ {
477
+ key: "block-height",
478
+ value: queryParamOpts?.blockHeight,
479
+ },
480
+ {
481
+ key: "date",
482
+ value: queryParamOpts?.date,
483
+ },
484
+ ]);
485
+ const parseData = (data) => {
486
+ data.data.updated_at = data.data.updated_at
487
+ ? new Date(data.data.updated_at)
488
+ : null;
489
+ data.data.items = data.data.items
490
+ ? data.data.items.map((balanceItem) => ({
491
+ ...balanceItem,
492
+ balance: bigIntParser(balanceItem.balance),
493
+ last_transferred_at: balanceItem.last_transferred_at
494
+ ? new Date(balanceItem.last_transferred_at)
495
+ : null,
496
+ nft_data: balanceItem.nft_data
497
+ ? balanceItem.nft_data.map((nftItem) => ({
498
+ ...nftItem,
499
+ token_id: bigIntParser(nftItem.token_id),
500
+ token_balance: bigIntParser(nftItem.token_balance),
501
+ token_price_wei: bigIntParser(nftItem.token_price_wei),
502
+ }))
503
+ : null,
504
+ }))
505
+ : null;
506
+ return data;
507
+ };
508
+ return await this.execution.execute(endpoint, parseData);
509
+ }
510
+ /**
511
+ *
512
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
513
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
514
+ * @param {GetNativeTokenBalanceQueryParamOpts} queryParamOpts
515
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
516
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
517
+ *
518
+ */
519
+ async getNativeTokenBalance(chainName, walletAddress, queryParamOpts) {
520
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/balances_native`, [
521
+ {
522
+ key: "quote-currency",
523
+ value: queryParamOpts?.quoteCurrency,
524
+ },
525
+ {
526
+ key: "block-height",
527
+ value: queryParamOpts?.blockHeight,
528
+ },
529
+ ]);
530
+ const parseData = (data) => {
531
+ data.data.updated_at = data.data.updated_at
532
+ ? new Date(data.data.updated_at)
533
+ : null;
534
+ data.data.items = data.data.items
535
+ ? data.data.items.map((balanceItem) => ({
536
+ ...balanceItem,
537
+ balance: bigIntParser(balanceItem.balance),
538
+ }))
539
+ : null;
540
+ return data;
541
+ };
542
+ return await this.execution.execute(endpoint, parseData);
543
+ }
544
+ }
545
+
546
+ /**
547
+ * Class A - Base
548
+ *
549
+ */
550
+ class BaseService {
551
+ constructor(execution) {
552
+ this.execution = execution;
553
+ }
554
+ /**
555
+ *
556
+ * Commonly used to fetch and render a single block for a block explorer.
557
+ *
558
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
559
+ * @param {string} blockHeight - The block height or `latest` for the latest block available.
560
+ *
561
+ */
562
+ async getBlock(chainName, blockHeight) {
563
+ const endpoint = endpointGenerator(`${chainName}/block_v2/${blockHeight}`, []);
564
+ const parseData = (data) => {
565
+ data.data.updated_at = data.data.updated_at
566
+ ? new Date(data.data.updated_at)
567
+ : null;
568
+ data.data.items = data.data.items
569
+ ? data.data.items.map((blockItem) => ({
570
+ ...blockItem,
571
+ signed_at: blockItem.signed_at
572
+ ? new Date(blockItem.signed_at)
573
+ : null,
574
+ }))
575
+ : null;
576
+ return data;
577
+ };
578
+ return await this.execution.execute(endpoint, parseData);
579
+ }
580
+ /**
581
+ *
582
+ * Commonly used to resolve ENS, RNS and Unstoppable Domains addresses.
583
+ *
584
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
585
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
586
+ *
587
+ */
588
+ async getResolvedAddress(chainName, walletAddress) {
589
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/resolve_address`, []);
590
+ const parseData = (data) => {
591
+ return data;
592
+ };
593
+ return await this.execution.execute(endpoint, parseData);
594
+ }
595
+ /**
596
+ *
597
+ * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
598
+ *
599
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
600
+ * @param {string} startDate - The start date in YYYY-MM-DD format.
601
+ * @param {string} endDate - The end date in YYYY-MM-DD format.
602
+ * @param {GetBlockHeightsQueryParamOpts} queryParamOpts
603
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
604
+ * - `pageNumber`: 0-indexed page number to begin pagination.
605
+ *
606
+ */
607
+ async *getBlockHeights(chainName, startDate, endDate, queryParamOpts) {
608
+ const endpoint = endpointGenerator(`${chainName}/block_v2/${startDate}/${endDate}`, [
609
+ {
610
+ key: "page-size",
611
+ value: queryParamOpts?.pageSize,
612
+ },
613
+ {
614
+ key: "page-number",
615
+ value: queryParamOpts?.pageNumber,
616
+ },
617
+ ]);
618
+ const parseData = (data) => {
619
+ data.data.updated_at = data.data.updated_at
620
+ ? new Date(data.data.updated_at)
621
+ : null;
622
+ data.data.items = data.data.items
623
+ ? data.data.items.map((blockItem) => ({
624
+ ...blockItem,
625
+ signed_at: blockItem.signed_at
626
+ ? new Date(blockItem.signed_at)
627
+ : null,
628
+ }))
629
+ : null;
630
+ return data;
631
+ };
632
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
633
+ yield data;
634
+ }
635
+ }
636
+ /**
637
+ *
638
+ * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
639
+ *
640
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
641
+ * @param {string} startDate - The start date in YYYY-MM-DD format.
642
+ * @param {string} endDate - The end date in YYYY-MM-DD format.
643
+ * @param {GetBlockHeightsQueryParamOpts} queryParamOpts
644
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
645
+ * - `pageNumber`: 0-indexed page number to begin pagination.
646
+ *
647
+ */
648
+ async getBlockHeightsByPage(chainName, startDate, endDate, queryParamOpts) {
649
+ const endpoint = endpointGenerator(`${chainName}/block_v2/${startDate}/${endDate}`, [
650
+ {
651
+ key: "page-size",
652
+ value: queryParamOpts?.pageSize,
653
+ },
654
+ {
655
+ key: "page-number",
656
+ value: queryParamOpts?.pageNumber,
657
+ },
658
+ ]);
659
+ const parseData = (data) => {
660
+ data.data.updated_at = data.data.updated_at
661
+ ? new Date(data.data.updated_at)
662
+ : null;
663
+ data.data.items = data.data.items
664
+ ? data.data.items.map((blockItem) => ({
665
+ ...blockItem,
666
+ signed_at: blockItem.signed_at
667
+ ? new Date(blockItem.signed_at)
668
+ : null,
669
+ }))
670
+ : null;
671
+ return data;
672
+ };
673
+ return await this.execution.execute(endpoint, parseData);
674
+ }
675
+ /**
676
+ *
677
+ * Commonly used to get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
678
+ *
679
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
680
+ * @param {GetLogsQueryParamOpts} queryParamOpts
681
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
682
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
683
+ * - `address`: The address of the log events sender contract.
684
+ * - `topics`: The topic hash(es) to retrieve logs with.
685
+ * - `blockHash`: The block hash to retrieve logs for.
686
+ * - `skipDecode`: Omit decoded log events.
687
+ *
688
+ */
689
+ async getLogs(chainName, queryParamOpts) {
690
+ const endpoint = endpointGenerator(`${chainName}/events`, [
691
+ {
692
+ key: "starting-block",
693
+ value: queryParamOpts?.startingBlock,
694
+ },
695
+ {
696
+ key: "ending-block",
697
+ value: queryParamOpts?.endingBlock,
698
+ },
699
+ {
700
+ key: "address",
701
+ value: queryParamOpts?.address,
702
+ },
703
+ {
704
+ key: "topics",
705
+ value: queryParamOpts?.topics,
706
+ },
707
+ {
708
+ key: "block-hash",
709
+ value: queryParamOpts?.blockHash,
710
+ },
711
+ {
712
+ key: "skip-decode",
713
+ value: queryParamOpts?.skipDecode,
714
+ },
715
+ ]);
716
+ const parseData = (data) => {
717
+ data.data.updated_at = data.data.updated_at
718
+ ? new Date(data.data.updated_at)
719
+ : null;
720
+ data.data.items = data.data.items
721
+ ? data.data.items.map((logItem) => ({
722
+ ...logItem,
723
+ block_signed_at: logItem.block_signed_at
724
+ ? new Date(logItem.block_signed_at)
725
+ : null,
726
+ }))
727
+ : null;
728
+ return data;
729
+ };
730
+ return await this.execution.execute(endpoint, parseData);
731
+ }
732
+ /**
733
+ *
734
+ * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
735
+ *
736
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
737
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
738
+ * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
739
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
740
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
741
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
742
+ * - `pageNumber`: 0-indexed page number to begin pagination.
743
+ *
744
+ */
745
+ async *getLogEventsByAddress(chainName, contractAddress, queryParamOpts) {
746
+ const endpoint = endpointGenerator(`${chainName}/events/address/${contractAddress}`, [
747
+ {
748
+ key: "starting-block",
749
+ value: queryParamOpts?.startingBlock,
750
+ },
751
+ {
752
+ key: "ending-block",
753
+ value: queryParamOpts?.endingBlock,
754
+ },
755
+ {
756
+ key: "page-size",
757
+ value: queryParamOpts?.pageSize,
758
+ },
759
+ {
760
+ key: "page-number",
761
+ value: queryParamOpts?.pageNumber,
762
+ },
763
+ ]);
764
+ const parseData = (data) => {
765
+ data.data.updated_at = data.data.updated_at
766
+ ? new Date(data.data.updated_at)
767
+ : null;
768
+ data.data.items = data.data.items
769
+ ? data.data.items.map((logItem) => ({
770
+ ...logItem,
771
+ block_signed_at: logItem.block_signed_at
772
+ ? new Date(logItem.block_signed_at)
773
+ : null,
774
+ }))
775
+ : null;
776
+ return data;
777
+ };
778
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
779
+ yield data;
780
+ }
781
+ }
782
+ /**
783
+ *
784
+ * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
785
+ *
786
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
787
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
788
+ * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
789
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
790
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
791
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
792
+ * - `pageNumber`: 0-indexed page number to begin pagination.
793
+ *
794
+ */
795
+ async getLogEventsByAddressByPage(chainName, contractAddress, queryParamOpts) {
796
+ const endpoint = endpointGenerator(`${chainName}/events/address/${contractAddress}`, [
797
+ {
798
+ key: "starting-block",
799
+ value: queryParamOpts?.startingBlock,
800
+ },
801
+ {
802
+ key: "ending-block",
803
+ value: queryParamOpts?.endingBlock,
804
+ },
805
+ {
806
+ key: "page-size",
807
+ value: queryParamOpts?.pageSize,
808
+ },
809
+ {
810
+ key: "page-number",
811
+ value: queryParamOpts?.pageNumber,
812
+ },
813
+ ]);
814
+ const parseData = (data) => {
815
+ data.data.updated_at = data.data.updated_at
816
+ ? new Date(data.data.updated_at)
817
+ : null;
818
+ data.data.items = data.data.items
819
+ ? data.data.items.map((logItem) => ({
820
+ ...logItem,
821
+ block_signed_at: logItem.block_signed_at
822
+ ? new Date(logItem.block_signed_at)
823
+ : null,
824
+ }))
825
+ : null;
826
+ return data;
827
+ };
828
+ return await this.execution.execute(endpoint, parseData);
829
+ }
830
+ /**
831
+ *
832
+ * Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain.
833
+ *
834
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
835
+ * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
836
+ * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
837
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
838
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
839
+ * - `secondaryTopics`: Additional topic hash(es) to filter on - padded & unpadded address fields are supported. Separate multiple topics with a comma.
840
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
841
+ * - `pageNumber`: 0-indexed page number to begin pagination.
842
+ *
843
+ */
844
+ async *getLogEventsByTopicHash(chainName, topicHash, queryParamOpts) {
845
+ const endpoint = endpointGenerator(`${chainName}/events/topics/${topicHash}`, [
846
+ {
847
+ key: "starting-block",
848
+ value: queryParamOpts?.startingBlock,
849
+ },
850
+ {
851
+ key: "ending-block",
852
+ value: queryParamOpts?.endingBlock,
853
+ },
854
+ {
855
+ key: "secondary-topics",
856
+ value: queryParamOpts?.secondaryTopics,
857
+ },
858
+ {
859
+ key: "page-size",
860
+ value: queryParamOpts?.pageSize,
861
+ },
862
+ {
863
+ key: "page-number",
864
+ value: queryParamOpts?.pageNumber,
865
+ },
866
+ ]);
867
+ const parseData = (data) => {
868
+ data.data.updated_at = data.data.updated_at
869
+ ? new Date(data.data.updated_at)
870
+ : null;
871
+ data.data.items = data.data.items
872
+ ? data.data.items.map((logItem) => ({
873
+ ...logItem,
874
+ block_signed_at: logItem.block_signed_at
875
+ ? new Date(logItem.block_signed_at)
876
+ : null,
877
+ }))
878
+ : null;
879
+ return data;
880
+ };
881
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
882
+ yield data;
883
+ }
884
+ }
885
+ /**
886
+ *
887
+ * Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain.
888
+ *
889
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
890
+ * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
891
+ * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
892
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
893
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
894
+ * - `secondaryTopics`: Additional topic hash(es) to filter on - padded & unpadded address fields are supported. Separate multiple topics with a comma.
895
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
896
+ * - `pageNumber`: 0-indexed page number to begin pagination.
897
+ *
898
+ */
899
+ async getLogEventsByTopicHashByPage(chainName, topicHash, queryParamOpts) {
900
+ const endpoint = endpointGenerator(`${chainName}/events/topics/${topicHash}`, [
901
+ {
902
+ key: "starting-block",
903
+ value: queryParamOpts?.startingBlock,
904
+ },
905
+ {
906
+ key: "ending-block",
907
+ value: queryParamOpts?.endingBlock,
908
+ },
909
+ {
910
+ key: "secondary-topics",
911
+ value: queryParamOpts?.secondaryTopics,
912
+ },
913
+ {
914
+ key: "page-size",
915
+ value: queryParamOpts?.pageSize,
916
+ },
917
+ {
918
+ key: "page-number",
919
+ value: queryParamOpts?.pageNumber,
920
+ },
921
+ ]);
922
+ const parseData = (data) => {
923
+ data.data.updated_at = data.data.updated_at
924
+ ? new Date(data.data.updated_at)
925
+ : null;
926
+ data.data.items = data.data.items
927
+ ? data.data.items.map((logItem) => ({
928
+ ...logItem,
929
+ block_signed_at: logItem.block_signed_at
930
+ ? new Date(logItem.block_signed_at)
931
+ : null,
932
+ }))
933
+ : null;
934
+ return data;
935
+ };
936
+ return await this.execution.execute(endpoint, parseData);
937
+ }
938
+ /**
939
+ *
940
+ * Commonly used to build internal dashboards for all supported chains on Covalent.
941
+ *
942
+ *
943
+ */
944
+ async getAllChains() {
945
+ const endpoint = endpointGenerator(`chains`);
946
+ const parseData = (data) => {
947
+ data.data.updated_at = data.data.updated_at
948
+ ? new Date(data.data.updated_at)
949
+ : null;
950
+ data.data.items = data.data.items
951
+ ? data.data.items.map((chainItem) => ({
952
+ ...chainItem,
953
+ chain_id: +chainItem.chain_id,
954
+ }))
955
+ : null;
956
+ return data;
957
+ };
958
+ return await this.execution.execute(endpoint, parseData);
959
+ }
960
+ /**
961
+ *
962
+ * Commonly used to build internal status dashboards of all supported chains.
963
+ *
964
+ *
965
+ */
966
+ async getAllChainStatus() {
967
+ const endpoint = endpointGenerator(`chains/status`);
968
+ const parseData = (data) => {
969
+ data.data.updated_at = data.data.updated_at
970
+ ? new Date(data.data.updated_at)
971
+ : null;
972
+ data.data.items = data.data.items
973
+ ? data.data.items.map((chainItem) => ({
974
+ ...chainItem,
975
+ chain_id: +chainItem.chain_id,
976
+ }))
977
+ : null;
978
+ return data;
979
+ };
980
+ return await this.execution.execute(endpoint, parseData);
981
+ }
982
+ /**
983
+ *
984
+ * Commonly used to locate chains which an address is active on with a single API call.
985
+ *
986
+ * @param {string} walletAddress - The requested wallet address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
987
+ * @param {GetAddressActivityQueryParamOpts} queryParamOpts
988
+ * - `testnets`: Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity.
989
+ *
990
+ */
991
+ async getAddressActivity(walletAddress, queryParamOpts) {
992
+ const endpoint = endpointGenerator(`address/${walletAddress}/activity`, [
993
+ {
994
+ key: "testnets",
995
+ value: queryParamOpts?.testnets,
996
+ },
997
+ ]);
998
+ const parseData = (data) => {
999
+ data.data.updated_at = data.data.updated_at
1000
+ ? new Date(data.data.updated_at)
1001
+ : null;
1002
+ data.data.items = data.data.items
1003
+ ? data.data.items.map((activityItem) => ({
1004
+ ...activityItem,
1005
+ last_seen_at: activityItem.last_seen_at
1006
+ ? new Date(activityItem.last_seen_at)
1007
+ : null,
1008
+ }))
1009
+ : null;
1010
+ return data;
1011
+ };
1012
+ return await this.execution.execute(endpoint, parseData);
1013
+ }
1014
+ /**
1015
+ *
1016
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1017
+ * @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
1018
+ * @param {GetGasPricesQueryParamOpts} queryParamOpts
1019
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1020
+ *
1021
+ */
1022
+ async getGasPrices(chainName, eventType, queryParamOpts) {
1023
+ const endpoint = endpointGenerator(`${chainName}/event/${eventType}/gas_prices`, [
1024
+ {
1025
+ key: "quote-currency",
1026
+ value: queryParamOpts?.quoteCurrency,
1027
+ },
1028
+ ]);
1029
+ const parseData = (data) => {
1030
+ data.data.updated_at = data.data.updated_at
1031
+ ? new Date(data.data.updated_at)
1032
+ : null;
1033
+ data.data.base_fee = bigIntParser(data.data.base_fee);
1034
+ return data;
1035
+ };
1036
+ return await this.execution.execute(endpoint, parseData);
1037
+ }
1038
+ }
1039
+
1040
+ /**
1041
+ * NFT APIs
1042
+ *
1043
+ */
1044
+ class NftService {
1045
+ constructor(execution) {
1046
+ this.execution = execution;
1047
+ }
1048
+ /**
1049
+ *
1050
+ * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
1051
+ *
1052
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1053
+ * @param {GetChainCollectionsQueryParamOpts} queryParamOpts
1054
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1055
+ * - `pageNumber`: 0-indexed page number to begin pagination.
1056
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1057
+ *
1058
+ */
1059
+ async *getChainCollections(chainName, queryParamOpts) {
1060
+ const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
1061
+ {
1062
+ key: "page-size",
1063
+ value: queryParamOpts?.pageSize,
1064
+ },
1065
+ {
1066
+ key: "page-number",
1067
+ value: queryParamOpts?.pageNumber,
1068
+ },
1069
+ {
1070
+ key: "no-spam",
1071
+ value: queryParamOpts?.noSpam,
1072
+ },
1073
+ ]);
1074
+ const parseData = (data) => {
1075
+ data.data.updated_at = data.data.updated_at
1076
+ ? new Date(data.data.updated_at)
1077
+ : null;
1078
+ data.data.items = data.data.items
1079
+ ? data.data.items.map((collectionItem) => ({
1080
+ ...collectionItem,
1081
+ last_scraped_at: collectionItem.last_scraped_at
1082
+ ? new Date(collectionItem.last_scraped_at)
1083
+ : null,
1084
+ }))
1085
+ : null;
1086
+ return data;
1087
+ };
1088
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
1089
+ yield data;
1090
+ }
1091
+ }
1092
+ /**
1093
+ *
1094
+ * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
1095
+ *
1096
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1097
+ * @param {GetChainCollectionsQueryParamOpts} queryParamOpts
1098
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1099
+ * - `pageNumber`: 0-indexed page number to begin pagination.
1100
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1101
+ *
1102
+ */
1103
+ async getChainCollectionsByPage(chainName, queryParamOpts) {
1104
+ const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
1105
+ {
1106
+ key: "page-size",
1107
+ value: queryParamOpts?.pageSize,
1108
+ },
1109
+ {
1110
+ key: "page-number",
1111
+ value: queryParamOpts?.pageNumber,
1112
+ },
1113
+ {
1114
+ key: "no-spam",
1115
+ value: queryParamOpts?.noSpam,
1116
+ },
1117
+ ]);
1118
+ const parseData = (data) => {
1119
+ data.data.updated_at = data.data.updated_at
1120
+ ? new Date(data.data.updated_at)
1121
+ : null;
1122
+ data.data.items = data.data.items
1123
+ ? data.data.items.map((collectionItem) => ({
1124
+ ...collectionItem,
1125
+ last_scraped_at: collectionItem.last_scraped_at
1126
+ ? new Date(collectionItem.last_scraped_at)
1127
+ : null,
1128
+ }))
1129
+ : null;
1130
+ return data;
1131
+ };
1132
+ return await this.execution.execute(endpoint, parseData);
1133
+ }
1134
+ /**
1135
+ *
1136
+ * Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
1137
+ *
1138
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1139
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1140
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
1141
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1142
+ * - `noNftAssetMetadata`: If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
1143
+ * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1144
+ *
1145
+ */
1146
+ async getNftsForAddress(chainName, walletAddress, queryParamOpts) {
1147
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/balances_nft`, [
1148
+ {
1149
+ key: "no-spam",
1150
+ value: queryParamOpts?.noSpam,
1151
+ },
1152
+ {
1153
+ key: "no-nft-asset-metadata",
1154
+ value: queryParamOpts?.noNftAssetMetadata,
1155
+ },
1156
+ {
1157
+ key: "with-uncached",
1158
+ value: queryParamOpts?.withUncached,
1159
+ },
1160
+ ]);
1161
+ const parseData = (data) => {
1162
+ data.data.updated_at = data.data.updated_at
1163
+ ? new Date(data.data.updated_at)
1164
+ : null;
1165
+ data.data.items = data.data.items
1166
+ ? data.data.items.map((balanceItem) => ({
1167
+ ...balanceItem,
1168
+ balance: bigIntParser(balanceItem.balance),
1169
+ balance_24h: bigIntParser(balanceItem.balance_24h),
1170
+ nft_data: balanceItem.nft_data
1171
+ ? balanceItem.nft_data.map((nftItem) => ({
1172
+ ...nftItem,
1173
+ token_id: bigIntParser(nftItem.token_id),
1174
+ }))
1175
+ : null,
1176
+ }))
1177
+ : null;
1178
+ return data;
1179
+ };
1180
+ return await this.execution.execute(endpoint, parseData);
1181
+ }
1182
+ /**
1183
+ *
1184
+ * Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
1185
+ *
1186
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1187
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1188
+ * @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
1189
+ * - `noMetadata`: Omit metadata.
1190
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1191
+ * - `pageNumber`: 0-indexed page number to begin pagination.
1192
+ * - `traitsFilter`: Filters NFTs based on a specific trait. If this filter is used, the API will return all NFTs with the specified trait. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1193
+ * - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1194
+ * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1195
+ *
1196
+ */
1197
+ async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
1198
+ const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
1199
+ {
1200
+ key: "no-metadata",
1201
+ value: queryParamOpts?.noMetadata,
1202
+ },
1203
+ {
1204
+ key: "page-size",
1205
+ value: queryParamOpts?.pageSize,
1206
+ },
1207
+ {
1208
+ key: "page-number",
1209
+ value: queryParamOpts?.pageNumber,
1210
+ },
1211
+ {
1212
+ key: "traits-filter",
1213
+ value: queryParamOpts?.traitsFilter,
1214
+ },
1215
+ {
1216
+ key: "values-filter",
1217
+ value: queryParamOpts?.valuesFilter,
1218
+ },
1219
+ {
1220
+ key: "with-uncached",
1221
+ value: queryParamOpts?.withUncached,
1222
+ },
1223
+ ]);
1224
+ const parseData = (data) => {
1225
+ data.data.updated_at = data.data.updated_at
1226
+ ? new Date(data.data.updated_at)
1227
+ : null;
1228
+ data.data.items = data.data.items
1229
+ ? data.data.items.map((tokenItem) => ({
1230
+ ...tokenItem,
1231
+ nft_data: {
1232
+ ...tokenItem.nft_data,
1233
+ token_id: bigIntParser(tokenItem.nft_data.token_id),
1234
+ },
1235
+ }))
1236
+ : null;
1237
+ return data;
1238
+ };
1239
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
1240
+ yield data;
1241
+ }
1242
+ }
1243
+ /**
1244
+ *
1245
+ * Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
1246
+ *
1247
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1248
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1249
+ * @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
1250
+ * - `noMetadata`: Omit metadata.
1251
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1252
+ * - `pageNumber`: 0-indexed page number to begin pagination.
1253
+ * - `traitsFilter`: Filters NFTs based on a specific trait. If this filter is used, the API will return all NFTs with the specified trait. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1254
+ * - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1255
+ * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1256
+ *
1257
+ */
1258
+ async getTokenIdsForContractWithMetadataByPage(chainName, contractAddress, queryParamOpts) {
1259
+ const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
1260
+ {
1261
+ key: "no-metadata",
1262
+ value: queryParamOpts?.noMetadata,
1263
+ },
1264
+ {
1265
+ key: "page-size",
1266
+ value: queryParamOpts?.pageSize,
1267
+ },
1268
+ {
1269
+ key: "page-number",
1270
+ value: queryParamOpts?.pageNumber,
1271
+ },
1272
+ {
1273
+ key: "traits-filter",
1274
+ value: queryParamOpts?.traitsFilter,
1275
+ },
1276
+ {
1277
+ key: "values-filter",
1278
+ value: queryParamOpts?.valuesFilter,
1279
+ },
1280
+ {
1281
+ key: "with-uncached",
1282
+ value: queryParamOpts?.withUncached,
1283
+ },
1284
+ ]);
1285
+ const parseData = (data) => {
1286
+ data.data.updated_at = data.data.updated_at
1287
+ ? new Date(data.data.updated_at)
1288
+ : null;
1289
+ data.data.items = data.data.items
1290
+ ? data.data.items.map((tokenItem) => ({
1291
+ ...tokenItem,
1292
+ nft_data: {
1293
+ ...tokenItem.nft_data,
1294
+ token_id: bigIntParser(tokenItem.nft_data.token_id),
1295
+ },
1296
+ }))
1297
+ : null;
1298
+ return data;
1299
+ };
1300
+ return await this.execution.execute(endpoint, parseData);
1301
+ }
1302
+ /**
1303
+ *
1304
+ * Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
1305
+ *
1306
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1307
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1308
+ * @param {string} tokenId - The requested token ID.
1309
+ * @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
1310
+ * - `noMetadata`: Omit metadata.
1311
+ * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1312
+ *
1313
+ */
1314
+ async getNftMetadataForGivenTokenIdForContract(chainName, contractAddress, tokenId, queryParamOpts) {
1315
+ const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata/${tokenId}`, [
1316
+ {
1317
+ key: "no-metadata",
1318
+ value: queryParamOpts?.noMetadata,
1319
+ },
1320
+ {
1321
+ key: "with-uncached",
1322
+ value: queryParamOpts?.withUncached,
1323
+ },
1324
+ ]);
1325
+ const parseData = (data) => {
1326
+ data.data.updated_at = data.data.updated_at
1327
+ ? new Date(data.data.updated_at)
1328
+ : null;
1329
+ data.data.items = data.data.items
1330
+ ? data.data.items.map((tokenItem) => ({
1331
+ ...tokenItem,
1332
+ nft_data: {
1333
+ ...tokenItem.nft_data,
1334
+ token_id: bigIntParser(tokenItem.nft_data.token_id),
1335
+ },
1336
+ }))
1337
+ : null;
1338
+ return data;
1339
+ };
1340
+ return await this.execution.execute(endpoint, parseData);
1341
+ }
1342
+ /**
1343
+ *
1344
+ * Commonly used to get all transactions of an NFT token. Useful for building a transaction history table or price chart.
1345
+ *
1346
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1347
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1348
+ * @param {string} tokenId - The requested token ID.
1349
+ * @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
1350
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1351
+ *
1352
+ */
1353
+ async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, queryParamOpts) {
1354
+ const endpoint = endpointGenerator(`${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}`, [
1355
+ {
1356
+ key: "no-spam",
1357
+ value: queryParamOpts?.noSpam,
1358
+ },
1359
+ ]);
1360
+ const parseData = (data) => {
1361
+ data.data.updated_at = data.data.updated_at
1362
+ ? new Date(data.data.updated_at)
1363
+ : null;
1364
+ data.data.items = data.data.items
1365
+ ? data.data.items.map((nftItem) => ({
1366
+ ...nftItem,
1367
+ nft_transactions: nftItem.nft_transactions
1368
+ ? nftItem.nft_transactions.map((txItem) => ({
1369
+ ...txItem,
1370
+ block_signed_at: txItem.block_signed_at
1371
+ ? new Date(txItem.block_signed_at)
1372
+ : null,
1373
+ value: bigIntParser(txItem.value),
1374
+ fees_paid: bigIntParser(txItem.fees_paid),
1375
+ log_events: txItem.log_events
1376
+ ? txItem.log_events.map((logItem) => ({
1377
+ ...logItem,
1378
+ block_signed_at: logItem.block_signed_at
1379
+ ? new Date(logItem.block_signed_at)
1380
+ : null,
1381
+ }))
1382
+ : null,
1383
+ }))
1384
+ : null,
1385
+ }))
1386
+ : null;
1387
+ return data;
1388
+ };
1389
+ return await this.execution.execute(endpoint, parseData);
1390
+ }
1391
+ /**
1392
+ *
1393
+ * Commonly used to fetch and render the traits of a collection as seen in rarity calculators.
1394
+ *
1395
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1396
+ * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1397
+ *
1398
+ */
1399
+ async getTraitsForCollection(chainName, collectionContract) {
1400
+ const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits`, []);
1401
+ const parseData = (data) => {
1402
+ data.data.updated_at = data.data.updated_at
1403
+ ? new Date(data.data.updated_at)
1404
+ : null;
1405
+ return data;
1406
+ };
1407
+ return await this.execution.execute(endpoint, parseData);
1408
+ }
1409
+ /**
1410
+ *
1411
+ * Commonly used to get the count of unique values for traits within an NFT collection.
1412
+ *
1413
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1414
+ * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1415
+ * @param {string} trait - The requested trait.
1416
+ *
1417
+ */
1418
+ async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
1419
+ const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits/${trait}/attributes`, []);
1420
+ const parseData = (data) => {
1421
+ data.data.updated_at = data.data.updated_at
1422
+ ? new Date(data.data.updated_at)
1423
+ : null;
1424
+ return data;
1425
+ };
1426
+ return await this.execution.execute(endpoint, parseData);
1427
+ }
1428
+ /**
1429
+ *
1430
+ * Commonly used to calculate rarity scores for a collection based on its traits.
1431
+ *
1432
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1433
+ * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1434
+ *
1435
+ */
1436
+ async getCollectionTraitsSummary(chainName, collectionContract) {
1437
+ const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits_summary`, []);
1438
+ const parseData = (data) => {
1439
+ data.data.updated_at = data.data.updated_at
1440
+ ? new Date(data.data.updated_at)
1441
+ : null;
1442
+ return data;
1443
+ };
1444
+ return await this.execution.execute(endpoint, parseData);
1445
+ }
1446
+ /**
1447
+ *
1448
+ * Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
1449
+ *
1450
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1451
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1452
+ * @param {string} collectionContract - The requested collection address.
1453
+ * @param {CheckOwnershipInNftQueryParamOpts} queryParamOpts
1454
+ * - `traitsFilter`: Filters NFTs based on a specific trait. If this filter is used, the API will return all NFTs with the specified trait. Must be used with "values-filter", is case-sensitive, and requires proper URL encoding.
1455
+ * - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. Must be used with "traits-filter", is case-sensitive, and requires proper URL encoding.
1456
+ *
1457
+ */
1458
+ async checkOwnershipInNft(chainName, walletAddress, collectionContract, queryParamOpts) {
1459
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/collection/${collectionContract}`, [
1460
+ {
1461
+ key: "traits-filter",
1462
+ value: queryParamOpts?.traitsFilter,
1463
+ },
1464
+ {
1465
+ key: "values-filter",
1466
+ value: queryParamOpts?.valuesFilter,
1467
+ },
1468
+ ]);
1469
+ const parseData = (data) => {
1470
+ data.data.updated_at = data.data.updated_at
1471
+ ? new Date(data.data.updated_at)
1472
+ : null;
1473
+ data.data.items = data.data.items
1474
+ ? data.data.items.map((nftItem) => ({
1475
+ ...nftItem,
1476
+ balance: bigIntParser(nftItem.balance),
1477
+ balance_24h: bigIntParser(nftItem.balance_24h),
1478
+ token_id: bigIntParser(nftItem.token_id),
1479
+ nft_data: {
1480
+ ...nftItem.nft_data,
1481
+ token_id: bigIntParser(nftItem.nft_data.token_id),
1482
+ },
1483
+ }))
1484
+ : null;
1485
+ return data;
1486
+ };
1487
+ return await this.execution.execute(endpoint, parseData);
1488
+ }
1489
+ /**
1490
+ *
1491
+ * Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
1492
+ *
1493
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
1494
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1495
+ * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1496
+ * @param {string} tokenId - The requested token ID.
1497
+ *
1498
+ */
1499
+ async checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) {
1500
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}`, []);
1501
+ const parseData = (data) => {
1502
+ data.data.updated_at = data.data.updated_at
1503
+ ? new Date(data.data.updated_at)
1504
+ : null;
1505
+ data.data.items = data.data.items
1506
+ ? data.data.items.map((balanceItem) => ({
1507
+ ...balanceItem,
1508
+ balance: bigIntParser(balanceItem.balance),
1509
+ balance_24h: bigIntParser(balanceItem.balance_24h),
1510
+ token_id: bigIntParser(balanceItem.token_id),
1511
+ last_transfered_at: balanceItem.last_transfered_at
1512
+ ? new Date(balanceItem.last_transfered_at)
1513
+ : null,
1514
+ }))
1515
+ : null;
1516
+ return data;
1517
+ };
1518
+ return await this.execution.execute(endpoint, parseData);
1519
+ }
1520
+ }
1521
+
1522
+ /**
1523
+ * Pricing APIs
1524
+ *
1525
+ */
1526
+ class PricingService {
1527
+ constructor(execution) {
1528
+ this.execution = execution;
1529
+ }
1530
+ /**
1531
+ *
1532
+ * Commonly used to get historic prices of a token between date ranges. Supports native tokens.
1533
+ *
1534
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1535
+ * @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1536
+ * @param {string} contractAddress - Contract address for the token. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically. Supports multiple contract addresses separated by commas.
1537
+ * @param {GetTokenPricesQueryParamOpts} queryParamOpts
1538
+ * - `from`: The start day of the historical price range (YYYY-MM-DD).
1539
+ * - `to`: The end day of the historical price range (YYYY-MM-DD).
1540
+ * - `pricesAtAsc`: Sort the prices in chronological ascending order. By default, it's set to `false` and returns prices in chronological descending order.
1541
+ *
1542
+ */
1543
+ async getTokenPrices(chainName, quoteCurrency, contractAddress, queryParamOpts) {
1544
+ const endpoint = endpointGenerator(`pricing/historical_by_addresses_v2/${chainName}/${quoteCurrency}/${contractAddress}`, [
1545
+ {
1546
+ key: "from",
1547
+ value: queryParamOpts?.from,
1548
+ },
1549
+ {
1550
+ key: "to",
1551
+ value: queryParamOpts?.to,
1552
+ },
1553
+ {
1554
+ key: "prices-at-asc",
1555
+ value: queryParamOpts?.pricesAtAsc,
1556
+ },
1557
+ ]);
1558
+ const parseData = (data) => {
1559
+ data.data.forEach((dataItem) => {
1560
+ dataItem.update_at = dataItem.update_at
1561
+ ? new Date(dataItem.update_at)
1562
+ : null;
1563
+ dataItem.items = dataItem.items
1564
+ ? dataItem.items.map((priceItem) => ({
1565
+ ...priceItem,
1566
+ date: priceItem.date ? new Date(priceItem.date) : null,
1567
+ }))
1568
+ : null;
1569
+ });
1570
+ return data;
1571
+ };
1572
+ return await this.execution.execute(endpoint, parseData);
1573
+ }
1574
+ }
1575
+
1576
+ /**
1577
+ * Approvals API
1578
+ *
1579
+ */
1580
+ class SecurityService {
1581
+ constructor(execution) {
1582
+ this.execution = execution;
1583
+ }
1584
+ /**
1585
+ *
1586
+ * Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
1587
+ *
1588
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1589
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1590
+ *
1591
+ */
1592
+ async getApprovals(chainName, walletAddress) {
1593
+ const endpoint = endpointGenerator(`${chainName}/approvals/${walletAddress}`, []);
1594
+ const parseData = (data) => {
1595
+ data.data.updated_at = data.data.updated_at
1596
+ ? new Date(data.data.updated_at)
1597
+ : null;
1598
+ data.data.items = data.data.items
1599
+ ? data.data.items.map((approvalItem) => ({
1600
+ ...approvalItem,
1601
+ balance: bigIntParser(approvalItem.balance),
1602
+ spenders: approvalItem.spenders
1603
+ ? approvalItem.spenders.map((spenderItem) => ({
1604
+ ...spenderItem,
1605
+ block_signed_at: spenderItem.block_signed_at
1606
+ ? new Date(spenderItem.block_signed_at)
1607
+ : null,
1608
+ }))
1609
+ : null,
1610
+ }))
1611
+ : null;
1612
+ return data;
1613
+ };
1614
+ return await this.execution.execute(endpoint, parseData);
1615
+ }
1616
+ /**
1617
+ *
1618
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1619
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1620
+
1621
+ *
1622
+ */
1623
+ async getNftApprovals(chainName, walletAddress) {
1624
+ const endpoint = endpointGenerator(`${chainName}/nft/approvals/${walletAddress}`, []);
1625
+ const parseData = (data) => {
1626
+ data.data.updated_at = data.data.updated_at
1627
+ ? new Date(data.data.updated_at)
1628
+ : null;
1629
+ data.data.items = data.data.items
1630
+ ? data.data.items.map((approvalItem) => ({
1631
+ ...approvalItem,
1632
+ token_balances: approvalItem.token_balances
1633
+ ? approvalItem.token_balances.map((balanceItem) => ({
1634
+ ...balanceItem,
1635
+ token_balance: bigIntParser(balanceItem.token_balance),
1636
+ token_id: bigIntParser(balanceItem.token_id),
1637
+ }))
1638
+ : null,
1639
+ }))
1640
+ : null;
1641
+ return data;
1642
+ };
1643
+ return await this.execution.execute(endpoint, parseData);
1644
+ }
1645
+ }
1646
+
1647
+ class TransactionService {
1648
+ constructor(execution) {
1649
+ this.execution = execution;
1650
+ }
1651
+ /**
1652
+ *
1653
+ * Commonly used to fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
1654
+ *
1655
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1656
+ * @param {string} txHash - The transaction hash.
1657
+ * @param {GetTransactionQueryParamOpts} queryParamOpts
1658
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1659
+ * - `noLogs`: Omit log events.
1660
+ * - `withDex`: Decoded DEX details including protocol (e.g. Uniswap), event (e.g 'add_liquidity') and tokens involved with historical prices. Additional 0.05 credits charged if data available.
1661
+ * - `withNftSales`: Decoded NFT sales details including marketplace (e.g. Opensea) and cached media links. Additional 0.05 credits charged if data available.
1662
+ * - `withLending`: Decoded lending details including protocol (e.g. Aave), event (e.g. 'deposit') and tokens involved with prices. Additional 0.05 credits charged if data available.
1663
+ * - `withSafe`: Include safe details.
1664
+ *
1665
+ */
1666
+ async getTransaction(chainName, txHash, queryParamOpts) {
1667
+ const endpoint = endpointGenerator(`${chainName}/transaction_v2/${txHash}`, [
1668
+ {
1669
+ key: "quote-currency",
1670
+ value: queryParamOpts?.quoteCurrency,
1671
+ },
1672
+ {
1673
+ key: "no-logs",
1674
+ value: queryParamOpts?.noLogs,
1675
+ },
1676
+ {
1677
+ key: "with-dex",
1678
+ value: queryParamOpts?.withDex,
1679
+ },
1680
+ {
1681
+ key: "with-nft-sales",
1682
+ value: queryParamOpts?.withNftSales,
1683
+ },
1684
+ {
1685
+ key: "with-lending",
1686
+ value: queryParamOpts?.withLending,
1687
+ },
1688
+ ]);
1689
+ const parseData = (data) => {
1690
+ data.data.updated_at = data.data.updated_at
1691
+ ? new Date(data.data.updated_at)
1692
+ : null;
1693
+ data.data.items = data.data.items
1694
+ ? data.data.items.map((txItem) => ({
1695
+ ...txItem,
1696
+ value: bigIntParser(txItem.value),
1697
+ fees_paid: bigIntParser(txItem.fees_paid),
1698
+ block_signed_at: txItem.block_signed_at
1699
+ ? new Date(txItem.block_signed_at)
1700
+ : null,
1701
+ log_events: txItem.log_events
1702
+ ? txItem.log_events.map((logItem) => ({
1703
+ ...logItem,
1704
+ block_signed_at: logItem.block_signed_at
1705
+ ? new Date(logItem.block_signed_at)
1706
+ : null,
1707
+ }))
1708
+ : null,
1709
+ }))
1710
+ : null;
1711
+ return data;
1712
+ };
1713
+ return await this.execution.execute(endpoint, parseData);
1714
+ }
1715
+ /**
1716
+ *
1717
+ * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
1718
+ *
1719
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1720
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1721
+ * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
1722
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1723
+ * - `noLogs`: Omit log events.
1724
+ * - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
1725
+ * - `withSafe`: Include safe details.
1726
+ *
1727
+ */
1728
+ async *getAllTransactionsForAddress(chainName, walletAddress, queryParamOpts) {
1729
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_v3`, [
1730
+ {
1731
+ key: "quote-currency",
1732
+ value: queryParamOpts?.quoteCurrency,
1733
+ },
1734
+ {
1735
+ key: "no-logs",
1736
+ value: queryParamOpts?.noLogs,
1737
+ },
1738
+ {
1739
+ key: "block-signed-at-asc",
1740
+ value: queryParamOpts?.blockSignedAtAsc,
1741
+ },
1742
+ {
1743
+ key: "with-safe",
1744
+ value: queryParamOpts?.withSafe,
1745
+ },
1746
+ ]);
1747
+ const parseData = (data) => {
1748
+ data.data.updated_at = data.data.updated_at
1749
+ ? new Date(data.data.updated_at)
1750
+ : null;
1751
+ data.data.items = data.data.items
1752
+ ? data.data.items.map((txItem) => ({
1753
+ ...txItem,
1754
+ value: bigIntParser(txItem.value),
1755
+ fees_paid: bigIntParser(txItem.fees_paid),
1756
+ block_signed_at: txItem.block_signed_at
1757
+ ? new Date(txItem.block_signed_at)
1758
+ : null,
1759
+ log_events: txItem.log_events
1760
+ ? txItem.log_events.map((logItem) => ({
1761
+ ...logItem,
1762
+ block_signed_at: logItem.block_signed_at
1763
+ ? new Date(logItem.block_signed_at)
1764
+ : null,
1765
+ }))
1766
+ : null,
1767
+ }))
1768
+ : null;
1769
+ return data;
1770
+ };
1771
+ for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "links")) {
1772
+ yield data;
1773
+ }
1774
+ }
1775
+ /**
1776
+ *
1777
+ * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
1778
+ *
1779
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1780
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1781
+ * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
1782
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1783
+ * - `noLogs`: Omit log events.
1784
+ * - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
1785
+ * - `withSafe`: Include safe details.
1786
+ *
1787
+ */
1788
+ async getAllTransactionsForAddressByPage(chainName, walletAddress, queryParamOpts) {
1789
+ const searchParams = [
1790
+ {
1791
+ key: "quote-currency",
1792
+ value: queryParamOpts?.quoteCurrency,
1793
+ },
1794
+ {
1795
+ key: "no-logs",
1796
+ value: queryParamOpts?.noLogs,
1797
+ },
1798
+ {
1799
+ key: "block-signed-at-asc",
1800
+ value: queryParamOpts?.blockSignedAtAsc,
1801
+ },
1802
+ {
1803
+ key: "with-safe",
1804
+ value: queryParamOpts?.withSafe,
1805
+ },
1806
+ ];
1807
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_v3`, searchParams);
1808
+ const parseData = (data) => {
1809
+ data.data.prev = data.data.links.prev
1810
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.prev, searchParams), parseData)
1811
+ : null;
1812
+ data.data.next = data.data.links.next
1813
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.next, searchParams), parseData)
1814
+ : null;
1815
+ data.data.updated_at = data.data.updated_at
1816
+ ? new Date(data.data.updated_at)
1817
+ : null;
1818
+ data.data.items = data.data.items
1819
+ ? data.data.items.map((txItem) => ({
1820
+ ...txItem,
1821
+ value: bigIntParser(txItem.value),
1822
+ fees_paid: bigIntParser(txItem.fees_paid),
1823
+ block_signed_at: txItem.block_signed_at
1824
+ ? new Date(txItem.block_signed_at)
1825
+ : null,
1826
+ log_events: txItem.log_events
1827
+ ? txItem.log_events.map((logItem) => ({
1828
+ ...logItem,
1829
+ block_signed_at: logItem.block_signed_at
1830
+ ? new Date(logItem.block_signed_at)
1831
+ : null,
1832
+ }))
1833
+ : null,
1834
+ }))
1835
+ : null;
1836
+ return data;
1837
+ };
1838
+ return await this.execution.execute(endpoint, parseData);
1839
+ }
1840
+ /**
1841
+ *
1842
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
1843
+ *
1844
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1845
+ * @param {number} blockHeight - The requested block height.
1846
+ * @param {GetTransactionsForBlockQueryParamOpts} queryParamOpts
1847
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1848
+ * - `noLogs`: Omit log events.
1849
+ * - `withSafe`: Include safe details.
1850
+ *
1851
+ */
1852
+ async getTransactionsForBlock(chainName, blockHeight, queryParamOpts) {
1853
+ const endpoint = endpointGenerator(`${chainName}/block/${blockHeight}/transactions_v3`, [
1854
+ {
1855
+ key: "quote-currency",
1856
+ value: queryParamOpts?.quoteCurrency,
1857
+ },
1858
+ {
1859
+ key: "no-logs",
1860
+ value: queryParamOpts?.noLogs,
1861
+ },
1862
+ {
1863
+ key: "with-safe",
1864
+ value: queryParamOpts?.withSafe,
1865
+ },
1866
+ ]);
1867
+ const parseData = (data) => {
1868
+ data.data.updated_at = data.data.updated_at
1869
+ ? new Date(data.data.updated_at)
1870
+ : null;
1871
+ data.data.items = data.data.items
1872
+ ? data.data.items.map((txItem) => ({
1873
+ ...txItem,
1874
+ value: bigIntParser(txItem.value),
1875
+ fees_paid: bigIntParser(txItem.fees_paid),
1876
+ block_signed_at: txItem.block_signed_at
1877
+ ? new Date(txItem.block_signed_at)
1878
+ : null,
1879
+ log_events: txItem.log_events
1880
+ ? txItem.log_events.map((logItem) => ({
1881
+ ...logItem,
1882
+ block_signed_at: logItem.block_signed_at
1883
+ ? new Date(logItem.block_signed_at)
1884
+ : null,
1885
+ }))
1886
+ : null,
1887
+ }))
1888
+ : null;
1889
+ return data;
1890
+ };
1891
+ return await this.execution.execute(endpoint, parseData);
1892
+ }
1893
+ /**
1894
+ *
1895
+ * Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
1896
+ *
1897
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1898
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1899
+ * @param {GetTransactionSummaryQueryParamOpts} queryParamOpts
1900
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1901
+ * - `withGas`: Include gas summary details. Additional charge of 1 credit when true. Response times may be impacted for wallets with millions of transactions.
1902
+ *
1903
+ */
1904
+ async getTransactionSummary(chainName, walletAddress, queryParamOpts) {
1905
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_summary`, [
1906
+ {
1907
+ key: "quote-currency",
1908
+ value: queryParamOpts?.quoteCurrency,
1909
+ },
1910
+ {
1911
+ key: "with-gas",
1912
+ value: queryParamOpts?.withGas,
1913
+ },
1914
+ ]);
1915
+ const parseData = (data) => {
1916
+ data.data.updated_at = data.data.updated_at
1917
+ ? new Date(data.data.updated_at)
1918
+ : null;
1919
+ data.data.items = data.data.items
1920
+ ? data.data.items.map((txsItem) => ({
1921
+ ...txsItem,
1922
+ earliest_transaction: {
1923
+ ...txsItem.earliest_transaction,
1924
+ block_signed_at: txsItem.earliest_transaction.block_signed_at
1925
+ ? new Date(txsItem.earliest_transaction.block_signed_at)
1926
+ : null,
1927
+ },
1928
+ latest_transaction: {
1929
+ ...txsItem.latest_transaction,
1930
+ block_signed_at: txsItem.latest_transaction.block_signed_at
1931
+ ? new Date(txsItem.latest_transaction.block_signed_at)
1932
+ : null,
1933
+ },
1934
+ // ? API vs docs non-consistent
1935
+ // gas_summary: {
1936
+ // ...txsItem.gas_summary,
1937
+ // total_fees_paid: bigIntParser(
1938
+ // txsItem.gas_summary.total_fees_paid
1939
+ // ),
1940
+ // },
1941
+ }))
1942
+ : null;
1943
+ return data;
1944
+ };
1945
+ return await this.execution.execute(endpoint, parseData);
1946
+ }
1947
+ /**
1948
+ *
1949
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1950
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1951
+ * @param {number} page - The requested page, 0-indexed.
1952
+ * @param {GetTransactionsForAddressV3QueryParamOpts} queryParamOpts
1953
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1954
+ * - `noLogs`: Omit log events.
1955
+ * - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
1956
+ * - `withSafe`: Include safe details.
1957
+ *
1958
+ */
1959
+ async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
1960
+ const searchParams = [
1961
+ {
1962
+ key: "quote-currency",
1963
+ value: queryParamOpts?.quoteCurrency,
1964
+ },
1965
+ {
1966
+ key: "no-logs",
1967
+ value: queryParamOpts?.noLogs,
1968
+ },
1969
+ {
1970
+ key: "block-signed-at-asc",
1971
+ value: queryParamOpts?.blockSignedAtAsc,
1972
+ },
1973
+ {
1974
+ key: "with-safe",
1975
+ value: queryParamOpts?.withSafe,
1976
+ },
1977
+ ];
1978
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/transactions_v3/page/${page}`, searchParams);
1979
+ const parseData = (data) => {
1980
+ data.data.prev = data.data.links.prev
1981
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.prev, searchParams), parseData)
1982
+ : null;
1983
+ data.data.next = data.data.links.next
1984
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.next, searchParams), parseData)
1985
+ : null;
1986
+ data.data.updated_at = data.data.updated_at
1987
+ ? new Date(data.data.updated_at)
1988
+ : null;
1989
+ data.data.items = data.data.items
1990
+ ? data.data.items.map((txItem) => ({
1991
+ ...txItem,
1992
+ value: bigIntParser(txItem.value),
1993
+ fees_paid: bigIntParser(txItem.fees_paid),
1994
+ block_signed_at: txItem.block_signed_at
1995
+ ? new Date(txItem.block_signed_at)
1996
+ : null,
1997
+ log_events: txItem.log_events
1998
+ ? txItem.log_events.map((logItem) => ({
1999
+ ...logItem,
2000
+ block_signed_at: logItem.block_signed_at
2001
+ ? new Date(logItem.block_signed_at)
2002
+ : null,
2003
+ }))
2004
+ : null,
2005
+ }))
2006
+ : null;
2007
+ return data;
2008
+ };
2009
+ return await this.execution.execute(endpoint, parseData);
2010
+ }
2011
+ /**
2012
+ *
2013
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2014
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2015
+ * @param {number} timeBucket - The 0-indexed 15-minute time bucket. E.g. 27 Feb 2023 05:23 GMT = 1677475383 (Unix time). 1677475383/900=1863861 timeBucket.
2016
+ * @param {GetTimeBucketTransactionsForAddressQueryParamOpts} queryParamOpts
2017
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2018
+ * - `noLogs`: Omit log events.
2019
+ * - `withSafe`: Include safe details.
2020
+ *
2021
+ */
2022
+ async getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, queryParamOpts) {
2023
+ const searchParams = [
2024
+ {
2025
+ key: "quote-currency",
2026
+ value: queryParamOpts?.quoteCurrency,
2027
+ },
2028
+ {
2029
+ key: "no-logs",
2030
+ value: queryParamOpts?.noLogs,
2031
+ },
2032
+ {
2033
+ key: "with-safe",
2034
+ value: queryParamOpts?.withSafe,
2035
+ },
2036
+ ];
2037
+ const endpoint = endpointGenerator(`${chainName}/bulk/transactions/${walletAddress}/${timeBucket}`, searchParams);
2038
+ const parseData = (data) => {
2039
+ data.data.prev = data.data.links.prev
2040
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.prev, searchParams), parseData)
2041
+ : null;
2042
+ data.data.next = data.data.links.next
2043
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.next, searchParams), parseData)
2044
+ : null;
2045
+ data.data.updated_at = data.data.updated_at
2046
+ ? new Date(data.data.updated_at)
2047
+ : null;
2048
+ data.data.items = data.data.items
2049
+ ? data.data.items.map((txItem) => ({
2050
+ ...txItem,
2051
+ value: bigIntParser(txItem.value),
2052
+ fees_paid: bigIntParser(txItem.fees_paid),
2053
+ block_signed_at: txItem.block_signed_at
2054
+ ? new Date(txItem.block_signed_at)
2055
+ : null,
2056
+ log_events: txItem.log_events
2057
+ ? txItem.log_events.map((logItem) => ({
2058
+ ...logItem,
2059
+ block_signed_at: logItem.block_signed_at
2060
+ ? new Date(logItem.block_signed_at)
2061
+ : null,
2062
+ }))
2063
+ : null,
2064
+ }))
2065
+ : null;
2066
+ return data;
2067
+ };
2068
+ return await this.execution.execute(endpoint, parseData);
2069
+ }
2070
+ /**
2071
+ *
2072
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
2073
+ *
2074
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2075
+ * @param {string} blockHash - The requested block hash.
2076
+ * @param {number} page - The requested 0-indexed page number.
2077
+ * @param {GetTransactionsForBlockHashByPageQueryParamOpts} queryParamOpts
2078
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2079
+ * - `noLogs`: Omit log events.
2080
+ * - `withSafe`: Include safe details.
2081
+ *
2082
+ */
2083
+ async getTransactionsForBlockHashByPage(chainName, blockHash, page, queryParamOpts) {
2084
+ const searchParams = [
2085
+ {
2086
+ key: "quote-currency",
2087
+ value: queryParamOpts?.quoteCurrency,
2088
+ },
2089
+ {
2090
+ key: "no-logs",
2091
+ value: queryParamOpts?.noLogs,
2092
+ },
2093
+ {
2094
+ key: "with-safe",
2095
+ value: queryParamOpts?.withSafe,
2096
+ },
2097
+ ];
2098
+ const endpoint = endpointGenerator(`${chainName}/block_hash/${blockHash}/transactions_v3/page/${page}`, searchParams);
2099
+ const parseData = (data) => {
2100
+ data.data.prev = data.data.links.prev
2101
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.prev, searchParams), parseData)
2102
+ : null;
2103
+ data.data.next = data.data.links.next
2104
+ ? async () => this.execution.execute(endpointGenerator(data.data.links.next, searchParams), parseData)
2105
+ : null;
2106
+ data.data.updated_at = data.data.updated_at
2107
+ ? new Date(data.data.updated_at)
2108
+ : null;
2109
+ data.data.items = data.data.items
2110
+ ? data.data.items.map((txItem) => ({
2111
+ ...txItem,
2112
+ value: bigIntParser(txItem.value),
2113
+ fees_paid: bigIntParser(txItem.fees_paid),
2114
+ block_signed_at: txItem.block_signed_at
2115
+ ? new Date(txItem.block_signed_at)
2116
+ : null,
2117
+ log_events: txItem.log_events
2118
+ ? txItem.log_events.map((logItem) => ({
2119
+ ...logItem,
2120
+ block_signed_at: logItem.block_signed_at
2121
+ ? new Date(logItem.block_signed_at)
2122
+ : null,
2123
+ }))
2124
+ : null,
2125
+ }))
2126
+ : null;
2127
+ return data;
2128
+ };
2129
+ return await this.execution.execute(endpoint, parseData);
2130
+ }
2131
+ /**
2132
+ *
2133
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
2134
+ *
2135
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2136
+ * @param {string} blockHash - The requested block hash.
2137
+ * @param {GetTransactionsForBlockHashQueryParamOpts} queryParamOpts
2138
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2139
+ * - `noLogs`: Omit log events.
2140
+ * - `withSafe`: Include safe details.
2141
+ *
2142
+ */
2143
+ async getTransactionsForBlockHash(chainName, blockHash, queryParamOpts) {
2144
+ const endpoint = endpointGenerator(`${chainName}/block_hash/${blockHash}/transactions_v3`, [
2145
+ {
2146
+ key: "quote-currency",
2147
+ value: queryParamOpts?.quoteCurrency,
2148
+ },
2149
+ {
2150
+ key: "no-logs",
2151
+ value: queryParamOpts?.noLogs,
2152
+ },
2153
+ {
2154
+ key: "with-safe",
2155
+ value: queryParamOpts?.withSafe,
2156
+ },
2157
+ ]);
2158
+ const parseData = (data) => {
2159
+ data.data.updated_at = data.data.updated_at
2160
+ ? new Date(data.data.updated_at)
2161
+ : null;
2162
+ data.data.items = data.data.items
2163
+ ? data.data.items.map((txItem) => ({
2164
+ ...txItem,
2165
+ value: bigIntParser(txItem.value),
2166
+ fees_paid: bigIntParser(txItem.fees_paid),
2167
+ block_signed_at: txItem.block_signed_at
2168
+ ? new Date(txItem.block_signed_at)
2169
+ : null,
2170
+ log_events: txItem.log_events
2171
+ ? txItem.log_events.map((logItem) => ({
2172
+ ...logItem,
2173
+ block_signed_at: logItem.block_signed_at
2174
+ ? new Date(logItem.block_signed_at)
2175
+ : null,
2176
+ }))
2177
+ : null,
2178
+ }))
2179
+ : null;
2180
+ return data;
2181
+ };
2182
+ return await this.execution.execute(endpoint, parseData);
2183
+ }
2184
+ }
2185
+
2186
+ async function debugOutput(settings, ...content) {
2187
+ if (settings.debug) {
2188
+ content.forEach((c) => {
2189
+ console.info("[DEBUG] |", c);
2190
+ });
2191
+ }
2192
+ }
2193
+
2194
+ function getDefaultExportFromCjs (x) {
2195
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2196
+ }
2197
+
2198
+ class Node {
2199
+ /// value;
2200
+ /// next;
2201
+
2202
+ constructor(value) {
2203
+ this.value = value;
2204
+
2205
+ // TODO: Remove this when targeting Node.js 12.
2206
+ this.next = undefined;
2207
+ }
2208
+ }
2209
+
2210
+ let Queue$1 = class Queue {
2211
+ // TODO: Use private class fields when targeting Node.js 12.
2212
+ // #_head;
2213
+ // #_tail;
2214
+ // #_size;
2215
+
2216
+ constructor() {
2217
+ this.clear();
2218
+ }
2219
+
2220
+ enqueue(value) {
2221
+ const node = new Node(value);
2222
+
2223
+ if (this._head) {
2224
+ this._tail.next = node;
2225
+ this._tail = node;
2226
+ } else {
2227
+ this._head = node;
2228
+ this._tail = node;
2229
+ }
2230
+
2231
+ this._size++;
2232
+ }
2233
+
2234
+ dequeue() {
2235
+ const current = this._head;
2236
+ if (!current) {
2237
+ return;
2238
+ }
2239
+
2240
+ this._head = this._head.next;
2241
+ this._size--;
2242
+ return current.value;
2243
+ }
2244
+
2245
+ clear() {
2246
+ this._head = undefined;
2247
+ this._tail = undefined;
2248
+ this._size = 0;
2249
+ }
2250
+
2251
+ get size() {
2252
+ return this._size;
2253
+ }
2254
+
2255
+ * [Symbol.iterator]() {
2256
+ let current = this._head;
2257
+
2258
+ while (current) {
2259
+ yield current.value;
2260
+ current = current.next;
2261
+ }
2262
+ }
2263
+ };
2264
+
2265
+ var yoctoQueue = Queue$1;
2266
+
2267
+ const Queue = yoctoQueue;
2268
+
2269
+ const pLimit = concurrency => {
2270
+ if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
2271
+ throw new TypeError('Expected `concurrency` to be a number from 1 and up');
2272
+ }
2273
+
2274
+ const queue = new Queue();
2275
+ let activeCount = 0;
2276
+
2277
+ const next = () => {
2278
+ activeCount--;
2279
+
2280
+ if (queue.size > 0) {
2281
+ queue.dequeue()();
2282
+ }
2283
+ };
2284
+
2285
+ const run = async (fn, resolve, ...args) => {
2286
+ activeCount++;
2287
+
2288
+ const result = (async () => fn(...args))();
2289
+
2290
+ resolve(result);
2291
+
2292
+ try {
2293
+ await result;
2294
+ } catch {}
2295
+
2296
+ next();
2297
+ };
2298
+
2299
+ const enqueue = (fn, resolve, ...args) => {
2300
+ queue.enqueue(run.bind(null, fn, resolve, ...args));
2301
+
2302
+ (async () => {
2303
+ // This function needs to wait until the next microtask before comparing
2304
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
2305
+ // when the run function is dequeued and called. The comparison in the if-statement
2306
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
2307
+ await Promise.resolve();
2308
+
2309
+ if (activeCount < concurrency && queue.size > 0) {
2310
+ queue.dequeue()();
2311
+ }
2312
+ })();
2313
+ };
2314
+
2315
+ const generator = (fn, ...args) => new Promise(resolve => {
2316
+ enqueue(fn, resolve, ...args);
2317
+ });
2318
+
2319
+ Object.defineProperties(generator, {
2320
+ activeCount: {
2321
+ get: () => activeCount
2322
+ },
2323
+ pendingCount: {
2324
+ get: () => queue.size
2325
+ },
2326
+ clearQueue: {
2327
+ value: () => {
2328
+ queue.clear();
2329
+ }
2330
+ }
2331
+ });
2332
+
2333
+ return generator;
2334
+ };
2335
+
2336
+ var pLimit_1 = pLimit;
2337
+
2338
+ var pLimit$1 = /*@__PURE__*/getDefaultExportFromCjs(pLimit_1);
2339
+
2340
+ class Execution {
2341
+ constructor(settings, headers) {
2342
+ this.settings = settings;
2343
+ this.headers = headers;
2344
+ this.processes = pLimit$1(this.settings.threadCount ?? 2);
2345
+ this.maxRetries = settings.maxRetries ?? 2;
2346
+ this.retryDelay = settings.retryDelay ?? 1500;
2347
+ this.enableRetry = settings.enableRetry ?? true;
2348
+ }
2349
+ async execute(endpoint, parseData) {
2350
+ let retryCount = 0;
2351
+ let completed = false;
2352
+ while (!completed) {
2353
+ try {
2354
+ const startTime = new Date();
2355
+ const response = await this.processes(() => fetch(endpoint, {
2356
+ headers: this.headers,
2357
+ }));
2358
+ debugOutput(this.settings, `Request URL: ${response ? new URL(response.url) : endpoint} | Response code: ${response ? response.status : 429} | Response time: ${(new Date().getTime() - startTime.getTime()).toFixed(2)}ms`);
2359
+ if (response.status === null || response.status === 429) {
2360
+ throw new Error(`Received status code: ${response.status ?? 429}`);
2361
+ }
2362
+ const data = (await response.json());
2363
+ if (data.error) {
2364
+ throw data;
2365
+ }
2366
+ const parsedData = parseData(data);
2367
+ completed = true;
2368
+ return {
2369
+ data: parsedData.data ?? null,
2370
+ error: false,
2371
+ error_code: null,
2372
+ error_message: null,
2373
+ };
2374
+ }
2375
+ catch (error) {
2376
+ debugOutput(this.settings, `Request URL: ${endpoint} | Retry Enabled: ${this.enableRetry} | Retry Count: ${retryCount} | Max Retries: ${this.maxRetries} | Retry Delay: ${this.retryDelay}ms`, error);
2377
+ if (this.enableRetry &&
2378
+ (error?.error_code === 429 || error?.cause?.code === 429)) {
2379
+ if (retryCount >= this.maxRetries) {
2380
+ completed = true;
2381
+ return {
2382
+ data: null,
2383
+ error: true,
2384
+ error_code: 429,
2385
+ error_message: `${this.maxRetries} retries exceeded`,
2386
+ };
2387
+ }
2388
+ else {
2389
+ retryCount++;
2390
+ await new Promise((resolve) => setTimeout(resolve, this.retryDelay));
2391
+ completed = false;
2392
+ }
2393
+ }
2394
+ else {
2395
+ completed = true;
2396
+ return {
2397
+ data: null,
2398
+ error: true,
2399
+ error_code: error?.cause?.code || error?.error_code || 500,
2400
+ error_message: error?.cause?.message ||
2401
+ error?.error_message ||
2402
+ "Internal server error",
2403
+ };
2404
+ }
2405
+ }
2406
+ }
2407
+ }
2408
+ }
2409
+
2410
+ const _apiKeyV1Pattern = /^ckey_([a-f0-9]{27})$/;
2411
+ const _apiKeyV2Pattern = /^cqt_(wF|rQ)([bcdfghjkmpqrtvwxyBCDFGHJKMPQRTVWXY346789]{26})$/;
2412
+ const isValidApiKey = (apiKey) => {
2413
+ return _apiKeyV1Pattern.test(apiKey) || _apiKeyV2Pattern.test(apiKey);
2414
+ };
2415
+
2416
+ /**
2417
+ * GoldRushClient Class
2418
+ */
2419
+ class GoldRushClient {
2420
+ constructor(apiKey, settings = {}) {
2421
+ this.userAgent = `com.covalenthq.sdk.typescript/${version}`;
2422
+ const validKey = isValidApiKey(apiKey);
2423
+ if (!validKey) {
2424
+ throw {
2425
+ data: null,
2426
+ error: true,
2427
+ error_code: 401,
2428
+ error_message: "Invalid or missing API key (sign up at https://goldrush.dev/platform/apikey)",
2429
+ };
2430
+ }
2431
+ const execution = new Execution(settings, {
2432
+ Authorization: `Bearer ${apiKey}`,
2433
+ "X-Requested-With": settings.source
2434
+ ? `${settings.source} (${this.userAgent})`
2435
+ : this.userAgent,
2436
+ });
2437
+ this.BalanceService = new BalanceService(execution);
2438
+ this.BaseService = new BaseService(execution);
2439
+ this.NftService = new NftService(execution);
2440
+ this.PricingService = new PricingService(execution);
2441
+ this.SecurityService = new SecurityService(execution);
2442
+ this.TransactionService = new TransactionService(execution);
2443
+ }
2444
+ }
2445
+
2446
+ const calculatePrettyBalance = (value, decimals = 18, roundOff = true, precision = 0) => {
2447
+ const bigDecimalValue = new Big(value.toString());
2448
+ const bigDecimalExpo = new Big(Math.pow(10, decimals).toString());
2449
+ const calculated = bigDecimalValue.div(bigDecimalExpo);
2450
+ if (decimals === 0 || !roundOff) {
2451
+ return calculated.toString();
2452
+ }
2453
+ const decimalFixed = precision || (calculated.lt(100) ? 6 : 2);
2454
+ return calculated.toFixed(decimalFixed);
2455
+ };
2456
+
2457
+ const LESS_THAN_ZERO = "0.01";
2458
+ const ZERO = "0.00";
2459
+ const currencyMap = {
2460
+ USD: "$",
2461
+ CAD: "CA$",
2462
+ EUR: "€",
2463
+ SGD: "S$",
2464
+ INR: "₹",
2465
+ JPY: "¥",
2466
+ VND: "₫",
2467
+ CNY: "CN¥",
2468
+ KRW: "₩",
2469
+ RUB: "₽",
2470
+ TRY: "₺",
2471
+ NGN: "₦",
2472
+ ARS: "ARS",
2473
+ AUD: "A$",
2474
+ CHF: "CHF",
2475
+ GBP: "£",
2476
+ };
2477
+ const prettifyCurrency = (value, decimals = 2, currency = "USD", ignoreSmallValue = false, ignoreMinus = true, ignoreZero = false) => {
2478
+ let numValue = Number(value);
2479
+ let minus = "";
2480
+ let currencySuffix = "";
2481
+ if (!ignoreMinus && numValue < 0) {
2482
+ numValue = Math.abs(numValue);
2483
+ minus = "-";
2484
+ }
2485
+ const currencySymbol = currencyMap[currency] ?? "$";
2486
+ if (numValue === 0 || isNaN(numValue)) {
2487
+ return ignoreZero
2488
+ ? `<${currencySymbol}${LESS_THAN_ZERO}`
2489
+ : `${currencySymbol}${ZERO}`;
2490
+ }
2491
+ if (numValue < 0.01 && ignoreSmallValue) {
2492
+ return `<${currencySymbol}${LESS_THAN_ZERO}`;
2493
+ }
2494
+ if (numValue > 999999999) {
2495
+ numValue /= 1000000000;
2496
+ currencySuffix = "B";
2497
+ }
2498
+ else if (numValue > 999999) {
2499
+ numValue /= 1000000;
2500
+ currencySuffix = "M";
2501
+ }
2502
+ const factor = Math.pow(10, decimals);
2503
+ numValue = Math.floor(numValue * factor) / factor;
2504
+ const formatter = new Intl.NumberFormat("en-US", {
2505
+ style: "currency",
2506
+ currency: currency,
2507
+ maximumFractionDigits: decimals,
2508
+ currencyDisplay: "symbol",
2509
+ });
2510
+ const formattedValue = formatter
2511
+ .format(numValue)
2512
+ .replace(new RegExp(`${currency}\\s?`), currencySymbol);
2513
+ return minus + formattedValue + currencySuffix;
2514
+ };
2515
+
2516
+ var ChainName;
2517
+ (function (ChainName) {
2518
+ ChainName["ETH_MAINNET"] = "eth-mainnet";
2519
+ ChainName["ETH_GOERLI"] = "eth-goerli";
2520
+ ChainName["ETH_SEPOLIA"] = "eth-sepolia";
2521
+ ChainName["ETH_HOLESKY"] = "eth-holesky";
2522
+ ChainName["MATIC_MAINNET"] = "matic-mainnet";
2523
+ ChainName["MATIC_MUMBAI"] = "matic-mumbai";
2524
+ ChainName["AVALANCHE_MAINNET"] = "avalanche-mainnet";
2525
+ ChainName["AVALANCHE_TESTNET"] = "avalanche-testnet";
2526
+ ChainName["BSC_MAINNET"] = "bsc-mainnet";
2527
+ ChainName["BSC_TESTNET"] = "bsc-testnet";
2528
+ ChainName["MOONBEAM_MAINNET"] = "moonbeam-mainnet";
2529
+ ChainName["MOONBEAM_MOONBASE_ALPHA"] = "moonbeam-moonbase-alpha";
2530
+ ChainName["MOONBEAM_MOONRIVER"] = "moonbeam-moonriver";
2531
+ ChainName["RSK_MAINNET"] = "rsk-mainnet";
2532
+ ChainName["RSK_TESTNET"] = "rsk-testnet";
2533
+ ChainName["ARBITRUM_MAINNET"] = "arbitrum-mainnet";
2534
+ ChainName["ARBITRUM_NOVA_MAINNET"] = "arbitrum-nova-mainnet";
2535
+ ChainName["ARBITRUM_SEPOLIA"] = "arbitrum-sepolia";
2536
+ ChainName["FANTOM_MAINNET"] = "fantom-mainnet";
2537
+ ChainName["FANTOM_TESTNET"] = "fantom-testnet";
2538
+ ChainName["PALM_MAINNET"] = "palm-mainnet";
2539
+ ChainName["PALM_TESTNET"] = "palm-testnet";
2540
+ ChainName["BTC_MAINNET"] = "btc-mainnet";
2541
+ ChainName["SOLANA_MAINNET"] = "solana-mainnet";
2542
+ ChainName["AXIE_MAINNET"] = "axie-mainnet";
2543
+ ChainName["OPTIMISM_MAINNET"] = "optimism-mainnet";
2544
+ ChainName["OPTIMISM_SEPOLIA"] = "optimism-sepolia";
2545
+ ChainName["EVMOS_MAINNET"] = "evmos-mainnet";
2546
+ ChainName["EVMOS_TESTNET"] = "evmos-testnet";
2547
+ ChainName["HARMONY_MAINNET"] = "harmony-mainnet";
2548
+ ChainName["HARMONY_TESTNET"] = "harmony-testnet";
2549
+ ChainName["CRONOS_MAINNET"] = "cronos-mainnet";
2550
+ ChainName["CRONOS_TESTNET"] = "cronos-testnet";
2551
+ ChainName["CRONOS_ZKEVM_TESTNET"] = "cronos-zkevm-testnet";
2552
+ ChainName["AURORA_MAINNET"] = "aurora-mainnet";
2553
+ ChainName["AURORA_TESTNET"] = "aurora-testnet";
2554
+ ChainName["EMERALD_PARATIME_MAINNET"] = "emerald-paratime-mainnet";
2555
+ ChainName["DEFI_KINGDOMS_MAINNET"] = "defi-kingdoms-mainnet";
2556
+ ChainName["DEFI_KINGDOMS_TESTNET"] = "defi-kingdoms-testnet";
2557
+ ChainName["BOBA_MAINNET"] = "boba-mainnet";
2558
+ ChainName["BOBA_BNB_MAINNET"] = "boba-bnb-mainnet";
2559
+ ChainName["BOBA_BNB_TESTNET"] = "boba-bnb-testnet";
2560
+ ChainName["SCROLL_SEPOLIA_TESTNET"] = "scroll-sepolia-testnet";
2561
+ ChainName["METIS_MAINNET"] = "metis-mainnet";
2562
+ ChainName["METIS_STARDUST"] = "metis-stardust";
2563
+ ChainName["AVALANCHE_DEXALOT_MAINNET"] = "avalanche-dexalot-mainnet";
2564
+ ChainName["AVALANCHE_DEXALOT_TESTNET"] = "avalanche-dexalot-testnet";
2565
+ ChainName["AVALANCHE_SHRAPNEL_MAINNET"] = "avalanche-shrapnel-mainnet";
2566
+ ChainName["AVALANCHE_NUMBERS"] = "avalanche-numbers";
2567
+ ChainName["AVALANCHE_DOS"] = "avalanche-dos";
2568
+ ChainName["AVALANCHE_XPLUS"] = "avalanche-xplus";
2569
+ ChainName["AVALANCHE_XANACHAIN"] = "avalanche-xanachain";
2570
+ ChainName["AVALANCHE_STEP_NETWORK"] = "avalanche-step-network";
2571
+ ChainName["AVALANCHE_SHRAPNEL_TESTNET"] = "avalanche-shrapnel-testnet";
2572
+ ChainName["AVALANCHE_BEAM_TESTNET"] = "avalanche-beam-testnet";
2573
+ ChainName["AVALANCHE_BLITZ_TESTNET"] = "avalanche-blitz-testnet";
2574
+ ChainName["AVALANCHE_MINTARA_TESTNET"] = "avalanche-mintara-testnet";
2575
+ ChainName["AVALANCHE_GREEN_DOT_TESTNET"] = "avalanche-green-dot-testnet";
2576
+ ChainName["AVALANCHE_PULSAR_TESTNET"] = "avalanche-pulsar-testnet";
2577
+ ChainName["AVALANCHE_UPTN"] = "avalanche-uptn";
2578
+ ChainName["AVALANCHE_AVACLOUD_TESTNET"] = "avalanche-avacloud-testnet";
2579
+ ChainName["AVALANCHE_BEAM_MAINNET"] = "avalanche-beam-mainnet";
2580
+ ChainName["AVALANCHE_BULLETIN_TESTNET"] = "avalanche-bulletin-testnet";
2581
+ ChainName["AVALANCHE_CONDUIT_TESTNET"] = "avalanche-conduit-testnet";
2582
+ ChainName["AVALANCHE_HERO_TESTNET"] = "avalanche-hero-testnet";
2583
+ ChainName["AVALANCHE_HUBBLE_EXCHANGE_TESTNET"] = "avalanche-hubble-exchange-testnet";
2584
+ ChainName["AVALANCHE_KIWI_TESTNET"] = "avalanche-kiwi-testnet";
2585
+ ChainName["AVALANCHE_MIHO_TESTNET"] = "avalanche-miho-testnet";
2586
+ ChainName["AVALANCHE_MONDRIAN_TESTNET"] = "avalanche-mondrian-testnet";
2587
+ ChainName["AVALANCHE_NMAC_TESTNET"] = "avalanche-nmac-testnet";
2588
+ ChainName["AVALANCHE_ORDERLY_TESTNET"] = "avalanche-orderly-testnet";
2589
+ ChainName["AVALANCHE_THIRDWEB_TESTNET"] = "avalanche-thirdweb-testnet";
2590
+ ChainName["AVALANCHE_WAGMI_TESTNET"] = "avalanche-wagmi-testnet";
2591
+ ChainName["AVALANCHE_PLAYA3ULL_TESTNET"] = "avalanche-playa3ull-testnet";
2592
+ ChainName["AVALANCHE_MIRAI_TESTNET"] = "avalanche-mirai-testnet";
2593
+ ChainName["AVALANCHE_AMPLIFY_TESTNET"] = "avalanche-amplify-testnet";
2594
+ ChainName["AVALANCHE_LT0_TESTNET"] = "avalanche-lt0-testnet";
2595
+ ChainName["AVALANCHE_LT5_TESTNET"] = "avalanche-lt5-testnet";
2596
+ ChainName["AVALANCHE_HUBBLE_EXCHANGE_MAINNET"] = "avalanche-hubble-exchange-mainnet";
2597
+ ChainName["METER_MAINNET"] = "meter-mainnet";
2598
+ ChainName["METER_TESTNET"] = "meter-testnet";
2599
+ ChainName["MILKOMEDA_A1_MAINNET"] = "milkomeda-a1-mainnet";
2600
+ ChainName["MILKOMEDA_C1_MAINNET"] = "milkomeda-c1-mainnet";
2601
+ ChainName["MILKOMEDA_C1_DEVNET"] = "milkomeda-c1-devnet";
2602
+ ChainName["CANTO_MAINNET"] = "canto-mainnet";
2603
+ ChainName["FLARENETWORKS_FLARE_MAINNET"] = "flarenetworks-flare-mainnet";
2604
+ ChainName["FLARENETWORKS_FLARE_TESTNET"] = "flarenetworks-flare-testnet";
2605
+ ChainName["FLARENETWORKS_CANARY_MAINNET"] = "flarenetworks-canary-mainnet";
2606
+ ChainName["FLARENETWORKS_CANARY_TESTNET"] = "flarenetworks-canary-testnet";
2607
+ ChainName["KCC_MAINNET"] = "kcc-mainnet";
2608
+ ChainName["KCC_TESTNET"] = "kcc-testnet";
2609
+ ChainName["LINEA_MAINNET"] = "linea-mainnet";
2610
+ ChainName["POLYGON_ZKEVM_MAINNET"] = "polygon-zkevm-mainnet";
2611
+ ChainName["LINEA_SEPOLIA_TESTNET"] = "linea-sepolia-testnet";
2612
+ ChainName["LINEA_GOERLI_TESTNET"] = "linea-goerli-testnet";
2613
+ ChainName["POLYGON_ZKEVM_TESTNET"] = "polygon-zkevm-testnet";
2614
+ ChainName["POLYGON_AMOY_TESTNET"] = "polygon-amoy-testnet";
2615
+ ChainName["MANTLE_MAINNET"] = "mantle-mainnet";
2616
+ ChainName["MANTLE_SEPOLIA_TESTNET"] = "mantle-sepolia-testnet";
2617
+ ChainName["POLYGON_ZKEVM_CARDONA_TESTNET"] = "polygon-zkevm-cardona-testnet";
2618
+ ChainName["BASE_MAINNET"] = "base-mainnet";
2619
+ ChainName["BASE_TESTNET"] = "base-testnet";
2620
+ ChainName["BASE_SEPOLIA_TESTNET"] = "base-sepolia-testnet";
2621
+ ChainName["OASYS_MAINNET"] = "oasys-mainnet";
2622
+ ChainName["OASYS_TESTNET"] = "oasys-testnet";
2623
+ ChainName["SX_MAINNET"] = "sx-mainnet";
2624
+ ChainName["LUMOZ_PUBLIC_ZKSYNC_V2"] = "lumoz-public-zksync-v2";
2625
+ ChainName["LUMOZ_STARK_SPORT"] = "lumoz-stark-sport";
2626
+ ChainName["OASIS_SAPPHIRE_MAINNET"] = "oasis-sapphire-mainnet";
2627
+ ChainName["OASIS_SAPPHIRE_TESTNET"] = "oasis-sapphire-testnet";
2628
+ ChainName["SYNDR_TESTNET"] = "syndr-testnet";
2629
+ ChainName["XAI_MAINNET"] = "xai-mainnet";
2630
+ ChainName["CELO_MAINNET"] = "celo-mainnet";
2631
+ ChainName["X1_MAINNET"] = "x1-mainnet";
2632
+ ChainName["CROSSFI_EVM_TESTNET"] = "crossfi-evm-testnet";
2633
+ ChainName["HORIZEN_EON_MAINNET"] = "horizen-eon-mainnet";
2634
+ ChainName["HORIZEN_GOBI_TESTNET"] = "horizen-gobi-testnet";
2635
+ ChainName["FRAXTAL_MAINNET"] = "fraxtal-mainnet";
2636
+ ChainName["APECHAIN_TESTNET"] = "apechain-testnet";
2637
+ ChainName["LISK_MAINNET"] = "lisk-mainnet";
2638
+ ChainName["REDSTONE_MAINNET"] = "redstone-mainnet";
2639
+ ChainName["SEI_MAINNET"] = "sei-mainnet";
2640
+ ChainName["AVALANCHE_MELD_TESTNET"] = "avalanche-meld-testnet";
2641
+ ChainName["AVALANCHE_MELD_MAINNET"] = "avalanche-meld-mainnet";
2642
+ ChainName["GUNZILLA_TESTNET"] = "gunzilla-testnet";
2643
+ ChainName["ULTRON_MAINNET"] = "ultron-mainnet";
2644
+ ChainName["ULTRON_TESTNET"] = "ultron-testnet";
2645
+ ChainName["ZORA_MAINNET"] = "zora-mainnet";
2646
+ ChainName["ZORA_SEPOLIA_TESTNET"] = "zora-sepolia-testnet";
2647
+ ChainName["LISK_SEPOLIA_TESTNET"] = "lisk-sepolia-testnet";
2648
+ ChainName["OPSIDE_READON_CONTENT_TESTNET"] = "opside-readon-content-testnet";
2649
+ ChainName["ZKSYNC_MAINNET"] = "zksync-mainnet";
2650
+ ChainName["ZKSYNC_SEPOLIA_TESTNET"] = "zksync-sepolia-testnet";
2651
+ ChainName["BNB_ANTIMATTER_TESTNET"] = "bnb-antimatter-testnet";
2652
+ ChainName["BNB_META_APES_MAINNET"] = "bnb-meta-apes-mainnet";
2653
+ ChainName["BNB_FNCY_MAINNET"] = "bnb-fncy-mainnet";
2654
+ ChainName["BNB_OPBNB_TESTNET"] = "bnb-opbnb-testnet";
2655
+ ChainName["BNB_FNCY_TESTNET"] = "bnb-fncy-testnet";
2656
+ ChainName["BNB_OPBNB_MAINNET"] = "bnb-opbnb-mainnet";
2657
+ ChainName["ZETACHAIN_TESTNET"] = "zetachain-testnet";
2658
+ ChainName["ZETACHAIN_MAINNET"] = "zetachain-mainnet";
2659
+ ChainName["MODE_TESTNET"] = "mode-testnet";
2660
+ ChainName["MODE_MAINNET"] = "mode-mainnet";
2661
+ ChainName["KINTO_TESTNET"] = "kinto-testnet";
2662
+ ChainName["LOOT_MAINNET"] = "loot-mainnet";
2663
+ ChainName["PGN_MAINNET"] = "pgn-mainnet";
2664
+ ChainName["PGN_TESTNET"] = "pgn-testnet";
2665
+ ChainName["MANTA_SEPOLIA_TESTNET"] = "manta-sepolia-testnet";
2666
+ ChainName["ROLLUX_MAINNET"] = "rollux-mainnet";
2667
+ ChainName["ROLLUX_TESTNET"] = "rollux-testnet";
2668
+ ChainName["GNOSIS_MAINNET"] = "gnosis-mainnet";
2669
+ ChainName["GNOSIS_TESTNET"] = "gnosis-testnet";
2670
+ ChainName["TELOS_MAINNET"] = "telos-mainnet";
2671
+ ChainName["TELOS_TESTNET"] = "telos-testnet";
2672
+ ChainName["TOMOCHAIN_MAINNET"] = "tomochain-mainnet";
2673
+ ChainName["TOMOCHAIN_TESTNET"] = "tomochain-testnet";
2674
+ ChainName["TAIKO_MAINNET"] = "taiko-mainnet";
2675
+ ChainName["TAIKO_HEKLA_TESTNET"] = "taiko-hekla-testnet";
2676
+ ChainName["MERLIN_MAINNET"] = "merlin-mainnet";
2677
+ ChainName["MERLIN_TESTNET"] = "merlin-testnet";
2678
+ ChainName["BLAST_MAINNET"] = "blast-mainnet";
2679
+ ChainName["MOVEMENT_MEVM_TESTNET"] = "movement-mevm-testnet";
2680
+ ChainName["SCROLL_MAINNET"] = "scroll-mainnet";
2681
+ ChainName["COVALENT_INTERNAL_NETWORK_V1"] = "covalent-internal-network-v1";
2682
+ })(ChainName || (ChainName = {}));
2683
+ var ChainID;
2684
+ (function (ChainID) {
2685
+ ChainID[ChainID["ETH_MAINNET"] = 1] = "ETH_MAINNET";
2686
+ ChainID[ChainID["ETH_GOERLI"] = 5] = "ETH_GOERLI";
2687
+ ChainID[ChainID["ETH_SEPOLIA"] = 11155111] = "ETH_SEPOLIA";
2688
+ ChainID[ChainID["ETH_HOLESKY"] = 17000] = "ETH_HOLESKY";
2689
+ ChainID[ChainID["MATIC_MAINNET"] = 137] = "MATIC_MAINNET";
2690
+ ChainID[ChainID["MATIC_MUMBAI"] = 80001] = "MATIC_MUMBAI";
2691
+ ChainID[ChainID["AVALANCHE_MAINNET"] = 43114] = "AVALANCHE_MAINNET";
2692
+ ChainID[ChainID["AVALANCHE_TESTNET"] = 43113] = "AVALANCHE_TESTNET";
2693
+ ChainID[ChainID["BSC_MAINNET"] = 56] = "BSC_MAINNET";
2694
+ ChainID[ChainID["BSC_TESTNET"] = 97] = "BSC_TESTNET";
2695
+ ChainID[ChainID["MOONBEAM_MAINNET"] = 1284] = "MOONBEAM_MAINNET";
2696
+ ChainID[ChainID["MOONBEAM_MOONBASE_ALPHA"] = 1287] = "MOONBEAM_MOONBASE_ALPHA";
2697
+ ChainID[ChainID["MOONBEAM_MOONRIVER"] = 1285] = "MOONBEAM_MOONRIVER";
2698
+ ChainID[ChainID["RSK_MAINNET"] = 30] = "RSK_MAINNET";
2699
+ ChainID[ChainID["RSK_TESTNET"] = 31] = "RSK_TESTNET";
2700
+ ChainID[ChainID["ARBITRUM_MAINNET"] = 42161] = "ARBITRUM_MAINNET";
2701
+ ChainID[ChainID["ARBITRUM_NOVA_MAINNET"] = 42170] = "ARBITRUM_NOVA_MAINNET";
2702
+ ChainID[ChainID["ARBITRUM_SEPOLIA"] = 421614] = "ARBITRUM_SEPOLIA";
2703
+ ChainID[ChainID["FANTOM_MAINNET"] = 250] = "FANTOM_MAINNET";
2704
+ ChainID[ChainID["FANTOM_TESTNET"] = 4002] = "FANTOM_TESTNET";
2705
+ ChainID[ChainID["PALM_MAINNET"] = 11297108109] = "PALM_MAINNET";
2706
+ ChainID[ChainID["PALM_TESTNET"] = 11297108099] = "PALM_TESTNET";
2707
+ ChainID[ChainID["BTC_MAINNET"] = 20090103] = "BTC_MAINNET";
2708
+ ChainID[ChainID["SOLANA_MAINNET"] = 1399811149] = "SOLANA_MAINNET";
2709
+ ChainID[ChainID["AXIE_MAINNET"] = 2020] = "AXIE_MAINNET";
2710
+ ChainID[ChainID["OPTIMISM_MAINNET"] = 10] = "OPTIMISM_MAINNET";
2711
+ ChainID[ChainID["OPTIMISM_SEPOLIA"] = 11155420] = "OPTIMISM_SEPOLIA";
2712
+ ChainID[ChainID["EVMOS_MAINNET"] = 9001] = "EVMOS_MAINNET";
2713
+ ChainID[ChainID["EVMOS_TESTNET"] = 9000] = "EVMOS_TESTNET";
2714
+ ChainID[ChainID["HARMONY_MAINNET"] = 1666600000] = "HARMONY_MAINNET";
2715
+ ChainID[ChainID["HARMONY_TESTNET"] = 1666700000] = "HARMONY_TESTNET";
2716
+ ChainID[ChainID["CRONOS_MAINNET"] = 25] = "CRONOS_MAINNET";
2717
+ ChainID[ChainID["CRONOS_TESTNET"] = 338] = "CRONOS_TESTNET";
2718
+ ChainID[ChainID["CRONOS_ZKEVM_TESTNET"] = 282] = "CRONOS_ZKEVM_TESTNET";
2719
+ ChainID[ChainID["AURORA_MAINNET"] = 1313161554] = "AURORA_MAINNET";
2720
+ ChainID[ChainID["AURORA_TESTNET"] = 1313161555] = "AURORA_TESTNET";
2721
+ ChainID[ChainID["EMERALD_PARATIME_MAINNET"] = 42262] = "EMERALD_PARATIME_MAINNET";
2722
+ ChainID[ChainID["DEFI_KINGDOMS_MAINNET"] = 53935] = "DEFI_KINGDOMS_MAINNET";
2723
+ ChainID[ChainID["DEFI_KINGDOMS_TESTNET"] = 335] = "DEFI_KINGDOMS_TESTNET";
2724
+ ChainID[ChainID["BOBA_MAINNET"] = 288] = "BOBA_MAINNET";
2725
+ ChainID[ChainID["BOBA_BNB_MAINNET"] = 56288] = "BOBA_BNB_MAINNET";
2726
+ ChainID[ChainID["BOBA_BNB_TESTNET"] = 9728] = "BOBA_BNB_TESTNET";
2727
+ ChainID[ChainID["SCROLL_SEPOLIA_TESTNET"] = 534351] = "SCROLL_SEPOLIA_TESTNET";
2728
+ ChainID[ChainID["METIS_MAINNET"] = 1088] = "METIS_MAINNET";
2729
+ ChainID[ChainID["METIS_STARDUST"] = 588] = "METIS_STARDUST";
2730
+ ChainID[ChainID["AVALANCHE_DEXALOT_MAINNET"] = 432204] = "AVALANCHE_DEXALOT_MAINNET";
2731
+ ChainID[ChainID["AVALANCHE_DEXALOT_TESTNET"] = 432201] = "AVALANCHE_DEXALOT_TESTNET";
2732
+ ChainID[ChainID["AVALANCHE_SHRAPNEL_MAINNET"] = 2044] = "AVALANCHE_SHRAPNEL_MAINNET";
2733
+ ChainID[ChainID["AVALANCHE_NUMBERS"] = 10507] = "AVALANCHE_NUMBERS";
2734
+ ChainID[ChainID["AVALANCHE_DOS"] = 7979] = "AVALANCHE_DOS";
2735
+ ChainID[ChainID["AVALANCHE_XPLUS"] = 1228] = "AVALANCHE_XPLUS";
2736
+ ChainID[ChainID["AVALANCHE_XANACHAIN"] = 8888] = "AVALANCHE_XANACHAIN";
2737
+ ChainID[ChainID["AVALANCHE_STEP_NETWORK"] = 1234] = "AVALANCHE_STEP_NETWORK";
2738
+ ChainID[ChainID["AVALANCHE_SHRAPNEL_TESTNET"] = 2038] = "AVALANCHE_SHRAPNEL_TESTNET";
2739
+ ChainID[ChainID["AVALANCHE_BEAM_TESTNET"] = 13337] = "AVALANCHE_BEAM_TESTNET";
2740
+ ChainID[ChainID["AVALANCHE_BLITZ_TESTNET"] = 1343] = "AVALANCHE_BLITZ_TESTNET";
2741
+ ChainID[ChainID["AVALANCHE_MINTARA_TESTNET"] = 1079] = "AVALANCHE_MINTARA_TESTNET";
2742
+ ChainID[ChainID["AVALANCHE_GREEN_DOT_TESTNET"] = 6765897100] = "AVALANCHE_GREEN_DOT_TESTNET";
2743
+ ChainID[ChainID["AVALANCHE_PULSAR_TESTNET"] = 431234] = "AVALANCHE_PULSAR_TESTNET";
2744
+ ChainID[ChainID["AVALANCHE_UPTN"] = 6119] = "AVALANCHE_UPTN";
2745
+ ChainID[ChainID["AVALANCHE_AVACLOUD_TESTNET"] = 152703] = "AVALANCHE_AVACLOUD_TESTNET";
2746
+ ChainID[ChainID["AVALANCHE_BEAM_MAINNET"] = 4337] = "AVALANCHE_BEAM_MAINNET";
2747
+ ChainID[ChainID["AVALANCHE_BULLETIN_TESTNET"] = 78431] = "AVALANCHE_BULLETIN_TESTNET";
2748
+ ChainID[ChainID["AVALANCHE_CONDUIT_TESTNET"] = 78432] = "AVALANCHE_CONDUIT_TESTNET";
2749
+ ChainID[ChainID["AVALANCHE_HERO_TESTNET"] = 17772] = "AVALANCHE_HERO_TESTNET";
2750
+ ChainID[ChainID["AVALANCHE_HUBBLE_EXCHANGE_TESTNET"] = 321123] = "AVALANCHE_HUBBLE_EXCHANGE_TESTNET";
2751
+ ChainID[ChainID["AVALANCHE_KIWI_TESTNET"] = 2037] = "AVALANCHE_KIWI_TESTNET";
2752
+ ChainID[ChainID["AVALANCHE_MIHO_TESTNET"] = 360163] = "AVALANCHE_MIHO_TESTNET";
2753
+ ChainID[ChainID["AVALANCHE_MONDRIAN_TESTNET"] = 179188] = "AVALANCHE_MONDRIAN_TESTNET";
2754
+ ChainID[ChainID["AVALANCHE_NMAC_TESTNET"] = 7777] = "AVALANCHE_NMAC_TESTNET";
2755
+ ChainID[ChainID["AVALANCHE_ORDERLY_TESTNET"] = 986532] = "AVALANCHE_ORDERLY_TESTNET";
2756
+ ChainID[ChainID["AVALANCHE_THIRDWEB_TESTNET"] = 894538] = "AVALANCHE_THIRDWEB_TESTNET";
2757
+ ChainID[ChainID["AVALANCHE_WAGMI_TESTNET"] = 11111] = "AVALANCHE_WAGMI_TESTNET";
2758
+ ChainID[ChainID["AVALANCHE_PLAYA3ULL_TESTNET"] = 3012] = "AVALANCHE_PLAYA3ULL_TESTNET";
2759
+ ChainID[ChainID["AVALANCHE_MIRAI_TESTNET"] = 2195] = "AVALANCHE_MIRAI_TESTNET";
2760
+ ChainID[ChainID["AVALANCHE_AMPLIFY_TESTNET"] = 78430] = "AVALANCHE_AMPLIFY_TESTNET";
2761
+ ChainID[ChainID["AVALANCHE_LT0_TESTNET"] = 31330] = "AVALANCHE_LT0_TESTNET";
2762
+ ChainID[ChainID["AVALANCHE_LT5_TESTNET"] = 31335] = "AVALANCHE_LT5_TESTNET";
2763
+ ChainID[ChainID["AVALANCHE_HUBBLE_EXCHANGE_MAINNET"] = 1992] = "AVALANCHE_HUBBLE_EXCHANGE_MAINNET";
2764
+ ChainID[ChainID["METER_MAINNET"] = 82] = "METER_MAINNET";
2765
+ ChainID[ChainID["METER_TESTNET"] = 83] = "METER_TESTNET";
2766
+ ChainID[ChainID["MILKOMEDA_A1_MAINNET"] = 2002] = "MILKOMEDA_A1_MAINNET";
2767
+ ChainID[ChainID["MILKOMEDA_C1_MAINNET"] = 2001] = "MILKOMEDA_C1_MAINNET";
2768
+ ChainID[ChainID["MILKOMEDA_C1_DEVNET"] = 200101] = "MILKOMEDA_C1_DEVNET";
2769
+ ChainID[ChainID["CANTO_MAINNET"] = 7700] = "CANTO_MAINNET";
2770
+ ChainID[ChainID["FLARENETWORKS_FLARE_MAINNET"] = 14] = "FLARENETWORKS_FLARE_MAINNET";
2771
+ ChainID[ChainID["FLARENETWORKS_FLARE_TESTNET"] = 114] = "FLARENETWORKS_FLARE_TESTNET";
2772
+ ChainID[ChainID["FLARENETWORKS_CANARY_MAINNET"] = 19] = "FLARENETWORKS_CANARY_MAINNET";
2773
+ ChainID[ChainID["FLARENETWORKS_CANARY_TESTNET"] = 16] = "FLARENETWORKS_CANARY_TESTNET";
2774
+ ChainID[ChainID["KCC_MAINNET"] = 321] = "KCC_MAINNET";
2775
+ ChainID[ChainID["KCC_TESTNET"] = 322] = "KCC_TESTNET";
2776
+ ChainID[ChainID["LINEA_MAINNET"] = 59144] = "LINEA_MAINNET";
2777
+ ChainID[ChainID["POLYGON_ZKEVM_MAINNET"] = 1101] = "POLYGON_ZKEVM_MAINNET";
2778
+ ChainID[ChainID["LINEA_SEPOLIA_TESTNET"] = 59141] = "LINEA_SEPOLIA_TESTNET";
2779
+ ChainID[ChainID["LINEA_GOERLI_TESTNET"] = 59140] = "LINEA_GOERLI_TESTNET";
2780
+ ChainID[ChainID["POLYGON_ZKEVM_TESTNET"] = 1422] = "POLYGON_ZKEVM_TESTNET";
2781
+ ChainID[ChainID["POLYGON_AMOY_TESTNET"] = 80002] = "POLYGON_AMOY_TESTNET";
2782
+ ChainID[ChainID["MANTLE_MAINNET"] = 5000] = "MANTLE_MAINNET";
2783
+ ChainID[ChainID["MANTLE_SEPOLIA_TESTNET"] = 5003] = "MANTLE_SEPOLIA_TESTNET";
2784
+ ChainID[ChainID["POLYGON_ZKEVM_CARDONA_TESTNET"] = 2442] = "POLYGON_ZKEVM_CARDONA_TESTNET";
2785
+ ChainID[ChainID["BASE_MAINNET"] = 8453] = "BASE_MAINNET";
2786
+ ChainID[ChainID["BASE_TESTNET"] = 84531] = "BASE_TESTNET";
2787
+ ChainID[ChainID["BASE_SEPOLIA_TESTNET"] = 84532] = "BASE_SEPOLIA_TESTNET";
2788
+ ChainID[ChainID["OASYS_MAINNET"] = 248] = "OASYS_MAINNET";
2789
+ ChainID[ChainID["OASYS_TESTNET"] = 9372] = "OASYS_TESTNET";
2790
+ ChainID[ChainID["SX_MAINNET"] = 416] = "SX_MAINNET";
2791
+ ChainID[ChainID["LUMOZ_PUBLIC_ZKSYNC_V2"] = 12027] = "LUMOZ_PUBLIC_ZKSYNC_V2";
2792
+ ChainID[ChainID["LUMOZ_STARK_SPORT"] = 12029] = "LUMOZ_STARK_SPORT";
2793
+ ChainID[ChainID["OASIS_SAPPHIRE_MAINNET"] = 23294] = "OASIS_SAPPHIRE_MAINNET";
2794
+ ChainID[ChainID["OASIS_SAPPHIRE_TESTNET"] = 23295] = "OASIS_SAPPHIRE_TESTNET";
2795
+ ChainID[ChainID["SYNDR_TESTNET"] = 412346] = "SYNDR_TESTNET";
2796
+ ChainID[ChainID["XAI_MAINNET"] = 660279] = "XAI_MAINNET";
2797
+ ChainID[ChainID["CELO_MAINNET"] = 42220] = "CELO_MAINNET";
2798
+ ChainID[ChainID["X1_MAINNET"] = 196] = "X1_MAINNET";
2799
+ ChainID[ChainID["CROSSFI_EVM_TESTNET"] = 8545] = "CROSSFI_EVM_TESTNET";
2800
+ ChainID[ChainID["HORIZEN_EON_MAINNET"] = 7332] = "HORIZEN_EON_MAINNET";
2801
+ ChainID[ChainID["HORIZEN_GOBI_TESTNET"] = 1663] = "HORIZEN_GOBI_TESTNET";
2802
+ ChainID[ChainID["FRAXTAL_MAINNET"] = 252] = "FRAXTAL_MAINNET";
2803
+ ChainID[ChainID["APECHAIN_TESTNET"] = 1798] = "APECHAIN_TESTNET";
2804
+ ChainID[ChainID["LISK_MAINNET"] = 1135] = "LISK_MAINNET";
2805
+ ChainID[ChainID["REDSTONE_MAINNET"] = 690] = "REDSTONE_MAINNET";
2806
+ ChainID[ChainID["SEI_MAINNET"] = 1329] = "SEI_MAINNET";
2807
+ ChainID[ChainID["AVALANCHE_MELD_TESTNET"] = 222000222] = "AVALANCHE_MELD_TESTNET";
2808
+ ChainID[ChainID["AVALANCHE_MELD_MAINNET"] = 333000333] = "AVALANCHE_MELD_MAINNET";
2809
+ ChainID[ChainID["GUNZILLA_TESTNET"] = 49321] = "GUNZILLA_TESTNET";
2810
+ ChainID[ChainID["ULTRON_MAINNET"] = 1231] = "ULTRON_MAINNET";
2811
+ ChainID[ChainID["ULTRON_TESTNET"] = 1230] = "ULTRON_TESTNET";
2812
+ ChainID[ChainID["ZORA_MAINNET"] = 7777777] = "ZORA_MAINNET";
2813
+ ChainID[ChainID["ZORA_SEPOLIA_TESTNET"] = 999999999] = "ZORA_SEPOLIA_TESTNET";
2814
+ ChainID[ChainID["LISK_SEPOLIA_TESTNET"] = 4202] = "LISK_SEPOLIA_TESTNET";
2815
+ ChainID[ChainID["OPSIDE_READON_CONTENT_TESTNET"] = 12015] = "OPSIDE_READON_CONTENT_TESTNET";
2816
+ ChainID[ChainID["ZKSYNC_MAINNET"] = 324] = "ZKSYNC_MAINNET";
2817
+ ChainID[ChainID["ZKSYNC_SEPOLIA_TESTNET"] = 300] = "ZKSYNC_SEPOLIA_TESTNET";
2818
+ ChainID[ChainID["BNB_ANTIMATTER_TESTNET"] = 20221] = "BNB_ANTIMATTER_TESTNET";
2819
+ ChainID[ChainID["BNB_META_APES_MAINNET"] = 16350] = "BNB_META_APES_MAINNET";
2820
+ ChainID[ChainID["BNB_FNCY_MAINNET"] = 73] = "BNB_FNCY_MAINNET";
2821
+ ChainID[ChainID["BNB_OPBNB_TESTNET"] = 5611] = "BNB_OPBNB_TESTNET";
2822
+ ChainID[ChainID["BNB_FNCY_TESTNET"] = 923018] = "BNB_FNCY_TESTNET";
2823
+ ChainID[ChainID["BNB_OPBNB_MAINNET"] = 204] = "BNB_OPBNB_MAINNET";
2824
+ ChainID[ChainID["ZETACHAIN_TESTNET"] = 7001] = "ZETACHAIN_TESTNET";
2825
+ ChainID[ChainID["ZETACHAIN_MAINNET"] = 7000] = "ZETACHAIN_MAINNET";
2826
+ ChainID[ChainID["MODE_TESTNET"] = 919] = "MODE_TESTNET";
2827
+ ChainID[ChainID["MODE_MAINNET"] = 34443] = "MODE_MAINNET";
2828
+ ChainID[ChainID["KINTO_TESTNET"] = 42888] = "KINTO_TESTNET";
2829
+ ChainID[ChainID["LOOT_MAINNET"] = 5151706] = "LOOT_MAINNET";
2830
+ ChainID[ChainID["PGN_MAINNET"] = 424] = "PGN_MAINNET";
2831
+ ChainID[ChainID["PGN_TESTNET"] = 58008] = "PGN_TESTNET";
2832
+ ChainID[ChainID["MANTA_SEPOLIA_TESTNET"] = 3441006] = "MANTA_SEPOLIA_TESTNET";
2833
+ ChainID[ChainID["ROLLUX_MAINNET"] = 570] = "ROLLUX_MAINNET";
2834
+ ChainID[ChainID["ROLLUX_TESTNET"] = 57000] = "ROLLUX_TESTNET";
2835
+ ChainID[ChainID["GNOSIS_MAINNET"] = 100] = "GNOSIS_MAINNET";
2836
+ ChainID[ChainID["GNOSIS_TESTNET"] = 10200] = "GNOSIS_TESTNET";
2837
+ ChainID[ChainID["TELOS_MAINNET"] = 40] = "TELOS_MAINNET";
2838
+ ChainID[ChainID["TELOS_TESTNET"] = 41] = "TELOS_TESTNET";
2839
+ ChainID[ChainID["TOMOCHAIN_MAINNET"] = 88] = "TOMOCHAIN_MAINNET";
2840
+ ChainID[ChainID["TOMOCHAIN_TESTNET"] = 89] = "TOMOCHAIN_TESTNET";
2841
+ ChainID[ChainID["TAIKO_MAINNET"] = 167000] = "TAIKO_MAINNET";
2842
+ ChainID[ChainID["TAIKO_HEKLA_TESTNET"] = 167009] = "TAIKO_HEKLA_TESTNET";
2843
+ ChainID[ChainID["MERLIN_MAINNET"] = 4200] = "MERLIN_MAINNET";
2844
+ ChainID[ChainID["MERLIN_TESTNET"] = 686868] = "MERLIN_TESTNET";
2845
+ ChainID[ChainID["BLAST_MAINNET"] = 81457] = "BLAST_MAINNET";
2846
+ ChainID[ChainID["MOVEMENT_MEVM_TESTNET"] = 336] = "MOVEMENT_MEVM_TESTNET";
2847
+ ChainID[ChainID["SCROLL_MAINNET"] = 534352] = "SCROLL_MAINNET";
2848
+ ChainID[ChainID["COVALENT_INTERNAL_NETWORK_V1"] = 1131378225] = "COVALENT_INTERNAL_NETWORK_V1";
2849
+ })(ChainID || (ChainID = {}));
2850
+ class GoldRushResponse {
2851
+ }
2852
+
2853
+ export { ChainID, ChainName, GoldRushClient as CovalentClient, GoldRushClient, GoldRushResponse, bigIntParser, calculatePrettyBalance, isValidApiKey, prettifyCurrency };
2854
+ //# sourceMappingURL=index.js.map