@covalenthq/client-sdk 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +3 -2
  2. package/dist/cjs/index.js +111 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BaseService.d.ts +17 -0
  5. package/dist/cjs/services/CovalentClient.d.ts +3 -3
  6. package/dist/cjs/services/TransactionService.d.ts +48 -0
  7. package/dist/cjs/util/types/BaseServiceTypes.d.ts +16 -0
  8. package/dist/cjs/util/types/TransactionServiceTypes.d.ts +17 -0
  9. package/dist/es/index.js +111 -1
  10. package/dist/es/index.js.map +1 -1
  11. package/dist/es/services/BaseService.d.ts +17 -0
  12. package/dist/es/services/CovalentClient.d.ts +3 -3
  13. package/dist/es/services/TransactionService.d.ts +48 -0
  14. package/dist/es/util/types/BaseServiceTypes.d.ts +16 -0
  15. package/dist/es/util/types/TransactionServiceTypes.d.ts +17 -0
  16. package/dist/esm/index.js +111 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/services/BaseService.d.ts +17 -0
  19. package/dist/esm/services/CovalentClient.d.ts +3 -3
  20. package/dist/esm/services/TransactionService.d.ts +48 -0
  21. package/dist/esm/util/types/BaseServiceTypes.d.ts +16 -0
  22. package/dist/esm/util/types/TransactionServiceTypes.d.ts +17 -0
  23. package/dist/services/BaseService.d.ts +17 -0
  24. package/dist/services/BaseService.js +11 -0
  25. package/dist/services/BaseService.js.map +1 -1
  26. package/dist/services/CovalentClient.d.ts +3 -3
  27. package/dist/services/CovalentClient.js +1 -1
  28. package/dist/services/TransactionService.d.ts +48 -0
  29. package/dist/services/TransactionService.js +93 -0
  30. package/dist/services/TransactionService.js.map +1 -1
  31. package/dist/util/types/BaseServiceTypes.d.ts +16 -0
  32. package/dist/util/types/TransactionServiceTypes.d.ts +17 -0
  33. package/package.json +2 -1
