@covalenthq/client-sdk 0.5.3 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/cjs/index.js +597 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +51 -1
- package/dist/cjs/services/BaseService.d.ts +92 -0
- package/dist/cjs/services/CovalentClient.d.ts +1 -1
- package/dist/cjs/services/NftService.d.ts +47 -0
- package/dist/cjs/services/TransactionService.d.ts +3 -0
- package/dist/cjs/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/cjs/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/es/index.js +597 -26
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +51 -1
- package/dist/es/services/BaseService.d.ts +92 -0
- package/dist/es/services/CovalentClient.d.ts +1 -1
- package/dist/es/services/NftService.d.ts +47 -0
- package/dist/es/services/TransactionService.d.ts +3 -0
- package/dist/es/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/es/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/esm/index.js +597 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +51 -1
- package/dist/esm/services/BaseService.d.ts +92 -0
- package/dist/esm/services/CovalentClient.d.ts +1 -1
- package/dist/esm/services/NftService.d.ts +47 -0
- package/dist/esm/services/TransactionService.d.ts +3 -0
- package/dist/esm/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/esm/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/services/BalanceService.d.ts +51 -1
- package/dist/services/BalanceService.js +101 -0
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +92 -0
- package/dist/services/BaseService.js +243 -0
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +1 -1
- package/dist/services/CovalentClient.js +1 -1
- package/dist/services/NftService.d.ts +47 -0
- package/dist/services/NftService.js +170 -0
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +3 -0
- package/dist/services/TransactionService.js +4 -0
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/util/types/NftServiceTypes.d.ts +6 -0
- package/package.json +1 -1
|
@@ -23,10 +23,14 @@ declare class BalanceItem {
|
|
|
23
23
|
contract_ticker_symbol: string;
|
|
24
24
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
25
25
|
contract_address: string;
|
|
26
|
+
/** * A display-friendly name for the contract. */
|
|
27
|
+
contract_display_name: string;
|
|
26
28
|
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
27
29
|
supports_erc: string;
|
|
28
30
|
/** * The contract logo URL. */
|
|
29
31
|
logo_url: string;
|
|
32
|
+
/** * The balance item logo URLs. */
|
|
33
|
+
logo_urls: LogoUrls;
|
|
30
34
|
/** * The timestamp when the token was transferred. */
|
|
31
35
|
last_transferred_at: Date;
|
|
32
36
|
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
@@ -51,10 +55,26 @@ declare class BalanceItem {
|
|
|
51
55
|
pretty_quote: string;
|
|
52
56
|
/** * A prettier version of the 24h quote for rendering purposes. */
|
|
53
57
|
pretty_quote_24h: string;
|
|
58
|
+
/** * The protocol metadata. */
|
|
59
|
+
protocol_metadata: ProtocolMetadata;
|
|
54
60
|
/** * NFT-specific data. */
|
|
55
61
|
nft_data: NftData[];
|
|
56
62
|
constructor(data: BalanceItem);
|
|
57
63
|
}
|
|
64
|
+
declare class LogoUrls {
|
|
65
|
+
/** * The token logo URL. */
|
|
66
|
+
token_logo_url: string;
|
|
67
|
+
/** * The protocol logo URL. */
|
|
68
|
+
protocol_logo_url: string;
|
|
69
|
+
/** * The chain logo URL. */
|
|
70
|
+
chain_logo_url: string;
|
|
71
|
+
constructor(data: LogoUrls);
|
|
72
|
+
}
|
|
73
|
+
declare class ProtocolMetadata {
|
|
74
|
+
/** * The name of the protocol. */
|
|
75
|
+
protocol_name: string;
|
|
76
|
+
constructor(data: ProtocolMetadata);
|
|
77
|
+
}
|
|
58
78
|
declare class NftData {
|
|
59
79
|
/** * The token's id. */
|
|
60
80
|
token_id: bigint | null;
|
|
@@ -253,6 +273,19 @@ declare class MethodCallsForTransfers {
|
|
|
253
273
|
method: string;
|
|
254
274
|
constructor(data: MethodCallsForTransfers);
|
|
255
275
|
}
|
|
276
|
+
declare class TokenHoldersResponse {
|
|
277
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
278
|
+
updated_at: Date;
|
|
279
|
+
/** * The requested chain ID eg: `1`. */
|
|
280
|
+
chain_id: number;
|
|
281
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
282
|
+
chain_name: string;
|
|
283
|
+
/** * List of response items. */
|
|
284
|
+
items: TokenHolder[];
|
|
285
|
+
/** * Pagination metadata. */
|
|
286
|
+
pagination: Pagination;
|
|
287
|
+
constructor(data: TokenHoldersResponse);
|
|
288
|
+
}
|
|
256
289
|
declare class TokenHolder {
|
|
257
290
|
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
258
291
|
contract_decimals: number;
|
|
@@ -403,6 +436,8 @@ export interface GetErc20TransfersForWalletAddressQueryParamOpts {
|
|
|
403
436
|
export interface GetTokenHoldersV2ForTokenAddressQueryParamOpts {
|
|
404
437
|
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
|
|
405
438
|
blockHeight?: number;
|
|
439
|
+
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
|
|
440
|
+
date?: string;
|
|
406
441
|
/** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
|
|
407
442
|
pageSize?: number;
|
|
408
443
|
/** * 0-indexed page number to begin pagination. */
|
|
@@ -422,7 +457,7 @@ export interface GetHistoricalTokenBalancesForWalletAddressQueryParamOpts {
|
|
|
422
457
|
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
|
|
423
458
|
blockHeight?: number;
|
|
424
459
|
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
|
|
425
|
-
date?:
|
|
460
|
+
date?: string;
|
|
426
461
|
}
|
|
427
462
|
export interface GetNativeTokenBalanceQueryParamOpts {
|
|
428
463
|
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
@@ -509,9 +544,24 @@ export declare class BalanceService {
|
|
|
509
544
|
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
510
545
|
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
511
546
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
547
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
512
548
|
*
|
|
513
549
|
*/
|
|
514
550
|
getTokenHoldersV2ForTokenAddress(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
* 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.
|
|
554
|
+
*
|
|
555
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
556
|
+
* @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
557
|
+
* @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
|
|
558
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
559
|
+
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
560
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
561
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
562
|
+
*
|
|
563
|
+
*/
|
|
564
|
+
getTokenHoldersV2ForTokenAddressByPage(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
|
|
515
565
|
/**
|
|
516
566
|
*
|
|
517
567
|
* 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;
|
|
@@ -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;
|
|
@@ -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.
|
|
24
|
+
export declare const userAgent = "com.covalenthq.sdk.typescript/0.6.1";
|
|
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
|
}
|
|
@@ -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.
|
|
@@ -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>>;
|
|
@@ -22,10 +22,14 @@ export interface BalanceItem {
|
|
|
22
22
|
contract_ticker_symbol: string;
|
|
23
23
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
24
24
|
contract_address: string;
|
|
25
|
+
/** * A display-friendly name for the contract. */
|
|
26
|
+
contract_display_name: string;
|
|
25
27
|
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
26
28
|
supports_erc: string;
|
|
27
29
|
/** * The contract logo URL. */
|
|
28
30
|
logo_url: string;
|
|
31
|
+
/** * The balance item logo URLs. */
|
|
32
|
+
logo_urls: LogoUrls;
|
|
29
33
|
/** * The timestamp when the token was transferred. */
|
|
30
34
|
last_transferred_at: Date;
|
|
31
35
|
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
@@ -50,9 +54,23 @@ export interface BalanceItem {
|
|
|
50
54
|
pretty_quote: string;
|
|
51
55
|
/** * A prettier version of the 24h quote for rendering purposes. */
|
|
52
56
|
pretty_quote_24h: string;
|
|
57
|
+
/** * The protocol metadata. */
|
|
58
|
+
protocol_metadata: ProtocolMetadata;
|
|
53
59
|
/** * NFT-specific data. */
|
|
54
60
|
nft_data: NftData[];
|
|
55
61
|
}
|
|
62
|
+
export interface LogoUrls {
|
|
63
|
+
/** * The token logo URL. */
|
|
64
|
+
token_logo_url: string;
|
|
65
|
+
/** * The protocol logo URL. */
|
|
66
|
+
protocol_logo_url: string;
|
|
67
|
+
/** * The chain logo URL. */
|
|
68
|
+
chain_logo_url: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ProtocolMetadata {
|
|
71
|
+
/** * The name of the protocol. */
|
|
72
|
+
protocol_name: string;
|
|
73
|
+
}
|
|
56
74
|
export interface PortfolioResponse {
|
|
57
75
|
/** * The requested address. */
|
|
58
76
|
address: string;
|
|
@@ -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 {
|
|
@@ -23,10 +23,14 @@ declare class BalanceItem {
|
|
|
23
23
|
contract_ticker_symbol: string;
|
|
24
24
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
25
25
|
contract_address: string;
|
|
26
|
+
/** * A display-friendly name for the contract. */
|
|
27
|
+
contract_display_name: string;
|
|
26
28
|
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
27
29
|
supports_erc: string;
|
|
28
30
|
/** * The contract logo URL. */
|
|
29
31
|
logo_url: string;
|
|
32
|
+
/** * The balance item logo URLs. */
|
|
33
|
+
logo_urls: LogoUrls;
|
|
30
34
|
/** * The timestamp when the token was transferred. */
|
|
31
35
|
last_transferred_at: Date;
|
|
32
36
|
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
@@ -51,10 +55,26 @@ declare class BalanceItem {
|
|
|
51
55
|
pretty_quote: string;
|
|
52
56
|
/** * A prettier version of the 24h quote for rendering purposes. */
|
|
53
57
|
pretty_quote_24h: string;
|
|
58
|
+
/** * The protocol metadata. */
|
|
59
|
+
protocol_metadata: ProtocolMetadata;
|
|
54
60
|
/** * NFT-specific data. */
|
|
55
61
|
nft_data: NftData[];
|
|
56
62
|
constructor(data: BalanceItem);
|
|
57
63
|
}
|
|
64
|
+
declare class LogoUrls {
|
|
65
|
+
/** * The token logo URL. */
|
|
66
|
+
token_logo_url: string;
|
|
67
|
+
/** * The protocol logo URL. */
|
|
68
|
+
protocol_logo_url: string;
|
|
69
|
+
/** * The chain logo URL. */
|
|
70
|
+
chain_logo_url: string;
|
|
71
|
+
constructor(data: LogoUrls);
|
|
72
|
+
}
|
|
73
|
+
declare class ProtocolMetadata {
|
|
74
|
+
/** * The name of the protocol. */
|
|
75
|
+
protocol_name: string;
|
|
76
|
+
constructor(data: ProtocolMetadata);
|
|
77
|
+
}
|
|
58
78
|
declare class NftData {
|
|
59
79
|
/** * The token's id. */
|
|
60
80
|
token_id: bigint | null;
|
|
@@ -253,6 +273,19 @@ declare class MethodCallsForTransfers {
|
|
|
253
273
|
method: string;
|
|
254
274
|
constructor(data: MethodCallsForTransfers);
|
|
255
275
|
}
|
|
276
|
+
declare class TokenHoldersResponse {
|
|
277
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
278
|
+
updated_at: Date;
|
|
279
|
+
/** * The requested chain ID eg: `1`. */
|
|
280
|
+
chain_id: number;
|
|
281
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
282
|
+
chain_name: string;
|
|
283
|
+
/** * List of response items. */
|
|
284
|
+
items: TokenHolder[];
|
|
285
|
+
/** * Pagination metadata. */
|
|
286
|
+
pagination: Pagination;
|
|
287
|
+
constructor(data: TokenHoldersResponse);
|
|
288
|
+
}
|
|
256
289
|
declare class TokenHolder {
|
|
257
290
|
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
258
291
|
contract_decimals: number;
|
|
@@ -403,6 +436,8 @@ export interface GetErc20TransfersForWalletAddressQueryParamOpts {
|
|
|
403
436
|
export interface GetTokenHoldersV2ForTokenAddressQueryParamOpts {
|
|
404
437
|
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
|
|
405
438
|
blockHeight?: number;
|
|
439
|
+
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
|
|
440
|
+
date?: string;
|
|
406
441
|
/** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
|
|
407
442
|
pageSize?: number;
|
|
408
443
|
/** * 0-indexed page number to begin pagination. */
|
|
@@ -422,7 +457,7 @@ export interface GetHistoricalTokenBalancesForWalletAddressQueryParamOpts {
|
|
|
422
457
|
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
|
|
423
458
|
blockHeight?: number;
|
|
424
459
|
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
|
|
425
|
-
date?:
|
|
460
|
+
date?: string;
|
|
426
461
|
}
|
|
427
462
|
export interface GetNativeTokenBalanceQueryParamOpts {
|
|
428
463
|
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
@@ -509,9 +544,24 @@ export declare class BalanceService {
|
|
|
509
544
|
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
510
545
|
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
511
546
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
547
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
512
548
|
*
|
|
513
549
|
*/
|
|
514
550
|
getTokenHoldersV2ForTokenAddress(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<TokenHolder>;
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
* 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.
|
|
554
|
+
*
|
|
555
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
556
|
+
* @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
557
|
+
* @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
|
|
558
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
559
|
+
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
560
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
561
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
562
|
+
*
|
|
563
|
+
*/
|
|
564
|
+
getTokenHoldersV2ForTokenAddressByPage(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<Response<TokenHoldersResponse>>;
|
|
515
565
|
/**
|
|
516
566
|
*
|
|
517
567
|
* 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.
|
|
@@ -19,6 +19,7 @@ class BalanceItem {
|
|
|
19
19
|
this.contract_name = data.contract_name;
|
|
20
20
|
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
21
21
|
this.contract_address = data.contract_address;
|
|
22
|
+
this.contract_display_name = data.contract_display_name;
|
|
22
23
|
this.supports_erc = data.supports_erc;
|
|
23
24
|
this.logo_url = data.logo_url;
|
|
24
25
|
this.last_transferred_at = data.last_transferred_at && data.last_transferred_at !== null ? parseISO(data.last_transferred_at.toString()) : null;
|
|
@@ -33,9 +34,23 @@ class BalanceItem {
|
|
|
33
34
|
this.quote_24h = data.quote_24h;
|
|
34
35
|
this.pretty_quote = data.pretty_quote;
|
|
35
36
|
this.pretty_quote_24h = data.pretty_quote_24h;
|
|
37
|
+
this.logo_urls = data.logo_urls && data.logo_urls !== null ? new LogoUrls(data.logo_urls) : null;
|
|
38
|
+
this.protocol_metadata = data.protocol_metadata && data.protocol_metadata !== null ? new ProtocolMetadata(data.protocol_metadata) : null;
|
|
36
39
|
this.nft_data = data.nft_data && data.nft_data !== null ? data.nft_data.map((itemData) => new NftData(itemData)) : null;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
42
|
+
class LogoUrls {
|
|
43
|
+
constructor(data) {
|
|
44
|
+
this.token_logo_url = data.token_logo_url;
|
|
45
|
+
this.protocol_logo_url = data.protocol_logo_url;
|
|
46
|
+
this.chain_logo_url = data.chain_logo_url;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class ProtocolMetadata {
|
|
50
|
+
constructor(data) {
|
|
51
|
+
this.protocol_name = data.protocol_name;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
39
54
|
class NftData {
|
|
40
55
|
constructor(data) {
|
|
41
56
|
this.token_id = data.token_id && data.token_id !== null ? BigInt(data.token_id) : null;
|
|
@@ -578,6 +593,7 @@ export class BalanceService {
|
|
|
578
593
|
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
579
594
|
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
580
595
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
596
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
581
597
|
*
|
|
582
598
|
*/
|
|
583
599
|
async *getTokenHoldersV2ForTokenAddress(chainName, tokenAddress, queryParamOpts) {
|
|
@@ -595,6 +611,9 @@ export class BalanceService {
|
|
|
595
611
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
596
612
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
597
613
|
}
|
|
614
|
+
if (queryParamOpts?.date !== undefined) {
|
|
615
|
+
urlParams.append("date", queryParamOpts?.date.toString());
|
|
616
|
+
}
|
|
598
617
|
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
618
|
yield res;
|
|
600
619
|
}
|
|
@@ -606,6 +625,88 @@ export class BalanceService {
|
|
|
606
625
|
}
|
|
607
626
|
}
|
|
608
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
*
|
|
630
|
+
* 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.
|
|
631
|
+
*
|
|
632
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
633
|
+
* @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
634
|
+
* @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
|
|
635
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
636
|
+
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
637
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
638
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
639
|
+
*
|
|
640
|
+
*/
|
|
641
|
+
async getTokenHoldersV2ForTokenAddressByPage(chainName, tokenAddress, queryParamOpts) {
|
|
642
|
+
let success = false;
|
|
643
|
+
let data;
|
|
644
|
+
let response;
|
|
645
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
646
|
+
while (!success) {
|
|
647
|
+
try {
|
|
648
|
+
const urlParams = new URLSearchParams();
|
|
649
|
+
if (queryParamOpts?.blockHeight !== undefined) {
|
|
650
|
+
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
651
|
+
}
|
|
652
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
653
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
654
|
+
}
|
|
655
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
656
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
657
|
+
}
|
|
658
|
+
if (queryParamOpts?.date !== undefined) {
|
|
659
|
+
urlParams.append("date", queryParamOpts?.date.toString());
|
|
660
|
+
}
|
|
661
|
+
let startTime;
|
|
662
|
+
if (this.debug) {
|
|
663
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
664
|
+
}
|
|
665
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
|
|
666
|
+
headers: {
|
|
667
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
668
|
+
"X-Requested-With": userAgent
|
|
669
|
+
}
|
|
670
|
+
}));
|
|
671
|
+
debugOutput(response.url, response.status, startTime);
|
|
672
|
+
if (response.status === 429) {
|
|
673
|
+
try {
|
|
674
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
success = true;
|
|
678
|
+
return {
|
|
679
|
+
data: null,
|
|
680
|
+
error: true,
|
|
681
|
+
error_code: response.status,
|
|
682
|
+
error_message: error.message
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
data = await response.json();
|
|
688
|
+
}
|
|
689
|
+
const dataClass = new TokenHoldersResponse(data.data);
|
|
690
|
+
checkAndModifyResponse(dataClass);
|
|
691
|
+
success = true;
|
|
692
|
+
return {
|
|
693
|
+
data: dataClass,
|
|
694
|
+
error: data.error,
|
|
695
|
+
error_code: data ? data.error_code : response.status,
|
|
696
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
catch (error) {
|
|
700
|
+
success = true;
|
|
701
|
+
return {
|
|
702
|
+
data: null,
|
|
703
|
+
error: true,
|
|
704
|
+
error_code: data ? data.error_code : response.status,
|
|
705
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
609
710
|
/**
|
|
610
711
|
*
|
|
611
712
|
* 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.
|