@covalenthq/client-sdk 0.0.2 → 0.0.4

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,16 +1,36 @@
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.TransactionsService = void 0;
13
4
  const baseDelayMs = 1000; // Base delay in milliseconds
5
+ async function* paginateEndpoint(url, apiKey, urlsParams) {
6
+ let hasNext = true;
7
+ let retryCount = 0;
8
+ while (hasNext) {
9
+ try {
10
+ const response = await fetch(`${url}?${urlsParams}`, {
11
+ headers: {
12
+ "Authorization": `Bearer ${apiKey}`
13
+ }
14
+ });
15
+ const data = await response.json();
16
+ if (data.error && data.error_code === 429) {
17
+ retryCount++;
18
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
19
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
20
+ }
21
+ else {
22
+ yield data;
23
+ if (data.data.links.prev === null) {
24
+ hasNext = false;
25
+ }
26
+ url = data.data.links.prev || "";
27
+ }
28
+ }
29
+ catch (error) {
30
+ console.error(error);
31
+ }
32
+ }
33
+ }
14
34
  class TransactionsService {
15
35
  constructor(apiKey) {
16
36
  this.apiKey = apiKey;
@@ -26,50 +46,48 @@ class TransactionsService {
26
46
  * @param {boolean} 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.
27
47
  *
28
48
  */
29
- getTransaction(chainName, txHash, quoteCurrency, noLogs, withDex, withNftSales, withLending) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- let retryCount = 0;
32
- let success = false;
33
- while (!success) {
34
- try {
35
- const urlParams = new URLSearchParams();
36
- if (quoteCurrency !== undefined) {
37
- urlParams.append("quote-currency", quoteCurrency.toString());
38
- }
39
- if (noLogs !== undefined) {
40
- urlParams.append("no-logs", noLogs.toString());
41
- }
42
- if (withDex !== undefined) {
43
- urlParams.append("with-dex", withDex.toString());
44
- }
45
- if (withNftSales !== undefined) {
46
- urlParams.append("with-nft-sales", withNftSales.toString());
47
- }
48
- if (withLending !== undefined) {
49
- urlParams.append("with-lending", withLending.toString());
50
- }
51
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, {
52
- headers: {
53
- "Authorization": `Bearer ${this.apiKey}`
54
- }
55
- });
56
- const data = yield response.json();
57
- if (data.error && data.error_code === 429) {
58
- retryCount++;
59
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
60
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
61
- }
62
- else {
63
- success = true;
64
- return data;
65
- }
49
+ async getTransaction(chainName, txHash, quoteCurrency, noLogs, withDex, withNftSales, withLending) {
50
+ let retryCount = 0;
51
+ let success = false;
52
+ while (!success) {
53
+ try {
54
+ const urlParams = new URLSearchParams();
55
+ if (quoteCurrency !== undefined) {
56
+ urlParams.append("quote-currency", quoteCurrency.toString());
57
+ }
58
+ if (noLogs !== undefined) {
59
+ urlParams.append("no-logs", noLogs.toString());
60
+ }
61
+ if (withDex !== undefined) {
62
+ urlParams.append("with-dex", withDex.toString());
66
63
  }
67
- catch (error) {
64
+ if (withNftSales !== undefined) {
65
+ urlParams.append("with-nft-sales", withNftSales.toString());
66
+ }
67
+ if (withLending !== undefined) {
68
+ urlParams.append("with-lending", withLending.toString());
69
+ }
70
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, {
71
+ headers: {
72
+ "Authorization": `Bearer ${this.apiKey}`
73
+ }
74
+ });
75
+ const data = await response.json();
76
+ if (data.error && data.error_code === 429) {
77
+ retryCount++;
78
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
79
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
80
+ }
81
+ else {
68
82
  success = true;
69
- return error.message;
83
+ return data;
70
84
  }
71
85
  }
72
- });
86
+ catch (error) {
87
+ success = true;
88
+ return error.message;
89
+ }
90
+ }
73
91
  }
74
92
  /**
75
93
  *
@@ -80,44 +98,42 @@ class TransactionsService {
80
98
  * @param {boolean} blockSignedAtAsc - Sort the transactions in ascending chronological order. By default, it's set to `false` and returns transactions in descending chronological order.
81
99
  *
82
100
  */
83
- getTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs, blockSignedAtAsc) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- let retryCount = 0;
86
- let success = false;
87
- while (!success) {
88
- try {
89
- const urlParams = new URLSearchParams();
90
- if (quoteCurrency !== undefined) {
91
- urlParams.append("quote-currency", quoteCurrency.toString());
92
- }
93
- if (noLogs !== undefined) {
94
- urlParams.append("no-logs", noLogs.toString());
95
- }
96
- if (blockSignedAtAsc !== undefined) {
97
- urlParams.append("block-signed-at-asc", blockSignedAtAsc.toString());
98
- }
99
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v2/?${urlParams}`, {
100
- headers: {
101
- "Authorization": `Bearer ${this.apiKey}`
102
- }
103
- });
104
- const data = yield response.json();
105
- if (data.error && data.error_code === 429) {
106
- retryCount++;
107
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
108
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
109
- }
110
- else {
111
- success = true;
112
- return data;
113
- }
101
+ async getTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs, blockSignedAtAsc) {
102
+ let retryCount = 0;
103
+ let success = false;
104
+ while (!success) {
105
+ try {
106
+ const urlParams = new URLSearchParams();
107
+ if (quoteCurrency !== undefined) {
108
+ urlParams.append("quote-currency", quoteCurrency.toString());
114
109
  }
115
- catch (error) {
110
+ if (noLogs !== undefined) {
111
+ urlParams.append("no-logs", noLogs.toString());
112
+ }
113
+ if (blockSignedAtAsc !== undefined) {
114
+ urlParams.append("block-signed-at-asc", blockSignedAtAsc.toString());
115
+ }
116
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v2/?${urlParams}`, {
117
+ headers: {
118
+ "Authorization": `Bearer ${this.apiKey}`
119
+ }
120
+ });
121
+ const data = await response.json();
122
+ if (data.error && data.error_code === 429) {
123
+ retryCount++;
124
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
125
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
126
+ }
127
+ else {
116
128
  success = true;
117
- return error.message;
129
+ return data;
118
130
  }
119
131
  }
120
- });
132
+ catch (error) {
133
+ success = true;
134
+ return error.message;
135
+ }
136
+ }
121
137
  }
