@covalenthq/client-sdk 0.7.5 → 0.8.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.
Files changed (76) hide show
  1. package/README.md +25 -0
  2. package/dist/cjs/index.js +1183 -451
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BalanceService.d.ts +15 -13
  5. package/dist/cjs/services/BaseService.d.ts +13 -11
  6. package/dist/cjs/services/CovalentClient.d.ts +8 -4
  7. package/dist/cjs/services/NftService.d.ts +19 -17
  8. package/dist/cjs/services/PricingService.d.ts +5 -3
  9. package/dist/cjs/services/SecurityService.d.ts +6 -4
  10. package/dist/cjs/services/TransactionService.d.ts +83 -12
  11. package/dist/cjs/services/XykService.d.ts +287 -22
  12. package/dist/cjs/util/ApiHelpers.d.ts +2 -1
  13. package/dist/cjs/util/backoff.d.ts +2 -1
  14. package/dist/cjs/util/types/TransactionServiceTypes.d.ts +11 -0
  15. package/dist/cjs/util/types/XykServiceTypes.d.ts +160 -8
  16. package/dist/es/index.js +1183 -451
  17. package/dist/es/index.js.map +1 -1
  18. package/dist/es/services/BalanceService.d.ts +15 -13
  19. package/dist/es/services/BaseService.d.ts +13 -11
  20. package/dist/es/services/CovalentClient.d.ts +8 -4
  21. package/dist/es/services/NftService.d.ts +19 -17
  22. package/dist/es/services/PricingService.d.ts +5 -3
  23. package/dist/es/services/SecurityService.d.ts +6 -4
  24. package/dist/es/services/TransactionService.d.ts +83 -12
  25. package/dist/es/services/XykService.d.ts +287 -22
  26. package/dist/es/util/ApiHelpers.d.ts +2 -1
  27. package/dist/es/util/backoff.d.ts +2 -1
  28. package/dist/es/util/types/TransactionServiceTypes.d.ts +11 -0
  29. package/dist/es/util/types/XykServiceTypes.d.ts +160 -8
  30. package/dist/esm/index.js +1183 -451
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/services/BalanceService.d.ts +15 -13
  33. package/dist/esm/services/BaseService.d.ts +13 -11
  34. package/dist/esm/services/CovalentClient.d.ts +8 -4
  35. package/dist/esm/services/NftService.d.ts +19 -17
  36. package/dist/esm/services/PricingService.d.ts +5 -3
  37. package/dist/esm/services/SecurityService.d.ts +6 -4
  38. package/dist/esm/services/TransactionService.d.ts +83 -12
  39. package/dist/esm/services/XykService.d.ts +287 -22
  40. package/dist/esm/util/ApiHelpers.d.ts +2 -1
  41. package/dist/esm/util/backoff.d.ts +2 -1
  42. package/dist/esm/util/types/TransactionServiceTypes.d.ts +11 -0
  43. package/dist/esm/util/types/XykServiceTypes.d.ts +160 -8
  44. package/dist/services/BalanceService.d.ts +15 -13
  45. package/dist/services/BalanceService.js +47 -39
  46. package/dist/services/BalanceService.js.map +1 -1
  47. package/dist/services/BaseService.d.ts +13 -11
  48. package/dist/services/BaseService.js +77 -65
  49. package/dist/services/BaseService.js.map +1 -1
  50. package/dist/services/CovalentClient.d.ts +8 -4
  51. package/dist/services/CovalentClient.js +19 -19
  52. package/dist/services/CovalentClient.js.map +1 -1
  53. package/dist/services/NftService.d.ts +19 -17
  54. package/dist/services/NftService.js +96 -81
  55. package/dist/services/NftService.js.map +1 -1
  56. package/dist/services/PricingService.d.ts +5 -3
  57. package/dist/services/PricingService.js +10 -7
  58. package/dist/services/PricingService.js.map +1 -1
  59. package/dist/services/SecurityService.d.ts +6 -4
  60. package/dist/services/SecurityService.js +17 -13
  61. package/dist/services/SecurityService.js.map +1 -1
  62. package/dist/services/TransactionService.d.ts +83 -12
  63. package/dist/services/TransactionService.js +434 -90
  64. package/dist/services/TransactionService.js.map +1 -1
  65. package/dist/services/XykService.d.ts +287 -22
  66. package/dist/services/XykService.js +438 -93
  67. package/dist/services/XykService.js.map +1 -1
  68. package/dist/util/ApiHelpers.d.ts +2 -1
  69. package/dist/util/ApiHelpers.js +7 -6
  70. package/dist/util/ApiHelpers.js.map +1 -1
  71. package/dist/util/backoff.d.ts +2 -1
  72. package/dist/util/backoff.js +3 -3
  73. package/dist/util/backoff.js.map +1 -1
  74. package/dist/util/types/TransactionServiceTypes.d.ts +11 -0
  75. package/dist/util/types/XykServiceTypes.d.ts +160 -8
  76. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Pagination } from "./GenericTypes";
