@covalenthq/client-sdk 0.7.6 → 0.8.1

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.
Files changed (76) hide show
  1. package/README.md +5 -0
  2. package/dist/cjs/index.js +2762 -199
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BalanceService.d.ts +14 -13
  5. package/dist/cjs/services/BaseService.d.ts +12 -11
  6. package/dist/cjs/services/CovalentClient.d.ts +5 -3
  7. package/dist/cjs/services/NftService.d.ts +18 -17
  8. package/dist/cjs/services/PricingService.d.ts +4 -3
  9. package/dist/cjs/services/SecurityService.d.ts +5 -4
  10. package/dist/cjs/services/TransactionService.d.ts +79 -12
  11. package/dist/cjs/services/XykService.d.ts +226 -15
  12. package/dist/cjs/util/ApiHelpers.d.ts +2 -1
  13. package/dist/cjs/util/backoff.d.ts +2 -1
  14. package/dist/cjs/util/types/TransactionServiceTypes.d.ts +11 -0
  15. package/dist/cjs/util/types/XykServiceTypes.d.ts +114 -0
  16. package/dist/es/index.js +2762 -199
  17. package/dist/es/index.js.map +1 -1
  18. package/dist/es/services/BalanceService.d.ts +14 -13
  19. package/dist/es/services/BaseService.d.ts +12 -11
  20. package/dist/es/services/CovalentClient.d.ts +5 -3
  21. package/dist/es/services/NftService.d.ts +18 -17
  22. package/dist/es/services/PricingService.d.ts +4 -3
  23. package/dist/es/services/SecurityService.d.ts +5 -4
  24. package/dist/es/services/TransactionService.d.ts +79 -12
  25. package/dist/es/services/XykService.d.ts +226 -15
  26. package/dist/es/util/ApiHelpers.d.ts +2 -1
  27. package/dist/es/util/backoff.d.ts +2 -1
  28. package/dist/es/util/types/TransactionServiceTypes.d.ts +11 -0
  29. package/dist/es/util/types/XykServiceTypes.d.ts +114 -0
  30. package/dist/esm/index.js +2762 -199
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/services/BalanceService.d.ts +14 -13
  33. package/dist/esm/services/BaseService.d.ts +12 -11
  34. package/dist/esm/services/CovalentClient.d.ts +5 -3
  35. package/dist/esm/services/NftService.d.ts +18 -17
  36. package/dist/esm/services/PricingService.d.ts +4 -3
  37. package/dist/esm/services/SecurityService.d.ts +5 -4
  38. package/dist/esm/services/TransactionService.d.ts +79 -12
  39. package/dist/esm/services/XykService.d.ts +226 -15
  40. package/dist/esm/util/ApiHelpers.d.ts +2 -1
  41. package/dist/esm/util/backoff.d.ts +2 -1
  42. package/dist/esm/util/types/TransactionServiceTypes.d.ts +11 -0
  43. package/dist/esm/util/types/XykServiceTypes.d.ts +114 -0
  44. package/dist/services/BalanceService.d.ts +14 -13
  45. package/dist/services/BalanceService.js +16 -15
  46. package/dist/services/BalanceService.js.map +1 -1
  47. package/dist/services/BaseService.d.ts +12 -11
  48. package/dist/services/BaseService.js +25 -24
  49. package/dist/services/BaseService.js.map +1 -1
  50. package/dist/services/CovalentClient.d.ts +5 -3
  51. package/dist/services/CovalentClient.js +17 -17
  52. package/dist/services/CovalentClient.js.map +1 -1
  53. package/dist/services/NftService.d.ts +18 -17
  54. package/dist/services/NftService.js +30 -29
  55. package/dist/services/NftService.js.map +1 -1
  56. package/dist/services/PricingService.d.ts +4 -3
  57. package/dist/services/PricingService.js +4 -3
  58. package/dist/services/PricingService.js.map +1 -1
  59. package/dist/services/SecurityService.d.ts +5 -4
  60. package/dist/services/SecurityService.js +6 -5
  61. package/dist/services/SecurityService.js.map +1 -1
  62. package/dist/services/TransactionService.d.ts +79 -12
  63. package/dist/services/TransactionService.js +369 -41
  64. package/dist/services/TransactionService.js.map +1 -1
  65. package/dist/services/XykService.d.ts +226 -15
  66. package/dist/services/XykService.js +335 -34
  67. package/dist/services/XykService.js.map +1 -1
  68. package/dist/util/ApiHelpers.d.ts +2 -1
  69. package/dist/util/ApiHelpers.js +3 -3
  70. package/dist/util/ApiHelpers.js.map +1 -1
  71. package/dist/util/backoff.d.ts +2 -1
  72. package/dist/util/backoff.js +3 -3
  73. package/dist/util/backoff.js.map +1 -1
  74. package/dist/util/types/TransactionServiceTypes.d.ts +11 -0
  75. package/dist/util/types/XykServiceTypes.d.ts +114 -0
  76. package/package.json +2 -2
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chalk = require('chalk');
3
+ var require$$0 = require('os');
4
+ var require$$1 = require('tty');
4
5
  var dateFns = require('date-fns');
5
6
  var Big = require('big.js');
6
7
 
@@ -13,7 +14,7 @@ class ExponentialBackoff {
13
14
  this._apiKey = apiKey;
14
15
  this._debug = debug;
15
16
  }
