@covalenthq/client-sdk 2.3.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "2.3.7";
3
+ var version = "3.0.0";
4
4
 
5
5
  const bigIntParser = (val) => {
6
6
  if (val === null || val === undefined) {
@@ -32,6 +32,7 @@ const endpointGenerator = (extension = "", params = []) => {
32
32
  *
33
33
  */
34
34
  class AllChainsService {
35
+ execution;
35
36
  constructor(execution) {
36
37
  this.execution = execution;
37
38
  }
@@ -39,6 +40,8 @@ class AllChainsService {
39
40
  *
40
41
  * Commonly used to locate chains which an address is active on with a single API call.
41
42
  *
43
+ * **Credit Cost**: 0.5 per call
44
+ *
42
45
  * @param {string} walletAddress - The requested wallet address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
43
46
  * @param {GetAddressActivityQueryParamOpts} queryParamOpts
44
47
  * - `testnets`: Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity.
@@ -147,24 +150,10 @@ class AllChainsService {
147
150
  return await this.execution.execute(endpoint, parseData);
148
151
  }
149
152
  /**
150
- * @deprecated This method is deprecated and will be removed in the upcoming versions. Please use `AllChainsService.getMultiChainMultiAddressTransactions` instead.
151
- *
152
- * Commonly used to get transactions cross chains and addresses.
153
153
  *
154
- * @param {Chain[]} chains - An array of the chain names or IDs to retrieve transactions from. Defaults to all foundational chains.
155
- * @param {string[]} addresses - An array of addresses for which transactions are fetched. Does not support name resolution.
156
- * @param {number} limit - Number of transactions to return per page, up to the default max of 100 items.
157
- * @param {string} before - Pagination cursor pointing to fetch transactions before a certain point.
158
- * @param {string} after - Pagination cursor pointing to fetch transactions after a certain point.
159
- * @param {boolean} withLogs - Whether to include raw logs in the response.
160
- * @param {boolean} withDecodedLogs - Whether to include decoded logs in the response.
161
- * @param {Quote | CryptocurrencyQuote} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, `BTC` and `ETH`.
154
+ * Fetch paginated spot & historical native and token balances for a single address on up to 10 EVM chains with one API call.
162
155
  *
163
- */
164
- async getMultiChainAndMultiAddressTransactions(queryParamOpts) {
165
- return await this.getMultiChainMultiAddressTransactions(queryParamOpts);
166
- }
167
- /**
156
+ * **Credit Cost**: 2.5 per call
168
157
  *
169
158
  * @param {string} walletAddress - The requested wallet Address.
170
159
  * @param {GetMultiChainBalanceQueryParamOpts} queryParamOpts
@@ -253,12 +242,13 @@ async function* paginateEndpoint(endpoint, execution, parseData, implementation)
253
242
  }
254
243
  catch (error) {
255
244
  hasMore = false;
245
+ const err = error;
256
246
  yield {
257
247
  data: null,
258
248
  error: true,
259
- error_code: error?.cause?.code || error?.error_code || 500,
260
- error_message: error?.cause?.message ||
261
- error?.error_message ||
249
+ error_code: err?.cause?.code || err?.error_code || 500,
250
+ error_message: err?.cause?.message ||
251
+ err?.error_message ||
262
252
  "Internal server error",
263
253
  };
264
254
  }
@@ -270,21 +260,21 @@ async function* paginateEndpoint(endpoint, execution, parseData, implementation)
270
260
  *
271
261
  */
272
262
  class BalanceService {
263
+ execution;
273
264
  constructor(execution) {
274
265
  this.execution = execution;
275
266
  }
276
267
  /**
277
268
  *
278
- * 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.
269
+ * Commonly used to fetch the native and fungible (ERC20) tokens held by an address. Response includes spot prices and other metadata.
270
+ *
271
+ * **Credit Cost**: 1 per call
279
272
  *
280
273
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
281
274
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
282
275
  * @param {GetTokenBalancesForWalletAddressQueryParamOpts} queryParamOpts
283
276
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
284
- * - `nft`: If `true`, NFTs will be included in the response.
285
- * - `noNftFetch`: If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
286
277
  * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
287
- * - `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.
288
278
  *
289
279
  */
290
280
  async getTokenBalancesForWalletAddress(chainName, walletAddress, queryParamOpts) {
@@ -293,22 +283,10 @@ class BalanceService {
293
283
  key: "quote-currency",
294
284
  value: queryParamOpts?.quoteCurrency,
295
285
  },
296
- {
297
- key: "nft",
298
- value: queryParamOpts?.nft,
299
- },
300
- {
301
- key: "no-nft-fetch",
302
- value: queryParamOpts?.noNftFetch,
303
- },
304
286
  {
305
287
  key: "no-spam",
306
288
  value: queryParamOpts?.noSpam,
307
289
  },
308
- {
309
- key: "no-nft-asset-metadata",
310
- value: queryParamOpts?.noNftAssetMetadata,
311
- },
312
290
  ]);
313
291
  const parseData = (data) => {
314
292
  if (data.data) {
@@ -342,6 +320,8 @@ class BalanceService {
342
320
  *
343
321
  * 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.
344
322
  *
323
+ * **Credit Cost**: 2 per 30 days
324
+ *
345
325
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
346
326
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
347
327
  * @param {GetHistoricalPortfolioForWalletAddressQueryParamOpts} queryParamOpts
@@ -400,6 +380,8 @@ class BalanceService {
400
380
  *
401
381
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
402
382
  *
383
+ * **Credit Cost**: 0.05 per item
384
+ *
403
385
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
404
386
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
405
387
  * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
@@ -474,6 +456,8 @@ class BalanceService {
474
456
  *
475
457
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
476
458
  *
459
+ * **Credit Cost**: 0.05 per item
460
+ *
477
461
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
478
462
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
479
463
  * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
@@ -542,11 +526,14 @@ class BalanceService {
542
526
  }
543
527
  /**
544
528
  *
545
- * 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.
529
+ * Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token.
530
+ *
531
+ * **Credit Cost**: 0.02 per item
546
532
  *
547
533
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
548
534
  * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
549
535
  * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
536
+ * - `noSnapshot`: Defaults to `false`. Set to `true` to bypass last snapshot and get the latest token holders list.
550
537
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
551
538
  * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
552
539
  * - `pageNumber`: 0-indexed page number to begin pagination.
@@ -555,6 +542,10 @@ class BalanceService {
555
542
  */
556
543
  async *getTokenHoldersV2ForTokenAddress(chainName, tokenAddress, queryParamOpts) {
557
544
  const endpoint = endpointGenerator(`${chainName}/tokens/${tokenAddress}/token_holders_v2`, [
545
+ {
546
+ key: "no-snapshot",
547
+ value: queryParamOpts?.noSnapshot,
548
+ },
558
549
  {
559
550
  key: "block-height",
560
551
  value: queryParamOpts?.blockHeight,
@@ -593,11 +584,14 @@ class BalanceService {
593
584
  }
594
585
  /**
595
586
  *
596
- * 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.
587
+ * Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token.
588
+ *
589
+ * **Credit Cost**: 0.02 per item
597
590
  *
598
591
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
599
592
  * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
600
593
  * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
594
+ * - `noSnapshot`: Defaults to `false`. Set to `true` to bypass last snapshot and get the latest token holders list.
601
595
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
602
596
  * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
603
597
  * - `pageNumber`: 0-indexed page number to begin pagination.
@@ -606,6 +600,10 @@ class BalanceService {
606
600
  */
607
601
  async getTokenHoldersV2ForTokenAddressByPage(chainName, tokenAddress, queryParamOpts) {
608
602
  const endpoint = endpointGenerator(`${chainName}/tokens/${tokenAddress}/token_holders_v2`, [
603
+ {
604
+ key: "no-snapshot",
605
+ value: queryParamOpts?.noSnapshot,
606
+ },
609
607
  {
610
608
  key: "block-height",
611
609
  value: queryParamOpts?.blockHeight,
@@ -642,16 +640,15 @@ class BalanceService {
642
640
  }
643
641
  /**
644
642
  *
645
- * 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.
643
+ * Commonly used to fetch the historical native and fungible (ERC20) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
644
+ *
645
+ * **Credit Cost**: 1 per call
646
646
  *
647
647
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
648
648
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
649
649
  * @param {GetHistoricalTokenBalancesForWalletAddressQueryParamOpts} queryParamOpts
650
650
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
651
- * - `nft`: If `true`, NFTs will be included in the response.
652
- * - `noNftFetch`: If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
653
651
  * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
654
- * - `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.
655
652
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
656
653
  * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
657
654
  *
@@ -662,22 +659,10 @@ class BalanceService {
662
659
  key: "quote-currency",
663
660
  value: queryParamOpts?.quoteCurrency,
664
661
  },
665
- {
666
- key: "nft",
667
- value: queryParamOpts?.nft,
668
- },
669
- {
670
- key: "no-nft-fetch",
671
- value: queryParamOpts?.noNftFetch,
672
- },
673
662
  {
674
663
  key: "no-spam",
675
664
  value: queryParamOpts?.noSpam,
676
665
  },
677
- {
678
- key: "no-nft-asset-metadata",
679
- value: queryParamOpts?.noNftAssetMetadata,
680
- },
681
666
  {
682
667
  key: "block-height",
683
668
  value: queryParamOpts?.blockHeight,
@@ -715,6 +700,10 @@ class BalanceService {
715
700
  return await this.execution.execute(endpoint, parseData);
716
701
  }
717
702
  /**
703
+ *
704
+ * Lightweight endpoint to just get the native token balance for an EVM address.
705
+ *
706
+ * **Credit Cost**: 0.5 per call
718
707
  *
719
708
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
720
709
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -757,6 +746,7 @@ class BalanceService {
757
746
  *
758
747
  */
759
748
  class BaseService {
749
+ execution;
760
750
  constructor(execution) {
761
751
  this.execution = execution;
762
752
  }
@@ -764,6 +754,8 @@ class BaseService {
764
754
  *
765
755
  * Commonly used to fetch and render a single block for a block explorer.
766
756
  *
757
+ * **Credit Cost**: 1 per call
758
+ *
767
759
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
768
760
  * @param {string} blockHeight - The block height or `latest` for the latest block available.
769
761
  *
@@ -790,7 +782,9 @@ class BaseService {
790
782
  }
791
783
  /**
792
784
  *
793
- * Commonly used to resolve ENS, RNS and Unstoppable Domains addresses.
785
+ * Commonly used to resolve ENS, RNS and Unstoppable Domains addresses. Only supports the resolution of a registered domain to an address.
786
+ *
787
+ * **Credit Cost**: 1 per call
794
788
  *
795
789
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
796
790
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -807,6 +801,8 @@ class BaseService {
807
801
  *
808
802
  * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
809
803
  *
804
+ * **Credit Cost**: 1 per call
805
+ *
810
806
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
811
807
  * @param {string} startDate - The start date in YYYY-MM-DD format.
812
808
  * @param {string | "latest"} endDate - The end date in YYYY-MM-DD format. Also accepts "latest" for the latest block height
@@ -850,6 +846,8 @@ class BaseService {
850
846
  *
851
847
  * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
852
848
  *
849
+ * **Credit Cost**: 1 per call
850
+ *
853
851
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
854
852
  * @param {string} startDate - The start date in YYYY-MM-DD format.
855
853
  * @param {string | "latest"} endDate - The end date in YYYY-MM-DD format. Also accepts "latest" for the latest block height
@@ -891,6 +889,8 @@ class BaseService {
891
889
  *
892
890
  * 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.
893
891
  *
892
+ * **Credit Cost**: 0.01 per item
893
+ *
894
894
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
895
895
  * @param {GetLogsQueryParamOpts} queryParamOpts
896
896
  * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
@@ -950,6 +950,8 @@ class BaseService {
950
950
  *
951
951
  * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
952
952
  *
953
+ * **Credit Cost**: 0.01 per item
954
+ *
953
955
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
954
956
  * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
955
957
  * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
@@ -1002,6 +1004,8 @@ class BaseService {
1002
1004
  *
1003
1005
  * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
1004
1006
  *
1007
+ * **Credit Cost**: 0.01 per item
1008
+ *
1005
1009
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1006
1010
  * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1007
1011
  * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
@@ -1052,6 +1056,8 @@ class BaseService {
1052
1056
  *
1053
1057
  * 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.
1054
1058
  *
1059
+ * **Credit Cost**: 0.01 per item
1060
+ *
1055
1061
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1056
1062
  * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
1057
1063
  * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
@@ -1109,6 +1115,8 @@ class BaseService {
1109
1115
  *
1110
1116
  * 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.
1111
1117
  *
1118
+ * **Credit Cost**: 0.01 per item
1119
+ *
1112
1120
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1113
1121
  * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
1114
1122
  * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
@@ -1164,6 +1172,7 @@ class BaseService {
1164
1172
  *
1165
1173
  * Commonly used to build internal dashboards for all supported chains on Covalent.
1166
1174
  *
1175
+ * **Credit Cost**: 0.01 per call
1167
1176
  *
1168
1177
  */
1169
1178
  async getAllChains() {
@@ -1176,7 +1185,9 @@ class BaseService {
1176
1185
  data.data.items = data.data.items
1177
1186
  ? data.data.items.map((chainItem) => ({
1178
1187
  ...chainItem,
1179
- chain_id: chainItem.chain_id ? +chainItem.chain_id : null,
1188
+ chain_id: chainItem.chain_id
1189
+ ? +chainItem.chain_id
1190
+ : null,
1180
1191
  }))
1181
1192
  : null;
1182
1193
  }
@@ -1188,6 +1199,7 @@ class BaseService {
1188
1199
  *
1189
1200
  * Commonly used to build internal status dashboards of all supported chains.
1190
1201
  *
1202
+ * **Credit Cost**: 1 per call
1191
1203
  *
1192
1204
  */
1193
1205
  async getAllChainStatus() {
@@ -1200,7 +1212,9 @@ class BaseService {
1200
1212
  data.data.items = data.data.items
1201
1213
  ? data.data.items.map((chainItem) => ({
1202
1214
  ...chainItem,
1203
- chain_id: chainItem.chain_id ? +chainItem.chain_id : null,
1215
+ chain_id: chainItem.chain_id
1216
+ ? +chainItem.chain_id
1217
+ : null,
1204
1218
  }))
1205
1219
  : null;
1206
1220
  }
@@ -1209,41 +1223,10 @@ class BaseService {
1209
1223
  return await this.execution.execute(endpoint, parseData);
1210
1224
  }
1211
1225
  /**
1212
- * @deprecated This method is deprecated and will be removed in the upcoming versions. Please use `AllChainsService.getAddressActivity` instead.
1213
1226
  *
1214
- * Commonly used to locate chains which an address is active on with a single API call.
1215
- *
1216
- * @param {string} walletAddress - The requested wallet address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1217
- * @param {GetAddressActivityQueryParamOpts} queryParamOpts
1218
- * - `testnets`: Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity.
1227
+ * Get real-time gas estimates for different transaction speeds on a specific network, enabling users to optimize transaction costs and confirmation times.
1219
1228
  *
1220
- */
1221
- async getAddressActivity(walletAddress, queryParamOpts) {
1222
- const endpoint = endpointGenerator(`address/${walletAddress}/activity`, [
1223
- {
1224
- key: "testnets",
1225
- value: queryParamOpts?.testnets,
1226
- },
1227
- ]);
1228
- const parseData = (data) => {
1229
- if (data.data) {
1230
- data.data.updated_at = data.data.updated_at
1231
- ? new Date(data.data.updated_at)
1232
- : null;
1233
- data.data.items = data.data.items
1234
- ? data.data.items.map((activityItem) => ({
1235
- ...activityItem,
1236
- last_seen_at: activityItem.last_seen_at
1237
- ? new Date(activityItem.last_seen_at)
1238
- : null,
1239
- }))
1240
- : null;
1241
- }
1242
- return data;
1243
- };
1244
- return await this.execution.execute(endpoint, parseData);
1245
- }
1246
- /**
1229
+ * **Credit Cost**: 1 per call
1247
1230
  *
1248
1231
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1249
1232
  * @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
@@ -1276,17 +1259,16 @@ exports.ChainName = void 0;
1276
1259
  ChainName["ETH_MAINNET"] = "eth-mainnet";
1277
1260
  ChainName["ETH_SEPOLIA"] = "eth-sepolia";
1278
1261
  ChainName["ETH_HOLESKY"] = "eth-holesky";
1279
- ChainName["ETH_HOODI"] = "eth-hoodi";
1280
1262
  ChainName["MATIC_MAINNET"] = "matic-mainnet";
1281
1263
  ChainName["AVALANCHE_MAINNET"] = "avalanche-mainnet";
1282
1264
  ChainName["AVALANCHE_TESTNET"] = "avalanche-testnet";
1283
1265
  ChainName["BSC_MAINNET"] = "bsc-mainnet";
1284
1266
  ChainName["BSC_TESTNET"] = "bsc-testnet";
1285
1267
  ChainName["MOONBEAM_MAINNET"] = "moonbeam-mainnet";
1286
- ChainName["MOONBEAM_MOONBASE_ALPHA"] = "moonbeam-moonbase-alpha";
1287
1268
  ChainName["MOONBEAM_MOONRIVER"] = "moonbeam-moonriver";
1288
1269
  ChainName["ARBITRUM_MAINNET"] = "arbitrum-mainnet";
1289
1270
  ChainName["ARBITRUM_NOVA_MAINNET"] = "arbitrum-nova-mainnet";
1271
+ ChainName["ARBITRUM_SEPOLIA"] = "arbitrum-sepolia";
1290
1272
  ChainName["FANTOM_MAINNET"] = "fantom-mainnet";
1291
1273
  ChainName["FANTOM_TESTNET"] = "fantom-testnet";
1292
1274
  ChainName["BTC_MAINNET"] = "btc-mainnet";
@@ -1298,17 +1280,22 @@ exports.ChainName = void 0;
1298
1280
  ChainName["EMERALD_PARATIME_MAINNET"] = "emerald-paratime-mainnet";
1299
1281
  ChainName["MONAD_TESTNET"] = "monad-testnet";
1300
1282
  ChainName["MONAD_MAINNET"] = "monad-mainnet";
1283
+ ChainName["MEGAETH_MAINNET"] = "megaeth-mainnet";
1301
1284
  ChainName["BERACHAIN_MAINNET"] = "berachain-mainnet";
1285
+ ChainName["BERACHAIN_TESTNET"] = "berachain-testnet";
1286
+ ChainName["HYPERCORE_MAINNET"] = "hypercore-mainnet";
1302
1287
  ChainName["PLASMA_MAINNET"] = "plasma-mainnet";
1303
1288
  ChainName["UNICHAIN_MAINNET"] = "unichain-mainnet";
1304
1289
  ChainName["PLASMA_TESTNET"] = "plasma-testnet";
1305
1290
  ChainName["ARC_TESTNET"] = "arc-testnet";
1291
+ ChainName["ADI_TESTNET"] = "adi-testnet";
1306
1292
  ChainName["CANTO_MAINNET"] = "canto-mainnet";
1307
1293
  ChainName["LINEA_MAINNET"] = "linea-mainnet";
1308
1294
  ChainName["LINEA_SEPOLIA_TESTNET"] = "linea-sepolia-testnet";
1309
1295
  ChainName["POLYGON_AMOY_TESTNET"] = "polygon-amoy-testnet";
1310
1296
  ChainName["MANTLE_MAINNET"] = "mantle-mainnet";
1311
1297
  ChainName["BASE_MAINNET"] = "base-mainnet";
1298
+ ChainName["BASE_SEPOLIA_TESTNET"] = "base-sepolia-testnet";
1312
1299
  ChainName["OASIS_SAPPHIRE_MAINNET"] = "oasis-sapphire-mainnet";
1313
1300
  ChainName["CELO_MAINNET"] = "celo-mainnet";
1314
1301
  ChainName["HYPEREVM_MAINNET"] = "hyperevm-mainnet";
@@ -1320,10 +1307,9 @@ exports.ChainName = void 0;
1320
1307
  ChainName["SONIC_MAINNET"] = "sonic-mainnet";
1321
1308
  ChainName["WORLD_MAINNET"] = "world-mainnet";
1322
1309
  ChainName["WORLD_SEPOLIA_TESTNET"] = "world-sepolia-testnet";
1323
- ChainName["LENS_SEPOLIA_TESTNET"] = "lens-sepolia-testnet";
1310
+ ChainName["MANTA_SEPOLIA_TESTNET"] = "manta-sepolia-testnet";
1324
1311
  ChainName["INK_SEPOLIA_TESTNET"] = "ink-sepolia-testnet";
1325
1312
  ChainName["INK_MAINNET"] = "ink-mainnet";
1326
- ChainName["LENS_MAINNET"] = "lens-mainnet";
1327
1313
  ChainName["ZKSYNC_MAINNET"] = "zksync-mainnet";
1328
1314
  ChainName["BNB_OPBNB_MAINNET"] = "bnb-opbnb-mainnet";
1329
1315
  ChainName["ZETACHAIN_MAINNET"] = "zetachain-mainnet";
@@ -1339,17 +1325,16 @@ exports.ChainID = void 0;
1339
1325
  ChainID[ChainID["ETH_MAINNET"] = 1] = "ETH_MAINNET";
1340
1326
  ChainID[ChainID["ETH_SEPOLIA"] = 11155111] = "ETH_SEPOLIA";
1341
1327
  ChainID[ChainID["ETH_HOLESKY"] = 17000] = "ETH_HOLESKY";
1342
- ChainID[ChainID["ETH_HOODI"] = 560048] = "ETH_HOODI";
1343
1328
  ChainID[ChainID["MATIC_MAINNET"] = 137] = "MATIC_MAINNET";
1344
1329
  ChainID[ChainID["AVALANCHE_MAINNET"] = 43114] = "AVALANCHE_MAINNET";
1345
1330
  ChainID[ChainID["AVALANCHE_TESTNET"] = 43113] = "AVALANCHE_TESTNET";
1346
1331
  ChainID[ChainID["BSC_MAINNET"] = 56] = "BSC_MAINNET";
1347
1332
  ChainID[ChainID["BSC_TESTNET"] = 97] = "BSC_TESTNET";
1348
1333
  ChainID[ChainID["MOONBEAM_MAINNET"] = 1284] = "MOONBEAM_MAINNET";
1349
- ChainID[ChainID["MOONBEAM_MOONBASE_ALPHA"] = 1287] = "MOONBEAM_MOONBASE_ALPHA";
1350
1334
  ChainID[ChainID["MOONBEAM_MOONRIVER"] = 1285] = "MOONBEAM_MOONRIVER";
1351
1335
  ChainID[ChainID["ARBITRUM_MAINNET"] = 42161] = "ARBITRUM_MAINNET";
1352
1336
  ChainID[ChainID["ARBITRUM_NOVA_MAINNET"] = 42170] = "ARBITRUM_NOVA_MAINNET";
1337
+ ChainID[ChainID["ARBITRUM_SEPOLIA"] = 421614] = "ARBITRUM_SEPOLIA";
1353
1338
  ChainID[ChainID["FANTOM_MAINNET"] = 250] = "FANTOM_MAINNET";
1354
1339
  ChainID[ChainID["FANTOM_TESTNET"] = 4002] = "FANTOM_TESTNET";
1355
1340
  ChainID[ChainID["BTC_MAINNET"] = 20090103] = "BTC_MAINNET";
@@ -1361,17 +1346,21 @@ exports.ChainID = void 0;
1361
1346
  ChainID[ChainID["EMERALD_PARATIME_MAINNET"] = 42262] = "EMERALD_PARATIME_MAINNET";
1362
1347
  ChainID[ChainID["MONAD_TESTNET"] = 10143] = "MONAD_TESTNET";
1363
1348
  ChainID[ChainID["MONAD_MAINNET"] = 143] = "MONAD_MAINNET";
1349
+ ChainID[ChainID["MEGAETH_MAINNET"] = 4326] = "MEGAETH_MAINNET";
1364
1350
  ChainID[ChainID["BERACHAIN_MAINNET"] = 80094] = "BERACHAIN_MAINNET";
1351
+ ChainID[ChainID["BERACHAIN_TESTNET"] = 80084] = "BERACHAIN_TESTNET";
1365
1352
  ChainID[ChainID["PLASMA_MAINNET"] = 9745] = "PLASMA_MAINNET";
1366
1353
  ChainID[ChainID["UNICHAIN_MAINNET"] = 130] = "UNICHAIN_MAINNET";
1367
1354
  ChainID[ChainID["PLASMA_TESTNET"] = 9746] = "PLASMA_TESTNET";
1368
1355
  ChainID[ChainID["ARC_TESTNET"] = 5042002] = "ARC_TESTNET";
1356
+ ChainID[ChainID["ADI_TESTNET"] = 99999] = "ADI_TESTNET";
1369
1357
  ChainID[ChainID["CANTO_MAINNET"] = 7700] = "CANTO_MAINNET";
1370
1358
  ChainID[ChainID["LINEA_MAINNET"] = 59144] = "LINEA_MAINNET";
1371
1359
  ChainID[ChainID["LINEA_SEPOLIA_TESTNET"] = 59141] = "LINEA_SEPOLIA_TESTNET";
1372
1360
  ChainID[ChainID["POLYGON_AMOY_TESTNET"] = 80002] = "POLYGON_AMOY_TESTNET";
1373
1361
  ChainID[ChainID["MANTLE_MAINNET"] = 5000] = "MANTLE_MAINNET";
1374
1362
  ChainID[ChainID["BASE_MAINNET"] = 8453] = "BASE_MAINNET";
1363
+ ChainID[ChainID["BASE_SEPOLIA_TESTNET"] = 84532] = "BASE_SEPOLIA_TESTNET";
1375
1364
  ChainID[ChainID["OASIS_SAPPHIRE_MAINNET"] = 23294] = "OASIS_SAPPHIRE_MAINNET";
1376
1365
  ChainID[ChainID["CELO_MAINNET"] = 42220] = "CELO_MAINNET";
1377
1366
  ChainID[ChainID["HYPEREVM_MAINNET"] = 999] = "HYPEREVM_MAINNET";
@@ -1383,10 +1372,9 @@ exports.ChainID = void 0;
1383
1372
  ChainID[ChainID["SONIC_MAINNET"] = 146] = "SONIC_MAINNET";
1384
1373
  ChainID[ChainID["WORLD_MAINNET"] = 480] = "WORLD_MAINNET";
1385
1374
  ChainID[ChainID["WORLD_SEPOLIA_TESTNET"] = 4801] = "WORLD_SEPOLIA_TESTNET";
1386
- ChainID[ChainID["LENS_SEPOLIA_TESTNET"] = 37111] = "LENS_SEPOLIA_TESTNET";
1375
+ ChainID[ChainID["MANTA_SEPOLIA_TESTNET"] = 3441006] = "MANTA_SEPOLIA_TESTNET";
1387
1376
  ChainID[ChainID["INK_SEPOLIA_TESTNET"] = 763373] = "INK_SEPOLIA_TESTNET";
1388
1377
  ChainID[ChainID["INK_MAINNET"] = 57073] = "INK_MAINNET";
1389
- ChainID[ChainID["LENS_MAINNET"] = 232] = "LENS_MAINNET";
1390
1378
  ChainID[ChainID["ZKSYNC_MAINNET"] = 324] = "ZKSYNC_MAINNET";
1391
1379
  ChainID[ChainID["BNB_OPBNB_MAINNET"] = 204] = "BNB_OPBNB_MAINNET";
1392
1380
  ChainID[ChainID["ZETACHAIN_MAINNET"] = 7000] = "ZETACHAIN_MAINNET";
@@ -1403,10 +1391,15 @@ exports.ChainID = void 0;
1403
1391
  *
1404
1392
  */
1405
1393
  class BitcoinService {
1394
+ execution;
1406
1395
  constructor(execution) {
1407
1396
  this.execution = execution;
1408
1397
  }
1409
1398
  /**
1399
+ *
1400
+ * Commonly used to fetch the historical Bitcoin balance held by an address at a given block height or date. Response includes daily prices and other metadata.
1401
+ *
1402
+ * **Credit Cost**: 1 per call
1410
1403
  *
1411
1404
  * @param {string} walletAddress - The requested Bitcoin HD address.
1412
1405
  * @param {GetBitcoinHdWalletBalancesQueryParamOpts} queryParamOpts
@@ -1442,536 +1435,22 @@ class BitcoinService {
1442
1435
  *
1443
1436
  * @param {GetTransactionsForBitcoinAddressParamOpts} queryParamOpts
1444
1437
  * - `address`: The bitcoin address to query.
1445
- * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1446
- * - `pageNumber`: 0-indexed page number to begin pagination.
1447
- */
1448
- async getTransactionsForBtcAddress(queryParamOpts) {
1449
- const endpoint = endpointGenerator(`cq/covalent/app/bitcoin/transactions/`, [
1450
- {
1451
- key: "address",
1452
- value: queryParamOpts?.address,
1453
- },
1454
- {
1455
- key: "page-size",
1456
- value: queryParamOpts?.pageSize,
1457
- },
1458
- {
1459
- key: "page-number",
1460
- value: queryParamOpts?.pageNumber,
1461
- },
1462
- ]);
1463
- const parseData = (data) => {
1464
- if (data.data) {
1465
- data.data.updated_at = data.data.updated_at
1466
- ? new Date(data.data.updated_at)
1467
- : null;
1468
- data.data.items = data.data.items
1469
- ? data.data.items.map((txItem) => ({
1470
- ...txItem,
1471
- value: bigIntParser(txItem.value),
1472
- fees_paid: bigIntParser(txItem.fees_paid),
1473
- block_signed_at: txItem.block_signed_at
1474
- ? new Date(txItem.block_signed_at)
1475
- : null,
1476
- }))
1477
- : null;
1478
- }
1479
- return data;
1480
- };
1481
- return await this.execution.execute(endpoint, parseData);
1482
- }
1483
- /**
1484
- *
1485
- * Commonly used to fetch the tokens held by an address. Response includes spot prices and other metadata.
1486
- *
1487
- * @param {string} walletAddress - The requested Bitcoin Non HD address.
1488
- * @param {GetBitcoinNonHdWalletBalancesQueryParamOpts} queryParamOpts
1489
- * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1490
- *
1491
- */
1492
- async getBitcoinNonHdWalletBalances(walletAddress, queryParamOpts) {
1493
- const endpoint = endpointGenerator(`${exports.ChainName.BTC_MAINNET}/address/${walletAddress}/balances_v2`, [
1494
- {
1495
- key: "quote-currency",
1496
- value: queryParamOpts?.quoteCurrency,
1497
- },
1498
- ]);
1499
- const parseData = (data) => {
1500
- if (data.data) {
1501
- data.data.updated_at = data.data.updated_at
1502
- ? new Date(data.data.updated_at)
1503
- : null;
1504
- data.data.items = data.data.items
1505
- ? data.data.items.map((balanceItem) => ({
1506
- ...balanceItem,
1507
- balance: bigIntParser(balanceItem.balance),
1508
- balance_24h: bigIntParser(balanceItem.balance_24h),
1509
- last_transferred_at: balanceItem.last_transferred_at
1510
- ? new Date(balanceItem.last_transferred_at)
1511
- : null,
1512
- nft_data: balanceItem.nft_data
1513
- ? balanceItem.nft_data.map((nftItem) => ({
1514
- ...nftItem,
1515
- token_id: bigIntParser(nftItem.token_id),
1516
- token_balance: bigIntParser(nftItem.token_balance),
1517
- token_price_wei: bigIntParser(nftItem.token_price_wei),
1518
- }))
1519
- : null,
1520
- }))
1521
- : null;
1522
- }
1523
- return data;
1524
- };
1525
- return await this.execution.execute(endpoint, parseData);
1526
- }
1527
- }
1528
-
1529
- /**
1530
- * NFTs API
1531
- *
1532
- */
1533
- class NftService {
1534
- constructor(execution) {
1535
- this.execution = execution;
1536
- }
1537
- /**
1538
- *
1539
- * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
1540
- *
1541
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1542
- * @param {GetChainCollectionsQueryParamOpts} queryParamOpts
1543
- * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1544
- * - `pageNumber`: 0-indexed page number to begin pagination.
1545
- * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1546
- *
1547
- */
1548
- async *getChainCollections(chainName, queryParamOpts) {
1549
- const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
1550
- {
1551
- key: "page-size",
1552
- value: queryParamOpts?.pageSize,
1553
- },
1554
- {
1555
- key: "page-number",
1556
- value: queryParamOpts?.pageNumber,
1557
- },
1558
- {
1559
- key: "no-spam",
1560
- value: queryParamOpts?.noSpam,
1561
- },
1562
- ]);
1563
- const parseData = (data) => {
1564
- if (data.data) {
1565
- data.data.updated_at = data.data.updated_at
1566
- ? new Date(data.data.updated_at)
1567
- : null;
1568
- data.data.items = data.data.items
1569
- ? data.data.items.map((collectionItem) => ({
1570
- ...collectionItem,
1571
- last_scraped_at: collectionItem.last_scraped_at
1572
- ? new Date(collectionItem.last_scraped_at)
1573
- : null,
1574
- }))
1575
- : null;
1576
- }
1577
- return data;
1578
- };
1579
- for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
1580
- yield data;
1581
- }
1582
- }
1583
- /**
1584
- *
1585
- * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
1586
- *
1587
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1588
- * @param {GetChainCollectionsQueryParamOpts} queryParamOpts
1589
- * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1590
- * - `pageNumber`: 0-indexed page number to begin pagination.
1591
- * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1592
- *
1593
- */
1594
- async getChainCollectionsByPage(chainName, queryParamOpts) {
1595
- const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
1596
- {
1597
- key: "page-size",
1598
- value: queryParamOpts?.pageSize,
1599
- },
1600
- {
1601
- key: "page-number",
1602
- value: queryParamOpts?.pageNumber,
1603
- },
1604
- {
1605
- key: "no-spam",
1606
- value: queryParamOpts?.noSpam,
1607
- },
1608
- ]);
1609
- const parseData = (data) => {
1610
- if (data.data) {
1611
- data.data.updated_at = data.data.updated_at
1612
- ? new Date(data.data.updated_at)
1613
- : null;
1614
- data.data.items = data.data.items
1615
- ? data.data.items.map((collectionItem) => ({
1616
- ...collectionItem,
1617
- last_scraped_at: collectionItem.last_scraped_at
1618
- ? new Date(collectionItem.last_scraped_at)
1619
- : null,
1620
- }))
1621
- : null;
1622
- }
1623
- return data;
1624
- };
1625
- return await this.execution.execute(endpoint, parseData);
1626
- }
1627
- /**
1628
- *
1629
- * Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
1630
- *
1631
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1632
- * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1633
- * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
1634
- * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1635
- * - `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.
1636
- * - `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.
1637
- *
1638
- */
1639
- async getNftsForAddress(chainName, walletAddress, queryParamOpts) {
1640
- const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/balances_nft`, [
1641
- {
1642
- key: "no-spam",
1643
- value: queryParamOpts?.noSpam,
1644
- },
1645
- {
1646
- key: "no-nft-asset-metadata",
1647
- value: queryParamOpts?.noNftAssetMetadata,
1648
- },
1649
- {
1650
- key: "with-uncached",
1651
- value: queryParamOpts?.withUncached,
1652
- },
1653
- ]);
1654
- const parseData = (data) => {
1655
- if (data.data) {
1656
- data.data.updated_at = data.data.updated_at
1657
- ? new Date(data.data.updated_at)
1658
- : null;
1659
- data.data.items = data.data.items
1660
- ? data.data.items.map((balanceItem) => ({
1661
- ...balanceItem,
1662
- balance: bigIntParser(balanceItem.balance),
1663
- balance_24h: bigIntParser(balanceItem.balance_24h),
1664
- nft_data: balanceItem.nft_data
1665
- ? balanceItem.nft_data.map((nftItem) => ({
1666
- ...nftItem,
1667
- token_id: bigIntParser(nftItem.token_id),
1668
- }))
1669
- : null,
1670
- }))
1671
- : null;
1672
- }
1673
- return data;
1674
- };
1675
- return await this.execution.execute(endpoint, parseData);
1676
- }
1677
- /**
1678
- *
1679
- * Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
1680
- *
1681
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1682
- * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1683
- * @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
1684
- * - `noMetadata`: Omit metadata.
1685
- * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1686
- * - `pageNumber`: 0-indexed page number to begin pagination.
1687
- * - `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.
1688
- * - `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.
1689
- * - `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.
1690
- *
1691
- */
1692
- async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
1693
- const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
1694
- {
1695
- key: "no-metadata",
1696
- value: queryParamOpts?.noMetadata,
1697
- },
1698
- {
1699
- key: "page-size",
1700
- value: queryParamOpts?.pageSize,
1701
- },
1702
- {
1703
- key: "page-number",
1704
- value: queryParamOpts?.pageNumber,
1705
- },
1706
- {
1707
- key: "traits-filter",
1708
- value: queryParamOpts?.traitsFilter,
1709
- },
1710
- {
1711
- key: "values-filter",
1712
- value: queryParamOpts?.valuesFilter,
1713
- },
1714
- {
1715
- key: "with-uncached",
1716
- value: queryParamOpts?.withUncached,
1717
- },
1718
- ]);
1719
- const parseData = (data) => {
1720
- if (data.data) {
1721
- data.data.updated_at = data.data.updated_at
1722
- ? new Date(data.data.updated_at)
1723
- : null;
1724
- data.data.items = data.data.items
1725
- ? data.data.items.map((tokenItem) => ({
1726
- ...tokenItem,
1727
- nft_data: {
1728
- ...tokenItem.nft_data,
1729
- token_id: bigIntParser(tokenItem.nft_data?.token_id),
1730
- },
1731
- }))
1732
- : null;
1733
- }
1734
- return data;
1735
- };
1736
- for await (const data of paginateEndpoint(endpoint, this.execution, parseData, "pagination")) {
1737
- yield data;
1738
- }
1739
- }
1740
- /**
1741
- *
1742
- * Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
1743
- *
1744
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1745
- * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1746
- * @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
1747
- * - `noMetadata`: Omit metadata.
1748
- * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1749
- * - `pageNumber`: 0-indexed page number to begin pagination.
1750
- * - `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.
1751
- * - `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.
1752
- * - `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.
1753
- *
1754
- */
1755
- async getTokenIdsForContractWithMetadataByPage(chainName, contractAddress, queryParamOpts) {
1756
- const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
1757
- {
1758
- key: "no-metadata",
1759
- value: queryParamOpts?.noMetadata,
1760
- },
1761
- {
1762
- key: "page-size",
1763
- value: queryParamOpts?.pageSize,
1764
- },
1765
- {
1766
- key: "page-number",
1767
- value: queryParamOpts?.pageNumber,
1768
- },
1769
- {
1770
- key: "traits-filter",
1771
- value: queryParamOpts?.traitsFilter,
1772
- },
1773
- {
1774
- key: "values-filter",
1775
- value: queryParamOpts?.valuesFilter,
1776
- },
1777
- {
1778
- key: "with-uncached",
1779
- value: queryParamOpts?.withUncached,
1780
- },
1781
- ]);
1782
- const parseData = (data) => {
1783
- if (data.data) {
1784
- data.data.updated_at = data.data.updated_at
1785
- ? new Date(data.data.updated_at)
1786
- : null;
1787
- data.data.items = data.data.items
1788
- ? data.data.items.map((tokenItem) => ({
1789
- ...tokenItem,
1790
- nft_data: {
1791
- ...tokenItem.nft_data,
1792
- token_id: bigIntParser(tokenItem.nft_data?.token_id),
1793
- },
1794
- }))
1795
- : null;
1796
- }
1797
- return data;
1798
- };
1799
- return await this.execution.execute(endpoint, parseData);
1800
- }
1801
- /**
1802
- *
1803
- * Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
1804
- *
1805
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1806
- * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1807
- * @param {string} tokenId - The requested token ID.
1808
- * @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
1809
- * - `noMetadata`: Omit metadata.
1810
- * - `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.
1811
- *
1812
- */
1813
- async getNftMetadataForGivenTokenIdForContract(chainName, contractAddress, tokenId, queryParamOpts) {
1814
- const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata/${tokenId}`, [
1815
- {
1816
- key: "no-metadata",
1817
- value: queryParamOpts?.noMetadata,
1818
- },
1819
- {
1820
- key: "with-uncached",
1821
- value: queryParamOpts?.withUncached,
1822
- },
1823
- ]);
1824
- const parseData = (data) => {
1825
- if (data.data) {
1826
- data.data.updated_at = data.data.updated_at
1827
- ? new Date(data.data.updated_at)
1828
- : null;
1829
- data.data.items = data.data.items
1830
- ? data.data.items.map((tokenItem) => ({
1831
- ...tokenItem,
1832
- nft_data: {
1833
- ...tokenItem.nft_data,
1834
- token_id: bigIntParser(tokenItem.nft_data?.token_id),
1835
- },
1836
- }))
1837
- : null;
1838
- }
1839
- return data;
1840
- };
1841
- return await this.execution.execute(endpoint, parseData);
1842
- }
1843
- /**
1844
- *
1845
- * Commonly used to get all transactions of an NFT token. Useful for building a transaction history table or price chart.
1846
- *
1847
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1848
- * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1849
- * @param {string} tokenId - The requested token ID.
1850
- * @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
1851
- * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1852
- *
1853
- */
1854
- async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, queryParamOpts) {
1855
- const endpoint = endpointGenerator(`${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}`, [
1856
- {
1857
- key: "no-spam",
1858
- value: queryParamOpts?.noSpam,
1859
- },
1860
- ]);
1861
- const parseData = (data) => {
1862
- if (data.data) {
1863
- data.data.updated_at = data.data.updated_at
1864
- ? new Date(data.data.updated_at)
1865
- : null;
1866
- data.data.items = data.data.items
1867
- ? data.data.items.map((nftItem) => ({
1868
- ...nftItem,
1869
- nft_transactions: nftItem.nft_transactions
1870
- ? nftItem.nft_transactions.map((txItem) => ({
1871
- ...txItem,
1872
- block_signed_at: txItem.block_signed_at
1873
- ? new Date(txItem.block_signed_at)
1874
- : null,
1875
- value: bigIntParser(txItem.value),
1876
- fees_paid: bigIntParser(txItem.fees_paid),
1877
- log_events: txItem.log_events
1878
- ? txItem.log_events.map((logItem) => ({
1879
- ...logItem,
1880
- block_signed_at: logItem.block_signed_at
1881
- ? new Date(logItem.block_signed_at)
1882
- : null,
1883
- }))
1884
- : null,
1885
- }))
1886
- : null,
1887
- }))
1888
- : null;
1889
- }
1890
- return data;
1891
- };
1892
- return await this.execution.execute(endpoint, parseData);
1893
- }
1894
- /**
1895
- *
1896
- * Commonly used to fetch and render the traits of a collection as seen in rarity calculators.
1897
- *
1898
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1899
- * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1900
- *
1901
- */
1902
- async getTraitsForCollection(chainName, collectionContract) {
1903
- const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits`, []);
1904
- const parseData = (data) => {
1905
- if (data.data) {
1906
- data.data.updated_at = data.data.updated_at
1907
- ? new Date(data.data.updated_at)
1908
- : null;
1909
- }
1910
- return data;
1911
- };
1912
- return await this.execution.execute(endpoint, parseData);
1913
- }
1914
- /**
1915
- *
1916
- * Commonly used to get the count of unique values for traits within an NFT collection.
1917
- *
1918
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1919
- * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1920
- * @param {string} trait - The requested trait.
1921
- *
1922
- */
1923
- async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
1924
- const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits/${trait}/attributes`, []);
1925
- const parseData = (data) => {
1926
- if (data.data) {
1927
- data.data.updated_at = data.data.updated_at
1928
- ? new Date(data.data.updated_at)
1929
- : null;
1930
- }
1931
- return data;
1932
- };
1933
- return await this.execution.execute(endpoint, parseData);
1934
- }
1935
- /**
1936
- *
1937
- * Commonly used to calculate rarity scores for a collection based on its traits.
1938
- *
1939
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1940
- * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1941
- *
1942
- */
1943
- async getCollectionTraitsSummary(chainName, collectionContract) {
1944
- const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits_summary`, []);
1945
- const parseData = (data) => {
1946
- if (data.data) {
1947
- data.data.updated_at = data.data.updated_at
1948
- ? new Date(data.data.updated_at)
1949
- : null;
1950
- }
1951
- return data;
1952
- };
1953
- return await this.execution.execute(endpoint, parseData);
1954
- }
1955
- /**
1956
- *
1957
- * Commonly used to render a price floor chart for an NFT collection.
1958
- *
1959
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1960
- * @param {string} collectionAddress - The requested address.
1961
- * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
1962
- * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1963
- * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
1964
- *
1438
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
1439
+ * - `pageNumber`: 0-indexed page number to begin pagination.
1965
1440
  */
1966
- async getHistoricalFloorPricesForCollection(chainName, collectionAddress, queryParamOpts) {
1967
- const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/floor_price`, [
1441
+ async getTransactionsForBtcAddress(queryParamOpts) {
1442
+ const endpoint = endpointGenerator(`cq/covalent/app/bitcoin/transactions/`, [
1968
1443
  {
1969
- key: "days",
1970
- value: queryParamOpts?.days,
1444
+ key: "address",
1445
+ value: queryParamOpts?.address,
1971
1446
  },
1972
1447
  {
1973
- key: "quote-currency",
1974
- value: queryParamOpts?.quote_currency,
1448
+ key: "page-size",
1449
+ value: queryParamOpts?.pageSize,
1450
+ },
1451
+ {
1452
+ key: "page-number",
1453
+ value: queryParamOpts?.pageNumber,
1975
1454
  },
1976
1455
  ]);
1977
1456
  const parseData = (data) => {
@@ -1980,9 +1459,13 @@ class NftService {
1980
1459
  ? new Date(data.data.updated_at)
1981
1460
  : null;
1982
1461
  data.data.items = data.data.items
1983
- ? data.data.items.map((floorPriceItem) => ({
1984
- ...floorPriceItem,
1985
- date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
1462
+ ? data.data.items.map((txItem) => ({
1463
+ ...txItem,
1464
+ value: bigIntParser(txItem.value),
1465
+ fees_paid: bigIntParser(txItem.fees_paid),
1466
+ block_signed_at: txItem.block_signed_at
1467
+ ? new Date(txItem.block_signed_at)
1468
+ : null,
1986
1469
  }))
1987
1470
  : null;
1988
1471
  }
@@ -1992,24 +1475,20 @@ class NftService {
1992
1475
  }
1993
1476
  /**
1994
1477
  *
1995
- * Commonly used to build a time-series chart of the transaction volume of an NFT collection.
1478
+ * Fetch Bitcoin balance for a non-HD address. Response includes spot prices and other metadata.
1996
1479
  *
1997
- * @param {string} chainName - The chain name eg: `eth-mainnet`.
1998
- * @param {string} collectionAddress - The requested address.
1999
- * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
1480
+ * **Credit Cost**: 1 per call
1481
+ *
1482
+ * @param {string} walletAddress - The requested Bitcoin Non HD address.
1483
+ * @param {GetBitcoinNonHdWalletBalancesQueryParamOpts} queryParamOpts
2000
1484
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2001
- * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2002
1485
  *
2003
1486
  */
2004
- async getHistoricalVolumeForCollection(chainName, collectionAddress, queryParamOpts) {
2005
- const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/volume`, [
2006
- {
2007
- key: "days",
2008
- value: queryParamOpts?.days,
2009
- },
1487
+ async getBitcoinNonHdWalletBalances(walletAddress, queryParamOpts) {
1488
+ const endpoint = endpointGenerator(`${exports.ChainName.BTC_MAINNET}/address/${walletAddress}/balances_v2`, [
2010
1489
  {
2011
1490
  key: "quote-currency",
2012
- value: queryParamOpts?.quote_currency,
1491
+ value: queryParamOpts?.quoteCurrency,
2013
1492
  },
2014
1493
  ]);
2015
1494
  const parseData = (data) => {
@@ -2018,9 +1497,21 @@ class NftService {
2018
1497
  ? new Date(data.data.updated_at)
2019
1498
  : null;
2020
1499
  data.data.items = data.data.items
2021
- ? data.data.items.map((floorPriceItem) => ({
2022
- ...floorPriceItem,
2023
- date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
1500
+ ? data.data.items.map((balanceItem) => ({
1501
+ ...balanceItem,
1502
+ balance: bigIntParser(balanceItem.balance),
1503
+ balance_24h: bigIntParser(balanceItem.balance_24h),
1504
+ last_transferred_at: balanceItem.last_transferred_at
1505
+ ? new Date(balanceItem.last_transferred_at)
1506
+ : null,
1507
+ nft_data: balanceItem.nft_data
1508
+ ? balanceItem.nft_data.map((nftItem) => ({
1509
+ ...nftItem,
1510
+ token_id: bigIntParser(nftItem.token_id),
1511
+ token_balance: bigIntParser(nftItem.token_balance),
1512
+ token_price_wei: bigIntParser(nftItem.token_price_wei),
1513
+ }))
1514
+ : null,
2024
1515
  }))
2025
1516
  : null;
2026
1517
  }
@@ -2028,26 +1519,39 @@ class NftService {
2028
1519
  };
2029
1520
  return await this.execution.execute(endpoint, parseData);
2030
1521
  }
1522
+ }
1523
+
1524
+ /**
1525
+ * NFTs API
1526
+ *
1527
+ */
1528
+ class NftService {
1529
+ execution;
1530
+ constructor(execution) {
1531
+ this.execution = execution;
1532
+ }
2031
1533
  /**
2032
1534
  *
2033
- * Commonly used to build a time-series chart of the sales count of an NFT collection.
1535
+ * Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
1536
+ *
1537
+ * **Credit Cost**: 1 per call
2034
1538
  *
2035
1539
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
2036
- * @param {string} collectionAddress - The requested address.
1540
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2037
1541
  * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
2038
- * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2039
- * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
1542
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1543
+ * - `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.
2040
1544
  *
2041
1545
  */
2042
- async getHistoricalSalesCountForCollection(chainName, collectionAddress, queryParamOpts) {
2043
- const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/sale_count`, [
1546
+ async getNftsForAddress(chainName, walletAddress, queryParamOpts) {
1547
+ const endpoint = endpointGenerator(`${chainName}/address/${walletAddress}/balances_nft`, [
2044
1548
  {
2045
- key: "days",
2046
- value: queryParamOpts?.days,
1549
+ key: "no-spam",
1550
+ value: queryParamOpts?.noSpam,
2047
1551
  },
2048
1552
  {
2049
- key: "quote-currency",
2050
- value: queryParamOpts?.quote_currency,
1553
+ key: "no-nft-asset-metadata",
1554
+ value: queryParamOpts?.noNftAssetMetadata,
2051
1555
  },
2052
1556
  ]);
2053
1557
  const parseData = (data) => {
@@ -2056,9 +1560,16 @@ class NftService {
2056
1560
  ? new Date(data.data.updated_at)
2057
1561
  : null;
2058
1562
  data.data.items = data.data.items
2059
- ? data.data.items.map((floorPriceItem) => ({
2060
- ...floorPriceItem,
2061
- date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
1563
+ ? data.data.items.map((balanceItem) => ({
1564
+ ...balanceItem,
1565
+ balance: bigIntParser(balanceItem.balance),
1566
+ balance_24h: bigIntParser(balanceItem.balance_24h),
1567
+ nft_data: balanceItem.nft_data
1568
+ ? balanceItem.nft_data.map((nftItem) => ({
1569
+ ...nftItem,
1570
+ token_id: bigIntParser(nftItem.token_id),
1571
+ }))
1572
+ : null,
2062
1573
  }))
2063
1574
  : null;
2064
1575
  }
@@ -2070,6 +1581,8 @@ class NftService {
2070
1581
  *
2071
1582
  * Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
2072
1583
  *
1584
+ * **Credit Cost**: 1 per call
1585
+ *
2073
1586
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
2074
1587
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2075
1588
  * @param {string} collectionContract - The requested collection address.
@@ -2115,6 +1628,8 @@ class NftService {
2115
1628
  *
2116
1629
  * Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
2117
1630
  *
1631
+ * **Credit Cost**: 1 per call
1632
+ *
2118
1633
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
2119
1634
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2120
1635
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -2151,12 +1666,15 @@ class NftService {
2151
1666
  *
2152
1667
  */
2153
1668
  class PricingService {
1669
+ execution;
2154
1670
  constructor(execution) {
2155
1671
  this.execution = execution;
2156
1672
  }
2157
1673
  /**
2158
1674
  *
2159
- * Commonly used to get historic prices of a token between date ranges. Supports native tokens.
1675
+ * Get the historical prices of one (or many) large cap ERC20 tokens between specified date ranges. Also supports native tokens.
1676
+ *
1677
+ * **Credit Cost**: 1 per call
2160
1678
  *
2161
1679
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2162
1680
  * @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`.
@@ -2191,7 +1709,9 @@ class PricingService {
2191
1709
  dataItem.items = dataItem.items
2192
1710
  ? dataItem.items.map((priceItem) => ({
2193
1711
  ...priceItem,
2194
- date: priceItem.date ? new Date(priceItem.date) : null,
1712
+ date: priceItem.date
1713
+ ? new Date(priceItem.date)
1714
+ : null,
2195
1715
  }))
2196
1716
  : null;
2197
1717
  });
@@ -2204,6 +1724,8 @@ class PricingService {
2204
1724
  *
2205
1725
  * Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.
2206
1726
  *
1727
+ * **Credit Cost**: 1 per call
1728
+ *
2207
1729
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2208
1730
  * @param {string} contractAddress - The pool contract address.
2209
1731
  * @param {GetTokenPricesQueryParamOpts} queryParamOpts
@@ -2236,6 +1758,7 @@ class PricingService {
2236
1758
  *
2237
1759
  */
2238
1760
  class SecurityService {
1761
+ execution;
2239
1762
  constructor(execution) {
2240
1763
  this.execution = execution;
2241
1764
  }
@@ -2243,6 +1766,8 @@ class SecurityService {
2243
1766
  *
2244
1767
  * Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
2245
1768
  *
1769
+ * **Credit Cost**: 2 per call
1770
+ *
2246
1771
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2247
1772
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2248
1773
  *
@@ -2273,37 +1798,6 @@ class SecurityService {
2273
1798
  };
2274
1799
  return await this.execution.execute(endpoint, parseData);
2275
1800
  }
2276
- /**
2277
- *
2278
- * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2279
- * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2280
-
2281
- *
2282
- */
2283
- async getNftApprovals(chainName, walletAddress) {
2284
- const endpoint = endpointGenerator(`${chainName}/nft/approvals/${walletAddress}`, []);
2285
- const parseData = (data) => {
2286
- if (data.data) {
2287
- data.data.updated_at = data.data.updated_at
2288
- ? new Date(data.data.updated_at)
2289
- : null;
2290
- data.data.items = data.data.items
2291
- ? data.data.items.map((approvalItem) => ({
2292
- ...approvalItem,
2293
- token_balances: approvalItem.token_balances
2294
- ? approvalItem.token_balances.map((balanceItem) => ({
2295
- ...balanceItem,
2296
- token_balance: bigIntParser(balanceItem.token_balance),
2297
- token_id: bigIntParser(balanceItem.token_id),
2298
- }))
2299
- : null,
2300
- }))
2301
- : null;
2302
- }
2303
- return data;
2304
- };
2305
- return await this.execution.execute(endpoint, parseData);
2306
- }
2307
1801
  }
2308
1802
 
2309
1803
  function extendedTypeof(val) {
@@ -2628,7 +2122,7 @@ function createClient(options) {
2628
2122
  if (retrying) {
2629
2123
  await retryWait(retries);
2630
2124
  if (!locks) {
2631
- connecting = undefined;
2125
+ connecting = void 0;
2632
2126
  return denied({ code: 1e3, reason: "All Subscriptions Gone" });
2633
2127
  }
2634
2128
  retries++;
@@ -2645,13 +2139,13 @@ function createClient(options) {
2645
2139
  queuedPing = setTimeout(() => {
2646
2140
  if (socket2.readyState === WebSocketImpl.OPEN) {
2647
2141
  socket2.send(stringifyMessage({ type: MessageType.Ping }));
2648
- emitter.emit("ping", false, undefined);
2142
+ emitter.emit("ping", false, void 0);
2649
2143
  }
2650
2144
  }, keepAlive);
2651
2145
  }
2652
2146
  }
2653
2147
  errorOrClosed((errOrEvent) => {
2654
- connecting = undefined;
2148
+ connecting = void 0;
2655
2149
  clearTimeout(connectionAckTimeout);
2656
2150
  clearTimeout(queuedPing);
2657
2151
  denied(errOrEvent);
@@ -2938,11 +2432,11 @@ function createClient(options) {
2938
2432
  deferred.error = err;
2939
2433
  deferred.resolve();
2940
2434
  }
2941
- return { done: true, value: undefined };
2435
+ return { done: true, value: void 0 };
2942
2436
  };
2943
2437
  iterator.return = async () => {
2944
2438
  dispose();
2945
- return { done: true, value: undefined };
2439
+ return { done: true, value: void 0 };
2946
2440
  };
2947
2441
  return iterator;
2948
2442
  },
@@ -2999,23 +2493,23 @@ function isWebSocket(val) {
2999
2493
  *
3000
2494
  */
3001
2495
  class StreamingService {
2496
+ defaultConfig = {
2497
+ shouldRetry: (retries) => retries < 5,
2498
+ maxReconnectAttempts: 5,
2499
+ onConnecting: () => {
2500
+ console.info("StreamingService Connection Connecting...");
2501
+ },
2502
+ onOpened: () => {
2503
+ console.info("StreamingService Connection Established Successfully!");
2504
+ },
2505
+ onClosed: () => {
2506
+ console.info("StreamingService Connection Closed");
2507
+ },
2508
+ onError: (err) => {
2509
+ console.error("StreamingService Connection Error:", err);
2510
+ },
2511
+ };
3002
2512
  constructor(apiKey, config) {
3003
- this.defaultConfig = {
3004
- shouldRetry: (retries) => retries < 5,
3005
- maxReconnectAttempts: 5,
3006
- onConnecting: () => {
3007
- console.info("StreamingService Connection Connecting...");
3008
- },
3009
- onOpened: () => {
3010
- console.info("StreamingService Connection Established Successfully!");
3011
- },
3012
- onClosed: () => {
3013
- console.info("StreamingService Connection Closed");
3014
- },
3015
- onError: (err) => {
3016
- console.error("StreamingService Connection Error:", err);
3017
- },
3018
- };
3019
2513
  StreamingWebSocketClient.configure(apiKey, {
3020
2514
  ...this.defaultConfig,
3021
2515
  ...config,
@@ -3061,7 +2555,12 @@ class StreamingService {
3061
2555
  });
3062
2556
  }
3063
2557
  /**
3064
- * Subscribe to OHLCV data for specific pairs
2558
+ *
2559
+ * The OHLCV Pairs stream provides real-time updates on the Open, High, Low, Close prices and Volume of one or many token pairs at configurable intervals.
2560
+ *
2561
+ * **Credit Cost**: 0 per call
2562
+ *
2563
+ * **Beta**: This endpoint is in beta.
3065
2564
  *
3066
2565
  * @param params - Parameters for the OHLCV pairs stream
3067
2566
  * @param callbacks - Subscription callbacks
@@ -3089,42 +2588,42 @@ class StreamingService {
3089
2588
  const pairAddressesString = params.pair_addresses
3090
2589
  .map((addr) => `"${addr}"`)
3091
2590
  .join(", ");
3092
- const query = `
3093
- subscription {
3094
- ohlcvCandlesForPair(
3095
- chain_name: ${params.chain_name}
3096
- pair_addresses: [${pairAddressesString}]
3097
- interval: ${params.interval}
3098
- timeframe: ${params.timeframe}
3099
- ${params.limit ? `limit: ${params.limit}` : ""}
3100
- ) {
3101
- chain_name
3102
- pair_address
3103
- interval
3104
- timeframe
3105
- timestamp
3106
- open
3107
- high
3108
- low
3109
- close
3110
- volume
3111
- volume_usd
3112
- quote_rate
3113
- quote_rate_usd
3114
- base_token {
3115
- contract_name
3116
- contract_address
3117
- contract_decimals
3118
- contract_ticker_symbol
3119
- }
3120
- quote_token {
3121
- contract_name
3122
- contract_address
3123
- contract_decimals
3124
- contract_ticker_symbol
3125
- }
3126
- }
3127
- }
2591
+ const query = `
2592
+ subscription {
2593
+ ohlcvCandlesForPair(
2594
+ chain_name: ${params.chain_name}
2595
+ pair_addresses: [${pairAddressesString}]
2596
+ interval: ${params.interval}
2597
+ timeframe: ${params.timeframe}
2598
+ ${params.limit ? `limit: ${params.limit}` : ""}
2599
+ ) {
2600
+ chain_name
2601
+ pair_address
2602
+ interval
2603
+ timeframe
2604
+ timestamp
2605
+ open
2606
+ high
2607
+ low
2608
+ close
2609
+ volume
2610
+ volume_usd
2611
+ quote_rate
2612
+ quote_rate_usd
2613
+ base_token {
2614
+ contract_name
2615
+ contract_address
2616
+ contract_decimals
2617
+ contract_ticker_symbol
2618
+ }
2619
+ quote_token {
2620
+ contract_name
2621
+ contract_address
2622
+ contract_decimals
2623
+ contract_ticker_symbol
2624
+ }
2625
+ }
2626
+ }
3128
2627
  `;
3129
2628
  const client = StreamingWebSocketClient.getClient();
3130
2629
  return client.subscribe({
@@ -3146,7 +2645,12 @@ class StreamingService {
3146
2645
  });
3147
2646
  }
3148
2647
  /**
3149
- * Subscribe to OHLCV data for specific tokens
2648
+ *
2649
+ * The OHLCV Tokens stream provides real-time updates on the Open, High, Low, Close prices and Volume of one or many tokens at configurable intervals.
2650
+ *
2651
+ * **Credit Cost**: 0 per call
2652
+ *
2653
+ * **Beta**: This endpoint is in beta.
3150
2654
  *
3151
2655
  * @param params - Parameters for the OHLCV tokens stream
3152
2656
  * @param callbacks - Subscription callbacks
@@ -3174,42 +2678,42 @@ class StreamingService {
3174
2678
  const tokenAddressesString = params.token_addresses
3175
2679
  .map((addr) => `"${addr}"`)
3176
2680
  .join(", ");
3177
- const query = `
3178
- subscription {
3179
- ohlcvCandlesForToken(
3180
- chain_name: ${params.chain_name}
3181
- token_addresses: [${tokenAddressesString}]
3182
- interval: ${params.interval}
3183
- timeframe: ${params.timeframe}
3184
- ${params.limit ? `limit: ${params.limit}` : ""}
3185
- ) {
3186
- chain_name
3187
- pair_address
3188
- interval
3189
- timeframe
3190
- timestamp
3191
- open
3192
- high
3193
- low
3194
- close
3195
- volume
3196
- volume_usd
3197
- quote_rate
3198
- quote_rate_usd
3199
- base_token {
3200
- contract_name
3201
- contract_address
3202
- contract_decimals
3203
- contract_ticker_symbol
3204
- }
3205
- quote_token {
3206
- contract_name
3207
- contract_address
3208
- contract_decimals
3209
- contract_ticker_symbol
3210
- }
3211
- }
3212
- }
2681
+ const query = `
2682
+ subscription {
2683
+ ohlcvCandlesForToken(
2684
+ chain_name: ${params.chain_name}
2685
+ token_addresses: [${tokenAddressesString}]
2686
+ interval: ${params.interval}
2687
+ timeframe: ${params.timeframe}
2688
+ ${params.limit ? `limit: ${params.limit}` : ""}
2689
+ ) {
2690
+ chain_name
2691
+ pair_address
2692
+ interval
2693
+ timeframe
2694
+ timestamp
2695
+ open
2696
+ high
2697
+ low
2698
+ close
2699
+ volume
2700
+ volume_usd
2701
+ quote_rate
2702
+ quote_rate_usd
2703
+ base_token {
2704
+ contract_name
2705
+ contract_address
2706
+ contract_decimals
2707
+ contract_ticker_symbol
2708
+ }
2709
+ quote_token {
2710
+ contract_name
2711
+ contract_address
2712
+ contract_decimals
2713
+ contract_ticker_symbol
2714
+ }
2715
+ }
2716
+ }
3213
2717
  `;
3214
2718
  const client = StreamingWebSocketClient.getClient();
3215
2719
  return client.subscribe({
@@ -3231,7 +2735,12 @@ class StreamingService {
3231
2735
  });
3232
2736
  }
3233
2737
  /**
3234
- * Subscribe to new DEX pairs created on supported decentralized exchanges
2738
+ *
2739
+ * The New DEX Pairs stream provides real-time updates when new liquidity pairs are created on decentralized exchanges (DEXes). This documentation follows our standard streaming API structure.
2740
+ *
2741
+ * **Credit Cost**: 0 per call
2742
+ *
2743
+ * **Beta**: This endpoint is in beta.
3235
2744
  *
3236
2745
  * @param params - Parameters for the new pairs stream
3237
2746
  * @param callbacks - Subscription callbacks
@@ -3253,45 +2762,45 @@ class StreamingService {
3253
2762
  * ```
3254
2763
  */
3255
2764
  subscribeToNewPairs(params, callbacks) {
3256
- const query = `
3257
- subscription {
3258
- newPairs(
3259
- chain_name: ${params.chain_name},
3260
- protocols: [${params.protocols.join(", ")}]
3261
- ) {
3262
- chain_name
3263
- protocol
3264
- protocol_version
3265
- pair_address
3266
- deployer_address
3267
- tx_hash
3268
- block_signed_at
3269
- liquidity
3270
- supply
3271
- market_cap
3272
- event_name
3273
- quote_rate
3274
- quote_rate_usd
3275
- base_token_metadata {
3276
- contract_address
3277
- contract_decimals
3278
- contract_name
3279
- contract_ticker_symbol
3280
- }
3281
- pair_metadata {
3282
- contract_address
3283
- contract_decimals
3284
- contract_name
3285
- contract_ticker_symbol
3286
- }
3287
- quote_token_metadata {
3288
- contract_address
3289
- contract_decimals
3290
- contract_name
3291
- contract_ticker_symbol
3292
- }
3293
- }
3294
- }
2765
+ const query = `
2766
+ subscription {
2767
+ newPairs(
2768
+ chain_name: ${params.chain_name},
2769
+ protocols: [${params.protocols.join(", ")}]
2770
+ ) {
2771
+ chain_name
2772
+ protocol
2773
+ protocol_version
2774
+ pair_address
2775
+ deployer_address
2776
+ tx_hash
2777
+ block_signed_at
2778
+ liquidity
2779
+ supply
2780
+ market_cap
2781
+ event_name
2782
+ quote_rate
2783
+ quote_rate_usd
2784
+ base_token {
2785
+ contract_address
2786
+ contract_decimals
2787
+ contract_name
2788
+ contract_ticker_symbol
2789
+ }
2790
+ pair {
2791
+ contract_address
2792
+ contract_decimals
2793
+ contract_name
2794
+ contract_ticker_symbol
2795
+ }
2796
+ quote_token {
2797
+ contract_address
2798
+ contract_decimals
2799
+ contract_name
2800
+ contract_ticker_symbol
2801
+ }
2802
+ }
2803
+ }
3295
2804
  `;
3296
2805
  const client = StreamingWebSocketClient.getClient();
3297
2806
  return client.subscribe({
@@ -3313,7 +2822,12 @@ class StreamingService {
3313
2822
  });
3314
2823
  }
3315
2824
  /**
3316
- * Subscribe to real-time updates for specific trading pairs including price, volume, and liquidity data
2825
+ *
2826
+ * The Update DEX Pairs stream provides real-time event updates on the prices, volumes, market cap and liquidity of one or many token pairs.
2827
+ *
2828
+ * **Credit Cost**: 0 per call
2829
+ *
2830
+ * **Beta**: This endpoint is in beta.
3317
2831
  *
3318
2832
  * @param params - Parameters for the update pairs stream
3319
2833
  * @param callbacks - Subscription callbacks
@@ -3340,47 +2854,47 @@ class StreamingService {
3340
2854
  const pairAddressesString = params.pair_addresses
3341
2855
  .map((addr) => `"${addr}"`)
3342
2856
  .join(", ");
3343
- const query = `
3344
- subscription {
3345
- updatePairs(
3346
- chain_name: ${params.chain_name}
3347
- pair_addresses: [${pairAddressesString}]
3348
- ) {
3349
- chain_name
3350
- pair_address
3351
- timestamp
3352
- quote_rate
3353
- quote_rate_usd
3354
- volume
3355
- volume_usd
3356
- market_cap
3357
- liquidity
3358
- base_token {
3359
- contract_name
3360
- contract_address
3361
- contract_decimals
3362
- contract_ticker_symbol
3363
- }
3364
- quote_token {
3365
- contract_name
3366
- contract_address
3367
- contract_decimals
3368
- contract_ticker_symbol
3369
- }
3370
- price_deltas {
3371
- last_5m
3372
- last_1hr
3373
- last_6hr
3374
- last_24hr
3375
- }
3376
- swap_counts {
3377
- last_5m
3378
- last_1hr
3379
- last_6hr
3380
- last_24hr
3381
- }
3382
- }
3383
- }
2857
+ const query = `
2858
+ subscription {
2859
+ updatePairs(
2860
+ chain_name: ${params.chain_name}
2861
+ pair_addresses: [${pairAddressesString}]
2862
+ ) {
2863
+ chain_name
2864
+ pair_address
2865
+ timestamp
2866
+ quote_rate
2867
+ quote_rate_usd
2868
+ volume
2869
+ volume_usd
2870
+ market_cap
2871
+ liquidity
2872
+ base_token {
2873
+ contract_name
2874
+ contract_address
2875
+ contract_decimals
2876
+ contract_ticker_symbol
2877
+ }
2878
+ quote_token {
2879
+ contract_name
2880
+ contract_address
2881
+ contract_decimals
2882
+ contract_ticker_symbol
2883
+ }
2884
+ price_deltas {
2885
+ last_5m
2886
+ last_1hr
2887
+ last_6hr
2888
+ last_24hr
2889
+ }
2890
+ swap_counts {
2891
+ last_5m
2892
+ last_1hr
2893
+ last_6hr
2894
+ last_24hr
2895
+ }
2896
+ }
2897
+ }
3384
2898
  `;
3385
2899
  const client = StreamingWebSocketClient.getClient();
3386
2900
  return client.subscribe({
@@ -3402,7 +2916,12 @@ class StreamingService {
3402
2916
  });
3403
2917
  }
3404
2918
  /**
3405
- * Subscribe to real-time wallet activity including transactions, token transfers, and smart contract interactions
2919
+ *
2920
+ * The Wallet Activity stream provides real-time updates on wallet transactions, token transfers, and interactions with smart contracts . This documentation follows our standard Streaming API structure.
2921
+ *
2922
+ * **Credit Cost**: 0 per call
2923
+ *
2924
+ * **Beta**: This endpoint is in beta.
3406
2925
  *
3407
2926
  * @param params - Parameters for the wallet activity stream
3408
2927
  * @param callbacks - Subscription callbacks
@@ -3428,110 +2947,120 @@ class StreamingService {
3428
2947
  const walletAddressesString = params.wallet_addresses
3429
2948
  .map((addr) => `"${addr}"`)
3430
2949
  .join(", ");
3431
- const query = `
3432
- subscription {
3433
- walletTxs(
3434
- chain_name: ${params.chain_name},
3435
- wallet_addresses: [${walletAddressesString}]
3436
- ) {
3437
- tx_hash
3438
- from_address
3439
- to_address
3440
- value
3441
- chain_name
3442
- block_signed_at
3443
- block_height
3444
- block_hash
3445
- miner_address
3446
- gas_used
3447
- tx_offset
3448
- successful
3449
- decoded_type
3450
- decoded_details {
3451
- ... on TransferTransaction {
3452
- from
3453
- to
3454
- amount
3455
- quote_usd
3456
- quote_rate_usd
3457
- contract_metadata {
3458
- contract_name
3459
- contract_address
3460
- contract_decimals
3461
- contract_ticker_symbol
3462
- }
3463
- }
3464
- ... on SwapTransaction {
3465
- token_in
3466
- token_out
3467
- amount_in
3468
- amount_out
3469
- }
3470
- ... on BridgeTransaction {
3471
- type
3472
- typeString
3473
- from
3474
- to
3475
- amount
3476
- quote_usd
3477
- quote_rate_usd
3478
- contract_metadata {
3479
- contract_name
3480
- contract_address
3481
- contract_decimals
3482
- contract_ticker_symbol
3483
- }
3484
- }
3485
- ... on DepositTransaction {
3486
- from
3487
- to
3488
- amount
3489
- quote_usd
3490
- quote_rate_usd
3491
- contract_metadata {
3492
- contract_name
3493
- contract_address
3494
- contract_decimals
3495
- contract_ticker_symbol
3496
- }
3497
- }
3498
- ... on WithdrawTransaction {
3499
- from
3500
- to
3501
- amount
3502
- quote_usd
3503
- quote_rate_usd
3504
- contract_metadata {
3505
- contract_name
3506
- contract_address
3507
- contract_decimals
3508
- contract_ticker_symbol
3509
- }
3510
- }
3511
- ... on ApproveTransaction {
3512
- spender
3513
- amount
3514
- quote_usd
3515
- quote_rate_usd
3516
- contract_metadata {
3517
- contract_name
3518
- contract_address
3519
- contract_decimals
3520
- contract_ticker_symbol
3521
- }
3522
- }
3523
- ... on ErrorDetails {
3524
- message
3525
- }
3526
- }
3527
- logs {
3528
- emitter_address
3529
- log_offset
3530
- data
3531
- topics
3532
- }
3533
- }
3534
- }
2950
+ const query = `
2951
+ subscription {
2952
+ walletTxs(
2953
+ chain_name: ${params.chain_name},
2954
+ wallet_addresses: [${walletAddressesString}]
2955
+ ) {
2956
+ tx_hash
2957
+ from_address
2958
+ to_address
2959
+ value
2960
+ chain_name
2961
+ block_signed_at
2962
+ block_height
2963
+ block_hash
2964
+ miner_address
2965
+ gas_used
2966
+ tx_offset
2967
+ successful
2968
+ decoded_type
2969
+ decoded_details {
2970
+ ... on TransferTransaction {
2971
+ from
2972
+ to
2973
+ amount
2974
+ quote_usd
2975
+ quote_rate_usd
2976
+ contract_metadata {
2977
+ contract_name
2978
+ contract_address
2979
+ contract_decimals
2980
+ contract_ticker_symbol
2981
+ }
2982
+ }
2983
+ ... on SwapTransaction {
2984
+ token_in {
2985
+ contract_name
2986
+ contract_address
2987
+ contract_decimals
2988
+ contract_ticker_symbol
2989
+ }
2990
+ token_out {
2991
+ contract_name
2992
+ contract_address
2993
+ contract_decimals
2994
+ contract_ticker_symbol
2995
+ }
2996
+ amount_in
2997
+ amount_out
2998
+ }
2999
+ ... on BridgeTransaction {
3000
+ type
3001
+ typeString
3002
+ from
3003
+ to
3004
+ amount
3005
+ quote_usd
3006
+ quote_rate_usd
3007
+ contract_metadata {
3008
+ contract_name
3009
+ contract_address
3010
+ contract_decimals
3011
+ contract_ticker_symbol
3012
+ }
3013
+ }
3014
+ ... on DepositTransaction {
3015
+ from
3016
+ to
3017
+ amount
3018
+ quote_usd
3019
+ quote_rate_usd
3020
+ contract_metadata {
3021
+ contract_name
3022
+ contract_address
3023
+ contract_decimals
3024
+ contract_ticker_symbol
3025
+ }
3026
+ }
3027
+ ... on WithdrawTransaction {
3028
+ from
3029
+ to
3030
+ amount
3031
+ quote_usd
3032
+ quote_rate_usd
3033
+ contract_metadata {
3034
+ contract_name
3035
+ contract_address
3036
+ contract_decimals
3037
+ contract_ticker_symbol
3038
+ }
3039
+ }
3040
+ ... on ApproveTransaction {
3041
+ spender
3042
+ amount
3043
+ quote_usd
3044
+ quote_rate_usd
3045
+ contract_metadata {
3046
+ contract_name
3047
+ contract_address
3048
+ contract_decimals
3049
+ contract_ticker_symbol
3050
+ }
3051
+ }
3052
+ ... on ErrorDetails {
3053
+ message
3054
+ }
3055
+ }
3056
+ logs {
3057
+ emitter_address
3058
+ log_offset
3059
+ data
3060
+ topics
3061
+ }
3062
+ }
3063
+ }
3535
3064
  `;
3536
3065
  const client = StreamingWebSocketClient.getClient();
3537
3066
  return client.subscribe({
@@ -3552,12 +3081,193 @@ class StreamingService {
3552
3081
  complete: callbacks.complete || (() => { }),
3553
3082
  });
3554
3083
  }
3084
+ /**
3085
+ * Search for tokens by keyword, ticker, or contract address
3086
+ *
3087
+ * @param params - Parameters for the token search query
3088
+ * @returns Promise resolving to an array of matching tokens
3089
+ *
3090
+ * @example
3091
+ * ```typescript
3092
+ * const results = await streamingService.searchToken({
3093
+ * query: "PEPE"
3094
+ * });
3095
+ * console.log("Search Results:", results);
3096
+ * ```
3097
+ */
3098
+ searchToken(params) {
3099
+ const query = `
3100
+ query SearchToken($query: String!) {
3101
+ searchToken(query: $query) {
3102
+ pair_address
3103
+ chain_name
3104
+ quote_rate
3105
+ quote_rate_usd
3106
+ volume
3107
+ volume_usd
3108
+ market_cap
3109
+ base_token {
3110
+ contract_name
3111
+ contract_address
3112
+ contract_decimals
3113
+ contract_ticker_symbol
3114
+ }
3115
+ quote_token {
3116
+ contract_name
3117
+ contract_address
3118
+ contract_decimals
3119
+ contract_ticker_symbol
3120
+ }
3121
+ }
3122
+ }
3123
+ `;
3124
+ const client = StreamingWebSocketClient.getClient();
3125
+ return new Promise((resolve, reject) => {
3126
+ let result = [];
3127
+ client.subscribe({
3128
+ query,
3129
+ variables: { query: params.query },
3130
+ }, {
3131
+ next: (data) => {
3132
+ if (data.data) {
3133
+ result = data.data.searchToken ?? [];
3134
+ }
3135
+ else if (data.errors) {
3136
+ reject(data.errors);
3137
+ }
3138
+ },
3139
+ error: (err) => reject(err),
3140
+ complete: () => resolve(result),
3141
+ });
3142
+ });
3143
+ }
3144
+ /**
3145
+ * Get top trader wallets and their PnL for a specific token
3146
+ *
3147
+ * @param params - Parameters for the UPnL token query
3148
+ * @returns Promise resolving to an array of top trader wallet data
3149
+ *
3150
+ * @example
3151
+ * ```typescript
3152
+ * const traders = await streamingService.getUPnLForToken({
3153
+ * chain_name: StreamingChain.ETH_MAINNET,
3154
+ * token_address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
3155
+ * });
3156
+ * console.log("Top Traders:", traders);
3157
+ * ```
3158
+ */
3159
+ getUPnLForToken(params) {
3160
+ const query = `
3161
+ query {
3162
+ upnlForToken(
3163
+ chain_name: ${params.chain_name}
3164
+ token_address: "${params.token_address}"
3165
+ ) {
3166
+ token_address
3167
+ wallet_address
3168
+ volume
3169
+ transactions_count
3170
+ pnl_realized_usd
3171
+ balance
3172
+ balance_pretty
3173
+ pnl_unrealized_usd
3174
+ contract_metadata {
3175
+ contract_name
3176
+ contract_address
3177
+ contract_decimals
3178
+ contract_ticker_symbol
3179
+ }
3180
+ }
3181
+ }
3182
+ `;
3183
+ const client = StreamingWebSocketClient.getClient();
3184
+ return new Promise((resolve, reject) => {
3185
+ let result = [];
3186
+ client.subscribe({
3187
+ query,
3188
+ }, {
3189
+ next: (data) => {
3190
+ if (data.data) {
3191
+ result = data.data.upnlForToken ?? [];
3192
+ }
3193
+ else if (data.errors) {
3194
+ reject(data.errors);
3195
+ }
3196
+ },
3197
+ error: (err) => reject(err),
3198
+ complete: () => resolve(result),
3199
+ });
3200
+ });
3201
+ }
3202
+ /**
3203
+ * Get unrealized and realized PnL for all tokens held by a wallet
3204
+ *
3205
+ * @param params - Parameters for the UPnL wallet query
3206
+ * @returns Promise resolving to an array of token PnL data for the wallet
3207
+ *
3208
+ * @example
3209
+ * ```typescript
3210
+ * const pnl = await streamingService.getUPnLForWallet({
3211
+ * chain_name: StreamingChain.ETH_MAINNET,
3212
+ * wallet_address: "0xfe97b0C517a84F98fc6eDe3CD26B43012d31992a"
3213
+ * });
3214
+ * console.log("Wallet PnL:", pnl);
3215
+ * ```
3216
+ */
3217
+ getUPnLForWallet(params) {
3218
+ const query = `
3219
+ query {
3220
+ upnlForWallet(
3221
+ chain_name: ${params.chain_name}
3222
+ wallet_address: "${params.wallet_address}"
3223
+ ) {
3224
+ token_address
3225
+ cost_basis
3226
+ current_price
3227
+ pnl_realized_usd
3228
+ pnl_unrealized_usd
3229
+ net_balance_change
3230
+ marketcap_usd
3231
+ contract_metadata {
3232
+ contract_name
3233
+ contract_address
3234
+ contract_decimals
3235
+ contract_ticker_symbol
3236
+ }
3237
+ }
3238
+ }
3239
+ `;
3240
+ const client = StreamingWebSocketClient.getClient();
3241
+ return new Promise((resolve, reject) => {
3242
+ let result = [];
3243
+ client.subscribe({
3244
+ query,
3245
+ }, {
3246
+ next: (data) => {
3247
+ if (data.data) {
3248
+ result = data.data.upnlForWallet ?? [];
3249
+ }
3250
+ else if (data.errors) {
3251
+ reject(data.errors);
3252
+ }
3253
+ },
3254
+ error: (err) => reject(err),
3255
+ complete: () => resolve(result),
3256
+ });
3257
+ });
3258
+ }
3555
3259
  }
3556
3260
  /**
3557
3261
  * Singleton WebSocket Client for GoldRush Streaming
3558
3262
  *
3559
3263
  */
3560
3264
  class StreamingWebSocketClient {
3265
+ static apiKey;
3266
+ static instance = null;
3267
+ static client = null;
3268
+ static connected = false;
3269
+ static reconnectAttempts = 0;
3270
+ static config;
3561
3271
  constructor() { }
3562
3272
  static getInstance() {
3563
3273
  if (!StreamingWebSocketClient.instance) {
@@ -3581,6 +3291,7 @@ class StreamingWebSocketClient {
3581
3291
  return;
3582
3292
  StreamingWebSocketClient.client = createClient({
3583
3293
  url: "wss://gr-staging-v2.streaming.covalenthq.com/graphql",
3294
+ lazyCloseTimeout: 3000,
3584
3295
  connectionParams: {
3585
3296
  GOLDRUSH_API_KEY: StreamingWebSocketClient.apiKey,
3586
3297
  },
@@ -3621,22 +3332,21 @@ class StreamingWebSocketClient {
3621
3332
  await new Promise((resolve) => setTimeout(resolve, 1000));
3622
3333
  }
3623
3334
  }
3624
- StreamingWebSocketClient.instance = null;
3625
- StreamingWebSocketClient.client = null;
3626
- StreamingWebSocketClient.connected = false;
3627
- StreamingWebSocketClient.reconnectAttempts = 0;
3628
3335
 
3629
3336
  /**
3630
3337
  * Transactions API
3631
3338
  *
3632
3339
  */
3633
3340
  class TransactionService {
3341
+ execution;
3634
3342
  constructor(execution) {
3635
3343
  this.execution = execution;
3636
3344
  }
3637
3345
  /**
3638
3346
  *
3639
- * Commonly used to fetch and render a single transaction including its decoded log events.
3347
+ * Used to fetch and render a single transaction including its decoded event logs. For foundational chains, can also retrieve internal transactions, state changes and method ID where available.
3348
+ *
3349
+ * **Credit Cost**: 0.1 per call
3640
3350
  *
3641
3351
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3642
3352
  * @param {string} txHash - The transaction hash.
@@ -3701,13 +3411,16 @@ class TransactionService {
3701
3411
  }
3702
3412
  /**
3703
3413
  *
3704
- * 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.
3414
+ * Used to fetch the earliest and latest transactions, and the transaction count for a wallet. Also enriched with gas expenditure details and total ERC20 token transfers count.
3415
+ *
3416
+ * **Credit Cost**: 1 per call
3705
3417
  *
3706
3418
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3707
3419
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3708
3420
  * @param {GetTransactionSummaryQueryParamOpts} queryParamOpts
3709
3421
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
3710
3422
  * - `withGas`: Include gas summary details. Additional charge of 1 credit when true. Response times may be impacted for wallets with millions of transactions.
3423
+ * - `withTransferCount`: Represents the total count of ERC-20 token movement events, including `Transfer`, `Deposit` and `Withdraw`. Response times may be impacted for wallets with large number of transactions. Additional charge of 3 credits.
3711
3424
  *
3712
3425
  */
3713
3426
  async getTransactionSummary(chainName, walletAddress, queryParamOpts) {
@@ -3720,6 +3433,10 @@ class TransactionService {
3720
3433
  key: "with-gas",
3721
3434
  value: queryParamOpts?.withGas,
3722
3435
  },
3436
+ {
3437
+ key: "with-transfer-count",
3438
+ value: queryParamOpts?.withTransferCount,
3439
+ },
3723
3440
  ]);
3724
3441
  const parseData = (data) => {
3725
3442
  if (data.data) {
@@ -3731,14 +3448,18 @@ class TransactionService {
3731
3448
  ...txsItem,
3732
3449
  earliest_transaction: {
3733
3450
  ...txsItem.earliest_transaction,
3734
- block_signed_at: txsItem?.earliest_transaction?.block_signed_at
3735
- ? new Date(txsItem.earliest_transaction.block_signed_at)
3451
+ block_signed_at: txsItem?.earliest_transaction
3452
+ ?.block_signed_at
3453
+ ? new Date(txsItem.earliest_transaction
3454
+ .block_signed_at)
3736
3455
  : null,
3737
3456
  },
3738
3457
  latest_transaction: {
3739
3458
  ...txsItem.latest_transaction,
3740
- block_signed_at: txsItem?.latest_transaction?.block_signed_at
3741
- ? new Date(txsItem?.latest_transaction?.block_signed_at)
3459
+ block_signed_at: txsItem?.latest_transaction
3460
+ ?.block_signed_at
3461
+ ? new Date(txsItem?.latest_transaction
3462
+ ?.block_signed_at)
3742
3463
  : null,
3743
3464
  },
3744
3465
  // ? API vs docs non-consistent
@@ -3816,6 +3537,8 @@ class TransactionService {
3816
3537
  *
3817
3538
  * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
3818
3539
  *
3540
+ * **Credit Cost**: 0.1 per item
3541
+ *
3819
3542
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3820
3543
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3821
3544
  * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
@@ -3888,6 +3611,8 @@ class TransactionService {
3888
3611
  *
3889
3612
  * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
3890
3613
  *
3614
+ * **Credit Cost**: 0.1 per item
3615
+ *
3891
3616
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3892
3617
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3893
3618
  * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
@@ -4082,6 +3807,8 @@ class TransactionService {
4082
3807
  *
4083
3808
  * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
4084
3809
  *
3810
+ * **Credit Cost**: 0.1 per item
3811
+ *
4085
3812
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
4086
3813
  * @param {number} blockHeight - The requested block height.
4087
3814
  * @param {number} page - The requested page, 0-indexed.
@@ -4140,6 +3867,8 @@ class TransactionService {
4140
3867
  *
4141
3868
  * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
4142
3869
  *
3870
+ * **Credit Cost**: 0.1 per item
3871
+ *
4143
3872
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
4144
3873
  * @param {string} blockHash - The requested block hash.
4145
3874
  * @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
@@ -4187,12 +3916,6 @@ class TransactionService {
4187
3916
  };
4188
3917
  return await this.execution.execute(endpoint, parseData);
4189
3918
  }
4190
- /**
4191
- * @deprecated This method has been deprecated and will be removed in future releases. Use `getPaginatedTransactionsForAddress` instead.
4192
- */
4193
- async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
4194
- return this.getPaginatedTransactionsForAddress(chainName, walletAddress, page, queryParamOpts);
4195
- }
4196
3919
  }
4197
3920
 
4198
3921
  async function debugOutput(settings, ...content) {
@@ -4350,6 +4073,12 @@ var pLimit_1 = pLimit;
4350
4073
  var pLimit$1 = /*@__PURE__*/getDefaultExportFromCjs(pLimit_1);
4351
4074
 
4352
4075
  class Execution {
4076
+ settings;
4077
+ headers;
4078
+ maxRetries;
4079
+ retryDelay;
4080
+ enableRetry;
4081
+ processes;
4353
4082
  constructor(settings, headers) {
4354
4083
  this.settings = settings;
4355
4084
  this.headers = headers;
@@ -4385,9 +4114,10 @@ class Execution {
4385
4114
  };
4386
4115
  }
4387
4116
  catch (error) {
4117
+ const err = error;
4388
4118
  debugOutput(this.settings, `Request URL: ${endpoint} | Retry Enabled: ${this.enableRetry} | Retry Count: ${retryCount} | Max Retries: ${this.maxRetries} | Retry Delay: ${this.retryDelay}ms`, error);
4389
4119
  if (this.enableRetry &&
4390
- (error?.error_code === 429 || error?.cause?.code === 429)) {
4120
+ (err?.error_code === 429 || err?.cause?.code === 429)) {
4391
4121
  if (retryCount >= this.maxRetries) {
4392
4122
  completed = true;
4393
4123
  return {
@@ -4408,9 +4138,9 @@ class Execution {
4408
4138
  return {
4409
4139
  data: null,
4410
4140
  error: true,
4411
- error_code: error?.cause?.code || error?.error_code || 500,
4412
- error_message: error?.cause?.message ||
4413
- error?.error_message ||
4141
+ error_code: err?.cause?.code || err?.error_code || 500,
4142
+ error_message: err?.cause?.message ||
4143
+ err?.error_message ||
4414
4144
  "Internal server error",
4415
4145
  };
4416
4146
  }
@@ -4435,8 +4165,17 @@ const isValidApiKey = (apiKey) => {
4435
4165
  * GoldRushClient Class
4436
4166
  */
4437
4167
  class GoldRushClient {
4168
+ userAgent = `com.covalenthq.sdk.typescript/${version}`;
4169
+ AllChainsService;
4170
+ BalanceService;
4171
+ BaseService;
4172
+ BitcoinService;
4173
+ NftService;
4174
+ PricingService;
4175
+ SecurityService;
4176
+ StreamingService;
4177
+ TransactionService;
4438
4178
  constructor(apiKey, settings = {}, streamingConfig = {}) {
4439
- this.userAgent = `com.covalenthq.sdk.typescript/${version}`;
4440
4179
  const validKey = isValidApiKey(apiKey);
4441
4180
  if (!validKey) {
4442
4181
  throw {
@@ -5650,7 +5389,10 @@ exports.StreamingChain = void 0;
5650
5389
  StreamingChain["ETH_MAINNET"] = "ETH_MAINNET";
5651
5390
  StreamingChain["BSC_MAINNET"] = "BSC_MAINNET";
5652
5391
  StreamingChain["HYPERCORE_MAINNET"] = "HYPERCORE_MAINNET";
5392
+ StreamingChain["HYPEREVM_MAINNET"] = "HYPEREVM_MAINNET";
5653
5393
  StreamingChain["MONAD_MAINNET"] = "MONAD_MAINNET";
5394
+ StreamingChain["POLYGON_MAINNET"] = "POLYGON_MAINNET";
5395
+ StreamingChain["MEGAETH_MAINNET"] = "MEGAETH_MAINNET";
5654
5396
  })(exports.StreamingChain || (exports.StreamingChain = {}));
5655
5397
  exports.StreamingInterval = void 0;
5656
5398
  (function (StreamingInterval) {
@@ -5678,9 +5420,8 @@ exports.StreamingProtocol = void 0;
5678
5420
  (function (StreamingProtocol) {
5679
5421
  StreamingProtocol["UNISWAP_V2"] = "UNISWAP_V2";
5680
5422
  StreamingProtocol["UNISWAP_V3"] = "UNISWAP_V3";
5681
- // UNISWAP_V4 = "UNISWAP_V4",
5682
5423
  StreamingProtocol["VIRTUALS_V2"] = "VIRTUALS_V2";
5683
- StreamingProtocol["CLANKER_V3"] = "CLANKER_V3";
5424
+ StreamingProtocol["CLANKER_V3"] = "CLANKER";
5684
5425
  StreamingProtocol["RAYDIUM_AMM"] = "RAYDIUM_AMM";
5685
5426
  StreamingProtocol["RAYDIUM_CLMM"] = "RAYDIUM_CLMM";
5686
5427
  StreamingProtocol["RAYDIUM_CPMM"] = "RAYDIUM_CPMM";
@@ -5697,7 +5438,12 @@ exports.StreamingProtocol = void 0;
5697
5438
  StreamingProtocol["SHADOW_V3"] = "SHADOW_V3";
5698
5439
  StreamingProtocol["OCTOSWAP_V2"] = "OCTOSWAP_V2";
5699
5440
  StreamingProtocol["OCTOSWAP_V3"] = "OCTOSWAP_V3";
5700
- // CROCSWAP = "CROCSWAP",
5441
+ StreamingProtocol["QUICKSWAP_V2"] = "QUICKSWAP_V2";
5442
+ StreamingProtocol["QUICKSWAP_V3"] = "QUICKSWAP_V3";
5443
+ StreamingProtocol["SUSHISWAP_V2"] = "SUSHISWAP_V2";
5444
+ StreamingProtocol["PROJECT_X"] = "PROJECT_X";
5445
+ StreamingProtocol["KUMBAYA_V1"] = "KUMBAYA_V1";
5446
+ StreamingProtocol["JOE_V2"] = "JOE_V2";
5701
5447
  })(exports.StreamingProtocol || (exports.StreamingProtocol = {}));
5702
5448
 
5703
5449
  exports.GoldRushClient = GoldRushClient;