@covalenthq/client-sdk 0.6.7 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/index.js +576 -25
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/services/BalanceService.d.ts +2 -1
  5. package/dist/cjs/services/BaseService.d.ts +55 -2
  6. package/dist/cjs/services/CovalentClient.d.ts +3 -1
  7. package/dist/cjs/services/NftService.d.ts +2 -1
  8. package/dist/cjs/services/PricingService.d.ts +2 -1
  9. package/dist/cjs/services/SecurityService.d.ts +2 -1
  10. package/dist/cjs/services/TransactionService.d.ts +5 -4
  11. package/dist/cjs/services/XykService.d.ts +2 -1
  12. package/dist/cjs/util/ApiKeyValidator.d.ts +8 -0
  13. package/dist/cjs/util/types/BaseServiceTypes.d.ts +36 -0
  14. package/dist/cjs/util/types/TransactionServiceTypes.d.ts +3 -3
  15. package/dist/es/index.js +576 -25
  16. package/dist/es/index.js.map +1 -1
  17. package/dist/es/services/BalanceService.d.ts +2 -1
  18. package/dist/es/services/BaseService.d.ts +55 -2
  19. package/dist/es/services/CovalentClient.d.ts +3 -1
  20. package/dist/es/services/NftService.d.ts +2 -1
  21. package/dist/es/services/PricingService.d.ts +2 -1
  22. package/dist/es/services/SecurityService.d.ts +2 -1
  23. package/dist/es/services/TransactionService.d.ts +5 -4
  24. package/dist/es/services/XykService.d.ts +2 -1
  25. package/dist/es/util/ApiKeyValidator.d.ts +8 -0
  26. package/dist/es/util/types/BaseServiceTypes.d.ts +36 -0
  27. package/dist/es/util/types/TransactionServiceTypes.d.ts +3 -3
  28. package/dist/esm/index.js +576 -25
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/services/BalanceService.d.ts +2 -1
  31. package/dist/esm/services/BaseService.d.ts +55 -2
  32. package/dist/esm/services/CovalentClient.d.ts +3 -1
  33. package/dist/esm/services/NftService.d.ts +2 -1
  34. package/dist/esm/services/PricingService.d.ts +2 -1
  35. package/dist/esm/services/SecurityService.d.ts +2 -1
  36. package/dist/esm/services/TransactionService.d.ts +5 -4
  37. package/dist/esm/services/XykService.d.ts +2 -1
  38. package/dist/esm/util/ApiKeyValidator.d.ts +8 -0
  39. package/dist/esm/util/types/BaseServiceTypes.d.ts +36 -0
  40. package/dist/esm/util/types/TransactionServiceTypes.d.ts +3 -3
  41. package/dist/services/BalanceService.d.ts +2 -1
  42. package/dist/services/BalanceService.js +57 -1
  43. package/dist/services/BalanceService.js.map +1 -1
  44. package/dist/services/BaseService.d.ts +55 -2
  45. package/dist/services/BaseService.js +187 -1
  46. package/dist/services/BaseService.js.map +1 -1
  47. package/dist/services/CovalentClient.d.ts +3 -1
  48. package/dist/services/CovalentClient.js +20 -15
  49. package/dist/services/CovalentClient.js.map +1 -1
  50. package/dist/services/NftService.d.ts +2 -1
  51. package/dist/services/NftService.js +113 -1
  52. package/dist/services/NftService.js.map +1 -1
  53. package/dist/services/PricingService.d.ts +2 -1
  54. package/dist/services/PricingService.js +11 -1
  55. package/dist/services/PricingService.js.map +1 -1
  56. package/dist/services/SecurityService.d.ts +2 -1
  57. package/dist/services/SecurityService.js +19 -1
  58. package/dist/services/SecurityService.js.map +1 -1
  59. package/dist/services/TransactionService.d.ts +5 -4
  60. package/dist/services/TransactionService.js +49 -4
  61. package/dist/services/TransactionService.js.map +1 -1
  62. package/dist/services/XykService.d.ts +2 -1
  63. package/dist/services/XykService.js +115 -1
  64. package/dist/services/XykService.js.map +1 -1
  65. package/dist/util/ApiKeyValidator.d.ts +8 -0
  66. package/dist/util/ApiKeyValidator.js +13 -0
  67. package/dist/util/ApiKeyValidator.js.map +1 -0
  68. package/dist/util/types/BaseServiceTypes.d.ts +36 -0
  69. package/dist/util/types/TransactionServiceTypes.d.ts +3 -3
  70. package/package.json +1 -1
package/dist/es/index.js CHANGED
@@ -283,6 +283,19 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
283
283
  }
284
284
  }
285
285
 