16
- async backOff(url) {
17
+ async backOff(url, source) {
17
18
  try {
18
19
  let startTime;
19
20
  if (this._debug) {
@@ -22,7 +23,7 @@ class ExponentialBackoff {
22
23
  const response = await fetch(url, {
23
24
  headers: {
24
25
  "Authorization": `Bearer ${this._apiKey}`,
25
- "X-Requested-With": userAgent
26
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
26
27
  }
27
28
  });
28
29
  debugOutput(response.url, response.status ?? 429, startTime);
@@ -38,7 +39,7 @@ class ExponentialBackoff {
38
39
  this.retryCount++;
39
40
  const delayMs = Math.pow(2, this.retryCount) * BASE_DELAY_MS;
40
41
  await new Promise((resolve) => setTimeout(resolve, delayMs));
41
- return this.backOff(url);
42
+ return this.backOff(url, source);
42
43
  }
43
44
  return Promise.reject(new Error(`Max retries exceeded: ${this.maxRetries}`));
44
45
  }
@@ -53,6 +54,1934 @@ function getDefaultExportFromCjs (x) {
53
54
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
54
55
  }
55
56
 
57
+ var ansiStyles$1 = {exports: {}};
58
+
59
+ var colorName;
60
+ var hasRequiredColorName;
61
+
62
+ function requireColorName () {
63
+ if (hasRequiredColorName) return colorName;
64
+ hasRequiredColorName = 1;
65
+
66
+ colorName = {
67
+ "aliceblue": [240, 248, 255],
68
+ "antiquewhite": [250, 235, 215],
69
+ "aqua": [0, 255, 255],
70
+ "aquamarine": [127, 255, 212],
71
+ "azure": [240, 255, 255],
72
+ "beige": [245, 245, 220],
73
+ "bisque": [255, 228, 196],
74
+ "black": [0, 0, 0],
75
+ "blanchedalmond": [255, 235, 205],
76
+ "blue": [0, 0, 255],
77
+ "blueviolet": [138, 43, 226],
78
+ "brown": [165, 42, 42],
79
+ "burlywood": [222, 184, 135],
80
+ "cadetblue": [95, 158, 160],
81
+ "chartreuse": [127, 255, 0],
82
+ "chocolate": [210, 105, 30],
83
+ "coral": [255, 127, 80],
84
+ "cornflowerblue": [100, 149, 237],
85
+ "cornsilk": [255, 248, 220],
86
+ "crimson": [220, 20, 60],
87
+ "cyan": [0, 255, 255],
88
+ "darkblue": [0, 0, 139],
89
+ "darkcyan": [0, 139, 139],
90
+ "darkgoldenrod": [184, 134, 11],
91
+ "darkgray": [169, 169, 169],
92
+ "darkgreen": [0, 100, 0],
93
+ "darkgrey": [169, 169, 169],
94
+ "darkkhaki": [189, 183, 107],
95
+ "darkmagenta": [139, 0, 139],
96
+ "darkolivegreen": [85, 107, 47],
97
+ "darkorange": [255, 140, 0],
98
+ "darkorchid": [153, 50, 204],
99
+ "darkred": [139, 0, 0],
100
+ "darksalmon": [233, 150, 122],
101
+ "darkseagreen": [143, 188, 143],
102
+ "darkslateblue": [72, 61, 139],
103
+ "darkslategray": [47, 79, 79],
104
+ "darkslategrey": [47, 79, 79],
105
+ "darkturquoise": [0, 206, 209],
106
+ "darkviolet": [148, 0, 211],
107
+ "deeppink": [255, 20, 147],
108
+ "deepskyblue": [0, 191, 255],
109
+ "dimgray": [105, 105, 105],
110
+ "dimgrey": [105, 105, 105],
111
+ "dodgerblue": [30, 144, 255],
112
+ "firebrick": [178, 34, 34],
113
+ "floralwhite": [255, 250, 240],
114
+ "forestgreen": [34, 139, 34],
115
+ "fuchsia": [255, 0, 255],
116
+ "gainsboro": [220, 220, 220],
117
+ "ghostwhite": [248, 248, 255],
118
+ "gold": [255, 215, 0],
119
+ "goldenrod": [218, 165, 32],
120
+ "gray": [128, 128, 128],
121
+ "green": [0, 128, 0],
122
+ "greenyellow": [173, 255, 47],
123
+ "grey": [128, 128, 128],
124
+ "honeydew": [240, 255, 240],
125
+ "hotpink": [255, 105, 180],
126
+ "indianred": [205, 92, 92],
127
+ "indigo": [75, 0, 130],
128
+ "ivory": [255, 255, 240],
129
+ "khaki": [240, 230, 140],
130
+ "lavender": [230, 230, 250],
131
+ "lavenderblush": [255, 240, 245],
132
+ "lawngreen": [124, 252, 0],
133
+ "lemonchiffon": [255, 250, 205],
134
+ "lightblue": [173, 216, 230],
135
+ "lightcoral": [240, 128, 128],
136
+ "lightcyan": [224, 255, 255],
137
+ "lightgoldenrodyellow": [250, 250, 210],
138
+ "lightgray": [211, 211, 211],
139
+ "lightgreen": [144, 238, 144],
140
+ "lightgrey": [211, 211, 211],
141
+ "lightpink": [255, 182, 193],
142
+ "lightsalmon": [255, 160, 122],
143
+ "lightseagreen": [32, 178, 170],
144
+ "lightskyblue": [135, 206, 250],
145
+ "lightslategray": [119, 136, 153],
146
+ "lightslategrey": [119, 136, 153],
147
+ "lightsteelblue": [176, 196, 222],
148
+ "lightyellow": [255, 255, 224],
149
+ "lime": [0, 255, 0],
150
+ "limegreen": [50, 205, 50],
151
+ "linen": [250, 240, 230],
152
+ "magenta": [255, 0, 255],
153
+ "maroon": [128, 0, 0],
154
+ "mediumaquamarine": [102, 205, 170],
155
+ "mediumblue": [0, 0, 205],
156
+ "mediumorchid": [186, 85, 211],
157
+ "mediumpurple": [147, 112, 219],
158
+ "mediumseagreen": [60, 179, 113],
159
+ "mediumslateblue": [123, 104, 238],
160
+ "mediumspringgreen": [0, 250, 154],
161
+ "mediumturquoise": [72, 209, 204],
162
+ "mediumvioletred": [199, 21, 133],
163
+ "midnightblue": [25, 25, 112],
164
+ "mintcream": [245, 255, 250],
165
+ "mistyrose": [255, 228, 225],
166
+ "moccasin": [255, 228, 181],
167
+ "navajowhite": [255, 222, 173],
168
+ "navy": [0, 0, 128],
169
+ "oldlace": [253, 245, 230],
170
+ "olive": [128, 128, 0],
171
+ "olivedrab": [107, 142, 35],
172
+ "orange": [255, 165, 0],
173
+ "orangered": [255, 69, 0],
174
+ "orchid": [218, 112, 214],
175
+ "palegoldenrod": [238, 232, 170],
176
+ "palegreen": [152, 251, 152],
177
+ "paleturquoise": [175, 238, 238],
178
+ "palevioletred": [219, 112, 147],
179
+ "papayawhip": [255, 239, 213],
180
+ "peachpuff": [255, 218, 185],
181
+ "peru": [205, 133, 63],
182
+ "pink": [255, 192, 203],
183
+ "plum": [221, 160, 221],
184
+ "powderblue": [176, 224, 230],
185
+ "purple": [128, 0, 128],
186
+ "rebeccapurple": [102, 51, 153],
187
+ "red": [255, 0, 0],
188
+ "rosybrown": [188, 143, 143],
189
+ "royalblue": [65, 105, 225],
190
+ "saddlebrown": [139, 69, 19],
191
+ "salmon": [250, 128, 114],
192
+ "sandybrown": [244, 164, 96],
193
+ "seagreen": [46, 139, 87],
194
+ "seashell": [255, 245, 238],
195
+ "sienna": [160, 82, 45],
196
+ "silver": [192, 192, 192],
197
+ "skyblue": [135, 206, 235],
198
+ "slateblue": [106, 90, 205],
199
+ "slategray": [112, 128, 144],
200
+ "slategrey": [112, 128, 144],
201
+ "snow": [255, 250, 250],
202
+ "springgreen": [0, 255, 127],
203
+ "steelblue": [70, 130, 180],
204
+ "tan": [210, 180, 140],
205
+ "teal": [0, 128, 128],
206
+ "thistle": [216, 191, 216],
207
+ "tomato": [255, 99, 71],
208
+ "turquoise": [64, 224, 208],
209
+ "violet": [238, 130, 238],
210
+ "wheat": [245, 222, 179],
211
+ "white": [255, 255, 255],
212
+ "whitesmoke": [245, 245, 245],
213
+ "yellow": [255, 255, 0],
214
+ "yellowgreen": [154, 205, 50]
215
+ };
216
+ return colorName;
217
+ }
218
+
219
+ /* MIT license */
220
+
221
+ var conversions;
222
+ var hasRequiredConversions;
223
+
224
+ function requireConversions () {
225
+ if (hasRequiredConversions) return conversions;
226
+ hasRequiredConversions = 1;
227
+ /* eslint-disable no-mixed-operators */
228
+ const cssKeywords = requireColorName();
229
+
230
+ // NOTE: conversions should only return primitive values (i.e. arrays, or
231
+ // values that give correct `typeof` results).
232
+ // do not use box values types (i.e. Number(), String(), etc.)
233
+
234
+ const reverseKeywords = {};
235
+ for (const key of Object.keys(cssKeywords)) {
236
+ reverseKeywords[cssKeywords[key]] = key;
237
+ }
238
+
239
+ const convert = {
240
+ rgb: {channels: 3, labels: 'rgb'},
241
+ hsl: {channels: 3, labels: 'hsl'},
242
+ hsv: {channels: 3, labels: 'hsv'},
243
+ hwb: {channels: 3, labels: 'hwb'},
244
+ cmyk: {channels: 4, labels: 'cmyk'},
245
+ xyz: {channels: 3, labels: 'xyz'},
246
+ lab: {channels: 3, labels: 'lab'},
247
+ lch: {channels: 3, labels: 'lch'},
248
+ hex: {channels: 1, labels: ['hex']},
249
+ keyword: {channels: 1, labels: ['keyword']},
250
+ ansi16: {channels: 1, labels: ['ansi16']},
251
+ ansi256: {channels: 1, labels: ['ansi256']},
252
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
253
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
254
+ gray: {channels: 1, labels: ['gray']}
255
+ };
256
+
257
+ conversions = convert;
258
+
259
+ // Hide .channels and .labels properties
260
+ for (const model of Object.keys(convert)) {
261
+ if (!('channels' in convert[model])) {
262
+ throw new Error('missing channels property: ' + model);
263
+ }
264
+
265
+ if (!('labels' in convert[model])) {
266
+ throw new Error('missing channel labels property: ' + model);
267
+ }
268
+
269
+ if (convert[model].labels.length !== convert[model].channels) {
270
+ throw new Error('channel and label counts mismatch: ' + model);
271
+ }
272
+
273
+ const {channels, labels} = convert[model];
274
+ delete convert[model].channels;
275
+ delete convert[model].labels;
276
+ Object.defineProperty(convert[model], 'channels', {value: channels});
277
+ Object.defineProperty(convert[model], 'labels', {value: labels});
278
+ }
279
+
280
+ convert.rgb.hsl = function (rgb) {
281
+ const r = rgb[0] / 255;
282
+ const g = rgb[1] / 255;
283
+ const b = rgb[2] / 255;
284
+ const min = Math.min(r, g, b);
285
+ const max = Math.max(r, g, b);
286
+ const delta = max - min;
287
+ let h;
288
+ let s;
289
+
290
+ if (max === min) {
291
+ h = 0;
292
+ } else if (r === max) {
293
+ h = (g - b) / delta;
294
+ } else if (g === max) {
295
+ h = 2 + (b - r) / delta;
296
+ } else if (b === max) {
297
+ h = 4 + (r - g) / delta;
298
+ }
299
+
300
+ h = Math.min(h * 60, 360);
301
+
302
+ if (h < 0) {
303
+ h += 360;
304
+ }
305
+
306
+ const l = (min + max) / 2;
307
+
308
+ if (max === min) {
309
+ s = 0;
310
+ } else if (l <= 0.5) {
311
+ s = delta / (max + min);
312
+ } else {
313
+ s = delta / (2 - max - min);
314
+ }
315
+
316
+ return [h, s * 100, l * 100];
317
+ };
318
+
319
+ convert.rgb.hsv = function (rgb) {
320
+ let rdif;
321
+ let gdif;
322
+ let bdif;
323
+ let h;
324
+ let s;
325
+
326
+ const r = rgb[0] / 255;
327
+ const g = rgb[1] / 255;
328
+ const b = rgb[2] / 255;
329
+ const v = Math.max(r, g, b);
330
+ const diff = v - Math.min(r, g, b);
331
+ const diffc = function (c) {
332
+ return (v - c) / 6 / diff + 1 / 2;
333
+ };
334
+
335
+ if (diff === 0) {
336
+ h = 0;
337
+ s = 0;
338
+ } else {
339
+ s = diff / v;
340
+ rdif = diffc(r);
341
+ gdif = diffc(g);
342
+ bdif = diffc(b);
343
+
344
+ if (r === v) {
345
+ h = bdif - gdif;
346
+ } else if (g === v) {
347
+ h = (1 / 3) + rdif - bdif;
348
+ } else if (b === v) {
349
+ h = (2 / 3) + gdif - rdif;
350
+ }
351
+
352
+ if (h < 0) {
353
+ h += 1;
354
+ } else if (h > 1) {
355
+ h -= 1;
356
+ }
357
+ }
358
+
359
+ return [
360
+ h * 360,
361
+ s * 100,
362
+ v * 100
363
+ ];
364
+ };
365
+
366
+ convert.rgb.hwb = function (rgb) {
367
+ const r = rgb[0];
368
+ const g = rgb[1];
369
+ let b = rgb[2];
370
+ const h = convert.rgb.hsl(rgb)[0];
371
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
372
+
373
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
374
+
375
+ return [h, w * 100, b * 100];
376
+ };
377
+
378
+ convert.rgb.cmyk = function (rgb) {
379
+ const r = rgb[0] / 255;
380
+ const g = rgb[1] / 255;
381
+ const b = rgb[2] / 255;
382
+
383
+ const k = Math.min(1 - r, 1 - g, 1 - b);
384
+ const c = (1 - r - k) / (1 - k) || 0;
385
+ const m = (1 - g - k) / (1 - k) || 0;
386
+ const y = (1 - b - k) / (1 - k) || 0;
387
+
388
+ return [c * 100, m * 100, y * 100, k * 100];
389
+ };
390
+
391
+ function comparativeDistance(x, y) {
392
+ /*
393
+ See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
394
+ */
395
+ return (
396
+ ((x[0] - y[0]) ** 2) +
397
+ ((x[1] - y[1]) ** 2) +
398
+ ((x[2] - y[2]) ** 2)
399
+ );
400
+ }
401
+
402
+ convert.rgb.keyword = function (rgb) {
403
+ const reversed = reverseKeywords[rgb];
404
+ if (reversed) {
405
+ return reversed;
406
+ }
407
+
408
+ let currentClosestDistance = Infinity;
409
+ let currentClosestKeyword;
410
+
411
+ for (const keyword of Object.keys(cssKeywords)) {
412
+ const value = cssKeywords[keyword];
413
+
414
+ // Compute comparative distance
415
+ const distance = comparativeDistance(rgb, value);
416
+
417
+ // Check if its less, if so set as closest
418
+ if (distance < currentClosestDistance) {
419
+ currentClosestDistance = distance;
420
+ currentClosestKeyword = keyword;
421
+ }
422
+ }
423
+
424
+ return currentClosestKeyword;
425
+ };
426
+
427
+ convert.keyword.rgb = function (keyword) {
428
+ return cssKeywords[keyword];
429
+ };
430
+
431
+ convert.rgb.xyz = function (rgb) {
432
+ let r = rgb[0] / 255;
433
+ let g = rgb[1] / 255;
434
+ let b = rgb[2] / 255;
435
+
436
+ // Assume sRGB
437
+ r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
438
+ g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
439
+ b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
440
+
441
+ const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
442
+ const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
443
+ const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
444
+
445
+ return [x * 100, y * 100, z * 100];
446
+ };
447
+
448
+ convert.rgb.lab = function (rgb) {
449
+ const xyz = convert.rgb.xyz(rgb);
450
+ let x = xyz[0];
451
+ let y = xyz[1];
452
+ let z = xyz[2];
453
+
454
+ x /= 95.047;
455
+ y /= 100;
456
+ z /= 108.883;
457
+
458
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
459
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
460
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
461
+
462
+ const l = (116 * y) - 16;
463
+ const a = 500 * (x - y);
464
+ const b = 200 * (y - z);
465
+
466
+ return [l, a, b];
467
+ };
468
+
469
+ convert.hsl.rgb = function (hsl) {
470
+ const h = hsl[0] / 360;
471
+ const s = hsl[1] / 100;
472
+ const l = hsl[2] / 100;
473
+ let t2;
474
+ let t3;
475
+ let val;
476
+
477
+ if (s === 0) {
478
+ val = l * 255;
479
+ return [val, val, val];
480
+ }
481
+
482
+ if (l < 0.5) {
483
+ t2 = l * (1 + s);
484
+ } else {
485
+ t2 = l + s - l * s;
486
+ }
487
+
488
+ const t1 = 2 * l - t2;
489
+
490
+ const rgb = [0, 0, 0];
491
+ for (let i = 0; i < 3; i++) {
492
+ t3 = h + 1 / 3 * -(i - 1);
493
+ if (t3 < 0) {
494
+ t3++;
495
+ }
496
+
497
+ if (t3 > 1) {
498
+ t3--;
499
+ }
500
+
501
+ if (6 * t3 < 1) {
502
+ val = t1 + (t2 - t1) * 6 * t3;
503
+ } else if (2 * t3 < 1) {
504
+ val = t2;
505
+ } else if (3 * t3 < 2) {
506
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
507
+ } else {
508
+ val = t1;
509
+ }
510
+
511
+ rgb[i] = val * 255;
512
+ }
513
+
514
+ return rgb;
515
+ };
516
+
517
+ convert.hsl.hsv = function (hsl) {
518
+ const h = hsl[0];
519
+ let s = hsl[1] / 100;
520
+ let l = hsl[2] / 100;
521
+ let smin = s;
522
+ const lmin = Math.max(l, 0.01);
523
+
524
+ l *= 2;
525
+ s *= (l <= 1) ? l : 2 - l;
526
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
527
+ const v = (l + s) / 2;
528
+ const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
529
+
530
+ return [h, sv * 100, v * 100];
531
+ };
532
+
533
+ convert.hsv.rgb = function (hsv) {
534
+ const h = hsv[0] / 60;
535
+ const s = hsv[1] / 100;
536
+ let v = hsv[2] / 100;
537
+ const hi = Math.floor(h) % 6;
538
+
539
+ const f = h - Math.floor(h);
540
+ const p = 255 * v * (1 - s);
541
+ const q = 255 * v * (1 - (s * f));
542
+ const t = 255 * v * (1 - (s * (1 - f)));
543
+ v *= 255;
544
+
545
+ switch (hi) {
546
+ case 0:
547
+ return [v, t, p];
548
+ case 1:
549
+ return [q, v, p];
550
+ case 2:
551
+ return [p, v, t];
552
+ case 3:
553
+ return [p, q, v];
554
+ case 4:
555
+ return [t, p, v];
556
+ case 5:
557
+ return [v, p, q];
558
+ }
559
+ };
560
+
561
+ convert.hsv.hsl = function (hsv) {
562
+ const h = hsv[0];
563
+ const s = hsv[1] / 100;
564
+ const v = hsv[2] / 100;
565
+ const vmin = Math.max(v, 0.01);
566
+ let sl;
567
+ let l;
568
+
569
+ l = (2 - s) * v;
570
+ const lmin = (2 - s) * vmin;
571
+ sl = s * vmin;
572
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
573
+ sl = sl || 0;
574
+ l /= 2;
575
+
576
+ return [h, sl * 100, l * 100];
577
+ };
578
+
579
+ // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
580
+ convert.hwb.rgb = function (hwb) {
581
+ const h = hwb[0] / 360;
582
+ let wh = hwb[1] / 100;
583
+ let bl = hwb[2] / 100;
584
+ const ratio = wh + bl;
585
+ let f;
586
+
587
+ // Wh + bl cant be > 1
588
+ if (ratio > 1) {
589
+ wh /= ratio;
590
+ bl /= ratio;
591
+ }
592
+
593
+ const i = Math.floor(6 * h);
594
+ const v = 1 - bl;
595
+ f = 6 * h - i;
596
+
597
+ if ((i & 0x01) !== 0) {
598
+ f = 1 - f;
599
+ }
600
+
601
+ const n = wh + f * (v - wh); // Linear interpolation
602
+
603
+ let r;
604
+ let g;
605
+ let b;
606
+ /* eslint-disable max-statements-per-line,no-multi-spaces */
607
+ switch (i) {
608
+ default:
609
+ case 6:
610
+ case 0: r = v; g = n; b = wh; break;
611
+ case 1: r = n; g = v; b = wh; break;
612
+ case 2: r = wh; g = v; b = n; break;
613
+ case 3: r = wh; g = n; b = v; break;
614
+ case 4: r = n; g = wh; b = v; break;
615
+ case 5: r = v; g = wh; b = n; break;
616
+ }
617
+ /* eslint-enable max-statements-per-line,no-multi-spaces */
618
+
619
+ return [r * 255, g * 255, b * 255];
620
+ };
621
+
622
+ convert.cmyk.rgb = function (cmyk) {
623
+ const c = cmyk[0] / 100;
624
+ const m = cmyk[1] / 100;
625
+ const y = cmyk[2] / 100;
626
+ const k = cmyk[3] / 100;
627
+
628
+ const r = 1 - Math.min(1, c * (1 - k) + k);
629
+ const g = 1 - Math.min(1, m * (1 - k) + k);
630
+ const b = 1 - Math.min(1, y * (1 - k) + k);
631
+
632
+ return [r * 255, g * 255, b * 255];
633
+ };
634
+
635
+ convert.xyz.rgb = function (xyz) {
636
+ const x = xyz[0] / 100;
637
+ const y = xyz[1] / 100;
638
+ const z = xyz[2] / 100;
639
+ let r;
640
+ let g;
641
+ let b;
642
+
643
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
644
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
645
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
646
+
647
+ // Assume sRGB
648
+ r = r > 0.0031308
649
+ ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
650
+ : r * 12.92;
651
+
652
+ g = g > 0.0031308
653
+ ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
654
+ : g * 12.92;
655
+
656
+ b = b > 0.0031308
657
+ ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
658
+ : b * 12.92;
659
+
660
+ r = Math.min(Math.max(0, r), 1);
661
+ g = Math.min(Math.max(0, g), 1);
662
+ b = Math.min(Math.max(0, b), 1);
663
+
664
+ return [r * 255, g * 255, b * 255];
665
+ };
666
+
667
+ convert.xyz.lab = function (xyz) {
668
+ let x = xyz[0];
669
+ let y = xyz[1];
670
+ let z = xyz[2];
671
+
672
+ x /= 95.047;
673
+ y /= 100;
674
+ z /= 108.883;
675
+
676
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
677
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
678
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
679
+
680
+ const l = (116 * y) - 16;
681
+ const a = 500 * (x - y);
682
+ const b = 200 * (y - z);
683
+
684
+ return [l, a, b];
685
+ };
686
+
687
+ convert.lab.xyz = function (lab) {
688
+ const l = lab[0];
689
+ const a = lab[1];
690
+ const b = lab[2];
691
+ let x;
692
+ let y;
693
+ let z;
694
+
695
+ y = (l + 16) / 116;
696
+ x = a / 500 + y;
697
+ z = y - b / 200;
698
+
699
+ const y2 = y ** 3;
700
+ const x2 = x ** 3;
701
+ const z2 = z ** 3;
702
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
703
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
704
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
705
+
706
+ x *= 95.047;
707
+ y *= 100;
708
+ z *= 108.883;
709
+
710
+ return [x, y, z];
711
+ };
712
+
713
+ convert.lab.lch = function (lab) {
714
+ const l = lab[0];
715
+ const a = lab[1];
716
+ const b = lab[2];
717
+ let h;
718
+
719
+ const hr = Math.atan2(b, a);
720
+ h = hr * 360 / 2 / Math.PI;
721
+
722
+ if (h < 0) {
723
+ h += 360;
724
+ }
725
+
726
+ const c = Math.sqrt(a * a + b * b);
727
+
728
+ return [l, c, h];
729
+ };
730
+
731
+ convert.lch.lab = function (lch) {
732
+ const l = lch[0];
733
+ const c = lch[1];
734
+ const h = lch[2];
735
+
736
+ const hr = h / 360 * 2 * Math.PI;
737
+ const a = c * Math.cos(hr);
738
+ const b = c * Math.sin(hr);
739
+
740
+ return [l, a, b];
741
+ };
742
+
743
+ convert.rgb.ansi16 = function (args, saturation = null) {
744
+ const [r, g, b] = args;
745
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
746
+
747
+ value = Math.round(value / 50);
748
+
749
+ if (value === 0) {
750
+ return 30;
751
+ }
752
+
753
+ let ansi = 30
754
+ + ((Math.round(b / 255) << 2)
755
+ | (Math.round(g / 255) << 1)
756
+ | Math.round(r / 255));
757
+
758
+ if (value === 2) {
759
+ ansi += 60;
760
+ }
761
+
762
+ return ansi;
763
+ };
764
+
765
+ convert.hsv.ansi16 = function (args) {
766
+ // Optimization here; we already know the value and don't need to get
767
+ // it converted for us.
768
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
769
+ };
770
+
771
+ convert.rgb.ansi256 = function (args) {
772
+ const r = args[0];
773
+ const g = args[1];
774
+ const b = args[2];
775
+
776
+ // We use the extended greyscale palette here, with the exception of
777
+ // black and white. normal palette only has 4 greyscale shades.
778
+ if (r === g && g === b) {
779
+ if (r < 8) {
780
+ return 16;
781
+ }
782
+
783
+ if (r > 248) {
784
+ return 231;
785
+ }
786
+
787
+ return Math.round(((r - 8) / 247) * 24) + 232;
788
+ }
789
+
790
+ const ansi = 16
791
+ + (36 * Math.round(r / 255 * 5))
792
+ + (6 * Math.round(g / 255 * 5))
793
+ + Math.round(b / 255 * 5);
794
+
795
+ return ansi;
796
+ };
797
+
798
+ convert.ansi16.rgb = function (args) {
799
+ let color = args % 10;
800
+
801
+ // Handle greyscale
802
+ if (color === 0 || color === 7) {
803
+ if (args > 50) {
804
+ color += 3.5;
805
+ }
806
+
807
+ color = color / 10.5 * 255;
808
+
809
+ return [color, color, color];
810
+ }
811
+
812
+ const mult = (~~(args > 50) + 1) * 0.5;
813
+ const r = ((color & 1) * mult) * 255;
814
+ const g = (((color >> 1) & 1) * mult) * 255;
815
+ const b = (((color >> 2) & 1) * mult) * 255;
816
+
817
+ return [r, g, b];
818
+ };
819
+
820
+ convert.ansi256.rgb = function (args) {
821
+ // Handle greyscale
822
+ if (args >= 232) {
823
+ const c = (args - 232) * 10 + 8;
824
+ return [c, c, c];
825
+ }
826
+
827
+ args -= 16;
828
+
829
+ let rem;
830
+ const r = Math.floor(args / 36) / 5 * 255;
831
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
832
+ const b = (rem % 6) / 5 * 255;
833
+
834
+ return [r, g, b];
835
+ };
836
+
837
+ convert.rgb.hex = function (args) {
838
+ const integer = ((Math.round(args[0]) & 0xFF) << 16)
839
+ + ((Math.round(args[1]) & 0xFF) << 8)
840
+ + (Math.round(args[2]) & 0xFF);
841
+
842
+ const string = integer.toString(16).toUpperCase();
843
+ return '000000'.substring(string.length) + string;
844
+ };
845
+
846
+ convert.hex.rgb = function (args) {
847
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
848
+ if (!match) {
849
+ return [0, 0, 0];
850
+ }
851
+
852
+ let colorString = match[0];
853
+
854
+ if (match[0].length === 3) {
855
+ colorString = colorString.split('').map(char => {
856
+ return char + char;
857
+ }).join('');
858
+ }
859
+
860
+ const integer = parseInt(colorString, 16);
861
+ const r = (integer >> 16) & 0xFF;
862
+ const g = (integer >> 8) & 0xFF;
863
+ const b = integer & 0xFF;
864
+
865
+ return [r, g, b];
866
+ };
867
+
868
+ convert.rgb.hcg = function (rgb) {
869
+ const r = rgb[0] / 255;
870
+ const g = rgb[1] / 255;
871
+ const b = rgb[2] / 255;
872
+ const max = Math.max(Math.max(r, g), b);
873
+ const min = Math.min(Math.min(r, g), b);
874
+ const chroma = (max - min);
875
+ let grayscale;
876
+ let hue;
877
+
878
+ if (chroma < 1) {
879
+ grayscale = min / (1 - chroma);
880
+ } else {
881
+ grayscale = 0;
882
+ }
883
+
884
+ if (chroma <= 0) {
885
+ hue = 0;
886
+ } else
887
+ if (max === r) {
888
+ hue = ((g - b) / chroma) % 6;
889
+ } else
890
+ if (max === g) {
891
+ hue = 2 + (b - r) / chroma;
892
+ } else {
893
+ hue = 4 + (r - g) / chroma;
894
+ }
895
+
896
+ hue /= 6;
897
+ hue %= 1;
898
+
899
+ return [hue * 360, chroma * 100, grayscale * 100];
900
+ };
901
+
902
+ convert.hsl.hcg = function (hsl) {
903
+ const s = hsl[1] / 100;
904
+ const l = hsl[2] / 100;
905
+
906
+ const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
907
+
908
+ let f = 0;
909
+ if (c < 1.0) {
910
+ f = (l - 0.5 * c) / (1.0 - c);
911
+ }
912
+
913
+ return [hsl[0], c * 100, f * 100];
914
+ };
915
+
916
+ convert.hsv.hcg = function (hsv) {
917
+ const s = hsv[1] / 100;
918
+ const v = hsv[2] / 100;
919
+
920
+ const c = s * v;
921
+ let f = 0;
922
+
923
+ if (c < 1.0) {
924
+ f = (v - c) / (1 - c);
925
+ }
926
+
927
+ return [hsv[0], c * 100, f * 100];
928
+ };
929
+
930
+ convert.hcg.rgb = function (hcg) {
931
+ const h = hcg[0] / 360;
932
+ const c = hcg[1] / 100;
933
+ const g = hcg[2] / 100;
934
+
935
+ if (c === 0.0) {
936
+ return [g * 255, g * 255, g * 255];
937
+ }
938
+
939
+ const pure = [0, 0, 0];
940
+ const hi = (h % 1) * 6;
941
+ const v = hi % 1;
942
+ const w = 1 - v;
943
+ let mg = 0;
944
+
945
+ /* eslint-disable max-statements-per-line */
946
+ switch (Math.floor(hi)) {
947
+ case 0:
948
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
949
+ case 1:
950
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
951
+ case 2:
952
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
953
+ case 3:
954
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
955
+ case 4:
956
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
957
+ default:
958
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
959
+ }
960
+ /* eslint-enable max-statements-per-line */
961
+
962
+ mg = (1.0 - c) * g;
963
+
964
+ return [
965
+ (c * pure[0] + mg) * 255,
966
+ (c * pure[1] + mg) * 255,
967
+ (c * pure[2] + mg) * 255
968
+ ];
969
+ };
970
+
971
+ convert.hcg.hsv = function (hcg) {
972
+ const c = hcg[1] / 100;
973
+ const g = hcg[2] / 100;
974
+
975
+ const v = c + g * (1.0 - c);
976
+ let f = 0;
977
+
978
+ if (v > 0.0) {
979
+ f = c / v;
980
+ }
981
+
982
+ return [hcg[0], f * 100, v * 100];
983
+ };
984
+
985
+ convert.hcg.hsl = function (hcg) {
986
+ const c = hcg[1] / 100;
987
+ const g = hcg[2] / 100;
988
+
989
+ const l = g * (1.0 - c) + 0.5 * c;
990
+ let s = 0;
991
+
992
+ if (l > 0.0 && l < 0.5) {
993
+ s = c / (2 * l);
994
+ } else
995
+ if (l >= 0.5 && l < 1.0) {
996
+ s = c / (2 * (1 - l));
997
+ }
998
+
999
+ return [hcg[0], s * 100, l * 100];
1000
+ };
1001
+
1002
+ convert.hcg.hwb = function (hcg) {
1003
+ const c = hcg[1] / 100;
1004
+ const g = hcg[2] / 100;
1005
+ const v = c + g * (1.0 - c);
1006
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1007
+ };
1008
+
1009
+ convert.hwb.hcg = function (hwb) {
1010
+ const w = hwb[1] / 100;
1011
+ const b = hwb[2] / 100;
1012
+ const v = 1 - b;
1013
+ const c = v - w;
1014
+ let g = 0;
1015
+
1016
+ if (c < 1) {
1017
+ g = (v - c) / (1 - c);
1018
+ }
1019
+
1020
+ return [hwb[0], c * 100, g * 100];
1021
+ };
1022
+
1023
+ convert.apple.rgb = function (apple) {
1024
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1025
+ };
1026
+
1027
+ convert.rgb.apple = function (rgb) {
1028
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1029
+ };
1030
+
1031
+ convert.gray.rgb = function (args) {
1032
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1033
+ };
1034
+
1035
+ convert.gray.hsl = function (args) {
1036
+ return [0, 0, args[0]];
1037
+ };
1038
+
1039
+ convert.gray.hsv = convert.gray.hsl;
1040
+
1041
+ convert.gray.hwb = function (gray) {
1042
+ return [0, 100, gray[0]];
1043
+ };
1044
+
1045
+ convert.gray.cmyk = function (gray) {
1046
+ return [0, 0, 0, gray[0]];
1047
+ };
1048
+
1049
+ convert.gray.lab = function (gray) {
1050
+ return [gray[0], 0, 0];
1051
+ };
1052
+
1053
+ convert.gray.hex = function (gray) {
1054
+ const val = Math.round(gray[0] / 100 * 255) & 0xFF;
1055
+ const integer = (val << 16) + (val << 8) + val;
1056
+
1057
+ const string = integer.toString(16).toUpperCase();
1058
+ return '000000'.substring(string.length) + string;
1059
+ };
1060
+
1061
+ convert.rgb.gray = function (rgb) {
1062
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1063
+ return [val / 255 * 100];
1064
+ };
1065
+ return conversions;
1066
+ }
1067
+
1068
+ var route;
1069
+ var hasRequiredRoute;
1070
+
1071
+ function requireRoute () {
1072
+ if (hasRequiredRoute) return route;
1073
+ hasRequiredRoute = 1;
1074
+ const conversions = requireConversions();
1075
+
1076
+ /*
1077
+ This function routes a model to all other models.
1078
+
1079
+ all functions that are routed have a property `.conversion` attached
1080
+ to the returned synthetic function. This property is an array
1081
+ of strings, each with the steps in between the 'from' and 'to'
1082
+ color models (inclusive).
1083
+
1084
+ conversions that are not possible simply are not included.
1085
+ */
1086
+
1087
+ function buildGraph() {
1088
+ const graph = {};
1089
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1090
+ const models = Object.keys(conversions);
1091
+
1092
+ for (let len = models.length, i = 0; i < len; i++) {
1093
+ graph[models[i]] = {
1094
+ // http://jsperf.com/1-vs-infinity
1095
+ // micro-opt, but this is simple.
1096
+ distance: -1,
1097
+ parent: null
1098
+ };
1099
+ }
1100
+
1101
+ return graph;
1102
+ }
1103
+
1104
+ // https://en.wikipedia.org/wiki/Breadth-first_search
1105
+ function deriveBFS(fromModel) {
1106
+ const graph = buildGraph();
1107
+ const queue = [fromModel]; // Unshift -> queue -> pop
1108
+
1109
+ graph[fromModel].distance = 0;
1110
+
1111
+ while (queue.length) {
1112
+ const current = queue.pop();
1113
+ const adjacents = Object.keys(conversions[current]);
1114
+
1115
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1116
+ const adjacent = adjacents[i];
1117
+ const node = graph[adjacent];
1118
+
1119
+ if (node.distance === -1) {
1120
+ node.distance = graph[current].distance + 1;
1121
+ node.parent = current;
1122
+ queue.unshift(adjacent);
1123
+ }
1124
+ }
1125
+ }
1126
+
1127
+ return graph;
1128
+ }
1129
+
1130
+ function link(from, to) {
1131
+ return function (args) {
1132
+ return to(from(args));
1133
+ };
1134
+ }
1135
+
1136
+ function wrapConversion(toModel, graph) {
1137
+ const path = [graph[toModel].parent, toModel];
1138
+ let fn = conversions[graph[toModel].parent][toModel];
1139
+
1140
+ let cur = graph[toModel].parent;
1141
+ while (graph[cur].parent) {
1142
+ path.unshift(graph[cur].parent);
1143
+ fn = link(conversions[graph[cur].parent][cur], fn);
1144
+ cur = graph[cur].parent;
1145
+ }
1146
+
1147
+ fn.conversion = path;
1148
+ return fn;
1149
+ }
1150
+
1151
+ route = function (fromModel) {
1152
+ const graph = deriveBFS(fromModel);
1153
+ const conversion = {};
1154
+
1155
+ const models = Object.keys(graph);
1156
+ for (let len = models.length, i = 0; i < len; i++) {
1157
+ const toModel = models[i];
1158
+ const node = graph[toModel];
1159
+
1160
+ if (node.parent === null) {
1161
+ // No possible conversion, or this node is the source model.
1162
+ continue;
1163
+ }
1164
+
1165
+ conversion[toModel] = wrapConversion(toModel, graph);
1166
+ }
1167
+
1168
+ return conversion;
1169
+ };
1170
+ return route;
1171
+ }
1172
+
1173
+ var colorConvert;
1174
+ var hasRequiredColorConvert;
1175
+
1176
+ function requireColorConvert () {
1177
+ if (hasRequiredColorConvert) return colorConvert;
1178
+ hasRequiredColorConvert = 1;
1179
+ const conversions = requireConversions();
1180
+ const route = requireRoute();
1181
+
1182
+ const convert = {};
1183
+
1184
+ const models = Object.keys(conversions);
1185
+
1186
+ function wrapRaw(fn) {
1187
+ const wrappedFn = function (...args) {
1188
+ const arg0 = args[0];
1189
+ if (arg0 === undefined || arg0 === null) {
1190
+ return arg0;
1191
+ }
1192
+
1193
+ if (arg0.length > 1) {
1194
+ args = arg0;
1195
+ }
1196
+
1197
+ return fn(args);
1198
+ };
1199
+
1200
+ // Preserve .conversion property if there is one
1201
+ if ('conversion' in fn) {
1202
+ wrappedFn.conversion = fn.conversion;
1203
+ }
1204
+
1205
+ return wrappedFn;
1206
+ }
1207
+
1208
+ function wrapRounded(fn) {
1209
+ const wrappedFn = function (...args) {
1210
+ const arg0 = args[0];
1211
+
1212
+ if (arg0 === undefined || arg0 === null) {
1213
+ return arg0;
1214
+ }
1215
+
1216
+ if (arg0.length > 1) {
1217
+ args = arg0;
1218
+ }
1219
+
1220
+ const result = fn(args);
1221
+
1222
+ // We're assuming the result is an array here.
1223
+ // see notice in conversions.js; don't use box types
1224
+ // in conversion functions.
1225
+ if (typeof result === 'object') {
1226
+ for (let len = result.length, i = 0; i < len; i++) {
1227
+ result[i] = Math.round(result[i]);
1228
+ }
1229
+ }
1230
+
1231
+ return result;
1232
+ };
1233
+
1234
+ // Preserve .conversion property if there is one
1235
+ if ('conversion' in fn) {
1236
+ wrappedFn.conversion = fn.conversion;
1237
+ }
1238
+
1239
+ return wrappedFn;
1240
+ }
1241
+
1242
+ models.forEach(fromModel => {
1243
+ convert[fromModel] = {};
1244
+
1245
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1246
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1247
+
1248
+ const routes = route(fromModel);
1249
+ const routeModels = Object.keys(routes);
1250
+
1251
+ routeModels.forEach(toModel => {
1252
+ const fn = routes[toModel];
1253
+
1254
+ convert[fromModel][toModel] = wrapRounded(fn);
1255
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1256
+ });
1257
+ });
1258
+
1259
+ colorConvert = convert;
1260
+ return colorConvert;
1261
+ }
1262
+
1263
+ ansiStyles$1.exports;
1264
+
1265
+ (function (module) {
1266
+
1267
+ const wrapAnsi16 = (fn, offset) => (...args) => {
1268
+ const code = fn(...args);
1269
+ return `\u001B[${code + offset}m`;
1270
+ };
1271
+
1272
+ const wrapAnsi256 = (fn, offset) => (...args) => {
1273
+ const code = fn(...args);
1274
+ return `\u001B[${38 + offset};5;${code}m`;
1275
+ };
1276
+
1277
+ const wrapAnsi16m = (fn, offset) => (...args) => {
1278
+ const rgb = fn(...args);
1279
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1280
+ };
1281
+
1282
+ const ansi2ansi = n => n;
1283
+ const rgb2rgb = (r, g, b) => [r, g, b];
1284
+
1285
+ const setLazyProperty = (object, property, get) => {
1286
+ Object.defineProperty(object, property, {
1287
+ get: () => {
1288
+ const value = get();
1289
+
1290
+ Object.defineProperty(object, property, {
1291
+ value,
1292
+ enumerable: true,
1293
+ configurable: true
1294
+ });
1295
+
1296
+ return value;
1297
+ },
1298
+ enumerable: true,
1299
+ configurable: true
1300
+ });
1301
+ };
1302
+
1303
+ /** @type {typeof import('color-convert')} */
1304
+ let colorConvert;
1305
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1306
+ if (colorConvert === undefined) {
1307
+ colorConvert = requireColorConvert();
1308
+ }
1309
+
1310
+ const offset = isBackground ? 10 : 0;
1311
+ const styles = {};
1312
+
1313
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
1314
+ const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
1315
+ if (sourceSpace === targetSpace) {
1316
+ styles[name] = wrap(identity, offset);
1317
+ } else if (typeof suite === 'object') {
1318
+ styles[name] = wrap(suite[targetSpace], offset);
1319
+ }
1320
+ }
1321
+
1322
+ return styles;
1323
+ };
1324
+
1325
+ function assembleStyles() {
1326
+ const codes = new Map();
1327
+ const styles = {
1328
+ modifier: {
1329
+ reset: [0, 0],
1330
+ // 21 isn't widely supported and 22 does the same thing
1331
+ bold: [1, 22],
1332
+ dim: [2, 22],
1333
+ italic: [3, 23],
1334
+ underline: [4, 24],
1335
+ inverse: [7, 27],
1336
+ hidden: [8, 28],
1337
+ strikethrough: [9, 29]
1338
+ },
1339
+ color: {
1340
+ black: [30, 39],
1341
+ red: [31, 39],
1342
+ green: [32, 39],
1343
+ yellow: [33, 39],
1344
+ blue: [34, 39],
1345
+ magenta: [35, 39],
1346
+ cyan: [36, 39],
1347
+ white: [37, 39],
1348
+
1349
+ // Bright color
1350
+ blackBright: [90, 39],
1351
+ redBright: [91, 39],
1352
+ greenBright: [92, 39],
1353
+ yellowBright: [93, 39],
1354
+ blueBright: [94, 39],
1355
+ magentaBright: [95, 39],
1356
+ cyanBright: [96, 39],
1357
+ whiteBright: [97, 39]
1358
+ },
1359
+ bgColor: {
1360
+ bgBlack: [40, 49],
1361
+ bgRed: [41, 49],
1362
+ bgGreen: [42, 49],
1363
+ bgYellow: [43, 49],
1364
+ bgBlue: [44, 49],
1365
+ bgMagenta: [45, 49],
1366
+ bgCyan: [46, 49],
1367
+ bgWhite: [47, 49],
1368
+
1369
+ // Bright color
1370
+ bgBlackBright: [100, 49],
1371
+ bgRedBright: [101, 49],
1372
+ bgGreenBright: [102, 49],
1373
+ bgYellowBright: [103, 49],
1374
+ bgBlueBright: [104, 49],
1375
+ bgMagentaBright: [105, 49],
1376
+ bgCyanBright: [106, 49],
1377
+ bgWhiteBright: [107, 49]
1378
+ }
1379
+ };
1380
+
1381
+ // Alias bright black as gray (and grey)
1382
+ styles.color.gray = styles.color.blackBright;
1383
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1384
+ styles.color.grey = styles.color.blackBright;
1385
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1386
+
1387
+ for (const [groupName, group] of Object.entries(styles)) {
1388
+ for (const [styleName, style] of Object.entries(group)) {
1389
+ styles[styleName] = {
1390
+ open: `\u001B[${style[0]}m`,
1391
+ close: `\u001B[${style[1]}m`
1392
+ };
1393
+
1394
+ group[styleName] = styles[styleName];
1395
+
1396
+ codes.set(style[0], style[1]);
1397
+ }
1398
+
1399
+ Object.defineProperty(styles, groupName, {
1400
+ value: group,
1401
+ enumerable: false
1402
+ });
1403
+ }
1404
+
1405
+ Object.defineProperty(styles, 'codes', {
1406
+ value: codes,
1407
+ enumerable: false
1408
+ });
1409
+
1410
+ styles.color.close = '\u001B[39m';
1411
+ styles.bgColor.close = '\u001B[49m';
1412
+
1413
+ setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
1414
+ setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
1415
+ setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
1416
+ setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
1417
+ setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
1418
+ setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
1419
+
1420
+ return styles;
1421
+ }
1422
+
1423
+ // Make the export immutable
1424
+ Object.defineProperty(module, 'exports', {
1425
+ enumerable: true,
1426
+ get: assembleStyles
1427
+ });
1428
+ } (ansiStyles$1));
1429
+
1430
+ var ansiStylesExports = ansiStyles$1.exports;
1431
+
1432
+ var hasFlag$1 = (flag, argv = process.argv) => {
1433
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
1434
+ const position = argv.indexOf(prefix + flag);
1435
+ const terminatorPosition = argv.indexOf('--');
1436
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1437
+ };
1438
+
1439
+ const os = require$$0;
1440
+ const tty = require$$1;
1441
+ const hasFlag = hasFlag$1;
1442
+
1443
+ const {env} = process;
1444
+
1445
+ let forceColor;
1446
+ if (hasFlag('no-color') ||
1447
+ hasFlag('no-colors') ||
1448
+ hasFlag('color=false') ||
1449
+ hasFlag('color=never')) {
1450
+ forceColor = 0;
1451
+ } else if (hasFlag('color') ||
1452
+ hasFlag('colors') ||
1453
+ hasFlag('color=true') ||
1454
+ hasFlag('color=always')) {
1455
+ forceColor = 1;
1456
+ }
1457
+
1458
+ if ('FORCE_COLOR' in env) {
1459
+ if (env.FORCE_COLOR === 'true') {
1460
+ forceColor = 1;
1461
+ } else if (env.FORCE_COLOR === 'false') {
1462
+ forceColor = 0;
1463
+ } else {
1464
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
1465
+ }
1466
+ }
1467
+
1468
+ function translateLevel(level) {
1469
+ if (level === 0) {
1470
+ return false;
1471
+ }
1472
+
1473
+ return {
1474
+ level,
1475
+ hasBasic: true,
1476
+ has256: level >= 2,
1477
+ has16m: level >= 3
1478
+ };
1479
+ }
1480
+
1481
+ function supportsColor(haveStream, streamIsTTY) {
1482
+ if (forceColor === 0) {
1483
+ return 0;
1484
+ }
1485
+
1486
+ if (hasFlag('color=16m') ||
1487
+ hasFlag('color=full') ||
1488
+ hasFlag('color=truecolor')) {
1489
+ return 3;
1490
+ }
1491
+
1492
+ if (hasFlag('color=256')) {
1493
+ return 2;
1494
+ }
1495
+
1496
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
1497
+ return 0;
1498
+ }
1499
+
1500
+ const min = forceColor || 0;
1501
+
1502
+ if (env.TERM === 'dumb') {
1503
+ return min;
1504
+ }
1505
+
1506
+ if (process.platform === 'win32') {
1507
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
1508
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
1509
+ const osRelease = os.release().split('.');
1510
+ if (
1511
+ Number(osRelease[0]) >= 10 &&
1512
+ Number(osRelease[2]) >= 10586
1513
+ ) {
1514
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
1515
+ }
1516
+
1517
+ return 1;
1518
+ }
1519
+
1520
+ if ('CI' in env) {
1521
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
1522
+ return 1;
1523
+ }
1524
+
1525
+ return min;
1526
+ }
1527
+
1528
+ if ('TEAMCITY_VERSION' in env) {
1529
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1530
+ }
1531
+
1532
+ if (env.COLORTERM === 'truecolor') {
1533
+ return 3;
1534
+ }
1535
+
1536
+ if ('TERM_PROGRAM' in env) {
1537
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1538
+
1539
+ switch (env.TERM_PROGRAM) {
1540
+ case 'iTerm.app':
1541
+ return version >= 3 ? 3 : 2;
1542
+ case 'Apple_Terminal':
1543
+ return 2;
1544
+ // No default
1545
+ }
1546
+ }
1547
+
1548
+ if (/-256(color)?$/i.test(env.TERM)) {
1549
+ return 2;
1550
+ }
1551
+
1552
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1553
+ return 1;
1554
+ }
1555
+
1556
+ if ('COLORTERM' in env) {
1557
+ return 1;
1558
+ }
1559
+
1560
+ return min;
1561
+ }
1562
+
1563
+ function getSupportLevel(stream) {
1564
+ const level = supportsColor(stream, stream && stream.isTTY);
1565
+ return translateLevel(level);
1566
+ }
1567
+
1568
+ var supportsColor_1 = {
1569
+ supportsColor: getSupportLevel,
1570
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
1571
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
1572
+ };
1573
+
1574
+ const stringReplaceAll$1 = (string, substring, replacer) => {
1575
+ let index = string.indexOf(substring);
1576
+ if (index === -1) {
1577
+ return string;
1578
+ }
1579
+
1580
+ const substringLength = substring.length;
1581
+ let endIndex = 0;
1582
+ let returnValue = '';
1583
+ do {
1584
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1585
+ endIndex = index + substringLength;
1586
+ index = string.indexOf(substring, endIndex);
1587
+ } while (index !== -1);
1588
+
1589
+ returnValue += string.substr(endIndex);
1590
+ return returnValue;
1591
+ };
1592
+
1593
+ const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
1594
+ let endIndex = 0;
1595
+ let returnValue = '';
1596
+ do {
1597
+ const gotCR = string[index - 1] === '\r';
1598
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
1599
+ endIndex = index + 1;
1600
+ index = string.indexOf('\n', endIndex);
1601
+ } while (index !== -1);
1602
+
1603
+ returnValue += string.substr(endIndex);
1604
+ return returnValue;
1605
+ };
1606
+
1607
+ var util = {
1608
+ stringReplaceAll: stringReplaceAll$1,
1609
+ stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
1610
+ };
1611
+
1612
+ var templates;
1613
+ var hasRequiredTemplates;
1614
+
1615
+ function requireTemplates () {
1616
+ if (hasRequiredTemplates) return templates;
1617
+ hasRequiredTemplates = 1;
1618
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1619
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1620
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1621
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1622
+
1623
+ const ESCAPES = new Map([
1624
+ ['n', '\n'],
1625
+ ['r', '\r'],
1626
+ ['t', '\t'],
1627
+ ['b', '\b'],
1628
+ ['f', '\f'],
1629
+ ['v', '\v'],
1630
+ ['0', '\0'],
1631
+ ['\\', '\\'],
1632
+ ['e', '\u001B'],
1633
+ ['a', '\u0007']
1634
+ ]);
1635
+
1636
+ function unescape(c) {
1637
+ const u = c[0] === 'u';
1638
+ const bracket = c[1] === '{';
1639
+
1640
+ if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
1641
+ return String.fromCharCode(parseInt(c.slice(1), 16));
1642
+ }
1643
+
1644
+ if (u && bracket) {
1645
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1646
+ }
1647
+
1648
+ return ESCAPES.get(c) || c;
1649
+ }
1650
+
1651
+ function parseArguments(name, arguments_) {
1652
+ const results = [];
1653
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
1654
+ let matches;
1655
+
1656
+ for (const chunk of chunks) {
1657
+ const number = Number(chunk);
1658
+ if (!Number.isNaN(number)) {
1659
+ results.push(number);
1660
+ } else if ((matches = chunk.match(STRING_REGEX))) {
1661
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1662
+ } else {
1663
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1664
+ }
1665
+ }
1666
+
1667
+ return results;
1668
+ }
1669
+
1670
+ function parseStyle(style) {
1671
+ STYLE_REGEX.lastIndex = 0;
1672
+
1673
+ const results = [];
1674
+ let matches;
1675
+
1676
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
1677
+ const name = matches[1];
1678
+
1679
+ if (matches[2]) {
1680
+ const args = parseArguments(name, matches[2]);
1681
+ results.push([name].concat(args));
1682
+ } else {
1683
+ results.push([name]);
1684
+ }
1685
+ }
1686
+
1687
+ return results;
1688
+ }
1689
+
1690
+ function buildStyle(chalk, styles) {
1691
+ const enabled = {};
1692
+
1693
+ for (const layer of styles) {
1694
+ for (const style of layer.styles) {
1695
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
1696
+ }
1697
+ }
1698
+
1699
+ let current = chalk;
1700
+ for (const [styleName, styles] of Object.entries(enabled)) {
1701
+ if (!Array.isArray(styles)) {
1702
+ continue;
1703
+ }
1704
+
1705
+ if (!(styleName in current)) {
1706
+ throw new Error(`Unknown Chalk style: ${styleName}`);
1707
+ }
1708
+
1709
+ current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
1710
+ }
1711
+
1712
+ return current;
1713
+ }
1714
+
1715
+ templates = (chalk, temporary) => {
1716
+ const styles = [];
1717
+ const chunks = [];
1718
+ let chunk = [];
1719
+
1720
+ // eslint-disable-next-line max-params
1721
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1722
+ if (escapeCharacter) {
1723
+ chunk.push(unescape(escapeCharacter));
1724
+ } else if (style) {
1725
+ const string = chunk.join('');
1726
+ chunk = [];
1727
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
1728
+ styles.push({inverse, styles: parseStyle(style)});
1729
+ } else if (close) {
1730
+ if (styles.length === 0) {
1731
+ throw new Error('Found extraneous } in Chalk template literal');
1732
+ }
1733
+
1734
+ chunks.push(buildStyle(chalk, styles)(chunk.join('')));
1735
+ chunk = [];
1736
+ styles.pop();
1737
+ } else {
1738
+ chunk.push(character);
1739
+ }
1740
+ });
1741
+
1742
+ chunks.push(chunk.join(''));
1743
+
1744
+ if (styles.length > 0) {
1745
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
1746
+ throw new Error(errMessage);
1747
+ }
1748
+
1749
+ return chunks.join('');
1750
+ };
1751
+ return templates;
1752
+ }
1753
+
1754
+ const ansiStyles = ansiStylesExports;
1755
+ const {stdout: stdoutColor, stderr: stderrColor} = supportsColor_1;
1756
+ const {
1757
+ stringReplaceAll,
1758
+ stringEncaseCRLFWithFirstIndex
1759
+ } = util;
1760
+
1761
+ const {isArray} = Array;
1762
+
1763
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
1764
+ const levelMapping = [
1765
+ 'ansi',
1766
+ 'ansi',
1767
+ 'ansi256',
1768
+ 'ansi16m'
1769
+ ];
1770
+
1771
+ const styles = Object.create(null);
1772
+
1773
+ const applyOptions = (object, options = {}) => {
1774
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1775
+ throw new Error('The `level` option should be an integer from 0 to 3');
1776
+ }
1777
+
1778
+ // Detect level if not set manually
1779
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
1780
+ object.level = options.level === undefined ? colorLevel : options.level;
1781
+ };
1782
+
1783
+ class ChalkClass {
1784
+ constructor(options) {
1785
+ // eslint-disable-next-line no-constructor-return
1786
+ return chalkFactory(options);
1787
+ }
1788
+ }
1789
+
1790
+ const chalkFactory = options => {
1791
+ const chalk = {};
1792
+ applyOptions(chalk, options);
1793
+
1794
+ chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
1795
+
1796
+ Object.setPrototypeOf(chalk, Chalk.prototype);
1797
+ Object.setPrototypeOf(chalk.template, chalk);
1798
+
1799
+ chalk.template.constructor = () => {
1800
+ throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
1801
+ };
1802
+
1803
+ chalk.template.Instance = ChalkClass;
1804
+
1805
+ return chalk.template;
1806
+ };
1807
+
1808
+ function Chalk(options) {
1809
+ return chalkFactory(options);
1810
+ }
1811
+
1812
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
1813
+ styles[styleName] = {
1814
+ get() {
1815
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1816
+ Object.defineProperty(this, styleName, {value: builder});
1817
+ return builder;
1818
+ }
1819
+ };
1820
+ }
1821
+
1822
+ styles.visible = {
1823
+ get() {
1824
+ const builder = createBuilder(this, this._styler, true);
1825
+ Object.defineProperty(this, 'visible', {value: builder});
1826
+ return builder;
1827
+ }
1828
+ };
1829
+
1830
+ const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
1831
+
1832
+ for (const model of usedModels) {
1833
+ styles[model] = {
1834
+ get() {
1835
+ const {level} = this;
1836
+ return function (...arguments_) {
1837
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1838
+ return createBuilder(this, styler, this._isEmpty);
1839
+ };
1840
+ }
1841
+ };
1842
+ }
1843
+
1844
+ for (const model of usedModels) {
1845
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
1846
+ styles[bgModel] = {
1847
+ get() {
1848
+ const {level} = this;
1849
+ return function (...arguments_) {
1850
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1851
+ return createBuilder(this, styler, this._isEmpty);
1852
+ };
1853
+ }
1854
+ };
1855
+ }
1856
+
1857
+ const proto = Object.defineProperties(() => {}, {
1858
+ ...styles,
1859
+ level: {
1860
+ enumerable: true,
1861
+ get() {
1862
+ return this._generator.level;
1863
+ },
1864
+ set(level) {
1865
+ this._generator.level = level;
1866
+ }
1867
+ }
1868
+ });
1869
+
1870
+ const createStyler = (open, close, parent) => {
1871
+ let openAll;
1872
+ let closeAll;
1873
+ if (parent === undefined) {
1874
+ openAll = open;
1875
+ closeAll = close;
1876
+ } else {
1877
+ openAll = parent.openAll + open;
1878
+ closeAll = close + parent.closeAll;
1879
+ }
1880
+
1881
+ return {
1882
+ open,
1883
+ close,
1884
+ openAll,
1885
+ closeAll,
1886
+ parent
1887
+ };
1888
+ };
1889
+
1890
+ const createBuilder = (self, _styler, _isEmpty) => {
1891
+ const builder = (...arguments_) => {
1892
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1893
+ // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
1894
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
1895
+ }
1896
+
1897
+ // Single argument is hot path, implicit coercion is faster than anything
1898
+ // eslint-disable-next-line no-implicit-coercion
1899
+ return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
1900
+ };
1901
+
1902
+ // We alter the prototype because we must return a function, but there is
1903
+ // no way to create a function with a different prototype
1904
+ Object.setPrototypeOf(builder, proto);
1905
+
1906
+ builder._generator = self;
1907
+ builder._styler = _styler;
1908
+ builder._isEmpty = _isEmpty;
1909
+
1910
+ return builder;
1911
+ };
1912
+
1913
+ const applyStyle = (self, string) => {
1914
+ if (self.level <= 0 || !string) {
1915
+ return self._isEmpty ? '' : string;
1916
+ }
1917
+
1918
+ let styler = self._styler;
1919
+
1920
+ if (styler === undefined) {
1921
+ return string;
1922
+ }
1923
+
1924
+ const {openAll, closeAll} = styler;
1925
+ if (string.indexOf('\u001B') !== -1) {
1926
+ while (styler !== undefined) {
1927
+ // Replace any instances already present with a re-opening code
1928
+ // otherwise only the part of the string until said closing code
1929
+ // will be colored, and the rest will simply be 'plain'.
1930
+ string = stringReplaceAll(string, styler.close, styler.open);
1931
+
1932
+ styler = styler.parent;
1933
+ }
1934
+ }
1935
+
1936
+ // We can move both next actions out of loop, because remaining actions in loop won't have
1937
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
1938
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
1939
+ const lfIndex = string.indexOf('\n');
1940
+ if (lfIndex !== -1) {
1941
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1942
+ }
1943
+
1944
+ return openAll + string + closeAll;
1945
+ };
1946
+
1947
+ let template;
1948
+ const chalkTag = (chalk, ...strings) => {
1949
+ const [firstString] = strings;
1950
+
1951
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
1952
+ // If chalk() was called by itself or with a string,
1953
+ // return the string itself as a string.
1954
+ return strings.join(' ');
1955
+ }
1956
+
1957
+ const arguments_ = strings.slice(1);
1958
+ const parts = [firstString.raw[0]];
1959
+
1960
+ for (let i = 1; i < firstString.length; i++) {
1961
+ parts.push(
1962
+ String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
1963
+ String(firstString.raw[i])
1964
+ );
1965
+ }
1966
+
1967
+ if (template === undefined) {
1968
+ template = requireTemplates();
1969
+ }
1970
+
1971
+ return template(chalk, parts.join(''));
1972
+ };
1973
+
1974
+ Object.defineProperties(Chalk.prototype, styles);
1975
+
1976
+ const chalk = Chalk(); // eslint-disable-line new-cap
1977
+ chalk.supportsColor = stdoutColor;
1978
+ chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
1979
+ chalk.stderr.supportsColor = stderrColor;
1980
+
1981
+ var source = chalk;
1982
+
1983
+ var chalk$1 = /*@__PURE__*/getDefaultExportFromCjs(source);
1984
+
56
1985
  class Node {
57
1986
  /// value;
58
1987
  /// next;
@@ -219,9 +2148,9 @@ async function debugOutput(url, responseStatus, startTime) {
219
2148
  endTime = performance.now();
220
2149
  elapsedTime = endTime - startTime;
221
2150
  }
222
- console.log(`${chalk.red("[DEBUG]")}` + " |" + ` Request URL: ${chalk.yellow(url)}` + " |" + ` Response code: ${responseStatus !== 200 ? chalk.red(responseStatus) : chalk.green(responseStatus)}` + " |" + ` Response time: ${chalk.cyan(elapsedTime.toFixed(2) + "ms")}`);
2151
+ console.log(`${chalk$1.red("[DEBUG]")}` + " |" + ` Request URL: ${chalk$1.yellow(url)}` + " |" + ` Response code: ${responseStatus !== 200 ? chalk$1.red(responseStatus) : chalk$1.green(responseStatus)}` + " |" + ` Response time: ${chalk$1.cyan(elapsedTime.toFixed(2) + "ms")}`);
223
2152
  }