package/README.md CHANGED
@@ -92,7 +92,7 @@ The `BalanceService` class refers to the [balances API endpoints](https://www.co
92
92
  - `getHistoricalTokenBalancesForWalletAddress()`: 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.
93
93
  - `getHistoricalPortfolioForWalletAddress()`: Render a daily portfolio balance for an address broken down by the token. The timeframe is user-configurable, defaults to 30 days.
94
94
  - `getErc20TransfersForWalletAddress()`: Render the transfer-in and transfer-out of a token along with historical prices from an address. (Paginated)
95
- - `getErc20TransfersForWalletAddressByPage()`: Render the transfer-in and transfer-out of a token along with historical prices from an address. (By page)
95
+ - `getErc20TransfersForWalletAddressByPage()`: Render the transfer-in and transfer-out of a token along with historical prices from an address. (NonPaginated)
96
96
  - `getTokenHoldersV2ForTokenAddress()`: 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.
97
97
  - `getNativeTokenBalance()`: Get the native token balance for an address. This endpoint is required because native tokens are usually not ERC20 tokens and sometimes you want something lightweight.
98
98
 
@@ -138,7 +138,8 @@ The `PricingService` class refers to the [historical token prices API endpoint](
138
138
 
139
139
  The `TransactionService` class refers to the [transactions API endpoints](https://www.covalenthq.com/docs/api/transactions/get-a-transaction/):
140
140
 
141
- - `getAllTransactionsForAddress()`: Fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
141
+ - `getAllTransactionsForAddress()`: Fetch and render the most recent transactions involving an address. Frequently seen in wallet applications. (Paginated)
142
+ - `getTransactionsForAddressV3()`: Fetch and render the most recent transactions involving an address. Frequently seen in wallet applications. (Nonpaginated)
142
143
  - `getTransaction()`: Fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
143
144
  - `getTransactionsForBlock()`: Fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
144
145
  - `getTransactionSummary()`: 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.
package/dist/cjs/index.js CHANGED
@@ -1377,9 +1377,20 @@ class ChainItem {
1377
1377
  this.black_logo_url = data.black_logo_url;
1378
1378
  this.white_logo_url = data.white_logo_url;
1379
1379
  this.is_appchain = data.is_appchain;
1380
+ this.color_theme = data.color_theme && data.color_theme !== null ? new ColorTheme(data.color_theme) : null;
1380
1381
  this.appchain_of = data.appchain_of && data.appchain_of !== null ? new ChainItem(data.appchain_of) : null;
1381
1382
  }
1382
1383
  }
1384
+ class ColorTheme {
1385
+ constructor(data) {
1386
+ this.red = data.red;
1387
+ this.green = data.green;
1388
+ this.blue = data.blue;
1389
+ this.alpha = data.alpha;
1390
+ this.hex = data.hex;
1391
+ this.css_rgb = data.css_rgb;
1392
+ }
1393
+ }
1383
1394
  class AllChainsStatusResponse {
1384
1395
  constructor(data) {
1385
1396
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
@@ -3473,6 +3484,12 @@ class Param {
3473
3484
  this.value = data.value;
3474
3485
  }
3475
3486
  }
3487
+ class PaginationLinks {
3488
+ constructor(data) {
3489
+ this.prev = data.prev;
3490
+ this.next = data.next;
3491
+ }
3492
+ }
3476
3493
  class TransactionsBlockResponse {
3477
3494
  constructor(data) {
3478
3495
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
@@ -3504,6 +3521,18 @@ class TransactionSummary {
3504
3521
  this.tx_detail_link = data.tx_detail_link;
3505
3522
  }
3506
3523
  }
3524
+ class TransactionsResponse {
3525
+ constructor(data) {
3526
+ this.address = data.address;
3527
+ this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
3528
+ this.quote_currency = data.quote_currency;
3529
+ this.chain_id = data.chain_id;
3530
+ this.chain_name = data.chain_name;
3531
+ this.current_page = data.current_page;
3532
+ this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
3533
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
3534
+ }
3535
+ }
3507
3536
  /**
3508
3537
  * Transactions APIs
3509
3538
  *
@@ -3842,6 +3871,87 @@ class TransactionService {
3842
3871
  }
3843
3872
  }
3844
3873
  }
3874
+ /**
3875
+ *
3876
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
3877
+ * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3878
+ * @param {number} page - The requested page, 0-indexed.
3879
+ * @param {GetTransactionsForAddressV3QueryParamOpts} queryParamOpts
3880
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
3881
+ * - `noLogs`: Omit log events.
3882
+ * - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
3883
+ * - `withSafe`: Include safe details.
3884
+ *
3885
+ */
3886
+ async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
3887
+ let success = false;
3888
+ let data;
3889
+ let response;
3890
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
3891
+ while (!success) {
3892
+ try {
3893
+ const urlParams = new URLSearchParams();
3894
+ if (queryParamOpts?.quoteCurrency !== undefined) {
3895
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
3896
+ }
3897
+ if (queryParamOpts?.noLogs !== undefined) {
3898
+ urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
3899
+ }
3900
+ if (queryParamOpts?.blockSignedAtAsc !== undefined) {
3901
+ urlParams.append("block-signed-at-asc", queryParamOpts?.blockSignedAtAsc.toString());
3902
+ }
3903
+ if (queryParamOpts?.withSafe !== undefined) {
3904
+ urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
3905
+ }
3906
+ let startTime;
3907
+ if (this.debug) {
3908
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
3909
+ }
3910
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
3911
+ headers: {
3912
+ "Authorization": `Bearer ${this.apiKey}`,
3913
+ "X-Requested-With": userAgent
3914
+ }
3915
+ });
3916
+ debugOutput(response.url, response.status, startTime);
3917
+ if (response.status === 429) {
3918
+ try {
3919
+ data = await this.LIMIT(() => backoff.backOff(response.url));
3920
+ }
3921
+ catch (error) {
3922
+ success = true;
3923
+ return {
3924
+ data: null,
3925
+ error: true,
3926
+ error_code: response.status,
3927
+ error_message: error.message
3928
+ };
3929
+ }
3930
+ }
3931
+ else {
3932
+ data = await response.json();
3933
+ }
3934
+ const dataClass = new TransactionsResponse(data.data);
3935
+ checkAndModifyResponse(dataClass);
3936
+ success = true;
3937
+ return {
3938
+ data: dataClass,
3939
+ error: data.error,
3940
+ error_code: data ? data.error_code : response.status,
3941
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
3942
+ };
3943
+ }
3944
+ catch (error) {
3945
+ success = true;
3946
+ return {
3947
+ data: null,
3948
+ error: true,
3949
+ error_code: data ? data.error_code : response.status,
3950
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
3951
+ };
3952
+ }
3953
+ }
3954
+ }
3845
3955
  }
3846
3956
 
3847
3957
  class PoolResponse {
@@ -5186,7 +5296,7 @@ class XykService {
5186
5296
  }
5187
5297
  }
5188
5298
 
5189
- const userAgent = "com.covalenthq.sdk.typescript/0.5.0";
5299
+ const userAgent = "com.covalenthq.sdk.typescript/0.5.2";
5190
5300
  /**
5191
5301
  * CovalentClient Class
5192
5302
  */