@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
|
@@ -193,6 +193,7 @@ class PoolsDexDataItem {
|
|
|
193
193
|
this.volume_24h_quote = data.volume_24h_quote;
|
|
194
194
|
this.volume_7d_quote = data.volume_7d_quote;
|
|
195
195
|
this.fee_24h_quote = data.fee_24h_quote;
|
|
196
|
+
this.annualized_fee = data.annualized_fee;
|
|
196
197
|
this.pretty_volume_24h_quote = data.pretty_volume_24h_quote;
|
|
197
198
|
this.pretty_volume_7d_quote = data.pretty_volume_7d_quote;
|
|
198
199
|
this.pretty_fee_24h_quote = data.pretty_fee_24h_quote;
|
|
@@ -235,6 +236,7 @@ class UniswapLikeToken {
|
|
|
235
236
|
this.logo_url = data.logo_url;
|
|
236
237
|
this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
|
|
237
238
|
this.quote = data.quote;
|
|
239
|
+
this.pretty_quote = data.pretty_quote;
|
|
238
240
|
this.quote_rate = data.quote_rate;
|
|
239
241
|
}
|
|
240
242
|
}
|
|
@@ -246,6 +248,7 @@ class UniswapLikeTokenWithSupply {
|
|
|
246
248
|
this.logo_url = data.logo_url;
|
|
247
249
|
this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
|
|
248
250
|
this.quote = data.quote;
|
|
251
|
+
this.pretty_quote = data.pretty_quote;
|
|
249
252
|
this.quote_rate = data.quote_rate;
|
|
250
253
|
this.total_supply = data.total_supply && data.total_supply !== null ? BigInt(data.total_supply) : null;
|
|
251
254
|
}
|
|
@@ -313,22 +316,45 @@ class ExchangeTransaction {
|
|
|
313
316
|
this.tx_hash = data.tx_hash;
|
|
314
317
|
this.act = data.act;
|
|
315
318
|
this.address = data.address;
|
|
316
|
-
this.
|
|
317
|
-
this.
|
|
318
|
-
this.
|
|
319
|
-
this.
|
|
320
|
-
this.
|
|
319
|
+
this.amount_0 = data.amount_0;
|
|
320
|
+
this.amount_1 = data.amount_1;
|
|
321
|
+
this.amount_0_in = data.amount_0_in;
|
|
322
|
+
this.amount_0_out = data.amount_0_out;
|
|
323
|
+
this.amount_1_in = data.amount_1_in;
|
|
324
|
+
this.amount_1_out = data.amount_1_out;
|
|
321
325
|
this.to_address = data.to_address;
|
|
322
326
|
this.from_address = data.from_address;
|
|
323
327
|
this.sender_address = data.sender_address;
|
|
324
328
|
this.total_quote = data.total_quote;
|
|
325
329
|
this.pretty_total_quote = data.pretty_total_quote;
|
|
330
|
+
this.value = data.value && data.value !== null ? BigInt(data.value) : null;
|
|
331
|
+
this.value_quote = data.value_quote;
|
|
332
|
+
this.pretty_value_quote = data.pretty_value_quote;
|
|
333
|
+
this.gas_offered = data.gas_offered;
|
|
334
|
+
this.gas_spent = data.gas_spent;
|
|
335
|
+
this.gas_price = data.gas_price;
|
|
336
|
+
this.fees_paid = data.fees_paid && data.fees_paid !== null ? BigInt(data.fees_paid) : null;
|
|
337
|
+
this.gas_quote = data.gas_quote;
|
|
338
|
+
this.pretty_gas_quote = data.pretty_gas_quote;
|
|
339
|
+
this.gas_quote_rate = data.gas_quote_rate;
|
|
340
|
+
this.quote_currency = data.quote_currency;
|
|
326
341
|
this.token_0_quote_rate = data.token_0_quote_rate;
|
|
327
342
|
this.token_1_quote_rate = data.token_1_quote_rate;
|
|
343
|
+
this.gas_metadata = data.gas_metadata && data.gas_metadata !== null ? new ContractMetadata(data.gas_metadata) : null;
|
|
328
344
|
this.token_0 = data.token_0 && data.token_0 !== null ? new PoolToken(data.token_0) : null;
|
|
329
345
|
this.token_1 = data.token_1 && data.token_1 !== null ? new PoolToken(data.token_1) : null;
|
|
330
346
|
}
|
|
331
347
|
}
|
|
348
|
+
class ContractMetadata {
|
|
349
|
+
constructor(data) {
|
|
350
|
+
this.contract_decimals = data.contract_decimals;
|
|
351
|
+
this.contract_name = data.contract_name;
|
|
352
|
+
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
353
|
+
this.contract_address = data.contract_address;
|
|
354
|
+
this.supports_erc = data.supports_erc;
|
|
355
|
+
this.logo_url = data.logo_url;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
332
358
|
class PoolToken {
|
|
333
359
|
constructor(data) {
|
|
334
360
|
this.contract_decimals = data.contract_decimals;
|
|
@@ -372,13 +398,15 @@ class UniswapLikeEcosystemCharts {
|
|
|
372
398
|
this.chain_id = data.chain_id;
|
|
373
399
|
this.quote_currency = data.quote_currency;
|
|
374
400
|
this.gas_token_price_quote = data.gas_token_price_quote;
|
|
375
|
-
this.
|
|
376
|
-
this.
|
|
377
|
-
this.
|
|
378
|
-
this.
|
|
379
|
-
this.
|
|
380
|
-
this.
|
|
381
|
-
this.
|
|
401
|
+
this.total_swaps_24h = data.total_swaps_24h;
|
|
402
|
+
this.total_active_pairs_7d = data.total_active_pairs_7d;
|
|
403
|
+
this.total_fees_24h = data.total_fees_24h;
|
|
404
|
+
this.pretty_gas_token_price_quote = data.pretty_gas_token_price_quote;
|
|
405
|
+
this.pretty_total_fees_24h = data.pretty_total_fees_24h;
|
|
406
|
+
this.volume_chart_7d = data.volume_chart_7d && data.volume_chart_7d !== null ? data.volume_chart_7d.map((itemData) => new VolumeEcosystemChart(itemData)) : null;
|
|
407
|
+
this.volume_chart_30d = data.volume_chart_30d && data.volume_chart_30d !== null ? data.volume_chart_30d.map((itemData) => new VolumeEcosystemChart(itemData)) : null;
|
|
408
|
+
this.liquidity_chart_7d = data.liquidity_chart_7d && data.liquidity_chart_7d !== null ? data.liquidity_chart_7d.map((itemData) => new LiquidityEcosystemChart(itemData)) : null;
|
|
409
|
+
this.liquidity_chart_30d = data.liquidity_chart_30d && data.liquidity_chart_30d !== null ? data.liquidity_chart_30d.map((itemData) => new LiquidityEcosystemChart(itemData)) : null;
|
|
382
410
|
}
|
|
383
411
|
}
|
|
384
412
|
class VolumeEcosystemChart {
|
|
@@ -388,6 +416,7 @@ class VolumeEcosystemChart {
|
|
|
388
416
|
this.dt = data.dt && data.dt !== null ? parseISO(data.dt.toString()) : null;
|
|
389
417
|
this.quote_currency = data.quote_currency;
|
|
390
418
|
this.volume_quote = data.volume_quote;
|
|
419
|
+
this.pretty_volume_quote = data.pretty_volume_quote;
|
|
391
420
|
this.swap_count_24 = data.swap_count_24;
|
|
392
421
|
}
|
|
393
422
|
}
|
|
@@ -398,6 +427,7 @@ class LiquidityEcosystemChart {
|
|
|
398
427
|
this.dt = data.dt && data.dt !== null ? parseISO(data.dt.toString()) : null;
|
|
399
428
|
this.quote_currency = data.quote_currency;
|
|
400
429
|
this.liquidity_quote = data.liquidity_quote;
|
|
430
|
+
this.pretty_liquidity_quote = data.pretty_liquidity_quote;
|
|
401
431
|
}
|
|
402
432
|
}
|
|
403
433
|
class HealthDataResponse {
|
|
@@ -422,11 +452,12 @@ class HealthData {
|
|
|
422
452
|
*
|
|
423
453
|
*/
|
|
424
454
|
export class XykService {
|
|
425
|
-
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
455
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
|
|
426
456
|
this.apiKey = apiKey;
|
|
427
457
|
this.debug = debug;
|
|
428
458
|
this.threadCount = threadCount;
|
|
429
459
|
this.is_key_valid = is_key_valid;
|
|
460
|
+
this.enableRetry = enableRetry;
|
|
430
461
|
this.LIMIT = pLimit(this.threadCount);
|
|
431
462
|
}
|
|
432
463
|
/**
|
|
@@ -445,6 +476,7 @@ export class XykService {
|
|
|
445
476
|
while (!success) {
|
|
446
477
|
try {
|
|
447
478
|
const urlParams = new URLSearchParams();
|
|
479
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`;
|
|
448
480
|
if (!this.is_key_valid) {
|
|
449
481
|
return {
|
|
450
482
|
data: null,
|
|
@@ -463,10 +495,10 @@ export class XykService {
|
|
|
463
495
|
"X-Requested-With": userAgent
|
|
464
496
|
}
|
|
465
497
|
}));
|
|
466
|
-
debugOutput(response.url, response.status
|
|
467
|
-
if (response.status === null || response.status === 429) {
|
|
498
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
499
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
468
500
|
try {
|
|
469
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
501
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
470
502
|
}
|
|
471
503
|
catch (error) {
|
|
472
504
|
success = true;
|
|
@@ -496,8 +528,8 @@ export class XykService {
|
|
|
496
528
|
return {
|
|
497
529
|
data: null,
|
|
498
530
|
error: true,
|
|
499
|
-
error_code: data ? data.error_code : response.status,
|
|
500
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
531
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
532
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
501
533
|
};
|
|
502
534
|
}
|
|
503
535
|
}
|
|
@@ -518,6 +550,7 @@ export class XykService {
|
|
|
518
550
|
while (!success) {
|
|
519
551
|
try {
|
|
520
552
|
const urlParams = new URLSearchParams();
|
|
553
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/address/${poolAddress}/dex_name/?${urlParams}`;
|
|
521
554
|
if (!this.is_key_valid) {
|
|
522
555
|
return {
|
|
523
556
|
data: null,
|
|
@@ -536,10 +569,10 @@ export class XykService {
|
|
|
536
569
|
"X-Requested-With": userAgent
|
|
537
570
|
}
|
|
538
571
|
}));
|
|
539
|
-
debugOutput(response.url, response.status
|
|
540
|
-
if (response.status === null || response.status === 429) {
|
|
572
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
573
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
541
574
|
try {
|
|
542
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
575
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
543
576
|
}
|
|
544
577
|
catch (error) {
|
|
545
578
|
success = true;
|
|
@@ -569,8 +602,8 @@ export class XykService {
|
|
|
569
602
|
return {
|
|
570
603
|
data: null,
|
|
571
604
|
error: true,
|
|
572
|
-
error_code: data ? data.error_code : response.status,
|
|
573
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
605
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
606
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
574
607
|
};
|
|
575
608
|
}
|
|
576
609
|
}
|
|
@@ -592,6 +625,7 @@ export class XykService {
|
|
|
592
625
|
while (!success) {
|
|
593
626
|
try {
|
|
594
627
|
const urlParams = new URLSearchParams();
|
|
628
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/?${urlParams}`;
|
|
595
629
|
if (!this.is_key_valid) {
|
|
596
630
|
return {
|
|
597
631
|
data: null,
|
|
@@ -610,10 +644,10 @@ export class XykService {
|
|
|
610
644
|
"X-Requested-With": userAgent
|
|
611
645
|
}
|
|
612
646
|
}));
|
|
613
|
-
debugOutput(response.url, response.status
|
|
614
|
-
if (response.status === null || response.status === 429) {
|
|
647
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
648
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
615
649
|
try {
|
|
616
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
650
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
617
651
|
}
|
|
618
652
|
catch (error) {
|
|
619
653
|
success = true;
|
|
@@ -643,8 +677,8 @@ export class XykService {
|
|
|
643
677
|
return {
|
|
644
678
|
data: null,
|
|
645
679
|
error: true,
|
|
646
|
-
error_code: data ? data.error_code : response.status,
|
|
647
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
680
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
681
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
648
682
|
};
|
|
649
683
|
}
|
|
650
684
|
}
|
|
@@ -682,6 +716,7 @@ export class XykService {
|
|
|
682
716
|
if (queryParamOpts?.dexName !== undefined) {
|
|
683
717
|
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
684
718
|
}
|
|
719
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/tokens/address/${tokenAddress}/pools/page/${page}/?${urlParams}`;
|
|
685
720
|
let startTime;
|
|
686
721
|
if (this.debug) {
|
|
687
722
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -692,10 +727,10 @@ export class XykService {
|
|
|
692
727
|
"X-Requested-With": userAgent
|
|
693
728
|
}
|
|
694
729
|
}));
|
|
695
|
-
debugOutput(response.url, response.status
|
|
696
|
-
if (response.status === null || response.status === 429) {
|
|
730
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
731
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
697
732
|
try {
|
|
698
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
733
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
699
734
|
}
|
|
700
735
|
catch (error) {
|
|
701
736
|
success = true;
|
|
@@ -725,8 +760,8 @@ export class XykService {
|
|
|
725
760
|
return {
|
|
726
761
|
data: null,
|
|
727
762
|
error: true,
|
|
728
|
-
error_code: data ? data.error_code : response.status,
|
|
729
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
763
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
764
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
730
765
|
};
|
|
731
766
|
}
|
|
732
767
|
}
|
|
@@ -756,6 +791,7 @@ export class XykService {
|
|
|
756
791
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
757
792
|
};
|
|
758
793
|
}
|
|
794
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/balances/?${urlParams}`;
|
|
759
795
|
let startTime;
|
|
760
796
|
if (this.debug) {
|
|
761
797
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -766,10 +802,10 @@ export class XykService {
|
|
|
766
802
|
"X-Requested-With": userAgent
|
|
767
803
|
}
|
|
768
804
|
}));
|
|
769
|
-
debugOutput(response.url, response.status
|
|
770
|
-
if (response.status === null || response.status === 429) {
|
|
805
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
806
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
771
807
|
try {
|
|
772
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
808
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
773
809
|
}
|
|
774
810
|
catch (error) {
|
|
775
811
|
success = true;
|
|
@@ -799,8 +835,8 @@ export class XykService {
|
|
|
799
835
|
return {
|
|
800
836
|
data: null,
|
|
801
837
|
error: true,
|
|
802
|
-
error_code: data ? data.error_code : response.status,
|
|
803
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
838
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
839
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
804
840
|
};
|
|
805
841
|
}
|
|
806
842
|
}
|
|
@@ -842,6 +878,7 @@ export class XykService {
|
|
|
842
878
|
if (queryParamOpts?.dexName !== undefined) {
|
|
843
879
|
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
844
880
|
}
|
|
881
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/address/${walletAddress}/pools/page/${page}/?${urlParams}`;
|
|
845
882
|
let startTime;
|
|
846
883
|
if (this.debug) {
|
|
847
884
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -852,10 +889,10 @@ export class XykService {
|
|
|
852
889
|
"X-Requested-With": userAgent
|
|
853
890
|
}
|
|
854
891
|
}));
|
|
855
|
-
debugOutput(response.url, response.status
|
|
856
|
-
if (response.status === null || response.status === 429) {
|
|
892
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
893
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
857
894
|
try {
|
|
858
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
895
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
859
896
|
}
|
|
860
897
|
catch (error) {
|
|
861
898
|
success = true;
|
|
@@ -885,8 +922,8 @@ export class XykService {
|
|
|
885
922
|
return {
|
|
886
923
|
data: null,
|
|
887
924
|
error: true,
|
|
888
|
-
error_code: data ? data.error_code : response.status,
|
|
889
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
925
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
926
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
890
927
|
};
|
|
891
928
|
}
|
|
892
929
|
}
|
|
@@ -915,6 +952,7 @@ export class XykService {
|
|
|
915
952
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
916
953
|
};
|
|
917
954
|
}
|
|
955
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/?${urlParams}`;
|
|
918
956
|
let startTime;
|
|
919
957
|
if (this.debug) {
|
|
920
958
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -925,10 +963,10 @@ export class XykService {
|
|
|
925
963
|
"X-Requested-With": userAgent
|
|
926
964
|
}
|
|
927
965
|
}));
|
|
928
|
-
debugOutput(response.url, response.status
|
|
929
|
-
if (response.status === null || response.status === 429) {
|
|
966
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
967
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
930
968
|
try {
|
|
931
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
969
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
932
970
|
}
|
|
933
971
|
catch (error) {
|
|
934
972
|
success = true;
|
|
@@ -958,8 +996,8 @@ export class XykService {
|
|
|
958
996
|
return {
|
|
959
997
|
data: null,
|
|
960
998
|
error: true,
|
|
961
|
-
error_code: data ? data.error_code : response.status,
|
|
962
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
999
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1000
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
963
1001
|
};
|
|
964
1002
|
}
|
|
965
1003
|
}
|
|
@@ -986,6 +1024,7 @@ export class XykService {
|
|
|
986
1024
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
987
1025
|
};
|
|
988
1026
|
}
|
|
1027
|
+
const url = `https://api.covalenthq.com/v1/xy=k/supported_dexes/?${urlParams}`;
|
|
989
1028
|
let startTime;
|
|
990
1029
|
if (this.debug) {
|
|
991
1030
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -996,10 +1035,10 @@ export class XykService {
|
|
|
996
1035
|
"X-Requested-With": userAgent
|
|
997
1036
|
}
|
|
998
1037
|
}));
|
|
999
|
-
debugOutput(response.url, response.status
|
|
1000
|
-
if (response.status === null || response.status === 429) {
|
|
1038
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1039
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1001
1040
|
try {
|
|
1002
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1041
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1003
1042
|
}
|
|
1004
1043
|
catch (error) {
|
|
1005
1044
|
success = true;
|
|
@@ -1029,8 +1068,8 @@ export class XykService {
|
|
|
1029
1068
|
return {
|
|
1030
1069
|
data: null,
|
|
1031
1070
|
error: true,
|
|
1032
|
-
error_code: data ? data.error_code : response.status,
|
|
1033
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1071
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1072
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1034
1073
|
};
|
|
1035
1074
|
}
|
|
1036
1075
|
}
|
|
@@ -1060,6 +1099,7 @@ export class XykService {
|
|
|
1060
1099
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1061
1100
|
};
|
|
1062
1101
|
}
|
|
1102
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`;
|
|
1063
1103
|
let startTime;
|
|
1064
1104
|
if (this.debug) {
|
|
1065
1105
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1070,10 +1110,10 @@ export class XykService {
|
|
|
1070
1110
|
"X-Requested-With": userAgent
|
|
1071
1111
|
}
|
|
1072
1112
|
}));
|
|
1073
|
-
debugOutput(response.url, response.status
|
|
1074
|
-
if (response.status === null || response.status === 429) {
|
|
1113
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1114
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1075
1115
|
try {
|
|
1076
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1116
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1077
1117
|
}
|
|
1078
1118
|
catch (error) {
|
|
1079
1119
|
success = true;
|
|
@@ -1103,8 +1143,8 @@ export class XykService {
|
|
|
1103
1143
|
return {
|
|
1104
1144
|
data: null,
|
|
1105
1145
|
error: true,
|
|
1106
|
-
error_code: data ? data.error_code : response.status,
|
|
1107
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1146
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1147
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1108
1148
|
};
|
|
1109
1149
|
}
|
|
1110
1150
|
}
|
|
@@ -1134,6 +1174,7 @@ export class XykService {
|
|
|
1134
1174
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1135
1175
|
};
|
|
1136
1176
|
}
|
|
1177
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/transactions/?${urlParams}`;
|
|
1137
1178
|
let startTime;
|
|
1138
1179
|
if (this.debug) {
|
|
1139
1180
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1144,10 +1185,10 @@ export class XykService {
|
|
|
1144
1185
|
"X-Requested-With": userAgent
|
|
1145
1186
|
}
|
|
1146
1187
|
}));
|
|
1147
|
-
debugOutput(response.url, response.status
|
|
1148
|
-
if (response.status === null || response.status === 429) {
|
|
1188
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1189
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1149
1190
|
try {
|
|
1150
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1191
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1151
1192
|
}
|
|
1152
1193
|
catch (error) {
|
|
1153
1194
|
success = true;
|
|
@@ -1177,8 +1218,8 @@ export class XykService {
|
|
|
1177
1218
|
return {
|
|
1178
1219
|
data: null,
|
|
1179
1220
|
error: true,
|
|
1180
|
-
error_code: data ? data.error_code : response.status,
|
|
1181
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1221
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1222
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1182
1223
|
};
|
|
1183
1224
|
}
|
|
1184
1225
|
}
|
|
@@ -1208,6 +1249,7 @@ export class XykService {
|
|
|
1208
1249
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1209
1250
|
};
|
|
1210
1251
|
}
|
|
1252
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`;
|
|
1211
1253
|
let startTime;
|
|
1212
1254
|
if (this.debug) {
|
|
1213
1255
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1218,10 +1260,10 @@ export class XykService {
|
|
|
1218
1260
|
"X-Requested-With": userAgent
|
|
1219
1261
|
}
|
|
1220
1262
|
}));
|
|
1221
|
-
debugOutput(response.url, response.status
|
|
1222
|
-
if (response.status === null || response.status === 429) {
|
|
1263
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1264
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1223
1265
|
try {
|
|
1224
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1266
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1225
1267
|
}
|
|
1226
1268
|
catch (error) {
|
|
1227
1269
|
success = true;
|
|
@@ -1251,8 +1293,8 @@ export class XykService {
|
|
|
1251
1293
|
return {
|
|
1252
1294
|
data: null,
|
|
1253
1295
|
error: true,
|
|
1254
|
-
error_code: data ? data.error_code : response.status,
|
|
1255
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1296
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1297
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1256
1298
|
};
|
|
1257
1299
|
}
|
|
1258
1300
|
}
|
|
@@ -1282,6 +1324,7 @@ export class XykService {
|
|
|
1282
1324
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1283
1325
|
};
|
|
1284
1326
|
}
|
|
1327
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`;
|
|
1285
1328
|
let startTime;
|
|
1286
1329
|
if (this.debug) {
|
|
1287
1330
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1292,10 +1335,10 @@ export class XykService {
|
|
|
1292
1335
|
"X-Requested-With": userAgent
|
|
1293
1336
|
}
|
|
1294
1337
|
}));
|
|
1295
|
-
debugOutput(response.url, response.status
|
|
1296
|
-
if (response.status === null || response.status === 429) {
|
|
1338
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1339
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1297
1340
|
try {
|
|
1298
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1341
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1299
1342
|
}
|
|
1300
1343
|
catch (error) {
|
|
1301
1344
|
success = true;
|
|
@@ -1325,8 +1368,8 @@ export class XykService {
|
|
|
1325
1368
|
return {
|
|
1326
1369
|
data: null,
|
|
1327
1370
|
error: true,
|
|
1328
|
-
error_code: data ? data.error_code : response.status,
|
|
1329
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1371
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1372
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1330
1373
|
};
|
|
1331
1374
|
}
|
|
1332
1375
|
}
|
|
@@ -1355,6 +1398,7 @@ export class XykService {
|
|
|
1355
1398
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1356
1399
|
};
|
|
1357
1400
|
}
|
|
1401
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/ecosystem/?${urlParams}`;
|
|
1358
1402
|
let startTime;
|
|
1359
1403
|
if (this.debug) {
|
|
1360
1404
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1365,10 +1409,10 @@ export class XykService {
|
|
|
1365
1409
|
"X-Requested-With": userAgent
|
|
1366
1410
|
}
|
|
1367
1411
|
}));
|
|
1368
|
-
debugOutput(response.url, response.status
|
|
1369
|
-
if (response.status === null || response.status === 429) {
|
|
1412
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1413
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1370
1414
|
try {
|
|
1371
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1415
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1372
1416
|
}
|
|
1373
1417
|
catch (error) {
|
|
1374
1418
|
success = true;
|
|
@@ -1398,8 +1442,8 @@ export class XykService {
|
|
|
1398
1442
|
return {
|
|
1399
1443
|
data: null,
|
|
1400
1444
|
error: true,
|
|
1401
|
-
error_code: data ? data.error_code : response.status,
|
|
1402
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1445
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1446
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1403
1447
|
};
|
|
1404
1448
|
}
|
|
1405
1449
|
}
|
|
@@ -1428,6 +1472,7 @@ export class XykService {
|
|
|
1428
1472
|
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1429
1473
|
};
|
|
1430
1474
|
}
|
|
1475
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/health/?${urlParams}`;
|
|
1431
1476
|
let startTime;
|
|
1432
1477
|
if (this.debug) {
|
|
1433
1478
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1438,10 +1483,10 @@ export class XykService {
|
|
|
1438
1483
|
"X-Requested-With": userAgent
|
|
1439
1484
|
}
|
|
1440
1485
|
}));
|
|
1441
|
-
debugOutput(response.url, response.status
|
|
1442
|
-
if (response.status === null || response.status === 429) {
|
|
1486
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
1487
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
1443
1488
|
try {
|
|
1444
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1489
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
1445
1490
|
}
|
|
1446
1491
|
catch (error) {
|
|
1447
1492
|
success = true;
|
|
@@ -1471,8 +1516,8 @@ export class XykService {
|
|
|
1471
1516
|
return {
|
|
1472
1517
|
data: null,
|
|
1473
1518
|
error: true,
|
|
1474
|
-
error_code: data ? data.error_code : response.status,
|
|
1475
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1519
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
1520
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
1476
1521
|
};
|
|
1477
1522
|
}
|
|
1478
1523
|
}
|