224
- async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor, debug, threadCount, enableRetry) {
2153
+ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor, debug, threadCount, enableRetry, source) {
225
2154
  let hasNext = true;
226
2155
  let response;
227
2156
  let data;
@@ -238,13 +2167,13 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
238
2167
  response = await LIMIT(() => fetch(urlsParams.get("page-number") ? `${url}?${urlsParams}` : `${url}?${urlsParams}&page-number=${page_number}`, {
239
2168
  headers: {
240
2169
  "Authorization": `Bearer ${apiKey}`,
241
- "X-Requested-With": userAgent
2170
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
242
2171
  }
243
2172
  }));
244
2173
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
245
2174
  if ((enableRetry === true) && (!response || response.status === null || response.status === 429)) {
246
2175
  try {
247
- data = await LIMIT(() => backoff.backOff(response ? response.url : link));
2176
+ data = await LIMIT(() => backoff.backOff(response ? response.url : link, source));
248
2177
  }
249
2178
  catch (error) {
250
2179
  hasNext = false;
@@ -386,12 +2315,13 @@ class NftApprovalSpender {
386
2315
  *
387
2316
  */
388
2317
  class SecurityService {
389
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
2318
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
390
2319
  this.apiKey = apiKey;
391
2320
  this.debug = debug;
392
2321
  this.threadCount = threadCount;
393
2322
  this.is_key_valid = is_key_valid;
394
2323
  this.enableRetry = enableRetry;
2324
+ this.source = source;
395
2325
  this.LIMIT = pLimit$1(this.threadCount);
396
2326
  }
397
2327
  /**
@@ -426,13 +2356,13 @@ class SecurityService {
426
2356
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/approvals/${walletAddress}/?${urlParams}`, {
427
2357
  headers: {
428
2358
  "Authorization": `Bearer ${this.apiKey}`,
429
- "X-Requested-With": userAgent
2359
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
430
2360
  }
431
2361
  }));
432
2362
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
433
2363
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
434
2364
  try {
435
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2365
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
436
2366
  }
437
2367
  catch (error) {
438
2368
  success = true;
@@ -499,13 +2429,13 @@ class SecurityService {
499
2429
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/approvals/${walletAddress}/?${urlParams}`, {
500
2430
  headers: {
501
2431
  "Authorization": `Bearer ${this.apiKey}`,
502
- "X-Requested-With": userAgent
2432
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
503
2433
  }
504
2434
  }));
505
2435
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
506
2436
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
507
2437
  try {
508
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2438
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
509
2439
  }
510
2440
  catch (error) {
511
2441
  success = true;
@@ -824,12 +2754,13 @@ class NativeBalanceItem {
824
2754
  *
825
2755
  */
826
2756
  class BalanceService {
827
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
2757
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
828
2758
  this.apiKey = apiKey;
829
2759
  this.debug = debug;
830
2760
  this.threadCount = threadCount;
831
2761
  this.is_key_valid = is_key_valid;
832
2762
  this.enableRetry = enableRetry;
2763
+ this.source = source;
833
2764
  this.LIMIT = pLimit$1(this.threadCount);
834
2765
  }
835
2766
  /**
@@ -885,13 +2816,13 @@ class BalanceService {
885
2816
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`, {
886
2817
  headers: {
887
2818
  "Authorization": `Bearer ${this.apiKey}`,
888
- "X-Requested-With": userAgent
2819
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
889
2820
  }
890
2821
  }));
891
2822
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
892
2823
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
893
2824
  try {
894
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2825
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
895
2826
  }
896
2827
  catch (error) {
897
2828
  success = true;
@@ -968,13 +2899,13 @@ class BalanceService {
968
2899
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`, {
969
2900
  headers: {
970
2901
  "Authorization": `Bearer ${this.apiKey}`,
971
- "X-Requested-With": userAgent
2902
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
972
2903
  }
973
2904
  }));
974
2905
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
975
2906
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
976
2907
  try {
977
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2908
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
978
2909
  }
979
2910
  catch (error) {
980
2911
  success = true;
@@ -1052,7 +2983,7 @@ class BalanceService {
1052
2983
  if (queryParamOpts?.pageNumber !== undefined) {
1053
2984
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
1054
2985
  }
1055
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount, this.enableRetry)) {
2986
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount, this.enableRetry, this.source)) {
1056
2987
  yield res;
1057
2988
  }
1058
2989
  success = true;
@@ -1120,13 +3051,13 @@ class BalanceService {
1120
3051
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, {
1121
3052
  headers: {
1122
3053
  "Authorization": `Bearer ${this.apiKey}`,
1123
- "X-Requested-With": userAgent
3054
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1124
3055
  }
1125
3056
  }));
1126
3057
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1127
3058
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1128
3059
  try {
1129
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3060
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1130
3061
  }
1131
3062
  catch (error) {
1132
3063
  success = true;
@@ -1196,7 +3127,7 @@ class BalanceService {
1196
3127
  if (queryParamOpts?.date !== undefined) {
1197
3128
  urlParams.append("date", queryParamOpts?.date.toString());
1198
3129
  }
1199
- 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, this.enableRetry)) {
3130
+ 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, this.enableRetry, this.source)) {
1200
3131
  yield res;
1201
3132
  }
1202
3133
  success = true;
@@ -1256,13 +3187,13 @@ class BalanceService {
1256
3187
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
1257
3188
  headers: {
1258
3189
  "Authorization": `Bearer ${this.apiKey}`,
1259
- "X-Requested-With": userAgent
3190
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1260
3191
  }
1261
3192
  }));
1262
3193
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1263
3194
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1264
3195
  try {
1265
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3196
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1266
3197
  }
1267
3198
  catch (error) {
1268
3199
  success = true;
@@ -1359,13 +3290,13 @@ class BalanceService {
1359
3290
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/historical_balances/?${urlParams}`, {
1360
3291
  headers: {
1361
3292
  "Authorization": `Bearer ${this.apiKey}`,
1362
- "X-Requested-With": userAgent
3293
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1363
3294
  }
1364
3295
  }));
1365
3296
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1366
3297
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1367
3298
  try {
1368
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3299
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1369
3300
  }
1370
3301
  catch (error) {
1371
3302
  success = true;
@@ -1440,13 +3371,13 @@ class BalanceService {
1440
3371
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`, {
1441
3372
  headers: {
1442
3373
  "Authorization": `Bearer ${this.apiKey}`,
1443
- "X-Requested-With": userAgent
3374
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1444
3375
  }
1445
3376
  }));
1446
3377
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1447
3378
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1448
3379
  try {
1449
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3380
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1450
3381
  }
1451
3382
  catch (error) {
1452
3383
  success = true;
@@ -1705,12 +3636,13 @@ class OtherFees {
1705
3636
  *
1706
3637
  */
1707
3638
  class BaseService {
1708
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
3639
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
1709
3640
  this.apiKey = apiKey;
1710
3641
  this.debug = debug;
1711
3642
  this.threadCount = threadCount;
1712
3643
  this.is_key_valid = is_key_valid;
1713
3644
  this.enableRetry = enableRetry;
3645
+ this.source = source;
1714
3646
  this.LIMIT = pLimit$1(this.threadCount);
1715
3647
  }
1716
3648
  /**
@@ -1745,13 +3677,13 @@ class BaseService {
1745
3677
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${blockHeight}/?${urlParams}`, {
1746
3678
  headers: {
1747
3679
  "Authorization": `Bearer ${this.apiKey}`,
1748
- "X-Requested-With": userAgent
3680
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1749
3681
  }
1750
3682
  }));
1751
3683
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1752
3684
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1753
3685
  try {
1754
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3686
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1755
3687
  }
1756
3688
  catch (error) {
1757
3689
  success = true;
@@ -1819,13 +3751,13 @@ class BaseService {
1819
3751
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, {
1820
3752
  headers: {
1821
3753
  "Authorization": `Bearer ${this.apiKey}`,
1822
- "X-Requested-With": userAgent
3754
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1823
3755
  }
1824
3756
  }));
1825
3757
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1826
3758
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1827
3759
  try {
1828
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3760
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1829
3761
  }
1830
3762
  catch (error) {
1831
3763
  success = true;
@@ -1888,7 +3820,7 @@ class BaseService {
1888
3820
  if (queryParamOpts?.pageNumber !== undefined) {
1889
3821
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
1890
3822
  }
1891
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/`, this.apiKey, urlParams, Block, this.debug, this.threadCount, this.enableRetry)) {
3823
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/`, this.apiKey, urlParams, Block, this.debug, this.threadCount, this.enableRetry, this.source)) {
1892
3824
  yield res;
1893
3825
  }
1894
3826
  success = true;
@@ -1941,13 +3873,13 @@ class BaseService {
1941
3873
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/?${urlParams}`, {
1942
3874
  headers: {
1943
3875
  "Authorization": `Bearer ${this.apiKey}`,
1944
- "X-Requested-With": userAgent
3876
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1945
3877
  }
1946
3878
  }));
1947
3879
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1948
3880
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1949
3881
  try {
1950
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3882
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1951
3883
  }
1952
3884
  catch (error) {
1953
3885
  success = true;
@@ -2039,13 +3971,13 @@ class BaseService {
2039
3971
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, {
2040
3972
  headers: {
2041
3973
  "Authorization": `Bearer ${this.apiKey}`,
2042
- "X-Requested-With": userAgent
3974
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2043
3975
  }
2044
3976
  }));
2045
3977
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2046
3978
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2047
3979
  try {
2048
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3980
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2049
3981
  }
2050
3982
  catch (error) {
2051
3983
  success = true;
@@ -2115,7 +4047,7 @@ class BaseService {
2115
4047
  if (queryParamOpts?.pageNumber !== undefined) {
2116
4048
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
2117
4049
  }
2118
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount, this.enableRetry)) {
4050
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount, this.enableRetry, this.source)) {
2119
4051
  yield res;
2120
4052
  }
2121
4053
  success = true;
@@ -2175,13 +4107,13 @@ class BaseService {
2175
4107
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/?${urlParams}`, {
2176
4108
  headers: {
2177
4109
  "Authorization": `Bearer ${this.apiKey}`,
2178
- "X-Requested-With": userAgent
4110
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2179
4111
  }
2180
4112
  }));
2181
4113
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2182
4114
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2183
4115
  try {
2184
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4116
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2185
4117
  }
2186
4118
  catch (error) {
2187
4119
  success = true;
@@ -2255,7 +4187,7 @@ class BaseService {
2255
4187
  if (queryParamOpts?.pageNumber !== undefined) {
2256
4188
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
2257
4189
  }
2258
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount, this.enableRetry)) {
4190
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/`, this.apiKey, urlParams, LogEvent$2, this.debug, this.threadCount, this.enableRetry, this.source)) {
2259
4191
  yield res;
2260
4192
  }
2261
4193
  success = true;
@@ -2319,13 +4251,13 @@ class BaseService {
2319
4251
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/?${urlParams}`, {
2320
4252
  headers: {
2321
4253
  "Authorization": `Bearer ${this.apiKey}`,
2322
- "X-Requested-With": userAgent
4254
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2323
4255
  }
2324
4256
  }));
2325
4257
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2326
4258
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2327
4259
  try {
2328
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4260
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2329
4261
  }
2330
4262
  catch (error) {
2331
4263
  success = true;
@@ -2391,13 +4323,13 @@ class BaseService {
2391
4323
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/chains/?${urlParams}`, {
2392
4324
  headers: {
2393
4325
  "Authorization": `Bearer ${this.apiKey}`,
2394
- "X-Requested-With": userAgent
4326
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2395
4327
  }
2396
4328
  }));
2397
4329
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2398
4330
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2399
4331
  try {
2400
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4332
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2401
4333
  }
2402
4334
  catch (error) {
2403
4335
  success = true;
@@ -2463,13 +4395,13 @@ class BaseService {
2463
4395
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/chains/status/?${urlParams}`, {
2464
4396
  headers: {
2465
4397
  "Authorization": `Bearer ${this.apiKey}`,
2466
- "X-Requested-With": userAgent
4398
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2467
4399
  }
2468
4400
  }));
2469
4401
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2470
4402
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2471
4403
  try {
2472
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4404
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2473
4405
  }
2474
4406
  catch (error) {
2475
4407
  success = true;
@@ -2541,13 +4473,13 @@ class BaseService {
2541
4473
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/address/${walletAddress}/activity/?${urlParams}`, {
2542
4474
  headers: {
2543
4475
  "Authorization": `Bearer ${this.apiKey}`,
2544
- "X-Requested-With": userAgent
4476
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2545
4477
  }
2546
4478
  }));
2547
4479
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2548
4480
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2549
4481
  try {
2550
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4482
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2551
4483
  }
2552
4484
  catch (error) {
2553
4485
  success = true;
@@ -2618,13 +4550,13 @@ class BaseService {
2618
4550
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/event/${eventType}/gas_prices/?${urlParams}`, {
2619
4551
  headers: {
2620
4552
  "Authorization": `Bearer ${this.apiKey}`,
2621
- "X-Requested-With": userAgent
4553
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2622
4554
  }
2623
4555
  }));
2624
4556
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2625
4557
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2626
4558
  try {
2627
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4559
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2628
4560
  }
2629
4561
  catch (error) {
2630
4562
  success = true;
@@ -2984,12 +4916,13 @@ class MarketFloorPriceItem {
2984
4916
  *
2985
4917
  */
2986
4918
  class NftService {
2987
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
4919
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
2988
4920
  this.apiKey = apiKey;
2989
4921
  this.debug = debug;
2990
4922
  this.threadCount = threadCount;
2991
4923
  this.is_key_valid = is_key_valid;
2992
4924
  this.enableRetry = enableRetry;
4925
+ this.source = source;
2993
4926
  this.LIMIT = pLimit$1(this.threadCount);
2994
4927
  }
2995
4928
  /**
@@ -3021,7 +4954,7 @@ class NftService {
3021
4954
  if (queryParamOpts?.noSpam !== undefined) {
3022
4955
  urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
3023
4956
  }
3024
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/collections/`, this.apiKey, urlParams, ChainCollectionItem, this.debug, this.threadCount, this.enableRetry)) {
4957
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/collections/`, this.apiKey, urlParams, ChainCollectionItem, this.debug, this.threadCount, this.enableRetry, this.source)) {
3025
4958
  yield res;
3026
4959
  }
3027
4960
  success = true;
@@ -3076,13 +5009,13 @@ class NftService {
3076
5009
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, {
3077
5010
  headers: {
3078
5011
  "Authorization": `Bearer ${this.apiKey}`,
3079
- "X-Requested-With": userAgent
5012
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3080
5013
  }
3081
5014
  }));
3082
5015
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3083
5016
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3084
5017
  try {
3085
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5018
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3086
5019
  }
3087
5020
  catch (error) {
3088
5021
  success = true;
@@ -3163,13 +5096,13 @@ class NftService {
3163
5096
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
3164
5097
  headers: {
3165
5098
  "Authorization": `Bearer ${this.apiKey}`,
3166
- "X-Requested-With": userAgent
5099
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3167
5100
  }
3168
5101
  }));
3169
5102
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3170
5103
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3171
5104
  try {
3172
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5105
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3173
5106
  }
3174
5107
  catch (error) {
3175
5108
  success = true;
@@ -3247,7 +5180,7 @@ class NftService {
3247
5180
  if (queryParamOpts?.withUncached !== undefined) {
3248
5181
  urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
3249
5182
  }
3250
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount, this.enableRetry)) {
5183
+ for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/`, this.apiKey, urlParams, NftTokenContract, this.debug, this.threadCount, this.enableRetry, this.source)) {
3251
5184
  yield res;
3252
5185
  }
3253
5186
  success = true;
@@ -3315,13 +5248,13 @@ class NftService {
3315
5248
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, {
3316
5249
  headers: {
3317
5250
  "Authorization": `Bearer ${this.apiKey}`,
3318
- "X-Requested-With": userAgent
5251
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3319
5252
  }
3320
5253
  }));
3321
5254
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3322
5255
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3323
5256
  try {
3324
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5257
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3325
5258
  }
3326
5259
  catch (error) {
3327
5260
  success = true;
@@ -3399,13 +5332,13 @@ class NftService {
3399
5332
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
3400
5333
  headers: {
3401
5334
  "Authorization": `Bearer ${this.apiKey}`,
3402
- "X-Requested-With": userAgent
5335
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3403
5336
  }
3404
5337
  }));
3405
5338
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3406
5339
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3407
5340
  try {
3408
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5341
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3409
5342
  }
3410
5343
  catch (error) {
3411
5344
  success = true;
@@ -3479,13 +5412,13 @@ class NftService {
3479
5412
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
3480
5413
  headers: {
3481
5414
  "Authorization": `Bearer ${this.apiKey}`,
3482
- "X-Requested-With": userAgent
5415
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3483
5416
  }
3484
5417
  }));
3485
5418
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3486
5419
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3487
5420
  try {
3488
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5421
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3489
5422
  }
3490
5423
  catch (error) {
3491
5424
  success = true;
@@ -3553,13 +5486,13 @@ class NftService {
3553
5486
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
3554
5487
  headers: {
3555
5488
  "Authorization": `Bearer ${this.apiKey}`,
3556
- "X-Requested-With": userAgent
5489
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3557
5490
  }
3558
5491
  }));
3559
5492
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3560
5493
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3561
5494
  try {
3562
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5495
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3563
5496
  }
3564
5497
  catch (error) {
3565
5498
  success = true;
@@ -3628,13 +5561,13 @@ class NftService {
3628
5561
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
3629
5562
  headers: {
3630
5563
  "Authorization": `Bearer ${this.apiKey}`,
3631
- "X-Requested-With": userAgent
5564
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3632
5565
  }
3633
5566
  }));
3634
5567
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3635
5568
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3636
5569
  try {
3637
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5570
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3638
5571
  }
3639
5572
  catch (error) {
3640
5573
  success = true;
@@ -3702,13 +5635,13 @@ class NftService {
3702
5635
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
3703
5636
  headers: {
3704
5637
  "Authorization": `Bearer ${this.apiKey}`,
3705
- "X-Requested-With": userAgent
5638
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3706
5639
  }
3707
5640
  }));
3708
5641
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3709
5642
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3710
5643
  try {
3711
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5644
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3712
5645
  }
3713
5646
  catch (error) {
3714
5647
  success = true;
@@ -3777,13 +5710,13 @@ class NftService {
3777
5710
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
3778
5711
  headers: {
3779
5712
  "Authorization": `Bearer ${this.apiKey}`,
3780
- "X-Requested-With": userAgent
5713
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3781
5714
  }
3782
5715
  }));
3783
5716
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3784
5717
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3785
5718
  try {
3786
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5719
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3787
5720
  }
3788
5721
  catch (error) {
3789
5722
  success = true;
@@ -3853,13 +5786,13 @@ class NftService {
3853
5786
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
3854
5787
  headers: {
3855
5788
  "Authorization": `Bearer ${this.apiKey}`,
3856
- "X-Requested-With": userAgent
5789
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3857
5790
  }
3858
5791
  }));
3859
5792
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3860
5793
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3861
5794
  try {
3862
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5795
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3863
5796
  }
3864
5797
  catch (error) {
3865
5798
  success = true;
@@ -3936,13 +5869,13 @@ class NftService {
3936
5869
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`, {
3937
5870
  headers: {
3938
5871
  "Authorization": `Bearer ${this.apiKey}`,
3939
- "X-Requested-With": userAgent
5872
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3940
5873
  }
3941
5874
  }));
3942
5875
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3943
5876
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3944
5877
  try {
3945
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5878
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3946
5879
  }
3947
5880
  catch (error) {
3948
5881
  success = true;
@@ -4019,13 +5952,13 @@ class NftService {
4019
5952
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`, {
4020
5953
  headers: {
4021
5954
  "Authorization": `Bearer ${this.apiKey}`,
4022
- "X-Requested-With": userAgent
5955
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4023
5956
  }
4024
5957
  }));
4025
5958
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4026
5959
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4027
5960
  try {
4028
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5961
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4029
5962
  }
4030
5963
  catch (error) {
4031
5964
  success = true;
@@ -4102,13 +6035,13 @@ class NftService {
4102
6035
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`, {
4103
6036
  headers: {
4104
6037
  "Authorization": `Bearer ${this.apiKey}`,
4105
- "X-Requested-With": userAgent
6038
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4106
6039
  }
4107
6040
  }));
4108
6041
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4109
6042
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4110
6043
  try {
4111
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6044
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4112
6045
  }
4113
6046
  catch (error) {
4114
6047
  success = true;
@@ -4179,12 +6112,13 @@ let ContractMetadata$2 = class ContractMetadata {
4179
6112
  }
4180
6113
  };
4181
6114
  class PricingService {
4182
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
6115
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
4183
6116
  this.apiKey = apiKey;
4184
6117
  this.debug = debug;
4185
6118
  this.threadCount = threadCount;
4186
6119
  this.is_key_valid = is_key_valid;
4187
6120
  this.enableRetry = enableRetry;
6121
+ this.source = source;
4188
6122
  this.LIMIT = pLimit$1(this.threadCount);
4189
6123
  }
4190
6124
  /**
@@ -4233,13 +6167,13 @@ class PricingService {
4233
6167
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/pricing/historical_by_addresses_v2/${chainName}/${quoteCurrency}/${contractAddress}/?${urlParams}`, {
4234
6168
  headers: {
4235
6169
  "Authorization": `Bearer ${this.apiKey}`,
4236
- "X-Requested-With": userAgent
6170
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4237
6171
  }
4238
6172
  }));
4239
6173
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4240
6174
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4241
6175
  try {
4242
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6176
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4243
6177
  }
4244
6178
  catch (error) {
4245
6179
  success = true;
@@ -4485,28 +6419,184 @@ class DecodedItem {
4485
6419
  this.params = data.params && data.params !== null ? data.params.map((itemData) => new Param(itemData)) : null;
4486
6420
  }
4487
6421
  }
4488
- class Param {
6422
+ class Param {
6423
+ constructor(data) {
6424
+ this.name = data.name;
6425
+ this.type = data.type;
6426
+ this.indexed = data.indexed;
6427
+ this.decoded = data.decoded;
6428
+ this.value = data.value;
6429
+ }
6430
+ }
6431
+ class RecentTransactionsResponse {
6432
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
6433
+ this._debug = _debug;
6434
+ this._apiKey = _apiKey;
6435
+ this._threadCount = _threadCount;
6436
+ this._urlParams = _urlParams;
6437
+ this._enableRetry = _enableRetry;
6438
+ this._source = _source;
6439
+ this.address = data.address;
6440
+ this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
6441
+ this.quote_currency = data.quote_currency;
6442
+ this.chain_id = data.chain_id;
6443
+ this.chain_name = data.chain_name;
6444
+ this.current_page = data.current_page;
6445
+ this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
6446
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
6447
+ }
6448
+ async prev() {
6449
+ let success = false;
6450
+ let data;
6451
+ let response;
6452
+ const backoff = new ExponentialBackoff(this._apiKey, this._debug);
6453
+ const LIMIT = pLimit$1(this._threadCount);
6454
+ while (!success) {
6455
+ try {
6456
+ let startTime;
6457
+ if (this._debug) {
6458
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
6459
+ }
6460
+ if (this.links.prev === null) {
6461
+ success = true;
6462
+ return {
6463
+ data: null,
6464
+ error: true,
6465
+ error_code: 400,
6466
+ error_message: "Invalid URL: URL link cannot be null"
6467
+ };
6468
+ }
6469
+ const url = `${this.links.prev}?${this._urlParams}`;
6470
+ response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
6471
+ headers: {
6472
+ "Authorization": `Bearer ${this._apiKey}`,
6473
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
6474
+ }
6475
+ }));
6476
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6477
+ if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6478
+ try {
6479
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
6480
+ }
6481
+ catch (error) {
6482
+ success = true;
6483
+ return {
6484
+ data: null,
6485
+ error: true,
6486
+ error_code: response.status ?? 429,
6487
+ error_message: error.message
6488
+ };
6489
+ }
6490
+ }
6491
+ else {
6492
+ data = await response.json();
6493
+ }
6494
+ const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
6495
+ checkAndModifyResponse(dataClass);
6496
+ success = true;
6497
+ return {
6498
+ data: dataClass,
6499
+ error: data.error,
6500
+ error_code: data ? data.error_code : response.status,
6501
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
6502
+ };
6503
+ }
6504
+ catch (error) {
6505
+ success = true;
6506
+ return {
6507
+ data: null,
6508
+ error: true,
6509
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
6510
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
6511
+ };
6512
+ }
6513
+ }
6514
+ }
6515
+ async next() {
6516
+ let success = false;
6517
+ let data;
6518
+ let response;
6519
+ const backoff = new ExponentialBackoff(this._apiKey, this._debug);
6520
+ const LIMIT = pLimit$1(this._threadCount);
6521
+ while (!success) {
6522
+ try {
6523
+ let startTime;
6524
+ if (this._debug) {
6525
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
6526
+ }
6527
+ if (this.links.next === null) {
6528
+ success = true;
6529
+ return {
6530
+ data: null,
6531
+ error: true,
6532
+ error_code: 400,
6533
+ error_message: "Invalid URL: URL link cannot be null"
6534
+ };
6535
+ }
6536
+ const url = `${this.links.next}?${this._urlParams}`;
6537
+ response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
6538
+ headers: {
6539
+ "Authorization": `Bearer ${this._apiKey}`,
6540
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
6541
+ }
6542
+ }));
6543
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6544
+ if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6545
+ try {
6546
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
6547
+ }
6548
+ catch (error) {
6549
+ success = true;
6550
+ return {
6551
+ data: null,
6552
+ error: true,
6553
+ error_code: response.status ?? 429,
6554
+ error_message: error.message
6555
+ };
6556
+ }
6557
+ }
6558
+ else {
6559
+ data = await response.json();
6560
+ }
6561
+ const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
6562
+ checkAndModifyResponse(dataClass);
6563
+ success = true;
6564
+ return {
6565
+ data: dataClass,
6566
+ error: data.error,
6567
+ error_code: data ? data.error_code : response.status,
6568
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
6569
+ };
6570
+ }
6571
+ catch (error) {
6572
+ success = true;
6573
+ return {
6574
+ data: null,
6575
+ error: true,
6576
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
6577
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
6578
+ };
6579
+ }
6580
+ }
6581
+ }
6582
+ }
6583
+ class PaginationLinks {
4489
6584
  constructor(data) {
4490
- this.name = data.name;
4491
- this.type = data.type;
4492
- this.indexed = data.indexed;
4493
- this.decoded = data.decoded;
4494
- this.value = data.value;
6585
+ this.prev = data.prev;
6586
+ this.next = data.next;
4495
6587
  }
4496
6588
  }
4497
- class RecentTransactionsResponse {
4498
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
6589
+ class TransactionsBlockPageResponse {
6590
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4499
6591
  this._debug = _debug;
4500
6592
  this._apiKey = _apiKey;
4501
6593
  this._threadCount = _threadCount;
4502
6594
  this._urlParams = _urlParams;
4503
6595
  this._enableRetry = _enableRetry;
4504
- this.address = data.address;
6596
+ this._source = _source;
4505
6597
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
4506
- this.quote_currency = data.quote_currency;
4507
6598
  this.chain_id = data.chain_id;
4508
6599
  this.chain_name = data.chain_name;
4509
- this.current_page = data.current_page;
4510
6600
  this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
4511
6601
  this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
4512
6602
  }
@@ -4535,13 +6625,13 @@ class RecentTransactionsResponse {
4535
6625
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4536
6626
  headers: {
4537
6627
  "Authorization": `Bearer ${this._apiKey}`,
4538
- "X-Requested-With": userAgent
6628
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4539
6629
  }
4540
6630
  }));
4541
6631
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4542
6632
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4543
6633
  try {
4544
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
6634
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4545
6635
  }
4546
6636
  catch (error) {
4547
6637
  success = true;
@@ -4556,7 +6646,7 @@ class RecentTransactionsResponse {
4556
6646
  else {
4557
6647
  data = await response.json();
4558
6648
  }
4559
- const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
6649
+ const dataClass = new TransactionsBlockPageResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4560
6650
  checkAndModifyResponse(dataClass);
4561
6651
  success = true;
4562
6652
  return {
@@ -4602,13 +6692,13 @@ class RecentTransactionsResponse {
4602
6692
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4603
6693
  headers: {
4604
6694
  "Authorization": `Bearer ${this._apiKey}`,
4605
- "X-Requested-With": userAgent
6695
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4606
6696
  }
4607
6697
  }));
4608
6698
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4609
6699
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4610
6700
  try {
4611
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
6701
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4612
6702
  }
4613
6703
  catch (error) {
4614
6704
  success = true;
@@ -4623,7 +6713,7 @@ class RecentTransactionsResponse {
4623
6713
  else {
4624
6714
  data = await response.json();
4625
6715
  }
4626
- const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
6716
+ const dataClass = new TransactionsBlockPageResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4627
6717
  checkAndModifyResponse(dataClass);
4628
6718
  success = true;
4629
6719
  return {
@@ -4645,12 +6735,6 @@ class RecentTransactionsResponse {
4645
6735
  }
4646
6736
  }
4647
6737
  }
4648
- class PaginationLinks {
4649
- constructor(data) {
4650
- this.prev = data.prev;
4651
- this.next = data.next;
4652
- }
4653
- }
4654
6738
  class TransactionsBlockResponse {
4655
6739
  constructor(data) {
4656
6740
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
@@ -4683,12 +6767,13 @@ class TransactionSummary {
4683
6767
  }
4684
6768
  }
4685
6769
  class TransactionsResponse {
4686
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
6770
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4687
6771
  this._debug = _debug;
4688
6772
  this._apiKey = _apiKey;
4689
6773
  this._threadCount = _threadCount;
4690
6774
  this._urlParams = _urlParams;
4691
6775
  this._enableRetry = _enableRetry;
6776
+ this._source = _source;
4692
6777
  this.address = data.address;
4693
6778
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
4694
6779
  this.quote_currency = data.quote_currency;
@@ -4723,13 +6808,13 @@ class TransactionsResponse {
4723
6808
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4724
6809
  headers: {
4725
6810
  "Authorization": `Bearer ${this._apiKey}`,
4726
- "X-Requested-With": userAgent
6811
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4727
6812
  }
4728
6813
  }));
4729
6814
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4730
6815
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4731
6816
  try {
4732
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
6817
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4733
6818
  }
4734
6819
  catch (error) {
4735
6820
  success = true;
@@ -4744,7 +6829,7 @@ class TransactionsResponse {
4744
6829
  else {
4745
6830
  data = await response.json();
4746
6831
  }
4747
- const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
6832
+ const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4748
6833
  checkAndModifyResponse(dataClass);
4749
6834
  success = true;
4750
6835
  return {
@@ -4790,13 +6875,13 @@ class TransactionsResponse {
4790
6875
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4791
6876
  headers: {
4792
6877
  "Authorization": `Bearer ${this._apiKey}`,
4793
- "X-Requested-With": userAgent
6878
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4794
6879
  }
4795
6880
  }));
4796
6881
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4797
6882
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4798
6883
  try {
4799
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
6884
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4800
6885
  }
4801
6886
  catch (error) {
4802
6887
  success = true;
@@ -4811,7 +6896,7 @@ class TransactionsResponse {
4811
6896
  else {
4812
6897
  data = await response.json();
4813
6898
  }
4814
- const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
6899
+ const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4815
6900
  checkAndModifyResponse(dataClass);
4816
6901
  success = true;
4817
6902
  return {
@@ -4834,12 +6919,13 @@ class TransactionsResponse {
4834
6919
  }
4835
6920
  }
4836
6921
  class TransactionsTimeBucketResponse {
4837
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
6922
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4838
6923
  this._debug = _debug;
4839
6924
  this._apiKey = _apiKey;
4840
6925
  this._threadCount = _threadCount;
4841
6926
  this._urlParams = _urlParams;
4842
6927
  this._enableRetry = _enableRetry;
6928
+ this._source = _source;
4843
6929
  this.address = data.address;
4844
6930
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
4845
6931
  this.quote_currency = data.quote_currency;
@@ -4875,13 +6961,13 @@ class TransactionsTimeBucketResponse {
4875
6961
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4876
6962
  headers: {
4877
6963
  "Authorization": `Bearer ${this._apiKey}`,
4878
- "X-Requested-With": userAgent
6964
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4879
6965
  }
4880
6966
  }));
4881
6967
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4882
6968
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4883
6969
  try {
4884
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
6970
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4885
6971
  }
4886
6972
  catch (error) {
4887
6973
  success = true;
@@ -4896,7 +6982,7 @@ class TransactionsTimeBucketResponse {
4896
6982
  else {
4897
6983
  data = await response.json();
4898
6984
  }
4899
- const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
6985
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4900
6986
  checkAndModifyResponse(dataClass);
4901
6987
  success = true;
4902
6988
  return {
@@ -4942,13 +7028,13 @@ class TransactionsTimeBucketResponse {
4942
7028
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4943
7029
  headers: {
4944
7030
  "Authorization": `Bearer ${this._apiKey}`,
4945
- "X-Requested-With": userAgent
7031
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4946
7032
  }
4947
7033
  }));
4948
7034
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4949
7035
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4950
7036
  try {
4951
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
7037
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4952
7038
  }
4953
7039
  catch (error) {
4954
7040
  success = true;
@@ -4963,7 +7049,7 @@ class TransactionsTimeBucketResponse {
4963
7049
  else {
4964
7050
  data = await response.json();
4965
7051
  }
4966
- const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
7052
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4967
7053
  checkAndModifyResponse(dataClass);
4968
7054
  success = true;
4969
7055
  return {
@@ -4989,7 +7075,7 @@ class TransactionsTimeBucketResponse {
4989
7075
  * Transactions APIs
4990
7076
  *
4991
7077
  */
4992
- async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, enableRetry) {
7078
+ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, enableRetry, source) {
4993
7079
  let hasNext = true;
4994
7080
  let response;
4995
7081
  let data;
@@ -5004,13 +7090,13 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, en
5004
7090
  response = await LIMIT(() => fetch(`${url}?${urlsParams}`, {
5005
7091
  headers: {
5006
7092
  "Authorization": `Bearer ${apiKey}`,
5007
- "X-Requested-With": userAgent
7093
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
5008
7094
  }
5009
7095
  }));
5010
7096
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5011
7097
  if ((enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5012
7098
  try {
5013
- data = await LIMIT(() => backoff.backOff(response ? response.url : `${url}?${urlsParams}`));
7099
+ data = await LIMIT(() => backoff.backOff(response ? response.url : `${url}?${urlsParams}`, this.source));
5014
7100
  }
5015
7101
  catch (error) {
5016
7102
  hasNext = false;
@@ -5046,12 +7132,13 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, en
5046
7132
  }
5047
7133
  }
5048
7134
  class TransactionService {
5049
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
7135
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
5050
7136
  this.apiKey = apiKey;
5051
7137
  this.debug = debug;
5052
7138
  this.threadCount = threadCount;
5053
7139
  this.is_key_valid = is_key_valid;
5054
7140
  this.enableRetry = enableRetry;
7141
+ this.source = source;
5055
7142
  this.LIMIT = pLimit$1(this.threadCount);
5056
7143
  }
5057
7144
  /**
@@ -5111,13 +7198,13 @@ class TransactionService {
5111
7198
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, {
5112
7199
  headers: {
5113
7200
  "Authorization": `Bearer ${this.apiKey}`,
5114
- "X-Requested-With": userAgent
7201
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5115
7202
  }
5116
7203
  }));
5117
7204
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5118
7205
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5119
7206
  try {
5120
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7207
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5121
7208
  }
5122
7209
  catch (error) {
5123
7210
  success = true;
@@ -5187,7 +7274,7 @@ class TransactionService {
5187
7274
  if (queryParamOpts?.withSafe !== undefined) {
5188
7275
  urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
5189
7276
  }
5190
- for await (tx of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams, this.debug, this.threadCount, this.enableRetry)) {
7277
+ for await (tx of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams, this.debug, this.threadCount, this.enableRetry, this.source)) {
5191
7278
  yield tx;
5192
7279
  }
5193
7280
  success = true;
@@ -5247,13 +7334,13 @@ class TransactionService {
5247
7334
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/?${urlParams}`, {
5248
7335
  headers: {
5249
7336
  "Authorization": `Bearer ${this.apiKey}`,
5250
- "X-Requested-With": userAgent
7337
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5251
7338
  }
5252
7339
  }));
5253
7340
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5254
7341
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5255
7342
  try {
5256
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7343
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5257
7344
  }
5258
7345
  catch (error) {
5259
7346
  success = true;
@@ -5268,7 +7355,7 @@ class TransactionService {
5268
7355
  else {
5269
7356
  data = await response.json();
5270
7357
  }
5271
- const dataClass = new RecentTransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
7358
+ const dataClass = new RecentTransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5272
7359
  checkAndModifyResponse(dataClass);
5273
7360
  success = true;
5274
7361
  return {
@@ -5334,13 +7421,13 @@ class TransactionService {
5334
7421
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, {
5335
7422
  headers: {
5336
7423
  "Authorization": `Bearer ${this.apiKey}`,
5337
- "X-Requested-With": userAgent
7424
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5338
7425
  }
5339
7426
  }));
5340
7427
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5341
7428
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5342
7429
  try {
5343
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7430
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5344
7431
  }
5345
7432
  catch (error) {
5346
7433
  success = true;
@@ -5408,13 +7495,13 @@ class TransactionService {
5408
7495
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, {
5409
7496
  headers: {
5410
7497
  "Authorization": `Bearer ${this.apiKey}`,
5411
- "X-Requested-With": userAgent
7498
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5412
7499
  }
5413
7500
  }));
5414
7501
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5415
7502
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5416
7503
  try {
5417
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7504
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5418
7505
  }
5419
7506
  catch (error) {
5420
7507
  success = true;
@@ -5498,13 +7585,13 @@ class TransactionService {
5498
7585
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
5499
7586
  headers: {
5500
7587
  "Authorization": `Bearer ${this.apiKey}`,
5501
- "X-Requested-With": userAgent
7588
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5502
7589
  }
5503
7590
  }));
5504
7591
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5505
7592
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5506
7593
  try {
5507
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7594
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5508
7595
  }
5509
7596
  catch (error) {
5510
7597
  success = true;
@@ -5519,7 +7606,7 @@ class TransactionService {
5519
7606
  else {
5520
7607
  data = await response.json();
5521
7608
  }
5522
- const dataClass = new TransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
7609
+ const dataClass = new TransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5523
7610
  checkAndModifyResponse(dataClass);
5524
7611
  success = true;
5525
7612
  return {
@@ -5584,13 +7671,188 @@ class TransactionService {
5584
7671
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, {
5585
7672
  headers: {
5586
7673
  "Authorization": `Bearer ${this.apiKey}`,
5587
- "X-Requested-With": userAgent
7674
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7675
+ }
7676
+ }));
7677
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7678
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7679
+ try {
7680
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7681
+ }
7682
+ catch (error) {
7683
+ success = true;
7684
+ return {
7685
+ data: null,
7686
+ error: true,
7687
+ error_code: response.status ?? 429,
7688
+ error_message: error.message
7689
+ };
7690
+ }
7691
+ }
7692
+ else {
7693
+ data = await response.json();
7694
+ }
7695
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
7696
+ checkAndModifyResponse(dataClass);
7697
+ success = true;
7698
+ return {
7699
+ data: dataClass,
7700
+ error: data.error,
7701
+ error_code: data ? data.error_code : response.status,
7702
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
7703
+ };
7704
+ }
7705
+ catch (error) {
7706
+ success = true;
7707
+ return {
7708
+ data: null,
7709
+ error: true,
7710
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
7711
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
7712
+ };
7713
+ }
7714
+ }
7715
+ }
7716
+ /**
7717
+ *
7718
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
7719
+ *
7720
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
7721
+ * @param {string} blockHash - The requested block hash.
7722
+ * @param {number} page - The requested 0-indexed page number.
7723
+ * @param {GetTransactionsForBlockHashByPageQueryParamOpts} queryParamOpts
7724
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
7725
+ * - `noLogs`: Omit log events.
7726
+ * - `withSafe`: Include safe details.
7727
+ *
7728
+ */
7729
+ async getTransactionsForBlockHashByPage(chainName, blockHash, page, queryParamOpts) {
7730
+ let success = false;
7731
+ let data;
7732
+ let response;
7733
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
7734
+ while (!success) {
7735
+ try {
7736
+ const urlParams = new URLSearchParams();
7737
+ if (!this.is_key_valid) {
7738
+ return {
7739
+ data: null,
7740
+ error: true,
7741
+ error_code: 401,
7742
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
7743
+ };
7744
+ }
7745
+ if (queryParamOpts?.quoteCurrency !== undefined) {
7746
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
7747
+ }
7748
+ if (queryParamOpts?.noLogs !== undefined) {
7749
+ urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
7750
+ }
7751
+ if (queryParamOpts?.withSafe !== undefined) {
7752
+ urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
7753
+ }
7754
+ const url = `https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/page/${page}/?${urlParams}`;
7755
+ let startTime;
7756
+ if (this.debug) {
7757
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
7758
+ }
7759
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/page/${page}/?${urlParams}`, {
7760
+ headers: {
7761
+ "Authorization": `Bearer ${this.apiKey}`,
7762
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7763
+ }
7764
+ }));
7765
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7766
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7767
+ try {
7768
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7769
+ }
7770
+ catch (error) {
7771
+ success = true;
7772
+ return {
7773
+ data: null,
7774
+ error: true,
7775
+ error_code: response.status ?? 429,
7776
+ error_message: error.message
7777
+ };
7778
+ }
7779
+ }
7780
+ else {
7781
+ data = await response.json();
7782
+ }
7783
+ const dataClass = new TransactionsBlockPageResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
7784
+ checkAndModifyResponse(dataClass);
7785
+ success = true;
7786
+ return {
7787
+ data: dataClass,
7788
+ error: data.error,
7789
+ error_code: data ? data.error_code : response.status,
7790
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
7791
+ };
7792
+ }
7793
+ catch (error) {
7794
+ success = true;
7795
+ return {
7796
+ data: null,
7797
+ error: true,
7798
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
7799
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
7800
+ };
7801
+ }
7802
+ }
7803
+ }
7804
+ /**
7805
+ *
7806
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
7807
+ *
7808
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
7809
+ * @param {string} blockHash - The requested block hash.
7810
+ * @param {GetTransactionsForBlockHashQueryParamOpts} queryParamOpts
7811
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
7812
+ * - `noLogs`: Omit log events.
7813
+ * - `withSafe`: Include safe details.
7814
+ *
7815
+ */
7816
+ async getTransactionsForBlockHash(chainName, blockHash, queryParamOpts) {
7817
+ let success = false;
7818
+ let data;
7819
+ let response;
7820
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
7821
+ while (!success) {
7822
+ try {
7823
+ const urlParams = new URLSearchParams();
7824
+ if (!this.is_key_valid) {
7825
+ return {
7826
+ data: null,
7827
+ error: true,
7828
+ error_code: 401,
7829
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
7830
+ };
7831
+ }
7832
+ if (queryParamOpts?.quoteCurrency !== undefined) {
7833
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
7834
+ }
7835
+ if (queryParamOpts?.noLogs !== undefined) {
7836
+ urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
7837
+ }
7838
+ if (queryParamOpts?.withSafe !== undefined) {
7839
+ urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
7840
+ }
7841
+ const url = `https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/?${urlParams}`;
7842
+ let startTime;
7843
+ if (this.debug) {
7844
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
7845
+ }
7846
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/?${urlParams}`, {
7847
+ headers: {
7848
+ "Authorization": `Bearer ${this.apiKey}`,
7849
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5588
7850
  }
5589
7851
  }));
5590
7852
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5591
7853
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5592
7854
  try {
5593
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7855
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5594
7856
  }
5595
7857
  catch (error) {
5596
7858
  success = true;
@@ -5605,7 +7867,7 @@ class TransactionService {
5605
7867
  else {
5606
7868
  data = await response.json();
5607
7869
  }
5608
- const dataClass = new TransactionsTimeBucketResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
7870
+ const dataClass = new TransactionsBlockResponse(data.data);
5609
7871
  checkAndModifyResponse(dataClass);
5610
7872
  success = true;
5611
7873
  return {
@@ -5870,23 +8132,55 @@ class UniswapLikeTokenWithSupply {
5870
8132
  this.contract_ticker_symbol = data.contract_ticker_symbol;
5871
8133
  this.contract_address = data.contract_address;
5872
8134
  this.logo_url = data.logo_url;
5873
- this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
5874
- this.quote = data.quote;
5875
- this.pretty_quote = data.pretty_quote;
8135
+ this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
8136
+ this.quote = data.quote;
8137
+ this.pretty_quote = data.pretty_quote;
8138
+ this.quote_rate = data.quote_rate;
8139
+ this.total_supply = data.total_supply && data.total_supply !== null ? BigInt(data.total_supply) : null;
8140
+ }
8141
+ }
8142
+ class NetworkExchangeTokensResponse {
8143
+ constructor(data) {
8144
+ this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
8145
+ this.chain_id = data.chain_id;
8146
+ this.chain_name = data.chain_name;
8147
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2Volume(itemData)) : null;
8148
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
8149
+ }
8150
+ }
8151
+ class TokenV2Volume {
8152
+ constructor(data) {
8153
+ this.chain_name = data.chain_name;
8154
+ this.chain_id = data.chain_id;
8155
+ this.dex_name = data.dex_name;
8156
+ this.contract_address = data.contract_address;
8157
+ this.contract_name = data.contract_name;
8158
+ this.total_liquidity = data.total_liquidity;
8159
+ this.total_volume_24h = data.total_volume_24h;
8160
+ this.logo_url = data.logo_url;
8161
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
8162
+ this.contract_decimals = data.contract_decimals;
8163
+ this.swap_count_24h = data.swap_count_24h;
5876
8164
  this.quote_rate = data.quote_rate;
5877
- this.total_supply = data.total_supply && data.total_supply !== null ? BigInt(data.total_supply) : null;
8165
+ this.quote_rate_24h = data.quote_rate_24h;
8166
+ this.pretty_quote_rate = data.pretty_quote_rate;
8167
+ this.pretty_quote_rate_24h = data.pretty_quote_rate_24h;
8168
+ this.pretty_total_liquidity_quote = data.pretty_total_liquidity_quote;
8169
+ this.pretty_total_volume_24h_quote = data.pretty_total_volume_24h_quote;
8170
+ this.total_liquidity_quote = data.total_liquidity_quote;
8171
+ this.total_volume_24h_quote = data.total_volume_24h_quote;
5878
8172
  }
5879
8173
  }
5880
- class NetworkExchangeTokensResponse {
8174
+ class NetworkExchangeTokenViewResponse {
5881
8175
  constructor(data) {
5882
8176
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
5883
8177
  this.chain_id = data.chain_id;
5884
8178
  this.chain_name = data.chain_name;
5885
- this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2Volume(itemData)) : null;
8179
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2VolumeWithChartData(itemData)) : null;
5886
8180
  this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
5887
8181
  }
5888
8182
  }
5889
- class TokenV2Volume {
8183
+ class TokenV2VolumeWithChartData {
5890
8184
  constructor(data) {
5891
8185
  this.chain_name = data.chain_name;
5892
8186
  this.chain_id = data.chain_id;
@@ -5907,6 +8201,43 @@ class TokenV2Volume {
5907
8201
  this.pretty_total_volume_24h_quote = data.pretty_total_volume_24h_quote;
5908
8202
  this.total_liquidity_quote = data.total_liquidity_quote;
5909
8203
  this.total_volume_24h_quote = data.total_volume_24h_quote;
8204
+ this.transactions_24h = data.transactions_24h;
8205
+ this.volume_timeseries_7d = data.volume_timeseries_7d && data.volume_timeseries_7d !== null ? data.volume_timeseries_7d.map((itemData) => new VolumeTokenTimeseries(itemData)) : null;
8206
+ this.volume_timeseries_30d = data.volume_timeseries_30d && data.volume_timeseries_30d !== null ? data.volume_timeseries_30d.map((itemData) => new VolumeTokenTimeseries(itemData)) : null;
8207
+ this.liquidity_timeseries_7d = data.liquidity_timeseries_7d && data.liquidity_timeseries_7d !== null ? data.liquidity_timeseries_7d.map((itemData) => new LiquidityTokenTimeseries(itemData)) : null;
8208
+ this.liquidity_timeseries_30d = data.liquidity_timeseries_30d && data.liquidity_timeseries_30d !== null ? data.liquidity_timeseries_30d.map((itemData) => new LiquidityTokenTimeseries(itemData)) : null;
8209
+ this.price_timeseries_7d = data.price_timeseries_7d && data.price_timeseries_7d !== null ? data.price_timeseries_7d.map((itemData) => new PriceTokenTimeseries(itemData)) : null;
8210
+ this.price_timeseries_30d = data.price_timeseries_30d && data.price_timeseries_30d !== null ? data.price_timeseries_30d.map((itemData) => new PriceTokenTimeseries(itemData)) : null;
8211
+ }
8212
+ }
8213
+ class VolumeTokenTimeseries {
8214
+ constructor(data) {
8215
+ this.dex_name = data.dex_name;
8216
+ this.chain_id = data.chain_id;
8217
+ this.dt = data.dt;
8218
+ this.total_volume = data.total_volume;
8219
+ this.volume_quote = data.volume_quote;
8220
+ this.pretty_volume_quote = data.pretty_volume_quote;
8221
+ }
8222
+ }
8223
+ class LiquidityTokenTimeseries {
8224
+ constructor(data) {
8225
+ this.dex_name = data.dex_name;
8226
+ this.chain_id = data.chain_id;
8227
+ this.dt = data.dt;
8228
+ this.total_liquidity = data.total_liquidity;
8229
+ this.liquidity_quote = data.liquidity_quote;
8230
+ this.pretty_liquidity_quote = data.pretty_liquidity_quote;
8231
+ }
8232
+ }
8233
+ class PriceTokenTimeseries {
8234
+ constructor(data) {
8235
+ this.dex_name = data.dex_name;
8236
+ this.chain_id = data.chain_id;
8237
+ this.dt = data.dt;
8238
+ this.quote_currency = data.quote_currency;
8239
+ this.quote_rate = data.quote_rate;
8240
+ this.pretty_quote_rate = data.pretty_quote_rate;
5910
8241
  }
5911
8242
  }
5912
8243
  class SupportedDexesResponse {
@@ -6007,6 +8338,15 @@ class TransactionsForExchangeResponse {
6007
8338
  this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
6008
8339
  }
6009
8340
  }
8341
+ class NetworkTransactionsResponse {
8342
+ constructor(data) {
8343
+ this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
8344
+ this.chain_id = data.chain_id;
8345
+ this.chain_name = data.chain_name;
8346
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new ExchangeTransaction(itemData)) : null;
8347
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
8348
+ }
8349
+ }
6010
8350
  class EcosystemChartDataResponse {
6011
8351
  constructor(data) {
6012
8352
  this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
@@ -6076,12 +8416,13 @@ class HealthData {
6076
8416
  *
6077
8417
  */
6078
8418
  class XykService {
6079
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
8419
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
6080
8420
  this.apiKey = apiKey;
6081
8421
  this.debug = debug;
6082
8422
  this.threadCount = threadCount;
6083
8423
  this.is_key_valid = is_key_valid;
6084
8424
  this.enableRetry = enableRetry;
8425
+ this.source = source;
6085
8426
  this.LIMIT = pLimit$1(this.threadCount);
6086
8427
  }
6087
8428
  /**
@@ -6090,9 +8431,12 @@ class XykService {
6090
8431
  *
6091
8432
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6092
8433
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
8434
+ * @param {GetPoolsQueryParamOpts} queryParamOpts
8435
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
8436
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6093
8437
  *
6094
8438
  */
6095
- async getPools(chainName, dexName) {
8439
+ async getPools(chainName, dexName, queryParamOpts) {
6096
8440
  let success = false;
6097
8441
  let data;
6098
8442
  let response;
@@ -6100,6 +8444,12 @@ class XykService {
6100
8444
  while (!success) {
6101
8445
  try {
6102
8446
  const urlParams = new URLSearchParams();
8447
+ if (queryParamOpts?.pageSize !== undefined) {
8448
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
8449
+ }
8450
+ if (queryParamOpts?.pageNumber !== undefined) {
8451
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
8452
+ }
6103
8453
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`;
6104
8454
  if (!this.is_key_valid) {
6105
8455
  return {
@@ -6116,13 +8466,13 @@ class XykService {
6116
8466
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`, {
6117
8467
  headers: {
6118
8468
  "Authorization": `Bearer ${this.apiKey}`,
6119
- "X-Requested-With": userAgent
8469
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6120
8470
  }
6121
8471
  }));
6122
8472
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6123
8473
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6124
8474
  try {
6125
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8475
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6126
8476
  }
6127
8477
  catch (error) {
6128
8478
  success = true;
@@ -6190,13 +8540,13 @@ class XykService {
6190
8540
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/address/${poolAddress}/dex_name/?${urlParams}`, {
6191
8541
  headers: {
6192
8542
  "Authorization": `Bearer ${this.apiKey}`,
6193
- "X-Requested-With": userAgent
8543
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6194
8544
  }
6195
8545
  }));
6196
8546
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6197
8547
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6198
8548
  try {
6199
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8549
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6200
8550
  }
6201
8551
  catch (error) {
6202
8552
  success = true;
@@ -6265,13 +8615,13 @@ class XykService {
6265
8615
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/?${urlParams}`, {
6266
8616
  headers: {
6267
8617
  "Authorization": `Bearer ${this.apiKey}`,
6268
- "X-Requested-With": userAgent
8618
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6269
8619
  }
6270
8620
  }));
6271
8621
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6272
8622
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6273
8623
  try {
6274
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8624
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6275
8625
  }
6276
8626
  catch (error) {
6277
8627
  success = true;
@@ -6316,6 +8666,8 @@ class XykService {
6316
8666
  * @param {number} page - The requested 0-indexed page number.
6317
8667
  * @param {GetPoolsForTokenAddressQueryParamOpts} queryParamOpts
6318
8668
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
8669
+ * - `dexName`: The DEX name eg: `uniswap_v2`.
8670
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6319
8671
  *
6320
8672
  */
6321
8673
  async getPoolsForTokenAddress(chainName, tokenAddress, page, queryParamOpts) {
@@ -6340,6 +8692,9 @@ class XykService {
6340
8692
  if (queryParamOpts?.dexName !== undefined) {
6341
8693
  urlParams.append("dex-name", queryParamOpts?.dexName.toString());
6342
8694
  }
8695
+ if (queryParamOpts?.pageSize !== undefined) {
8696
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
8697
+ }
6343
8698
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/tokens/address/${tokenAddress}/pools/page/${page}/?${urlParams}`;
6344
8699
  let startTime;
6345
8700
  if (this.debug) {
@@ -6348,13 +8703,13 @@ class XykService {
6348
8703
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/tokens/address/${tokenAddress}/pools/page/${page}/?${urlParams}`, {
6349
8704
  headers: {
6350
8705
  "Authorization": `Bearer ${this.apiKey}`,
6351
- "X-Requested-With": userAgent
8706
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6352
8707
  }
6353
8708
  }));
6354
8709
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6355
8710
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6356
8711
  try {
6357
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8712
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6358
8713
  }
6359
8714
  catch (error) {
6360
8715
  success = true;
@@ -6423,13 +8778,13 @@ class XykService {
6423
8778
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/balances/?${urlParams}`, {
6424
8779
  headers: {
6425
8780
  "Authorization": `Bearer ${this.apiKey}`,
6426
- "X-Requested-With": userAgent
8781
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6427
8782
  }
6428
8783
  }));
6429
8784
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6430
8785
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6431
8786
  try {
6432
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8787
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6433
8788
  }
6434
8789
  catch (error) {
6435
8790
  success = true;
@@ -6475,6 +8830,8 @@ class XykService {
6475
8830
  * @param {GetPoolsForWalletAddressQueryParamOpts} queryParamOpts
6476
8831
  * - `tokenAddress`: The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
6477
8832
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
8833
+ * - `dexName`: The DEX name eg: `uniswap_v2`.
8834
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6478
8835
  *
6479
8836
  */
6480
8837
  async getPoolsForWalletAddress(chainName, walletAddress, page, queryParamOpts) {
@@ -6502,6 +8859,9 @@ class XykService {
6502
8859
  if (queryParamOpts?.dexName !== undefined) {
6503
8860
  urlParams.append("dex-name", queryParamOpts?.dexName.toString());
6504
8861
  }
8862
+ if (queryParamOpts?.pageSize !== undefined) {
8863
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
8864
+ }
6505
8865
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/address/${walletAddress}/pools/page/${page}/?${urlParams}`;
6506
8866
  let startTime;
6507
8867
  if (this.debug) {
@@ -6510,13 +8870,13 @@ class XykService {
6510
8870
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/address/${walletAddress}/pools/page/${page}/?${urlParams}`, {
6511
8871
  headers: {
6512
8872
  "Authorization": `Bearer ${this.apiKey}`,
6513
- "X-Requested-With": userAgent
8873
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6514
8874
  }
6515
8875
  }));
6516
8876
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6517
8877
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6518
8878
  try {
6519
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8879
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6520
8880
  }
6521
8881
  catch (error) {
6522
8882
  success = true;
@@ -6558,9 +8918,12 @@ class XykService {
6558
8918
  *
6559
8919
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6560
8920
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
8921
+ * @param {GetNetworkExchangeTokensQueryParamOpts} queryParamOpts
8922
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
8923
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6561
8924
  *
6562
8925
  */
6563
- async getNetworkExchangeTokens(chainName, dexName) {
8926
+ async getNetworkExchangeTokens(chainName, dexName, queryParamOpts) {
6564
8927
  let success = false;
6565
8928
  let data;
6566
8929
  let response;
@@ -6568,6 +8931,12 @@ class XykService {
6568
8931
  while (!success) {
6569
8932
  try {
6570
8933
  const urlParams = new URLSearchParams();
8934
+ if (queryParamOpts?.pageSize !== undefined) {
8935
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
8936
+ }
8937
+ if (queryParamOpts?.pageNumber !== undefined) {
8938
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
8939
+ }
6571
8940
  if (!this.is_key_valid) {
6572
8941
  return {
6573
8942
  data: null,
@@ -6584,13 +8953,13 @@ class XykService {
6584
8953
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/?${urlParams}`, {
6585
8954
  headers: {
6586
8955
  "Authorization": `Bearer ${this.apiKey}`,
6587
- "X-Requested-With": userAgent
8956
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6588
8957
  }
6589
8958
  }));
6590
8959
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6591
8960
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6592
8961
  try {
6593
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
8962
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6594
8963
  }
6595
8964
  catch (error) {
6596
8965
  success = true;
@@ -6626,6 +8995,86 @@ class XykService {
6626
8995
  }
6627
8996
  }
6628
8997
  }
8998
+ /**
8999
+ *
9000
+ * Commonly used to get a detailed view for a single liquidity pool token. Includes time series data.
9001
+ *
9002
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
9003
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
9004
+ * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
9005
+ * @param {GetLpTokenViewQueryParamOpts} queryParamOpts
9006
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
9007
+ *
9008
+ */
9009
+ async getLpTokenView(chainName, dexName, tokenAddress, queryParamOpts) {
9010
+ let success = false;
9011
+ let data;
9012
+ let response;
9013
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
9014
+ while (!success) {
9015
+ try {
9016
+ const urlParams = new URLSearchParams();
9017
+ if (!this.is_key_valid) {
9018
+ return {
9019
+ data: null,
9020
+ error: true,
9021
+ error_code: 401,
9022
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
9023
+ };
9024
+ }
9025
+ if (queryParamOpts?.quoteCurrency !== undefined) {
9026
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
9027
+ }
9028
+ const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/view/?${urlParams}`;
9029
+ let startTime;
9030
+ if (this.debug) {
9031
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
9032
+ }
9033
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/view/?${urlParams}`, {
9034
+ headers: {
9035
+ "Authorization": `Bearer ${this.apiKey}`,
9036
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
9037
+ }
9038
+ }));
9039
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
9040
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
9041
+ try {
9042
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
9043
+ }
9044
+ catch (error) {
9045
+ success = true;
9046
+ return {
9047
+ data: null,
9048
+ error: true,
9049
+ error_code: response.status ?? 429,
9050
+ error_message: error.message
9051
+ };
9052
+ }
9053
+ }
9054
+ else {
9055
+ data = await response.json();
9056
+ }
9057
+ const dataClass = new NetworkExchangeTokenViewResponse(data.data);
9058
+ checkAndModifyResponse(dataClass);
9059
+ success = true;
9060
+ return {
9061
+ data: dataClass,
9062
+ error: data.error,
9063
+ error_code: data ? data.error_code : response.status,
9064
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
9065
+ };
9066
+ }
9067
+ catch (error) {
9068
+ success = true;
9069
+ return {
9070
+ data: null,
9071
+ error: true,
9072
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
9073
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
9074
+ };
9075
+ }
9076
+ }
9077
+ }
6629
9078
  /**
6630
9079
  *
6631
9080
  * Commonly used to get all the supported DEXs available for the xy=k endpoints, along with the swap fees and factory addresses.
@@ -6656,13 +9105,13 @@ class XykService {
6656
9105
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/xy=k/supported_dexes/?${urlParams}`, {
6657
9106
  headers: {
6658
9107
  "Authorization": `Bearer ${this.apiKey}`,
6659
- "X-Requested-With": userAgent
9108
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6660
9109
  }
6661
9110
  }));
6662
9111
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6663
9112
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6664
9113
  try {
6665
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9114
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6666
9115
  }
6667
9116
  catch (error) {
6668
9117
  success = true;
@@ -6705,9 +9154,12 @@ class XykService {
6705
9154
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6706
9155
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6707
9156
  * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
9157
+ * @param {GetSingleNetworkExchangeTokenQueryParamOpts} queryParamOpts
9158
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
9159
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6708
9160
  *
6709
9161
  */
6710
- async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) {
9162
+ async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress, queryParamOpts) {
6711
9163
  let success = false;
6712
9164
  let data;
6713
9165
  let response;
@@ -6715,6 +9167,12 @@ class XykService {
6715
9167
  while (!success) {
6716
9168
  try {
6717
9169
  const urlParams = new URLSearchParams();
9170
+ if (queryParamOpts?.pageSize !== undefined) {
9171
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
9172
+ }
9173
+ if (queryParamOpts?.pageNumber !== undefined) {
9174
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
9175
+ }
6718
9176
  if (!this.is_key_valid) {
6719
9177
  return {
6720
9178
  data: null,
@@ -6731,13 +9189,13 @@ class XykService {
6731
9189
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, {
6732
9190
  headers: {
6733
9191
  "Authorization": `Bearer ${this.apiKey}`,
6734
- "X-Requested-With": userAgent
9192
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6735
9193
  }
6736
9194
  }));
6737
9195
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6738
9196
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6739
9197
  try {
6740
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9198
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6741
9199
  }
6742
9200
  catch (error) {
6743
9201
  success = true;
@@ -6806,13 +9264,13 @@ class XykService {
6806
9264
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, {
6807
9265
  headers: {
6808
9266
  "Authorization": `Bearer ${this.apiKey}`,
6809
- "X-Requested-With": userAgent
9267
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6810
9268
  }
6811
9269
  }));
6812
9270
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6813
9271
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6814
9272
  try {
6815
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9273
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6816
9274
  }
6817
9275
  catch (error) {
6818
9276
  success = true;
@@ -6855,9 +9313,12 @@ class XykService {
6855
9313
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6856
9314
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6857
9315
  * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
9316
+ * @param {GetTransactionsForTokenAddressQueryParamOpts} queryParamOpts
9317
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
9318
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6858
9319
  *
6859
9320
  */
6860
- async getTransactionsForTokenAddress(chainName, dexName, tokenAddress) {
9321
+ async getTransactionsForTokenAddress(chainName, dexName, tokenAddress, queryParamOpts) {
6861
9322
  let success = false;
6862
9323
  let data;
6863
9324
  let response;
@@ -6873,6 +9334,12 @@ class XykService {
6873
9334
  error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6874
9335
  };
6875
9336
  }
9337
+ if (queryParamOpts?.pageSize !== undefined) {
9338
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
9339
+ }
9340
+ if (queryParamOpts?.pageNumber !== undefined) {
9341
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
9342
+ }
6876
9343
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`;
6877
9344
  let startTime;
6878
9345
  if (this.debug) {
@@ -6881,13 +9348,13 @@ class XykService {
6881
9348
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, {
6882
9349
  headers: {
6883
9350
  "Authorization": `Bearer ${this.apiKey}`,
6884
- "X-Requested-With": userAgent
9351
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6885
9352
  }
6886
9353
  }));
6887
9354
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6888
9355
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6889
9356
  try {
6890
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9357
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6891
9358
  }
6892
9359
  catch (error) {
6893
9360
  success = true;
@@ -6930,9 +9397,12 @@ class XykService {
6930
9397
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6931
9398
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6932
9399
  * @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
9400
+ * @param {GetTransactionsForExchangeQueryParamOpts} queryParamOpts
9401
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
9402
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6933
9403
  *
6934
9404
  */
6935
- async getTransactionsForExchange(chainName, dexName, poolAddress) {
9405
+ async getTransactionsForExchange(chainName, dexName, poolAddress, queryParamOpts) {
6936
9406
  let success = false;
6937
9407
  let data;
6938
9408
  let response;
@@ -6948,6 +9418,12 @@ class XykService {
6948
9418
  error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6949
9419
  };
6950
9420
  }
9421
+ if (queryParamOpts?.pageSize !== undefined) {
9422
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
9423
+ }
9424
+ if (queryParamOpts?.pageNumber !== undefined) {
9425
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
9426
+ }
6951
9427
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`;
6952
9428
  let startTime;
6953
9429
  if (this.debug) {
@@ -6956,13 +9432,13 @@ class XykService {
6956
9432
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, {
6957
9433
  headers: {
6958
9434
  "Authorization": `Bearer ${this.apiKey}`,
6959
- "X-Requested-With": userAgent
9435
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6960
9436
  }
6961
9437
  }));
6962
9438
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6963
9439
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6964
9440
  try {
6965
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9441
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6966
9442
  }
6967
9443
  catch (error) {
6968
9444
  success = true;
@@ -6998,6 +9474,93 @@ class XykService {
6998
9474
  }
6999
9475
  }
7000
9476
  }
9477
+ /**
9478
+ *
9479
+ * Commonly used to get all the the transactions for a given DEX. Useful for building DEX activity views.
9480
+ *
9481
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
9482
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
9483
+ * @param {GetTransactionsForDexQueryParamOpts} queryParamOpts
9484
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
9485
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
9486
+ * - `pageNumber`: 0-indexed page number to begin pagination.
9487
+ *
9488
+ */
9489
+ async getTransactionsForDex(chainName, dexName, queryParamOpts) {
9490
+ let success = false;
9491
+ let data;
9492
+ let response;
9493
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
9494
+ while (!success) {
9495
+ try {
9496
+ const urlParams = new URLSearchParams();
9497
+ if (!this.is_key_valid) {
9498
+ return {
9499
+ data: null,
9500
+ error: true,
9501
+ error_code: 401,
9502
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
9503
+ };
9504
+ }
9505
+ if (queryParamOpts?.quoteCurrency !== undefined) {
9506
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
9507
+ }
9508
+ if (queryParamOpts?.pageSize !== undefined) {
9509
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
9510
+ }
9511
+ if (queryParamOpts?.pageNumber !== undefined) {
9512
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
9513
+ }
9514
+ const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/transactions/?${urlParams}`;
9515
+ let startTime;
9516
+ if (this.debug) {
9517
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
9518
+ }
9519
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/transactions/?${urlParams}`, {
9520
+ headers: {
9521
+ "Authorization": `Bearer ${this.apiKey}`,
9522
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
9523
+ }
9524
+ }));
9525
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
9526
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
9527
+ try {
9528
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
9529
+ }
9530
+ catch (error) {
9531
+ success = true;
9532
+ return {
9533
+ data: null,
9534
+ error: true,
9535
+ error_code: response.status ?? 429,
9536
+ error_message: error.message
9537
+ };
9538
+ }
9539
+ }
9540
+ else {
9541
+ data = await response.json();
9542
+ }
9543
+ const dataClass = new NetworkTransactionsResponse(data.data);
9544
+ checkAndModifyResponse(dataClass);
9545
+ success = true;
9546
+ return {
9547
+ data: dataClass,
9548
+ error: data.error,
9549
+ error_code: data ? data.error_code : response.status,
9550
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
9551
+ };
9552
+ }
9553
+ catch (error) {
9554
+ success = true;
9555
+ return {
9556
+ data: null,
9557
+ error: true,
9558
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
9559
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
9560
+ };
9561
+ }
9562
+ }
9563
+ }
7001
9564
  /**
7002
9565
  *
7003
9566
  * Commonly used to get a 7d and 30d time-series chart of DEX activity. Includes volume and swap count.
@@ -7030,13 +9593,13 @@ class XykService {
7030
9593
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/ecosystem/?${urlParams}`, {
7031
9594
  headers: {
7032
9595
  "Authorization": `Bearer ${this.apiKey}`,
7033
- "X-Requested-With": userAgent
9596
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7034
9597
  }
7035
9598
  }));
7036
9599
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7037
9600
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7038
9601
  try {
7039
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9602
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7040
9603
  }
7041
9604
  catch (error) {
7042
9605
  success = true;
@@ -7104,13 +9667,13 @@ class XykService {
7104
9667
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/health/?${urlParams}`, {
7105
9668
  headers: {
7106
9669
  "Authorization": `Bearer ${this.apiKey}`,
7107
- "X-Requested-With": userAgent
9670
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7108
9671
  }
7109
9672
  }));
7110
9673
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7111
9674
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7112
9675
  try {
7113
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
9676
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7114
9677
  }
7115
9678
  catch (error) {
7116
9679
  success = true;
@@ -7148,22 +9711,22 @@ class XykService {
7148
9711
  }
7149
9712
  }
7150
9713
 
7151
- const userAgent = "com.covalenthq.sdk.typescript/0.7.6";
9714
+ const userAgent = "com.covalenthq.sdk.typescript/0.8.1";
7152
9715
  /**
7153
9716
  * CovalentClient Class
7154
9717
  */
7155
9718
  class CovalentClient {
7156
- constructor(apiKey, settings) {
9719
+ constructor(apiKey, settings, source) {
7157
9720
  const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
7158
9721
  const validator = new ApiKeyValidator(apiKey);
7159
9722
  this._is_key_valid = validator.isValidApiKey();
7160
- this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7161
- this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7162
- this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7163
- this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7164
- this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7165
- this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7166
- this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
9723
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9724
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9725
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9726
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9727
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9728
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9729
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7167
9730
  }
7168
9731
  }
7169
9732
  /**
@@ -7173,17 +9736,17 @@ class CovalentClient {
7173
9736
  * CovalentClient Class
7174
9737
  */
7175
9738
  class Client {
7176
- constructor(apiKey, settings) {
9739
+ constructor(apiKey, settings, source) {
7177
9740
  const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
7178
9741
  const validator = new ApiKeyValidator(apiKey);
7179
9742
  this._is_key_valid = validator.isValidApiKey();
7180
- this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7181
- this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7182
- this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7183
- this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7184
- this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7185
- this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7186
- this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
9743
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9744
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9745
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9746
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9747
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9748
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
9749
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7187
9750
  }
7188
9751
  }
7189
9752