@covalenthq/client-sdk 0.6.7 → 0.7.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 (70) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/index.js +576 -25
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BalanceService.d.ts +2 -1
  5. package/dist/cjs/services/BaseService.d.ts +55 -2
  6. package/dist/cjs/services/CovalentClient.d.ts +3 -1
  7. package/dist/cjs/services/NftService.d.ts +2 -1
  8. package/dist/cjs/services/PricingService.d.ts +2 -1
  9. package/dist/cjs/services/SecurityService.d.ts +2 -1
  10. package/dist/cjs/services/TransactionService.d.ts +5 -4
  11. package/dist/cjs/services/XykService.d.ts +2 -1
  12. package/dist/cjs/util/ApiKeyValidator.d.ts +8 -0
  13. package/dist/cjs/util/types/BaseServiceTypes.d.ts +36 -0
  14. package/dist/cjs/util/types/TransactionServiceTypes.d.ts +3 -3
  15. package/dist/es/index.js +576 -25
  16. package/dist/es/index.js.map +1 -1
  17. package/dist/es/services/BalanceService.d.ts +2 -1
  18. package/dist/es/services/BaseService.d.ts +55 -2
  19. package/dist/es/services/CovalentClient.d.ts +3 -1
  20. package/dist/es/services/NftService.d.ts +2 -1
  21. package/dist/es/services/PricingService.d.ts +2 -1
  22. package/dist/es/services/SecurityService.d.ts +2 -1
  23. package/dist/es/services/TransactionService.d.ts +5 -4
  24. package/dist/es/services/XykService.d.ts +2 -1
  25. package/dist/es/util/ApiKeyValidator.d.ts +8 -0
  26. package/dist/es/util/types/BaseServiceTypes.d.ts +36 -0
  27. package/dist/es/util/types/TransactionServiceTypes.d.ts +3 -3
  28. package/dist/esm/index.js +576 -25
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/services/BalanceService.d.ts +2 -1
  31. package/dist/esm/services/BaseService.d.ts +55 -2
  32. package/dist/esm/services/CovalentClient.d.ts +3 -1
  33. package/dist/esm/services/NftService.d.ts +2 -1
  34. package/dist/esm/services/PricingService.d.ts +2 -1
  35. package/dist/esm/services/SecurityService.d.ts +2 -1
  36. package/dist/esm/services/TransactionService.d.ts +5 -4
  37. package/dist/esm/services/XykService.d.ts +2 -1
  38. package/dist/esm/util/ApiKeyValidator.d.ts +8 -0
  39. package/dist/esm/util/types/BaseServiceTypes.d.ts +36 -0
  40. package/dist/esm/util/types/TransactionServiceTypes.d.ts +3 -3
  41. package/dist/services/BalanceService.d.ts +2 -1
  42. package/dist/services/BalanceService.js +57 -1
  43. package/dist/services/BalanceService.js.map +1 -1
  44. package/dist/services/BaseService.d.ts +55 -2
  45. package/dist/services/BaseService.js +187 -1
  46. package/dist/services/BaseService.js.map +1 -1
  47. package/dist/services/CovalentClient.d.ts +3 -1
  48. package/dist/services/CovalentClient.js +20 -15
  49. package/dist/services/CovalentClient.js.map +1 -1
  50. package/dist/services/NftService.d.ts +2 -1
  51. package/dist/services/NftService.js +113 -1
  52. package/dist/services/NftService.js.map +1 -1
  53. package/dist/services/PricingService.d.ts +2 -1
  54. package/dist/services/PricingService.js +11 -1
  55. package/dist/services/PricingService.js.map +1 -1
  56. package/dist/services/SecurityService.d.ts +2 -1
  57. package/dist/services/SecurityService.js +19 -1
  58. package/dist/services/SecurityService.js.map +1 -1
  59. package/dist/services/TransactionService.d.ts +5 -4
  60. package/dist/services/TransactionService.js +49 -4
  61. package/dist/services/TransactionService.js.map +1 -1
  62. package/dist/services/XykService.d.ts +2 -1
  63. package/dist/services/XykService.js +115 -1
  64. package/dist/services/XykService.js.map +1 -1
  65. package/dist/util/ApiKeyValidator.d.ts +8 -0
  66. package/dist/util/ApiKeyValidator.js +13 -0
  67. package/dist/util/ApiKeyValidator.js.map +1 -0
  68. package/dist/util/types/BaseServiceTypes.d.ts +36 -0
  69. package/dist/util/types/TransactionServiceTypes.d.ts +3 -3
  70. package/package.json +1 -1
