@covalenthq/client-sdk 0.5.2 → 0.6.0
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 +12 -6
- package/dist/cjs/index.js +582 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +31 -1
- package/dist/cjs/services/BaseService.d.ts +94 -2
- package/dist/cjs/services/CovalentClient.d.ts +1 -1
- package/dist/cjs/services/NftService.d.ts +48 -1
- package/dist/cjs/services/TransactionService.d.ts +4 -1
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +1 -1
- package/dist/cjs/util/types/GenericTypes.d.ts +1 -1
- package/dist/cjs/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/es/index.js +582 -26
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +31 -1
- package/dist/es/services/BaseService.d.ts +94 -2
- package/dist/es/services/CovalentClient.d.ts +1 -1
- package/dist/es/services/NftService.d.ts +48 -1
- package/dist/es/services/TransactionService.d.ts +4 -1
- package/dist/es/util/types/BaseServiceTypes.d.ts +1 -1
- package/dist/es/util/types/GenericTypes.d.ts +1 -1
- package/dist/es/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/esm/index.js +582 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +31 -1
- package/dist/esm/services/BaseService.d.ts +94 -2
- package/dist/esm/services/CovalentClient.d.ts +1 -1
- package/dist/esm/services/NftService.d.ts +48 -1
- package/dist/esm/services/TransactionService.d.ts +4 -1
- package/dist/esm/util/types/BaseServiceTypes.d.ts +1 -1
- package/dist/esm/util/types/GenericTypes.d.ts +1 -1
- package/dist/esm/util/types/NftServiceTypes.d.ts +6 -0
- package/dist/services/BalanceService.d.ts +31 -1
- package/dist/services/BalanceService.js +86 -0
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +94 -2
- package/dist/services/BaseService.js +243 -0
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +1 -1
- package/dist/services/CovalentClient.js +1 -1
- package/dist/services/NftService.d.ts +48 -1
- package/dist/services/NftService.js +170 -0
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +4 -1
- package/dist/services/TransactionService.js +4 -0
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/types/BaseServiceTypes.d.ts +1 -1
- package/dist/util/types/GenericTypes.d.ts +1 -1
- package/dist/util/types/NftServiceTypes.d.ts +6 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -617,7 +617,7 @@ class Erc20TransfersResponse {
|
|
|
617
617
|
this.chain_id = data.chain_id;
|
|
618
618
|
this.chain_name = data.chain_name;
|
|
619
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$
|
|
620
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$3(data.pagination) : null;
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
class BlockTransactionWithContractTransfers {
|
|
@@ -644,7 +644,7 @@ class BlockTransactionWithContractTransfers {
|
|
|
644
644
|
this.transfers = data.transfers && data.transfers !== null ? data.transfers.map((itemData) => new TokenTransferItem(itemData)) : null;
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
let Pagination$
|
|
647
|
+
let Pagination$3 = class Pagination {
|
|
648
648
|
constructor(data) {
|
|
649
649
|
this.has_more = data.has_more;
|
|
650
650
|
this.page_number = data.page_number;
|
|
@@ -681,6 +681,15 @@ class MethodCallsForTransfers {
|
|
|
681
681
|
this.method = data.method;
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
|
+
class TokenHoldersResponse {
|
|
685
|
+
constructor(data) {
|
|
686
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
687
|
+
this.chain_id = data.chain_id;
|
|
688
|
+
this.chain_name = data.chain_name;
|
|
689
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenHolder(itemData)) : null;
|
|
690
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$3(data.pagination) : null;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
684
693
|
class TokenHolder {
|
|
685
694
|
constructor(data) {
|
|
686
695
|
this.contract_decimals = data.contract_decimals;
|
|
@@ -1072,6 +1081,7 @@ class BalanceService {
|
|
|
1072
1081
|
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
1073
1082
|
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
1074
1083
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1084
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
1075
1085
|
*
|
|
1076
1086
|
*/
|
|
1077
1087
|
async *getTokenHoldersV2ForTokenAddress(chainName, tokenAddress, queryParamOpts) {
|
|
@@ -1089,6 +1099,9 @@ class BalanceService {
|
|
|
1089
1099
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1090
1100
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1091
1101
|
}
|
|
1102
|
+
if (queryParamOpts?.date !== undefined) {
|
|
1103
|
+
urlParams.append("date", queryParamOpts?.date.toString());
|
|
1104
|
+
}
|
|
1092
1105
|
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount)) {
|
|
1093
1106
|
yield res;
|
|
1094
1107
|
}
|
|
@@ -1100,6 +1113,88 @@ class BalanceService {
|
|
|
1100
1113
|
}
|
|
1101
1114
|
}
|
|
1102
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
*
|
|
1118
|
+
* 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.
|
|
1119
|
+
*
|
|
1120
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1121
|
+
* @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1122
|
+
* @param {GetTokenHoldersV2ForTokenAddressQueryParamOpts} queryParamOpts
|
|
1123
|
+
* - `blockHeight`: Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
1124
|
+
* - `pageSize`: Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
1125
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1126
|
+
* - `date`: Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
1127
|
+
*
|
|
1128
|
+
*/
|
|
1129
|
+
async getTokenHoldersV2ForTokenAddressByPage(chainName, tokenAddress, queryParamOpts) {
|
|
1130
|
+
let success = false;
|
|
1131
|
+
let data;
|
|
1132
|
+
let response;
|
|
1133
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1134
|
+
while (!success) {
|
|
1135
|
+
try {
|
|
1136
|
+
const urlParams = new URLSearchParams();
|
|
1137
|
+
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1138
|
+
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1139
|
+
}
|
|
1140
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1141
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1142
|
+
}
|
|
1143
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1144
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1145
|
+
}
|
|
1146
|
+
if (queryParamOpts?.date !== undefined) {
|
|
1147
|
+
urlParams.append("date", queryParamOpts?.date.toString());
|
|
1148
|
+
}
|
|
1149
|
+
let startTime;
|
|
1150
|
+
if (this.debug) {
|
|
1151
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1152
|
+
}
|
|
1153
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
|
|
1154
|
+
headers: {
|
|
1155
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1156
|
+
"X-Requested-With": userAgent
|
|
1157
|
+
}
|
|
1158
|
+
}));
|
|
1159
|
+
debugOutput(response.url, response.status, startTime);
|
|
1160
|
+
if (response.status === 429) {
|
|
1161
|
+
try {
|
|
1162
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1163
|
+
}
|
|
1164
|
+
catch (error) {
|
|
1165
|
+
success = true;
|
|
1166
|
+
return {
|
|
1167
|
+
data: null,
|
|
1168
|
+
error: true,
|
|
1169
|
+
error_code: response.status,
|
|
1170
|
+
error_message: error.message
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
data = await response.json();
|
|
1176
|
+
}
|
|
1177
|
+
const dataClass = new TokenHoldersResponse(data.data);
|
|
1178
|
+
checkAndModifyResponse(dataClass);
|
|
1179
|
+
success = true;
|
|
1180
|
+
return {
|
|
1181
|
+
data: dataClass,
|
|
1182
|
+
error: data.error,
|
|
1183
|
+
error_code: data ? data.error_code : response.status,
|
|
1184
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
catch (error) {
|
|
1188
|
+
success = true;
|
|
1189
|
+
return {
|
|
1190
|
+
data: null,
|
|
1191
|
+
error: true,
|
|
1192
|
+
error_code: data ? data.error_code : response.status,
|
|
1193
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1103
1198
|
/**
|
|
1104
1199
|
*
|
|
1105
1200
|
* Commonly used to fetch the historical native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
|
|
@@ -1296,6 +1391,23 @@ class ResolvedAddressItem {
|
|
|
1296
1391
|
this.name = data.name;
|
|
1297
1392
|
}
|
|
1298
1393
|
}
|
|
1394
|
+
class BlockHeightsResponse {
|
|
1395
|
+
constructor(data) {
|
|
1396
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1397
|
+
this.chain_id = data.chain_id;
|
|
1398
|
+
this.chain_name = data.chain_name;
|
|
1399
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new Block(itemData)) : null;
|
|
1400
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$2(data.pagination) : null;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
let Pagination$2 = class Pagination {
|
|
1404
|
+
constructor(data) {
|
|
1405
|
+
this.has_more = data.has_more;
|
|
1406
|
+
this.page_number = data.page_number;
|
|
1407
|
+
this.page_size = data.page_size;
|
|
1408
|
+
this.total_count = data.total_count;
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1299
1411
|
class GetLogsResponse {
|
|
1300
1412
|
constructor(data) {
|
|
1301
1413
|
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
@@ -1339,6 +1451,15 @@ let Param$2 = class Param {
|
|
|
1339
1451
|
this.value = data.value;
|
|
1340
1452
|
}
|
|
1341
1453
|
};
|
|
1454
|
+
class LogEventsByAddressResponse {
|
|
1455
|
+
constructor(data) {
|
|
1456
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1457
|
+
this.chain_id = data.chain_id;
|
|
1458
|
+
this.chain_name = data.chain_name;
|
|
1459
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new LogEvent$2(itemData)) : null;
|
|
1460
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$2(data.pagination) : null;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1342
1463
|
let LogEvent$2 = class LogEvent {
|
|
1343
1464
|
constructor(data) {
|
|
1344
1465
|
this.block_signed_at = data.block_signed_at && data.block_signed_at !== null ? parseISO(data.block_signed_at.toString()) : null;
|
|
@@ -1357,6 +1478,15 @@ let LogEvent$2 = class LogEvent {
|
|
|
1357
1478
|
this.decoded = data.decoded && data.decoded !== null ? new DecodedItem$2(data.decoded) : null;
|
|
1358
1479
|
}
|
|
1359
1480
|
};
|
|
1481
|
+
class LogEventsByTopicHashResponse {
|
|
1482
|
+
constructor(data) {
|
|
1483
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1484
|
+
this.chain_id = data.chain_id;
|
|
1485
|
+
this.chain_name = data.chain_name;
|
|
1486
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new LogEvent$2(itemData)) : null;
|
|
1487
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$2(data.pagination) : null;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1360
1490
|
class AllChainsResponse {
|
|
1361
1491
|
constructor(data) {
|
|
1362
1492
|
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
@@ -1598,6 +1728,81 @@ class BaseService {
|
|
|
1598
1728
|
}
|
|
1599
1729
|
}
|
|
1600
1730
|
}
|
|
1731
|
+
/**
|
|
1732
|
+
*
|
|
1733
|
+
* Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
|
|
1734
|
+
*
|
|
1735
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1736
|
+
* @param {string} startDate - The start date in YYYY-MM-DD format.
|
|
1737
|
+
* @param {string} endDate - The end date in YYYY-MM-DD format.
|
|
1738
|
+
* @param {GetBlockHeightsQueryParamOpts} queryParamOpts
|
|
1739
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
1740
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1741
|
+
*
|
|
1742
|
+
*/
|
|
1743
|
+
async getBlockHeightsByPage(chainName, startDate, endDate, queryParamOpts) {
|
|
1744
|
+
let success = false;
|
|
1745
|
+
let data;
|
|
1746
|
+
let response;
|
|
1747
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1748
|
+
while (!success) {
|
|
1749
|
+
try {
|
|
1750
|
+
const urlParams = new URLSearchParams();
|
|
1751
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1752
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1753
|
+
}
|
|
1754
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1755
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1756
|
+
}
|
|
1757
|
+
let startTime;
|
|
1758
|
+
if (this.debug) {
|
|
1759
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1760
|
+
}
|
|
1761
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/?${urlParams}`, {
|
|
1762
|
+
headers: {
|
|
1763
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1764
|
+
"X-Requested-With": userAgent
|
|
1765
|
+
}
|
|
1766
|
+
}));
|
|
1767
|
+
debugOutput(response.url, response.status, startTime);
|
|
1768
|
+
if (response.status === 429) {
|
|
1769
|
+
try {
|
|
1770
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1771
|
+
}
|
|
1772
|
+
catch (error) {
|
|
1773
|
+
success = true;
|
|
1774
|
+
return {
|
|
1775
|
+
data: null,
|
|
1776
|
+
error: true,
|
|
1777
|
+
error_code: response.status,
|
|
1778
|
+
error_message: error.message
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
else {
|
|
1783
|
+
data = await response.json();
|
|
1784
|
+
}
|
|
1785
|
+
const dataClass = new BlockHeightsResponse(data.data);
|
|
1786
|
+
checkAndModifyResponse(dataClass);
|
|
1787
|
+
success = true;
|
|
1788
|
+
return {
|
|
1789
|
+
data: dataClass,
|
|
1790
|
+
error: data.error,
|
|
1791
|
+
error_code: data ? data.error_code : response.status,
|
|
1792
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
catch (error) {
|
|
1796
|
+
success = true;
|
|
1797
|
+
return {
|
|
1798
|
+
data: null,
|
|
1799
|
+
error: true,
|
|
1800
|
+
error_code: data ? data.error_code : response.status,
|
|
1801
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1601
1806
|
/**
|
|
1602
1807
|
*
|
|
1603
1808
|
* Commonly used to get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
|
|
@@ -1612,7 +1817,137 @@ class BaseService {
|
|
|
1612
1817
|
* - `skipDecode`: Omit decoded log events.
|
|
1613
1818
|
*
|
|
1614
1819
|
*/
|
|
1615
|
-
async getLogs(chainName, queryParamOpts) {
|
|
1820
|
+
async getLogs(chainName, queryParamOpts) {
|
|
1821
|
+
let success = false;
|
|
1822
|
+
let data;
|
|
1823
|
+
let response;
|
|
1824
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1825
|
+
while (!success) {
|
|
1826
|
+
try {
|
|
1827
|
+
const urlParams = new URLSearchParams();
|
|
1828
|
+
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1829
|
+
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1830
|
+
}
|
|
1831
|
+
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1832
|
+
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1833
|
+
}
|
|
1834
|
+
if (queryParamOpts?.address !== undefined) {
|
|
1835
|
+
urlParams.append("address", queryParamOpts?.address.toString());
|
|
1836
|
+
}
|
|
1837
|
+
if (queryParamOpts?.topics !== undefined) {
|
|
1838
|
+
urlParams.append("topics", queryParamOpts?.topics.toString());
|
|
1839
|
+
}
|
|
1840
|
+
if (queryParamOpts?.blockHash !== undefined) {
|
|
1841
|
+
urlParams.append("block-hash", queryParamOpts?.blockHash.toString());
|
|
1842
|
+
}
|
|
1843
|
+
if (queryParamOpts?.skipDecode !== undefined) {
|
|
1844
|
+
urlParams.append("skip-decode", queryParamOpts?.skipDecode.toString());
|
|
1845
|
+
}
|
|
1846
|
+
let startTime;
|
|
1847
|
+
if (this.debug) {
|
|
1848
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1849
|
+
}
|
|
1850
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, {
|
|
1851
|
+
headers: {
|
|
1852
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
1853
|
+
"X-Requested-With": userAgent
|
|
1854
|
+
}
|
|
1855
|
+
}));
|
|
1856
|
+
debugOutput(response.url, response.status, startTime);
|
|
1857
|
+
if (response.status === 429) {
|
|
1858
|
+
try {
|
|
1859
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1860
|
+
}
|
|
1861
|
+
catch (error) {
|
|
1862
|
+
success = true;
|
|
1863
|
+
return {
|
|
1864
|
+
data: null,
|
|
1865
|
+
error: true,
|
|
1866
|
+
error_code: response.status,
|
|
1867
|
+
error_message: error.message
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
else {
|
|
1872
|
+
data = await response.json();
|
|
1873
|
+
}
|
|
1874
|
+
const dataClass = new GetLogsResponse(data.data);
|
|
1875
|
+
checkAndModifyResponse(dataClass);
|
|
1876
|
+
success = true;
|
|
1877
|
+
return {
|
|
1878
|
+
data: dataClass,
|
|
1879
|
+
error: data.error,
|
|
1880
|
+
error_code: data ? data.error_code : response.status,
|
|
1881
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
catch (error) {
|
|
1885
|
+
success = true;
|
|
1886
|
+
return {
|
|
1887
|
+
data: null,
|
|
1888
|
+
error: true,
|
|
1889
|
+
error_code: data ? data.error_code : response.status,
|
|
1890
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
*
|
|
1897
|
+
* Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
|
|
1898
|
+
*
|
|
1899
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1900
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1901
|
+
* @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
|
|
1902
|
+
* - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
1903
|
+
* - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
1904
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
1905
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1906
|
+
*
|
|
1907
|
+
*/
|
|
1908
|
+
async *getLogEventsByAddress(chainName, contractAddress, queryParamOpts) {
|
|
1909
|
+
let success = false;
|
|
1910
|
+
let res;
|
|
1911
|
+
while (!success) {
|
|
1912
|
+
try {
|
|
1913
|
+
const urlParams = new URLSearchParams();
|
|
1914
|
+
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1915
|
+
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1916
|
+
}
|
|
1917
|
+
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1918
|
+
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1919
|
+
}
|
|
1920
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1921
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1922
|
+
}
|
|
1923
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1924
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1925
|
+
}
|
|
1926
|
+
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount)) {
|
|
1927
|
+
yield res;
|
|
1928
|
+
}
|
|
1929
|
+
success = true;
|
|
1930
|
+
}
|
|
1931
|
+
catch (error) {
|
|
1932
|
+
success = true;
|
|
1933
|
+
throw new Error(error.message);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
*
|
|
1939
|
+
* Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
|
|
1940
|
+
*
|
|
1941
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1942
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
1943
|
+
* @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
|
|
1944
|
+
* - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
1945
|
+
* - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
1946
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
1947
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1948
|
+
*
|
|
1949
|
+
*/
|
|
1950
|
+
async getLogEventsByAddressByPage(chainName, contractAddress, queryParamOpts) {
|
|
1616
1951
|
let success = false;
|
|
1617
1952
|
let data;
|
|
1618
1953
|
let response;
|
|
@@ -1626,23 +1961,17 @@ class BaseService {
|
|
|
1626
1961
|
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1627
1962
|
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1628
1963
|
}
|
|
1629
|
-
if (queryParamOpts?.
|
|
1630
|
-
urlParams.append("
|
|
1631
|
-
}
|
|
1632
|
-
if (queryParamOpts?.topics !== undefined) {
|
|
1633
|
-
urlParams.append("topics", queryParamOpts?.topics.toString());
|
|
1634
|
-
}
|
|
1635
|
-
if (queryParamOpts?.blockHash !== undefined) {
|
|
1636
|
-
urlParams.append("block-hash", queryParamOpts?.blockHash.toString());
|
|
1964
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
1965
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1637
1966
|
}
|
|
1638
|
-
if (queryParamOpts?.
|
|
1639
|
-
urlParams.append("
|
|
1967
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1968
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1640
1969
|
}
|
|
1641
1970
|
let startTime;
|
|
1642
1971
|
if (this.debug) {
|
|
1643
1972
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
1644
1973
|
}
|
|
1645
|
-
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, {
|
|
1974
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/?${urlParams}`, {
|
|
1646
1975
|
headers: {
|
|
1647
1976
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
1648
1977
|
"X-Requested-With": userAgent
|
|
@@ -1666,7 +1995,7 @@ class BaseService {
|
|
|
1666
1995
|
else {
|
|
1667
1996
|
data = await response.json();
|
|
1668
1997
|
}
|
|
1669
|
-
const dataClass = new
|
|
1998
|
+
const dataClass = new LogEventsByAddressResponse(data.data);
|
|
1670
1999
|
checkAndModifyResponse(dataClass);
|
|
1671
2000
|
success = true;
|
|
1672
2001
|
return {
|
|
@@ -1689,18 +2018,19 @@ class BaseService {
|
|
|
1689
2018
|
}
|
|
1690
2019
|
/**
|
|
1691
2020
|
*
|
|
1692
|
-
* Commonly used to get all
|
|
2021
|
+
* Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain.
|
|
1693
2022
|
*
|
|
1694
2023
|
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
1695
|
-
* @param {string}
|
|
1696
|
-
* @param {
|
|
2024
|
+
* @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
|
|
2025
|
+
* @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
|
|
1697
2026
|
* - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
1698
2027
|
* - `endingBlock`: The last block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
|
|
2028
|
+
* - `secondaryTopics`: Additional topic hash(es) to filter on - padded & unpadded address fields are supported. Separate multiple topics with a comma.
|
|
1699
2029
|
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
1700
2030
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1701
2031
|
*
|
|
1702
2032
|
*/
|
|
1703
|
-
async *
|
|
2033
|
+
async *getLogEventsByTopicHash(chainName, topicHash, queryParamOpts) {
|
|
1704
2034
|
let success = false;
|
|
1705
2035
|
let res;
|
|
1706
2036
|
while (!success) {
|
|
@@ -1712,13 +2042,16 @@ class BaseService {
|
|
|
1712
2042
|
if (queryParamOpts?.endingBlock !== undefined) {
|
|
1713
2043
|
urlParams.append("ending-block", queryParamOpts?.endingBlock.toString());
|
|
1714
2044
|
}
|
|
2045
|
+
if (queryParamOpts?.secondaryTopics !== undefined) {
|
|
2046
|
+
urlParams.append("secondary-topics", queryParamOpts?.secondaryTopics.toString());
|
|
2047
|
+
}
|
|
1715
2048
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
1716
2049
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1717
2050
|
}
|
|
1718
2051
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1719
2052
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1720
2053
|
}
|
|
1721
|
-
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/
|
|
2054
|
+
for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount)) {
|
|
1722
2055
|
yield res;
|
|
1723
2056
|
}
|
|
1724
2057
|
success = true;
|
|
@@ -1743,9 +2076,11 @@ class BaseService {
|
|
|
1743
2076
|
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
1744
2077
|
*
|
|
1745
2078
|
*/
|
|
1746
|
-
async
|
|
2079
|
+
async getLogEventsByTopicHashByPage(chainName, topicHash, queryParamOpts) {
|
|
1747
2080
|
let success = false;
|
|
1748
|
-
let
|
|
2081
|
+
let data;
|
|
2082
|
+
let response;
|
|
2083
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
1749
2084
|
while (!success) {
|
|
1750
2085
|
try {
|
|
1751
2086
|
const urlParams = new URLSearchParams();
|
|
@@ -1764,14 +2099,52 @@ class BaseService {
|
|
|
1764
2099
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
1765
2100
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
1766
2101
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
2102
|
+
let startTime;
|
|
2103
|
+
if (this.debug) {
|
|
2104
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2105
|
+
}
|
|
2106
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/?${urlParams}`, {
|
|
2107
|
+
headers: {
|
|
2108
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2109
|
+
"X-Requested-With": userAgent
|
|
2110
|
+
}
|
|
2111
|
+
}));
|
|
2112
|
+
debugOutput(response.url, response.status, startTime);
|
|
2113
|
+
if (response.status === 429) {
|
|
2114
|
+
try {
|
|
2115
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2116
|
+
}
|
|
2117
|
+
catch (error) {
|
|
2118
|
+
success = true;
|
|
2119
|
+
return {
|
|
2120
|
+
data: null,
|
|
2121
|
+
error: true,
|
|
2122
|
+
error_code: response.status,
|
|
2123
|
+
error_message: error.message
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
data = await response.json();
|
|
1769
2129
|
}
|
|
2130
|
+
const dataClass = new LogEventsByTopicHashResponse(data.data);
|
|
2131
|
+
checkAndModifyResponse(dataClass);
|
|
1770
2132
|
success = true;
|
|
2133
|
+
return {
|
|
2134
|
+
data: dataClass,
|
|
2135
|
+
error: data.error,
|
|
2136
|
+
error_code: data ? data.error_code : response.status,
|
|
2137
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2138
|
+
};
|
|
1771
2139
|
}
|
|
1772
2140
|
catch (error) {
|
|
1773
2141
|
success = true;
|
|
1774
|
-
|
|
2142
|
+
return {
|
|
2143
|
+
data: null,
|
|
2144
|
+
error: true,
|
|
2145
|
+
error_code: data ? data.error_code : response.status,
|
|
2146
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2147
|
+
};
|
|
1775
2148
|
}
|
|
1776
2149
|
}
|
|
1777
2150
|
}
|
|
@@ -1972,6 +2345,15 @@ class BaseService {
|
|
|
1972
2345
|
}
|
|
1973
2346
|
}
|
|
1974
2347
|
|
|
2348
|
+
class ChainCollectionResponse {
|
|
2349
|
+
constructor(data) {
|
|
2350
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
2351
|
+
this.chain_id = data.chain_id;
|
|
2352
|
+
this.chain_name = data.chain_name;
|
|
2353
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new ChainCollectionItem(itemData)) : null;
|
|
2354
|
+
this.pagination = data.pagination && data.pagination !== null ? new Pagination$1(data.pagination) : null;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
1975
2357
|
class ChainCollectionItem {
|
|
1976
2358
|
constructor(data) {
|
|
1977
2359
|
this.contract_address = data.contract_address;
|
|
@@ -2009,6 +2391,9 @@ class NftTokenContractBalanceItem {
|
|
|
2009
2391
|
this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
|
|
2010
2392
|
this.balance_24h = data.balance_24h;
|
|
2011
2393
|
this.type = data.type;
|
|
2394
|
+
this.floor_price_quote = data.floor_price_quote;
|
|
2395
|
+
this.pretty_floor_price_quote = data.pretty_floor_price_quote;
|
|
2396
|
+
this.floor_price_native_quote = data.floor_price_native_quote;
|
|
2012
2397
|
this.nft_data = data.nft_data && data.nft_data !== null ? data.nft_data.map((itemData) => new NftData(itemData)) : null;
|
|
2013
2398
|
}
|
|
2014
2399
|
}
|
|
@@ -2325,6 +2710,83 @@ class NftService {
|
|
|
2325
2710
|
}
|
|
2326
2711
|
}
|
|
2327
2712
|
}
|
|
2713
|
+
/**
|
|
2714
|
+
*
|
|
2715
|
+
* Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
|
|
2716
|
+
*
|
|
2717
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2718
|
+
* @param {GetChainCollectionsQueryParamOpts} queryParamOpts
|
|
2719
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2720
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2721
|
+
* - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
2722
|
+
*
|
|
2723
|
+
*/
|
|
2724
|
+
async getChainCollectionsByPage(chainName, queryParamOpts) {
|
|
2725
|
+
let success = false;
|
|
2726
|
+
let data;
|
|
2727
|
+
let response;
|
|
2728
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2729
|
+
while (!success) {
|
|
2730
|
+
try {
|
|
2731
|
+
const urlParams = new URLSearchParams();
|
|
2732
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
2733
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2734
|
+
}
|
|
2735
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2736
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2737
|
+
}
|
|
2738
|
+
if (queryParamOpts?.noSpam !== undefined) {
|
|
2739
|
+
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2740
|
+
}
|
|
2741
|
+
let startTime;
|
|
2742
|
+
if (this.debug) {
|
|
2743
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2744
|
+
}
|
|
2745
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, {
|
|
2746
|
+
headers: {
|
|
2747
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2748
|
+
"X-Requested-With": userAgent
|
|
2749
|
+
}
|
|
2750
|
+
}));
|
|
2751
|
+
debugOutput(response.url, response.status, startTime);
|
|
2752
|
+
if (response.status === 429) {
|
|
2753
|
+
try {
|
|
2754
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2755
|
+
}
|
|
2756
|
+
catch (error) {
|
|
2757
|
+
success = true;
|
|
2758
|
+
return {
|
|
2759
|
+
data: null,
|
|
2760
|
+
error: true,
|
|
2761
|
+
error_code: response.status,
|
|
2762
|
+
error_message: error.message
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
else {
|
|
2767
|
+
data = await response.json();
|
|
2768
|
+
}
|
|
2769
|
+
const dataClass = new ChainCollectionResponse(data.data);
|
|
2770
|
+
checkAndModifyResponse(dataClass);
|
|
2771
|
+
success = true;
|
|
2772
|
+
return {
|
|
2773
|
+
data: dataClass,
|
|
2774
|
+
error: data.error,
|
|
2775
|
+
error_code: data ? data.error_code : response.status,
|
|
2776
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
catch (error) {
|
|
2780
|
+
success = true;
|
|
2781
|
+
return {
|
|
2782
|
+
data: null,
|
|
2783
|
+
error: true,
|
|
2784
|
+
error_code: data ? data.error_code : response.status,
|
|
2785
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2328
2790
|
/**
|
|
2329
2791
|
*
|
|
2330
2792
|
* Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
|
|
@@ -2453,6 +2915,96 @@ class NftService {
|
|
|
2453
2915
|
}
|
|
2454
2916
|
}
|
|
2455
2917
|
}
|
|
2918
|
+
/**
|
|
2919
|
+
*
|
|
2920
|
+
* Commonly used to get NFT token IDs with metadata from a collection. Useful for building NFT card displays.
|
|
2921
|
+
*
|
|
2922
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2923
|
+
* @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
2924
|
+
* @param {GetTokenIdsForContractWithMetadataQueryParamOpts} queryParamOpts
|
|
2925
|
+
* - `noMetadata`: Omit metadata.
|
|
2926
|
+
* - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
|
|
2927
|
+
* - `pageNumber`: 0-indexed page number to begin pagination.
|
|
2928
|
+
* - `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.
|
|
2929
|
+
* - `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.
|
|
2930
|
+
* - `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.
|
|
2931
|
+
*
|
|
2932
|
+
*/
|
|
2933
|
+
async getTokenIdsForContractWithMetadataByPage(chainName, contractAddress, queryParamOpts) {
|
|
2934
|
+
let success = false;
|
|
2935
|
+
let data;
|
|
2936
|
+
let response;
|
|
2937
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2938
|
+
while (!success) {
|
|
2939
|
+
try {
|
|
2940
|
+
const urlParams = new URLSearchParams();
|
|
2941
|
+
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2942
|
+
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2943
|
+
}
|
|
2944
|
+
if (queryParamOpts?.pageSize !== undefined) {
|
|
2945
|
+
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2946
|
+
}
|
|
2947
|
+
if (queryParamOpts?.pageNumber !== undefined) {
|
|
2948
|
+
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
2949
|
+
}
|
|
2950
|
+
if (queryParamOpts?.traitsFilter !== undefined) {
|
|
2951
|
+
urlParams.append("traits-filter", queryParamOpts?.traitsFilter.toString());
|
|
2952
|
+
}
|
|
2953
|
+
if (queryParamOpts?.valuesFilter !== undefined) {
|
|
2954
|
+
urlParams.append("values-filter", queryParamOpts?.valuesFilter.toString());
|
|
2955
|
+
}
|
|
2956
|
+
if (queryParamOpts?.withUncached !== undefined) {
|
|
2957
|
+
urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
|
|
2958
|
+
}
|
|
2959
|
+
let startTime;
|
|
2960
|
+
if (this.debug) {
|
|
2961
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2962
|
+
}
|
|
2963
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, {
|
|
2964
|
+
headers: {
|
|
2965
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2966
|
+
"X-Requested-With": userAgent
|
|
2967
|
+
}
|
|
2968
|
+
}));
|
|
2969
|
+
debugOutput(response.url, response.status, startTime);
|
|
2970
|
+
if (response.status === 429) {
|
|
2971
|
+
try {
|
|
2972
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2973
|
+
}
|
|
2974
|
+
catch (error) {
|
|
2975
|
+
success = true;
|
|
2976
|
+
return {
|
|
2977
|
+
data: null,
|
|
2978
|
+
error: true,
|
|
2979
|
+
error_code: response.status,
|
|
2980
|
+
error_message: error.message
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
else {
|
|
2985
|
+
data = await response.json();
|
|
2986
|
+
}
|
|
2987
|
+
const dataClass = new NftMetadataResponse(data.data);
|
|
2988
|
+
checkAndModifyResponse(dataClass);
|
|
2989
|
+
success = true;
|
|
2990
|
+
return {
|
|
2991
|
+
data: dataClass,
|
|
2992
|
+
error: data.error,
|
|
2993
|
+
error_code: data ? data.error_code : response.status,
|
|
2994
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
catch (error) {
|
|
2998
|
+
success = true;
|
|
2999
|
+
return {
|
|
3000
|
+
data: null,
|
|
3001
|
+
error: true,
|
|
3002
|
+
error_code: data ? data.error_code : response.status,
|
|
3003
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
2456
3008
|
/**
|
|
2457
3009
|
*
|
|
2458
3010
|
* Commonly used to get a single NFT metadata by token ID from a collection. Useful for building NFT card displays.
|
|
@@ -3739,6 +4291,7 @@ class TransactionService {
|
|
|
3739
4291
|
* @param {GetTransactionsForBlockQueryParamOpts} queryParamOpts
|
|
3740
4292
|
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
3741
4293
|
* - `noLogs`: Omit log events.
|
|
4294
|
+
* - `withSafe`: Include safe details.
|
|
3742
4295
|
*
|
|
3743
4296
|
*/
|
|
3744
4297
|
async getTransactionsForBlock(chainName, blockHeight, queryParamOpts) {
|
|
@@ -3755,6 +4308,9 @@ class TransactionService {
|
|
|
3755
4308
|
if (queryParamOpts?.noLogs !== undefined) {
|
|
3756
4309
|
urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
|
|
3757
4310
|
}
|
|
4311
|
+
if (queryParamOpts?.withSafe !== undefined) {
|
|
4312
|
+
urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
|
|
4313
|
+
}
|
|
3758
4314
|
let startTime;
|
|
3759
4315
|
if (this.debug) {
|
|
3760
4316
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5294,7 +5850,7 @@ class XykService {
|
|
|
5294
5850
|
}
|
|
5295
5851
|
}
|
|
5296
5852
|
|
|
5297
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
5853
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.6.0";
|
|
5298
5854
|
/**
|
|
5299
5855
|
* CovalentClient Class
|
|
5300
5856
|
*/
|