@covalenthq/client-sdk 0.5.2 → 0.6.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 (50) hide show
  1. package/README.md +12 -6
  2. package/dist/cjs/index.js +582 -26
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BalanceService.d.ts +31 -1
  5. package/dist/cjs/services/BaseService.d.ts +94 -2
  6. package/dist/cjs/services/CovalentClient.d.ts +1 -1
  7. package/dist/cjs/services/NftService.d.ts +48 -1
  8. package/dist/cjs/services/TransactionService.d.ts +4 -1
  9. package/dist/cjs/util/types/BaseServiceTypes.d.ts +1 -1
  10. package/dist/cjs/util/types/GenericTypes.d.ts +1 -1
  11. package/dist/cjs/util/types/NftServiceTypes.d.ts +6 -0
  12. package/dist/es/index.js +582 -26
  13. package/dist/es/index.js.map +1 -1
  14. package/dist/es/services/BalanceService.d.ts +31 -1
  15. package/dist/es/services/BaseService.d.ts +94 -2
  16. package/dist/es/services/CovalentClient.d.ts +1 -1
  17. package/dist/es/services/NftService.d.ts +48 -1
  18. package/dist/es/services/TransactionService.d.ts +4 -1
  19. package/dist/es/util/types/BaseServiceTypes.d.ts +1 -1
  20. package/dist/es/util/types/GenericTypes.d.ts +1 -1
  21. package/dist/es/util/types/NftServiceTypes.d.ts +6 -0
  22. package/dist/esm/index.js +582 -26
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/services/BalanceService.d.ts +31 -1
  25. package/dist/esm/services/BaseService.d.ts +94 -2
  26. package/dist/esm/services/CovalentClient.d.ts +1 -1
  27. package/dist/esm/services/NftService.d.ts +48 -1
  28. package/dist/esm/services/TransactionService.d.ts +4 -1
  29. package/dist/esm/util/types/BaseServiceTypes.d.ts +1 -1
  30. package/dist/esm/util/types/GenericTypes.d.ts +1 -1
  31. package/dist/esm/util/types/NftServiceTypes.d.ts +6 -0
  32. package/dist/services/BalanceService.d.ts +31 -1
  33. package/dist/services/BalanceService.js +86 -0
  34. package/dist/services/BalanceService.js.map +1 -1
  35. package/dist/services/BaseService.d.ts +94 -2
  36. package/dist/services/BaseService.js +243 -0
  37. package/dist/services/BaseService.js.map +1 -1
  38. package/dist/services/CovalentClient.d.ts +1 -1
  39. package/dist/services/CovalentClient.js +1 -1
  40. package/dist/services/NftService.d.ts +48 -1
  41. package/dist/services/NftService.js +170 -0
  42. package/dist/services/NftService.js.map +1 -1
  43. package/dist/services/TransactionService.d.ts +4 -1
  44. package/dist/services/TransactionService.js +4 -0
  45. package/dist/services/TransactionService.js.map +1 -1
  46. package/dist/services/XykService.js.map +1 -1
  47. package/dist/util/types/BaseServiceTypes.d.ts +1 -1
  48. package/dist/util/types/GenericTypes.d.ts +1 -1
  49. package/dist/util/types/NftServiceTypes.d.ts +6 -0
  50. package/package.json +1 -1
@@ -253,6 +253,19 @@ declare class MethodCallsForTransfers {
253
253
  method: string;
254
254
  constructor(data: MethodCallsForTransfers);
255
255
  }
