@covalenthq/client-sdk 0.4.2 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -40
- package/dist/cjs/index.js +956 -239
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +100 -0
- package/dist/cjs/services/BaseService.d.ts +17 -0
- package/dist/cjs/services/CovalentClient.d.ts +3 -3
- package/dist/cjs/services/NftService.d.ts +137 -1
- package/dist/cjs/services/SecurityService.d.ts +62 -0
- package/dist/cjs/services/TransactionService.d.ts +65 -0
- package/dist/cjs/services/XykService.d.ts +4 -0
- package/dist/cjs/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/cjs/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/cjs/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/es/index.js +956 -239
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +100 -0
- package/dist/es/services/BaseService.d.ts +17 -0
- package/dist/es/services/CovalentClient.d.ts +3 -3
- package/dist/es/services/NftService.d.ts +137 -1
- package/dist/es/services/SecurityService.d.ts +62 -0
- package/dist/es/services/TransactionService.d.ts +65 -0
- package/dist/es/services/XykService.d.ts +4 -0
- package/dist/es/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/es/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/es/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/es/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/es/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/esm/index.js +956 -239
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +100 -0
- package/dist/esm/services/BaseService.d.ts +17 -0
- package/dist/esm/services/CovalentClient.d.ts +3 -3
- package/dist/esm/services/NftService.d.ts +137 -1
- package/dist/esm/services/SecurityService.d.ts +62 -0
- package/dist/esm/services/TransactionService.d.ts +65 -0
- package/dist/esm/services/XykService.d.ts +4 -0
- package/dist/esm/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/esm/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/esm/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/esm/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/services/BalanceService.d.ts +100 -0
- package/dist/services/BalanceService.js +193 -6
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +17 -0
- package/dist/services/BaseService.js +23 -12
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +3 -3
- package/dist/services/CovalentClient.js +1 -1
- package/dist/services/NftService.d.ts +137 -1
- package/dist/services/NftService.js +294 -16
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.js +2 -2
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +62 -0
- package/dist/services/SecurityService.js +103 -2
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +65 -0
- package/dist/services/TransactionService.js +116 -7
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +4 -0
- package/dist/services/XykService.js +34 -28
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.js +1 -1
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/util/types/TransactionServiceTypes.d.ts +27 -0
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, Response } from "./CovalentClient";
|
|
1
|
+
import { Chain, Quote, Response } from "./CovalentClient";
|
|
2
2
|
declare class ChainCollectionItem {
|
|
3
3
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
4
4
|
contract_address: string;
|
|
@@ -315,6 +315,88 @@ declare class NftOwnershipForCollectionItem {
|
|
|
315
315
|
nft_data: NftData;
|
|
316
316
|
constructor(data: NftOwnershipForCollectionItem);
|
|
317
317
|
}
|
|
318
|
+
declare class NftMarketSaleCountResponse {
|
|
319
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
320
|
+
updated_at: Date;
|
|
321
|
+
/** * The requested address. */
|
|
322
|
+
address: string;
|
|
323
|
+
/** * The requested quote currency eg: `USD`. */
|
|
324
|
+
quote_currency: string;
|
|
325
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
326
|
+
chain_name: string;
|
|
327
|
+
/** * The requested chain ID eg: `1`. */
|
|
328
|
+
chain_id: number;
|
|
329
|
+
/** * List of response items. */
|
|
330
|
+
items: MarketSaleCountItem[];
|
|
331
|
+
constructor(data: NftMarketSaleCountResponse);
|
|
332
|
+
}
|
|
333
|
+
declare class MarketSaleCountItem {
|
|
334
|
+
/** * The timestamp of the date of sale. */
|
|
335
|
+
date: Date;
|
|
336
|
+
/** * The total amount of sales for the current day. */
|
|
337
|
+
sale_count: number;
|
|
338
|
+
constructor(data: MarketSaleCountItem);
|
|
339
|
+
}
|
|
340
|
+
declare class NftMarketVolumeResponse {
|
|
341
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
342
|
+
updated_at: Date;
|
|
343
|
+
/** * The requested address. */
|
|
344
|
+
address: string;
|
|
345
|
+
/** * The requested quote currency eg: `USD`. */
|
|
346
|
+
quote_currency: string;
|
|
347
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
348
|
+
chain_name: string;
|
|
349
|
+
/** * The requested chain ID eg: `1`. */
|
|
350
|
+
chain_id: number;
|
|
351
|
+
/** * List of response items. */
|
|
352
|
+
items: MarketVolumeItem[];
|
|
353
|
+
constructor(data: NftMarketVolumeResponse);
|
|
354
|
+
}
|
|
355
|
+
declare class MarketVolumeItem {
|
|
356
|
+
/** * The timestamp of the date of sale. */
|
|
357
|
+
date: Date;
|
|
358
|
+
/** * The ticker symbol for the native currency. */
|
|
359
|
+
native_ticker_symbol: string;
|
|
360
|
+
/** * The contract name of the native currency. */
|
|
361
|
+
native_name: string;
|
|
362
|
+
/** * The current volume converted to fiat in `quote-currency`. */
|
|
363
|
+
volume_quote: number;
|
|
364
|
+
/** * The current volume in native currency. */
|
|
365
|
+
volume_native_quote: number;
|
|
366
|
+
/** * A prettier version of the volume quote for rendering purposes. */
|
|
367
|
+
pretty_volume_quote: string;
|
|
368
|
+
constructor(data: MarketVolumeItem);
|
|
369
|
+
}
|
|
370
|
+
declare class NftMarketFloorPriceResponse {
|
|
371
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
372
|
+
updated_at: Date;
|
|
373
|
+
/** * The requested address. */
|
|
374
|
+
address: string;
|
|
375
|
+
/** * The requested quote currency eg: `USD`. */
|
|
376
|
+
quote_currency: string;
|
|
377
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
378
|
+
chain_name: string;
|
|
379
|
+
/** * The requested chain ID eg: `1`. */
|
|
380
|
+
chain_id: number;
|
|
381
|
+
/** * List of response items. */
|
|
382
|
+
items: MarketFloorPriceItem[];
|
|
383
|
+
constructor(data: NftMarketFloorPriceResponse);
|
|
384
|
+
}
|
|
385
|
+
declare class MarketFloorPriceItem {
|
|
386
|
+
/** * The timestamp of the date of sale. */
|
|
387
|
+
date: Date;
|
|
388
|
+
/** * The ticker symbol for the native currency. */
|
|
389
|
+
native_ticker_symbol: string;
|
|
390
|
+
/** * The contract name of the native currency. */
|
|
391
|
+
native_name: string;
|
|
392
|
+
/** * The current floor price in native currency. */
|
|
393
|
+
floor_price_native_quote: number;
|
|
394
|
+
/** * The current floor price converted to fiat in `quote-currency`. */
|
|
395
|
+
floor_price_quote: number;
|
|
396
|
+
/** * A prettier version of the floor price quote for rendering purposes. */
|
|
397
|
+
pretty_floor_price_quote: string;
|
|
398
|
+
constructor(data: MarketFloorPriceItem);
|
|
399
|
+
}
|
|
318
400
|
export interface GetChainCollectionsQueryParamOpts {
|
|
319
401
|
/** * Number of items per page. Omitting this parameter defaults to 100. */
|
|
320
402
|
pageSize?: number;
|
|
@@ -355,6 +437,24 @@ export interface GetNftTransactionsForContractTokenIdQueryParamOpts {
|
|
|
355
437
|
/** * If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`. */
|
|
356
438
|
noSpam?: boolean;
|
|
357
439
|
}
|
|
440
|
+
export interface GetNftMarketSaleCountQueryParamOpts {
|
|
441
|
+
/** * The number of days to return data for. Request up 365 days. Defaults to 30 days. */
|
|
442
|
+
days?: number;
|
|
443
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
444
|
+
quoteCurrency?: Quote;
|
|
445
|
+
}
|
|
446
|
+
export interface GetNftMarketVolumeQueryParamOpts {
|
|
447
|
+
/** * The number of days to return data for. Request up 365 days. Defaults to 30 days. */
|
|
448
|
+
days?: number;
|
|
449
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
450
|
+
quoteCurrency?: Quote;
|
|
451
|
+
}
|
|
452
|
+
export interface GetNftMarketFloorPriceQueryParamOpts {
|
|
453
|
+
/** * The number of days to return data for. Request up 365 days. Defaults to 30 days. */
|
|
454
|
+
days?: number;
|
|
455
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
456
|
+
quoteCurrency?: Quote;
|
|
457
|
+
}
|
|
358
458
|
/**
|
|
359
459
|
* NFT APIs
|
|
360
460
|
*
|
|
@@ -480,5 +580,41 @@ export declare class NftService {
|
|
|
480
580
|
*
|
|
481
581
|
*/
|
|
482
582
|
checkOwnershipInNftForSpecificTokenId(chainName: Chain, walletAddress: string, collectionContract: string, tokenId: string): Promise<Response<NftOwnershipForCollectionResponse>>;
|
|
583
|
+
/**
|
|
584
|
+
*
|
|
585
|
+
* Commonly used to build a time-series chart of the sales count of an NFT collection.
|
|
586
|
+
*
|
|
587
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
588
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
589
|
+
* @param {GetNftMarketSaleCountQueryParamOpts} queryParamOpts
|
|
590
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
591
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
592
|
+
*
|
|
593
|
+
*/
|
|
594
|
+
getNftMarketSaleCount(chainName: Chain, contractAddress: string, queryParamOpts?: GetNftMarketSaleCountQueryParamOpts): Promise<Response<NftMarketSaleCountResponse>>;
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
* Commonly used to build a time-series chart of the transaction volume of an NFT collection.
|
|
598
|
+
*
|
|
599
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
600
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
601
|
+
* @param {GetNftMarketVolumeQueryParamOpts} queryParamOpts
|
|
602
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
603
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
604
|
+
*
|
|
605
|
+
*/
|
|
606
|
+
getNftMarketVolume(chainName: Chain, contractAddress: string, queryParamOpts?: GetNftMarketVolumeQueryParamOpts): Promise<Response<NftMarketVolumeResponse>>;
|
|
607
|
+
/**
|
|
608
|
+
*
|
|
609
|
+
* Commonly used to render a price floor chart for an NFT collection.
|
|
610
|
+
*
|
|
611
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
612
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
613
|
+
* @param {GetNftMarketFloorPriceQueryParamOpts} queryParamOpts
|
|
614
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
615
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
616
|
+
*
|
|
617
|
+
*/
|
|
618
|
+
getNftMarketFloorPrice(chainName: Chain, contractAddress: string, queryParamOpts?: GetNftMarketFloorPriceQueryParamOpts): Promise<Response<NftMarketFloorPriceResponse>>;
|
|
483
619
|
}
|
|
484
620
|
export {};
|
|
@@ -261,6 +261,62 @@ class NftOwnershipForCollectionItem {
|
|
|
261
261
|
this.nft_data = data.nft_data && data.nft_data !== null ? new NftData(data.nft_data) : null;
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
+
class NftMarketSaleCountResponse {
|
|
265
|
+
constructor(data) {
|
|
266
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
267
|
+
this.address = data.address;
|
|
268
|
+
this.quote_currency = data.quote_currency;
|
|
269
|
+
this.chain_name = data.chain_name;
|
|
270
|
+
this.chain_id = data.chain_id;
|
|
271
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketSaleCountItem(itemData)) : null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
class MarketSaleCountItem {
|
|
275
|
+
constructor(data) {
|
|
276
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
277
|
+
this.sale_count = data.sale_count;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
class NftMarketVolumeResponse {
|
|
281
|
+
constructor(data) {
|
|
282
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
283
|
+
this.address = data.address;
|
|
284
|
+
this.quote_currency = data.quote_currency;
|
|
285
|
+
this.chain_name = data.chain_name;
|
|
286
|
+
this.chain_id = data.chain_id;
|
|
287
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketVolumeItem(itemData)) : null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
class MarketVolumeItem {
|
|
291
|
+
constructor(data) {
|
|
292
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
293
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
294
|
+
this.native_name = data.native_name;
|
|
295
|
+
this.volume_quote = data.volume_quote;
|
|
296
|
+
this.volume_native_quote = data.volume_native_quote;
|
|
297
|
+
this.pretty_volume_quote = data.pretty_volume_quote;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
class NftMarketFloorPriceResponse {
|
|
301
|
+
constructor(data) {
|
|
302
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
303
|
+
this.address = data.address;
|
|
304
|
+
this.quote_currency = data.quote_currency;
|
|
305
|
+
this.chain_name = data.chain_name;
|
|
306
|
+
this.chain_id = data.chain_id;
|
|
307
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketFloorPriceItem(itemData)) : null;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
class MarketFloorPriceItem {
|
|
311
|
+
constructor(data) {
|
|
312
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
313
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
314
|
+
this.native_name = data.native_name;
|
|
315
|
+
this.floor_price_native_quote = data.floor_price_native_quote;
|
|
316
|
+
this.floor_price_quote = data.floor_price_quote;
|
|
317
|
+
this.pretty_floor_price_quote = data.pretty_floor_price_quote;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
264
320
|
/**
|
|
265
321
|
* NFT APIs
|
|
266
322
|
*
|
|
@@ -373,7 +429,7 @@ export class NftService {
|
|
|
373
429
|
data: dataClass,
|
|
374
430
|
error: data.error,
|
|
375
431
|
error_code: data ? data.error_code : response.status,
|
|
376
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
432
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
377
433
|
};
|
|
378
434
|
}
|
|
379
435
|
catch (error) {
|
|
@@ -382,7 +438,7 @@ export class NftService {
|
|
|
382
438
|
data: null,
|
|
383
439
|
error: true,
|
|
384
440
|
error_code: data ? data.error_code : response.status,
|
|
385
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
441
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
386
442
|
};
|
|
387
443
|
}
|
|
388
444
|
}
|
|
@@ -498,7 +554,7 @@ export class NftService {
|
|
|
498
554
|
data: dataClass,
|
|
499
555
|
error: data.error,
|
|
500
556
|
error_code: data ? data.error_code : response.status,
|
|
501
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
557
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
502
558
|
};
|
|
503
559
|
}
|
|
504
560
|
catch (error) {
|
|
@@ -507,7 +563,7 @@ export class NftService {
|
|
|
507
563
|
data: null,
|
|
508
564
|
error: true,
|
|
509
565
|
error_code: data ? data.error_code : response.status,
|
|
510
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
566
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
511
567
|
};
|
|
512
568
|
}
|
|
513
569
|
}
|
|
@@ -569,7 +625,7 @@ export class NftService {
|
|
|
569
625
|
data: dataClass,
|
|
570
626
|
error: data.error,
|
|
571
627
|
error_code: data ? data.error_code : response.status,
|
|
572
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
628
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
573
629
|
};
|
|
574
630
|
}
|
|
575
631
|
catch (error) {
|
|
@@ -578,7 +634,7 @@ export class NftService {
|
|
|
578
634
|
data: null,
|
|
579
635
|
error: true,
|
|
580
636
|
error_code: data ? data.error_code : response.status,
|
|
581
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
637
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
582
638
|
};
|
|
583
639
|
}
|
|
584
640
|
}
|
|
@@ -634,7 +690,7 @@ export class NftService {
|
|
|
634
690
|
data: dataClass,
|
|
635
691
|
error: data.error,
|
|
636
692
|
error_code: data ? data.error_code : response.status,
|
|
637
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
693
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
638
694
|
};
|
|
639
695
|
}
|
|
640
696
|
catch (error) {
|
|
@@ -643,7 +699,7 @@ export class NftService {
|
|
|
643
699
|
data: null,
|
|
644
700
|
error: true,
|
|
645
701
|
error_code: data ? data.error_code : response.status,
|
|
646
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
702
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
647
703
|
};
|
|
648
704
|
}
|
|
649
705
|
}
|
|
@@ -700,7 +756,7 @@ export class NftService {
|
|
|
700
756
|
data: dataClass,
|
|
701
757
|
error: data.error,
|
|
702
758
|
error_code: data ? data.error_code : response.status,
|
|
703
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
759
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
704
760
|
};
|
|
705
761
|
}
|
|
706
762
|
catch (error) {
|
|
@@ -709,7 +765,7 @@ export class NftService {
|
|
|
709
765
|
data: null,
|
|
710
766
|
error: true,
|
|
711
767
|
error_code: data ? data.error_code : response.status,
|
|
712
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
768
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
713
769
|
};
|
|
714
770
|
}
|
|
715
771
|
}
|
|
@@ -765,7 +821,7 @@ export class NftService {
|
|
|
765
821
|
data: dataClass,
|
|
766
822
|
error: data.error,
|
|
767
823
|
error_code: data ? data.error_code : response.status,
|
|
768
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
824
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
769
825
|
};
|
|
770
826
|
}
|
|
771
827
|
catch (error) {
|
|
@@ -774,7 +830,7 @@ export class NftService {
|
|
|
774
830
|
data: null,
|
|
775
831
|
error: true,
|
|
776
832
|
error_code: data ? data.error_code : response.status,
|
|
777
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
833
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
778
834
|
};
|
|
779
835
|
}
|
|
780
836
|
}
|
|
@@ -831,7 +887,7 @@ export class NftService {
|
|
|
831
887
|
data: dataClass,
|
|
832
888
|
error: data.error,
|
|
833
889
|
error_code: data ? data.error_code : response.status,
|
|
834
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
890
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
835
891
|
};
|
|
836
892
|
}
|
|
837
893
|
catch (error) {
|
|
@@ -840,7 +896,7 @@ export class NftService {
|
|
|
840
896
|
data: null,
|
|
841
897
|
error: true,
|
|
842
898
|
error_code: data ? data.error_code : response.status,
|
|
843
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
899
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
844
900
|
};
|
|
845
901
|
}
|
|
846
902
|
}
|
|
@@ -898,7 +954,229 @@ export class NftService {
|
|
|
898
954
|
data: dataClass,
|
|
899
955
|
error: data.error,
|
|
900
956
|
error_code: data ? data.error_code : response.status,
|
|
901
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
957
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
catch (error) {
|
|
961
|
+
success = true;
|
|
962
|
+
return {
|
|
963
|
+
data: null,
|
|
964
|
+
error: true,
|
|
965
|
+
error_code: data ? data.error_code : response.status,
|
|
966
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
*
|
|
973
|
+
* Commonly used to build a time-series chart of the sales count of an NFT collection.
|
|
974
|
+
*
|
|
975
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
976
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
977
|
+
* @param {GetNftMarketSaleCountQueryParamOpts} queryParamOpts
|
|
978
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
979
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
980
|
+
*
|
|
981
|
+
*/
|
|
982
|
+
async getNftMarketSaleCount(chainName, contractAddress, queryParamOpts) {
|
|
983
|
+
let success = false;
|
|
984
|
+
let data;
|
|
985
|
+
let response;
|
|
986
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
987
|
+
while (!success) {
|
|
988
|
+
try {
|
|
989
|
+
const urlParams = new URLSearchParams();
|
|
990
|
+
if (queryParamOpts?.days !== undefined) {
|
|
991
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
992
|
+
}
|
|
993
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
994
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
995
|
+
}
|
|
996
|
+
let startTime;
|
|
997
|
+
if (this.debug) {
|
|
998
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
999
|
+
}
|
|
1000
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`, {
|
|
1001
|
+
headers: {
|
|
1002
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1003
|
+
"X-Requested-With": userAgent
|
|
1004
|
+
}
|
|
1005
|
+
}));
|
|
1006
|
+
debugOutput(response.url, response.status, startTime);
|
|
1007
|
+
if (response.status === 429) {
|
|
1008
|
+
try {
|
|
1009
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1010
|
+
}
|
|
1011
|
+
catch (error) {
|
|
1012
|
+
success = true;
|
|
1013
|
+
return {
|
|
1014
|
+
data: null,
|
|
1015
|
+
error: true,
|
|
1016
|
+
error_code: response.status,
|
|
1017
|
+
error_message: error.message
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
else {
|
|
1022
|
+
data = await response.json();
|
|
1023
|
+
}
|
|
1024
|
+
const dataClass = new NftMarketSaleCountResponse(data.data);
|
|
1025
|
+
checkAndModifyResponse(dataClass);
|
|
1026
|
+
success = true;
|
|
1027
|
+
return {
|
|
1028
|
+
data: dataClass,
|
|
1029
|
+
error: data.error,
|
|
1030
|
+
error_code: data ? data.error_code : response.status,
|
|
1031
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
catch (error) {
|
|
1035
|
+
success = true;
|
|
1036
|
+
return {
|
|
1037
|
+
data: null,
|
|
1038
|
+
error: true,
|
|
1039
|
+
error_code: data ? data.error_code : response.status,
|
|
1040
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
*
|
|
1047
|
+
* Commonly used to build a time-series chart of the transaction volume of an NFT collection.
|
|
1048
|
+
*
|
|
1049
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1050
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1051
|
+
* @param {GetNftMarketVolumeQueryParamOpts} queryParamOpts
|
|
1052
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
1053
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
1054
|
+
*
|
|
1055
|
+
*/
|
|
1056
|
+
async getNftMarketVolume(chainName, contractAddress, queryParamOpts) {
|
|
1057
|
+
let success = false;
|
|
1058
|
+
let data;
|
|
1059
|
+
let response;
|
|
1060
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1061
|
+
while (!success) {
|
|
1062
|
+
try {
|
|
1063
|
+
const urlParams = new URLSearchParams();
|
|
1064
|
+
if (queryParamOpts?.days !== undefined) {
|
|
1065
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
1066
|
+
}
|
|
1067
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1068
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1069
|
+
}
|
|
1070
|
+
let startTime;
|
|
1071
|
+
if (this.debug) {
|
|
1072
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1073
|
+
}
|
|
1074
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`, {
|
|
1075
|
+
headers: {
|
|
1076
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1077
|
+
"X-Requested-With": userAgent
|
|
1078
|
+
}
|
|
1079
|
+
}));
|
|
1080
|
+
debugOutput(response.url, response.status, startTime);
|
|
1081
|
+
if (response.status === 429) {
|
|
1082
|
+
try {
|
|
1083
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1084
|
+
}
|
|
1085
|
+
catch (error) {
|
|
1086
|
+
success = true;
|
|
1087
|
+
return {
|
|
1088
|
+
data: null,
|
|
1089
|
+
error: true,
|
|
1090
|
+
error_code: response.status,
|
|
1091
|
+
error_message: error.message
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
else {
|
|
1096
|
+
data = await response.json();
|
|
1097
|
+
}
|
|
1098
|
+
const dataClass = new NftMarketVolumeResponse(data.data);
|
|
1099
|
+
checkAndModifyResponse(dataClass);
|
|
1100
|
+
success = true;
|
|
1101
|
+
return {
|
|
1102
|
+
data: dataClass,
|
|
1103
|
+
error: data.error,
|
|
1104
|
+
error_code: data ? data.error_code : response.status,
|
|
1105
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
catch (error) {
|
|
1109
|
+
success = true;
|
|
1110
|
+
return {
|
|
1111
|
+
data: null,
|
|
1112
|
+
error: true,
|
|
1113
|
+
error_code: data ? data.error_code : response.status,
|
|
1114
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
*
|
|
1121
|
+
* Commonly used to render a price floor chart for an NFT collection.
|
|
1122
|
+
*
|
|
1123
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1124
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1125
|
+
* @param {GetNftMarketFloorPriceQueryParamOpts} queryParamOpts
|
|
1126
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
1127
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
1128
|
+
*
|
|
1129
|
+
*/
|
|
1130
|
+
async getNftMarketFloorPrice(chainName, contractAddress, queryParamOpts) {
|
|
1131
|
+
let success = false;
|
|
1132
|
+
let data;
|
|
1133
|
+
let response;
|
|
1134
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1135
|
+
while (!success) {
|
|
1136
|
+
try {
|
|
1137
|
+
const urlParams = new URLSearchParams();
|
|
1138
|
+
if (queryParamOpts?.days !== undefined) {
|
|
1139
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
1140
|
+
}
|
|
1141
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1142
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1143
|
+
}
|
|
1144
|
+
let startTime;
|
|
1145
|
+
if (this.debug) {
|
|
1146
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1147
|
+
}
|
|
1148
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`, {
|
|
1149
|
+
headers: {
|
|
1150
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1151
|
+
"X-Requested-With": userAgent
|
|
1152
|
+
}
|
|
1153
|
+
}));
|
|
1154
|
+
debugOutput(response.url, response.status, startTime);
|
|
1155
|
+
if (response.status === 429) {
|
|
1156
|
+
try {
|
|
1157
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1158
|
+
}
|
|
1159
|
+
catch (error) {
|
|
1160
|
+
success = true;
|
|
1161
|
+
return {
|
|
1162
|
+
data: null,
|
|
1163
|
+
error: true,
|
|
1164
|
+
error_code: response.status,
|
|
1165
|
+
error_message: error.message
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
data = await response.json();
|
|
1171
|
+
}
|
|
1172
|
+
const dataClass = new NftMarketFloorPriceResponse(data.data);
|
|
1173
|
+
checkAndModifyResponse(dataClass);
|
|
1174
|
+
success = true;
|
|
1175
|
+
return {
|
|
1176
|
+
data: dataClass,
|
|
1177
|
+
error: data.error,
|
|
1178
|
+
error_code: data ? data.error_code : response.status,
|
|
1179
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
902
1180
|
};
|
|
903
1181
|
}
|
|
904
1182
|
catch (error) {
|
|
@@ -907,7 +1185,7 @@ export class NftService {
|
|
|
907
1185
|
data: null,
|
|
908
1186
|
error: true,
|
|
909
1187
|
error_code: data ? data.error_code : response.status,
|
|
910
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1188
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
911
1189
|
};
|
|
912
1190
|
}
|
|
913
1191
|
}
|