@@ -483,8 +483,9 @@ export declare class BalanceService {
483
483
  private apiKey;
484
484
  private debug;
485
485
  private threadCount;
486
+ private is_key_valid;
486
487
  private LIMIT;
487
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
488
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
488
489
  /**
489
490
  *
490
491
  * 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.
@@ -1,4 +1,4 @@
1
- import { Chain, Response } from "./CovalentClient";
1
+ import { Chain, Quote, Response } from "./CovalentClient";
2
2
  import { Chains } from "../util/Chains";
3
3
  declare class BlockResponse {
4
4
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
@@ -266,6 +266,45 @@ declare class ChainActivityEvent extends ChainItem {
266
266
  last_seen_at: Date;
267
267
  constructor(data: ChainActivityEvent);
268
268
  }
269
+ declare class GasPricesResponse {
270
+ /** * The requested chain ID eg: `1`. */
271
+ chain_id: number;
272
+ /** * The requested chain name eg: `eth-mainnet`. */
273
+ chain_name: string;
274
+ /** * The requested quote currency eg: `USD`. */
275
+ quote_currency: string;
276
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
277
+ updated_at: Date;
278
+ /** * The requested event type. */
279
+ event_type: string;
280
+ /** * The exchange rate for the requested quote currency. */
281
+ gas_quote_rate: number;
282
+ /** * List of response items. */
283
+ items: PriceItem[];
284
+ constructor(data: GasPricesResponse);
285
+ }
286
+ declare class PriceItem {
287
+ /** * The average gas price, in WEI, for the time interval. */
288
+ gas_price: string;
289
+ /** * The average gas spent for the time interval. */
290
+ gas_spent: string;
291
+ /** * The average gas spent in `quote-currency` denomination for the time interval. */
292
+ gas_quote: number;
293
+ /** * Other fees, when applicable. For example: OP chain L1 fees. */
294
+ other_fees: OtherFees;
295
+ /** * The sum of the L1 and L2 gas spent, in quote-currency, for the specified time interval. */
296
+ total_gas_quote: number;
297
+ /** * A prettier version of the total average gas spent, in quote-currency, for the specified time interval, for rendering purposes. */
298
+ pretty_total_gas_quote: string;
299
+ /** * The specified time interval. */
300
+ interval: string;
301
+ constructor(data: PriceItem);
302
+ }
303
+ declare class OtherFees {
304
+ /** * The calculated L1 gas spent, when applicable, in quote-currency, for the specified time interval. */
305
+ l1_gas_quote: number;
306
+ constructor(data: OtherFees);
307
+ }
269
308
  export interface GetBlockHeightsQueryParamOpts {
270
309
  /** * Number of items per page. Omitting this parameter defaults to 100. */
271
310
  pageSize?: number;
@@ -312,6 +351,10 @@ export interface GetAddressActivityQueryParamOpts {
312
351
  /** * Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity. */
313
352
  testnets?: boolean;
314
353
  }
354
+ export interface GetGasPricesQueryParamOpts {
355
+ /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
356
+ quoteCurrency?: Quote;
357
+ }
315
358
  /**
316
359
  * Class A - Base
317
360
  *
@@ -320,8 +363,9 @@ export declare class BaseService {
320
363
  private apiKey;
321
364
  private debug;
322
365
  private threadCount;
366
+ private is_key_valid;
323
367
  private LIMIT;
324
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
368
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
325
369
  /**
326
370
  *
327
371
  * Commonly used to fetch and render a single block for a block explorer.
@@ -463,5 +507,14 @@ export declare class BaseService {
463
507
  *
464
508
  */
465
509
  getAddressActivity(walletAddress: string, queryParamOpts?: GetAddressActivityQueryParamOpts): Promise<Response<ChainActivityResponse>>;
510
+ /**
511
+ *
512
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
513
+ * @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
514
+ * @param {GetGasPricesQueryParamOpts} queryParamOpts
515
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
516
+ *
517
+ */
518
+ getGasPrices(chainName: Chains, eventType: string, queryParamOpts?: GetGasPricesQueryParamOpts): Promise<Response<GasPricesResponse>>;
466
519
  }
