@covalenthq/client-sdk 0.0.2 → 0.0.3

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.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NftService = void 0;
13
4
  const baseDelayMs = 1000; // Base delay in milliseconds
@@ -23,44 +14,42 @@ class NftService {
23
14
  * @param {boolean} noSpam - If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
24
15
  *
25
16
  */
26
- getChainCollections(chainName, pageSize, pageNumber, noSpam) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- let retryCount = 0;
29
- let success = false;
30
- while (!success) {
31
- try {
32
- const urlParams = new URLSearchParams();
33
- if (pageSize !== undefined) {
34
- urlParams.append("page-size", pageSize.toString());
35
- }
36
- if (pageNumber !== undefined) {
37
- urlParams.append("page-number", pageNumber.toString());
38
- }
39
- if (noSpam !== undefined) {
40
- urlParams.append("no-spam", noSpam.toString());
41
- }
42
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, {
43
- headers: {
44
- "Authorization": `Bearer ${this.apiKey}`
45
- }
46
- });
47
- const data = yield response.json();
48
- if (data.error && data.error_code === 429) {
49
- retryCount++;
50
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
51
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
52
- }
53
- else {
54
- success = true;
55
- return data;
56
- }
17
+ async getChainCollections(chainName, pageSize, pageNumber, noSpam) {
18
+ let retryCount = 0;
19
+ let success = false;
20
+ while (!success) {
21
+ try {
22
+ const urlParams = new URLSearchParams();
23
+ if (pageSize !== undefined) {
24
+ urlParams.append("page-size", pageSize.toString());
25
+ }
26
+ if (pageNumber !== undefined) {
27
+ urlParams.append("page-number", pageNumber.toString());
28
+ }
29
+ if (noSpam !== undefined) {
30
+ urlParams.append("no-spam", noSpam.toString());
31
+ }
32
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, {
33
+ headers: {
34
+ "Authorization": `Bearer ${this.apiKey}`
35
+ }
36
+ });
37
+ const data = await response.json();
38
+ if (data.error && data.error_code === 429) {
39
+ retryCount++;
40
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
41
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
57
42
  }
58
- catch (error) {
43
+ else {
59
44
  success = true;
60
- return error.message;
45
+ return data;
61
46
  }
62
47
  }
63
- });
48
+ catch (error) {
49
+ success = true;
50
+ return error.message;
51
+ }
52
+ }
64
53
  }
65
54
  /**
66
55
  *
@@ -70,41 +59,39 @@ class NftService {
70
59
  * @param {boolean} noNftAssetMetadata - If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
71
60
  *
72
61
  */
73
- getNftsForAddress(chainName, walletAddress, noSpam, noNftAssetMetadata) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- let retryCount = 0;
76
- let success = false;
77
- while (!success) {
78
- try {
79
- const urlParams = new URLSearchParams();
80
- if (noSpam !== undefined) {
81
- urlParams.append("no-spam", noSpam.toString());
82
- }
83
- if (noNftAssetMetadata !== undefined) {
84
- urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString());
85
- }
86
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
87
- headers: {
88
- "Authorization": `Bearer ${this.apiKey}`
89
- }
90
- });
91
- const data = yield response.json();
92
- if (data.error && data.error_code === 429) {
93
- retryCount++;
94
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
95
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
96
- }
97
- else {
98
- success = true;
99
- return data;
100
- }
62
+ async getNftsForAddress(chainName, walletAddress, noSpam, noNftAssetMetadata) {
63
+ let retryCount = 0;
64
+ let success = false;
65
+ while (!success) {
66
+ try {
67
+ const urlParams = new URLSearchParams();
68
+ if (noSpam !== undefined) {
69
+ urlParams.append("no-spam", noSpam.toString());
70
+ }
71
+ if (noNftAssetMetadata !== undefined) {
72
+ urlParams.append("no-nft-asset-metadata", noNftAssetMetadata.toString());
73
+ }
74
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
75
+ headers: {
76
+ "Authorization": `Bearer ${this.apiKey}`
77
+ }
78
+ });
79
+ const data = await response.json();
80
+ if (data.error && data.error_code === 429) {
81
+ retryCount++;
82
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
83
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
101
84
  }
102
- catch (error) {
85
+ else {
103
86
  success = true;
104
- return error.message;
87
+ return data;
105
88
  }
106
89
  }
107
- });
90
+ catch (error) {
91
+ success = true;
92
+ return error.message;
93
+ }
94
+ }
108
95
  }
