@covalenthq/client-sdk 0.7.4 → 0.7.6
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 +20 -0
- package/dist/cjs/index.js +461 -362
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +2 -1
- package/dist/cjs/services/BaseService.d.ts +2 -1
- package/dist/cjs/services/CovalentClient.d.ts +4 -2
- package/dist/cjs/services/NftService.d.ts +2 -1
- package/dist/cjs/services/PricingService.d.ts +2 -1
- package/dist/cjs/services/SecurityService.d.ts +2 -1
- package/dist/cjs/services/TransactionService.d.ts +8 -4
- package/dist/cjs/services/XykService.d.ts +68 -13
- package/dist/cjs/util/ApiHelpers.d.ts +1 -1
- package/dist/cjs/util/types/XykServiceTypes.d.ts +52 -13
- package/dist/es/index.js +461 -362
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +2 -1
- package/dist/es/services/BaseService.d.ts +2 -1
- package/dist/es/services/CovalentClient.d.ts +4 -2
- package/dist/es/services/NftService.d.ts +2 -1
- package/dist/es/services/PricingService.d.ts +2 -1
- package/dist/es/services/SecurityService.d.ts +2 -1
- package/dist/es/services/TransactionService.d.ts +8 -4
- package/dist/es/services/XykService.d.ts +68 -13
- package/dist/es/util/ApiHelpers.d.ts +1 -1
- package/dist/es/util/types/XykServiceTypes.d.ts +52 -13
- package/dist/esm/index.js +461 -362
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +2 -1
- package/dist/esm/services/BaseService.d.ts +2 -1
- package/dist/esm/services/CovalentClient.d.ts +4 -2
- package/dist/esm/services/NftService.d.ts +2 -1
- package/dist/esm/services/PricingService.d.ts +2 -1
- package/dist/esm/services/SecurityService.d.ts +2 -1
- package/dist/esm/services/TransactionService.d.ts +8 -4
- package/dist/esm/services/XykService.d.ts +68 -13
- package/dist/esm/util/ApiHelpers.d.ts +1 -1
- package/dist/esm/util/types/XykServiceTypes.d.ts +52 -13
- package/dist/services/BalanceService.d.ts +2 -1
- package/dist/services/BalanceService.js +40 -33
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +2 -1
- package/dist/services/BaseService.js +66 -55
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +4 -2
- package/dist/services/CovalentClient.js +17 -17
- package/dist/services/CovalentClient.js.map +1 -1
- package/dist/services/NftService.d.ts +2 -1
- package/dist/services/NftService.js +82 -68
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.d.ts +2 -1
- package/dist/services/PricingService.js +8 -6
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +2 -1
- package/dist/services/SecurityService.js +14 -11
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +8 -4
- package/dist/services/TransactionService.js +95 -79
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +68 -13
- package/dist/services/XykService.js +128 -83
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.d.ts +1 -1
- package/dist/util/ApiHelpers.js +6 -5
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/types/XykServiceTypes.d.ts +52 -13
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { PricingService } from "./PricingService";
|
|
|
6
6
|
import { TransactionService } from "./TransactionService";
|
|
7
7
|
import { XykService } from "./XykService";
|
|
8
8
|
import { ApiKeyValidator } from "../util/ApiKeyValidator";
|
|
9
|
-
export const userAgent = "com.covalenthq.sdk.typescript/0.7.
|
|
9
|
+
export const userAgent = "com.covalenthq.sdk.typescript/0.7.6";
|
|
10
10
|
export class Response {
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -14,16 +14,16 @@ export class Response {
|
|
|
14
14
|
*/
|
|
15
15
|
export class CovalentClient {
|
|
16
16
|
constructor(apiKey, settings) {
|
|
17
|
-
const { debug = false, threadCount = 3 } = settings || {};
|
|
17
|
+
const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
|
|
18
18
|
const validator = new ApiKeyValidator(apiKey);
|
|
19
19
|
this._is_key_valid = validator.isValidApiKey();
|
|
20
|
-
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
21
|
-
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
22
|
-
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
23
|
-
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
24
|
-
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
25
|
-
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
26
|
-
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
20
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
21
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
22
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
23
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
24
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
25
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
26
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -34,16 +34,16 @@ export class CovalentClient {
|
|
|
34
34
|
*/
|
|
35
35
|
export class Client {
|
|
36
36
|
constructor(apiKey, settings) {
|
|
37
|
-
const { debug = false, threadCount = 3 } = settings || {};
|
|
37
|
+
const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
|
|
38
38
|
const validator = new ApiKeyValidator(apiKey);
|
|
39
39
|
this._is_key_valid = validator.isValidApiKey();
|
|
40
|
-
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
41
|
-
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
42
|
-
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
43
|
-
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
44
|
-
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
45
|
-
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
46
|
-
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
40
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
41
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
42
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
43
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
44
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
45
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
46
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
//# sourceMappingURL=CovalentClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CovalentClient.js","sourceRoot":"","sources":["../../src/services/CovalentClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;A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AE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACxG,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACtG,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAC/F,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAC9F,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACtG,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAC9G,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAClG,CAAC;CAEJ"}
|
|
@@ -484,8 +484,9 @@ export declare class NftService {
|
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
486
|
private is_key_valid;
|
|
487
|
+
private enableRetry;
|
|
487
488
|
private LIMIT;
|
|
488
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
489
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
489
490
|
/**
|
|
490
491
|
*
|
|
491
492
|
* Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
|
|
@@ -326,11 +326,12 @@ class MarketFloorPriceItem {
|
|
|
326
326
|
*
|
|
327
327
|
*/
|
|
328
328
|
export class NftService {
|
|
329
|
-
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
329
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
|
|
330
330
|
this.apiKey = apiKey;
|
|
331
331
|
this.debug = debug;
|
|
332
332
|
this.threadCount = threadCount;
|
|
333
333
|
this.is_key_valid = is_key_valid;
|
|
334
|
+
this.enableRetry = enableRetry;
|
|
334
335
|
this.LIMIT = pLimit(this.threadCount);
|
|
335
336
|
}
|
|
336
337
|
/**
|
|
@@ -362,7 +363,7 @@ export class NftService {
|
|
|
362
363
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
363
364
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
364
365
|
}
|
|
365
|
-
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/nft/collections/`, this.apiKey, urlParams, ChainCollectionItem, this.debug, this.threadCount)) {
|
|
366
|
+
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/nft/collections/`, this.apiKey, urlParams, ChainCollectionItem, this.debug, this.threadCount, this.enableRetry)) {
|
|
366
367
|
yield res;
|
|
367
368
|
}
|
|
368
369
|
success = true;
|
|
@@ -409,6 +410,7 @@ export class NftService {
|
|
|
409
410
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
410
411
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
411
412
|
}
|
|
413
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`;
|
|
412
414
|
let startTime;
|
|
413
415
|
if (this.debug) {
|
|
414
416
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -419,10 +421,10 @@ export class NftService {
|
|
|
419
421
|
"X-Requested-With": userAgent
|
|
420
422
|
}
|
|
421
423
|
}));
|
|
422
|
-
debugOutput(response.url, response.status
|
|
423
|
-
if (response.status === null || response.status === 429) {
|
|
424
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
425
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
424
426
|
try {
|
|
425
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
427
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
426
428
|
}
|
|
427
429
|
catch (error) {
|
|
428
430
|
success = true;
|
|
@@ -452,8 +454,8 @@ export class NftService {
|
|
|
452
454
|
return {
|
|
453
455
|
data: null,
|
|
454
456
|
error: true,
|
|
455
|
-
error_code: data ? data.error_code : response.status,
|
|
456
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
457
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
458
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
457
459
|
};
|
|
458
460
|
}
|
|
459
461
|
}
|
|
@@ -495,6 +497,7 @@ export class NftService {
|
|
|
495
497
|
if (queryParamOpts?.withUncached !== undefined) {
|
|
496
498
|
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
497
499
|
}
|
|
500
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`;
|
|
498
501
|
let startTime;
|
|
499
502
|
if (this.debug) {
|
|
500
503
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -505,10 +508,10 @@ export class NftService {
|
|
|
505
508
|
"X-Requested-With": userAgent
|
|
506
509
|
}
|
|
507
510
|
}));
|
|
508
|
-
debugOutput(response.url, response.status
|
|
509
|
-
if (response.status === null || response.status === 429) {
|
|
511
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
512
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
510
513
|
try {
|
|
511
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
514
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
512
515
|
}
|
|
513
516
|
catch (error) {
|
|
514
517
|
success = true;
|
|
@@ -538,8 +541,8 @@ export class NftService {
|
|
|
538
541
|
return {
|
|
539
542
|
data: null,
|
|
540
543
|
error: true,
|
|
541
|
-
error_code: data ? data.error_code : response.status,
|
|
542
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
544
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
545
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
543
546
|
};
|
|
544
547
|
}
|
|
545
548
|
}
|
|
@@ -586,7 +589,7 @@ export class NftService {
|
|
|
586
589
|
if (queryParamOpts?.withUncached !== undefined) {
|
|
587
590
|
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
588
591
|
}
|
|
589
|
-
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount)) {
|
|
592
|
+
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount, this.enableRetry)) {
|
|
590
593
|
yield res;
|
|
591
594
|
}
|
|
592
595
|
success = true;
|
|
@@ -646,6 +649,7 @@ export class NftService {
|
|
|
646
649
|
if (queryParamOpts?.withUncached !== undefined) {
|
|
647
650
|
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
648
651
|
}
|
|
652
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`;
|
|
649
653
|
let startTime;
|
|
650
654
|
if (this.debug) {
|
|
651
655
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -656,10 +660,10 @@ export class NftService {
|
|
|
656
660
|
"X-Requested-With": userAgent
|
|
657
661
|
}
|
|
658
662
|
}));
|
|
659
|
-
debugOutput(response.url, response.status
|
|
660
|
-
if (response.status === null || response.status === 429) {
|
|
663
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
664
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
661
665
|
try {
|
|
662
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
666
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
663
667
|
}
|
|
664
668
|
catch (error) {
|
|
665
669
|
success = true;
|
|
@@ -689,8 +693,8 @@ export class NftService {
|
|
|
689
693
|
return {
|
|
690
694
|
data: null,
|
|
691
695
|
error: true,
|
|
692
|
-
error_code: data ? data.error_code : response.status,
|
|
693
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
696
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
697
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
694
698
|
};
|
|
695
699
|
}
|
|
696
700
|
}
|
|
@@ -729,6 +733,7 @@ export class NftService {
|
|
|
729
733
|
if (queryParamOpts?.withUncached !== undefined) {
|
|
730
734
|
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
731
735
|
}
|
|
736
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`;
|
|
732
737
|
let startTime;
|
|
733
738
|
if (this.debug) {
|
|
734
739
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -739,10 +744,10 @@ export class NftService {
|
|
|
739
744
|
"X-Requested-With": userAgent
|
|
740
745
|
}
|
|
741
746
|
}));
|
|
742
|
-
debugOutput(response.url, response.status
|
|
743
|
-
if (response.status === null || response.status === 429) {
|
|
747
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
748
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
744
749
|
try {
|
|
745
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
750
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
746
751
|
}
|
|
747
752
|
catch (error) {
|
|
748
753
|
success = true;
|
|
@@ -772,8 +777,8 @@ export class NftService {
|
|
|
772
777
|
return {
|
|
773
778
|
data: null,
|
|
774
779
|
error: true,
|
|
775
|
-
error_code: data ? data.error_code : response.status,
|
|
776
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
780
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
781
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
777
782
|
};
|
|
778
783
|
}
|
|
779
784
|
}
|
|
@@ -808,6 +813,7 @@ export class NftService {
|
|
|
808
813
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
809
814
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
810
815
|
}
|
|
816
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`;
|
|
811
817
|
let startTime;
|
|
812
818
|
if (this.debug) {
|
|
813
819
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -818,10 +824,10 @@ export class NftService {
|
|
|
818
824
|
"X-Requested-With": userAgent
|
|
819
825
|
}
|
|
820
826
|
}));
|
|
821
|
-
debugOutput(response.url, response.status
|
|
822
|
-
if (response.status === null || response.status === 429) {
|
|
827
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
828
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
823
829
|
try {
|
|
824
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
830
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
825
831
|
}
|
|
826
832
|
catch (error) {
|
|
827
833
|
success = true;
|
|
@@ -851,8 +857,8 @@ export class NftService {
|
|
|
851
857
|
return {
|
|
852
858
|
data: null,
|
|
853
859
|
error: true,
|
|
854
|
-
error_code: data ? data.error_code : response.status,
|
|
855
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
860
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
861
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
856
862
|
};
|
|
857
863
|
}
|
|
858
864
|
}
|
|
@@ -881,6 +887,7 @@ export class NftService {
|
|
|
881
887
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
882
888
|
};
|
|
883
889
|
}
|
|
890
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`;
|
|
884
891
|
let startTime;
|
|
885
892
|
if (this.debug) {
|
|
886
893
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -891,10 +898,10 @@ export class NftService {
|
|
|
891
898
|
"X-Requested-With": userAgent
|
|
892
899
|
}
|
|
893
900
|
}));
|
|
894
|
-
debugOutput(response.url, response.status
|
|
895
|
-
if (response.status === null || response.status === 429) {
|
|
901
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
902
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
896
903
|
try {
|
|
897
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
904
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
898
905
|
}
|
|
899
906
|
catch (error) {
|
|
900
907
|
success = true;
|
|
@@ -924,8 +931,8 @@ export class NftService {
|
|
|
924
931
|
return {
|
|
925
932
|
data: null,
|
|
926
933
|
error: true,
|
|
927
|
-
error_code: data ? data.error_code : response.status,
|
|
928
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
934
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
935
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
929
936
|
};
|
|
930
937
|
}
|
|
931
938
|
}
|
|
@@ -955,6 +962,7 @@ export class NftService {
|
|
|
955
962
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
956
963
|
};
|
|
957
964
|
}
|
|
965
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`;
|
|
958
966
|
let startTime;
|
|
959
967
|
if (this.debug) {
|
|
960
968
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -965,10 +973,10 @@ export class NftService {
|
|
|
965
973
|
"X-Requested-With": userAgent
|
|
966
974
|
}
|
|
967
975
|
}));
|
|
968
|
-
debugOutput(response.url, response.status
|
|
969
|
-
if (response.status === null || response.status === 429) {
|
|
976
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
977
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
970
978
|
try {
|
|
971
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
979
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
972
980
|
}
|
|
973
981
|
catch (error) {
|
|
974
982
|
success = true;
|
|
@@ -998,8 +1006,8 @@ export class NftService {
|
|
|
998
1006
|
return {
|
|
999
1007
|
data: null,
|
|
1000
1008
|
error: true,
|
|
1001
|
-
error_code: data ? data.error_code : response.status,
|
|
1002
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1009
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1010
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1003
1011
|
};
|
|
1004
1012
|
}
|
|
1005
1013
|
}
|
|
@@ -1028,6 +1036,7 @@ export class NftService {
|
|
|
1028
1036
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1029
1037
|
};
|
|
1030
1038
|
}
|
|
1039
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`;
|
|
1031
1040
|
let startTime;
|
|
1032
1041
|
if (this.debug) {
|
|
1033
1042
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1038,10 +1047,10 @@ export class NftService {
|
|
|
1038
1047
|
"X-Requested-With": userAgent
|
|
1039
1048
|
}
|
|
1040
1049
|
}));
|
|
1041
|
-
debugOutput(response.url, response.status
|
|
1042
|
-
if (response.status === null || response.status === 429) {
|
|
1050
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1051
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1043
1052
|
try {
|
|
1044
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1053
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1045
1054
|
}
|
|
1046
1055
|
catch (error) {
|
|
1047
1056
|
success = true;
|
|
@@ -1071,8 +1080,8 @@ export class NftService {
|
|
|
1071
1080
|
return {
|
|
1072
1081
|
data: null,
|
|
1073
1082
|
error: true,
|
|
1074
|
-
error_code: data ? data.error_code : response.status,
|
|
1075
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1083
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1084
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1076
1085
|
};
|
|
1077
1086
|
}
|
|
1078
1087
|
}
|
|
@@ -1102,6 +1111,7 @@ export class NftService {
|
|
|
1102
1111
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1103
1112
|
};
|
|
1104
1113
|
}
|
|
1114
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`;
|
|
1105
1115
|
let startTime;
|
|
1106
1116
|
if (this.debug) {
|
|
1107
1117
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1112,10 +1122,10 @@ export class NftService {
|
|
|
1112
1122
|
"X-Requested-With": userAgent
|
|
1113
1123
|
}
|
|
1114
1124
|
}));
|
|
1115
|
-
debugOutput(response.url, response.status
|
|
1116
|
-
if (response.status === null || response.status === 429) {
|
|
1125
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1126
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1117
1127
|
try {
|
|
1118
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1128
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1119
1129
|
}
|
|
1120
1130
|
catch (error) {
|
|
1121
1131
|
success = true;
|
|
@@ -1145,8 +1155,8 @@ export class NftService {
|
|
|
1145
1155
|
return {
|
|
1146
1156
|
data: null,
|
|
1147
1157
|
error: true,
|
|
1148
|
-
error_code: data ? data.error_code : response.status,
|
|
1149
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1158
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1159
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1150
1160
|
};
|
|
1151
1161
|
}
|
|
1152
1162
|
}
|
|
@@ -1177,6 +1187,7 @@ export class NftService {
|
|
|
1177
1187
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1178
1188
|
};
|
|
1179
1189
|
}
|
|
1190
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`;
|
|
1180
1191
|
let startTime;
|
|
1181
1192
|
if (this.debug) {
|
|
1182
1193
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1187,10 +1198,10 @@ export class NftService {
|
|
|
1187
1198
|
"X-Requested-With": userAgent
|
|
1188
1199
|
}
|
|
1189
1200
|
}));
|
|
1190
|
-
debugOutput(response.url, response.status
|
|
1191
|
-
if (response.status === null || response.status === 429) {
|
|
1201
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1202
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1192
1203
|
try {
|
|
1193
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1204
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1194
1205
|
}
|
|
1195
1206
|
catch (error) {
|
|
1196
1207
|
success = true;
|
|
@@ -1220,8 +1231,8 @@ export class NftService {
|
|
|
1220
1231
|
return {
|
|
1221
1232
|
data: null,
|
|
1222
1233
|
error: true,
|
|
1223
|
-
error_code: data ? data.error_code : response.status,
|
|
1224
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1234
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1235
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1225
1236
|
};
|
|
1226
1237
|
}
|
|
1227
1238
|
}
|
|
@@ -1259,6 +1270,7 @@ export class NftService {
|
|
|
1259
1270
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1260
1271
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1261
1272
|
}
|
|
1273
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`;
|
|
1262
1274
|
let startTime;
|
|
1263
1275
|
if (this.debug) {
|
|
1264
1276
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1269,10 +1281,10 @@ export class NftService {
|
|
|
1269
1281
|
"X-Requested-With": userAgent
|
|
1270
1282
|
}
|
|
1271
1283
|
}));
|
|
1272
|
-
debugOutput(response.url, response.status
|
|
1273
|
-
if (response.status === null || response.status === 429) {
|
|
1284
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1285
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1274
1286
|
try {
|
|
1275
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1287
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1276
1288
|
}
|
|
1277
1289
|
catch (error) {
|
|
1278
1290
|
success = true;
|
|
@@ -1302,8 +1314,8 @@ export class NftService {
|
|
|
1302
1314
|
return {
|
|
1303
1315
|
data: null,
|
|
1304
1316
|
error: true,
|
|
1305
|
-
error_code: data ? data.error_code : response.status,
|
|
1306
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1317
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1318
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1307
1319
|
};
|
|
1308
1320
|
}
|
|
1309
1321
|
}
|
|
@@ -1341,6 +1353,7 @@ export class NftService {
|
|
|
1341
1353
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1342
1354
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1343
1355
|
}
|
|
1356
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`;
|
|
1344
1357
|
let startTime;
|
|
1345
1358
|
if (this.debug) {
|
|
1346
1359
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1351,10 +1364,10 @@ export class NftService {
|
|
|
1351
1364
|
"X-Requested-With": userAgent
|
|
1352
1365
|
}
|
|
1353
1366
|
}));
|
|
1354
|
-
debugOutput(response.url, response.status
|
|
1355
|
-
if (response.status === null || response.status === 429) {
|
|
1367
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1368
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1356
1369
|
try {
|
|
1357
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1370
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1358
1371
|
}
|
|
1359
1372
|
catch (error) {
|
|
1360
1373
|
success = true;
|
|
@@ -1384,8 +1397,8 @@ export class NftService {
|
|
|
1384
1397
|
return {
|
|
1385
1398
|
data: null,
|
|
1386
1399
|
error: true,
|
|
1387
|
-
error_code: data ? data.error_code : response.status,
|
|
1388
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1400
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1401
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1389
1402
|
};
|
|
1390
1403
|
}
|
|
1391
1404
|
}
|
|
@@ -1423,6 +1436,7 @@ export class NftService {
|
|
|
1423
1436
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1424
1437
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1425
1438
|
}
|
|
1439
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`;
|
|
1426
1440
|
let startTime;
|
|
1427
1441
|
if (this.debug) {
|
|
1428
1442
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1433,10 +1447,10 @@ export class NftService {
|
|
|
1433
1447
|
"X-Requested-With": userAgent
|
|
1434
1448
|
}
|
|
1435
1449
|
}));
|
|
1436
|
-
debugOutput(response.url, response.status
|
|
1437
|
-
if (response.status === null || response.status === 429) {
|
|
1450
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1451
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1438
1452
|
try {
|
|
1439
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1453
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1440
1454
|
}
|
|
1441
1455
|
catch (error) {
|
|
1442
1456
|
success = true;
|
|
@@ -1466,8 +1480,8 @@ export class NftService {
|
|
|
1466
1480
|
return {
|
|
1467
1481
|
data: null,
|
|
1468
1482
|
error: true,
|
|
1469
|
-
error_code: data ? data.error_code : response.status,
|
|
1470
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1483
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1484
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1471
1485
|
};
|
|
1472
1486
|
}
|
|
1473
1487
|
}
|