467
520
  export {};
@@ -7,7 +7,7 @@ import { TransactionService } from "./TransactionService";
7
7
  import { XykService } from "./XykService";
8
8
  export type Chain = "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-mainnet" | "avalanche-mainnet" | "optimism-mainnet" | "fantom-mainnet" | "moonbeam-mainnet" | "moonbeam-moonriver" | "rsk-mainnet" | "arbitrum-mainnet" | "palm-mainnet" | "klaytn-mainnet" | "heco-mainnet" | "nervos-godwoken-mainnet" | "axie-mainnet" | "evmos-mainnet" | "astar-mainnet" | "iotex-mainnet" | "harmony-mainnet" | "cronos-mainnet" | "aurora-mainnet" | "emerald-paratime-mainnet" | "boba-mainnet" | "eth-goerli" | "matic-mumbai" | "avalanche-testnet" | "bsc-testnet" | "moonbeam-moonbase-alpha" | "rsk-testnet" | "arbitrum-goerli" | "fantom-testnet" | "palm-testnet" | "heco-testnet" | "nervos-godwoken-testnet" | "evmos-testnet" | "astar-shiden" | "iotex-testnet" | "harmony-testnet" | "aurora-testnet" | "scroll-sepolia-testnet" | "covalent-internal-network-v1" | "defi-kingdoms-mainnet" | "swimmer-mainnet" | "boba-avalanche-mainnet" | "boba-bobabeam-mainnet" | "boba-bnb-mainnet" | "boba-rinkeby-testnet" | "boba-bobabase-testnet" | "boba-bnb-testnet" | "boba-avalanche-testnet" | "klaytn-testnet" | "gather-mainnet" | "gather-testnet" | "skale-calypso" | "skale-mainnet" | "skale-razor" | "avalanche-dexalot-mainnet" | "skale-omnus" | "avalanche-dexalot-testnet" | "astar-shibuya" | "cronos-testnet" | "defi-kingdoms-testnet" | "metis-mainnet" | "metis-stardust" | "milkomeda-a1-mainnet" | "milkomeda-a1-devnet" | "milkomeda-c1-mainnet" | "milkomeda-c1-devnet" | "swimmer-testnet" | "solana-mainnet" | "skale-europa" | "meter-mainnet" | "meter-testnet" | "skale-exorde" | "boba-goerli" | "neon-testnet" | "skale-staging-uum" | "skale-staging-lcc" | "arbitrum-nova-mainnet" | "canto-mainnet" | "bittorrent-mainnet" | "bittorrent-testnet" | "flarenetworks-flare-mainnet" | "flarenetworks-flare-testnet" | "flarenetworks-canary-mainnet" | "flarenetworks-canary-testnet" | "kcc-mainnet" | "kcc-testnet" | "polygon-zkevm-testnet" | "linea-testnet" | "base-testnet" | "mantle-testnet" | "scroll-alpha-testnet" | "oasys-mainnet" | "oasys-testnet" | "findora-mainnet" | "findora-forge-testnet" | "sx-mainnet" | "oasis-sapphire-mainnet" | "oasis-sapphire-testnet" | "optimism-goerli" | "polygon-zkevm-mainnet" | "horizen-yuma-testnet" | "clv-parachain" | "energi-mainnet" | "energi-testnet" | "horizen-gobi-testnet" | "eth-sepolia" | "skale-nebula" | "skale-battleground" | "avalanche-meld-testnet" | "gunzilla-testnet" | "ultron-mainnet" | "ultron-testnet" | "zora-mainnet" | "zora-testnet" | "neon-mainnet" | "avalanche-shrapnel-mainnet" | "base-mainnet" | "mantle-mainnet" | "avalanche-loco-legends-mainnet" | "linea-mainnet" | "horizen-eon-mainnet" | "avalanche-numbers" | "avalanche-dos" | "avalanche-step-network" | "avalanche-xplus" | "avalanche-xanachain" | "avalanche-meld-mainnet" | "opside-public-zkevm" | "opside-law-chain" | "avalanche-shrapnel-testnet" | "avalanche-loco-legends-testnet" | "opside-cb-zkevm" | "opside-pre-alpha-testnet" | "opside-era7" | "opside-xthrill" | "zksync-mainnet" | "metis-testnet" | "zksync-testnet" | "avalanche-blitz-testnet" | "avalanche-d-chain-testnet" | "avalanche-green-dot-testnet" | "avalanche-mintara-testnet" | "avalanche-beam-testnet" | "bnb-meta-apes-mainnet" | "bnb-antimatter-mainnet" | "bnb-antimatter-testnet" | "bnb-opbnb-testnet" | "opside-debox" | "opside-jackbot" | "opside-odx-zkevm-testnet" | "opside-readon-content-testnet" | "opside-relation" | "opside-soquest-zkevm" | "opside-vip3" | "opside-zkmeta" | "avalanche-pulsar-testnet" | "avalanche-uptn" | "bnb-fncy-mainnet" | "zetachain-testnet" | "kinto-testnet" | "mode-testnet" | "loot-mainnet" | "bnb-fncy-testnet" | "manta-testnet" | "pgn-mainnet" | "pgn-testnet" | "gnosis-mainnet" | "gnosis-testnet" | "rollux-mainnet" | "rollux-testnet" | "taiko-jolnir-testnet" | "optimism-sepolia" | "bnb-opbnb-mainnet" | "telos-mainnet" | "telos-testnet";