109
96
  /**
110
97
  *
@@ -117,50 +104,48 @@ class NftService {
117
104
  * @param {string} 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.
118
105
  *
119
106
  */
120
- getTokenIdsForContractWithMetadata(chainName, contractAddress, noMetadata, pageSize, pageNumber, traitsFilter, valuesFilter) {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- let retryCount = 0;
123
- let success = false;
124
- while (!success) {
125
- try {
126
- const urlParams = new URLSearchParams();
127
- if (noMetadata !== undefined) {
128
- urlParams.append("no-metadata", noMetadata.toString());
129
- }
130
- if (pageSize !== undefined) {
131
- urlParams.append("page-size", pageSize.toString());
132
- }
133
- if (pageNumber !== undefined) {
134
- urlParams.append("page-number", pageNumber.toString());
135
- }
136
- if (traitsFilter !== undefined) {
137
- urlParams.append("traits-filter", traitsFilter.toString());
138
- }
139
- if (valuesFilter !== undefined) {
140
- urlParams.append("values-filter", valuesFilter.toString());
141
- }
142
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, {
143
- headers: {
144
- "Authorization": `Bearer ${this.apiKey}`
145
- }
146
- });
147
- const data = yield response.json();
148
- if (data.error && data.error_code === 429) {
149
- retryCount++;
150
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
151
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
152
- }
153
- else {
154
- success = true;
155
- return data;
156
- }
107
+ async getTokenIdsForContractWithMetadata(chainName, contractAddress, noMetadata, pageSize, pageNumber, traitsFilter, valuesFilter) {
108
+ let retryCount = 0;
109
+ let success = false;
110
+ while (!success) {
111
+ try {
112
+ const urlParams = new URLSearchParams();
113
+ if (noMetadata !== undefined) {
114
+ urlParams.append("no-metadata", noMetadata.toString());
157
115
  }
158
- catch (error) {
116
+ if (pageSize !== undefined) {
117
+ urlParams.append("page-size", pageSize.toString());
118
+ }
119
+ if (pageNumber !== undefined) {
120
+ urlParams.append("page-number", pageNumber.toString());
121
+ }
122
+ if (traitsFilter !== undefined) {
123
+ urlParams.append("traits-filter", traitsFilter.toString());
124
+ }
125
+ if (valuesFilter !== undefined) {
126
+ urlParams.append("values-filter", valuesFilter.toString());
127
+ }
128
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, {
129
+ headers: {
130
+ "Authorization": `Bearer ${this.apiKey}`
131
+ }
132
+ });
133
+ const data = await response.json();
134
+ if (data.error && data.error_code === 429) {
135
+ retryCount++;
136
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
137
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
138
+ }
139
+ else {
159
140
  success = true;
160
- return error.message;
141
+ return data;
161
142
  }
162
143
  }
163
- });
144
+ catch (error) {
145
+ success = true;
146
+ return error.message;
147
+ }
148
+ }
164
149
  }
165
150
  /**
166
151
  *
@@ -171,41 +156,39 @@ class NftService {
171
156
  * @param {string} tokenId - The requested token ID.
172
157
  *
173
158
  */
