@covalenthq/client-sdk 0.6.7 → 0.7.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 +1 -0
- package/dist/cjs/index.js +744 -193
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +2 -1
- package/dist/cjs/services/BaseService.d.ts +55 -2
- package/dist/cjs/services/CovalentClient.d.ts +3 -1
- 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 +5 -4
- package/dist/cjs/services/XykService.d.ts +2 -1
- package/dist/cjs/util/ApiKeyValidator.d.ts +8 -0
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/es/index.js +744 -193
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +2 -1
- package/dist/es/services/BaseService.d.ts +55 -2
- package/dist/es/services/CovalentClient.d.ts +3 -1
- 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 +5 -4
- package/dist/es/services/XykService.d.ts +2 -1
- package/dist/es/util/ApiKeyValidator.d.ts +8 -0
- package/dist/es/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/es/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/esm/index.js +744 -193
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +2 -1
- package/dist/esm/services/BaseService.d.ts +55 -2
- package/dist/esm/services/CovalentClient.d.ts +3 -1
- 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 +5 -4
- package/dist/esm/services/XykService.d.ts +2 -1
- package/dist/esm/util/ApiKeyValidator.d.ts +8 -0
- package/dist/esm/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/services/BalanceService.d.ts +2 -1
- package/dist/services/BalanceService.js +75 -19
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +55 -2
- package/dist/services/BaseService.js +212 -26
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +3 -1
- package/dist/services/CovalentClient.js +20 -15
- package/dist/services/CovalentClient.js.map +1 -1
- package/dist/services/NftService.d.ts +2 -1
- package/dist/services/NftService.js +152 -40
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.d.ts +2 -1
- package/dist/services/PricingService.js +14 -4
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +2 -1
- package/dist/services/SecurityService.js +25 -7
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +5 -4
- package/dist/services/TransactionService.js +78 -33
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +2 -1
- package/dist/services/XykService.js +157 -43
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.js +3 -3
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/ApiKeyValidator.d.ts +8 -0
- package/dist/util/ApiKeyValidator.js +13 -0
- package/dist/util/ApiKeyValidator.js.map +1 -0
- package/dist/util/backoff.js +3 -3
- package/dist/util/backoff.js.map +1 -1
- package/dist/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/util/types/TransactionServiceTypes.d.ts +3 -3
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { TransactionService } from "./TransactionService";
|
|
|
7
7
|
import { XykService } from "./XykService";
|
|
8
8
|
export type Chain = "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-mainnet" | "avalanche-mainnet" | "optimism-mainnet" | "fantom-mainnet" | "moonbeam-mainnet" | "moonbeam-moonriver" | "rsk-mainnet" | "arbitrum-mainnet" | "palm-mainnet" | "klaytn-mainnet" | "heco-mainnet" | "nervos-godwoken-mainnet" | "axie-mainnet" | "evmos-mainnet" | "astar-mainnet" | "iotex-mainnet" | "harmony-mainnet" | "cronos-mainnet" | "aurora-mainnet" | "emerald-paratime-mainnet" | "boba-mainnet" | "eth-goerli" | "matic-mumbai" | "avalanche-testnet" | "bsc-testnet" | "moonbeam-moonbase-alpha" | "rsk-testnet" | "arbitrum-goerli" | "fantom-testnet" | "palm-testnet" | "heco-testnet" | "nervos-godwoken-testnet" | "evmos-testnet" | "astar-shiden" | "iotex-testnet" | "harmony-testnet" | "aurora-testnet" | "scroll-sepolia-testnet" | "covalent-internal-network-v1" | "defi-kingdoms-mainnet" | "swimmer-mainnet" | "boba-avalanche-mainnet" | "boba-bobabeam-mainnet" | "boba-bnb-mainnet" | "boba-rinkeby-testnet" | "boba-bobabase-testnet" | "boba-bnb-testnet" | "boba-avalanche-testnet" | "klaytn-testnet" | "gather-mainnet" | "gather-testnet" | "skale-calypso" | "skale-mainnet" | "skale-razor" | "avalanche-dexalot-mainnet" | "skale-omnus" | "avalanche-dexalot-testnet" | "astar-shibuya" | "cronos-testnet" | "defi-kingdoms-testnet" | "metis-mainnet" | "metis-stardust" | "milkomeda-a1-mainnet" | "milkomeda-a1-devnet" | "milkomeda-c1-mainnet" | "milkomeda-c1-devnet" | "swimmer-testnet" | "solana-mainnet" | "skale-europa" | "meter-mainnet" | "meter-testnet" | "skale-exorde" | "boba-goerli" | "neon-testnet" | "skale-staging-uum" | "skale-staging-lcc" | "arbitrum-nova-mainnet" | "canto-mainnet" | "bittorrent-mainnet" | "bittorrent-testnet" | "flarenetworks-flare-mainnet" | "flarenetworks-flare-testnet" | "flarenetworks-canary-mainnet" | "flarenetworks-canary-testnet" | "kcc-mainnet" | "kcc-testnet" | "polygon-zkevm-testnet" | "linea-testnet" | "base-testnet" | "mantle-testnet" | "scroll-alpha-testnet" | "oasys-mainnet" | "oasys-testnet" | "findora-mainnet" | "findora-forge-testnet" | "sx-mainnet" | "oasis-sapphire-mainnet" | "oasis-sapphire-testnet" | "optimism-goerli" | "polygon-zkevm-mainnet" | "horizen-yuma-testnet" | "clv-parachain" | "energi-mainnet" | "energi-testnet" | "horizen-gobi-testnet" | "eth-sepolia" | "skale-nebula" | "skale-battleground" | "avalanche-meld-testnet" | "gunzilla-testnet" | "ultron-mainnet" | "ultron-testnet" | "zora-mainnet" | "zora-testnet" | "neon-mainnet" | "avalanche-shrapnel-mainnet" | "base-mainnet" | "mantle-mainnet" | "avalanche-loco-legends-mainnet" | "linea-mainnet" | "horizen-eon-mainnet" | "avalanche-numbers" | "avalanche-dos" | "avalanche-step-network" | "avalanche-xplus" | "avalanche-xanachain" | "avalanche-meld-mainnet" | "opside-public-zkevm" | "opside-law-chain" | "avalanche-shrapnel-testnet" | "avalanche-loco-legends-testnet" | "opside-cb-zkevm" | "opside-pre-alpha-testnet" | "opside-era7" | "opside-xthrill" | "zksync-mainnet" | "metis-testnet" | "zksync-testnet" | "avalanche-blitz-testnet" | "avalanche-d-chain-testnet" | "avalanche-green-dot-testnet" | "avalanche-mintara-testnet" | "avalanche-beam-testnet" | "bnb-meta-apes-mainnet" | "bnb-antimatter-mainnet" | "bnb-antimatter-testnet" | "bnb-opbnb-testnet" | "opside-debox" | "opside-jackbot" | "opside-odx-zkevm-testnet" | "opside-readon-content-testnet" | "opside-relation" | "opside-soquest-zkevm" | "opside-vip3" | "opside-zkmeta" | "avalanche-pulsar-testnet" | "avalanche-uptn" | "bnb-fncy-mainnet" | "zetachain-testnet" | "kinto-testnet" | "mode-testnet" | "loot-mainnet" | "bnb-fncy-testnet" | "manta-testnet" | "pgn-mainnet" | "pgn-testnet" | "gnosis-mainnet" | "gnosis-testnet" | "rollux-mainnet" | "rollux-testnet" | "taiko-jolnir-testnet" | "optimism-sepolia" | "bnb-opbnb-mainnet" | "telos-mainnet" | "telos-testnet";
|
|
9
9
|
export type Quote = "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP";
|
|
10
|
-
export declare const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
10
|
+
export declare const userAgent = "com.covalenthq.sdk.typescript/0.7.1";
|
|
11
11
|
export declare class Response<T> {
|
|
12
12
|
data: T;
|
|
13
13
|
error: boolean;
|
|
@@ -31,6 +31,7 @@ export declare class CovalentClient {
|
|
|
31
31
|
PricingService: PricingService;
|
|
32
32
|
TransactionService: TransactionService;
|
|
33
33
|
XykService: XykService;
|
|
34
|
+
private _is_key_valid;
|
|
34
35
|
constructor(apiKey: string, settings?: CovalentClientSettings);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
@@ -47,5 +48,6 @@ export declare class Client {
|
|
|
47
48
|
PricingService: PricingService;
|
|
48
49
|
TransactionService: TransactionService;
|
|
49
50
|
XykService: XykService;
|
|
51
|
+
private _is_key_valid;
|
|
50
52
|
constructor(apiKey: string, settings?: CovalentClientSettings);
|
|
51
53
|
}
|
|
@@ -5,7 +5,8 @@ import { NftService } from "./NftService";
|
|
|
5
5
|
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.1";
|
|
9
10
|
export class Response {
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
@@ -14,13 +15,15 @@ export class Response {
|
|
|
14
15
|
export class CovalentClient {
|
|
15
16
|
constructor(apiKey, settings) {
|
|
16
17
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
18
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
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);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
@@ -32,13 +35,15 @@ export class CovalentClient {
|
|
|
32
35
|
export class Client {
|
|
33
36
|
constructor(apiKey, settings) {
|
|
34
37
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
38
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
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);
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
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;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CovalentClient.js","sourceRoot":"","sources":["../../src/services/CovalentClient.ts"],"names":[],"mappings":"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"}
|
|
@@ -483,8 +483,9 @@ export declare class NftService {
|
|
|
483
483
|
private apiKey;
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
|
+
private is_key_valid;
|
|
486
487
|
private LIMIT;
|
|
487
|
-
constructor(apiKey: string, debug
|
|
488
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
488
489
|
/**
|
|
489
490
|
*
|
|
490
491
|
* Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
|
|
@@ -3,6 +3,7 @@ import { checkAndModifyResponse, debugOutput, paginateEndpoint } from "../util/A
|
|
|
3
3
|
import { parseISO } from "date-fns";
|
|
4
4
|
import { ExponentialBackoff } from "../util/backoff";
|
|
5
5
|
import pLimit from "p-limit";
|
|
6
|
+
import { ApiKeyValidator } from "../util/ApiKeyValidator";
|
|
6
7
|
class ChainCollectionResponse {
|
|
7
8
|
constructor(data) {
|
|
8
9
|
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
@@ -325,10 +326,11 @@ class MarketFloorPriceItem {
|
|
|
325
326
|
*
|
|
326
327
|
*/
|
|
327
328
|
export class NftService {
|
|
328
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
329
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
329
330
|
this.apiKey = apiKey;
|
|
330
331
|
this.debug = debug;
|
|
331
332
|
this.threadCount = threadCount;
|
|
333
|
+
this.is_key_valid = is_key_valid;
|
|
332
334
|
this.LIMIT = pLimit(this.threadCount);
|
|
333
335
|
}
|
|
334
336
|
/**
|
|
@@ -348,6 +350,9 @@ export class NftService {
|
|
|
348
350
|
while (!success) {
|
|
349
351
|
try {
|
|
350
352
|
const urlParams = new URLSearchParams();
|
|
353
|
+
if (!this.is_key_valid) {
|
|
354
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
355
|
+
}
|
|
351
356
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
352
357
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
353
358
|
}
|
|
@@ -387,6 +392,14 @@ export class NftService {
|
|
|
387
392
|
while (!success) {
|
|
388
393
|
try {
|
|
389
394
|
const urlParams = new URLSearchParams();
|
|
395
|
+
if (!this.is_key_valid) {
|
|
396
|
+
return {
|
|
397
|
+
data: null,
|
|
398
|
+
error: true,
|
|
399
|
+
error_code: 401,
|
|
400
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
401
|
+
};
|
|
402
|
+
}
|
|
390
403
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
391
404
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
392
405
|
}
|
|
@@ -406,8 +419,8 @@ export class NftService {
|
|
|
406
419
|
"X-Requested-With": userAgent
|
|
407
420
|
}
|
|
408
421
|
}));
|
|
409
|
-
debugOutput(response.url, response.status, startTime);
|
|
410
|
-
if (response.status === 429) {
|
|
422
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
423
|
+
if (response.status === null || response.status === 429) {
|
|
411
424
|
try {
|
|
412
425
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
413
426
|
}
|
|
@@ -416,7 +429,7 @@ export class NftService {
|
|
|
416
429
|
return {
|
|
417
430
|
data: null,
|
|
418
431
|
error: true,
|
|
419
|
-
error_code: response.status,
|
|
432
|
+
error_code: response.status ?? 429,
|
|
420
433
|
error_message: error.message
|
|
421
434
|
};
|
|
422
435
|
}
|
|
@@ -465,6 +478,14 @@ export class NftService {
|
|
|
465
478
|
while (!success) {
|
|
466
479
|
try {
|
|
467
480
|
const urlParams = new URLSearchParams();
|
|
481
|
+
if (!this.is_key_valid) {
|
|
482
|
+
return {
|
|
483
|
+
data: null,
|
|
484
|
+
error: true,
|
|
485
|
+
error_code: 401,
|
|
486
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
487
|
+
};
|
|
488
|
+
}
|
|
468
489
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
469
490
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
470
491
|
}
|
|
@@ -484,8 +505,8 @@ export class NftService {
|
|
|
484
505
|
"X-Requested-With": userAgent
|
|
485
506
|
}
|
|
486
507
|
}));
|
|
487
|
-
debugOutput(response.url, response.status, startTime);
|
|
488
|
-
if (response.status === 429) {
|
|
508
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
509
|
+
if (response.status === null || response.status === 429) {
|
|
489
510
|
try {
|
|
490
511
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
491
512
|
}
|
|
@@ -494,7 +515,7 @@ export class NftService {
|
|
|
494
515
|
return {
|
|
495
516
|
data: null,
|
|
496
517
|
error: true,
|
|
497
|
-
error_code: response.status,
|
|
518
|
+
error_code: response.status ?? 429,
|
|
498
519
|
error_message: error.message
|
|
499
520
|
};
|
|
500
521
|
}
|
|
@@ -544,6 +565,9 @@ export class NftService {
|
|
|
544
565
|
while (!success) {
|
|
545
566
|
try {
|
|
546
567
|
const urlParams = new URLSearchParams();
|
|
568
|
+
if (!this.is_key_valid) {
|
|
569
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
570
|
+
}
|
|
547
571
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
548
572
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
549
573
|
}
|
|
@@ -596,6 +620,14 @@ export class NftService {
|
|
|
596
620
|
while (!success) {
|
|
597
621
|
try {
|
|
598
622
|
const urlParams = new URLSearchParams();
|
|
623
|
+
if (!this.is_key_valid) {
|
|
624
|
+
return {
|
|
625
|
+
data: null,
|
|
626
|
+
error: true,
|
|
627
|
+
error_code: 401,
|
|
628
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
629
|
+
};
|
|
630
|
+
}
|
|
599
631
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
600
632
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
601
633
|
}
|
|
@@ -624,8 +656,8 @@ export class NftService {
|
|
|
624
656
|
"X-Requested-With": userAgent
|
|
625
657
|
}
|
|
626
658
|
}));
|
|
627
|
-
debugOutput(response.url, response.status, startTime);
|
|
628
|
-
if (response.status === 429) {
|
|
659
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
660
|
+
if (response.status === null || response.status === 429) {
|
|
629
661
|
try {
|
|
630
662
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
631
663
|
}
|
|
@@ -634,7 +666,7 @@ export class NftService {
|
|
|
634
666
|
return {
|
|
635
667
|
data: null,
|
|
636
668
|
error: true,
|
|
637
|
-
error_code: response.status,
|
|
669
|
+
error_code: response.status ?? 429,
|
|
638
670
|
error_message: error.message
|
|
639
671
|
};
|
|
640
672
|
}
|
|
@@ -683,6 +715,14 @@ export class NftService {
|
|
|
683
715
|
while (!success) {
|
|
684
716
|
try {
|
|
685
717
|
const urlParams = new URLSearchParams();
|
|
718
|
+
if (!this.is_key_valid) {
|
|
719
|
+
return {
|
|
720
|
+
data: null,
|
|
721
|
+
error: true,
|
|
722
|
+
error_code: 401,
|
|
723
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
724
|
+
};
|
|
725
|
+
}
|
|
686
726
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
687
727
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
688
728
|
}
|
|
@@ -699,8 +739,8 @@ export class NftService {
|
|
|
699
739
|
"X-Requested-With": userAgent
|
|
700
740
|
}
|
|
701
741
|
}));
|
|
702
|
-
debugOutput(response.url, response.status, startTime);
|
|
703
|
-
if (response.status === 429) {
|
|
742
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
743
|
+
if (response.status === null || response.status === 429) {
|
|
704
744
|
try {
|
|
705
745
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
706
746
|
}
|
|
@@ -709,7 +749,7 @@ export class NftService {
|
|
|
709
749
|
return {
|
|
710
750
|
data: null,
|
|
711
751
|
error: true,
|
|
712
|
-
error_code: response.status,
|
|
752
|
+
error_code: response.status ?? 429,
|
|
713
753
|
error_message: error.message
|
|
714
754
|
};
|
|
715
755
|
}
|
|
@@ -757,6 +797,14 @@ export class NftService {
|
|
|
757
797
|
while (!success) {
|
|
758
798
|
try {
|
|
759
799
|
const urlParams = new URLSearchParams();
|
|
800
|
+
if (!this.is_key_valid) {
|
|
801
|
+
return {
|
|
802
|
+
data: null,
|
|
803
|
+
error: true,
|
|
804
|
+
error_code: 401,
|
|
805
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
806
|
+
};
|
|
807
|
+
}
|
|
760
808
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
761
809
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
762
810
|
}
|
|
@@ -770,8 +818,8 @@ export class NftService {
|
|
|
770
818
|
"X-Requested-With": userAgent
|
|
771
819
|
}
|
|
772
820
|
}));
|
|
773
|
-
debugOutput(response.url, response.status, startTime);
|
|
774
|
-
if (response.status === 429) {
|
|
821
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
822
|
+
if (response.status === null || response.status === 429) {
|
|
775
823
|
try {
|
|
776
824
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
777
825
|
}
|
|
@@ -780,7 +828,7 @@ export class NftService {
|
|
|
780
828
|
return {
|
|
781
829
|
data: null,
|
|
782
830
|
error: true,
|
|
783
|
-
error_code: response.status,
|
|
831
|
+
error_code: response.status ?? 429,
|
|
784
832
|
error_message: error.message
|
|
785
833
|
};
|
|
786
834
|
}
|
|
@@ -825,6 +873,14 @@ export class NftService {
|
|
|
825
873
|
while (!success) {
|
|
826
874
|
try {
|
|
827
875
|
const urlParams = new URLSearchParams();
|
|
876
|
+
if (!this.is_key_valid) {
|
|
877
|
+
return {
|
|
878
|
+
data: null,
|
|
879
|
+
error: true,
|
|
880
|
+
error_code: 401,
|
|
881
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
882
|
+
};
|
|
883
|
+
}
|
|
828
884
|
let startTime;
|
|
829
885
|
if (this.debug) {
|
|
830
886
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -835,8 +891,8 @@ export class NftService {
|
|
|
835
891
|
"X-Requested-With": userAgent
|
|
836
892
|
}
|
|
837
893
|
}));
|
|
838
|
-
debugOutput(response.url, response.status, startTime);
|
|
839
|
-
if (response.status === 429) {
|
|
894
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
895
|
+
if (response.status === null || response.status === 429) {
|
|
840
896
|
try {
|
|
841
897
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
842
898
|
}
|
|
@@ -845,7 +901,7 @@ export class NftService {
|
|
|
845
901
|
return {
|
|
846
902
|
data: null,
|
|
847
903
|
error: true,
|
|
848
|
-
error_code: response.status,
|
|
904
|
+
error_code: response.status ?? 429,
|
|
849
905
|
error_message: error.message
|
|
850
906
|
};
|
|
851
907
|
}
|
|
@@ -891,6 +947,14 @@ export class NftService {
|
|
|
891
947
|
while (!success) {
|
|
892
948
|
try {
|
|
893
949
|
const urlParams = new URLSearchParams();
|
|
950
|
+
if (!this.is_key_valid) {
|
|
951
|
+
return {
|
|
952
|
+
data: null,
|
|
953
|
+
error: true,
|
|
954
|
+
error_code: 401,
|
|
955
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
956
|
+
};
|
|
957
|
+
}
|
|
894
958
|
let startTime;
|
|
895
959
|
if (this.debug) {
|
|
896
960
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -901,8 +965,8 @@ export class NftService {
|
|
|
901
965
|
"X-Requested-With": userAgent
|
|
902
966
|
}
|
|
903
967
|
}));
|
|
904
|
-
debugOutput(response.url, response.status, startTime);
|
|
905
|
-
if (response.status === 429) {
|
|
968
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
969
|
+
if (response.status === null || response.status === 429) {
|
|
906
970
|
try {
|
|
907
971
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
908
972
|
}
|
|
@@ -911,7 +975,7 @@ export class NftService {
|
|
|
911
975
|
return {
|
|
912
976
|
data: null,
|
|
913
977
|
error: true,
|
|
914
|
-
error_code: response.status,
|
|
978
|
+
error_code: response.status ?? 429,
|
|
915
979
|
error_message: error.message
|
|
916
980
|
};
|
|
917
981
|
}
|
|
@@ -956,6 +1020,14 @@ export class NftService {
|
|
|
956
1020
|
while (!success) {
|
|
957
1021
|
try {
|
|
958
1022
|
const urlParams = new URLSearchParams();
|
|
1023
|
+
if (!this.is_key_valid) {
|
|
1024
|
+
return {
|
|
1025
|
+
data: null,
|
|
1026
|
+
error: true,
|
|
1027
|
+
error_code: 401,
|
|
1028
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
959
1031
|
let startTime;
|
|
960
1032
|
if (this.debug) {
|
|
961
1033
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -966,8 +1038,8 @@ export class NftService {
|
|
|
966
1038
|
"X-Requested-With": userAgent
|
|
967
1039
|
}
|
|
968
1040
|
}));
|
|
969
|
-
debugOutput(response.url, response.status, startTime);
|
|
970
|
-
if (response.status === 429) {
|
|
1041
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1042
|
+
if (response.status === null || response.status === 429) {
|
|
971
1043
|
try {
|
|
972
1044
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
973
1045
|
}
|
|
@@ -976,7 +1048,7 @@ export class NftService {
|
|
|
976
1048
|
return {
|
|
977
1049
|
data: null,
|
|
978
1050
|
error: true,
|
|
979
|
-
error_code: response.status,
|
|
1051
|
+
error_code: response.status ?? 429,
|
|
980
1052
|
error_message: error.message
|
|
981
1053
|
};
|
|
982
1054
|
}
|
|
@@ -1022,6 +1094,14 @@ export class NftService {
|
|
|
1022
1094
|
while (!success) {
|
|
1023
1095
|
try {
|
|
1024
1096
|
const urlParams = new URLSearchParams();
|
|
1097
|
+
if (!this.is_key_valid) {
|
|
1098
|
+
return {
|
|
1099
|
+
data: null,
|
|
1100
|
+
error: true,
|
|
1101
|
+
error_code: 401,
|
|
1102
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1025
1105
|
let startTime;
|
|
1026
1106
|
if (this.debug) {
|
|
1027
1107
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1032,8 +1112,8 @@ export class NftService {
|
|
|
1032
1112
|
"X-Requested-With": userAgent
|
|
1033
1113
|
}
|
|
1034
1114
|
}));
|
|
1035
|
-
debugOutput(response.url, response.status, startTime);
|
|
1036
|
-
if (response.status === 429) {
|
|
1115
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1116
|
+
if (response.status === null || response.status === 429) {
|
|
1037
1117
|
try {
|
|
1038
1118
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1039
1119
|
}
|
|
@@ -1042,7 +1122,7 @@ export class NftService {
|
|
|
1042
1122
|
return {
|
|
1043
1123
|
data: null,
|
|
1044
1124
|
error: true,
|
|
1045
|
-
error_code: response.status,
|
|
1125
|
+
error_code: response.status ?? 429,
|
|
1046
1126
|
error_message: error.message
|
|
1047
1127
|
};
|
|
1048
1128
|
}
|
|
@@ -1089,6 +1169,14 @@ export class NftService {
|
|
|
1089
1169
|
while (!success) {
|
|
1090
1170
|
try {
|
|
1091
1171
|
const urlParams = new URLSearchParams();
|
|
1172
|
+
if (!this.is_key_valid) {
|
|
1173
|
+
return {
|
|
1174
|
+
data: null,
|
|
1175
|
+
error: true,
|
|
1176
|
+
error_code: 401,
|
|
1177
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1092
1180
|
let startTime;
|
|
1093
1181
|
if (this.debug) {
|
|
1094
1182
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1099,8 +1187,8 @@ export class NftService {
|
|
|
1099
1187
|
"X-Requested-With": userAgent
|
|
1100
1188
|
}
|
|
1101
1189
|
}));
|
|
1102
|
-
debugOutput(response.url, response.status, startTime);
|
|
1103
|
-
if (response.status === 429) {
|
|
1190
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1191
|
+
if (response.status === null || response.status === 429) {
|
|
1104
1192
|
try {
|
|
1105
1193
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1106
1194
|
}
|
|
@@ -1109,7 +1197,7 @@ export class NftService {
|
|
|
1109
1197
|
return {
|
|
1110
1198
|
data: null,
|
|
1111
1199
|
error: true,
|
|
1112
|
-
error_code: response.status,
|
|
1200
|
+
error_code: response.status ?? 429,
|
|
1113
1201
|
error_message: error.message
|
|
1114
1202
|
};
|
|
1115
1203
|
}
|
|
@@ -1157,6 +1245,14 @@ export class NftService {
|
|
|
1157
1245
|
while (!success) {
|
|
1158
1246
|
try {
|
|
1159
1247
|
const urlParams = new URLSearchParams();
|
|
1248
|
+
if (!this.is_key_valid) {
|
|
1249
|
+
return {
|
|
1250
|
+
data: null,
|
|
1251
|
+
error: true,
|
|
1252
|
+
error_code: 401,
|
|
1253
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1160
1256
|
if (queryParamOpts?.days !== undefined) {
|
|
1161
1257
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
1162
1258
|
}
|
|
@@ -1173,8 +1269,8 @@ export class NftService {
|
|
|
1173
1269
|
"X-Requested-With": userAgent
|
|
1174
1270
|
}
|
|
1175
1271
|
}));
|
|
1176
|
-
debugOutput(response.url, response.status, startTime);
|
|
1177
|
-
if (response.status === 429) {
|
|
1272
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1273
|
+
if (response.status === null || response.status === 429) {
|
|
1178
1274
|
try {
|
|
1179
1275
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1180
1276
|
}
|
|
@@ -1183,7 +1279,7 @@ export class NftService {
|
|
|
1183
1279
|
return {
|
|
1184
1280
|
data: null,
|
|
1185
1281
|
error: true,
|
|
1186
|
-
error_code: response.status,
|
|
1282
|
+
error_code: response.status ?? 429,
|
|
1187
1283
|
error_message: error.message
|
|
1188
1284
|
};
|
|
1189
1285
|
}
|
|
@@ -1231,6 +1327,14 @@ export class NftService {
|
|
|
1231
1327
|
while (!success) {
|
|
1232
1328
|
try {
|
|
1233
1329
|
const urlParams = new URLSearchParams();
|
|
1330
|
+
if (!this.is_key_valid) {
|
|
1331
|
+
return {
|
|
1332
|
+
data: null,
|
|
1333
|
+
error: true,
|
|
1334
|
+
error_code: 401,
|
|
1335
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1234
1338
|
if (queryParamOpts?.days !== undefined) {
|
|
1235
1339
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
1236
1340
|
}
|
|
@@ -1247,8 +1351,8 @@ export class NftService {
|
|
|
1247
1351
|
"X-Requested-With": userAgent
|
|
1248
1352
|
}
|
|
1249
1353
|
}));
|
|
1250
|
-
debugOutput(response.url, response.status, startTime);
|
|
1251
|
-
if (response.status === 429) {
|
|
1354
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1355
|
+
if (response.status === null || response.status === 429) {
|
|
1252
1356
|
try {
|
|
1253
1357
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1254
1358
|
}
|
|
@@ -1257,7 +1361,7 @@ export class NftService {
|
|
|
1257
1361
|
return {
|
|
1258
1362
|
data: null,
|
|
1259
1363
|
error: true,
|
|
1260
|
-
error_code: response.status,
|
|
1364
|
+
error_code: response.status ?? 429,
|
|
1261
1365
|
error_message: error.message
|
|
1262
1366
|
};
|
|
1263
1367
|
}
|
|
@@ -1305,6 +1409,14 @@ export class NftService {
|
|
|
1305
1409
|
while (!success) {
|
|
1306
1410
|
try {
|
|
1307
1411
|
const urlParams = new URLSearchParams();
|
|
1412
|
+
if (!this.is_key_valid) {
|
|
1413
|
+
return {
|
|
1414
|
+
data: null,
|
|
1415
|
+
error: true,
|
|
1416
|
+
error_code: 401,
|
|
1417
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1308
1420
|
if (queryParamOpts?.days !== undefined) {
|
|
1309
1421
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
1310
1422
|
}
|
|
@@ -1321,8 +1433,8 @@ export class NftService {
|
|
|
1321
1433
|
"X-Requested-With": userAgent
|
|
1322
1434
|
}
|
|
1323
1435
|
}));
|
|
1324
|
-
debugOutput(response.url, response.status, startTime);
|
|
1325
|
-
if (response.status === 429) {
|
|
1436
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1437
|
+
if (response.status === null || response.status === 429) {
|
|
1326
1438
|
try {
|
|
1327
1439
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1328
1440
|
}
|
|
@@ -1331,7 +1443,7 @@ export class NftService {
|
|
|
1331
1443
|
return {
|
|
1332
1444
|
data: null,
|
|
1333
1445
|
error: true,
|
|
1334
|
-
error_code: response.status,
|
|
1446
|
+
error_code: response.status ?? 429,
|
|
1335
1447
|
error_message: error.message
|
|
1336
1448
|
};
|
|
1337
1449
|
}
|