9
9
  export type Quote = "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP";
10
- export declare const userAgent = "com.covalenthq.sdk.typescript/0.6.7";
10
+ export declare const userAgent = "com.covalenthq.sdk.typescript/0.7.0";
11
11
  export declare class Response<T> {
12
12
  data: T;
13
13
  error: boolean;
@@ -31,6 +31,7 @@ export declare class CovalentClient {
31
31
  PricingService: PricingService;
32
32
  TransactionService: TransactionService;
33
33
  XykService: XykService;
34
+ private _is_key_valid;
34
35
  constructor(apiKey: string, settings?: CovalentClientSettings);
35
36
  }
36
37
  /**
@@ -47,5 +48,6 @@ export declare class Client {
47
48
  PricingService: PricingService;
48
49
  TransactionService: TransactionService;
49
50
  XykService: XykService;
51
+ private _is_key_valid;
50
52
  constructor(apiKey: string, settings?: CovalentClientSettings);
51
53
  }
@@ -483,8 +483,9 @@ export declare class NftService {
483
483
  private apiKey;
484
484
  private debug;
485
485
  private threadCount;
486
+ private is_key_valid;
486
487
  private LIMIT;
487
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
488
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
488
489
  /**
489
490
  *
490
491
  * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
@@ -69,8 +69,9 @@ export declare class PricingService {
69
69
  private apiKey;
70
70
  private debug;
71
71
  private threadCount;
72
+ private is_key_valid;
72
73
  private LIMIT;
73
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
74
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
74
75
  /**
75
76
  *
76
77
  * Commonly used to get historic prices of a token between date ranges. Supports native tokens.
@@ -136,8 +136,9 @@ export declare class SecurityService {
136
136
  private apiKey;
137
137
  private debug;
138
138
  private threadCount;
139
+ private is_key_valid;
139
140
  private LIMIT;
140
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
141
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
141
142
  /**
142
143
  *
143
144
  * Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
@@ -58,11 +58,11 @@ declare class Transaction {
58
58
  /** * The explorer links for this transaction. */
59
59
  explorers: Explorer[];
60
60
  /** * The details for the dex transaction. */
61
- dex_details: DexReport;
61
+ dex_details: DexReport[];
62
62
  /** * The details for the NFT sale transaction. */
63
- nft_sale_details: NftSalesReport;
63
+ nft_sale_details: NftSalesReport[];
64
64
  /** * The details for the lending protocol transaction. */
65
- lending_details: LendingReport;
65
+ lending_details: LendingReport[];
66
66
  /** * The log events. */
67
67
  log_events: LogEvent[];
68
68
  /** * The details related to the safe transaction. */
@@ -477,8 +477,9 @@ export declare class TransactionService {
477
477
  private apiKey;
478
478
  private debug;
479
479
  private threadCount;
480
+ private is_key_valid;
480
481
  private LIMIT;
481
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
482
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
482
483
  /**
483
484
  *
484
485
  * Commonly used to fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
@@ -544,8 +544,9 @@ export declare class XykService {
544
544
  private apiKey;
545
545
  private debug;
546
546
  private threadCount;
547
+ private is_key_valid;
547
548
  private LIMIT;
548
- constructor(apiKey: string, debug?: boolean, threadCount?: number);
549
+ constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
549
550
  /**
550
551
  *
551
552
  * Commonly used to get all the pools of a particular DEX. Supports most common DEXs (Uniswap, SushiSwap, etc), and returns detailed trading data (volume, liquidity, swap counts, fees, LP token prices).
@@ -0,0 +1,8 @@
1
+ export declare class ApiKeyValidator {
2
+ readonly _apiKey: string;
3
+ private static readonly _apiKeyV1Pattern;
4
+ private static readonly _apiKeyV2Pattern;
5
+ static readonly INVALID_API_KEY_MESSAGE = "Invalid or missing API key (sign up at covalenthq.com/platform)";
6
+ constructor(apiKey: string);
7
+ isValidApiKey(): boolean;
8
+ }
@@ -194,3 +194,39 @@ export interface ChainActivityEvent extends ChainItem {
194
194
  /** * The timestamp when the address was last seen on the chain. */
195
195
  last_seen_at: Date;
196
196
  }
197
+ export interface GasPricesResponse {
198
+ /** * The requested chain ID eg: `1`. */
199
+ chain_id: number;
200
+ /** * The requested chain name eg: `eth-mainnet`. */
201
+ chain_name: string;
202
+ /** * The requested quote currency eg: `USD`. */
203
+ quote_currency: string;
204
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
205
+ updated_at: Date;
206
+ /** * The requested event type. */
207
+ event_type: string;
208
+ /** * The exchange rate for the requested quote currency. */
209
+ gas_quote_rate: number;
210
+ /** * List of response items. */
211
+ items: PriceItem[];
212
+ }
213
+ export interface PriceItem {
214
+ /** * The average gas price, in WEI, for the time interval. */
215
+ gas_price: string;
216
+ /** * The average gas spent for the time interval. */
217
+ gas_spent: string;
218
+ /** * The average gas spent in `quote-currency` denomination for the time interval. */
219
+ gas_quote: number;
220
+ /** * Other fees, when applicable. For example: OP chain L1 fees. */
221
+ other_fees: OtherFees;
222
+ /** * The sum of the L1 and L2 gas spent, in quote-currency, for the specified time interval. */
223
+ total_gas_quote: number;
224
+ /** * A prettier version of the total average gas spent, in quote-currency, for the specified time interval, for rendering purposes. */
225
+ pretty_total_gas_quote: string;
226
+ /** * The specified time interval. */
227
+ interval: string;
228
+ }
229
+ export interface OtherFees {
230
+ /** * The calculated L1 gas spent, when applicable, in quote-currency, for the specified time interval. */
231
+ l1_gas_quote: number;
232
+ }
@@ -56,11 +56,11 @@ export interface Transaction {
56
56
  /** * The explorer links for this transaction. */
57
57
  explorers: Explorer[];
58
58
  /** * The details for the dex transaction. */
59
- dex_details: DexReport;
59
+ dex_details: DexReport[];
60
60
  /** * The details for the NFT sale transaction. */
61
- nft_sale_details: NftSalesReport;
61
+ nft_sale_details: NftSalesReport[];
62
62
  /** * The details for the lending protocol transaction. */
63
- lending_details: LendingReport;
63
+ lending_details: LendingReport[];
64
64
  /** * The log events. */
65
65
  log_events: LogEvent[];
66
66
  /** * The details related to the safe transaction. */