174
- getNftMetadataForGivenTokenIDForContract(chainName, contractAddress, noMetadata, withUncached, tokenId) {
175
- return __awaiter(this, void 0, void 0, function* () {
176
- let retryCount = 0;
177
- let success = false;
178
- while (!success) {
179
- try {
180
- const urlParams = new URLSearchParams();
181
- if (noMetadata !== undefined) {
182
- urlParams.append("no-metadata", noMetadata.toString());
183
- }
184
- if (withUncached !== undefined) {
185
- urlParams.append("with-uncached", withUncached.toString());
186
- }
187
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
188
- headers: {
189
- "Authorization": `Bearer ${this.apiKey}`
190
- }
191
- });
192
- const data = yield response.json();
193
- if (data.error && data.error_code === 429) {
194
- retryCount++;
195
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
196
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
197
- }
198
- else {
199
- success = true;
200
- return data;
201
- }
159
+ async getNftMetadataForGivenTokenIDForContract(chainName, contractAddress, noMetadata, withUncached, tokenId) {
160
+ let retryCount = 0;
161
+ let success = false;
162
+ while (!success) {
163
+ try {
164
+ const urlParams = new URLSearchParams();
165
+ if (noMetadata !== undefined) {
166
+ urlParams.append("no-metadata", noMetadata.toString());
167
+ }
168
+ if (withUncached !== undefined) {
169
+ urlParams.append("with-uncached", withUncached.toString());
202
170
  }
203
- catch (error) {
171
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
172
+ headers: {
173
+ "Authorization": `Bearer ${this.apiKey}`
174
+ }
175
+ });
176
+ const data = await response.json();
177
+ if (data.error && data.error_code === 429) {
178
+ retryCount++;
179
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
180
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
181
+ }
182
+ else {
204
183
  success = true;
205
- return error.message;
184
+ return data;
206
185
  }
207
186
  }
208
- });
187
+ catch (error) {
188
+ success = true;
189
+ return error.message;
190
+ }
191
+ }
209
192
  }
210
193
  /**
211
194
  *
@@ -215,38 +198,36 @@ class NftService {
215
198
  * @param {boolean} noSpam - If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
216
199
  *
217
200
  */
218
- getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, noSpam) {
219
- return __awaiter(this, void 0, void 0, function* () {
220
- let retryCount = 0;
221
- let success = false;
222
- while (!success) {
223
- try {
224
- const urlParams = new URLSearchParams();
225
- if (noSpam !== undefined) {
226
- urlParams.append("no-spam", noSpam.toString());
227
- }
228
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
229
- headers: {
230
- "Authorization": `Bearer ${this.apiKey}`
231
- }
232
- });
233
- const data = yield response.json();
234
- if (data.error && data.error_code === 429) {
235
- retryCount++;
236
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
237
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
238
- }
239
- else {
240
- success = true;
241
- return data;
242
- }
201
+ async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, noSpam) {
202
+ let retryCount = 0;
203
+ let success = false;
204
+ while (!success) {
205
+ try {
206
+ const urlParams = new URLSearchParams();
207
+ if (noSpam !== undefined) {
208
+ urlParams.append("no-spam", noSpam.toString());
209
+ }
210
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
211
+ headers: {
212
+ "Authorization": `Bearer ${this.apiKey}`
213
+ }
214
+ });
215
+ const data = await response.json();
216
+ if (data.error && data.error_code === 429) {
217
+ retryCount++;
218
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
219
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
243
220
  }
244
- catch (error) {
221
+ else {
245
222
  success = true;
246
- return error.message;
223
+ return data;
247
224
  }
248
225
  }
249
- });
226
+ catch (error) {
227
+ success = true;
228
+ return error.message;
229
+ }
230
+ }
250
231
  }
251
232
  /**
252
233
  *
@@ -254,35 +235,33 @@ class NftService {
254
235
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
255
236
  *
256
237
  */
257
- getTraitsForCollection(chainName, collectionContract) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- let retryCount = 0;
260
- let success = false;
261
- while (!success) {
262
- try {
263
- const urlParams = new URLSearchParams();
264
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
265
- headers: {
266
- "Authorization": `Bearer ${this.apiKey}`
267
- }
268
- });
269
- const data = yield response.json();
270
- if (data.error && data.error_code === 429) {
271
- retryCount++;
272
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
273
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
274
- }
275
- else {
276
- success = true;
277
- return data;
278
- }
238
+ async getTraitsForCollection(chainName, collectionContract) {
239
+ let retryCount = 0;
240
+ let success = false;
241
+ while (!success) {
242
+ try {
243
+ const urlParams = new URLSearchParams();
244
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
245
+ headers: {
246
+ "Authorization": `Bearer ${this.apiKey}`
247
+ }
248
+ });
249
+ const data = await response.json();
250
+ if (data.error && data.error_code === 429) {
251
+ retryCount++;
252
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
253
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
279
254
  }
280
- catch (error) {
255
+ else {
281
256
  success = true;
282
- return error.message;
257
+ return data;
283
258
  }
284
259
  }
285
- });
260
+ catch (error) {
261
+ success = true;
262
+ return error.message;
263
+ }
264
+ }
286
265
  }