256
+ declare class TokenHoldersResponse {
257
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
258
+ updated_at: Date;
259
+ /** * The requested chain ID eg: `1`. */
260
+ chain_id: number;
261
+ /** * The requested chain name eg: `eth-mainnet`. */
262
+ chain_name: string;
263
+ /** * List of response items. */
264
+ items: TokenHolder[];
265
+ /** * Pagination metadata. */
266
+ pagination: Pagination;
267
+ constructor(data: TokenHoldersResponse);
268
+ }
256
269
  declare class TokenHolder {
257
270
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
258
271
  contract_decimals: number;
@@ -403,6 +416,8 @@ export interface GetErc20TransfersForWalletAddressQueryParamOpts {
403
416
  export interface GetTokenHoldersV2ForTokenAddressQueryParamOpts {
404
417
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
405
418
  blockHeight?: number;
419
+ /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
420
+ date?: string;
406
421
  /** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
407
422
  pageSize?: number;
408
423
  /** * 0-indexed page number to begin pagination. */
@@ -422,7 +437,7 @@ export interface GetHistoricalTokenBalancesForWalletAddressQueryParamOpts {
422
437
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
423
438
  blockHeight?: number;
424
439
  /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
425
- date?: number;
440
+ date?: string;
426
441
  }
427
442
  export interface GetNativeTokenBalanceQueryParamOpts {
428
443
  /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
@@ -509,9 +524,24 @@ export declare class BalanceService {
509
524
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
510
525
  * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
511
526
  * - `pageNumber`: 0-indexed page number to begin pagination.
527
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
512
528
  *
513
529
  */
514
530
  getTokenHoldersV2ForTokenAddress(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
531
+ /**
532
+ *
533
+ * 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.
534
+ *
535
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
536
+ * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
537
+ * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
538
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
539
+ * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
540
+ * - `pageNumber`: 0-indexed page number to begin pagination.
541
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
542
+ *
543
+ */
544
+ getTokenHoldersV2ForTokenAddressByPage(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
515
545
  /**
516
546
  *
517
547
  * 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.
@@ -34,6 +34,30 @@ declare class ResolvedAddressItem {
34
34
  name: string;
35
35
  constructor(data: ResolvedAddressItem);
36
36
  }
37
+ declare class BlockHeightsResponse {
38
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
39
+ updated_at: Date;
40
+ /** * The requested chain ID eg: `1`. */
41
+ chain_id: number;
42
+ /** * The requested chain name eg: `eth-mainnet`. */
43
+ chain_name: string;
44
+ /** * List of response items. */
45
+ items: Block[];
46
+ /** * Pagination metadata. */
47
+ pagination: Pagination;
48
+ constructor(data: BlockHeightsResponse);
49
+ }
50
+ declare class Pagination {
51
+ /** * True is there is another page. */
52
+ has_more: boolean;
53
+ /** * The requested page number. */
54
+ page_number: number;
55
+ /** * The requested number of items on the current page. */
56
+ page_size: number;
57
+ /** * The total number of items across all pages for this request. */
58
+ total_count: number;
59
+ constructor(data: Pagination);
60
+ }
37
61
  declare class GetLogsResponse {
38
62
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
39
63
  updated_at: Date;
@@ -59,7 +83,7 @@ declare class GetLogsEvent {
59
83
  /** * The requested transaction hash. */
60
84
  tx_hash: string;
61
85
  /** * The log topics in raw data. */
62
- raw_log_topics: string;
86
+ raw_log_topics: string[];
63
87
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
64
88
  sender_contract_decimals: number;
65
89
  /** * The name of the sender. */
@@ -92,6 +116,19 @@ declare class Param {
92
116
  value: string;
93
117
  constructor(data: Param);
94
118
  }
119
+ declare class LogEventsByAddressResponse {
120
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
121
+ updated_at: Date;
122
+ /** * The requested chain ID eg: `1`. */
123
+ chain_id: number;
124
+ /** * The requested chain name eg: `eth-mainnet`. */
125
+ chain_name: string;
126
+ /** * List of response items. */
127
+ items: LogEvent[];
128
+ /** * Pagination metadata. */
129
+ pagination: Pagination;
130
+ constructor(data: LogEventsByAddressResponse);
131
+ }
95
132
  declare class LogEvent {
96
133
  /** * The block signed timestamp in UTC. */
97
134
  block_signed_at: Date;
@@ -104,7 +141,7 @@ declare class LogEvent {
104
141
  /** * The requested transaction hash. */
105
142
  tx_hash: string;
106
143
  /** * The log topics in raw data. */
107
- raw_log_topics: string;
144
+ raw_log_topics: string[];
108
145
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
109
146
  sender_contract_decimals: number;
110
147
  /** * The name of the sender. */
@@ -122,6 +159,19 @@ declare class LogEvent {
122
159
  decoded: DecodedItem;
123
160
  constructor(data: LogEvent);
124
161
  }
162
+ declare class LogEventsByTopicHashResponse {
163
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
164
+ updated_at: Date;
165
+ /** * The requested chain ID eg: `1`. */
166
+ chain_id: number;
167
+ /** * The requested chain name eg: `eth-mainnet`. */
168
+ chain_name: string;
169
+ /** * List of response items. */
170
+ items: LogEvent[];
171
+ /** * Pagination metadata. */
172
+ pagination: Pagination;
173
+ constructor(data: LogEventsByTopicHashResponse);
174
+ }
125
175
  declare class AllChainsResponse {
126
176
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
127
177
  updated_at: Date;
@@ -302,6 +352,19 @@ export declare class BaseService {
302
352
  *
303
353
  */
304
354
  getBlockHeights(chainName: Chain, startDate: string, endDate: string, queryParamOpts?: GetBlockHeightsQueryParamOpts): AsyncIterable<Block>;
355
+ /**
356
+ *
357
+ * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
358
+ *
359
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
360
+ * @param {string} startDate - The start date in YYYY-MM-DD format.
361
+ * @param {string} endDate - The end date in YYYY-MM-DD format.
362
+ * @param {GetBlockHeightsQueryParamOpts} queryParamOpts
363
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
364
+ * - `pageNumber`: 0-indexed page number to begin pagination.
365
+ *
366
+ */
367
+ getBlockHeightsByPage(chainName: Chain, startDate: string, endDate: string, queryParamOpts?: GetBlockHeightsQueryParamOpts): Promise<Response<BlockHeightsResponse>>;
305
368
  /**
306
369
  *
307
370
  * 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.
@@ -331,6 +394,20 @@ export declare class BaseService {
331
394
  *
332
395
  */
333
396
  getLogEventsByAddress(chainName: Chain, contractAddress: string, queryParamOpts?: GetLogEventsByAddressQueryParamOpts): AsyncIterable<LogEvent>;
397
+ /**
398
+ *
399
+ * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
400
+ *
401
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
402
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
403
+ * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
404
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
405
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
406
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
407
+ * - `pageNumber`: 0-indexed page number to begin pagination.
408
+ *
409
+ */
410
+ getLogEventsByAddressByPage(chainName: Chain, contractAddress: string, queryParamOpts?: GetLogEventsByAddressQueryParamOpts): Promise<Response<LogEventsByAddressResponse>>;
334
411
  /**
335
412
  *
336
413
  * 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.
@@ -346,6 +423,21 @@ export declare class BaseService {
346
423
  *
347
424
  */
348
425
  getLogEventsByTopicHash(chainName: Chain, topicHash: string, queryParamOpts?: GetLogEventsByTopicHashQueryParamOpts): AsyncIterable<LogEvent>;
426
+ /**
427
+ *
428
+ * 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.
429
+ *
430
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
431
+ * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
432
+ * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
433
+ * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
434
+ * - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
435
+ * - `secondaryTopics`: Additional topic hash(es) to filter on - padded & unpadded address fields are supported. Separate multiple topics with a comma.
436
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
437
+ * - `pageNumber`: 0-indexed page number to begin pagination.
438
+ *
439
+ */
440
+ getLogEventsByTopicHashByPage(chainName: Chain, topicHash: string, queryParamOpts?: GetLogEventsByTopicHashQueryParamOpts): Promise<Response<LogEventsByTopicHashResponse>>;
349
441
  /**
350
442
  *
351
443
  * Commonly used to build internal dashboards for all supported chains on Covalent.
@@ -21,7 +21,7 @@ export type Chains = "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-main
21
21
  * CovalentClient Class
22
22
  */
23
23
  export type Quotes = "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP";
24
- export declare const userAgent = "com.covalenthq.sdk.typescript/0.5.2";
24
+ export declare const userAgent = "com.covalenthq.sdk.typescript/0.6.0";
25
25
  export declare class Response<T> {
26
26
  data: T;
27
27
  error: boolean;
@@ -1,4 +1,17 @@
1
1
  import { Chain, Quote, Response } from "./CovalentClient";
2
+ declare class ChainCollectionResponse {
3
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
4
+ updated_at: Date;
5
+ /** * The requested chain ID eg: `1`. */
6
+ chain_id: number;
7
+ /** * The requested chain name eg: `eth-mainnet`. */
8
+ chain_name: string;
9
+ /** * List of response items. */
10
+ items: ChainCollectionItem[];
11
+ /** * Pagination metadata. */
12
+ pagination: Pagination;
13
+ constructor(data: ChainCollectionResponse);
14
+ }
2
15
  declare class ChainCollectionItem {
3
16
  /** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
4
17
  contract_address: string;
@@ -48,6 +61,12 @@ declare class NftTokenContractBalanceItem {
48
61
  balance: bigint | null;
49
62
  balance_24h: number;
50
63
  type: string;
64
+ /** * The current floor price converted to fiat in `quote-currency`. The floor price is determined by the last minimum sale price within the last 30 days across all the supported markets where the collection is sold on. */
65
+ floor_price_quote: number;
66
+ /** * A prettier version of the floor price quote for rendering purposes. */
67
+ pretty_floor_price_quote: string;
68
+ /** * The current floor price in native currency. The floor price is determined by the last minimum sale price within the last 30 days across all the supported markets where the collection is sold on. */
69
+ floor_price_native_quote: number;
51
70
  nft_data: NftData[];
52
71
  constructor(data: NftTokenContractBalanceItem);
53
72
  }
@@ -189,7 +208,7 @@ declare class LogEvent {
189
208
  /** * The requested transaction hash. */
190
209
  tx_hash: string;
191
210
  /** * The log topics in raw data. */
192
- raw_log_topics: string;
211
+ raw_log_topics: string[];
193
212
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
194
213
  sender_contract_decimals: number;
195
214
  /** * The name of the sender. */
@@ -477,6 +496,18 @@ export declare class NftService {
477
496
  *
478
497
  */
479
498
  getChainCollections(chainName: Chain, queryParamOpts?: GetChainCollectionsQueryParamOpts): AsyncIterable<ChainCollectionItem>;
499
+ /**
500
+ *
501
+ * Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
502
+ *
503
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
504
+ * @param {GetChainCollectionsQueryParamOpts} queryParamOpts
505
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
506
+ * - `pageNumber`: 0-indexed page number to begin pagination.
507
+ * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
508
+ *
509
+ */
510
+ getChainCollectionsByPage(chainName: Chain, queryParamOpts?: GetChainCollectionsQueryParamOpts): Promise<Response<ChainCollectionResponse>>;
480
511
  /**
481
512
  *
482
513
  * Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
@@ -506,6 +537,22 @@ export declare class NftService {
506
537
  *
507
538
  */
508
539
  getTokenIdsForContractWithMetadata(chainName: Chain, contractAddress: string, queryParamOpts?: GetTokenIdsForContractWithMetadataQueryParamOpts): AsyncIterable<NftTokenContract>;
540
+ /**
541
+ *
542
+ * Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
543
+ *
544
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
545
+ * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
546
+ * @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
547
+ * - `noMetadata`: Omit metadata.
548
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
549
+ * - `pageNumber`: 0-indexed page number to begin pagination.
550
+ * - `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.
551
+ * - `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.
552
+ * - `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.
553
+ *
554
+ */
555
+ getTokenIdsForContractWithMetadataByPage(chainName: Chain, contractAddress: string, queryParamOpts?: GetTokenIdsForContractWithMetadataQueryParamOpts): Promise<Response<NftMetadataResponse>>;
509
556
  /**
510
557
  *
511
558
  * Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
@@ -283,7 +283,7 @@ declare class LogEvent {
283
283
  /** * The requested transaction hash. */
284
284
  tx_hash: string;
285
285
  /** * The log topics in raw data. */
286
- raw_log_topics: string;
286
+ raw_log_topics: string[];
287
287
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
288
288
  sender_contract_decimals: number;
289
289
  /** * The name of the sender. */
@@ -420,6 +420,8 @@ export interface GetTransactionsForBlockQueryParamOpts {
420
420
  quoteCurrency?: Quote;
421
421
  /** * Omit log events. */
422
422
  noLogs?: boolean;
423
+ /** * Include safe details. */
424
+ withSafe?: boolean;
423
425
  }
424
426
  export interface GetTransactionsForAddressV3QueryParamOpts {
425
427
  /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
@@ -476,6 +478,7 @@ export declare class TransactionService {
476
478
  * @param {GetTransactionsForBlockQueryParamOpts} queryParamOpts
477
479
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
478
480
  * - `noLogs`: Omit log events.
481
+ * - `withSafe`: Include safe details.
479
482
  *
480
483
  */
481
484
  getTransactionsForBlock(chainName: Chain, blockHeight: number, queryParamOpts?: GetTransactionsForBlockQueryParamOpts): Promise<Response<TransactionsBlockResponse>>;
@@ -66,7 +66,7 @@ export interface GetLogsEvent {
66
66
  /** * The requested transaction hash. */
67
67
  tx_hash: string;
68
68
  /** * The log topics in raw data. */
69
- raw_log_topics: string;
69
+ raw_log_topics: string[];
70
70
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
71
71
  sender_contract_decimals: number;
72
72
  /** * The name of the sender. */
@@ -63,7 +63,7 @@ export interface LogEvent {
63
63
  /** * The requested transaction hash. */
64
64
  tx_hash: string;
65
65
  /** * The log topics in raw data. */
66
- raw_log_topics: string;
66
+ raw_log_topics: string[];
67
67
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
68
68
  sender_contract_decimals: number;
69
69
  /** * The name of the sender. */
@@ -47,6 +47,12 @@ export interface NftTokenContractBalanceItem {
47
47
  balance: bigint | null;
48
48
  balance_24h: number;
49
49
  type: string;
50
+ /** * The current floor price converted to fiat in `quote-currency`. The floor price is determined by the last minimum sale price within the last 30 days across all the supported markets where the collection is sold on. */
51
+ floor_price_quote: number;
52
+ /** * A prettier version of the floor price quote for rendering purposes. */
53
+ pretty_floor_price_quote: string;
54
+ /** * The current floor price in native currency. The floor price is determined by the last minimum sale price within the last 30 days across all the supported markets where the collection is sold on. */
55
+ floor_price_native_quote: number;
50
56
  nft_data: NftData[];
51
57
  }
52
58
  export interface NftMetadataResponse {
@@ -253,6 +253,19 @@ declare class MethodCallsForTransfers {
253
253
  method: string;
254
254
  constructor(data: MethodCallsForTransfers);
255
255
  }
256
+ declare class TokenHoldersResponse {
257
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
258
+ updated_at: Date;
259
+ /** * The requested chain ID eg: `1`. */
260
+ chain_id: number;
261
+ /** * The requested chain name eg: `eth-mainnet`. */
262
+ chain_name: string;
263
+ /** * List of response items. */
264
+ items: TokenHolder[];
265
+ /** * Pagination metadata. */
266
+ pagination: Pagination;
267
+ constructor(data: TokenHoldersResponse);
268
+ }
256
269
  declare class TokenHolder {
257
270
  /** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
258
271
  contract_decimals: number;
@@ -403,6 +416,8 @@ export interface GetErc20TransfersForWalletAddressQueryParamOpts {
403
416
  export interface GetTokenHoldersV2ForTokenAddressQueryParamOpts {
404
417
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
405
418
  blockHeight?: number;
419
+ /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
420
+ date?: string;
406
421
  /** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
407
422
  pageSize?: number;
408
423
  /** * 0-indexed page number to begin pagination. */
@@ -422,7 +437,7 @@ export interface GetHistoricalTokenBalancesForWalletAddressQueryParamOpts {
422
437
  /** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
423
438
  blockHeight?: number;
424
439
  /** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
425
- date?: number;
440
+ date?: string;
426
441
  }
427
442
  export interface GetNativeTokenBalanceQueryParamOpts {
428
443
  /** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
@@ -509,9 +524,24 @@ export declare class BalanceService {
509
524
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
510
525
  * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
511
526
  * - `pageNumber`: 0-indexed page number to begin pagination.
527
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
512
528
  *
513
529
  */
514
530
  getTokenHoldersV2ForTokenAddress(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
531
+ /**
532
+ *
533
+ * 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.
534
+ *
535
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
536
+ * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
537
+ * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
538
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
539
+ * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
540
+ * - `pageNumber`: 0-indexed page number to begin pagination.
541
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
542
+ *
543
+ */
544
+ getTokenHoldersV2ForTokenAddressByPage(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
515
545
  /**
516
546
  *
517
547
  * 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.
@@ -578,6 +578,7 @@ export class BalanceService {
578
578
  * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
579
579
  * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
580
580
  * - `pageNumber`: 0-indexed page number to begin pagination.
581
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
581
582
  *
582
583
  */
583
584
  async *getTokenHoldersV2ForTokenAddress(chainName, tokenAddress, queryParamOpts) {
@@ -595,6 +596,9 @@ export class BalanceService {
595
596
  if (queryParamOpts?.pageNumber !== undefined) {
596
597
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
597
598
  }
599
+ if (queryParamOpts?.date !== undefined) {
600
+ urlParams.append("date", queryParamOpts?.date.toString());
601
+ }
598
602
  for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount)) {
599
603
  yield res;
600
604
  }
@@ -606,6 +610,88 @@ export class BalanceService {
606
610
  }
607
611
  }
608
612
  }
613
+ /**
614
+ *
615
+ * 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.
616
+ *
617
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
618
+ * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
619
+ * @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
620
+ * - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
621
+ * - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
622
+ * - `pageNumber`: 0-indexed page number to begin pagination.
623
+ * - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
624
+ *
625
+ */
626
+ async getTokenHoldersV2ForTokenAddressByPage(chainName, tokenAddress, queryParamOpts) {
627
+ let success = false;
628
+ let data;
629
+ let response;
630
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
631
+ while (!success) {
632
+ try {
633
+ const urlParams = new URLSearchParams();
634
+ if (queryParamOpts?.blockHeight !== undefined) {
635
+ urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
636
+ }
637
+ if (queryParamOpts?.pageSize !== undefined) {
638
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
639
+ }
640
+ if (queryParamOpts?.pageNumber !== undefined) {
641
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
642
+ }
643
+ if (queryParamOpts?.date !== undefined) {
644
+ urlParams.append("date", queryParamOpts?.date.toString());
645
+ }
646
+ let startTime;
647
+ if (this.debug) {
648
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
649
+ }
650
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
651
+ headers: {
652
+ "Authorization": `Bearer ${this.apiKey}`,
653
+ "X-Requested-With": userAgent
654
+ }
655
+ }));
656
+ debugOutput(response.url, response.status, startTime);
657
+ if (response.status === 429) {
658
+ try {
659
+ data = await this.LIMIT(() => backoff.backOff(response.url));
660
+ }
661
+ catch (error) {
662
+ success = true;
663
+ return {
664
+ data: null,
665
+ error: true,
666
+ error_code: response.status,
667
+ error_message: error.message
668
+ };
669
+ }
670
+ }
671
+ else {
672
+ data = await response.json();
673
+ }
674
+ const dataClass = new TokenHoldersResponse(data.data);
675
+ checkAndModifyResponse(dataClass);
676
+ success = true;
677
+ return {
678
+ data: dataClass,
679
+ error: data.error,
680
+ error_code: data ? data.error_code : response.status,
681
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
682
+ };
683
+ }
684
+ catch (error) {
685
+ success = true;
686
+ return {
687
+ data: null,
688
+ error: true,
689
+ error_code: data ? data.error_code : response.status,
690
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
691
+ };
692
+ }
693
+ }
694
+ }
609
695
  /**
610
696
  *
611
697
  * 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.