@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/es/index.js
CHANGED
|
@@ -277,7 +277,7 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
277
277
|
if (error.message.includes("An error occurred 429")) {
|
|
278
278
|
throw new Error(error.message);
|
|
279
279
|
}
|
|
280
|
-
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : "401 Authorization Required"}`);
|
|
280
|
+
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"}`);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
|
@@ -327,6 +327,43 @@ class TokenSpenderItem {
|
|
|
327
327
|
this.risk_factor = data.risk_factor;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
+
class NftApprovalsResponse {
|
|
331
|
+
constructor(data) {
|
|
332
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
333
|
+
this.chain_id = data.chain_id;
|
|
334
|
+
this.chain_name = data.chain_name;
|
|
335
|
+
this.address = data.address;
|
|
336
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new NftApprovalsItem(itemData)) : null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
class NftApprovalsItem {
|
|
340
|
+
constructor(data) {
|
|
341
|
+
this.contract_address = data.contract_address;
|
|
342
|
+
this.contract_address_label = data.contract_address_label;
|
|
343
|
+
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
344
|
+
this.token_balances = data.token_balances && data.token_balances !== null ? data.token_balances.map((itemData) => new NftApprovalBalance(itemData)) : null;
|
|
345
|
+
this.spenders = data.spenders && data.spenders !== null ? data.spenders.map((itemData) => new NftApprovalSpender(itemData)) : null;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
class NftApprovalBalance {
|
|
349
|
+
constructor(data) {
|
|
350
|
+
this.token_id = data.token_id && data.token_id !== null ? BigInt(data.token_id) : null;
|
|
351
|
+
this.token_balance = data.token_balance && data.token_balance !== null ? BigInt(data.token_balance) : null;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
class NftApprovalSpender {
|
|
355
|
+
constructor(data) {
|
|
356
|
+
this.block_height = data.block_height;
|
|
357
|
+
this.tx_offset = data.tx_offset;
|
|
358
|
+
this.log_offset = data.log_offset;
|
|
359
|
+
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? parseISO(data.block_signed_at.toString()) : null;
|
|
360
|
+
this.tx_hash = data.tx_hash;
|
|
361
|
+
this.spender_address = data.spender_address;
|
|
362
|
+
this.spender_address_label = data.spender_address_label;
|
|
363
|
+
this.token_ids_approved = data.token_ids_approved;
|
|
364
|
+
this.allowance = data.allowance;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
330
367
|
/**
|
|
331
368
|
* Approvals API
|
|
332
369
|
*
|
|
@@ -389,7 +426,71 @@ class SecurityService {
|
|
|
389
426
|
data: dataClass,
|
|
390
427
|
error: data.error,
|
|
391
428
|
error_code: data ? data.error_code : response.status,
|
|
392
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
429
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
success = true;
|
|
434
|
+
return {
|
|
435
|
+
data: null,
|
|
436
|
+
error: true,
|
|
437
|
+
error_code: data ? data.error_code : response.status,
|
|
438
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
*
|
|
445
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
446
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
447
|
+
|
|
448
|
+
*
|
|
449
|
+
*/
|
|
450
|
+
async getNftApprovals(chainName, walletAddress) {
|
|
451
|
+
let success = false;
|
|
452
|
+
let data;
|
|
453
|
+
let response;
|
|
454
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
455
|
+
while (!success) {
|
|
456
|
+
try {
|
|
457
|
+
const urlParams = new URLSearchParams();
|
|
458
|
+
let startTime;
|
|
459
|
+
if (this.debug) {
|
|
460
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
461
|
+
}
|
|
462
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/approvals/${walletAddress}/?${urlParams}`, {
|
|
463
|
+
headers: {
|
|
464
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
465
|
+
"X-Requested-With": userAgent
|
|
466
|
+
}
|
|
467
|
+
}));
|
|
468
|
+
debugOutput(response.url, response.status, startTime);
|
|
469
|
+
if (response.status === 429) {
|
|
470
|
+
try {
|
|
471
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
success = true;
|
|
475
|
+
return {
|
|
476
|
+
data: null,
|
|
477
|
+
error: true,
|
|
478
|
+
error_code: response.status,
|
|
479
|
+
error_message: error.message
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
data = await response.json();
|
|
485
|
+
}
|
|
486
|
+
const dataClass = new NftApprovalsResponse(data.data);
|
|
487
|
+
checkAndModifyResponse(dataClass);
|
|
488
|
+
success = true;
|
|
489
|
+
return {
|
|
490
|
+
data: dataClass,
|
|
491
|
+
error: data.error,
|
|
492
|
+
error_code: data ? data.error_code : response.status,
|
|
493
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
393
494
|
};
|
|
394
495
|
}
|
|
395
496
|
catch (error) {
|
|
@@ -398,7 +499,7 @@ class SecurityService {
|
|
|
398
499
|
data: null,
|
|
399
500
|
error: true,
|
|
400
501
|
error_code: data ? data.error_code : response.status,
|
|
401
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
502
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
402
503
|
};
|
|
403
504
|
}
|
|
404
505
|
}
|
|
@@ -508,6 +609,17 @@ class OhlcItem {
|
|
|
508
609
|
this.pretty_quote = data.pretty_quote;
|
|
509
610
|
}
|
|
510
611
|
}
|
|
612
|
+
class Erc20TransfersResponse {
|
|
613
|
+
constructor(data) {
|
|
614
|
+
this.address = data.address;
|
|
615
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
616
|
+
this.quote_currency = data.quote_currency;
|
|
617
|
+
this.chain_id = data.chain_id;
|
|
618
|
+
this.chain_name = data.chain_name;
|
|
619
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new BlockTransactionWithContractTransfers(itemData)) : null;
|
|
620
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$2(data.pagination) : null;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
511
623
|
class BlockTransactionWithContractTransfers {
|
|
512
624
|
constructor(data) {
|
|
513
625
|
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? parseISO(data.block_signed_at.toString()) : null;
|
|
@@ -532,6 +644,14 @@ class BlockTransactionWithContractTransfers {
|
|
|
532
644
|
this.transfers = data.transfers && data.transfers !== null ? data.transfers.map((itemData) => new TokenTransferItem(itemData)) : null;
|
|
533
645
|
}
|
|
534
646
|
}
|
|
647
|
+
let Pagination$2 = class Pagination {
|
|
648
|
+
constructor(data) {
|
|
649
|
+
this.has_more = data.has_more;
|
|
650
|
+
this.page_number = data.page_number;
|
|
651
|
+
this.page_size = data.page_size;
|
|
652
|
+
this.total_count = data.total_count;
|
|
653
|
+
}
|
|
654
|
+
};
|
|
535
655
|
class TokenTransferItem {
|
|
536
656
|
constructor(data) {
|
|
537
657
|
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? parseISO(data.block_signed_at.toString()) : null;
|
|
@@ -606,6 +726,31 @@ class HistoricalBalanceItem {
|
|
|
606
726
|
this.nft_data = data.nft_data && data.nft_data !== null ? data.nft_data.map((itemData) => new NftData$1(itemData)) : null;
|
|
607
727
|
}
|
|
608
728
|
}
|
|
729
|
+
class TokenBalanceNativeResponse {
|
|
730
|
+
constructor(data) {
|
|
731
|
+
this.address = data.address;
|
|
732
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
733
|
+
this.quote_currency = data.quote_currency;
|
|
734
|
+
this.chain_id = data.chain_id;
|
|
735
|
+
this.chain_name = data.chain_name;
|
|
736
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new NativeBalanceItem(itemData)) : null;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
class NativeBalanceItem {
|
|
740
|
+
constructor(data) {
|
|
741
|
+
this.contract_decimals = data.contract_decimals;
|
|
742
|
+
this.contract_name = data.contract_name;
|
|
743
|
+
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
744
|
+
this.contract_address = data.contract_address;
|
|
745
|
+
this.supports_erc = data.supports_erc;
|
|
746
|
+
this.logo_url = data.logo_url;
|
|
747
|
+
this.block_height = data.block_height;
|
|
748
|
+
this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
|
|
749
|
+
this.quote_rate = data.quote_rate;
|
|
750
|
+
this.quote = data.quote;
|
|
751
|
+
this.pretty_quote = data.pretty_quote;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
609
754
|
/**
|
|
610
755
|
* Balances APIs
|
|
611
756
|
*
|
|
@@ -689,7 +834,7 @@ class BalanceService {
|
|
|
689
834
|
data: dataClass,
|
|
690
835
|
error: data.error,
|
|
691
836
|
error_code: data ? data.error_code : response.status,
|
|
692
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
837
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
693
838
|
};
|
|
694
839
|
}
|
|
695
840
|
catch (error) {
|
|
@@ -698,7 +843,7 @@ class BalanceService {
|
|
|
698
843
|
data: null,
|
|
699
844
|
error: true,
|
|
700
845
|
error_code: data ? data.error_code : response.status,
|
|
701
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
846
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
702
847
|
};
|
|
703
848
|
}
|
|
704
849
|
}
|
|
@@ -763,7 +908,7 @@ class BalanceService {
|
|
|
763
908
|
data: dataClass,
|
|
764
909
|
error: data.error,
|
|
765
910
|
error_code: data ? data.error_code : response.status,
|
|
766
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
911
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
767
912
|
};
|
|
768
913
|
}
|
|
769
914
|
catch (error) {
|
|
@@ -772,7 +917,7 @@ class BalanceService {
|
|
|
772
917
|
data: null,
|
|
773
918
|
error: true,
|
|
774
919
|
error_code: data ? data.error_code : response.status,
|
|
775
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
920
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
776
921
|
};
|
|
777
922
|
}
|
|
778
923
|
}
|
|
@@ -827,6 +972,96 @@ class BalanceService {
|
|
|
827
972
|
}
|
|
828
973
|
}
|
|
829
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
*
|
|
977
|
+
* Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
|
|
978
|
+
*
|
|
979
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
980
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
981
|
+
* @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
|
|
982
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
983
|
+
* - `contractAddress`: The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
984
|
+
* - `startingBlock`: The block height to start from, defaults to `0`.
|
|
985
|
+
* - `endingBlock`: The block height to end at, defaults to current block height.
|
|
986
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
987
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
988
|
+
*
|
|
989
|
+
*/
|
|
990
|
+
async getErc20TransfersForWalletAddressByPage(chainName, walletAddress, queryParamOpts) {
|
|
991
|
+
let success = false;
|
|
992
|
+
let data;
|
|
993
|
+
let response;
|
|
994
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
995
|
+
while (!success) {
|
|
996
|
+
try {
|
|
997
|
+
const urlParams = new URLSearchParams();
|
|
998
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
999
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1000
|
+
}
|
|
1001
|
+
if (queryParamOpts?.contractAddress !== undefined) {
|
|
1002
|
+
urlParams.append("contract-address", queryParamOpts?.contractAddress.toString());
|
|
1003
|
+
}
|
|
1004
|
+
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1005
|
+
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1006
|
+
}
|
|
1007
|
+
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1008
|
+
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1009
|
+
}
|
|
1010
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1011
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1012
|
+
}
|
|
1013
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1014
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1015
|
+
}
|
|
1016
|
+
let startTime;
|
|
1017
|
+
if (this.debug) {
|
|
1018
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1019
|
+
}
|
|
1020
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, {
|
|
1021
|
+
headers: {
|
|
1022
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1023
|
+
"X-Requested-With": userAgent
|
|
1024
|
+
}
|
|
1025
|
+
}));
|
|
1026
|
+
debugOutput(response.url, response.status, startTime);
|
|
1027
|
+
if (response.status === 429) {
|
|
1028
|
+
try {
|
|
1029
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1030
|
+
}
|
|
1031
|
+
catch (error) {
|
|
1032
|
+
success = true;
|
|
1033
|
+
return {
|
|
1034
|
+
data: null,
|
|
1035
|
+
error: true,
|
|
1036
|
+
error_code: response.status,
|
|
1037
|
+
error_message: error.message
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
data = await response.json();
|
|
1043
|
+
}
|
|
1044
|
+
const dataClass = new Erc20TransfersResponse(data.data);
|
|
1045
|
+
checkAndModifyResponse(dataClass);
|
|
1046
|
+
success = true;
|
|
1047
|
+
return {
|
|
1048
|
+
data: dataClass,
|
|
1049
|
+
error: data.error,
|
|
1050
|
+
error_code: data ? data.error_code : response.status,
|
|
1051
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
catch (error) {
|
|
1055
|
+
success = true;
|
|
1056
|
+
return {
|
|
1057
|
+
data: null,
|
|
1058
|
+
error: true,
|
|
1059
|
+
error_code: data ? data.error_code : response.status,
|
|
1060
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
830
1065
|
/**
|
|
831
1066
|
*
|
|
832
1067
|
* 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.
|
|
@@ -945,7 +1180,7 @@ class BalanceService {
|
|
|
945
1180
|
data: dataClass,
|
|
946
1181
|
error: data.error,
|
|
947
1182
|
error_code: data ? data.error_code : response.status,
|
|
948
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1183
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
949
1184
|
};
|
|
950
1185
|
}
|
|
951
1186
|
catch (error) {
|
|
@@ -954,60 +1189,132 @@ class BalanceService {
|
|
|
954
1189
|
data: null,
|
|
955
1190
|
error: true,
|
|
956
1191
|
error_code: data ? data.error_code : response.status,
|
|
957
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1192
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
958
1193
|
};
|
|
959
1194
|
}
|
|
960
1195
|
}
|
|
961
1196
|
}
|
|
962
|
-
|
|
963
|
-
|
|
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
|
-
|
|
1197
|
+
/**
|
|
1198
|
+
*
|
|
1199
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1200
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1201
|
+
* @param {GetNativeTokenBalanceQueryParamOpts} queryParamOpts
|
|
1202
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
1203
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
1204
|
+
*
|
|
1205
|
+
*/
|
|
1206
|
+
async getNativeTokenBalance(chainName, walletAddress, queryParamOpts) {
|
|
1207
|
+
let success = false;
|
|
1208
|
+
let data;
|
|
1209
|
+
let response;
|
|
1210
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1211
|
+
while (!success) {
|
|
1212
|
+
try {
|
|
1213
|
+
const urlParams = new URLSearchParams();
|
|
1214
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1215
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1216
|
+
}
|
|
1217
|
+
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1218
|
+
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1219
|
+
}
|
|
1220
|
+
let startTime;
|
|
1221
|
+
if (this.debug) {
|
|
1222
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1223
|
+
}
|
|
1224
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`, {
|
|
1225
|
+
headers: {
|
|
1226
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1227
|
+
"X-Requested-With": userAgent
|
|
1228
|
+
}
|
|
1229
|
+
}));
|
|
1230
|
+
debugOutput(response.url, response.status, startTime);
|
|
1231
|
+
if (response.status === 429) {
|
|
1232
|
+
try {
|
|
1233
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1234
|
+
}
|
|
1235
|
+
catch (error) {
|
|
1236
|
+
success = true;
|
|
1237
|
+
return {
|
|
1238
|
+
data: null,
|
|
1239
|
+
error: true,
|
|
1240
|
+
error_code: response.status,
|
|
1241
|
+
error_message: error.message
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
data = await response.json();
|
|
1247
|
+
}
|
|
1248
|
+
const dataClass = new TokenBalanceNativeResponse(data.data);
|
|
1249
|
+
checkAndModifyResponse(dataClass);
|
|
1250
|
+
success = true;
|
|
1251
|
+
return {
|
|
1252
|
+
data: dataClass,
|
|
1253
|
+
error: data.error,
|
|
1254
|
+
error_code: data ? data.error_code : response.status,
|
|
1255
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
catch (error) {
|
|
1259
|
+
success = true;
|
|
1260
|
+
return {
|
|
1261
|
+
data: null,
|
|
1262
|
+
error: true,
|
|
1263
|
+
error_code: data ? data.error_code : response.status,
|
|
1264
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
class BlockResponse {
|
|
1272
|
+
constructor(data) {
|
|
1273
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1274
|
+
this.chain_id = data.chain_id;
|
|
1275
|
+
this.chain_name = data.chain_name;
|
|
1276
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Block(itemData)) : null;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
class Block {
|
|
1280
|
+
constructor(data) {
|
|
1281
|
+
this.signed_at = data.signed_at && data.signed_at !== null ? parseISO(data.signed_at.toString()) : null;
|
|
1282
|
+
this.height = data.height;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
class ResolvedAddress {
|
|
1286
|
+
constructor(data) {
|
|
1287
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1288
|
+
this.chain_id = data.chain_id;
|
|
1289
|
+
this.chain_name = data.chain_name;
|
|
1290
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new ResolvedAddressItem(itemData)) : null;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
class ResolvedAddressItem {
|
|
1294
|
+
constructor(data) {
|
|
1295
|
+
this.address = data.address;
|
|
1296
|
+
this.name = data.name;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
class GetLogsResponse {
|
|
1300
|
+
constructor(data) {
|
|
1301
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1302
|
+
this.chain_id = data.chain_id;
|
|
1303
|
+
this.chain_name = data.chain_name;
|
|
1304
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new GetLogsEvent(itemData)) : null;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
class GetLogsEvent {
|
|
1308
|
+
constructor(data) {
|
|
1309
|
+
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? parseISO(data.block_signed_at.toString()) : null;
|
|
1310
|
+
this.block_height = data.block_height;
|
|
1311
|
+
this.block_hash = data.block_hash;
|
|
1312
|
+
this.tx_offset = data.tx_offset;
|
|
1313
|
+
this.log_offset = data.log_offset;
|
|
1314
|
+
this.tx_hash = data.tx_hash;
|
|
1315
|
+
this.raw_log_topics = data.raw_log_topics;
|
|
1316
|
+
this.sender_contract_decimals = data.sender_contract_decimals;
|
|
1317
|
+
this.sender_name = data.sender_name;
|
|
1011
1318
|
this.sender_contract_ticker_symbol = data.sender_contract_ticker_symbol;
|
|
1012
1319
|
this.sender_address = data.sender_address;
|
|
1013
1320
|
this.sender_address_label = data.sender_address_label;
|
|
@@ -1068,9 +1375,20 @@ class ChainItem {
|
|
|
1068
1375
|
this.black_logo_url = data.black_logo_url;
|
|
1069
1376
|
this.white_logo_url = data.white_logo_url;
|
|
1070
1377
|
this.is_appchain = data.is_appchain;
|
|
1378
|
+
this.color_theme = data.color_theme && data.color_theme !== null ? new ColorTheme(data.color_theme) : null;
|
|
1071
1379
|
this.appchain_of = data.appchain_of && data.appchain_of !== null ? new ChainItem(data.appchain_of) : null;
|
|
1072
1380
|
}
|
|
1073
1381
|
}
|
|
1382
|
+
class ColorTheme {
|
|
1383
|
+
constructor(data) {
|
|
1384
|
+
this.red = data.red;
|
|
1385
|
+
this.green = data.green;
|
|
1386
|
+
this.blue = data.blue;
|
|
1387
|
+
this.alpha = data.alpha;
|
|
1388
|
+
this.hex = data.hex;
|
|
1389
|
+
this.css_rgb = data.css_rgb;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1074
1392
|
class AllChainsStatusResponse {
|
|
1075
1393
|
constructor(data) {
|
|
1076
1394
|
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
@@ -1166,7 +1484,7 @@ class BaseService {
|
|
|
1166
1484
|
data: dataClass,
|
|
1167
1485
|
error: data.error,
|
|
1168
1486
|
error_code: data ? data.error_code : response.status,
|
|
1169
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1487
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1170
1488
|
};
|
|
1171
1489
|
}
|
|
1172
1490
|
catch (error) {
|
|
@@ -1175,7 +1493,7 @@ class BaseService {
|
|
|
1175
1493
|
data: null,
|
|
1176
1494
|
error: true,
|
|
1177
1495
|
error_code: data ? data.error_code : response.status,
|
|
1178
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1496
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1179
1497
|
};
|
|
1180
1498
|
}
|
|
1181
1499
|
}
|
|
@@ -1231,7 +1549,7 @@ class BaseService {
|
|
|
1231
1549
|
data: dataClass,
|
|
1232
1550
|
error: data.error,
|
|
1233
1551
|
error_code: data ? data.error_code : response.status,
|
|
1234
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1552
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1235
1553
|
};
|
|
1236
1554
|
}
|
|
1237
1555
|
catch (error) {
|
|
@@ -1240,7 +1558,7 @@ class BaseService {
|
|
|
1240
1558
|
data: null,
|
|
1241
1559
|
error: true,
|
|
1242
1560
|
error_code: data ? data.error_code : response.status,
|
|
1243
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1561
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1244
1562
|
};
|
|
1245
1563
|
}
|
|
1246
1564
|
}
|
|
@@ -1355,7 +1673,7 @@ class BaseService {
|
|
|
1355
1673
|
data: dataClass,
|
|
1356
1674
|
error: data.error,
|
|
1357
1675
|
error_code: data ? data.error_code : response.status,
|
|
1358
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1676
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1359
1677
|
};
|
|
1360
1678
|
}
|
|
1361
1679
|
catch (error) {
|
|
@@ -1364,7 +1682,7 @@ class BaseService {
|
|
|
1364
1682
|
data: null,
|
|
1365
1683
|
error: true,
|
|
1366
1684
|
error_code: data ? data.error_code : response.status,
|
|
1367
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1685
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1368
1686
|
};
|
|
1369
1687
|
}
|
|
1370
1688
|
}
|
|
@@ -1506,7 +1824,7 @@ class BaseService {
|
|
|
1506
1824
|
data: dataClass,
|
|
1507
1825
|
error: data.error,
|
|
1508
1826
|
error_code: data ? data.error_code : response.status,
|
|
1509
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1827
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1510
1828
|
};
|
|
1511
1829
|
}
|
|
1512
1830
|
catch (error) {
|
|
@@ -1515,7 +1833,7 @@ class BaseService {
|
|
|
1515
1833
|
data: null,
|
|
1516
1834
|
error: true,
|
|
1517
1835
|
error_code: data ? data.error_code : response.status,
|
|
1518
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1836
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1519
1837
|
};
|
|
1520
1838
|
}
|
|
1521
1839
|
}
|
|
@@ -1569,7 +1887,7 @@ class BaseService {
|
|
|
1569
1887
|
data: dataClass,
|
|
1570
1888
|
error: data.error,
|
|
1571
1889
|
error_code: data ? data.error_code : response.status,
|
|
1572
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1890
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1573
1891
|
};
|
|
1574
1892
|
}
|
|
1575
1893
|
catch (error) {
|
|
@@ -1578,7 +1896,7 @@ class BaseService {
|
|
|
1578
1896
|
data: null,
|
|
1579
1897
|
error: true,
|
|
1580
1898
|
error_code: data ? data.error_code : response.status,
|
|
1581
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1899
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1582
1900
|
};
|
|
1583
1901
|
}
|
|
1584
1902
|
}
|
|
@@ -1638,7 +1956,7 @@ class BaseService {
|
|
|
1638
1956
|
data: dataClass,
|
|
1639
1957
|
error: data.error,
|
|
1640
1958
|
error_code: data ? data.error_code : response.status,
|
|
1641
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1959
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1642
1960
|
};
|
|
1643
1961
|
}
|
|
1644
1962
|
catch (error) {
|
|
@@ -1647,7 +1965,7 @@ class BaseService {
|
|
|
1647
1965
|
data: null,
|
|
1648
1966
|
error: true,
|
|
1649
1967
|
error_code: data ? data.error_code : response.status,
|
|
1650
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
1968
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1651
1969
|
};
|
|
1652
1970
|
}
|
|
1653
1971
|
}
|
|
@@ -1903,6 +2221,62 @@ class NftOwnershipForCollectionItem {
|
|
|
1903
2221
|
this.nft_data = data.nft_data && data.nft_data !== null ? new NftData(data.nft_data) : null;
|
|
1904
2222
|
}
|
|
1905
2223
|
}
|
|
2224
|
+
class NftMarketSaleCountResponse {
|
|
2225
|
+
constructor(data) {
|
|
2226
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
2227
|
+
this.address = data.address;
|
|
2228
|
+
this.quote_currency = data.quote_currency;
|
|
2229
|
+
this.chain_name = data.chain_name;
|
|
2230
|
+
this.chain_id = data.chain_id;
|
|
2231
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketSaleCountItem(itemData)) : null;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
class MarketSaleCountItem {
|
|
2235
|
+
constructor(data) {
|
|
2236
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
2237
|
+
this.sale_count = data.sale_count;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
class NftMarketVolumeResponse {
|
|
2241
|
+
constructor(data) {
|
|
2242
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
2243
|
+
this.address = data.address;
|
|
2244
|
+
this.quote_currency = data.quote_currency;
|
|
2245
|
+
this.chain_name = data.chain_name;
|
|
2246
|
+
this.chain_id = data.chain_id;
|
|
2247
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketVolumeItem(itemData)) : null;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
class MarketVolumeItem {
|
|
2251
|
+
constructor(data) {
|
|
2252
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
2253
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
2254
|
+
this.native_name = data.native_name;
|
|
2255
|
+
this.volume_quote = data.volume_quote;
|
|
2256
|
+
this.volume_native_quote = data.volume_native_quote;
|
|
2257
|
+
this.pretty_volume_quote = data.pretty_volume_quote;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
class NftMarketFloorPriceResponse {
|
|
2261
|
+
constructor(data) {
|
|
2262
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
2263
|
+
this.address = data.address;
|
|
2264
|
+
this.quote_currency = data.quote_currency;
|
|
2265
|
+
this.chain_name = data.chain_name;
|
|
2266
|
+
this.chain_id = data.chain_id;
|
|
2267
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new MarketFloorPriceItem(itemData)) : null;
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
class MarketFloorPriceItem {
|
|
2271
|
+
constructor(data) {
|
|
2272
|
+
this.date = data.date && data.date !== null ? parseISO(data.date.toString()) : null;
|
|
2273
|
+
this.native_ticker_symbol = data.native_ticker_symbol;
|
|
2274
|
+
this.native_name = data.native_name;
|
|
2275
|
+
this.floor_price_native_quote = data.floor_price_native_quote;
|
|
2276
|
+
this.floor_price_quote = data.floor_price_quote;
|
|
2277
|
+
this.pretty_floor_price_quote = data.pretty_floor_price_quote;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
1906
2280
|
/**
|
|
1907
2281
|
* NFT APIs
|
|
1908
2282
|
*
|
|
@@ -1971,20 +2345,281 @@ class NftService {
|
|
|
1971
2345
|
while (!success) {
|
|
1972
2346
|
try {
|
|
1973
2347
|
const urlParams = new URLSearchParams();
|
|
1974
|
-
if (queryParamOpts?.noSpam !== undefined) {
|
|
1975
|
-
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
1976
|
-
}
|
|
1977
|
-
if (queryParamOpts?.noNftAssetMetadata !== undefined) {
|
|
1978
|
-
urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
|
|
1979
|
-
}
|
|
1980
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
1981
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
1982
|
-
}
|
|
2348
|
+
if (queryParamOpts?.noSpam !== undefined) {
|
|
2349
|
+
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2350
|
+
}
|
|
2351
|
+
if (queryParamOpts?.noNftAssetMetadata !== undefined) {
|
|
2352
|
+
urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
|
|
2353
|
+
}
|
|
2354
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2355
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2356
|
+
}
|
|
2357
|
+
let startTime;
|
|
2358
|
+
if (this.debug) {
|
|
2359
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2360
|
+
}
|
|
2361
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
|
|
2362
|
+
headers: {
|
|
2363
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2364
|
+
"X-Requested-With": userAgent
|
|
2365
|
+
}
|
|
2366
|
+
}));
|
|
2367
|
+
debugOutput(response.url, response.status, startTime);
|
|
2368
|
+
if (response.status === 429) {
|
|
2369
|
+
try {
|
|
2370
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2371
|
+
}
|
|
2372
|
+
catch (error) {
|
|
2373
|
+
success = true;
|
|
2374
|
+
return {
|
|
2375
|
+
data: null,
|
|
2376
|
+
error: true,
|
|
2377
|
+
error_code: response.status,
|
|
2378
|
+
error_message: error.message
|
|
2379
|
+
};
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
else {
|
|
2383
|
+
data = await response.json();
|
|
2384
|
+
}
|
|
2385
|
+
const dataClass = new NftAddressBalanceNftResponse(data.data);
|
|
2386
|
+
checkAndModifyResponse(dataClass);
|
|
2387
|
+
success = true;
|
|
2388
|
+
return {
|
|
2389
|
+
data: dataClass,
|
|
2390
|
+
error: data.error,
|
|
2391
|
+
error_code: data ? data.error_code : response.status,
|
|
2392
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
catch (error) {
|
|
2396
|
+
success = true;
|
|
2397
|
+
return {
|
|
2398
|
+
data: null,
|
|
2399
|
+
error: true,
|
|
2400
|
+
error_code: data ? data.error_code : response.status,
|
|
2401
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
*
|
|
2408
|
+
* Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
|
|
2409
|
+
*
|
|
2410
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2411
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2412
|
+
* @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
|
|
2413
|
+
* - `noMetadata`: Omit metadata.
|
|
2414
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2415
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2416
|
+
* - `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.
|
|
2417
|
+
* - `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.
|
|
2418
|
+
* - `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.
|
|
2419
|
+
*
|
|
2420
|
+
*/
|
|
2421
|
+
async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
|
|
2422
|
+
let success = false;
|
|
2423
|
+
let res;
|
|
2424
|
+
while (!success) {
|
|
2425
|
+
try {
|
|
2426
|
+
const urlParams = new URLSearchParams();
|
|
2427
|
+
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2428
|
+
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2429
|
+
}
|
|
2430
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
2431
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2432
|
+
}
|
|
2433
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2434
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2435
|
+
}
|
|
2436
|
+
if (queryParamOpts?.traitsFilter !== undefined) {
|
|
2437
|
+
urlParams.append("traits-filter", queryParamOpts?.traitsFilter.toString());
|
|
2438
|
+
}
|
|
2439
|
+
if (queryParamOpts?.valuesFilter !== undefined) {
|
|
2440
|
+
urlParams.append("values-filter", queryParamOpts?.valuesFilter.toString());
|
|
2441
|
+
}
|
|
2442
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2443
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2444
|
+
}
|
|
2445
|
+
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount)) {
|
|
2446
|
+
yield res;
|
|
2447
|
+
}
|
|
2448
|
+
success = true;
|
|
2449
|
+
}
|
|
2450
|
+
catch (error) {
|
|
2451
|
+
success = true;
|
|
2452
|
+
throw new Error(error.message);
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
*
|
|
2458
|
+
* Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
|
|
2459
|
+
*
|
|
2460
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2461
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2462
|
+
* @param {string} tokenId - The requested token ID.
|
|
2463
|
+
* @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
|
|
2464
|
+
* - `noMetadata`: Omit metadata.
|
|
2465
|
+
* - `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.
|
|
2466
|
+
*
|
|
2467
|
+
*/
|
|
2468
|
+
async getNftMetadataForGivenTokenIdForContract(chainName, contractAddress, tokenId, queryParamOpts) {
|
|
2469
|
+
let success = false;
|
|
2470
|
+
let data;
|
|
2471
|
+
let response;
|
|
2472
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2473
|
+
while (!success) {
|
|
2474
|
+
try {
|
|
2475
|
+
const urlParams = new URLSearchParams();
|
|
2476
|
+
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2477
|
+
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2478
|
+
}
|
|
2479
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2480
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2481
|
+
}
|
|
2482
|
+
let startTime;
|
|
2483
|
+
if (this.debug) {
|
|
2484
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2485
|
+
}
|
|
2486
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
|
|
2487
|
+
headers: {
|
|
2488
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2489
|
+
"X-Requested-With": userAgent
|
|
2490
|
+
}
|
|
2491
|
+
}));
|
|
2492
|
+
debugOutput(response.url, response.status, startTime);
|
|
2493
|
+
if (response.status === 429) {
|
|
2494
|
+
try {
|
|
2495
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2496
|
+
}
|
|
2497
|
+
catch (error) {
|
|
2498
|
+
success = true;
|
|
2499
|
+
return {
|
|
2500
|
+
data: null,
|
|
2501
|
+
error: true,
|
|
2502
|
+
error_code: response.status,
|
|
2503
|
+
error_message: error.message
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
else {
|
|
2508
|
+
data = await response.json();
|
|
2509
|
+
}
|
|
2510
|
+
const dataClass = new NftMetadataResponse(data.data);
|
|
2511
|
+
checkAndModifyResponse(dataClass);
|
|
2512
|
+
success = true;
|
|
2513
|
+
return {
|
|
2514
|
+
data: dataClass,
|
|
2515
|
+
error: data.error,
|
|
2516
|
+
error_code: data ? data.error_code : response.status,
|
|
2517
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
catch (error) {
|
|
2521
|
+
success = true;
|
|
2522
|
+
return {
|
|
2523
|
+
data: null,
|
|
2524
|
+
error: true,
|
|
2525
|
+
error_code: data ? data.error_code : response.status,
|
|
2526
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
*
|
|
2533
|
+
* Commonly used to get all transactions of an NFT token. Useful for building a transaction history table or price chart.
|
|
2534
|
+
*
|
|
2535
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2536
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2537
|
+
* @param {string} tokenId - The requested token ID.
|
|
2538
|
+
* @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
|
|
2539
|
+
* - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
2540
|
+
*
|
|
2541
|
+
*/
|
|
2542
|
+
async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, queryParamOpts) {
|
|
2543
|
+
let success = false;
|
|
2544
|
+
let data;
|
|
2545
|
+
let response;
|
|
2546
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2547
|
+
while (!success) {
|
|
2548
|
+
try {
|
|
2549
|
+
const urlParams = new URLSearchParams();
|
|
2550
|
+
if (queryParamOpts?.noSpam !== undefined) {
|
|
2551
|
+
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2552
|
+
}
|
|
2553
|
+
let startTime;
|
|
2554
|
+
if (this.debug) {
|
|
2555
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2556
|
+
}
|
|
2557
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
|
|
2558
|
+
headers: {
|
|
2559
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2560
|
+
"X-Requested-With": userAgent
|
|
2561
|
+
}
|
|
2562
|
+
}));
|
|
2563
|
+
debugOutput(response.url, response.status, startTime);
|
|
2564
|
+
if (response.status === 429) {
|
|
2565
|
+
try {
|
|
2566
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2567
|
+
}
|
|
2568
|
+
catch (error) {
|
|
2569
|
+
success = true;
|
|
2570
|
+
return {
|
|
2571
|
+
data: null,
|
|
2572
|
+
error: true,
|
|
2573
|
+
error_code: response.status,
|
|
2574
|
+
error_message: error.message
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
else {
|
|
2579
|
+
data = await response.json();
|
|
2580
|
+
}
|
|
2581
|
+
const dataClass = new NftTransactionsResponse(data.data);
|
|
2582
|
+
checkAndModifyResponse(dataClass);
|
|
2583
|
+
success = true;
|
|
2584
|
+
return {
|
|
2585
|
+
data: dataClass,
|
|
2586
|
+
error: data.error,
|
|
2587
|
+
error_code: data ? data.error_code : response.status,
|
|
2588
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
catch (error) {
|
|
2592
|
+
success = true;
|
|
2593
|
+
return {
|
|
2594
|
+
data: null,
|
|
2595
|
+
error: true,
|
|
2596
|
+
error_code: data ? data.error_code : response.status,
|
|
2597
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
/**
|
|
2603
|
+
*
|
|
2604
|
+
* Commonly used to fetch and render the traits of a collection as seen in rarity calculators.
|
|
2605
|
+
*
|
|
2606
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2607
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2608
|
+
*
|
|
2609
|
+
*/
|
|
2610
|
+
async getTraitsForCollection(chainName, collectionContract) {
|
|
2611
|
+
let success = false;
|
|
2612
|
+
let data;
|
|
2613
|
+
let response;
|
|
2614
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2615
|
+
while (!success) {
|
|
2616
|
+
try {
|
|
2617
|
+
const urlParams = new URLSearchParams();
|
|
1983
2618
|
let startTime;
|
|
1984
2619
|
if (this.debug) {
|
|
1985
2620
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1986
2621
|
}
|
|
1987
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2622
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
|
|
1988
2623
|
headers: {
|
|
1989
2624
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
1990
2625
|
"X-Requested-With": userAgent
|
|
@@ -2008,14 +2643,14 @@ class NftService {
|
|
|
2008
2643
|
else {
|
|
2009
2644
|
data = await response.json();
|
|
2010
2645
|
}
|
|
2011
|
-
const dataClass = new
|
|
2646
|
+
const dataClass = new NftCollectionTraitsResponse(data.data);
|
|
2012
2647
|
checkAndModifyResponse(dataClass);
|
|
2013
2648
|
success = true;
|
|
2014
2649
|
return {
|
|
2015
2650
|
data: dataClass,
|
|
2016
2651
|
error: data.error,
|
|
2017
2652
|
error_code: data ? data.error_code : response.status,
|
|
2018
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2653
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2019
2654
|
};
|
|
2020
2655
|
}
|
|
2021
2656
|
catch (error) {
|
|
@@ -2024,74 +2659,21 @@ class NftService {
|
|
|
2024
2659
|
data: null,
|
|
2025
2660
|
error: true,
|
|
2026
2661
|
error_code: data ? data.error_code : response.status,
|
|
2027
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2662
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2028
2663
|
};
|
|
2029
2664
|
}
|
|
2030
2665
|
}
|
|
2031
2666
|
}
|
|
2032
2667
|
/**
|
|
2033
2668
|
*
|
|
2034
|
-
* Commonly used to get
|
|
2035
|
-
*
|
|
2036
|
-
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2037
|
-
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2038
|
-
* @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
|
|
2039
|
-
* - `noMetadata`: Omit metadata.
|
|
2040
|
-
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2041
|
-
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2042
|
-
* - `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.
|
|
2043
|
-
* - `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.
|
|
2044
|
-
* - `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.
|
|
2045
|
-
*
|
|
2046
|
-
*/
|
|
2047
|
-
async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
|
|
2048
|
-
let success = false;
|
|
2049
|
-
let res;
|
|
2050
|
-
while (!success) {
|
|
2051
|
-
try {
|
|
2052
|
-
const urlParams = new URLSearchParams();
|
|
2053
|
-
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2054
|
-
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2055
|
-
}
|
|
2056
|
-
if (queryParamOpts?.pageSize !== undefined) {
|
|
2057
|
-
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2058
|
-
}
|
|
2059
|
-
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2060
|
-
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2061
|
-
}
|
|
2062
|
-
if (queryParamOpts?.traitsFilter !== undefined) {
|
|
2063
|
-
urlParams.append("traits-filter", queryParamOpts?.traitsFilter.toString());
|
|
2064
|
-
}
|
|
2065
|
-
if (queryParamOpts?.valuesFilter !== undefined) {
|
|
2066
|
-
urlParams.append("values-filter", queryParamOpts?.valuesFilter.toString());
|
|
2067
|
-
}
|
|
2068
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
2069
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2070
|
-
}
|
|
2071
|
-
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount)) {
|
|
2072
|
-
yield res;
|
|
2073
|
-
}
|
|
2074
|
-
success = true;
|
|
2075
|
-
}
|
|
2076
|
-
catch (error) {
|
|
2077
|
-
success = true;
|
|
2078
|
-
throw new Error(error.message);
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
*
|
|
2084
|
-
* Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
|
|
2669
|
+
* Commonly used to get the count of unique values for traits within an NFT collection.
|
|
2085
2670
|
*
|
|
2086
2671
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2087
|
-
* @param {string}
|
|
2088
|
-
* @param {string}
|
|
2089
|
-
* @param {GetNftMetadataForGivenTokenIdForContractQueryParamOpts} queryParamOpts
|
|
2090
|
-
* - `noMetadata`: Omit metadata.
|
|
2091
|
-
* - `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.
|
|
2672
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2673
|
+
* @param {string} trait - The requested trait.
|
|
2092
2674
|
*
|
|
2093
2675
|
*/
|
|
2094
|
-
async
|
|
2676
|
+
async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
|
|
2095
2677
|
let success = false;
|
|
2096
2678
|
let data;
|
|
2097
2679
|
let response;
|
|
@@ -2099,17 +2681,11 @@ class NftService {
|
|
|
2099
2681
|
while (!success) {
|
|
2100
2682
|
try {
|
|
2101
2683
|
const urlParams = new URLSearchParams();
|
|
2102
|
-
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2103
|
-
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2104
|
-
}
|
|
2105
|
-
if (queryParamOpts?.withUncached !== undefined) {
|
|
2106
|
-
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2107
|
-
}
|
|
2108
2684
|
let startTime;
|
|
2109
2685
|
if (this.debug) {
|
|
2110
2686
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2111
2687
|
}
|
|
2112
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${
|
|
2688
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
|
|
2113
2689
|
headers: {
|
|
2114
2690
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2115
2691
|
"X-Requested-With": userAgent
|
|
@@ -2133,14 +2709,14 @@ class NftService {
|
|
|
2133
2709
|
else {
|
|
2134
2710
|
data = await response.json();
|
|
2135
2711
|
}
|
|
2136
|
-
const dataClass = new
|
|
2712
|
+
const dataClass = new NftCollectionAttributesForTraitResponse(data.data);
|
|
2137
2713
|
checkAndModifyResponse(dataClass);
|
|
2138
2714
|
success = true;
|
|
2139
2715
|
return {
|
|
2140
2716
|
data: dataClass,
|
|
2141
2717
|
error: data.error,
|
|
2142
2718
|
error_code: data ? data.error_code : response.status,
|
|
2143
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2719
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2144
2720
|
};
|
|
2145
2721
|
}
|
|
2146
2722
|
catch (error) {
|
|
@@ -2149,23 +2725,20 @@ class NftService {
|
|
|
2149
2725
|
data: null,
|
|
2150
2726
|
error: true,
|
|
2151
2727
|
error_code: data ? data.error_code : response.status,
|
|
2152
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2728
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2153
2729
|
};
|
|
2154
2730
|
}
|
|
2155
2731
|
}
|
|
2156
2732
|
}
|
|
2157
2733
|
/**
|
|
2158
2734
|
*
|
|
2159
|
-
* Commonly used to
|
|
2735
|
+
* Commonly used to calculate rarity scores for a collection based on its traits.
|
|
2160
2736
|
*
|
|
2161
2737
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2162
|
-
* @param {string}
|
|
2163
|
-
* @param {string} tokenId - The requested token ID.
|
|
2164
|
-
* @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
|
|
2165
|
-
* - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
2738
|
+
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2166
2739
|
*
|
|
2167
2740
|
*/
|
|
2168
|
-
async
|
|
2741
|
+
async getCollectionTraitsSummary(chainName, collectionContract) {
|
|
2169
2742
|
let success = false;
|
|
2170
2743
|
let data;
|
|
2171
2744
|
let response;
|
|
@@ -2173,14 +2746,11 @@ class NftService {
|
|
|
2173
2746
|
while (!success) {
|
|
2174
2747
|
try {
|
|
2175
2748
|
const urlParams = new URLSearchParams();
|
|
2176
|
-
if (queryParamOpts?.noSpam !== undefined) {
|
|
2177
|
-
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2178
|
-
}
|
|
2179
2749
|
let startTime;
|
|
2180
2750
|
if (this.debug) {
|
|
2181
2751
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2182
2752
|
}
|
|
2183
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2753
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
|
|
2184
2754
|
headers: {
|
|
2185
2755
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2186
2756
|
"X-Requested-With": userAgent
|
|
@@ -2204,14 +2774,14 @@ class NftService {
|
|
|
2204
2774
|
else {
|
|
2205
2775
|
data = await response.json();
|
|
2206
2776
|
}
|
|
2207
|
-
const dataClass = new
|
|
2777
|
+
const dataClass = new NftCollectionTraitSummaryResponse(data.data);
|
|
2208
2778
|
checkAndModifyResponse(dataClass);
|
|
2209
2779
|
success = true;
|
|
2210
2780
|
return {
|
|
2211
2781
|
data: dataClass,
|
|
2212
2782
|
error: data.error,
|
|
2213
2783
|
error_code: data ? data.error_code : response.status,
|
|
2214
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2784
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2215
2785
|
};
|
|
2216
2786
|
}
|
|
2217
2787
|
catch (error) {
|
|
@@ -2220,20 +2790,21 @@ class NftService {
|
|
|
2220
2790
|
data: null,
|
|
2221
2791
|
error: true,
|
|
2222
2792
|
error_code: data ? data.error_code : response.status,
|
|
2223
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2793
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2224
2794
|
};
|
|
2225
2795
|
}
|
|
2226
2796
|
}
|
|
2227
2797
|
}
|
|
2228
2798
|
/**
|
|
2229
2799
|
*
|
|
2230
|
-
* Commonly used to
|
|
2800
|
+
* Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
|
|
2231
2801
|
*
|
|
2232
2802
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2233
|
-
* @param {string}
|
|
2803
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2804
|
+
* @param {string} collectionContract - The requested collection address.
|
|
2234
2805
|
*
|
|
2235
2806
|
*/
|
|
2236
|
-
async
|
|
2807
|
+
async checkOwnershipInNft(chainName, walletAddress, collectionContract) {
|
|
2237
2808
|
let success = false;
|
|
2238
2809
|
let data;
|
|
2239
2810
|
let response;
|
|
@@ -2245,7 +2816,7 @@ class NftService {
|
|
|
2245
2816
|
if (this.debug) {
|
|
2246
2817
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2247
2818
|
}
|
|
2248
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2819
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
|
|
2249
2820
|
headers: {
|
|
2250
2821
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2251
2822
|
"X-Requested-With": userAgent
|
|
@@ -2269,14 +2840,14 @@ class NftService {
|
|
|
2269
2840
|
else {
|
|
2270
2841
|
data = await response.json();
|
|
2271
2842
|
}
|
|
2272
|
-
const dataClass = new
|
|
2843
|
+
const dataClass = new NftOwnershipForCollectionResponse(data.data);
|
|
2273
2844
|
checkAndModifyResponse(dataClass);
|
|
2274
2845
|
success = true;
|
|
2275
2846
|
return {
|
|
2276
2847
|
data: dataClass,
|
|
2277
2848
|
error: data.error,
|
|
2278
2849
|
error_code: data ? data.error_code : response.status,
|
|
2279
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2850
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2280
2851
|
};
|
|
2281
2852
|
}
|
|
2282
2853
|
catch (error) {
|
|
@@ -2285,21 +2856,22 @@ class NftService {
|
|
|
2285
2856
|
data: null,
|
|
2286
2857
|
error: true,
|
|
2287
2858
|
error_code: data ? data.error_code : response.status,
|
|
2288
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2859
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2289
2860
|
};
|
|
2290
2861
|
}
|
|
2291
2862
|
}
|
|
2292
2863
|
}
|
|
2293
2864
|
/**
|
|
2294
2865
|
*
|
|
2295
|
-
* Commonly used to
|
|
2866
|
+
* Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
|
|
2296
2867
|
*
|
|
2297
2868
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2869
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2298
2870
|
* @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2299
|
-
* @param {string}
|
|
2871
|
+
* @param {string} tokenId - The requested token ID.
|
|
2300
2872
|
*
|
|
2301
2873
|
*/
|
|
2302
|
-
async
|
|
2874
|
+
async checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) {
|
|
2303
2875
|
let success = false;
|
|
2304
2876
|
let data;
|
|
2305
2877
|
let response;
|
|
@@ -2311,7 +2883,7 @@ class NftService {
|
|
|
2311
2883
|
if (this.debug) {
|
|
2312
2884
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2313
2885
|
}
|
|
2314
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2886
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
|
|
2315
2887
|
headers: {
|
|
2316
2888
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2317
2889
|
"X-Requested-With": userAgent
|
|
@@ -2335,14 +2907,14 @@ class NftService {
|
|
|
2335
2907
|
else {
|
|
2336
2908
|
data = await response.json();
|
|
2337
2909
|
}
|
|
2338
|
-
const dataClass = new
|
|
2910
|
+
const dataClass = new NftOwnershipForCollectionResponse(data.data);
|
|
2339
2911
|
checkAndModifyResponse(dataClass);
|
|
2340
2912
|
success = true;
|
|
2341
2913
|
return {
|
|
2342
2914
|
data: dataClass,
|
|
2343
2915
|
error: data.error,
|
|
2344
2916
|
error_code: data ? data.error_code : response.status,
|
|
2345
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2917
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2346
2918
|
};
|
|
2347
2919
|
}
|
|
2348
2920
|
catch (error) {
|
|
@@ -2351,20 +2923,23 @@ class NftService {
|
|
|
2351
2923
|
data: null,
|
|
2352
2924
|
error: true,
|
|
2353
2925
|
error_code: data ? data.error_code : response.status,
|
|
2354
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2926
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2355
2927
|
};
|
|
2356
2928
|
}
|
|
2357
2929
|
}
|
|
2358
2930
|
}
|
|
2359
2931
|
/**
|
|
2360
2932
|
*
|
|
2361
|
-
* Commonly used to
|
|
2933
|
+
* Commonly used to build a time-series chart of the sales count of an NFT collection.
|
|
2362
2934
|
*
|
|
2363
2935
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2364
|
-
* @param {string}
|
|
2936
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2937
|
+
* @param {GetNftMarketSaleCountQueryParamOpts} queryParamOpts
|
|
2938
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
2939
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2365
2940
|
*
|
|
2366
2941
|
*/
|
|
2367
|
-
async
|
|
2942
|
+
async getNftMarketSaleCount(chainName, contractAddress, queryParamOpts) {
|
|
2368
2943
|
let success = false;
|
|
2369
2944
|
let data;
|
|
2370
2945
|
let response;
|
|
@@ -2372,11 +2947,17 @@ class NftService {
|
|
|
2372
2947
|
while (!success) {
|
|
2373
2948
|
try {
|
|
2374
2949
|
const urlParams = new URLSearchParams();
|
|
2950
|
+
if (queryParamOpts?.days !== undefined) {
|
|
2951
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
2952
|
+
}
|
|
2953
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
2954
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
2955
|
+
}
|
|
2375
2956
|
let startTime;
|
|
2376
2957
|
if (this.debug) {
|
|
2377
2958
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2378
2959
|
}
|
|
2379
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
2960
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`, {
|
|
2380
2961
|
headers: {
|
|
2381
2962
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2382
2963
|
"X-Requested-With": userAgent
|
|
@@ -2400,14 +2981,14 @@ class NftService {
|
|
|
2400
2981
|
else {
|
|
2401
2982
|
data = await response.json();
|
|
2402
2983
|
}
|
|
2403
|
-
const dataClass = new
|
|
2984
|
+
const dataClass = new NftMarketSaleCountResponse(data.data);
|
|
2404
2985
|
checkAndModifyResponse(dataClass);
|
|
2405
2986
|
success = true;
|
|
2406
2987
|
return {
|
|
2407
2988
|
data: dataClass,
|
|
2408
2989
|
error: data.error,
|
|
2409
2990
|
error_code: data ? data.error_code : response.status,
|
|
2410
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
2991
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2411
2992
|
};
|
|
2412
2993
|
}
|
|
2413
2994
|
catch (error) {
|
|
@@ -2416,21 +2997,23 @@ class NftService {
|
|
|
2416
2997
|
data: null,
|
|
2417
2998
|
error: true,
|
|
2418
2999
|
error_code: data ? data.error_code : response.status,
|
|
2419
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3000
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2420
3001
|
};
|
|
2421
3002
|
}
|
|
2422
3003
|
}
|
|
2423
3004
|
}
|
|
2424
3005
|
/**
|
|
2425
3006
|
*
|
|
2426
|
-
* Commonly used to
|
|
3007
|
+
* Commonly used to build a time-series chart of the transaction volume of an NFT collection.
|
|
2427
3008
|
*
|
|
2428
3009
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2429
|
-
* @param {string}
|
|
2430
|
-
* @param {
|
|
3010
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3011
|
+
* @param {GetNftMarketVolumeQueryParamOpts} queryParamOpts
|
|
3012
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
3013
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2431
3014
|
*
|
|
2432
3015
|
*/
|
|
2433
|
-
async
|
|
3016
|
+
async getNftMarketVolume(chainName, contractAddress, queryParamOpts) {
|
|
2434
3017
|
let success = false;
|
|
2435
3018
|
let data;
|
|
2436
3019
|
let response;
|
|
@@ -2438,11 +3021,17 @@ class NftService {
|
|
|
2438
3021
|
while (!success) {
|
|
2439
3022
|
try {
|
|
2440
3023
|
const urlParams = new URLSearchParams();
|
|
3024
|
+
if (queryParamOpts?.days !== undefined) {
|
|
3025
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3026
|
+
}
|
|
3027
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3028
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3029
|
+
}
|
|
2441
3030
|
let startTime;
|
|
2442
3031
|
if (this.debug) {
|
|
2443
3032
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2444
3033
|
}
|
|
2445
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
3034
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`, {
|
|
2446
3035
|
headers: {
|
|
2447
3036
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2448
3037
|
"X-Requested-With": userAgent
|
|
@@ -2466,14 +3055,14 @@ class NftService {
|
|
|
2466
3055
|
else {
|
|
2467
3056
|
data = await response.json();
|
|
2468
3057
|
}
|
|
2469
|
-
const dataClass = new
|
|
3058
|
+
const dataClass = new NftMarketVolumeResponse(data.data);
|
|
2470
3059
|
checkAndModifyResponse(dataClass);
|
|
2471
3060
|
success = true;
|
|
2472
3061
|
return {
|
|
2473
3062
|
data: dataClass,
|
|
2474
3063
|
error: data.error,
|
|
2475
3064
|
error_code: data ? data.error_code : response.status,
|
|
2476
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3065
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2477
3066
|
};
|
|
2478
3067
|
}
|
|
2479
3068
|
catch (error) {
|
|
@@ -2482,22 +3071,23 @@ class NftService {
|
|
|
2482
3071
|
data: null,
|
|
2483
3072
|
error: true,
|
|
2484
3073
|
error_code: data ? data.error_code : response.status,
|
|
2485
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3074
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2486
3075
|
};
|
|
2487
3076
|
}
|
|
2488
3077
|
}
|
|
2489
3078
|
}
|
|
2490
3079
|
/**
|
|
2491
3080
|
*
|
|
2492
|
-
* Commonly used to
|
|
3081
|
+
* Commonly used to render a price floor chart for an NFT collection.
|
|
2493
3082
|
*
|
|
2494
3083
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2495
|
-
* @param {string}
|
|
2496
|
-
* @param {
|
|
2497
|
-
*
|
|
3084
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3085
|
+
* @param {GetNftMarketFloorPriceQueryParamOpts} queryParamOpts
|
|
3086
|
+
* - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
|
|
3087
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2498
3088
|
*
|
|
2499
3089
|
*/
|
|
2500
|
-
async
|
|
3090
|
+
async getNftMarketFloorPrice(chainName, contractAddress, queryParamOpts) {
|
|
2501
3091
|
let success = false;
|
|
2502
3092
|
let data;
|
|
2503
3093
|
let response;
|
|
@@ -2505,11 +3095,17 @@ class NftService {
|
|
|
2505
3095
|
while (!success) {
|
|
2506
3096
|
try {
|
|
2507
3097
|
const urlParams = new URLSearchParams();
|
|
3098
|
+
if (queryParamOpts?.days !== undefined) {
|
|
3099
|
+
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3100
|
+
}
|
|
3101
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3102
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3103
|
+
}
|
|
2508
3104
|
let startTime;
|
|
2509
3105
|
if (this.debug) {
|
|
2510
3106
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2511
3107
|
}
|
|
2512
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/
|
|
3108
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`, {
|
|
2513
3109
|
headers: {
|
|
2514
3110
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
2515
3111
|
"X-Requested-With": userAgent
|
|
@@ -2533,14 +3129,14 @@ class NftService {
|
|
|
2533
3129
|
else {
|
|
2534
3130
|
data = await response.json();
|
|
2535
3131
|
}
|
|
2536
|
-
const dataClass = new
|
|
3132
|
+
const dataClass = new NftMarketFloorPriceResponse(data.data);
|
|
2537
3133
|
checkAndModifyResponse(dataClass);
|
|
2538
3134
|
success = true;
|
|
2539
3135
|
return {
|
|
2540
3136
|
data: dataClass,
|
|
2541
3137
|
error: data.error,
|
|
2542
3138
|
error_code: data ? data.error_code : response.status,
|
|
2543
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3139
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2544
3140
|
};
|
|
2545
3141
|
}
|
|
2546
3142
|
catch (error) {
|
|
@@ -2549,7 +3145,7 @@ class NftService {
|
|
|
2549
3145
|
data: null,
|
|
2550
3146
|
error: true,
|
|
2551
3147
|
error_code: data ? data.error_code : response.status,
|
|
2552
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3148
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2553
3149
|
};
|
|
2554
3150
|
}
|
|
2555
3151
|
}
|
|
@@ -2664,7 +3260,7 @@ class PricingService {
|
|
|
2664
3260
|
data: res,
|
|
2665
3261
|
error: data.error,
|
|
2666
3262
|
error_code: data ? data.error_code : response.status,
|
|
2667
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3263
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2668
3264
|
};
|
|
2669
3265
|
}
|
|
2670
3266
|
catch (error) {
|
|
@@ -2673,7 +3269,7 @@ class PricingService {
|
|
|
2673
3269
|
data: null,
|
|
2674
3270
|
error: true,
|
|
2675
3271
|
error_code: data ? data.error_code : response.status,
|
|
2676
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3272
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2677
3273
|
};
|
|
2678
3274
|
}
|
|
2679
3275
|
}
|
|
@@ -2716,6 +3312,7 @@ class Transaction {
|
|
|
2716
3312
|
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? new NftSalesReport(data.nft_sale_details) : null;
|
|
2717
3313
|
this.lending_details = data.lending_details && data.lending_details !== null ? new LendingReport(data.lending_details) : null;
|
|
2718
3314
|
this.log_events = data.log_events && data.log_events !== null ? data.log_events.map((itemData) => new LogEvent(itemData)) : null;
|
|
3315
|
+
this.safe_details = data.safe_details && data.safe_details !== null ? data.safe_details.map((itemData) => new SafeDetails(itemData)) : null;
|
|
2719
3316
|
}
|
|
2720
3317
|
}
|
|
2721
3318
|
class ContractMetadata {
|
|
@@ -2862,6 +3459,13 @@ class LogEvent {
|
|
|
2862
3459
|
this.decoded = data.decoded && data.decoded !== null ? new DecodedItem(data.decoded) : null;
|
|
2863
3460
|
}
|
|
2864
3461
|
}
|
|
3462
|
+
class SafeDetails {
|
|
3463
|
+
constructor(data) {
|
|
3464
|
+
this.owner_address = data.owner_address;
|
|
3465
|
+
this.signature = data.signature;
|
|
3466
|
+
this.signature_type = data.signature_type;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
2865
3469
|
class DecodedItem {
|
|
2866
3470
|
constructor(data) {
|
|
2867
3471
|
this.name = data.name;
|
|
@@ -2878,6 +3482,12 @@ class Param {
|
|
|
2878
3482
|
this.value = data.value;
|
|
2879
3483
|
}
|
|
2880
3484
|
}
|
|
3485
|
+
class PaginationLinks {
|
|
3486
|
+
constructor(data) {
|
|
3487
|
+
this.prev = data.prev;
|
|
3488
|
+
this.next = data.next;
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
2881
3491
|
class TransactionsBlockResponse {
|
|
2882
3492
|
constructor(data) {
|
|
2883
3493
|
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
@@ -2909,6 +3519,18 @@ class TransactionSummary {
|
|
|
2909
3519
|
this.tx_detail_link = data.tx_detail_link;
|
|
2910
3520
|
}
|
|
2911
3521
|
}
|
|
3522
|
+
class TransactionsResponse {
|
|
3523
|
+
constructor(data) {
|
|
3524
|
+
this.address = data.address;
|
|
3525
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
3526
|
+
this.quote_currency = data.quote_currency;
|
|
3527
|
+
this.chain_id = data.chain_id;
|
|
3528
|
+
this.chain_name = data.chain_name;
|
|
3529
|
+
this.current_page = data.current_page;
|
|
3530
|
+
this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
|
|
3531
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
2912
3534
|
/**
|
|
2913
3535
|
* Transactions APIs
|
|
2914
3536
|
*
|
|
@@ -2965,7 +3587,7 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
2965
3587
|
if (error.message.includes("An error occurred 429")) {
|
|
2966
3588
|
throw new Error(error.message);
|
|
2967
3589
|
}
|
|
2968
|
-
throw new Error(`An error occurred ${data ? data.error_code : response.status}: ${data ? data.error_message : "401 Authorization Required"}`);
|
|
3590
|
+
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"}`);
|
|
2969
3591
|
}
|
|
2970
3592
|
}
|
|
2971
3593
|
}
|
|
@@ -2988,6 +3610,7 @@ class TransactionService {
|
|
|
2988
3610
|
* - `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.
|
|
2989
3611
|
* - `withNftSales`: Decoded NFT sales details including marketplace (e.g. Opensea) and cached media links. Additional 0.05 credits charged if data available.
|
|
2990
3612
|
* - `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.
|
|
3613
|
+
* - `withSafe`: Include safe details.
|
|
2991
3614
|
*
|
|
2992
3615
|
*/
|
|
2993
3616
|
async getTransaction(chainName, txHash, queryParamOpts) {
|
|
@@ -3013,6 +3636,9 @@ class TransactionService {
|
|
|
3013
3636
|
if (queryParamOpts?.withLending !== undefined) {
|
|
3014
3637
|
urlParams.append("with-lending", queryParamOpts?.withLending.toString());
|
|
3015
3638
|
}
|
|
3639
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3640
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3641
|
+
}
|
|
3016
3642
|
let startTime;
|
|
3017
3643
|
if (this.debug) {
|
|
3018
3644
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3048,7 +3674,7 @@ class TransactionService {
|
|
|
3048
3674
|
data: dataClass,
|
|
3049
3675
|
error: data.error,
|
|
3050
3676
|
error_code: data ? data.error_code : response.status,
|
|
3051
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3677
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3052
3678
|
};
|
|
3053
3679
|
}
|
|
3054
3680
|
catch (error) {
|
|
@@ -3057,7 +3683,7 @@ class TransactionService {
|
|
|
3057
3683
|
data: null,
|
|
3058
3684
|
error: true,
|
|
3059
3685
|
error_code: data ? data.error_code : response.status,
|
|
3060
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3686
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3061
3687
|
};
|
|
3062
3688
|
}
|
|
3063
3689
|
}
|
|
@@ -3072,6 +3698,7 @@ class TransactionService {
|
|
|
3072
3698
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
3073
3699
|
* - `noLogs`: Omit log events.
|
|
3074
3700
|
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
3701
|
+
* - `withSafe`: Include safe details.
|
|
3075
3702
|
*
|
|
3076
3703
|
*/
|
|
3077
3704
|
async *getAllTransactionsForAddress(chainName, walletAddress, queryParamOpts) {
|
|
@@ -3089,6 +3716,9 @@ class TransactionService {
|
|
|
3089
3716
|
if (queryParamOpts?.blockSignedAtAsc !== undefined) {
|
|
3090
3717
|
urlParams.append("block-signed-at-asc", queryParamOpts?.blockSignedAtAsc.toString());
|
|
3091
3718
|
}
|
|
3719
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3720
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3721
|
+
}
|
|
3092
3722
|
for await (tx of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams, this.debug, this.threadCount)) {
|
|
3093
3723
|
yield tx;
|
|
3094
3724
|
}
|
|
@@ -3160,7 +3790,7 @@ class TransactionService {
|
|
|
3160
3790
|
data: dataClass,
|
|
3161
3791
|
error: data.error,
|
|
3162
3792
|
error_code: data ? data.error_code : response.status,
|
|
3163
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3793
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3164
3794
|
};
|
|
3165
3795
|
}
|
|
3166
3796
|
catch (error) {
|
|
@@ -3169,7 +3799,7 @@ class TransactionService {
|
|
|
3169
3799
|
data: null,
|
|
3170
3800
|
error: true,
|
|
3171
3801
|
error_code: data ? data.error_code : response.status,
|
|
3172
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3802
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3173
3803
|
};
|
|
3174
3804
|
}
|
|
3175
3805
|
}
|
|
@@ -3225,7 +3855,88 @@ class TransactionService {
|
|
|
3225
3855
|
data: dataClass,
|
|
3226
3856
|
error: data.error,
|
|
3227
3857
|
error_code: data ? data.error_code : response.status,
|
|
3228
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3858
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3861
|
+
catch (error) {
|
|
3862
|
+
success = true;
|
|
3863
|
+
return {
|
|
3864
|
+
data: null,
|
|
3865
|
+
error: true,
|
|
3866
|
+
error_code: data ? data.error_code : response.status,
|
|
3867
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
/**
|
|
3873
|
+
*
|
|
3874
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
3875
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
3876
|
+
* @param {number} page - The requested page, 0-indexed.
|
|
3877
|
+
* @param {GetTransactionsForAddressV3QueryParamOpts} queryParamOpts
|
|
3878
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
3879
|
+
* - `noLogs`: Omit log events.
|
|
3880
|
+
* - `blockSignedAtAsc`: Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
|
|
3881
|
+
* - `withSafe`: Include safe details.
|
|
3882
|
+
*
|
|
3883
|
+
*/
|
|
3884
|
+
async getTransactionsForAddressV3(chainName, walletAddress, page, queryParamOpts) {
|
|
3885
|
+
let success = false;
|
|
3886
|
+
let data;
|
|
3887
|
+
let response;
|
|
3888
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
3889
|
+
while (!success) {
|
|
3890
|
+
try {
|
|
3891
|
+
const urlParams = new URLSearchParams();
|
|
3892
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3893
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3894
|
+
}
|
|
3895
|
+
if (queryParamOpts?.noLogs !== undefined) {
|
|
3896
|
+
urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
|
|
3897
|
+
}
|
|
3898
|
+
if (queryParamOpts?.blockSignedAtAsc !== undefined) {
|
|
3899
|
+
urlParams.append("block-signed-at-asc", queryParamOpts?.blockSignedAtAsc.toString());
|
|
3900
|
+
}
|
|
3901
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
3902
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
3903
|
+
}
|
|
3904
|
+
let startTime;
|
|
3905
|
+
if (this.debug) {
|
|
3906
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
3907
|
+
}
|
|
3908
|
+
response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
|
|
3909
|
+
headers: {
|
|
3910
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
3911
|
+
"X-Requested-With": userAgent
|
|
3912
|
+
}
|
|
3913
|
+
});
|
|
3914
|
+
debugOutput(response.url, response.status, startTime);
|
|
3915
|
+
if (response.status === 429) {
|
|
3916
|
+
try {
|
|
3917
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3918
|
+
}
|
|
3919
|
+
catch (error) {
|
|
3920
|
+
success = true;
|
|
3921
|
+
return {
|
|
3922
|
+
data: null,
|
|
3923
|
+
error: true,
|
|
3924
|
+
error_code: response.status,
|
|
3925
|
+
error_message: error.message
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
else {
|
|
3930
|
+
data = await response.json();
|
|
3931
|
+
}
|
|
3932
|
+
const dataClass = new TransactionsResponse(data.data);
|
|
3933
|
+
checkAndModifyResponse(dataClass);
|
|
3934
|
+
success = true;
|
|
3935
|
+
return {
|
|
3936
|
+
data: dataClass,
|
|
3937
|
+
error: data.error,
|
|
3938
|
+
error_code: data ? data.error_code : response.status,
|
|
3939
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3229
3940
|
};
|
|
3230
3941
|
}
|
|
3231
3942
|
catch (error) {
|
|
@@ -3234,7 +3945,7 @@ class TransactionService {
|
|
|
3234
3945
|
data: null,
|
|
3235
3946
|
error: true,
|
|
3236
3947
|
error_code: data ? data.error_code : response.status,
|
|
3237
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
3948
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3238
3949
|
};
|
|
3239
3950
|
}
|
|
3240
3951
|
}
|
|
@@ -3696,7 +4407,7 @@ class XykService {
|
|
|
3696
4407
|
data: dataClass,
|
|
3697
4408
|
error: data.error,
|
|
3698
4409
|
error_code: data ? data.error_code : response.status,
|
|
3699
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4410
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3700
4411
|
};
|
|
3701
4412
|
}
|
|
3702
4413
|
catch (error) {
|
|
@@ -3705,7 +4416,7 @@ class XykService {
|
|
|
3705
4416
|
data: null,
|
|
3706
4417
|
error: true,
|
|
3707
4418
|
error_code: data ? data.error_code : response.status,
|
|
3708
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4419
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3709
4420
|
};
|
|
3710
4421
|
}
|
|
3711
4422
|
}
|
|
@@ -3761,7 +4472,7 @@ class XykService {
|
|
|
3761
4472
|
data: dataClass,
|
|
3762
4473
|
error: data.error,
|
|
3763
4474
|
error_code: data ? data.error_code : response.status,
|
|
3764
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4475
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3765
4476
|
};
|
|
3766
4477
|
}
|
|
3767
4478
|
catch (error) {
|
|
@@ -3770,7 +4481,7 @@ class XykService {
|
|
|
3770
4481
|
data: null,
|
|
3771
4482
|
error: true,
|
|
3772
4483
|
error_code: data ? data.error_code : response.status,
|
|
3773
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4484
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3774
4485
|
};
|
|
3775
4486
|
}
|
|
3776
4487
|
}
|
|
@@ -3827,7 +4538,7 @@ class XykService {
|
|
|
3827
4538
|
data: dataClass,
|
|
3828
4539
|
error: data.error,
|
|
3829
4540
|
error_code: data ? data.error_code : response.status,
|
|
3830
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4541
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3831
4542
|
};
|
|
3832
4543
|
}
|
|
3833
4544
|
catch (error) {
|
|
@@ -3836,7 +4547,7 @@ class XykService {
|
|
|
3836
4547
|
data: null,
|
|
3837
4548
|
error: true,
|
|
3838
4549
|
error_code: data ? data.error_code : response.status,
|
|
3839
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4550
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3840
4551
|
};
|
|
3841
4552
|
}
|
|
3842
4553
|
}
|
|
@@ -3863,6 +4574,9 @@ class XykService {
|
|
|
3863
4574
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
3864
4575
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
3865
4576
|
}
|
|
4577
|
+
if (queryParamOpts?.dexName !== undefined) {
|
|
4578
|
+
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
4579
|
+
}
|
|
3866
4580
|
let startTime;
|
|
3867
4581
|
if (this.debug) {
|
|
3868
4582
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3898,7 +4612,7 @@ class XykService {
|
|
|
3898
4612
|
data: dataClass,
|
|
3899
4613
|
error: data.error,
|
|
3900
4614
|
error_code: data ? data.error_code : response.status,
|
|
3901
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4615
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3902
4616
|
};
|
|
3903
4617
|
}
|
|
3904
4618
|
catch (error) {
|
|
@@ -3907,7 +4621,7 @@ class XykService {
|
|
|
3907
4621
|
data: null,
|
|
3908
4622
|
error: true,
|
|
3909
4623
|
error_code: data ? data.error_code : response.status,
|
|
3910
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4624
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3911
4625
|
};
|
|
3912
4626
|
}
|
|
3913
4627
|
}
|
|
@@ -3964,7 +4678,7 @@ class XykService {
|
|
|
3964
4678
|
data: dataClass,
|
|
3965
4679
|
error: data.error,
|
|
3966
4680
|
error_code: data ? data.error_code : response.status,
|
|
3967
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4681
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3968
4682
|
};
|
|
3969
4683
|
}
|
|
3970
4684
|
catch (error) {
|
|
@@ -3973,7 +4687,7 @@ class XykService {
|
|
|
3973
4687
|
data: null,
|
|
3974
4688
|
error: true,
|
|
3975
4689
|
error_code: data ? data.error_code : response.status,
|
|
3976
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4690
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3977
4691
|
};
|
|
3978
4692
|
}
|
|
3979
4693
|
}
|
|
@@ -4004,6 +4718,9 @@ class XykService {
|
|
|
4004
4718
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4005
4719
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4006
4720
|
}
|
|
4721
|
+
if (queryParamOpts?.dexName !== undefined) {
|
|
4722
|
+
urlParams.append("dex-name", queryParamOpts?.dexName.toString());
|
|
4723
|
+
}
|
|
4007
4724
|
let startTime;
|
|
4008
4725
|
if (this.debug) {
|
|
4009
4726
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -4039,7 +4756,7 @@ class XykService {
|
|
|
4039
4756
|
data: dataClass,
|
|
4040
4757
|
error: data.error,
|
|
4041
4758
|
error_code: data ? data.error_code : response.status,
|
|
4042
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4759
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4043
4760
|
};
|
|
4044
4761
|
}
|
|
4045
4762
|
catch (error) {
|
|
@@ -4048,7 +4765,7 @@ class XykService {
|
|
|
4048
4765
|
data: null,
|
|
4049
4766
|
error: true,
|
|
4050
4767
|
error_code: data ? data.error_code : response.status,
|
|
4051
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4768
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4052
4769
|
};
|
|
4053
4770
|
}
|
|
4054
4771
|
}
|
|
@@ -4104,7 +4821,7 @@ class XykService {
|
|
|
4104
4821
|
data: dataClass,
|
|
4105
4822
|
error: data.error,
|
|
4106
4823
|
error_code: data ? data.error_code : response.status,
|
|
4107
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4824
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4108
4825
|
};
|
|
4109
4826
|
}
|
|
4110
4827
|
catch (error) {
|
|
@@ -4113,7 +4830,7 @@ class XykService {
|
|
|
4113
4830
|
data: null,
|
|
4114
4831
|
error: true,
|
|
4115
4832
|
error_code: data ? data.error_code : response.status,
|
|
4116
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4833
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4117
4834
|
};
|
|
4118
4835
|
}
|
|
4119
4836
|
}
|
|
@@ -4167,7 +4884,7 @@ class XykService {
|
|
|
4167
4884
|
data: dataClass,
|
|
4168
4885
|
error: data.error,
|
|
4169
4886
|
error_code: data ? data.error_code : response.status,
|
|
4170
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4887
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4171
4888
|
};
|
|
4172
4889
|
}
|
|
4173
4890
|
catch (error) {
|
|
@@ -4176,7 +4893,7 @@ class XykService {
|
|
|
4176
4893
|
data: null,
|
|
4177
4894
|
error: true,
|
|
4178
4895
|
error_code: data ? data.error_code : response.status,
|
|
4179
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4896
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4180
4897
|
};
|
|
4181
4898
|
}
|
|
4182
4899
|
}
|
|
@@ -4233,7 +4950,7 @@ class XykService {
|
|
|
4233
4950
|
data: dataClass,
|
|
4234
4951
|
error: data.error,
|
|
4235
4952
|
error_code: data ? data.error_code : response.status,
|
|
4236
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4953
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4237
4954
|
};
|
|
4238
4955
|
}
|
|
4239
4956
|
catch (error) {
|
|
@@ -4242,7 +4959,7 @@ class XykService {
|
|
|
4242
4959
|
data: null,
|
|
4243
4960
|
error: true,
|
|
4244
4961
|
error_code: data ? data.error_code : response.status,
|
|
4245
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
4962
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4246
4963
|
};
|
|
4247
4964
|
}
|
|
4248
4965
|
}
|
|
@@ -4299,7 +5016,7 @@ class XykService {
|
|
|
4299
5016
|
data: dataClass,
|
|
4300
5017
|
error: data.error,
|
|
4301
5018
|
error_code: data ? data.error_code : response.status,
|
|
4302
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5019
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4303
5020
|
};
|
|
4304
5021
|
}
|
|
4305
5022
|
catch (error) {
|
|
@@ -4308,7 +5025,7 @@ class XykService {
|
|
|
4308
5025
|
data: null,
|
|
4309
5026
|
error: true,
|
|
4310
5027
|
error_code: data ? data.error_code : response.status,
|
|
4311
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5028
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4312
5029
|
};
|
|
4313
5030
|
}
|
|
4314
5031
|
}
|
|
@@ -4365,7 +5082,7 @@ class XykService {
|
|
|
4365
5082
|
data: dataClass,
|
|
4366
5083
|
error: data.error,
|
|
4367
5084
|
error_code: data ? data.error_code : response.status,
|
|
4368
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5085
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4369
5086
|
};
|
|
4370
5087
|
}
|
|
4371
5088
|
catch (error) {
|
|
@@ -4374,7 +5091,7 @@ class XykService {
|
|
|
4374
5091
|
data: null,
|
|
4375
5092
|
error: true,
|
|
4376
5093
|
error_code: data ? data.error_code : response.status,
|
|
4377
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5094
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4378
5095
|
};
|
|
4379
5096
|
}
|
|
4380
5097
|
}
|
|
@@ -4431,7 +5148,7 @@ class XykService {
|
|
|
4431
5148
|
data: dataClass,
|
|
4432
5149
|
error: data.error,
|
|
4433
5150
|
error_code: data ? data.error_code : response.status,
|
|
4434
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5151
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4435
5152
|
};
|
|
4436
5153
|
}
|
|
4437
5154
|
catch (error) {
|
|
@@ -4440,7 +5157,7 @@ class XykService {
|
|
|
4440
5157
|
data: null,
|
|
4441
5158
|
error: true,
|
|
4442
5159
|
error_code: data ? data.error_code : response.status,
|
|
4443
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5160
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4444
5161
|
};
|
|
4445
5162
|
}
|
|
4446
5163
|
}
|
|
@@ -4496,7 +5213,7 @@ class XykService {
|
|
|
4496
5213
|
data: dataClass,
|
|
4497
5214
|
error: data.error,
|
|
4498
5215
|
error_code: data ? data.error_code : response.status,
|
|
4499
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5216
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4500
5217
|
};
|
|
4501
5218
|
}
|
|
4502
5219
|
catch (error) {
|
|
@@ -4505,7 +5222,7 @@ class XykService {
|
|
|
4505
5222
|
data: null,
|
|
4506
5223
|
error: true,
|
|
4507
5224
|
error_code: data ? data.error_code : response.status,
|
|
4508
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5225
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4509
5226
|
};
|
|
4510
5227
|
}
|
|
4511
5228
|
}
|
|
@@ -4561,7 +5278,7 @@ class XykService {
|
|
|
4561
5278
|
data: dataClass,
|
|
4562
5279
|
error: data.error,
|
|
4563
5280
|
error_code: data ? data.error_code : response.status,
|
|
4564
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5281
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4565
5282
|
};
|
|
4566
5283
|
}
|
|
4567
5284
|
catch (error) {
|
|
@@ -4570,14 +5287,14 @@ class XykService {
|
|
|
4570
5287
|
data: null,
|
|
4571
5288
|
error: true,
|
|
4572
5289
|
error_code: data ? data.error_code : response.status,
|
|
4573
|
-
error_message: data ? data.error_message : "401 Authorization Required"
|
|
5290
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
4574
5291
|
};
|
|
4575
5292
|
}
|
|
4576
5293
|
}
|
|
4577
5294
|
}
|
|
4578
5295
|
}
|
|
4579
5296
|
|
|
4580
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
5297
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.5.2";
|
|
4581
5298
|
/**
|
|
4582
5299
|
* CovalentClient Class
|
|
4583
5300
|
*/
|