287
266
  /**
288
267
  *
@@ -291,35 +270,33 @@ class NftService {
291
270
  * @param {string} trait - The requested trait.
292
271
  *
293
272
  */
294
- getAttributesForTraitInCollection(chainName, collectionContract, trait) {
295
- return __awaiter(this, void 0, void 0, function* () {
296
- let retryCount = 0;
297
- let success = false;
298
- while (!success) {
299
- try {
300
- const urlParams = new URLSearchParams();
301
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
302
- headers: {
303
- "Authorization": `Bearer ${this.apiKey}`
304
- }
305
- });
306
- const data = yield response.json();
307
- if (data.error && data.error_code === 429) {
308
- retryCount++;
309
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
310
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
311
- }
312
- else {
313
- success = true;
314
- return data;
315
- }
273
+ async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
274
+ let retryCount = 0;
275
+ let success = false;
276
+ while (!success) {
277
+ try {
278
+ const urlParams = new URLSearchParams();
279
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
280
+ headers: {
281
+ "Authorization": `Bearer ${this.apiKey}`
282
+ }
283
+ });
284
+ const data = await response.json();
285
+ if (data.error && data.error_code === 429) {
286
+ retryCount++;
287
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
288
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
316
289
  }
317
- catch (error) {
290
+ else {
318
291
  success = true;
319
- return error.message;
292
+ return data;
320
293
  }
321
294
  }
322
- });
295
+ catch (error) {
296
+ success = true;
297
+ return error.message;
298
+ }
299
+ }
323
300
  }
324
301
  /**
325
302
  *
@@ -327,35 +304,33 @@ class NftService {
327
304
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
328
305
  *
329
306
  */
330
- getCollectionTraitsSummary(chainName, collectionContract) {
331
- return __awaiter(this, void 0, void 0, function* () {
332
- let retryCount = 0;
333
- let success = false;
334
- while (!success) {
335
- try {
336
- const urlParams = new URLSearchParams();
337
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
338
- headers: {
339
- "Authorization": `Bearer ${this.apiKey}`
340
- }
341
- });
342
- const data = yield response.json();
343
- if (data.error && data.error_code === 429) {
344
- retryCount++;
345
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
346
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
347
- }
348
- else {
349
- success = true;
350
- return data;
351
- }
307
+ async getCollectionTraitsSummary(chainName, collectionContract) {
308
+ let retryCount = 0;
309
+ let success = false;
310
+ while (!success) {
311
+ try {
312
+ const urlParams = new URLSearchParams();
313
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
314
+ headers: {
315
+ "Authorization": `Bearer ${this.apiKey}`
316
+ }
317
+ });
318
+ const data = await response.json();
319
+ if (data.error && data.error_code === 429) {
320
+ retryCount++;
321
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
322
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
352
323
  }
353
- catch (error) {
324
+ else {
354
325
  success = true;
355
- return error.message;
326
+ return data;
356
327
  }
357
328
  }
358
- });
329
+ catch (error) {
330
+ success = true;
331
+ return error.message;
332
+ }
333
+ }
359
334
  }
360
335
  /**
361
336
  *
@@ -364,35 +339,33 @@ class NftService {
364
339
  * @param {string} collectionContract - The requested collection address.
365
340
  *
366
341
  */
