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