@covalenthq/client-sdk 0.4.2 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -40
- package/dist/cjs/index.js +956 -239
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +100 -0
- package/dist/cjs/services/BaseService.d.ts +17 -0
- package/dist/cjs/services/CovalentClient.d.ts +3 -3
- package/dist/cjs/services/NftService.d.ts +137 -1
- package/dist/cjs/services/SecurityService.d.ts +62 -0
- package/dist/cjs/services/TransactionService.d.ts +65 -0
- package/dist/cjs/services/XykService.d.ts +4 -0
- package/dist/cjs/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/cjs/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/cjs/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/es/index.js +956 -239
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +100 -0
- package/dist/es/services/BaseService.d.ts +17 -0
- package/dist/es/services/CovalentClient.d.ts +3 -3
- package/dist/es/services/NftService.d.ts +137 -1
- package/dist/es/services/SecurityService.d.ts +62 -0
- package/dist/es/services/TransactionService.d.ts +65 -0
- package/dist/es/services/XykService.d.ts +4 -0
- package/dist/es/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/es/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/es/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/es/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/es/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/esm/index.js +956 -239
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +100 -0
- package/dist/esm/services/BaseService.d.ts +17 -0
- package/dist/esm/services/CovalentClient.d.ts +3 -3
- package/dist/esm/services/NftService.d.ts +137 -1
- package/dist/esm/services/SecurityService.d.ts +62 -0
- package/dist/esm/services/TransactionService.d.ts +65 -0
- package/dist/esm/services/XykService.d.ts +4 -0
- package/dist/esm/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/esm/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/esm/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/esm/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +27 -0
- package/dist/services/BalanceService.d.ts +100 -0
- package/dist/services/BalanceService.js +193 -6
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +17 -0
- package/dist/services/BaseService.js +23 -12
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +3 -3
- package/dist/services/CovalentClient.js +1 -1
- package/dist/services/NftService.d.ts +137 -1
- package/dist/services/NftService.js +294 -16
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.js +2 -2
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +62 -0
- package/dist/services/SecurityService.js +103 -2
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +65 -0
- package/dist/services/TransactionService.js +116 -7
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +4 -0
- package/dist/services/XykService.js +34 -28
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.js +1 -1
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/types/BalanceServiceTypes.d.ts +38 -0
- package/dist/util/types/BaseServiceTypes.d.ts +16 -0
- package/dist/util/types/NftServiceTypes.d.ts +76 -0
- package/dist/util/types/SecurityServiceTypes.d.ts +50 -0
- package/dist/util/types/TransactionServiceTypes.d.ts +27 -0
- package/package.json +2 -1
package/dist/cjs/index.js
CHANGED
|
@@ -279,7 +279,7 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
279
279
|
if (error.message.includes("An error occurred 429")) {
|
|
280
280
|
throw new Error(error.message);
|
|
281
281
|
}
|
|
282
|
-
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : "401 Authorization Required"}`);
|
|
282
|
+
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"}`);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -329,6 +329,43 @@ class TokenSpenderItem {
|
|
|
329
329
|
this.risk_factor = data.risk_factor;
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
+
class NftApprovalsResponse {
|
|
333
|
+
constructor(data) {
|
|
334
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
335
|
+
this.chain_id = data.chain_id;
|
|
336
|
+
this.chain_name = data.chain_name;
|
|
337
|
+
this.address = data.address;
|
|
338
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new NftApprovalsItem(itemData)) : null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class NftApprovalsItem {
|
|
342
|
+
constructor(data) {
|
|
343
|
+
this.contract_address = data.contract_address;
|
|
344
|
+
this.contract_address_label = data.contract_address_label;
|
|
345
|
+
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
346
|
+
this.token_balances = data.token_balances && data.token_balances !== null ? data.token_balances.map((itemData) => new NftApprovalBalance(itemData)) : null;
|
|
347
|
+
this.spenders = data.spenders && data.spenders !== null ? data.spenders.map((itemData) => new NftApprovalSpender(itemData)) : null;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
class NftApprovalBalance {
|
|
351
|
+
constructor(data) {
|
|
352
|
+
this.token_id = data.token_id && data.token_id !== null ? BigInt(data.token_id) : null;
|
|
353
|
+
this.token_balance = data.token_balance && data.token_balance !== null ? BigInt(data.token_balance) : null;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class NftApprovalSpender {
|
|
357
|
+
constructor(data) {
|
|
358
|
+
this.block_height = data.block_height;
|
|
359
|
+
this.tx_offset = data.tx_offset;
|
|
360
|
+
this.log_offset = data.log_offset;
|
|
361
|
+
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? dateFns.parseISO(data.block_signed_at.toString()) : null;
|
|
362
|
+
this.tx_hash = data.tx_hash;
|
|
363
|
+
this.spender_address = data.spender_address;
|
|
364
|
+
this.spender_address_label = data.spender_address_label;
|
|
365
|
+
this.token_ids_approved = data.token_ids_approved;
|
|
366
|
+
this.allowance = data.allowance;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
332
369
|
/**
|
|
333
370
|
* Approvals API
|
|
334
371
|
*
|
|
@@ -391,7 +428,71 @@ class SecurityService {
|
|
|
391
428
|
data: dataClass,
|
|
392
429
|
error: data.error,
|
|
393
430
|
error_code: data ? data.error_code : response.status,
|
|
394
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
431
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
success = true;
|
|
436
|
+
return {
|
|
437
|
+
data: null,
|
|
438
|
+
error: true,
|
|
439
|
+
error_code: data ? data.error_code : response.status,
|
|
440
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
*
|
|
447
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
448
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
449
|
+
|
|
450
|
+
*
|
|
451
|
+
*/
|
|
452
|
+
async getNftApprovals(chainName, walletAddress) {
|
|
453
|
+
let success = false;
|
|
454
|
+
let data;
|
|
455
|
+
let response;
|
|
456
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
457
|
+
while (!success) {
|
|
458
|
+
try {
|
|
459
|
+
const urlParams = new URLSearchParams();
|
|
460
|
+
let startTime;
|
|
461
|
+
if (this.debug) {
|
|
462
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
463
|
+
}
|
|
464
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/approvals/${walletAddress}/?${urlParams}`, {
|
|
465
|
+
headers: {
|
|
466
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
467
|
+
"X-Requested-With": userAgent
|
|
468
|
+
}
|
|
469
|
+
}));
|
|
470
|
+
debugOutput(response.url, response.status, startTime);
|
|
471
|
+
if (response.status === 429) {
|
|
472
|
+
try {
|
|
473
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
success = true;
|
|
477
|
+
return {
|
|
478
|
+
data: null,
|
|
479
|
+
error: true,
|
|
480
|
+
error_code: response.status,
|
|
481
|
+
error_message: error.message
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
data = await response.json();
|
|
487
|
+
}
|
|
488
|
+
const dataClass = new NftApprovalsResponse(data.data);
|
|
489
|
+
checkAndModifyResponse(dataClass);
|
|
490
|
+
success = true;
|
|
491
|
+
return {
|
|
492
|
+
data: dataClass,
|
|
493
|
+
error: data.error,
|
|
494
|
+
error_code: data ? data.error_code : response.status,
|
|
495
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
395
496
|
};
|
|
396
497
|
}
|
|
397
498
|
catch (error) {
|
|
@@ -400,7 +501,7 @@ class SecurityService {
|
|
|
400
501
|
data: null,
|
|
401
502
|
error: true,
|
|
402
503
|
error_code: data ? data.error_code : response.status,
|
|
403
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
504
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
404
505
|
};
|
|
405
506
|
}
|
|
406
507
|
}
|
|
@@ -510,6 +611,17 @@ class OhlcItem {
|
|
|
510
611
|
this.pretty_quote = data.pretty_quote;
|
|
511
612
|
}
|
|
512
613
|
}
|
|
614
|
+
class Erc20TransfersResponse {
|
|
615
|
+
constructor(data) {
|
|
616
|
+
this.address = data.address;
|
|
617
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
618
|
+
this.quote_currency = data.quote_currency;
|
|
619
|
+
this.chain_id = data.chain_id;
|
|
620
|
+
this.chain_name = data.chain_name;
|
|
621
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new BlockTransactionWithContractTransfers(itemData)) : null;
|
|
622
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$2(data.pagination) : null;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
513
625
|
class BlockTransactionWithContractTransfers {
|
|
514
626
|
constructor(data) {
|
|
515
627
|
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? dateFns.parseISO(data.block_signed_at.toString()) : null;
|
|
@@ -534,6 +646,14 @@ class BlockTransactionWithContractTransfers {
|
|
|
534
646
|
this.transfers = data.transfers && data.transfers !== null ? data.transfers.map((itemData) => new TokenTransferItem(itemData)) : null;
|
|
535
647
|
}
|
|
536
648
|
}
|
|
649
|
+
let Pagination$2 = class Pagination {
|
|
650
|
+
constructor(data) {
|
|
651
|
+
this.has_more = data.has_more;
|
|
652
|
+
this.page_number = data.page_number;
|
|
653
|
+
this.page_size = data.page_size;
|
|
654
|
+
this.total_count = data.total_count;
|
|
655
|
+
}
|
|
656
|
+
};
|
|
537
657
|
class TokenTransferItem {
|
|
538
658
|
constructor(data) {
|
|
539
659
|
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? dateFns.parseISO(data.block_signed_at.toString()) : null;
|
|
@@ -608,6 +728,31 @@ class HistoricalBalanceItem {
|
|
|
608
728
|
this.nft_data = data.nft_data && data.nft_data !== null ? data.nft_data.map((itemData) => new NftData$1(itemData)) : null;
|
|
609
729
|
}
|
|
610
730
|
}
|
|
731
|
+
class TokenBalanceNativeResponse {
|
|
732
|
+
constructor(data) {
|
|
733
|
+
this.address = data.address;
|
|
734
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
735
|
+
this.quote_currency = data.quote_currency;
|
|
736
|
+
this.chain_id = data.chain_id;
|
|
737
|
+
this.chain_name = data.chain_name;
|
|
738
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new NativeBalanceItem(itemData)) : null;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
class NativeBalanceItem {
|
|
742
|
+
constructor(data) {
|
|
743
|
+
this.contract_decimals = data.contract_decimals;
|
|
744
|
+
this.contract_name = data.contract_name;
|
|
745
|
+
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
746
|
+
this.contract_address = data.contract_address;
|
|
747
|
+
this.supports_erc = data.supports_erc;
|
|
748
|
+
this.logo_url = data.logo_url;
|
|
749
|
+
this.block_height = data.block_height;
|
|
750
|
+
this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
|
|
751
|
+
this.quote_rate = data.quote_rate;
|
|
752
|
+
this.quote = data.quote;
|
|
753
|
+
this.pretty_quote = data.pretty_quote;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
611
756
|
/**
|
|
612
757
|
* Balances APIs
|
|
613
758
|
*
|
|
@@ -691,7 +836,7 @@ class BalanceService {
|
|
|
691
836
|
data: dataClass,
|
|
692
837
|
error: data.error,
|
|
693
838
|
error_code: data ? data.error_code : response.status,
|
|
694
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
839
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
695
840
|
};
|
|
696
841
|
}
|
|
697
842
|
catch (error) {
|
|
@@ -700,7 +845,7 @@ class BalanceService {
|
|
|
700
845
|
data: null,
|
|
701
846
|
error: true,
|
|
702
847
|
error_code: data ? data.error_code : response.status,
|
|
703
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
848
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
704
849
|
};
|
|
705
850
|
}
|
|
706
851
|
}
|
|
@@ -765,7 +910,7 @@ class BalanceService {
|
|
|
765
910
|
data: dataClass,
|
|
766
911
|
error: data.error,
|
|
767
912
|
error_code: data ? data.error_code : response.status,
|
|
768
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
913
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
769
914
|
};
|
|
770
915
|
}
|
|
771
916
|
catch (error) {
|
|
@@ -774,7 +919,7 @@ class BalanceService {
|
|
|
774
919
|
data: null,
|
|
775
920
|
error: true,
|
|
776
921
|
error_code: data ? data.error_code : response.status,
|
|
777
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
922
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
778
923
|
};
|
|
779
924
|
}
|
|
780
925
|
}
|
|
@@ -829,6 +974,96 @@ class BalanceService {
|
|
|
829
974
|
}
|
|
830
975
|
}
|
|
831
976
|
}
|
|
977
|
+
/**
|
|
978
|
+
*
|
|
979
|
+
* Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
|
|
980
|
+
*
|
|
981
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
982
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
983
|
+
* @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
|
|
984
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
985
|
+
* - `contractAddress`: The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
986
|
+
* - `startingBlock`: The block height to start from, defaults to `0`.
|
|
987
|
+
* - `endingBlock`: The block height to end at, defaults to current block height.
|
|
988
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
989
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
990
|
+
*
|
|
991
|
+
*/
|
|
992
|
+
async getErc20TransfersForWalletAddressByPage(chainName, walletAddress, queryParamOpts) {
|
|
993
|
+
let success = false;
|
|
994
|
+
let data;
|
|
995
|
+
let response;
|
|
996
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
997
|
+
while (!success) {
|
|
998
|
+
try {
|
|
999
|
+
const urlParams = new URLSearchParams();
|
|
1000
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1001
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1002
|
+
}
|
|
1003
|
+
if (queryParamOpts?.contractAddress !== undefined) {
|
|
1004
|
+
urlParams.append("contract-address", queryParamOpts?.contractAddress.toString());
|
|
1005
|
+
}
|
|
1006
|
+
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1007
|
+
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1008
|
+
}
|
|
1009
|
+
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1010
|
+
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1011
|
+
}
|
|
1012
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1013
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1014
|
+
}
|
|
1015
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1016
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1017
|
+
}
|
|
1018
|
+
let startTime;
|
|
1019
|
+
if (this.debug) {
|
|
1020
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1021
|
+
}
|
|
1022
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, {
|
|
1023
|
+
headers: {
|
|
1024
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1025
|
+
"X-Requested-With": userAgent
|
|
1026
|
+
}
|
|
1027
|
+
}));
|
|
1028
|
+
debugOutput(response.url, response.status, startTime);
|
|
1029
|
+
if (response.status === 429) {
|
|
1030
|
+
try {
|
|
1031
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1032
|
+
}
|
|
1033
|
+
catch (error) {
|
|
1034
|
+
success = true;
|
|
1035
|
+
return {
|
|
1036
|
+
data: null,
|
|
1037
|
+
error: true,
|
|
1038
|
+
error_code: response.status,
|
|
1039
|
+
error_message: error.message
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
data = await response.json();
|
|
1045
|
+
}
|
|
1046
|
+
const dataClass = new Erc20TransfersResponse(data.data);
|
|
1047
|
+
checkAndModifyResponse(dataClass);
|
|
1048
|
+
success = true;
|
|
1049
|
+
return {
|
|
1050
|
+
data: dataClass,
|
|
1051
|
+
error: data.error,
|
|
1052
|
+
error_code: data ? data.error_code : response.status,
|
|
1053
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
catch (error) {
|
|
1057
|
+
success = true;
|
|
1058
|
+
return {
|
|
1059
|
+
data: null,
|
|
1060
|
+
error: true,
|
|
1061
|
+
error_code: data ? data.error_code : response.status,
|
|
1062
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
832
1067
|
/**
|
|
833
1068
|
*
|
|
834
1069
|
* Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
|
|
@@ -947,7 +1182,7 @@ class BalanceService {
|
|
|
947
1182
|
data: dataClass,
|
|
948
1183
|
error: data.error,
|
|
949
1184
|
error_code: data ? data.error_code : response.status,
|
|
950
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1185
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
951
1186
|
};
|
|
952
1187
|
}
|
|
953
1188
|
catch (error) {
|
|
@@ -956,60 +1191,132 @@ class BalanceService {
|
|
|
956
1191
|
data: null,
|
|
957
1192
|
error: true,
|
|
958
1193
|
error_code: data ? data.error_code : response.status,
|
|
959
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1194
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
960
1195
|
};
|
|
961
1196
|
}
|
|
962
1197
|
}
|
|
963
1198
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1199
|
+
/**
|
|
1200
|
+
*
|
|
1201
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1202
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1203
|
+
* @param {GetNativeTokenBalanceQueryParamOpts} queryParamOpts
|
|
1204
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
1205
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
1206
|
+
*
|
|
1207
|
+
*/
|
|
1208
|
+
async getNativeTokenBalance(chainName, walletAddress, queryParamOpts) {
|
|
1209
|
+
let success = false;
|
|
1210
|
+
let data;
|
|
1211
|
+
let response;
|
|
1212
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1213
|
+
while (!success) {
|
|
1214
|
+
try {
|
|
1215
|
+
const urlParams = new URLSearchParams();
|
|
1216
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1217
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1218
|
+
}
|
|
1219
|
+
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1220
|
+
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1221
|
+
}
|
|
1222
|
+
let startTime;
|
|
1223
|
+
if (this.debug) {
|
|
1224
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1225
|
+
}
|
|
1226
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`, {
|
|
1227
|
+
headers: {
|
|
1228
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1229
|
+
"X-Requested-With": userAgent
|
|
1230
|
+
}
|
|
1231
|
+
}));
|
|
1232
|
+
debugOutput(response.url, response.status, startTime);
|
|
1233
|
+
if (response.status === 429) {
|
|
1234
|
+
try {
|
|
1235
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1236
|
+
}
|
|
1237
|
+
catch (error) {
|
|
1238
|
+
success = true;
|
|
1239
|
+
return {
|
|
1240
|
+
data: null,
|
|
1241
|
+
error: true,
|
|
1242
|
+
error_code: response.status,
|
|
1243
|
+
error_message: error.message
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
data = await response.json();
|
|
1249
|
+
}
|
|
1250
|
+
const dataClass = new TokenBalanceNativeResponse(data.data);
|
|
1251
|
+
checkAndModifyResponse(dataClass);
|
|
1252
|
+
success = true;
|
|
1253
|
+
return {
|
|
1254
|
+
data: dataClass,
|
|
1255
|
+
error: data.error,
|
|
1256
|
+
error_code: data ? data.error_code : response.status,
|
|
1257
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
catch (error) {
|
|
1261
|
+
success = true;
|
|
1262
|
+
return {
|
|
1263
|
+
data: null,
|
|
1264
|
+
error: true,
|
|
1265
|
+
error_code: data ? data.error_code : response.status,
|
|
1266
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
class BlockResponse {
|
|
1274
|
+
constructor(data) {
|
|
1275
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
1276
|
+
this.chain_id = data.chain_id;
|
|
1277
|
+
this.chain_name = data.chain_name;
|
|
1278
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Block(itemData)) : null;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
class Block {
|
|
1282
|
+
constructor(data) {
|
|
1283
|
+
this.signed_at = data.signed_at && data.signed_at !== null ? dateFns.parseISO(data.signed_at.toString()) : null;
|
|
1284
|
+
this.height = data.height;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
class ResolvedAddress {
|
|
1288
|
+
constructor(data) {
|
|
1289
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
1290
|
+
this.chain_id = data.chain_id;
|
|
1291
|
+
this.chain_name = data.chain_name;
|
|
1292
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new ResolvedAddressItem(itemData)) : null;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
class ResolvedAddressItem {
|
|
1296
|
+
constructor(data) {
|
|
1297
|
+
this.address = data.address;
|
|
1298
|
+
this.name = data.name;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
class GetLogsResponse {
|
|
1302
|
+
constructor(data) {
|
|
1303
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
1304
|
+
this.chain_id = data.chain_id;
|
|
1305
|
+
this.chain_name = data.chain_name;
|
|
1306
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new GetLogsEvent(itemData)) : null;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
class GetLogsEvent {
|
|
1310
|
+
constructor(data) {
|
|
1311
|
+
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? dateFns.parseISO(data.block_signed_at.toString()) : null;
|
|
1312
|
+
this.block_height = data.block_height;
|
|
1313
|
+
this.block_hash = data.block_hash;
|
|
1314
|
+
this.tx_offset = data.tx_offset;
|
|
1315
|
+
this.log_offset = data.log_offset;
|
|
1316
|
+
this.tx_hash = data.tx_hash;
|
|
1317
|
+
this.raw_log_topics = data.raw_log_topics;
|
|
1318
|
+
this.sender_contract_decimals = data.sender_contract_decimals;
|
|
1319
|
+
this.sender_name = data.sender_name;
|
|
1013
1320
|
this.sender_contract_ticker_symbol = data.sender_contract_ticker_symbol;
|
|
1014
1321
|
this.sender_address = data.sender_address;
|
|
1015
1322
|
this.sender_address_label = data.sender_address_label;
|
|
@@ -1070,9 +1377,20 @@ class ChainItem {
|
|
|
1070
1377
|
this.black_logo_url = data.black_logo_url;
|
|
1071
1378
|
this.white_logo_url = data.white_logo_url;
|
|
1072
1379
|
this.is_appchain = data.is_appchain;
|
|
1380
|
+
this.color_theme = data.color_theme && data.color_theme !== null ? new ColorTheme(data.color_theme) : null;
|
|
1073
1381
|
this.appchain_of = data.appchain_of && data.appchain_of !== null ? new ChainItem(data.appchain_of) : null;
|
|
1074
1382
|
}
|
|
1075
1383
|
}
|
|
1384
|
+
class ColorTheme {
|
|
1385
|
+
constructor(data) {
|
|
1386
|
+
this.red = data.red;
|
|
1387
|
+
this.green = data.green;
|
|
1388
|
+
this.blue = data.blue;
|
|
1389
|
+
this.alpha = data.alpha;
|
|
1390
|
+
this.hex = data.hex;
|
|
1391
|
+
this.css_rgb = data.css_rgb;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1076
1394
|
class AllChainsStatusResponse {
|
|
1077
1395
|
constructor(data) {
|
|
1078
1396
|
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
@@ -1168,7 +1486,7 @@ class BaseService {
|
|
|
1168
1486
|
data: dataClass,
|
|
1169
1487
|
error: data.error,
|
|
1170
1488
|
error_code: data ? data.error_code : response.status,
|
|
1171
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1489
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1172
1490
|
};
|
|
1173
1491
|
}
|
|
1174
1492
|
catch (error) {
|
|
@@ -1177,7 +1495,7 @@ class BaseService {
|
|
|
1177
1495
|
data: null,
|
|
1178
1496
|
error: true,
|
|
1179
1497
|
error_code: data ? data.error_code : response.status,
|
|
1180
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1498
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1181
1499
|
};
|
|
1182
1500
|
}
|
|
1183
1501
|
}
|
|
@@ -1233,7 +1551,7 @@ class BaseService {
|
|
|
1233
1551
|
data: dataClass,
|
|
1234
1552
|
error: data.error,
|
|
1235
1553
|
error_code: data ? data.error_code : response.status,
|
|
1236
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1554
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1237
1555
|
};
|
|
1238
1556
|
}
|
|
1239
1557
|
catch (error) {
|
|
@@ -1242,7 +1560,7 @@ class BaseService {
|
|
|
1242
1560
|
data: null,
|
|
1243
1561
|
error: true,
|
|
1244
1562
|
error_code: data ? data.error_code : response.status,
|
|
1245
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1563
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1246
1564
|
};
|
|
1247
1565
|
}
|
|
1248
1566
|
}
|
|
@@ -1357,7 +1675,7 @@ class BaseService {
|
|
|
1357
1675
|
data: dataClass,
|
|
1358
1676
|
error: data.error,
|
|
1359
1677
|
error_code: data ? data.error_code : response.status,
|
|
1360
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1678
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1361
1679
|
};
|
|
1362
1680
|
}
|
|
1363
1681
|
catch (error) {
|
|
@@ -1366,7 +1684,7 @@ class BaseService {
|
|
|
1366
1684
|
data: null,
|
|
1367
1685
|
error: true,
|
|
1368
1686
|
error_code: data ? data.error_code : response.status,
|
|
1369
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1687
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1370
1688
|
};
|
|
1371
1689
|
}
|
|
1372
1690
|
}
|
|
@@ -1508,7 +1826,7 @@ class BaseService {
|
|
|
1508
1826
|
data: dataClass,
|
|
1509
1827
|
error: data.error,
|
|
1510
1828
|
error_code: data ? data.error_code : response.status,
|
|
1511
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1829
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1512
1830
|
};
|
|
1513
1831
|
}
|
|
1514
1832
|
catch (error) {
|
|
@@ -1517,7 +1835,7 @@ class BaseService {
|
|
|
1517
1835
|
data: null,
|
|
1518
1836
|
error: true,
|
|
1519
1837
|
error_code: data ? data.error_code : response.status,
|
|
1520
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1838
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1521
1839
|
};
|
|
1522
1840
|
}
|
|
1523
1841
|
}
|
|
@@ -1571,7 +1889,7 @@ class BaseService {
|
|
|
1571
1889
|
data: dataClass,
|
|
1572
1890
|
error: data.error,
|
|
1573
1891
|
error_code: data ? data.error_code : response.status,
|
|
1574
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1892
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1575
1893
|
};
|
|
1576
1894
|
}
|
|
1577
1895
|
catch (error) {
|
|
@@ -1580,7 +1898,7 @@ class BaseService {
|
|
|
1580
1898
|
data: null,
|
|
1581
1899
|
error: true,
|
|
1582
1900
|
error_code: data ? data.error_code : response.status,
|
|
1583
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1901
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1584
1902
|
};
|
|
1585
1903
|
}
|
|
1586
1904
|
}
|
|
@@ -1640,7 +1958,7 @@ class BaseService {
|
|
|
1640
1958
|
data: dataClass,
|
|
1641
1959
|
error: data.error,
|
|
1642
1960
|
error_code: data ? data.error_code : response.status,
|
|
1643
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1961
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1644
1962
|
};
|
|
1645
1963
|
}
|
|
1646
1964
|
catch (error) {
|
|
@@ -1649,7 +1967,7 @@ class BaseService {
|
|
|
1649
1967
|
data: null,
|
|
1650
1968
|
error: true,
|
|
1651
1969
|
error_code: data ? data.error_code : response.status,
|
|
1652
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1970
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1653
1971
|
};
|
|
1654
1972
|
}
|
|
1655
1973
|
}
|
|
@@ -1905,6 +2223,62 @@ class NftOwnershipForCollectionItem {
|
|
|
1905
2223
|
this.nft_data = data.nft_data && data.nft_data !== null ? new NftData(data.nft_data) : null;
|
|
1906
2224
|
}
|
|
1907
2225
|
}
|
|
2226
|
+
class NftMarketSaleCountResponse {
|
|
2227
|
+
constructor(data) {
|
|
2228
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
2229
|
+
this.address = data.address;
|
|
2230
|
+
this.quote_currency = data.quote_currency;
|
|
2231
|
+
this.chain_name = data.chain_name;
|
|
2232
|
+
this.chain_id = data.chain_id;
|
|
2233
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketSaleCountItem(itemData)) : null;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
class MarketSaleCountItem {
|
|
2237
|
+
constructor(data) {
|
|
2238
|
+
this.date = data.date && data.date !== null ? dateFns.parseISO(data.date.toString()) : null;
|
|
2239
|
+
this.sale_count = data.sale_count;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
class NftMarketVolumeResponse {
|
|
2243
|
+
constructor(data) {
|
|
2244
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
2245
|
+
this.address = data.address;
|
|
2246
|
+
this.quote_currency = data.quote_currency;
|
|
2247
|
+
this.chain_name = data.chain_name;
|
|
2248
|
+
this.chain_id = data.chain_id;
|
|
2249
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketVolumeItem(itemData)) : null;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
class MarketVolumeItem {
|
|
2253
|
+
constructor(data) {
|
|
2254
|
+
this.date = data.date && data.date !== null ? dateFns.parseISO(data.date.toString()) : null;
|
|
2255
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
2256
|
+
this.native_name = data.native_name;
|
|
2257
|
+
this.volume_quote = data.volume_quote;
|
|
2258
|
+
this.volume_native_quote = data.volume_native_quote;
|
|
2259
|
+
this.pretty_volume_quote = data.pretty_volume_quote;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
class NftMarketFloorPriceResponse {
|
|
2263
|
+
constructor(data) {
|
|
2264
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
2265
|
+
this.address = data.address;
|
|
2266
|
+
this.quote_currency = data.quote_currency;
|
|
2267
|
+
this.chain_name = data.chain_name;
|
|
2268
|
+
this.chain_id = data.chain_id;
|
|
2269
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketFloorPriceItem(itemData)) : null;
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
class MarketFloorPriceItem {
|
|
2273
|
+
constructor(data) {
|
|
2274
|
+
this.date = data.date && data.date !== null ? dateFns.parseISO(data.date.toString()) : null;
|
|
2275
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
2276
|
+
this.native_name = data.native_name;
|
|
2277
|
+
this.floor_price_native_quote = data.floor_price_native_quote;
|
|
2278
|
+
this.floor_price_quote = data.floor_price_quote;
|
|
2279
|
+
this.pretty_floor_price_quote = data.pretty_floor_price_quote;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
1908
2282
|
/**
|
|
1909
2283
|
* NFT APIs
|
|
1910
2284
|
*
|
|
@@ -1973,20 +2347,281 @@ class NftService {
|
|
|
1973
2347
|
while (!success) {
|
|
1974
2348
|
try {
|
|
1975
2349
|
const urlParams = new URLSearchParams();
|
|
1976
|
-
if (queryParamOpts?.noSpam !== undefined) {
|
|
1977
|
-
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
1978
|
-
}
|
|
1979
|
-
if (queryParamOpts?.noNftAssetMetadata !== undefined) {
|
|
1980
|
-
urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
|
|
1981
|
-
}
|
|
1982
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
1983
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
1984
|
-
}
|
|
2350
|
+
if (queryParamOpts?.noSpam !== undefined) {
|
|
2351
|
+
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2352
|
+
}
|
|
2353
|
+
if (queryParamOpts?.noNftAssetMetadata !== undefined) {
|
|
2354
|
+
urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
|
|
2355
|
+
}
|
|
2356
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2357
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2358
|
+
}
|
|
2359
|
+
let startTime;
|
|
2360
|
+
if (this.debug) {
|
|
2361
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2362
|
+
}
|
|
2363
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
|
|
2364
|
+
headers: {
|
|
2365
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2366
|
+
"X-Requested-With": userAgent
|
|
2367
|
+
}
|
|
2368
|
+
}));
|
|
2369
|
+
debugOutput(response.url, response.status, startTime);
|
|
2370
|
+
if (response.status === 429) {
|
|
2371
|
+
try {
|
|
2372
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2373
|
+
}
|
|
2374
|
+
catch (error) {
|
|
2375
|
+
success = true;
|
|
2376
|
+
return {
|
|
2377
|
+
data: null,
|
|
2378
|
+
error: true,
|
|
2379
|
+
error_code: response.status,
|
|
2380
|
+
error_message: error.message
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
else {
|
|
2385
|
+
data = await response.json();
|
|
2386
|
+
}
|
|
2387
|
+
const dataClass = new NftAddressBalanceNftResponse(data.data);
|
|
2388
|
+
checkAndModifyResponse(dataClass);
|
|
2389
|
+
success = true;
|
|
2390
|
+
return {
|
|
2391
|
+
data: dataClass,
|
|
2392
|
+
error: data.error,
|
|
2393
|
+
error_code: data ? data.error_code : response.status,
|
|
2394
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2395
|
+
};
|
|
2396
|
+
}
|
|
2397
|
+
catch (error) {
|
|
2398
|
+
success = true;
|
|
2399
|
+
return {
|
|
2400
|
+
data: null,
|
|
2401
|
+
error: true,
|
|
2402
|
+
error_code: data ? data.error_code : response.status,
|
|
2403
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
/**
|
|
2409
|
+
*
|
|
2410
|
+
* Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
|
|
2411
|
+
*
|
|
2412
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2413
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2414
|
+
* @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
|
|
2415
|
+
* - `noMetadata`: Omit metadata.
|
|
2416
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2417
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2418
|
+
* - `traitsFilter`: Filters NFTs based on a specific trait. If this filter is used, the API will return all NFTs with the specified trait. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
|
|
2419
|
+
* - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
|
|
2420
|
+
* - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
|
|
2421
|
+
*
|
|
2422
|
+
*/
|
|
2423
|
+
async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
|
|
2424
|
+
let success = false;
|
|
2425
|
+
let res;
|
|
2426
|
+
while (!success) {
|
|
2427
|
+
try {
|
|
2428
|
+
const urlParams = new URLSearchParams();
|
|
2429
|
+
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2430
|
+
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2431
|
+
}
|
|
2432
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
2433
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2434
|
+
}
|
|
2435
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2436
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2437
|
+
}
|
|
2438
|
+
if (queryParamOpts?.traitsFilter !== undefined) {
|
|
2439
|
+
urlParams.append("traits-filter", queryParamOpts?.traitsFilter.toString());
|
|
2440
|
+
}
|
|
2441
|
+
if (queryParamOpts?.valuesFilter !== undefined) {
|
|
2442
|
+
urlParams.append("values-filter", queryParamOpts?.valuesFilter.toString());
|
|
2443
|
+
}
|
|
2444
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2445
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2446
|
+
}
|
|
2447
|
+
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount)) {
|
|
2448
|
+
yield res;
|
|
2449
|
+
}
|
|
2450
|
+
success = true;
|
|
2451
|
+
}
|
|
2452
|
+
catch (error) {
|
|
2453
|
+
success = true;
|
|
2454
|
+
throw new Error(error.message);
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
*
|
|
2460
|
+
* Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
|
|
2461
|
+
*
|
|
2462
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2463
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2464
|
+
* @param {string} tokenId - The requested token ID.
|
|
2465
|
+
* @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
|
|
2466
|
+
* - `noMetadata`: Omit metadata.
|
|
2467
|
+
* - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
|
|
2468
|
+
*
|
|
2469
|
+
*/
|
|
2470
|
+
async getNftMetadataForGivenTokenIdForContract(chainName, contractAddress, tokenId, queryParamOpts) {
|
|
2471
|
+
let success = false;
|
|
2472
|
+
let data;
|
|
2473
|
+
let response;
|
|
2474
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2475
|
+
while (!success) {
|
|
2476
|
+
try {
|
|
2477
|
+
const urlParams = new URLSearchParams();
|
|
2478
|
+
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2479
|
+
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2480
|
+
}
|
|
2481
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2482
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2483
|
+
}
|
|
2484
|
+
let startTime;
|
|
2485
|
+
if (this.debug) {
|
|
2486
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2487
|
+
}
|
|
2488
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
|
|
2489
|
+
headers: {
|
|
2490
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2491
|
+
"X-Requested-With": userAgent
|
|
2492
|
+
}
|
|
2493
|
+
}));
|
|
2494
|
+
debugOutput(response.url, response.status, startTime);
|
|
2495
|
+
if (response.status === 429) {
|
|
2496
|
+
try {
|
|
2497
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2498
|
+
}
|
|
2499
|
+
catch (error) {
|
|
2500
|
+
success = true;
|
|
2501
|
+
return {
|
|
2502
|
+
data: null,
|
|
2503
|
+
error: true,
|
|
2504
|
+
error_code: response.status,
|
|
2505
|
+
error_message: error.message
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
else {
|
|
2510
|
+
data = await response.json();
|
|
2511
|
+
}
|
|
2512
|
+
const dataClass = new NftMetadataResponse(data.data);
|
|
2513
|
+
checkAndModifyResponse(dataClass);
|
|
2514
|
+
success = true;
|
|
2515
|
+
return {
|
|
2516
|
+
data: dataClass,
|
|
2517
|
+
error: data.error,
|
|
2518
|
+
error_code: data ? data.error_code : response.status,
|
|
2519
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
catch (error) {
|
|
2523
|
+
success = true;
|
|
2524
|
+
return {
|
|
2525
|
+
data: null,
|
|
2526
|
+
error: true,
|
|
2527
|
+
error_code: data ? data.error_code : response.status,
|
|
2528
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2529
|
+
};
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
*
|
|
2535
|
+
* Commonly used to get all transactions of an NFT token. Useful for building a transaction history table or price chart.
|
|
2536
|
+
*
|
|
2537
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2538
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2539
|
+
* @param {string} tokenId - The requested token ID.
|
|
2540
|
+
* @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
|
|
2541
|
+
* - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
2542
|
+
*
|
|
2543
|
+
*/
|
|
2544
|
+
async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, queryParamOpts) {
|
|
2545
|
+
let success = false;
|
|
2546
|
+
let data;
|
|
2547
|
+
let response;
|
|
2548
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2549
|
+
while (!success) {
|
|
2550
|
+
try {
|
|
2551
|
+
const urlParams = new URLSearchParams();
|
|
2552
|
+
if (queryParamOpts?.noSpam !== undefined) {
|
|
2553
|
+
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2554
|
+
}
|
|
2555
|
+
let startTime;
|
|
2556
|
+
if (this.debug) {
|
|
2557
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2558
|
+
}
|
|
2559
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
|
|
2560
|
+
headers: {
|
|
2561
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2562
|
+
"X-Requested-With": userAgent
|
|
2563
|
+
}
|
|
2564
|
+
}));
|
|
2565
|
+
debugOutput(response.url, response.status, startTime);
|
|
2566
|
+
if (response.status === 429) {
|
|
2567
|
+
try {
|
|
2568
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2569
|
+
}
|
|
2570
|
+
catch (error) {
|
|
2571
|
+
success = true;
|
|
2572
|
+
return {
|
|
2573
|
+
data: null,
|
|
2574
|
+
error: true,
|
|
2575
|
+
error_code: response.status,
|
|
2576
|
+
error_message: error.message
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
else {
|
|
2581
|
+
data = await response.json();
|
|
2582
|
+
}
|
|
2583
|
+
const dataClass = new NftTransactionsResponse(data.data);
|
|
2584
|
+
checkAndModifyResponse(dataClass);
|
|
2585
|
+
success = true;
|
|
2586
|
+
return {
|
|
2587
|
+
data: dataClass,
|
|
2588
|
+
error: data.error,
|
|
2589
|
+
error_code: data ? data.error_code : response.status,
|
|
2590
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
catch (error) {
|
|
2594
|
+
success = true;
|
|
2595
|
+
return {
|
|
2596
|
+
data: null,
|
|
2597
|
+
error: true,
|
|
2598
|
+
error_code: data ? data.error_code : response.status,
|
|
2599
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2605
|
+
*
|
|
2606
|
+
* Commonly used to fetch and render the traits of a collection as seen in rarity calculators.
|
|
2607
|
+
*
|
|
2608
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2609
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2610
|
+
*
|
|
2611
|
+
*/
|
|
2612
|
+
async getTraitsForCollection(chainName, collectionContract) {
|
|
2613
|
+
let success = false;
|
|
2614
|
+
let data;
|
|
2615
|
+
let response;
|
|
2616
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2617
|
+
while (!success) {
|
|
2618
|
+
try {
|
|
2619
|
+
const urlParams = new URLSearchParams();
|
|
1985
2620
|
let startTime;
|
|
1986
2621
|
if (this.debug) {
|
|
1987
2622
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1988
2623
|
}
|
|
1989
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2624
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
|
|
1990
2625
|
headers: {
|
|
1991
2626
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
1992
2627
|
"X-Requested-With": userAgent
|
|
@@ -2010,14 +2645,14 @@ class NftService {
|
|
|
2010
2645
|
else {
|
|
2011
2646
|
data = await response.json();
|
|
2012
2647
|
}
|
|
2013
|
-
const dataClass = new
|
|
2648
|
+
const dataClass = new NftCollectionTraitsResponse(data.data);
|
|
2014
2649
|
checkAndModifyResponse(dataClass);
|
|
2015
2650
|
success = true;
|
|
2016
2651
|
return {
|
|
2017
2652
|
data: dataClass,
|
|
2018
2653
|
error: data.error,
|
|
2019
2654
|
error_code: data ? data.error_code : response.status,
|
|
2020
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2655
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2021
2656
|
};
|
|
2022
2657
|
}
|
|
2023
2658
|
catch (error) {
|
|
@@ -2026,74 +2661,21 @@ class NftService {
|
|
|
2026
2661
|
data: null,
|
|
2027
2662
|
error: true,
|
|
2028
2663
|
error_code: data ? data.error_code : response.status,
|
|
2029
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2664
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2030
2665
|
};
|
|
2031
2666
|
}
|
|
2032
2667
|
}
|
|
2033
2668
|
}
|
|
2034
2669
|
/**
|
|
2035
2670
|
*
|
|
2036
|
-
* Commonly used to get
|
|
2037
|
-
*
|
|
2038
|
-
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2039
|
-
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2040
|
-
* @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
|
|
2041
|
-
* - `noMetadata`: Omit metadata.
|
|
2042
|
-
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2043
|
-
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2044
|
-
* - `traitsFilter`: Filters NFTs based on a specific trait. If this filter is used, the API will return all NFTs with the specified trait. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
|
|
2045
|
-
* - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
|
|
2046
|
-
* - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
|
|
2047
|
-
*
|
|
2048
|
-
*/
|
|
2049
|
-
async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
|
|
2050
|
-
let success = false;
|
|
2051
|
-
let res;
|
|
2052
|
-
while (!success) {
|
|
2053
|
-
try {
|
|
2054
|
-
const urlParams = new URLSearchParams();
|
|
2055
|
-
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2056
|
-
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2057
|
-
}
|
|
2058
|
-
if (queryParamOpts?.pageSize !== undefined) {
|
|
2059
|
-
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2060
|
-
}
|
|
2061
|
-
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2062
|
-
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2063
|
-
}
|
|
2064
|
-
if (queryParamOpts?.traitsFilter !== undefined) {
|
|
2065
|
-
urlParams.append("traits-filter", queryParamOpts?.traitsFilter.toString());
|
|
2066
|
-
}
|
|
2067
|
-
if (queryParamOpts?.valuesFilter !== undefined) {
|
|
2068
|
-
urlParams.append("values-filter", queryParamOpts?.valuesFilter.toString());
|
|
2069
|
-
}
|
|
2070
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
2071
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2072
|
-
}
|
|
2073
|
-
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount)) {
|
|
2074
|
-
yield res;
|
|
2075
|
-
}
|
|
2076
|
-
success = true;
|
|
2077
|
-
}
|
|
2078
|
-
catch (error) {
|
|
2079
|
-
success = true;
|
|
2080
|
-
throw new Error(error.message);
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
*
|
|
2086
|
-
* Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
|
|
2671
|
+
* Commonly used to get the count of unique values for traits within an NFT collection.
|
|
2087
2672
|
*
|
|
2088
2673
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2089
|
-
* @param {string}
|
|
2090
|
-
* @param {string}
|
|
2091
|
-
* @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
|
|
2092
|
-
* - `noMetadata`: Omit metadata.
|
|
2093
|
-
* - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
|
|
2674
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2675
|
+
* @param {string} trait - The requested trait.
|
|
2094
2676
|
*
|
|
2095
2677
|
*/
|
|
2096
|
-
async
|
|
2678
|
+
async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
|
|
2097
2679
|
let success = false;
|
|
2098
2680
|
let data;
|
|
2099
2681
|
let response;
|
|
@@ -2101,17 +2683,11 @@ class NftService {
|
|
|
2101
2683
|
while (!success) {
|
|
2102
2684
|
try {
|
|
2103
2685
|
const urlParams = new URLSearchParams();
|
|
2104
|
-
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2105
|
-
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2106
|
-
}
|
|
2107
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
2108
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2109
|
-
}
|
|
2110
2686
|
let startTime;
|
|
2111
2687
|
if (this.debug) {
|
|
2112
2688
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2113
2689
|
}
|
|
2114
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${
|
|
2690
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
|
|
2115
2691
|
headers: {
|
|
2116
2692
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2117
2693
|
"X-Requested-With": userAgent
|
|
@@ -2135,14 +2711,14 @@ class NftService {
|
|
|
2135
2711
|
else {
|
|
2136
2712
|
data = await response.json();
|
|
2137
2713
|
}
|
|
2138
|
-
const dataClass = new
|
|
2714
|
+
const dataClass = new NftCollectionAttributesForTraitResponse(data.data);
|
|
2139
2715
|
checkAndModifyResponse(dataClass);
|
|
2140
2716
|
success = true;
|
|
2141
2717
|
return {
|
|
2142
2718
|
data: dataClass,
|
|
2143
2719
|
error: data.error,
|
|
2144
2720
|
error_code: data ? data.error_code : response.status,
|
|
2145
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2721
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2146
2722
|
};
|
|
2147
2723
|
}
|
|
2148
2724
|
catch (error) {
|
|
@@ -2151,23 +2727,20 @@ class NftService {
|
|
|
2151
2727
|
data: null,
|
|
2152
2728
|
error: true,
|
|
2153
2729
|
error_code: data ? data.error_code : response.status,
|
|
2154
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2730
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2155
2731
|
};
|
|
2156
2732
|
}
|
|
2157
2733
|
}
|
|
2158
2734
|
}
|
|
2159
2735
|
/**
|
|
2160
2736
|
*
|
|
2161
|
-
* Commonly used to
|
|
2737
|
+
* Commonly used to calculate rarity scores for a collection based on its traits.
|
|
2162
2738
|
*
|
|
2163
2739
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2164
|
-
* @param {string}
|
|
2165
|
-
* @param {string} tokenId - The requested token ID.
|
|
2166
|
-
* @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
|
|
2167
|
-
* - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
2740
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2168
2741
|
*
|
|
2169
2742
|
*/
|
|
2170
|
-
async
|
|
2743
|
+
async getCollectionTraitsSummary(chainName, collectionContract) {
|
|
2171
2744
|
let success = false;
|
|
2172
2745
|
let data;
|
|
2173
2746
|
let response;
|
|
@@ -2175,14 +2748,11 @@ class NftService {
|
|
|
2175
2748
|
while (!success) {
|
|
2176
2749
|
try {
|
|
2177
2750
|
const urlParams = new URLSearchParams();
|
|
2178
|
-
if (queryParamOpts?.noSpam !== undefined) {
|
|
2179
|
-
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2180
|
-
}
|
|
2181
2751
|
let startTime;
|
|
2182
2752
|
if (this.debug) {
|
|
2183
2753
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2184
2754
|
}
|
|
2185
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2755
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
|
|
2186
2756
|
headers: {
|
|
2187
2757
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2188
2758
|
"X-Requested-With": userAgent
|
|
@@ -2206,14 +2776,14 @@ class NftService {
|
|
|
2206
2776
|
else {
|
|
2207
2777
|
data = await response.json();
|
|
2208
2778
|
}
|
|
2209
|
-
const dataClass = new
|
|
2779
|
+
const dataClass = new NftCollectionTraitSummaryResponse(data.data);
|
|
2210
2780
|
checkAndModifyResponse(dataClass);
|
|
2211
2781
|
success = true;
|
|
2212
2782
|
return {
|
|
2213
2783
|
data: dataClass,
|
|
2214
2784
|
error: data.error,
|
|
2215
2785
|
error_code: data ? data.error_code : response.status,
|
|
2216
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2786
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2217
2787
|
};
|
|
2218
2788
|
}
|
|
2219
2789
|
catch (error) {
|
|
@@ -2222,20 +2792,21 @@ class NftService {
|
|
|
2222
2792
|
data: null,
|
|
2223
2793
|
error: true,
|
|
2224
2794
|
error_code: data ? data.error_code : response.status,
|
|
2225
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2795
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2226
2796
|
};
|
|
2227
2797
|
}
|
|
2228
2798
|
}
|
|
2229
2799
|
}
|
|
2230
2800
|
/**
|
|
2231
2801
|
*
|
|
2232
|
-
* Commonly used to
|
|
2802
|
+
* Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
|
|
2233
2803
|
*
|
|
2234
2804
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2235
|
-
* @param {string}
|
|
2805
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2806
|
+
* @param {string} collectionContract - The requested collection address.
|
|
2236
2807
|
*
|
|
2237
2808
|
*/
|
|
2238
|
-
async
|
|
2809
|
+
async checkOwnershipInNft(chainName, walletAddress, collectionContract) {
|
|
2239
2810
|
let success = false;
|
|
2240
2811
|
let data;
|
|
2241
2812
|
let response;
|
|
@@ -2247,7 +2818,7 @@ class NftService {
|
|
|
2247
2818
|
if (this.debug) {
|
|
2248
2819
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2249
2820
|
}
|
|
2250
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2821
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
|
|
2251
2822
|
headers: {
|
|
2252
2823
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2253
2824
|
"X-Requested-With": userAgent
|
|
@@ -2271,14 +2842,14 @@ class NftService {
|
|
|
2271
2842
|
else {
|
|
2272
2843
|
data = await response.json();
|
|
2273
2844
|
}
|
|
2274
|
-
const dataClass = new
|
|
2845
|
+
const dataClass = new NftOwnershipForCollectionResponse(data.data);
|
|
2275
2846
|
checkAndModifyResponse(dataClass);
|
|
2276
2847
|
success = true;
|
|
2277
2848
|
return {
|
|
2278
2849
|
data: dataClass,
|
|
2279
2850
|
error: data.error,
|
|
2280
2851
|
error_code: data ? data.error_code : response.status,
|
|
2281
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2852
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2282
2853
|
};
|
|
2283
2854
|
}
|
|
2284
2855
|
catch (error) {
|
|
@@ -2287,21 +2858,22 @@ class NftService {
|
|
|
2287
2858
|
data: null,
|
|
2288
2859
|
error: true,
|
|
2289
2860
|
error_code: data ? data.error_code : response.status,
|
|
2290
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2861
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2291
2862
|
};
|
|
2292
2863
|
}
|
|
2293
2864
|
}
|
|
2294
2865
|
}
|
|
2295
2866
|
/**
|
|
2296
2867
|
*
|
|
2297
|
-
* Commonly used to
|
|
2868
|
+
* Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
|
|
2298
2869
|
*
|
|
2299
2870
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2871
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2300
2872
|
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2301
|
-
* @param {string}
|
|
2873
|
+
* @param {string} tokenId - The requested token ID.
|
|
2302
2874
|
*
|
|
2303
2875
|
*/
|
|
2304
|
-
async
|
|
2876
|
+
async checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) {
|
|
2305
2877
|
let success = false;
|
|
2306
2878
|
let data;
|
|
2307
2879
|
let response;
|
|
@@ -2313,7 +2885,7 @@ class NftService {
|
|
|
2313
2885
|
if (this.debug) {
|
|
2314
2886
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2315
2887
|
}
|
|
2316
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2888
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
|
|
2317
2889
|
headers: {
|
|
2318
2890
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2319
2891
|
"X-Requested-With": userAgent
|
|
@@ -2337,14 +2909,14 @@ class NftService {
|
|
|
2337
2909
|
else {
|
|
2338
2910
|
data = await response.json();
|
|
2339
2911
|
}
|
|
2340
|
-
const dataClass = new
|
|
2912
|
+
const dataClass = new NftOwnershipForCollectionResponse(data.data);
|
|
2341
2913
|
checkAndModifyResponse(dataClass);
|
|
2342
2914
|
success = true;
|
|
2343
2915
|
return {
|
|
2344
2916
|
data: dataClass,
|
|
2345
2917
|
error: data.error,
|
|
2346
2918
|
error_code: data ? data.error_code : response.status,
|
|
2347
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2919
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2348
2920
|
};
|
|
2349
2921
|
}
|
|
2350
2922
|
catch (error) {
|
|
@@ -2353,20 +2925,23 @@ class NftService {
|
|
|
2353
2925
|
data: null,
|
|
2354
2926
|
error: true,
|
|
2355
2927
|
error_code: data ? data.error_code : response.status,
|
|
2356
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2928
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2357
2929
|
};
|
|
2358
2930
|
}
|
|
2359
2931
|
}
|
|
2360
2932
|
}
|
|
2361
2933
|
/**
|
|
2362
2934
|
*
|
|
2363
|
-
* Commonly used to
|
|
2935
|
+
* Commonly used to build a time-series chart of the sales count of an NFT collection.
|
|
2364
2936
|
*
|
|
2365
2937
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2366
|
-
* @param {string}
|
|
2938
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2939
|
+
* @param {GetNftMarketSaleCountQueryParamOpts} queryParamOpts
|
|
2940
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
2941
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2367
2942
|
*
|
|
2368
2943
|
*/
|
|
2369
|
-
async
|
|
2944
|
+
async getNftMarketSaleCount(chainName, contractAddress, queryParamOpts) {
|
|
2370
2945
|
let success = false;
|
|
2371
2946
|
let data;
|
|
2372
2947
|
let response;
|
|
@@ -2374,11 +2949,17 @@ class NftService {
|
|
|
2374
2949
|
while (!success) {
|
|
2375
2950
|
try {
|
|
2376
2951
|
const urlParams = new URLSearchParams();
|
|
2952
|
+
if (queryParamOpts?.days !== undefined) {
|
|
2953
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
2954
|
+
}
|
|
2955
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
2956
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
2957
|
+
}
|
|
2377
2958
|
let startTime;
|
|
2378
2959
|
if (this.debug) {
|
|
2379
2960
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2380
2961
|
}
|
|
2381
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2962
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`, {
|
|
2382
2963
|
headers: {
|
|
2383
2964
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2384
2965
|
"X-Requested-With": userAgent
|
|
@@ -2402,14 +2983,14 @@ class NftService {
|
|
|
2402
2983
|
else {
|
|
2403
2984
|
data = await response.json();
|
|
2404
2985
|
}
|
|
2405
|
-
const dataClass = new
|
|
2986
|
+
const dataClass = new NftMarketSaleCountResponse(data.data);
|
|
2406
2987
|
checkAndModifyResponse(dataClass);
|
|
2407
2988
|
success = true;
|
|
2408
2989
|
return {
|
|
2409
2990
|
data: dataClass,
|
|
2410
2991
|
error: data.error,
|
|
2411
2992
|
error_code: data ? data.error_code : response.status,
|
|
2412
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2993
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2413
2994
|
};
|
|
2414
2995
|
}
|
|
2415
2996
|
catch (error) {
|
|
@@ -2418,21 +2999,23 @@ class NftService {
|
|
|
2418
2999
|
data: null,
|
|
2419
3000
|
error: true,
|
|
2420
3001
|
error_code: data ? data.error_code : response.status,
|
|
2421
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3002
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2422
3003
|
};
|
|
2423
3004
|
}
|
|
2424
3005
|
}
|
|
2425
3006
|
}
|
|
2426
3007
|
/**
|
|
2427
3008
|
*
|
|
2428
|
-
* Commonly used to
|
|
3009
|
+
* Commonly used to build a time-series chart of the transaction volume of an NFT collection.
|
|
2429
3010
|
*
|
|
2430
3011
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2431
|
-
* @param {string}
|
|
2432
|
-
* @param {
|
|
3012
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3013
|
+
* @param {GetNftMarketVolumeQueryParamOpts} queryParamOpts
|
|
3014
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
3015
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2433
3016
|
*
|
|
2434
3017
|
*/
|
|
2435
|
-
async
|
|
3018
|
+
async getNftMarketVolume(chainName, contractAddress, queryParamOpts) {
|
|
2436
3019
|
let success = false;
|
|
2437
3020
|
let data;
|
|
2438
3021
|
let response;
|
|
@@ -2440,11 +3023,17 @@ class NftService {
|
|
|
2440
3023
|
while (!success) {
|
|
2441
3024
|
try {
|
|
2442
3025
|
const urlParams = new URLSearchParams();
|
|
3026
|
+
if (queryParamOpts?.days !== undefined) {
|
|
3027
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3028
|
+
}
|
|
3029
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3030
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3031
|
+
}
|
|
2443
3032
|
let startTime;
|
|
2444
3033
|
if (this.debug) {
|
|
2445
3034
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2446
3035
|
}
|
|
2447
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
3036
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`, {
|
|
2448
3037
|
headers: {
|
|
2449
3038
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2450
3039
|
"X-Requested-With": userAgent
|
|
@@ -2468,14 +3057,14 @@ class NftService {
|
|
|
2468
3057
|
else {
|
|
2469
3058
|
data = await response.json();
|
|
2470
3059
|
}
|
|
2471
|
-
const dataClass = new
|
|
3060
|
+
const dataClass = new NftMarketVolumeResponse(data.data);
|
|
2472
3061
|
checkAndModifyResponse(dataClass);
|
|
2473
3062
|
success = true;
|
|
2474
3063
|
return {
|
|
2475
3064
|
data: dataClass,
|
|
2476
3065
|
error: data.error,
|
|
2477
3066
|
error_code: data ? data.error_code : response.status,
|
|
2478
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3067
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2479
3068
|
};
|
|
2480
3069
|
}
|
|
2481
3070
|
catch (error) {
|
|
@@ -2484,22 +3073,23 @@ class NftService {
|
|
|
2484
3073
|
data: null,
|
|
2485
3074
|
error: true,
|
|
2486
3075
|
error_code: data ? data.error_code : response.status,
|
|
2487
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3076
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2488
3077
|
};
|
|
2489
3078
|
}
|
|
2490
3079
|
}
|
|
2491
3080
|
}
|
|
2492
3081
|
/**
|
|
2493
3082
|
*
|
|
2494
|
-
* Commonly used to
|
|
3083
|
+
* Commonly used to render a price floor chart for an NFT collection.
|
|
2495
3084
|
*
|
|
2496
3085
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2497
|
-
* @param {string}
|
|
2498
|
-
* @param {
|
|
2499
|
-
*
|
|
3086
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3087
|
+
* @param {GetNftMarketFloorPriceQueryParamOpts} queryParamOpts
|
|
3088
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
3089
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2500
3090
|
*
|
|
2501
3091
|
*/
|
|
2502
|
-
async
|
|
3092
|
+
async getNftMarketFloorPrice(chainName, contractAddress, queryParamOpts) {
|
|
2503
3093
|
let success = false;
|
|
2504
3094
|
let data;
|
|
2505
3095
|
let response;
|
|
@@ -2507,11 +3097,17 @@ class NftService {
|
|
|
2507
3097
|
while (!success) {
|
|
2508
3098
|
try {
|
|
2509
3099
|
const urlParams = new URLSearchParams();
|
|
3100
|
+
if (queryParamOpts?.days !== undefined) {
|
|
3101
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3102
|
+
}
|
|
3103
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3104
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3105
|
+
}
|
|
2510
3106
|
let startTime;
|
|
2511
3107
|
if (this.debug) {
|
|
2512
3108
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2513
3109
|
}
|
|
2514
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
3110
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`, {
|
|
2515
3111
|
headers: {
|
|
2516
3112
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2517
3113
|
"X-Requested-With": userAgent
|
|
@@ -2535,14 +3131,14 @@ class NftService {
|
|
|
2535
3131
|
else {
|
|
2536
3132
|
data = await response.json();
|
|
2537
3133
|
}
|
|
2538
|
-
const dataClass = new
|
|
3134
|
+
const dataClass = new NftMarketFloorPriceResponse(data.data);
|
|
2539
3135
|
checkAndModifyResponse(dataClass);
|
|
2540
3136
|
success = true;
|
|
2541
3137
|
return {
|
|
2542
3138
|
data: dataClass,
|
|
2543
3139
|
error: data.error,
|
|
2544
3140
|
error_code: data ? data.error_code : response.status,
|
|
2545
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3141
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2546
3142
|
};
|
|
2547
3143
|
}
|
|
2548
3144
|
catch (error) {
|
|
@@ -2551,7 +3147,7 @@ class NftService {
|
|
|
2551
3147
|
data: null,
|
|
2552
3148
|
error: true,
|
|
2553
3149
|
error_code: data ? data.error_code : response.status,
|
|
2554
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3150
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2555
3151
|
};
|
|
2556
3152
|
}
|
|
2557
3153
|
}
|
|
@@ -2666,7 +3262,7 @@ class PricingService {
|
|
|
2666
3262
|
data: res,
|
|
2667
3263
|
error: data.error,
|
|
2668
3264
|
error_code: data ? data.error_code : response.status,
|
|
2669
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3265
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2670
3266
|
};
|
|
2671
3267
|
}
|
|
2672
3268
|
catch (error) {
|
|
@@ -2675,7 +3271,7 @@ class PricingService {
|
|
|
2675
3271
|
data: null,
|
|
2676
3272
|
error: true,
|
|
2677
3273
|
error_code: data ? data.error_code : response.status,
|
|
2678
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3274
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2679
3275
|
};
|
|
2680
3276
|
}
|
|
2681
3277
|
}
|
|
@@ -2718,6 +3314,7 @@ class Transaction {
|
|
|
2718
3314
|
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? new NftSalesReport(data.nft_sale_details) : null;
|
|
2719
3315
|
this.lending_details = data.lending_details && data.lending_details !== null ? new LendingReport(data.lending_details) : null;
|
|
2720
3316
|
this.log_events = data.log_events && data.log_events !== null ? data.log_events.map((itemData) => new LogEvent(itemData)) : null;
|
|
3317
|
+
this.safe_details = data.safe_details && data.safe_details !== null ? data.safe_details.map((itemData) => new SafeDetails(itemData)) : null;
|
|
2721
3318
|
}
|
|
2722
3319
|
}
|
|
2723
3320
|
class ContractMetadata {
|
|
@@ -2864,6 +3461,13 @@ class LogEvent {
|
|
|
2864
3461
|
this.decoded = data.decoded && data.decoded !== null ? new DecodedItem(data.decoded) : null;
|
|
2865
3462
|
}
|
|
2866
3463
|
}
|
|
3464
|
+
class SafeDetails {
|
|
3465
|
+
constructor(data) {
|
|
3466
|
+
this.owner_address = data.owner_address;
|
|
3467
|
+
this.signature = data.signature;
|
|
3468
|
+
this.signature_type = data.signature_type;
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
2867
3471
|
class DecodedItem {
|
|
2868
3472
|
constructor(data) {
|
|
2869
3473
|
this.name = data.name;
|
|
@@ -2880,6 +3484,12 @@ class Param {
|
|
|
2880
3484
|
this.value = data.value;
|
|
2881
3485
|
}
|
|
2882
3486
|
}
|
|
3487
|
+
class PaginationLinks {
|
|
3488
|
+
constructor(data) {
|
|
3489
|
+
this.prev = data.prev;
|
|
3490
|
+
this.next = data.next;
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
2883
3493
|
class TransactionsBlockResponse {
|
|
2884
3494
|
constructor(data) {
|
|
2885
3495
|
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
@@ -2911,6 +3521,18 @@ class TransactionSummary {
|
|
|
2911
3521
|
this.tx_detail_link = data.tx_detail_link;
|
|
2912
3522
|
}
|
|
2913
3523
|
}
|
|
3524
|
+
class TransactionsResponse {
|
|
3525
|
+
constructor(data) {
|
|
3526
|
+
this.address = data.address;
|
|
3527
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
3528
|
+
this.quote_currency = data.quote_currency;
|
|
3529
|
+
this.chain_id = data.chain_id;
|
|
3530
|
+
this.chain_name = data.chain_name;
|
|
3531
|
+
this.current_page = data.current_page;
|
|
3532
|
+
this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
|
|
3533
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
2914
3536
|
/**
|
|
2915
3537
|
* Transactions APIs
|
|
2916
3538
|
*
|
|
@@ -2967,7 +3589,7 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
2967
3589
|
if (error.message.includes("An error occurred 429")) {
|
|
2968
3590
|
throw new Error(error.message);
|
|
2969
3591
|
}
|
|
2970
|
-
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : "401 Authorization Required"}`);
|
|
3592
|
+
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"}`);
|
|
2971
3593
|
}
|
|
2972
3594
|
}
|
|
2973
3595
|
}
|
|
@@ -2990,6 +3612,7 @@ class TransactionService {
|
|
|
2990
3612
|
* - `withDex`: Decoded DEX details including protocol (e.g. Uniswap), event (e.g 'add_liquidity') and tokens involved with historical prices. Additional 0.05 credits charged if data available.
|
|
2991
3613
|
* - `withNftSales`: Decoded NFT sales details including marketplace (e.g. Opensea) and cached media links. Additional 0.05 credits charged if data available.
|
|
2992
3614
|
* - `withLending`: Decoded lending details including protocol (e.g. Aave), event (e.g. 'deposit') and tokens involved with prices. Additional 0.05 credits charged if data available.
|
|
3615
|
+
* - `withSafe`: Include safe details.
|
|
2993
3616
|
*
|
|
2994
3617
|
*/
|
|
2995
3618
|
async getTransaction(chainName, txHash, queryParamOpts) {
|
|
@@ -3015,6 +3638,9 @@ class TransactionService {
|
|
|
3015
3638
|
if (queryParamOpts?.withLending !== undefined) {
|
|
3016
3639
|
urlParams.append("with-lending", queryParamOpts?.withLending.toString());
|
|
3017
3640
|
}
|
|
3641
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3642
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3643
|
+
}
|
|
3018
3644
|
let startTime;
|
|
3019
3645
|
if (this.debug) {
|
|
3020
3646
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3050,7 +3676,7 @@ class TransactionService {
|
|
|
3050
3676
|
data: dataClass,
|
|
3051
3677
|
error: data.error,
|
|
3052
3678
|
error_code: data ? data.error_code : response.status,
|
|
3053
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3679
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3054
3680
|
};
|
|
3055
3681
|
}
|
|
3056
3682
|
catch (error) {
|
|
@@ -3059,7 +3685,7 @@ class TransactionService {
|
|
|
3059
3685
|
data: null,
|
|
3060
3686
|
error: true,
|
|
3061
3687
|
error_code: data ? data.error_code : response.status,
|
|
3062
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3688
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3063
3689
|
};
|
|
3064
3690
|
}
|
|
3065
3691
|
}
|
|
@@ -3074,6 +3700,7 @@ class TransactionService {
|
|
|
3074
3700
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
3075
3701
|
* - `noLogs`: Omit log events.
|
|
3076
3702
|
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
3703
|
+
* - `withSafe`: Include safe details.
|
|
3077
3704
|
*
|
|
3078
3705
|
*/
|
|
3079
3706
|
async *getAllTransactionsForAddress(chainName, walletAddress, queryParamOpts) {
|
|
@@ -3091,6 +3718,9 @@ class TransactionService {
|
|
|
3091
3718
|
if (queryParamOpts?.blockSignedAtAsc !== undefined) {
|
|
3092
3719
|
urlParams.append("block-signed-at-asc", queryParamOpts?.blockSignedAtAsc.toString());
|
|
3093
3720
|
}
|
|
3721
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3722
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3723
|
+
}
|
|
3094
3724
|
for await (tx of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams, this.debug, this.threadCount)) {
|
|
3095
3725
|
yield tx;
|
|
3096
3726
|
}
|
|
@@ -3162,7 +3792,7 @@ class TransactionService {
|
|
|
3162
3792
|
data: dataClass,
|
|
3163
3793
|
error: data.error,
|
|
3164
3794
|
error_code: data ? data.error_code : response.status,
|
|
3165
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3795
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3166
3796
|
};
|
|
3167
3797
|
}
|
|
3168
3798
|
catch (error) {
|
|
@@ -3171,7 +3801,7 @@ class TransactionService {
|
|
|
3171
3801
|
data: null,
|
|
3172
3802
|
error: true,
|
|
3173
3803
|
error_code: data ? data.error_code : response.status,
|
|
3174
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3804
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3175
3805
|
};
|
|
3176
3806
|
}
|
|
3177
3807
|
}
|
|
@@ -3227,7 +3857,88 @@ class TransactionService {
|
|
|
3227
3857
|
data: dataClass,
|
|
3228
3858
|
error: data.error,
|
|
3229
3859
|
error_code: data ? data.error_code : response.status,
|
|
3230
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3860
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
catch (error) {
|
|
3864
|
+
success = true;
|
|
3865
|
+
return {
|
|
3866
|
+
data: null,
|
|
3867
|
+
error: true,
|
|
3868
|
+
error_code: data ? data.error_code : response.status,
|
|
3869
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3870
|
+
};
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
/**
|
|
3875
|
+
*
|
|
3876
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
3877
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3878
|
+
* @param {number} page - The requested page, 0-indexed.
|
|
3879
|
+
* @param {GetTransactionsForAddressV3QueryParamOpts} queryParamOpts
|
|
3880
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
3881
|
+
* - `noLogs`: Omit log events.
|
|
3882
|
+
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
3883
|
+
* - `withSafe`: Include safe details.
|
|
3884
|
+
*
|
|
3885
|
+
*/
|
|
3886
|
+
async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
|
|
3887
|
+
let success = false;
|
|
3888
|
+
let data;
|
|
3889
|
+
let response;
|
|
3890
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
3891
|
+
while (!success) {
|
|
3892
|
+
try {
|
|
3893
|
+
const urlParams = new URLSearchParams();
|
|
3894
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3895
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3896
|
+
}
|
|
3897
|
+
if (queryParamOpts?.noLogs !== undefined) {
|
|
3898
|
+
urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
|
|
3899
|
+
}
|
|
3900
|
+
if (queryParamOpts?.blockSignedAtAsc !== undefined) {
|
|
3901
|
+
urlParams.append("block-signed-at-asc", queryParamOpts?.blockSignedAtAsc.toString());
|
|
3902
|
+
}
|
|
3903
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3904
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3905
|
+
}
|
|
3906
|
+
let startTime;
|
|
3907
|
+
if (this.debug) {
|
|
3908
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
3909
|
+
}
|
|
3910
|
+
response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
|
|
3911
|
+
headers: {
|
|
3912
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
3913
|
+
"X-Requested-With": userAgent
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3916
|
+
debugOutput(response.url, response.status, startTime);
|
|
3917
|
+
if (response.status === 429) {
|
|
3918
|
+
try {
|
|
3919
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3920
|
+
}
|
|
3921
|
+
catch (error) {
|
|
3922
|
+
success = true;
|
|
3923
|
+
return {
|
|
3924
|
+
data: null,
|
|
3925
|
+
error: true,
|
|
3926
|
+
error_code: response.status,
|
|
3927
|
+
error_message: error.message
|
|
3928
|
+
};
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
else {
|
|
3932
|
+
data = await response.json();
|
|
3933
|
+
}
|
|
3934
|
+
const dataClass = new TransactionsResponse(data.data);
|
|
3935
|
+
checkAndModifyResponse(dataClass);
|
|
3936
|
+
success = true;
|
|
3937
|
+
return {
|
|
3938
|
+
data: dataClass,
|
|
3939
|
+
error: data.error,
|
|
3940
|
+
error_code: data ? data.error_code : response.status,
|
|
3941
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3231
3942
|
};
|
|
3232
3943
|
}
|
|
3233
3944
|
catch (error) {
|
|
@@ -3236,7 +3947,7 @@ class TransactionService {
|
|
|
3236
3947
|
data: null,
|
|
3237
3948
|
error: true,
|
|
3238
3949
|
error_code: data ? data.error_code : response.status,
|
|
3239
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3950
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3240
3951
|
};
|
|
3241
3952
|
}
|
|
3242
3953
|
}
|
|
@@ -3698,7 +4409,7 @@ class XykService {
|
|
|
3698
4409
|
data: dataClass,
|
|
3699
4410
|
error: data.error,
|
|
3700
4411
|
error_code: data ? data.error_code : response.status,
|
|
3701
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4412
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3702
4413
|
};
|
|
3703
4414
|
}
|
|
3704
4415
|
catch (error) {
|
|
@@ -3707,7 +4418,7 @@ class XykService {
|
|
|
3707
4418
|
data: null,
|
|
3708
4419
|
error: true,
|
|
3709
4420
|
error_code: data ? data.error_code : response.status,
|
|
3710
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4421
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3711
4422
|
};
|
|
3712
4423
|
}
|
|
3713
4424
|
}
|
|
@@ -3763,7 +4474,7 @@ class XykService {
|
|
|
3763
4474
|
data: dataClass,
|
|
3764
4475
|
error: data.error,
|
|
3765
4476
|
error_code: data ? data.error_code : response.status,
|
|
3766
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4477
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3767
4478
|
};
|
|
3768
4479
|
}
|
|
3769
4480
|
catch (error) {
|
|
@@ -3772,7 +4483,7 @@ class XykService {
|
|
|
3772
4483
|
data: null,
|
|
3773
4484
|
error: true,
|
|
3774
4485
|
error_code: data ? data.error_code : response.status,
|
|
3775
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4486
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3776
4487
|
};
|
|
3777
4488
|
}
|
|
3778
4489
|
}
|
|
@@ -3829,7 +4540,7 @@ class XykService {
|
|
|
3829
4540
|
data: dataClass,
|
|
3830
4541
|
error: data.error,
|
|
3831
4542
|
error_code: data ? data.error_code : response.status,
|
|
3832
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4543
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3833
4544
|
};
|
|
3834
4545
|
}
|
|
3835
4546
|
catch (error) {
|
|
@@ -3838,7 +4549,7 @@ class XykService {
|
|
|
3838
4549
|
data: null,
|
|
3839
4550
|
error: true,
|
|
3840
4551
|
error_code: data ? data.error_code : response.status,
|
|
3841
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4552
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3842
4553
|
};
|
|
3843
4554
|
}
|
|
3844
4555
|
}
|
|
@@ -3865,6 +4576,9 @@ class XykService {
|
|
|
3865
4576
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3866
4577
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3867
4578
|
}
|
|
4579
|
+
if (queryParamOpts?.dexName !== undefined) {
|
|
4580
|
+
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
4581
|
+
}
|
|
3868
4582
|
let startTime;
|
|
3869
4583
|
if (this.debug) {
|
|
3870
4584
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3900,7 +4614,7 @@ class XykService {
|
|
|
3900
4614
|
data: dataClass,
|
|
3901
4615
|
error: data.error,
|
|
3902
4616
|
error_code: data ? data.error_code : response.status,
|
|
3903
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4617
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3904
4618
|
};
|
|
3905
4619
|
}
|
|
3906
4620
|
catch (error) {
|
|
@@ -3909,7 +4623,7 @@ class XykService {
|
|
|
3909
4623
|
data: null,
|
|
3910
4624
|
error: true,
|
|
3911
4625
|
error_code: data ? data.error_code : response.status,
|
|
3912
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4626
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3913
4627
|
};
|
|
3914
4628
|
}
|
|
3915
4629
|
}
|
|
@@ -3966,7 +4680,7 @@ class XykService {
|
|
|
3966
4680
|
data: dataClass,
|
|
3967
4681
|
error: data.error,
|
|
3968
4682
|
error_code: data ? data.error_code : response.status,
|
|
3969
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4683
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3970
4684
|
};
|
|
3971
4685
|
}
|
|
3972
4686
|
catch (error) {
|
|
@@ -3975,7 +4689,7 @@ class XykService {
|
|
|
3975
4689
|
data: null,
|
|
3976
4690
|
error: true,
|
|
3977
4691
|
error_code: data ? data.error_code : response.status,
|
|
3978
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4692
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3979
4693
|
};
|
|
3980
4694
|
}
|
|
3981
4695
|
}
|
|
@@ -4006,6 +4720,9 @@ class XykService {
|
|
|
4006
4720
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4007
4721
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4008
4722
|
}
|
|
4723
|
+
if (queryParamOpts?.dexName !== undefined) {
|
|
4724
|
+
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
4725
|
+
}
|
|
4009
4726
|
let startTime;
|
|
4010
4727
|
if (this.debug) {
|
|
4011
4728
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -4041,7 +4758,7 @@ class XykService {
|
|
|
4041
4758
|
data: dataClass,
|
|
4042
4759
|
error: data.error,
|
|
4043
4760
|
error_code: data ? data.error_code : response.status,
|
|
4044
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4761
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4045
4762
|
};
|
|
4046
4763
|
}
|
|
4047
4764
|
catch (error) {
|
|
@@ -4050,7 +4767,7 @@ class XykService {
|
|
|
4050
4767
|
data: null,
|
|
4051
4768
|
error: true,
|
|
4052
4769
|
error_code: data ? data.error_code : response.status,
|
|
4053
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4770
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4054
4771
|
};
|
|
4055
4772
|
}
|
|
4056
4773
|
}
|
|
@@ -4106,7 +4823,7 @@ class XykService {
|
|
|
4106
4823
|
data: dataClass,
|
|
4107
4824
|
error: data.error,
|
|
4108
4825
|
error_code: data ? data.error_code : response.status,
|
|
4109
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4826
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4110
4827
|
};
|
|
4111
4828
|
}
|
|
4112
4829
|
catch (error) {
|
|
@@ -4115,7 +4832,7 @@ class XykService {
|
|
|
4115
4832
|
data: null,
|
|
4116
4833
|
error: true,
|
|
4117
4834
|
error_code: data ? data.error_code : response.status,
|
|
4118
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4835
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4119
4836
|
};
|
|
4120
4837
|
}
|
|
4121
4838
|
}
|
|
@@ -4169,7 +4886,7 @@ class XykService {
|
|
|
4169
4886
|
data: dataClass,
|
|
4170
4887
|
error: data.error,
|
|
4171
4888
|
error_code: data ? data.error_code : response.status,
|
|
4172
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4889
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4173
4890
|
};
|
|
4174
4891
|
}
|
|
4175
4892
|
catch (error) {
|
|
@@ -4178,7 +4895,7 @@ class XykService {
|
|
|
4178
4895
|
data: null,
|
|
4179
4896
|
error: true,
|
|
4180
4897
|
error_code: data ? data.error_code : response.status,
|
|
4181
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4898
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4182
4899
|
};
|
|
4183
4900
|
}
|
|
4184
4901
|
}
|
|
@@ -4235,7 +4952,7 @@ class XykService {
|
|
|
4235
4952
|
data: dataClass,
|
|
4236
4953
|
error: data.error,
|
|
4237
4954
|
error_code: data ? data.error_code : response.status,
|
|
4238
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4955
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4239
4956
|
};
|
|
4240
4957
|
}
|
|
4241
4958
|
catch (error) {
|
|
@@ -4244,7 +4961,7 @@ class XykService {
|
|
|
4244
4961
|
data: null,
|
|
4245
4962
|
error: true,
|
|
4246
4963
|
error_code: data ? data.error_code : response.status,
|
|
4247
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4964
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4248
4965
|
};
|
|
4249
4966
|
}
|
|
4250
4967
|
}
|
|
@@ -4301,7 +5018,7 @@ class XykService {
|
|
|
4301
5018
|
data: dataClass,
|
|
4302
5019
|
error: data.error,
|
|
4303
5020
|
error_code: data ? data.error_code : response.status,
|
|
4304
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5021
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4305
5022
|
};
|
|
4306
5023
|
}
|
|
4307
5024
|
catch (error) {
|
|
@@ -4310,7 +5027,7 @@ class XykService {
|
|
|
4310
5027
|
data: null,
|
|
4311
5028
|
error: true,
|
|
4312
5029
|
error_code: data ? data.error_code : response.status,
|
|
4313
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5030
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4314
5031
|
};
|
|
4315
5032
|
}
|
|
4316
5033
|
}
|
|
@@ -4367,7 +5084,7 @@ class XykService {
|
|
|
4367
5084
|
data: dataClass,
|
|
4368
5085
|
error: data.error,
|
|
4369
5086
|
error_code: data ? data.error_code : response.status,
|
|
4370
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5087
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4371
5088
|
};
|
|
4372
5089
|
}
|
|
4373
5090
|
catch (error) {
|
|
@@ -4376,7 +5093,7 @@ class XykService {
|
|
|
4376
5093
|
data: null,
|
|
4377
5094
|
error: true,
|
|
4378
5095
|
error_code: data ? data.error_code : response.status,
|
|
4379
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5096
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4380
5097
|
};
|
|
4381
5098
|
}
|
|
4382
5099
|
}
|
|
@@ -4433,7 +5150,7 @@ class XykService {
|
|
|
4433
5150
|
data: dataClass,
|
|
4434
5151
|
error: data.error,
|
|
4435
5152
|
error_code: data ? data.error_code : response.status,
|
|
4436
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5153
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4437
5154
|
};
|
|
4438
5155
|
}
|
|
4439
5156
|
catch (error) {
|
|
@@ -4442,7 +5159,7 @@ class XykService {
|
|
|
4442
5159
|
data: null,
|
|
4443
5160
|
error: true,
|
|
4444
5161
|
error_code: data ? data.error_code : response.status,
|
|
4445
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5162
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4446
5163
|
};
|
|
4447
5164
|
}
|
|
4448
5165
|
}
|
|
@@ -4498,7 +5215,7 @@ class XykService {
|
|
|
4498
5215
|
data: dataClass,
|
|
4499
5216
|
error: data.error,
|
|
4500
5217
|
error_code: data ? data.error_code : response.status,
|
|
4501
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5218
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4502
5219
|
};
|
|
4503
5220
|
}
|
|
4504
5221
|
catch (error) {
|
|
@@ -4507,7 +5224,7 @@ class XykService {
|
|
|
4507
5224
|
data: null,
|
|
4508
5225
|
error: true,
|
|
4509
5226
|
error_code: data ? data.error_code : response.status,
|
|
4510
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5227
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4511
5228
|
};
|
|
4512
5229
|
}
|
|
4513
5230
|
}
|
|
@@ -4563,7 +5280,7 @@ class XykService {
|
|
|
4563
5280
|
data: dataClass,
|
|
4564
5281
|
error: data.error,
|
|
4565
5282
|
error_code: data ? data.error_code : response.status,
|
|
4566
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5283
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4567
5284
|
};
|
|
4568
5285
|
}
|
|
4569
5286
|
catch (error) {
|
|
@@ -4572,14 +5289,14 @@ class XykService {
|
|
|
4572
5289
|
data: null,
|
|
4573
5290
|
error: true,
|
|
4574
5291
|
error_code: data ? data.error_code : response.status,
|
|
4575
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5292
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4576
5293
|
};
|
|
4577
5294
|
}
|
|
4578
5295
|
}
|
|
4579
5296
|
}
|
|
4580
5297
|
}
|
|
4581
5298
|
|
|
4582
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
5299
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.5.2";
|
|
4583
5300
|
/**
|
|
4584
5301
|
* CovalentClient Class
|
|
4585
5302
|
*/
|