367
- checkOwnershipInNft(chainName, walletAddress, collectionContract) {
368
- return __awaiter(this, void 0, void 0, function* () {
369
- let retryCount = 0;
370
- let success = false;
371
- while (!success) {
372
- try {
373
- const urlParams = new URLSearchParams();
374
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
375
- headers: {
376
- "Authorization": `Bearer ${this.apiKey}`
377
- }
378
- });
379
- const data = yield response.json();
380
- if (data.error && data.error_code === 429) {
381
- retryCount++;
382
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
383
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
384
- }
385
- else {
386
- success = true;
387
- return data;
388
- }
342
+ async checkOwnershipInNft(chainName, walletAddress, collectionContract) {
343
+ let retryCount = 0;
344
+ let success = false;
345
+ while (!success) {
346
+ try {
347
+ const urlParams = new URLSearchParams();
348
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
349
+ headers: {
350
+ "Authorization": `Bearer ${this.apiKey}`
351
+ }
352
+ });
353
+ const data = await response.json();
354
+ if (data.error && data.error_code === 429) {
355
+ retryCount++;
356
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
357
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
389
358
  }
390
- catch (error) {
359
+ else {
391
360
  success = true;
392
- return error.message;
361
+ return data;
393
362
  }
394
363
  }
395
- });
364
+ catch (error) {
365
+ success = true;
366
+ return error.message;
367
+ }
368
+ }
396
369
  }
397
370
  /**
398
371
  *
@@ -402,35 +375,33 @@ class NftService {
402
375
  * @param {string} tokenId - The requested token ID.
403
376
  *
404
377
  */
405
- checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) {
406
- return __awaiter(this, void 0, void 0, function* () {
407
- let retryCount = 0;
408
- let success = false;
409
- while (!success) {
410
- try {
411
- const urlParams = new URLSearchParams();
412
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
413
- headers: {
414
- "Authorization": `Bearer ${this.apiKey}`
415
- }
416
- });
417
- const data = yield response.json();
418
- if (data.error && data.error_code === 429) {
419
- retryCount++;
420
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
421
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
422
- }
423
- else {
424
- success = true;
425
- return data;
426
- }
378
+ async checkOwnershipInNftForSpecificTokenId(chainName, walletAddress, collectionContract, tokenId) {
379
+ let retryCount = 0;
380
+ let success = false;
381
+ while (!success) {
382
+ try {
383
+ const urlParams = new URLSearchParams();
384
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
385
+ headers: {
386
+ "Authorization": `Bearer ${this.apiKey}`
387
+ }
388
+ });
389
+ const data = await response.json();
390
+ if (data.error && data.error_code === 429) {
391
+ retryCount++;
392
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
393
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
427
394
  }
428
- catch (error) {
395
+ else {
429
396
  success = true;
430
- return error.message;
397
+ return data;
431
398
  }
432
399
  }
433
- });
400
+ catch (error) {
401
+ success = true;
402
+ return error.message;
403
+ }
404
+ }
434
405
  }
435
406
  /**
436
407
  *
@@ -439,35 +410,33 @@ class NftService {
439
410
  * @param {string} tokenId - The requested token ID.
440
411
  *
441
412
  */
442
- getNftExternalMetadataForContract(chainName, contractAddress, tokenId) {
443
- return __awaiter(this, void 0, void 0, function* () {
444
- let retryCount = 0;
445
- let success = false;
446
- while (!success) {
447
- try {
448
- const urlParams = new URLSearchParams();
449
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_metadata/${tokenId}/?${urlParams}`, {
450
- headers: {
451
- "Authorization": `Bearer ${this.apiKey}`
452
- }
453
- });
454
- const data = yield response.json();
455
- if (data.error && data.error_code === 429) {
456
- retryCount++;
457
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
458
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
459
- }
460
- else {
461
- success = true;
462
- return data;
463
- }
413
+ async getNftExternalMetadataForContract(chainName, contractAddress, tokenId) {
414
+ let retryCount = 0;
415
+ let success = false;
416
+ while (!success) {
417
+ try {
418
+ const urlParams = new URLSearchParams();
419
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_metadata/${tokenId}/?${urlParams}`, {
420
+ headers: {
421
+ "Authorization": `Bearer ${this.apiKey}`
422
+ }
423
+ });
424
+ const data = await response.json();
425
+ if (data.error && data.error_code === 429) {
426
+ retryCount++;
427
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
428
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
464
429
  }
465
- catch (error) {
430
+ else {
466
431
  success = true;
467
- return error.message;
432
+ return data;
468
433
  }
469
434
  }
470
- });
435
+ catch (error) {
436
+ success = true;
437
+ return error.message;
438
+ }
439
+ }
471
440
  }
472
441
  }
473
442
  exports.NftService = NftService;