286
+ class ApiKeyValidator {
287
+ constructor(apiKey) {
288
+ this._apiKey = apiKey;
289
+ }
290
+ isValidApiKey() {
291
+ return ApiKeyValidator._apiKeyV1Pattern.test(this._apiKey) || ApiKeyValidator._apiKeyV2Pattern.test(this._apiKey);
292
+ }
293
+ }
294
+ // Regular expression patterns
295
+ ApiKeyValidator._apiKeyV1Pattern = /^ckey_([a-f0-9]{27})$/;
296
+ ApiKeyValidator._apiKeyV2Pattern = /^cqt_(wF|rQ)([bcdfghjkmpqrtvwxyBCDFGHJKMPQRTVWXY346789]{26})$/;
297
+ ApiKeyValidator.INVALID_API_KEY_MESSAGE = "Invalid or missing API key (sign up at covalenthq.com/platform)";
298
+
286
299
  class ApprovalsResponse {
287
300
  constructor(data) {
288
301
  this.address = data.address;
@@ -370,10 +383,11 @@ class NftApprovalSpender {
370
383
  *
371
384
  */
372
385
  class SecurityService {
373
- constructor(apiKey, debug = false, threadCount = 3) {
386
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
374
387
  this.apiKey = apiKey;
375
388
  this.debug = debug;
376
389
  this.threadCount = threadCount;
390
+ this.is_key_valid = is_key_valid;
377
391
  this.LIMIT = pLimit$1(this.threadCount);
378
392
  }
379
393
  /**
@@ -392,6 +406,14 @@ class SecurityService {
392
406
  while (!success) {
393
407
  try {
394
408
  const urlParams = new URLSearchParams();
409
+ if (!this.is_key_valid) {
410
+ return {
411
+ data: null,
412
+ error: true,
413
+ error_code: 401,
414
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
415
+ };
416
+ }
395
417
  let startTime;
396
418
  if (this.debug) {
397
419
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -456,6 +478,14 @@ class SecurityService {
456
478
  while (!success) {
457
479
  try {
458
480
  const urlParams = new URLSearchParams();
481
+ if (!this.is_key_valid) {
482
+ return {
483
+ data: null,
484
+ error: true,
485
+ error_code: 401,
486
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
487
+ };
488
+ }
459
489
  let startTime;
460
490
  if (this.debug) {
461
491
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -788,10 +818,11 @@ class NativeBalanceItem {
788
818
  *
789
819
  */
790
820
  class BalanceService {
791
- constructor(apiKey, debug = false, threadCount = 3) {
821
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
792
822
  this.apiKey = apiKey;
793
823
  this.debug = debug;
794
824
  this.threadCount = threadCount;
825
+ this.is_key_valid = is_key_valid;
795
826
  this.LIMIT = pLimit$1(this.threadCount);
796
827
  }
797
828
  /**
@@ -816,6 +847,14 @@ class BalanceService {
816
847
  while (!success) {
817
848
  try {
818
849
  const urlParams = new URLSearchParams();
850
+ if (!this.is_key_valid) {
851
+ return {
852
+ data: null,
853
+ error: true,
854
+ error_code: 401,
855
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
856
+ };
857
+ }
819
858
  if (queryParamOpts?.quoteCurrency !== undefined) {
820
859
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
821
860
  }
@@ -899,6 +938,14 @@ class BalanceService {
899
938
  while (!success) {
900
939
  try {
901
940
  const urlParams = new URLSearchParams();
941
+ if (!this.is_key_valid) {
942
+ return {
943
+ data: null,
944
+ error: true,
945
+ error_code: 401,
946
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
947
+ };
948
+ }
902
949
  if (queryParamOpts?.quoteCurrency !== undefined) {
903
950
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
904
951
  }
@@ -975,6 +1022,9 @@ class BalanceService {
975
1022
  while (!success) {
976
1023
  try {
977
1024
  const urlParams = new URLSearchParams();
1025
+ if (!this.is_key_valid) {
1026
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
1027
+ }
978
1028
  if (queryParamOpts?.quoteCurrency !== undefined) {
979
1029
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
980
1030
  }
@@ -1027,6 +1077,14 @@ class BalanceService {
1027
1077
  while (!success) {
1028
1078
  try {
1029
1079
  const urlParams = new URLSearchParams();
1080
+ if (!this.is_key_valid) {
1081
+ return {
1082
+ data: null,
1083
+ error: true,
1084
+ error_code: 401,
1085
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1086
+ };
1087
+ }
1030
1088
  if (queryParamOpts?.quoteCurrency !== undefined) {
1031
1089
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
1032
1090
  }
@@ -1113,6 +1171,9 @@ class BalanceService {
1113
1171
  while (!success) {
1114
1172
  try {
1115
1173
  const urlParams = new URLSearchParams();
1174
+ if (!this.is_key_valid) {
1175
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
1176
+ }
1116
1177
  if (queryParamOpts?.blockHeight !== undefined) {
1117
1178
  urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
1118
1179
  }
@@ -1157,6 +1218,14 @@ class BalanceService {
1157
1218
  while (!success) {
1158
1219
  try {
1159
1220
  const urlParams = new URLSearchParams();
1221
+ if (!this.is_key_valid) {
1222
+ return {
1223
+ data: null,
1224
+ error: true,
1225
+ error_code: 401,
1226
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1227
+ };
1228
+ }
1160
1229
  if (queryParamOpts?.blockHeight !== undefined) {
1161
1230
  urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
1162
1231
  }
@@ -1242,6 +1311,14 @@ class BalanceService {
1242
1311
  while (!success) {
1243
1312
  try {
1244
1313
  const urlParams = new URLSearchParams();
1314
+ if (!this.is_key_valid) {
1315
+ return {
1316
+ data: null,
1317
+ error: true,
1318
+ error_code: 401,
1319
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1320
+ };
1321
+ }
1245
1322
  if (queryParamOpts?.quoteCurrency !== undefined) {
1246
1323
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
1247
1324
  }
@@ -1329,6 +1406,14 @@ class BalanceService {
1329
1406
  while (!success) {
1330
1407
  try {
1331
1408
  const urlParams = new URLSearchParams();
1409
+ if (!this.is_key_valid) {
1410
+ return {
1411
+ data: null,
1412
+ error: true,
1413
+ error_code: 401,
1414
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1415
+ };
1416
+ }
1332
1417
  if (queryParamOpts?.quoteCurrency !== undefined) {
1333
1418
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
1334
1419
  }
@@ -1575,15 +1660,43 @@ class ChainActivityEvent extends ChainItem {
1575
1660
  this.last_seen_at = data.last_seen_at && data.last_seen_at !== null ? parseISO(data.last_seen_at.toString()) : null;
1576
1661
  }
1577
1662
  }
1663
+ class GasPricesResponse {
1664
+ constructor(data) {
1665
+ this.chain_id = data.chain_id;
1666
+ this.chain_name = data.chain_name;
1667
+ this.quote_currency = data.quote_currency;
1668
+ this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
1669
+ this.event_type = data.event_type;
1670
+ this.gas_quote_rate = data.gas_quote_rate;
1671
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new PriceItem(itemData)) : null;
1672
+ }
1673
+ }
1674
+ class PriceItem {
1675
+ constructor(data) {
1676
+ this.gas_price = data.gas_price;
1677
+ this.gas_spent = data.gas_spent;
1678
+ this.gas_quote = data.gas_quote;
1679
+ this.total_gas_quote = data.total_gas_quote;
1680
+ this.pretty_total_gas_quote = data.pretty_total_gas_quote;
1681
+ this.interval = data.interval;
1682
+ this.other_fees = data.other_fees && data.other_fees !== null ? new OtherFees(data.other_fees) : null;
1683
+ }
1684
+ }
1685
+ class OtherFees {
1686
+ constructor(data) {
1687
+ this.l1_gas_quote = data.l1_gas_quote;
1688
+ }
1689
+ }
1578
1690
  /**
1579
1691
  * Class A - Base
1580
1692
  *
1581
1693
  */
1582
1694
  class BaseService {
1583
- constructor(apiKey, debug = false, threadCount = 3) {
1695
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
1584
1696
  this.apiKey = apiKey;
1585
1697
  this.debug = debug;
1586
1698
  this.threadCount = threadCount;
1699
+ this.is_key_valid = is_key_valid;
1587
1700
  this.LIMIT = pLimit$1(this.threadCount);
1588
1701
  }
1589
1702
  /**
@@ -1602,6 +1715,14 @@ class BaseService {
1602
1715
  while (!success) {
1603
1716
  try {
1604
1717
  const urlParams = new URLSearchParams();
1718
+ if (!this.is_key_valid) {
1719
+ return {
1720
+ data: null,
1721
+ error: true,
1722
+ error_code: 401,
1723
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1724
+ };
1725
+ }
1605
1726
  let startTime;
1606
1727
  if (this.debug) {
1607
1728
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -1667,6 +1788,14 @@ class BaseService {
1667
1788
  while (!success) {
1668
1789
  try {
1669
1790
  const urlParams = new URLSearchParams();
1791
+ if (!this.is_key_valid) {
1792
+ return {
1793
+ data: null,
1794
+ error: true,
1795
+ error_code: 401,
1796
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1797
+ };
1798
+ }
1670
1799
  let startTime;
1671
1800
  if (this.debug) {
1672
1801
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -1734,6 +1863,9 @@ class BaseService {
1734
1863
  while (!success) {
1735
1864
  try {
1736
1865
  const urlParams = new URLSearchParams();
1866
+ if (!this.is_key_valid) {
1867
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
1868
+ }
1737
1869
  if (queryParamOpts?.pageSize !== undefined) {
1738
1870
  urlParams.append("page-size", queryParamOpts?.pageSize.toString());
1739
1871
  }
@@ -1771,6 +1903,14 @@ class BaseService {
1771
1903
  while (!success) {
1772
1904
  try {
1773
1905
  const urlParams = new URLSearchParams();
1906
+ if (!this.is_key_valid) {
1907
+ return {
1908
+ data: null,
1909
+ error: true,
1910
+ error_code: 401,
1911
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1912
+ };
1913
+ }
1774
1914
  if (queryParamOpts?.pageSize !== undefined) {
1775
1915
  urlParams.append("page-size", queryParamOpts?.pageSize.toString());
1776
1916
  }
@@ -1848,6 +1988,14 @@ class BaseService {
1848
1988
  while (!success) {
1849
1989
  try {
1850
1990
  const urlParams = new URLSearchParams();
1991
+ if (!this.is_key_valid) {
1992
+ return {
1993
+ data: null,
1994
+ error: true,
1995
+ error_code: 401,
1996
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
1997
+ };
1998
+ }
1851
1999
  if (queryParamOpts?.startingBlock !== undefined) {
1852
2000
  urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
1853
2001
  }
@@ -1934,6 +2082,9 @@ class BaseService {
1934
2082
  while (!success) {
1935
2083
  try {
1936
2084
  const urlParams = new URLSearchParams();
2085
+ if (!this.is_key_valid) {
2086
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
2087
+ }
1937
2088
  if (queryParamOpts?.startingBlock !== undefined) {
1938
2089
  urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
1939
2090
  }
@@ -1978,6 +2129,14 @@ class BaseService {
1978
2129
  while (!success) {
1979
2130
  try {
1980
2131
  const urlParams = new URLSearchParams();
2132
+ if (!this.is_key_valid) {
2133
+ return {
2134
+ data: null,
2135
+ error: true,
2136
+ error_code: 401,
2137
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2138
+ };
2139
+ }
1981
2140
  if (queryParamOpts?.startingBlock !== undefined) {
1982
2141
  urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
1983
2142
  }
@@ -2059,6 +2218,9 @@ class BaseService {
2059
2218
  while (!success) {
2060
2219
  try {
2061
2220
  const urlParams = new URLSearchParams();
2221
+ if (!this.is_key_valid) {
2222
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
2223
+ }
2062
2224
  if (queryParamOpts?.startingBlock !== undefined) {
2063
2225
  urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
2064
2226
  }
@@ -2107,6 +2269,14 @@ class BaseService {
2107
2269
  while (!success) {
2108
2270
  try {
2109
2271
  const urlParams = new URLSearchParams();
2272
+ if (!this.is_key_valid) {
2273
+ return {
2274
+ data: null,
2275
+ error: true,
2276
+ error_code: 401,
2277
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2278
+ };
2279
+ }
2110
2280
  if (queryParamOpts?.startingBlock !== undefined) {
2111
2281
  urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
2112
2282
  }
@@ -2185,6 +2355,14 @@ class BaseService {
2185
2355
  while (!success) {
2186
2356
  try {
2187
2357
  const urlParams = new URLSearchParams();
2358
+ if (!this.is_key_valid) {
2359
+ return {
2360
+ data: null,
2361
+ error: true,
2362
+ error_code: 401,
2363
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2364
+ };
2365
+ }
2188
2366
  let startTime;
2189
2367
  if (this.debug) {
2190
2368
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -2248,6 +2426,14 @@ class BaseService {
2248
2426
  while (!success) {
2249
2427
  try {
2250
2428
  const urlParams = new URLSearchParams();
2429
+ if (!this.is_key_valid) {
2430
+ return {
2431
+ data: null,
2432
+ error: true,
2433
+ error_code: 401,
2434
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2435
+ };
2436
+ }
2251
2437
  let startTime;
2252
2438
  if (this.debug) {
2253
2439
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -2314,6 +2500,14 @@ class BaseService {
2314
2500
  while (!success) {
2315
2501
  try {
2316
2502
  const urlParams = new URLSearchParams();
2503
+ if (!this.is_key_valid) {
2504
+ return {
2505
+ data: null,
2506
+ error: true,
2507
+ error_code: 401,
2508
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2509
+ };
2510
+ }
2317
2511
  if (queryParamOpts?.testnets !== undefined) {
2318
2512
  urlParams.append("testnets", queryParamOpts?.testnets.toString());
2319
2513
  }
@@ -2366,6 +2560,82 @@ class BaseService {
2366
2560
  }
2367
2561
  }
2368
2562
  }
2563
+ /**
2564
+ *
2565
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
2566
+ * @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
2567
+ * @param {GetGasPricesQueryParamOpts} queryParamOpts
2568
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2569
+ *
2570
+ */
2571
+ async getGasPrices(chainName, eventType, queryParamOpts) {
2572
+ let success = false;
2573
+ let data;
2574
+ let response;
2575
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
2576
+ while (!success) {
2577
+ try {
2578
+ const urlParams = new URLSearchParams();
2579
+ if (!this.is_key_valid) {
2580
+ return {
2581
+ data: null,
2582
+ error: true,
2583
+ error_code: 401,
2584
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
2585
+ };
2586
+ }
2587
+ if (queryParamOpts?.quoteCurrency !== undefined) {
2588
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
2589
+ }
2590
+ let startTime;
2591
+ if (this.debug) {
2592
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
2593
+ }
2594
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/event/${eventType}/gas_prices/?${urlParams}`, {
2595
+ headers: {
2596
+ "Authorization": `Bearer ${this.apiKey}`,
2597
+ "X-Requested-With": userAgent
2598
+ }
2599
+ }));
2600
+ debugOutput(response.url, response.status, startTime);
2601
+ if (response.status === 429) {
2602
+ try {
2603
+ data = await this.LIMIT(() => backoff.backOff(response.url));
2604
+ }
2605
+ catch (error) {
2606
+ success = true;
2607
+ return {
2608
+ data: null,
2609
+ error: true,
2610
+ error_code: response.status,
2611
+ error_message: error.message
2612
+ };
2613
+ }
2614
+ }
2615
+ else {
2616
+ data = await response.json();
2617
+ }
2618
+ const dataClass = new GasPricesResponse(data.data);
2619
+ checkAndModifyResponse(dataClass);
2620
+ success = true;
2621
+ return {
2622
+ data: dataClass,
2623
+ error: data.error,
2624
+ error_code: data ? data.error_code : response.status,
2625
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
2626
+ };
2627
+ }
2628
+ catch (error) {
2629
+ success = true;
2630
+ return {
2631
+ data: null,
2632
+ error: true,
2633
+ error_code: data ? data.error_code : response.status,
2634
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
2635
+ };
2636
+ }
2637
+ }
2638
+ }
2369
2639
  }
2370
2640
 
2371
2641
  class ChainCollectionResponse {
@@ -2690,10 +2960,11 @@ class MarketFloorPriceItem {
2690
2960
  *
2691
2961
  */
2692
2962
  class NftService {
2693
- constructor(apiKey, debug = false, threadCount = 3) {
2963
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
2694
2964
  this.apiKey = apiKey;
2695
2965
  this.debug = debug;
2696
2966
  this.threadCount = threadCount;
2967
+ this.is_key_valid = is_key_valid;
2697
2968
  this.LIMIT = pLimit$1(this.threadCount);
2698
2969
  }
2699
2970
  /**
@@ -2713,6 +2984,9 @@ class NftService {
2713
2984
  while (!success) {
2714
2985
  try {
2715
2986
  const urlParams = new URLSearchParams();
2987
+ if (!this.is_key_valid) {
2988
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
2989
+ }
2716
2990
  if (queryParamOpts?.pageSize !== undefined) {
2717
2991
  urlParams.append("page-size", queryParamOpts?.pageSize.toString());
2718
2992
  }
@@ -2752,6 +3026,14 @@ class NftService {
2752
3026
  while (!success) {
2753
3027
  try {
2754
3028
  const urlParams = new URLSearchParams();
3029
+ if (!this.is_key_valid) {
3030
+ return {
3031
+ data: null,
3032
+ error: true,
3033
+ error_code: 401,
3034
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3035
+ };
3036
+ }
2755
3037
  if (queryParamOpts?.pageSize !== undefined) {
2756
3038
  urlParams.append("page-size", queryParamOpts?.pageSize.toString());
2757
3039
  }
@@ -2830,6 +3112,14 @@ class NftService {
2830
3112
  while (!success) {
2831
3113
  try {
2832
3114
  const urlParams = new URLSearchParams();
3115
+ if (!this.is_key_valid) {
3116
+ return {
3117
+ data: null,
3118
+ error: true,
3119
+ error_code: 401,
3120
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3121
+ };
3122
+ }
2833
3123
  if (queryParamOpts?.noSpam !== undefined) {
2834
3124
  urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
2835
3125
  }
@@ -2909,6 +3199,9 @@ class NftService {
2909
3199
  while (!success) {
2910
3200
  try {
2911
3201
  const urlParams = new URLSearchParams();
3202
+ if (!this.is_key_valid) {
3203
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
3204
+ }
2912
3205
  if (queryParamOpts?.noMetadata !== undefined) {
2913
3206
  urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
2914
3207
  }
@@ -2961,6 +3254,14 @@ class NftService {
2961
3254
  while (!success) {
2962
3255
  try {
2963
3256
  const urlParams = new URLSearchParams();
3257
+ if (!this.is_key_valid) {
3258
+ return {
3259
+ data: null,
3260
+ error: true,
3261
+ error_code: 401,
3262
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3263
+ };
3264
+ }
2964
3265
  if (queryParamOpts?.noMetadata !== undefined) {
2965
3266
  urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
2966
3267
  }
@@ -3048,6 +3349,14 @@ class NftService {
3048
3349
  while (!success) {
3049
3350
  try {
3050
3351
  const urlParams = new URLSearchParams();
3352
+ if (!this.is_key_valid) {
3353
+ return {
3354
+ data: null,
3355
+ error: true,
3356
+ error_code: 401,
3357
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3358
+ };
3359
+ }
3051
3360
  if (queryParamOpts?.noMetadata !== undefined) {
3052
3361
  urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
3053
3362
  }
@@ -3122,6 +3431,14 @@ class NftService {
3122
3431
  while (!success) {
3123
3432
  try {
3124
3433
  const urlParams = new URLSearchParams();
3434
+ if (!this.is_key_valid) {
3435
+ return {
3436
+ data: null,
3437
+ error: true,
3438
+ error_code: 401,
3439
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3440
+ };
3441
+ }
3125
3442
  if (queryParamOpts?.noSpam !== undefined) {
3126
3443
  urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
3127
3444
  }
@@ -3190,6 +3507,14 @@ class NftService {
3190
3507
  while (!success) {
3191
3508
  try {
3192
3509
  const urlParams = new URLSearchParams();
3510
+ if (!this.is_key_valid) {
3511
+ return {
3512
+ data: null,
3513
+ error: true,
3514
+ error_code: 401,
3515
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3516
+ };
3517
+ }
3193
3518
  let startTime;
3194
3519
  if (this.debug) {
3195
3520
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -3256,6 +3581,14 @@ class NftService {
3256
3581
  while (!success) {
3257
3582
  try {
3258
3583
  const urlParams = new URLSearchParams();
3584
+ if (!this.is_key_valid) {
3585
+ return {
3586
+ data: null,
3587
+ error: true,
3588
+ error_code: 401,
3589
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3590
+ };
3591
+ }
3259
3592
  let startTime;
3260
3593
  if (this.debug) {
3261
3594
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -3321,6 +3654,14 @@ class NftService {
3321
3654
  while (!success) {
3322
3655
  try {
3323
3656
  const urlParams = new URLSearchParams();
3657
+ if (!this.is_key_valid) {
3658
+ return {
3659
+ data: null,
3660
+ error: true,
3661
+ error_code: 401,
3662
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3663
+ };
3664
+ }
3324
3665
  let startTime;
3325
3666
  if (this.debug) {
3326
3667
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -3387,6 +3728,14 @@ class NftService {
3387
3728
  while (!success) {
3388
3729
  try {
3389
3730
  const urlParams = new URLSearchParams();
3731
+ if (!this.is_key_valid) {
3732
+ return {
3733
+ data: null,
3734
+ error: true,
3735
+ error_code: 401,
3736
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3737
+ };
3738
+ }
3390
3739
  let startTime;
3391
3740
  if (this.debug) {
3392
3741
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -3454,6 +3803,14 @@ class NftService {
3454
3803
  while (!success) {
3455
3804
  try {
3456
3805
  const urlParams = new URLSearchParams();
3806
+ if (!this.is_key_valid) {
3807
+ return {
3808
+ data: null,
3809
+ error: true,
3810
+ error_code: 401,
3811
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3812
+ };
3813
+ }
3457
3814
  let startTime;
3458
3815
  if (this.debug) {
3459
3816
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -3522,6 +3879,14 @@ class NftService {
3522
3879
  while (!success) {
3523
3880
  try {
3524
3881
  const urlParams = new URLSearchParams();
3882
+ if (!this.is_key_valid) {
3883
+ return {
3884
+ data: null,
3885
+ error: true,
3886
+ error_code: 401,
3887
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3888
+ };
3889
+ }
3525
3890
  if (queryParamOpts?.days !== undefined) {
3526
3891
  urlParams.append("days", queryParamOpts?.days.toString());
3527
3892
  }
@@ -3596,6 +3961,14 @@ class NftService {
3596
3961
  while (!success) {
3597
3962
  try {
3598
3963
  const urlParams = new URLSearchParams();
3964
+ if (!this.is_key_valid) {
3965
+ return {
3966
+ data: null,
3967
+ error: true,
3968
+ error_code: 401,
3969
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
3970
+ };
3971
+ }
3599
3972
  if (queryParamOpts?.days !== undefined) {
3600
3973
  urlParams.append("days", queryParamOpts?.days.toString());
3601
3974
  }
@@ -3670,6 +4043,14 @@ class NftService {
3670
4043
  while (!success) {
3671
4044
  try {
3672
4045
  const urlParams = new URLSearchParams();
4046
+ if (!this.is_key_valid) {
4047
+ return {
4048
+ data: null,
4049
+ error: true,
4050
+ error_code: 401,
4051
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
4052
+ };
4053
+ }
3673
4054
  if (queryParamOpts?.days !== undefined) {
3674
4055
  urlParams.append("days", queryParamOpts?.days.toString());
3675
4056
  }
@@ -3760,10 +4141,11 @@ let ContractMetadata$1 = class ContractMetadata {
3760
4141
  }
3761
4142
  };
3762
4143
  class PricingService {
3763
- constructor(apiKey, debug = false, threadCount = 3) {
4144
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
3764
4145
  this.apiKey = apiKey;
3765
4146
  this.debug = debug;
3766
4147
  this.threadCount = threadCount;
4148
+ this.is_key_valid = is_key_valid;
3767
4149
  this.LIMIT = pLimit$1(this.threadCount);
3768
4150
  }
3769
4151
  /**
@@ -3787,6 +4169,14 @@ class PricingService {
3787
4169
  while (!success) {
3788
4170
  try {
3789
4171
  const urlParams = new URLSearchParams();
4172
+ if (!this.is_key_valid) {
4173
+ return {
4174
+ data: null,
4175
+ error: true,
4176
+ error_code: 401,
4177
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
4178
+ };
4179
+ }
3790
4180
  if (queryParamOpts?.from !== undefined) {
3791
4181
  urlParams.append("from", queryParamOpts?.from.toString());
3792
4182
  }
@@ -3884,9 +4274,9 @@ class Transaction {
3884
4274
  this.gas_quote_rate = data.gas_quote_rate;
3885
4275
  this.gas_metadata = data.gas_metadata && data.gas_metadata !== null ? new ContractMetadata(data.gas_metadata) : null;
3886
4276
  this.explorers = data.explorers && data.explorers !== null ? data.explorers.map((itemData) => new Explorer(itemData)) : null;
3887
- this.dex_details = data.dex_details && data.dex_details !== null ? new DexReport(data.dex_details) : null;
3888
- this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? new NftSalesReport(data.nft_sale_details) : null;
3889
- this.lending_details = data.lending_details && data.lending_details !== null ? new LendingReport(data.lending_details) : null;
4277
+ this.dex_details = data.dex_details && data.dex_details !== null ? data.dex_details.map((itemData) => new DexReport(itemData)) : null;
4278
+ this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? data.nft_sale_details.map((itemData) => new NftSalesReport(itemData)) : null;
4279
+ this.lending_details = data.lending_details && data.lending_details !== null ? data.lending_details.map((itemData) => new LendingReport(itemData)) : null;
3890
4280
  this.log_events = data.log_events && data.log_events !== null ? data.log_events.map((itemData) => new LogEvent(itemData)) : null;
3891
4281
  this.safe_details = data.safe_details && data.safe_details !== null ? data.safe_details.map((itemData) => new SafeDetails(itemData)) : null;
3892
4282
  }
@@ -4458,10 +4848,11 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
4458
4848
  }
4459
4849
  }
4460
4850
  class TransactionService {
4461
- constructor(apiKey, debug = false, threadCount = 3) {
4851
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
4462
4852
  this.apiKey = apiKey;
4463
4853
  this.debug = debug;
4464
4854
  this.threadCount = threadCount;
4855
+ this.is_key_valid = is_key_valid;
4465
4856
  this.LIMIT = pLimit$1(this.threadCount);
4466
4857
  }
4467
4858
  /**
@@ -4487,6 +4878,14 @@ class TransactionService {
4487
4878
  while (!success) {
4488
4879
  try {
4489
4880
  const urlParams = new URLSearchParams();
4881
+ if (!this.is_key_valid) {
4882
+ return {
4883
+ data: null,
4884
+ error: true,
4885
+ error_code: 401,
4886
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
4887
+ };
4888
+ }
4490
4889
  if (queryParamOpts?.quoteCurrency !== undefined) {
4491
4890
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
4492
4891
  }
@@ -4573,6 +4972,9 @@ class TransactionService {
4573
4972
  while (!success) {
4574
4973
  try {
4575
4974
  const urlParams = new URLSearchParams();
4975
+ if (!this.is_key_valid) {
4976
+ throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
4977
+ }
4576
4978
  if (queryParamOpts?.quoteCurrency !== undefined) {
4577
4979
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
4578
4980
  }
@@ -4617,6 +5019,14 @@ class TransactionService {
4617
5019
  while (!success) {
4618
5020
  try {
4619
5021
  const urlParams = new URLSearchParams();
5022
+ if (!this.is_key_valid) {
5023
+ return {
5024
+ data: null,
5025
+ error: true,
5026
+ error_code: 401,
5027
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5028
+ };
5029
+ }
4620
5030
  if (queryParamOpts?.quoteCurrency !== undefined) {
4621
5031
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
4622
5032
  }
@@ -4698,6 +5108,14 @@ class TransactionService {
4698
5108
  while (!success) {
4699
5109
  try {
4700
5110
  const urlParams = new URLSearchParams();
5111
+ if (!this.is_key_valid) {
5112
+ return {
5113
+ data: null,
5114
+ error: true,
5115
+ error_code: 401,
5116
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5117
+ };
5118
+ }
4701
5119
  if (queryParamOpts?.quoteCurrency !== undefined) {
4702
5120
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
4703
5121
  }
@@ -4772,6 +5190,14 @@ class TransactionService {
4772
5190
  while (!success) {
4773
5191
  try {
4774
5192
  const urlParams = new URLSearchParams();
5193
+ if (!this.is_key_valid) {
5194
+ return {
5195
+ data: null,
5196
+ error: true,
5197
+ error_code: 401,
5198
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5199
+ };
5200
+ }
4775
5201
  let startTime;
4776
5202
  if (this.debug) {
4777
5203
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -4841,6 +5267,14 @@ class TransactionService {
4841
5267
  while (!success) {
4842
5268
  try {
4843
5269
  const urlParams = new URLSearchParams();
5270
+ if (!this.is_key_valid) {
5271
+ return {
5272
+ data: null,
5273
+ error: true,
5274
+ error_code: 401,
5275
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5276
+ };
5277
+ }
4844
5278
  if (queryParamOpts?.quoteCurrency !== undefined) {
4845
5279
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
4846
5280
  }
@@ -5302,10 +5736,11 @@ class HealthData {
5302
5736
  *
5303
5737
  */
5304
5738
  class XykService {
5305
- constructor(apiKey, debug = false, threadCount = 3) {
5739
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
5306
5740
  this.apiKey = apiKey;
5307
5741
  this.debug = debug;
5308
5742
  this.threadCount = threadCount;
5743
+ this.is_key_valid = is_key_valid;
5309
5744
  this.LIMIT = pLimit$1(this.threadCount);
5310
5745
  }
5311
5746
  /**
@@ -5324,6 +5759,14 @@ class XykService {
5324
5759
  while (!success) {
5325
5760
  try {
5326
5761
  const urlParams = new URLSearchParams();
5762
+ if (!this.is_key_valid) {
5763
+ return {
5764
+ data: null,
5765
+ error: true,
5766
+ error_code: 401,
5767
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5768
+ };
5769
+ }
5327
5770
  let startTime;
5328
5771
  if (this.debug) {
5329
5772
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5389,6 +5832,14 @@ class XykService {
5389
5832
  while (!success) {
5390
5833
  try {
5391
5834
  const urlParams = new URLSearchParams();
5835
+ if (!this.is_key_valid) {
5836
+ return {
5837
+ data: null,
5838
+ error: true,
5839
+ error_code: 401,
5840
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5841
+ };
5842
+ }
5392
5843
  let startTime;
5393
5844
  if (this.debug) {
5394
5845
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5455,6 +5906,14 @@ class XykService {
5455
5906
  while (!success) {
5456
5907
  try {
5457
5908
  const urlParams = new URLSearchParams();
5909
+ if (!this.is_key_valid) {
5910
+ return {
5911
+ data: null,
5912
+ error: true,
5913
+ error_code: 401,
5914
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5915
+ };
5916
+ }
5458
5917
  let startTime;
5459
5918
  if (this.debug) {
5460
5919
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5523,6 +5982,14 @@ class XykService {
5523
5982
  while (!success) {
5524
5983
  try {
5525
5984
  const urlParams = new URLSearchParams();
5985
+ if (!this.is_key_valid) {
5986
+ return {
5987
+ data: null,
5988
+ error: true,
5989
+ error_code: 401,
5990
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5991
+ };
5992
+ }
5526
5993
  if (queryParamOpts?.quoteCurrency !== undefined) {
5527
5994
  urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
5528
5995
  }
@@ -5595,6 +6062,14 @@ class XykService {
5595
6062
  while (!success) {
5596
6063
  try {
5597
6064
  const urlParams = new URLSearchParams();
6065
+ if (!this.is_key_valid) {
6066
+ return {
6067
+ data: null,
6068
+ error: true,
6069
+ error_code: 401,
6070
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6071
+ };
6072
+ }
5598
6073
  let startTime;
5599
6074
  if (this.debug) {
5600
6075
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5664,6 +6139,14 @@ class XykService {
5664
6139
  while (!success) {
5665
6140
  try {
5666
6141
  const urlParams = new URLSearchParams();
6142
+ if (!this.is_key_valid) {
6143
+ return {
6144
+ data: null,
6145
+ error: true,
6146
+ error_code: 401,
6147
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6148
+ };
6149
+ }
5667
6150
  if (queryParamOpts?.tokenAddress !== undefined) {
5668
6151
  urlParams.append("token-address", queryParamOpts?.tokenAddress.toString());
5669
6152
  }
@@ -5738,6 +6221,14 @@ class XykService {
5738
6221
  while (!success) {
5739
6222
  try {
5740
6223
  const urlParams = new URLSearchParams();
6224
+ if (!this.is_key_valid) {
6225
+ return {
6226
+ data: null,
6227
+ error: true,
6228
+ error_code: 401,
6229
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6230
+ };
6231
+ }
5741
6232
  let startTime;
5742
6233
  if (this.debug) {
5743
6234
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5801,6 +6292,14 @@ class XykService {
5801
6292
  while (!success) {
5802
6293
  try {
5803
6294
  const urlParams = new URLSearchParams();
6295
+ if (!this.is_key_valid) {
6296
+ return {
6297
+ data: null,
6298
+ error: true,
6299
+ error_code: 401,
6300
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6301
+ };
6302
+ }
5804
6303
  let startTime;
5805
6304
  if (this.debug) {
5806
6305
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5867,6 +6366,14 @@ class XykService {
5867
6366
  while (!success) {
5868
6367
  try {
5869
6368
  const urlParams = new URLSearchParams();
6369
+ if (!this.is_key_valid) {
6370
+ return {
6371
+ data: null,
6372
+ error: true,
6373
+ error_code: 401,
6374
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6375
+ };
6376
+ }
5870
6377
  let startTime;
5871
6378
  if (this.debug) {
5872
6379
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5933,6 +6440,14 @@ class XykService {
5933
6440
  while (!success) {
5934
6441
  try {
5935
6442
  const urlParams = new URLSearchParams();
6443
+ if (!this.is_key_valid) {
6444
+ return {
6445
+ data: null,
6446
+ error: true,
6447
+ error_code: 401,
6448
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6449
+ };
6450
+ }
5936
6451
  let startTime;
5937
6452
  if (this.debug) {
5938
6453
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -5999,6 +6514,14 @@ class XykService {
5999
6514
  while (!success) {
6000
6515
  try {
6001
6516
  const urlParams = new URLSearchParams();
6517
+ if (!this.is_key_valid) {
6518
+ return {
6519
+ data: null,
6520
+ error: true,
6521
+ error_code: 401,
6522
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6523
+ };
6524
+ }
6002
6525
  let startTime;
6003
6526
  if (this.debug) {
6004
6527
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -6065,6 +6588,14 @@ class XykService {
6065
6588
  while (!success) {
6066
6589
  try {
6067
6590
  const urlParams = new URLSearchParams();
6591
+ if (!this.is_key_valid) {
6592
+ return {
6593
+ data: null,
6594
+ error: true,
6595
+ error_code: 401,
6596
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6597
+ };
6598
+ }
6068
6599
  let startTime;
6069
6600
  if (this.debug) {
6070
6601
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -6130,6 +6661,14 @@ class XykService {
6130
6661
  while (!success) {
6131
6662
  try {
6132
6663
  const urlParams = new URLSearchParams();
6664
+ if (!this.is_key_valid) {
6665
+ return {
6666
+ data: null,
6667
+ error: true,
6668
+ error_code: 401,
6669
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6670
+ };
6671
+ }
6133
6672
  let startTime;
6134
6673
  if (this.debug) {
6135
6674
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -6195,6 +6734,14 @@ class XykService {
6195
6734
  while (!success) {
6196
6735
  try {
6197
6736
  const urlParams = new URLSearchParams();
6737
+ if (!this.is_key_valid) {
6738
+ return {
6739
+ data: null,
6740
+ error: true,
6741
+ error_code: 401,
6742
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6743
+ };
6744
+ }
6198
6745
  let startTime;
6199
6746
  if (this.debug) {
6200
6747
  startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
@@ -6246,20 +6793,22 @@ class XykService {
6246
6793
  }
6247
6794
  }
6248
6795
 
6249
- const userAgent = "com.covalenthq.sdk.typescript/0.6.7";
6796
+ const userAgent = "com.covalenthq.sdk.typescript/0.7.0";
6250
6797
  /**
6251
6798
  * CovalentClient Class
6252
6799
  */
6253
6800
  class CovalentClient {
6254
6801
  constructor(apiKey, settings) {
6255
6802
  const { debug = false, threadCount = 3 } = settings || {};
6256
- this.SecurityService = new SecurityService(apiKey, debug, threadCount);
6257
- this.BalanceService = new BalanceService(apiKey, debug, threadCount);
6258
- this.BaseService = new BaseService(apiKey, debug, threadCount);
6259
- this.NftService = new NftService(apiKey, debug, threadCount);
6260
- this.PricingService = new PricingService(apiKey, debug, threadCount);
6261
- this.TransactionService = new TransactionService(apiKey, debug, threadCount);
6262
- this.XykService = new XykService(apiKey, debug, threadCount);
6803
+ const validator = new ApiKeyValidator(apiKey);
6804
+ this._is_key_valid = validator.isValidApiKey();
6805
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
6806
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
6807
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
6808
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
6809
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
6810
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
6811
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
6263
6812
  }
6264
6813
  }
6265
6814
  /**
@@ -6271,13 +6820,15 @@ class CovalentClient {
6271
6820
  class Client {
6272
6821
  constructor(apiKey, settings) {
6273
6822
  const { debug = false, threadCount = 3 } = settings || {};
6274
- this.SecurityService = new SecurityService(apiKey, debug, threadCount);
6275
- this.BalanceService = new BalanceService(apiKey, debug, threadCount);
6276
- this.BaseService = new BaseService(apiKey, debug, threadCount);
6277
- this.NftService = new NftService(apiKey, debug, threadCount);
6278
- this.PricingService = new PricingService(apiKey, debug, threadCount);
6279
- this.TransactionService = new TransactionService(apiKey, debug, threadCount);
6280
- this.XykService = new XykService(apiKey, debug, threadCount);
6823
+ const validator = new ApiKeyValidator(apiKey);
6824
+ this._is_key_valid = validator.isValidApiKey();
6825
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
6826
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
6827
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
6828
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
6829
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
6830
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
6831
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
6281
6832
  }
6282
6833
  }
6283
6834