122
138
  /**
123
139
  *
@@ -127,41 +143,28 @@ class TransactionsService {
127
143
  * @param {boolean} noLogs - Omit log events.
128
144
  *
129
145
  */
130
- getRecentTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- let retryCount = 0;
133
- let success = false;
134
- while (!success) {
135
- try {
136
- const urlParams = new URLSearchParams();
137
- if (quoteCurrency !== undefined) {
138
- urlParams.append("quote-currency", quoteCurrency.toString());
139
- }
140
- if (noLogs !== undefined) {
141
- urlParams.append("no-logs", noLogs.toString());
142
- }
143
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/?${urlParams}`, {
144
- headers: {
145
- "Authorization": `Bearer ${this.apiKey}`
146
- }
147
- });
148
- const data = yield response.json();
149
- if (data.error && data.error_code === 429) {
150
- retryCount++;
151
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
152
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
153
- }
154
- else {
155
- success = true;
156
- return data;
157
- }
146
+ async *getRecentTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) {
147
+ let retryCount = 0;
148
+ let success = false;
149
+ while (!success) {
150
+ try {
151
+ const urlParams = new URLSearchParams();
152
+ if (quoteCurrency !== undefined) {
153
+ urlParams.append("quote-currency", quoteCurrency.toString());
158
154
  }
159
- catch (error) {
160
- success = true;
161
- return error.message;
155
+ if (noLogs !== undefined) {
156
+ urlParams.append("no-logs", noLogs.toString());
162
157
  }
158
+ for await (const response of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams)) {
159
+ yield response;
160
+ }
161
+ success = true;
162
+ }
163
+ catch (error) {
164
+ success = true;
165
+ return error.message;
163
166
  }
164
- });
167
+ }
165
168
  }
166
169
  /**
167
170
  *
@@ -172,41 +175,39 @@ class TransactionsService {
172
175
  * @param {boolean} noLogs - Omit log events.
173
176
  *
174
177
  */
175
- getTransactionsForAddressV3(chainName, walletAddress, page, quoteCurrency, noLogs) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- let retryCount = 0;
178
- let success = false;
179
- while (!success) {
180
- try {
181
- const urlParams = new URLSearchParams();
182
- if (quoteCurrency !== undefined) {
183
- urlParams.append("quote-currency", quoteCurrency.toString());
184
- }
185
- if (noLogs !== undefined) {
186
- urlParams.append("no-logs", noLogs.toString());
187
- }
188
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
189
- headers: {
190
- "Authorization": `Bearer ${this.apiKey}`
191
- }
192
- });
193
- const data = yield response.json();
194
- if (data.error && data.error_code === 429) {
195
- retryCount++;
196
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
197
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
198
- }
199
- else {
200
- success = true;
201
- return data;
202
- }
178
+ async getTransactionsForAddressV3(chainName, walletAddress, page, quoteCurrency, noLogs) {
179
+ let retryCount = 0;
180
+ let success = false;
181
+ while (!success) {
182
+ try {
183
+ const urlParams = new URLSearchParams();
184
+ if (quoteCurrency !== undefined) {
185
+ urlParams.append("quote-currency", quoteCurrency.toString());
186
+ }
187
+ if (noLogs !== undefined) {
188
+ urlParams.append("no-logs", noLogs.toString());
203
189
  }
204
- catch (error) {
190
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
191
+ headers: {
192
+ "Authorization": `Bearer ${this.apiKey}`
193
+ }
194
+ });
195
+ const data = await response.json();
196
+ if (data.error && data.error_code === 429) {
197
+ retryCount++;
198
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
199
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
200
+ }
201
+ else {
205
202
  success = true;
206
- return error.message;
203
+ return data;
207
204
  }
208
205
  }
209
- });
206
+ catch (error) {
207
+ success = true;
208
+ return error.message;
209
+ }
210
+ }
210
211
  }
211
212
  /**
212
213
  *
@@ -217,41 +218,39 @@ class TransactionsService {
217
218
  * @param {boolean} noLogs - Omit log events.
218
219
  *
219
220
  */
220
- getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, quoteCurrency, noLogs) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- let retryCount = 0;
223
- let success = false;
224
- while (!success) {
225
- try {
226
- const urlParams = new URLSearchParams();
227
- if (quoteCurrency !== undefined) {
228
- urlParams.append("quote-currency", quoteCurrency.toString());
229
- }
230
- if (noLogs !== undefined) {
231
- urlParams.append("no-logs", noLogs.toString());
232
- }
233
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, {
234
- headers: {
235
- "Authorization": `Bearer ${this.apiKey}`
236
- }
237
- });
238
- const data = yield response.json();
239
- if (data.error && data.error_code === 429) {
240
- retryCount++;
241
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
242
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
243
- }
244
- else {
245
- success = true;
246
- return data;
247
- }
221
+ async getTimeBucketTransactionsForAddress(chainName, walletAddress, timeBucket, quoteCurrency, noLogs) {
222
+ let retryCount = 0;
223
+ let success = false;
224
+ while (!success) {
225
+ try {
226
+ const urlParams = new URLSearchParams();
227
+ if (quoteCurrency !== undefined) {
228
+ urlParams.append("quote-currency", quoteCurrency.toString());
248
229
  }
249
- catch (error) {
230
+ if (noLogs !== undefined) {
231
+ urlParams.append("no-logs", noLogs.toString());
232
+ }
233
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, {
234
+ headers: {
235
+ "Authorization": `Bearer ${this.apiKey}`
236
+ }
237
+ });
238
+ const data = await response.json();
239
+ if (data.error && data.error_code === 429) {
240
+ retryCount++;
241
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
242
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
243
+ }
244
+ else {
250
245
  success = true;
251
- return error.message;
246
+ return data;
252
247
  }
253
248
  }
254
- });
249
+ catch (error) {
250
+ success = true;
251
+ return error.message;
252
+ }
253
+ }
255
254
  }
256
255
  /**
257
256
  *
@@ -261,41 +260,39 @@ class TransactionsService {
261
260
  * @param {boolean} noLogs - Omit log events.
262
261
  *
263
262
  */
264
- getEarliestTimeBucketTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) {
265
- return __awaiter(this, void 0, void 0, function* () {
266
- let retryCount = 0;
267
- let success = false;
268
- while (!success) {
269
- try {
270
- const urlParams = new URLSearchParams();
271
- if (quoteCurrency !== undefined) {
272
- urlParams.append("quote-currency", quoteCurrency.toString());
273
- }
274
- if (noLogs !== undefined) {
275
- urlParams.append("no-logs", noLogs.toString());
276
- }
277
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/?${urlParams}`, {
278
- headers: {
279
- "Authorization": `Bearer ${this.apiKey}`
280
- }
281
- });
282
- const data = yield response.json();
283
- if (data.error && data.error_code === 429) {
284
- retryCount++;
285
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
286
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
287
- }
288
- else {
289
- success = true;
290
- return data;
291
- }
263
+ async getEarliestTimeBucketTransactionsForAddress(chainName, walletAddress, quoteCurrency, noLogs) {
264
+ let retryCount = 0;
265
+ let success = false;
266
+ while (!success) {
267
+ try {
268
+ const urlParams = new URLSearchParams();
269
+ if (quoteCurrency !== undefined) {
270
+ urlParams.append("quote-currency", quoteCurrency.toString());
271
+ }
272
+ if (noLogs !== undefined) {
273
+ urlParams.append("no-logs", noLogs.toString());
274
+ }
275
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/?${urlParams}`, {
276
+ headers: {
277
+ "Authorization": `Bearer ${this.apiKey}`
278
+ }
279
+ });
280
+ const data = await response.json();
281
+ if (data.error && data.error_code === 429) {
282
+ retryCount++;
283
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
284
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
292
285
  }
293
- catch (error) {
286
+ else {
294
287
  success = true;
295
- return error.message;
288
+ return data;
296
289
  }
297
290
  }
298
- });
291
+ catch (error) {
292
+ success = true;
293
+ return error.message;
294
+ }
295
+ }
299
296
  }
300
297
  /**
301
298
  *
@@ -306,41 +303,39 @@ class TransactionsService {
306
303
  * @param {boolean} noLogs - Omit log events.
307
304
  *
308
305
  */
309
- getTransactionsForBlockByPage(chainName, blockHeight, page, quoteCurrency, noLogs) {
310
- return __awaiter(this, void 0, void 0, function* () {
311
- let retryCount = 0;
312
- let success = false;
313
- while (!success) {
314
- try {
315
- const urlParams = new URLSearchParams();
316
- if (quoteCurrency !== undefined) {
317
- urlParams.append("quote-currency", quoteCurrency.toString());
318
- }
319
- if (noLogs !== undefined) {
320
- urlParams.append("no-logs", noLogs.toString());
321
- }
322
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/page/${page}/?${urlParams}`, {
323
- headers: {
324
- "Authorization": `Bearer ${this.apiKey}`
325
- }
326
- });
327
- const data = yield response.json();
328
- if (data.error && data.error_code === 429) {
329
- retryCount++;
330
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
331
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
332
- }
333
- else {
334
- success = true;
335
- return data;
336
- }
306
+ async getTransactionsForBlockByPage(chainName, blockHeight, page, quoteCurrency, noLogs) {
307
+ let retryCount = 0;
308
+ let success = false;
309
+ while (!success) {
310
+ try {
311
+ const urlParams = new URLSearchParams();
312
+ if (quoteCurrency !== undefined) {
313
+ urlParams.append("quote-currency", quoteCurrency.toString());
337
314
  }
338
- catch (error) {
315
+ if (noLogs !== undefined) {
316
+ urlParams.append("no-logs", noLogs.toString());
317
+ }
318
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/page/${page}/?${urlParams}`, {
319
+ headers: {
320
+ "Authorization": `Bearer ${this.apiKey}`
321
+ }
322
+ });
323
+ const data = await response.json();
324
+ if (data.error && data.error_code === 429) {
325
+ retryCount++;
326
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
327
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
328
+ }
329
+ else {
339
330
  success = true;
340
- return error.message;
331
+ return data;
341
332
  }
342
333
  }
343
- });
334
+ catch (error) {
335
+ success = true;
336
+ return error.message;
337
+ }
338
+ }
344
339
  }
345
340
  /**
346
341
  *
@@ -350,41 +345,39 @@ class TransactionsService {
350
345
  * @param {boolean} noLogs - Omit log events.
351
346
  *
352
347
  */
353
- getTransactionsForBlock(chainName, blockHeight, quoteCurrency, noLogs) {
354
- return __awaiter(this, void 0, void 0, function* () {
355
- let retryCount = 0;
356
- let success = false;
357
- while (!success) {
358
- try {
359
- const urlParams = new URLSearchParams();
360
- if (quoteCurrency !== undefined) {
361
- urlParams.append("quote-currency", quoteCurrency.toString());
362
- }
363
- if (noLogs !== undefined) {
364
- urlParams.append("no-logs", noLogs.toString());
365
- }
366
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, {
367
- headers: {
368
- "Authorization": `Bearer ${this.apiKey}`
369
- }
370
- });
371
- const data = yield response.json();
372
- if (data.error && data.error_code === 429) {
373
- retryCount++;
374
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
375
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
376
- }
377
- else {
378
- success = true;
379
- return data;
380
- }
348
+ async getTransactionsForBlock(chainName, blockHeight, quoteCurrency, noLogs) {
349
+ let retryCount = 0;
350
+ let success = false;
351
+ while (!success) {
352
+ try {
353
+ const urlParams = new URLSearchParams();
354
+ if (quoteCurrency !== undefined) {
355
+ urlParams.append("quote-currency", quoteCurrency.toString());
356
+ }
357
+ if (noLogs !== undefined) {
358
+ urlParams.append("no-logs", noLogs.toString());
359
+ }
360
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, {
361
+ headers: {
362
+ "Authorization": `Bearer ${this.apiKey}`
363
+ }
364
+ });
365
+ const data = await response.json();
366
+ if (data.error && data.error_code === 429) {
367
+ retryCount++;
368
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
369
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
381
370
  }
382
- catch (error) {
371
+ else {
383
372
  success = true;
384
- return error.message;
373
+ return data;
385
374
  }
386
375
  }
387
- });
376
+ catch (error) {
377
+ success = true;
378
+ return error.message;
379
+ }
380
+ }
388
381
  }
389
382
  /**
390
383
  *
@@ -392,35 +385,33 @@ class TransactionsService {
392
385
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
393
386
  *
394
387
  */
395
- getTransactionSummary(chainName, walletAddress) {
396
- return __awaiter(this, void 0, void 0, function* () {
397
- let retryCount = 0;
398
- let success = false;
399
- while (!success) {
400
- try {
401
- const urlParams = new URLSearchParams();
402
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, {
403
- headers: {
404
- "Authorization": `Bearer ${this.apiKey}`
405
- }
406
- });
407
- const data = yield response.json();
408
- if (data.error && data.error_code === 429) {
409
- retryCount++;
410
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
411
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
412
- }
413
- else {
414
- success = true;
415
- return data;
416
- }
388
+ async getTransactionSummary(chainName, walletAddress) {
389
+ let retryCount = 0;
390
+ let success = false;
391
+ while (!success) {
392
+ try {
393
+ const urlParams = new URLSearchParams();
394
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, {
395
+ headers: {
396
+ "Authorization": `Bearer ${this.apiKey}`
397
+ }
398
+ });
399
+ const data = await response.json();
400
+ if (data.error && data.error_code === 429) {
401
+ retryCount++;
402
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
403
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
417
404
  }
418
- catch (error) {
405
+ else {
419
406
  success = true;
420
- return error.message;
407
+ return data;
421
408
  }
422
409
  }
423
- });
410
+ catch (error) {
411
+ success = true;
412
+ return error.message;
413
+ }
414
+ }
424
415
  }
425
416
  }
426
417
  exports.TransactionsService = TransactionsService;