1
+ import { Pagination, ContractMetadata } from "./GenericTypes";
2
2
  export interface PoolResponse {
3
3
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
4
4
  updated_at: Date;
@@ -232,6 +232,8 @@ export interface PoolsDexDataItem {
232
232
  volume_7d_quote: number;
233
233
  /** * The fee 24h converted to fiat in `quote-currency`. */
234
234
  fee_24h_quote: number;
235
+ /** * The annual fee percentage. */
236
+ annualized_fee: number;
235
237
  /** * A prettier version of the volume 24h quote for rendering purposes. */
236
238
  pretty_volume_24h_quote: string;
237
239
  /** * A prettier version of the volume 7d quote for rendering purposes. */
@@ -288,6 +290,8 @@ export interface UniswapLikeToken {
288
290
  /** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
289
291
  balance: bigint | null;
290
292
  quote: number;
293
+ /** * A prettier version of the quote for rendering purposes. */
294
+ pretty_quote: string;
291
295
  /** * The exchange rate for the requested quote currency. */
292
296
  quote_rate: number;
293
297
  }
@@ -303,6 +307,8 @@ export interface UniswapLikeTokenWithSupply {
303
307
  /** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
304
308
  balance: bigint | null;
305
309
  quote: number;
310
+ /** * A prettier version of the quote for rendering purposes. */
311
+ pretty_quote: string;
306
312
  /** * The exchange rate for the requested quote currency. */
307
313
  quote_rate: number;
308
314
  /** * Total supply of this pool token. */
@@ -357,6 +363,108 @@ export interface TokenV2Volume {
357
363
  /** * The total volume 24h converted to fiat in `quote-currency`. */
358
364
  total_volume_24h_quote: number;
359
365
  }
366
+ export interface NetworkExchangeTokenViewResponse {
367
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
368
+ updated_at: Date;
369
+ /** * The requested chain ID eg: `1`. */
370
+ chain_id: number;
371
+ /** * The requested chain name eg: `eth-mainnet`. */
372
+ chain_name: string;
373
+ /** * List of response items. */
374
+ items: TokenV2VolumeWithChartData[];
375
+ /** * Pagination metadata. */
376
+ pagination: Pagination;
377
+ }
378
+ export interface TokenV2VolumeWithChartData {
379
+ /** * The requested chain name eg: `eth-mainnet`. */
380
+ chain_name: string;
381
+ /** * The requested chain ID eg: `1`. */
382
+ chain_id: string;
383
+ /** * The name of the DEX, eg: `uniswap_v2`. */
384
+ dex_name: string;
385
+ /** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
386
+ contract_address: string;
387
+ /** * The string returned by the `name()` method. */
388
+ contract_name: string;
389
+ /** * The total liquidity unscaled value. */
390
+ total_liquidity: number;
391
+ /** * The total volume 24h unscaled value. */
392
+ total_volume_24h: number;
393
+ /** * The contract logo URL. */
394
+ logo_url: string;
395
+ /** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
396
+ contract_ticker_symbol: string;
397
+ /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
398
+ contract_decimals: number;
399
+ /** * The total amount of swaps in the last 24h. */
400
+ swap_count_24h: number;
401
+ /** * The exchange rate for the requested quote currency. */
402
+ quote_rate: number;
403
+ /** * The 24h exchange rate for the requested quote currency. */
404
+ quote_rate_24h: number;
405
+ /** * A prettier version of the exchange rate for rendering purposes. */
406
+ pretty_quote_rate: string;
407
+ /** * A prettier version of the 24h exchange rate for rendering purposes. */
408
+ pretty_quote_rate_24h: string;
409
+ /** * A prettier version of the total liquidity quote for rendering purposes. */
410
+ pretty_total_liquidity_quote: string;
411
+ /** * A prettier version of the 24h volume quote for rendering purposes. */
412
+ pretty_total_volume_24h_quote: string;
413
+ /** * The total liquidity converted to fiat in `quote-currency`. */
414
+ total_liquidity_quote: number;
415
+ /** * The total volume 24h converted to fiat in `quote-currency`. */
416
+ total_volume_24h_quote: number;
417
+ /** * The number of transactions in the last 24h. */
418
+ transactions_24h: number;
419
+ volume_timeseries_7d: VolumeTokenTimeseries[];
420
+ volume_timeseries_30d: VolumeTokenTimeseries[];
421
+ liquidity_timeseries_7d: LiquidityTokenTimeseries[];
422
+ liquidity_timeseries_30d: LiquidityTokenTimeseries[];
423
+ price_timeseries_7d: PriceTokenTimeseries[];
424
+ price_timeseries_30d: PriceTokenTimeseries[];
425
+ }
426
+ export interface VolumeTokenTimeseries {
427
+ /** * The name of the DEX, eg: `uniswap_v2`. */
428
+ dex_name: string;
429
+ /** * The requested chain ID eg: `1`. */
430
+ chain_id: string;
431
+ /** * The current date. */
432
+ dt: string;
433
+ /** * The total volume unscaled for this day. */
434
+ total_volume: string;
435
+ /** * The volume in `quote-currency` denomination. */
436
+ volume_quote: number;
437
+ /** * A prettier version of the volume quote for rendering purposes. */
438
+ pretty_volume_quote: string;
439
+ }
440
+ export interface LiquidityTokenTimeseries {
441
+ /** * The name of the DEX, eg: `uniswap_v2`. */
442
+ dex_name: string;
443
+ /** * The requested chain ID eg: `1`. */
444
+ chain_id: string;
445
+ /** * The current date. */
446
+ dt: string;
447
+ /** * The total liquidity unscaled up to this day. */
448
+ total_liquidity: string;
449
+ /** * The liquidity in `quote-currency` denomination. */
450
+ liquidity_quote: number;
451
+ /** * A prettier version of the liquidity quote for rendering purposes. */
452
+ pretty_liquidity_quote: string;
453
+ }
454
+ export interface PriceTokenTimeseries {
455
+ /** * The name of the DEX, eg: `uniswap_v2`. */
456
+ dex_name: string;
457
+ /** * The requested chain ID eg: `1`. */
458
+ chain_id: string;
459
+ /** * The current date. */
460
+ dt: string;
461
+ /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
462
+ quote_currency: string;
463
+ /** * The exchange rate for the requested quote currency. */
464
+ quote_rate: number;
465
+ /** * A prettier version of the exchange rate for rendering purposes. */
466
+ pretty_quote_rate: string;
467
+ }
360
468
  export interface SupportedDexesResponse {
361
469
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
362
470
  updated_at: Date;
@@ -409,6 +517,30 @@ export interface ExchangeTransaction {
409
517
  total_quote: number;
410
518
  /** * A prettier version of the total quote for rendering purposes. */
411
519
  pretty_total_quote: string;
520
+ /** * The value attached to this tx. */
521
+ value: bigint | null;
522
+ /** * The value attached in `quote-currency` to this tx. */
523
+ value_quote: number;
524
+ /** * A prettier version of the quote for rendering purposes. */
525
+ pretty_value_quote: string;
526
+ /** * The requested chain native gas token metadata. */
527
+ gas_metadata: ContractMetadata;
528
+ /** * The amount of gas supplied for this tx. */
529
+ gas_offered: string;
530
+ /** * The gas spent for this tx. */
531
+ gas_spent: string;
532
+ /** * The gas price at the time of this tx. */
533
+ gas_price: string;
534
+ /** * The total transaction fees (`gas_price` * `gas_spent`) paid for this tx, denoted in wei. */
535
+ fees_paid: bigint | null;
536
+ /** * The gas spent in `quote-currency` denomination. */
537
+ gas_quote: number;
538
+ /** * A prettier version of the quote for rendering purposes. */
539
+ pretty_gas_quote: string;
540
+ /** * The native gas exchange rate for the requested `quote-currency`. */
541
+ gas_quote_rate: number;
542
+ /** * The requested quote currency eg: `USD`. */
543
+ quote_currency: string;
412
544
  token_0: PoolToken;
413
545
  token_1: PoolToken;
414
546
  token_0_quote_rate: number;
@@ -452,6 +584,18 @@ export interface TransactionsForExchangeResponse {
452
584
  /** * Pagination metadata. */
453
585
  pagination: Pagination;
454
586
  }
587
+ export interface NetworkTransactionsResponse {
588
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
589
+ updated_at: Date;
590
+ /** * The requested chain ID eg: `1`. */
591
+ chain_id: number;
592
+ /** * The requested chain name eg: `eth-mainnet`. */
593
+ chain_name: string;
594
+ /** * List of response items. */
595
+ items: ExchangeTransaction[];
596
+ /** * Pagination metadata. */
597
+ pagination: Pagination;
598
+ }
455
599
  export interface EcosystemChartDataResponse {
456
600
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
457
601
  updated_at: Date;
@@ -472,13 +616,17 @@ export interface UniswapLikeEcosystemCharts {
472
616
  /** * The requested quote currency eg: `USD`. */
473
617
  quote_currency: string;
474
618
  gas_token_price_quote: number;
475
- total_swaps24h: number;
476
- total_active_pairs7d: number;
477
- total_fees24h: number;
478
- volume_chart7d: VolumeEcosystemChart[];
479
- volume_chart30d: VolumeEcosystemChart[];
480
- liquidity_chart7d: LiquidityEcosystemChart[];
481
- liquidity_chart30d: LiquidityEcosystemChart[];
619
+ total_swaps_24h: number;
620
+ total_active_pairs_7d: number;
621
+ total_fees_24h: number;
622
+ /** * A prettier version of the gas quote for rendering purposes. */
623
+ pretty_gas_token_price_quote: string;
624
+ /** * A prettier version of the 24h total fees for rendering purposes. */
625
+ pretty_total_fees_24h: string;
626
+ volume_chart_7d: VolumeEcosystemChart[];
627
+ volume_chart_30d: VolumeEcosystemChart[];
628
+ liquidity_chart_7d: LiquidityEcosystemChart[];
629
+ liquidity_chart_30d: LiquidityEcosystemChart[];
482
630
  }
483
631
  export interface VolumeEcosystemChart {
484
632
  /** * The name of the DEX, eg: `uniswap_v2`. */
@@ -489,6 +637,8 @@ export interface VolumeEcosystemChart {
489
637
  /** * The requested quote currency eg: `USD`. */
490
638
  quote_currency: string;
491
639
  volume_quote: number;
640
+ /** * A prettier version of the volume quote for rendering purposes. */
641
+ pretty_volume_quote: string;
492
642
  swap_count_24: number;
493
643
  }
494
644
  export interface LiquidityEcosystemChart {
@@ -500,6 +650,8 @@ export interface LiquidityEcosystemChart {
500
650
  /** * The requested quote currency eg: `USD`. */
501
651
  quote_currency: string;
502
652
  liquidity_quote: number;
653
+ /** * A prettier version of the liquidity quote for rendering purposes. */
654
+ pretty_liquidity_quote: string;
503
655
  }
504
656
  export interface HealthDataResponse {
505
657
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
@@ -1,4 +1,4 @@
1
- import { Chain, Quote, Response } from "./CovalentClient";
1
+ import { Chain, Quote, Response, ChainID, Source } from "./CovalentClient";
2
2
  import { Chains } from "../util/Chains";
3
3
  declare class BalancesResponse {
4
4
  /** * The requested address. */
@@ -445,7 +445,7 @@ export interface GetErc20TransfersForWalletAddressQueryParamOpts {
445
445
  }
446
446
  export interface GetTokenHoldersV2ForTokenAddressQueryParamOpts {
447
447
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
448
- blockHeight?: number;
448
+ blockHeight?: number | string;
449
449
  /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
450
450
  date?: string;
451
451
  /** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
@@ -465,7 +465,7 @@ export interface GetHistoricalTokenBalancesForWalletAddressQueryParamOpts {
465
465
  /** * 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. */
466
466
  noNftAssetMetadata?: boolean;
467
467
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
468
- blockHeight?: number;
468
+ blockHeight?: number | string;
469
469
  /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
470
470
  date?: string;
471
471
  }
@@ -473,7 +473,7 @@ export interface GetNativeTokenBalanceQueryParamOpts {
473
473
  /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
474
474
  quoteCurrency?: Quote;
475
475
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
476
- blockHeight?: number;
476
+ blockHeight?: number | string;
477
477
  }
478
478
  /**
479
479
  * Balances APIs
@@ -484,8 +484,10 @@ export declare class BalanceService {
484
484
  private debug;
485
485
  private threadCount;
486
486
  private is_key_valid;
487
+ private enableRetry;
488
+ private source;
487
489
  private LIMIT;
488
- constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
490
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry: boolean, source: Source);
489
491
  /**
490
492
  *
491
493
  * 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.
@@ -500,7 +502,7 @@ export declare class BalanceService {
500
502
  * - `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.
501
503
  *
502
504
  */
503
- getTokenBalancesForWalletAddress(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetTokenBalancesForWalletAddressQueryParamOpts): Promise<Response<BalancesResponse>>;
505
+ getTokenBalancesForWalletAddress(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetTokenBalancesForWalletAddressQueryParamOpts): Promise<Response<BalancesResponse>>;
504
506
  /**
505
507
  *
506
508
  * 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.
@@ -512,7 +514,7 @@ export declare class BalanceService {
512
514
  * - `days`: The number of days to return data for. Defaults to 30 days.
513
515
  *
514
516
  */
515
- getHistoricalPortfolioForWalletAddress(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetHistoricalPortfolioForWalletAddressQueryParamOpts): Promise<Response<PortfolioResponse>>;
517
+ getHistoricalPortfolioForWalletAddress(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetHistoricalPortfolioForWalletAddressQueryParamOpts): Promise<Response<PortfolioResponse>>;
516
518
  /**
517
519
  *
518
520
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
@@ -528,7 +530,7 @@ export declare class BalanceService {
528
530
  * - `pageNumber`: 0-indexed page number to begin pagination.
529
531
  *
530
532
  */
531
- getErc20TransfersForWalletAddress(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetErc20TransfersForWalletAddressQueryParamOpts): AsyncIterable<BlockTransactionWithContractTransfers>;
533
+ getErc20TransfersForWalletAddress(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetErc20TransfersForWalletAddressQueryParamOpts): AsyncIterable<BlockTransactionWithContractTransfers>;
532
534
  /**
533
535
  *
534
536
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
@@ -544,7 +546,7 @@ export declare class BalanceService {
544
546
  * - `pageNumber`: 0-indexed page number to begin pagination.
545
547
  *
546
548
  */
547
- getErc20TransfersForWalletAddressByPage(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetErc20TransfersForWalletAddressQueryParamOpts): Promise<Response<Erc20TransfersResponse>>;
549
+ getErc20TransfersForWalletAddressByPage(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetErc20TransfersForWalletAddressQueryParamOpts): Promise<Response<Erc20TransfersResponse>>;
548
550
  /**
549
551
  *
550
552
  * 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.
@@ -558,7 +560,7 @@ export declare class BalanceService {
558
560
  * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
559
561
  *
560
562
  */
561
- getTokenHoldersV2ForTokenAddress(chainName: Chain | Chains, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
563
+ getTokenHoldersV2ForTokenAddress(chainName: Chain | Chains | ChainID, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
562
564
  /**
563
565
  *
564
566
  * 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.
@@ -572,7 +574,7 @@ export declare class BalanceService {
572
574
  * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
573
575
  *
574
576
  */
575
- getTokenHoldersV2ForTokenAddressByPage(chainName: Chain | Chains, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
577
+ getTokenHoldersV2ForTokenAddressByPage(chainName: Chain | Chains | ChainID, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
576
578
  /**
577
579
  *
578
580
  * 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.
@@ -589,7 +591,7 @@ export declare class BalanceService {
589
591
  * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
590
592
  *
591
593
  */
592
- getHistoricalTokenBalancesForWalletAddress(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetHistoricalTokenBalancesForWalletAddressQueryParamOpts): Promise<Response<HistoricalBalancesResponse>>;
594
+ getHistoricalTokenBalancesForWalletAddress(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetHistoricalTokenBalancesForWalletAddressQueryParamOpts): Promise<Response<HistoricalBalancesResponse>>;
593
595
  /**
594
596
  *
595
597
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
@@ -599,6 +601,6 @@ export declare class BalanceService {
599
601
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
600
602
  *
601
603
  */
602
- getNativeTokenBalance(chainName: Chain | Chains, walletAddress: string, queryParamOpts?: GetNativeTokenBalanceQueryParamOpts): Promise<Response<TokenBalanceNativeResponse>>;
604
+ getNativeTokenBalance(chainName: Chain | Chains | ChainID, walletAddress: string, queryParamOpts?: GetNativeTokenBalanceQueryParamOpts): Promise<Response<TokenBalanceNativeResponse>>;
603
605
  }
604
606
  export {};
@@ -285,11 +285,13 @@ class NativeBalanceItem {
285
285
  *
286
286
  */
287
287
  export class BalanceService {
288
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
288
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
289
289
  this.apiKey = apiKey;
290
290
  this.debug = debug;
291
291
  this.threadCount = threadCount;
292
292
  this.is_key_valid = is_key_valid;
293
+ this.enableRetry = enableRetry;
294
+ this.source = source;
293
295
  this.LIMIT = pLimit(this.threadCount);
294
296
  }
295
297
  /**
@@ -337,6 +339,7 @@ export class BalanceService {
337
339
  if (queryParamOpts?.noNftAssetMetadata !== undefined) {
338
340
  urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
339
341
  }
342
+ const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`;
340
343
  let startTime;
341
344
  if (this.debug) {
342
345
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -344,13 +347,13 @@ export class BalanceService {
344
347
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`, {
345
348
  headers: {
346
349
  "Authorization": `Bearer ${this.apiKey}`,
347
- "X-Requested-With": userAgent
350
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
348
351
  }
349
352
  }));
350
- debugOutput(response.url, response.status ?? 429, startTime);
351
- if (response.status === null || response.status === 429) {
353
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
354
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
352
355
  try {
353
- data = await this.LIMIT(() => backoff.backOff(response.url));
356
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
354
357
  }
355
358
  catch (error) {
356
359
  success = true;
@@ -380,8 +383,8 @@ export class BalanceService {
380
383
  return {
381
384
  data: null,
382
385
  error: true,
383
- error_code: data ? data.error_code : response.status,
384
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
386
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
387
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
385
388
  };
386
389
  }
387
390
  }
@@ -419,6 +422,7 @@ export class BalanceService {
419
422
  if (queryParamOpts?.days !== undefined) {
420
423
  urlParams.append("days", queryParamOpts?.days.toString());
421
424
  }
425
+ const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`;
422
426
  let startTime;
423
427
  if (this.debug) {
424
428
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -426,13 +430,13 @@ export class BalanceService {
426
430
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`, {
427
431
  headers: {
428
432
  "Authorization": `Bearer ${this.apiKey}`,
429
- "X-Requested-With": userAgent
433
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
430
434
  }
431
435
  }));
432
- debugOutput(response.url, response.status ?? 429, startTime);
433
- if (response.status === null || response.status === 429) {
436
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
437
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
434
438
  try {
435
- data = await this.LIMIT(() => backoff.backOff(response.url));
439
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
436
440
  }
437
441
  catch (error) {
438
442
  success = true;
@@ -462,8 +466,8 @@ export class BalanceService {
462
466
  return {
463
467
  data: null,
464
468
  error: true,
465
- error_code: data ? data.error_code : response.status,
466
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
469
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
470
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
467
471
  };
468
472
  }
469
473
  }
@@ -510,7 +514,7 @@ export class BalanceService {
510
514
  if (queryParamOpts?.pageNumber !== undefined) {
511
515
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
512
516
  }
513
- for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount)) {
517
+ for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount, this.enableRetry, this.source)) {
514
518
  yield res;
515
519
  }
516
520
  success = true;
@@ -570,6 +574,7 @@ export class BalanceService {
570
574
  if (queryParamOpts?.pageNumber !== undefined) {
571
575
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
572
576
  }
577
+ const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`;
573
578
  let startTime;
574
579
  if (this.debug) {
575
580
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -577,13 +582,13 @@ export class BalanceService {
577
582
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, {
578
583
  headers: {
579
584
  "Authorization": `Bearer ${this.apiKey}`,
580
- "X-Requested-With": userAgent
585
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
581
586
  }
582
587
  }));
583
- debugOutput(response.url, response.status ?? 429, startTime);
584
- if (response.status === null || response.status === 429) {
588
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
589
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
585
590
  try {
586
- data = await this.LIMIT(() => backoff.backOff(response.url));
591
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
587
592
  }
588
593
  catch (error) {
589
594
  success = true;
@@ -613,8 +618,8 @@ export class BalanceService {
613
618
  return {
614
619
  data: null,
615
620
  error: true,
616
- error_code: data ? data.error_code : response.status,
617
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
621
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
622
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
618
623
  };
619
624
  }
620
625
  }
@@ -653,7 +658,7 @@ export class BalanceService {
653
658
  if (queryParamOpts?.date !== undefined) {
654
659
  urlParams.append("date", queryParamOpts?.date.toString());
655
660
  }
656
- for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount)) {
661
+ for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount, this.enableRetry, this.source)) {
657
662
  yield res;
658
663
  }
659
664
  success = true;
@@ -705,6 +710,7 @@ export class BalanceService {
705
710
  if (queryParamOpts?.date !== undefined) {
706
711
  urlParams.append("date", queryParamOpts?.date.toString());
707
712
  }
713
+ const url = `https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`;
708
714
  let startTime;
709
715
  if (this.debug) {
710
716
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -712,13 +718,13 @@ export class BalanceService {
712
718
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
713
719
  headers: {
714
720
  "Authorization": `Bearer ${this.apiKey}`,
715
- "X-Requested-With": userAgent
721
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
716
722
  }
717
723
  }));
718
- debugOutput(response.url, response.status ?? 429, startTime);
719
- if (response.status === null || response.status === 429) {
724
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
725
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
720
726
  try {
721
- data = await this.LIMIT(() => backoff.backOff(response.url));
727
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
722
728
  }
723
729
  catch (error) {
724
730
  success = true;
@@ -748,8 +754,8 @@ export class BalanceService {
748
754
  return {
749
755
  data: null,
750
756
  error: true,
751
- error_code: data ? data.error_code : response.status,
752
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
757
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
758
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
753
759
  };
754
760
  }
755
761
  }
@@ -807,6 +813,7 @@ export class BalanceService {
807
813
  if (queryParamOpts?.date !== undefined) {
808
814
  urlParams.append("date", queryParamOpts?.date.toString());
809
815
  }
816
+ const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/historical_balances/?${urlParams}`;
810
817
  let startTime;
811
818
  if (this.debug) {
812
819
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -814,13 +821,13 @@ export class BalanceService {
814
821
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/historical_balances/?${urlParams}`, {
815
822
  headers: {
816
823
  "Authorization": `Bearer ${this.apiKey}`,
817
- "X-Requested-With": userAgent
824
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
818
825
  }
819
826
  }));
820
- debugOutput(response.url, response.status ?? 429, startTime);
821
- if (response.status === null || response.status === 429) {
827
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
828
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
822
829
  try {
823
- data = await this.LIMIT(() => backoff.backOff(response.url));
830
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
824
831
  }
825
832
  catch (error) {
826
833
  success = true;
@@ -850,8 +857,8 @@ export class BalanceService {
850
857
  return {
851
858
  data: null,
852
859
  error: true,
853
- error_code: data ? data.error_code : response.status,
854
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
860
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
861
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
855
862
  };
856
863
  }
857
864
  }
@@ -887,6 +894,7 @@ export class BalanceService {
887
894
  if (queryParamOpts?.blockHeight !== undefined) {
888
895
  urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
889
896
  }
897
+ const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`;
890
898
  let startTime;
891
899
  if (this.debug) {
892
900
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -894,13 +902,13 @@ export class BalanceService {
894
902
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`, {
895
903
  headers: {
896
904
  "Authorization": `Bearer ${this.apiKey}`,
897
- "X-Requested-With": userAgent
905
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
898
906
  }
899
907
  }));
900
- debugOutput(response.url, response.status ?? 429, startTime);
901
- if (response.status === null || response.status === 429) {
908
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
909
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
902
910
  try {
903
- data = await this.LIMIT(() => backoff.backOff(response.url));
911
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
904
912
  }
905
913
  catch (error) {
906
914
  success = true;
@@ -930,8 +938,8 @@ export class BalanceService {
930
938
  return {
931
939
  data: null,
932
940
  error: true,
933
- error_code: data ? data.error_code : response.status,
934
- error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
941
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
942
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
935
943
  };
936
944
  }
937
945
  }