@covalenthq/client-sdk 0.7.6 → 0.8.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 (76) hide show
  1. package/README.md +5 -0
  2. package/dist/cjs/index.js +815 -181
  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 +815 -181
  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 +815 -181
  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 +1 -1
package/dist/esm/index.js CHANGED
@@ -11,7 +11,7 @@ class ExponentialBackoff {
11
11
  this._apiKey = apiKey;
12
12
  this._debug = debug;
13
13
  }
14
- async backOff(url) {
14
+ async backOff(url, source) {
15
15
  try {
16
16
  let startTime;
17
17
  if (this._debug) {
@@ -20,7 +20,7 @@ class ExponentialBackoff {
20
20
  const response = await fetch(url, {
21
21
  headers: {
22
22
  "Authorization": `Bearer ${this._apiKey}`,
23
- "X-Requested-With": userAgent
23
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
24
24
  }
25
25
  });
26
26
  debugOutput(response.url, response.status ?? 429, startTime);
@@ -36,7 +36,7 @@ class ExponentialBackoff {
36
36
  this.retryCount++;
37
37
  const delayMs = Math.pow(2, this.retryCount) * BASE_DELAY_MS;
38
38
  await new Promise((resolve) => setTimeout(resolve, delayMs));
39
- return this.backOff(url);
39
+ return this.backOff(url, source);
40
40
  }
41
41
  return Promise.reject(new Error(`Max retries exceeded: ${this.maxRetries}`));
42
42
  }
@@ -219,7 +219,7 @@ async function debugOutput(url, responseStatus, startTime) {
219
219
  }
220
220
  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")}`);
221
221
  }
222
- async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor, debug, threadCount, enableRetry) {
222
+ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor, debug, threadCount, enableRetry, source) {
223
223
  let hasNext = true;
224
224
  let response;
225
225
  let data;
@@ -236,13 +236,13 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
236
236
  response = await LIMIT(() => fetch(urlsParams.get("page-number") ? `${url}?${urlsParams}` : `${url}?${urlsParams}&page-number=${page_number}`, {
237
237
  headers: {
238
238
  "Authorization": `Bearer ${apiKey}`,
239
- "X-Requested-With": userAgent
239
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
240
240
  }
241
241
  }));
242
242
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
243
243
  if ((enableRetry === true) && (!response || response.status === null || response.status === 429)) {
244
244
  try {
245
- data = await LIMIT(() => backoff.backOff(response ? response.url : link));
245
+ data = await LIMIT(() => backoff.backOff(response ? response.url : link, source));
246
246
  }
247
247
  catch (error) {
248
248
  hasNext = false;
@@ -384,12 +384,13 @@ class NftApprovalSpender {
384
384
  *
385
385
  */
386
386
  class SecurityService {
387
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
387
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
388
388
  this.apiKey = apiKey;
389
389
  this.debug = debug;
390
390
  this.threadCount = threadCount;
391
391
  this.is_key_valid = is_key_valid;
392
392
  this.enableRetry = enableRetry;
393
+ this.source = source;
393
394
  this.LIMIT = pLimit$1(this.threadCount);
394
395
  }
395
396
  /**
@@ -424,13 +425,13 @@ class SecurityService {
424
425
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/approvals/${walletAddress}/?${urlParams}`, {
425
426
  headers: {
426
427
  "Authorization": `Bearer ${this.apiKey}`,
427
- "X-Requested-With": userAgent
428
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
428
429
  }
429
430
  }));
430
431
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
431
432
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
432
433
  try {
433
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
434
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
434
435
  }
435
436
  catch (error) {
436
437
  success = true;
@@ -497,13 +498,13 @@ class SecurityService {
497
498
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/approvals/${walletAddress}/?${urlParams}`, {
498
499
  headers: {
499
500
  "Authorization": `Bearer ${this.apiKey}`,
500
- "X-Requested-With": userAgent
501
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
501
502
  }
502
503
  }));
503
504
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
504
505
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
505
506
  try {
506
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
507
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
507
508
  }
508
509
  catch (error) {
509
510
  success = true;
@@ -822,12 +823,13 @@ class NativeBalanceItem {
822
823
  *
823
824
  */
824
825
  class BalanceService {
825
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
826
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
826
827
  this.apiKey = apiKey;
827
828
  this.debug = debug;
828
829
  this.threadCount = threadCount;
829
830
  this.is_key_valid = is_key_valid;
830
831
  this.enableRetry = enableRetry;
832
+ this.source = source;
831
833
  this.LIMIT = pLimit$1(this.threadCount);
832
834
  }
833
835
  /**
@@ -883,13 +885,13 @@ class BalanceService {
883
885
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`, {
884
886
  headers: {
885
887
  "Authorization": `Bearer ${this.apiKey}`,
886
- "X-Requested-With": userAgent
888
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
887
889
  }
888
890
  }));
889
891
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
890
892
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
891
893
  try {
892
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
894
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
893
895
  }
894
896
  catch (error) {
895
897
  success = true;
@@ -966,13 +968,13 @@ class BalanceService {
966
968
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`, {
967
969
  headers: {
968
970
  "Authorization": `Bearer ${this.apiKey}`,
969
- "X-Requested-With": userAgent
971
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
970
972
  }
971
973
  }));
972
974
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
973
975
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
974
976
  try {
975
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
977
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
976
978
  }
977
979
  catch (error) {
978
980
  success = true;
@@ -1050,7 +1052,7 @@ class BalanceService {
1050
1052
  if (queryParamOpts?.pageNumber !== undefined) {
1051
1053
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
1052
1054
  }
1053
- 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)) {
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, this.source)) {
1054
1056
  yield res;
1055
1057
  }
1056
1058
  success = true;
@@ -1118,13 +1120,13 @@ class BalanceService {
1118
1120
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`, {
1119
1121
  headers: {
1120
1122
  "Authorization": `Bearer ${this.apiKey}`,
1121
- "X-Requested-With": userAgent
1123
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1122
1124
  }
1123
1125
  }));
1124
1126
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1125
1127
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1126
1128
  try {
1127
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1129
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1128
1130
  }
1129
1131
  catch (error) {
1130
1132
  success = true;
@@ -1194,7 +1196,7 @@ class BalanceService {
1194
1196
  if (queryParamOpts?.date !== undefined) {
1195
1197
  urlParams.append("date", queryParamOpts?.date.toString());
1196
1198
  }
1197
- 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)) {
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, this.source)) {
1198
1200
  yield res;
1199
1201
  }
1200
1202
  success = true;
@@ -1254,13 +1256,13 @@ class BalanceService {
1254
1256
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`, {
1255
1257
  headers: {
1256
1258
  "Authorization": `Bearer ${this.apiKey}`,
1257
- "X-Requested-With": userAgent
1259
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1258
1260
  }
1259
1261
  }));
1260
1262
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1261
1263
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1262
1264
  try {
1263
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1265
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1264
1266
  }
1265
1267
  catch (error) {
1266
1268
  success = true;
@@ -1357,13 +1359,13 @@ class BalanceService {
1357
1359
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/historical_balances/?${urlParams}`, {
1358
1360
  headers: {
1359
1361
  "Authorization": `Bearer ${this.apiKey}`,
1360
- "X-Requested-With": userAgent
1362
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1361
1363
  }
1362
1364
  }));
1363
1365
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1364
1366
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1365
1367
  try {
1366
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1368
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1367
1369
  }
1368
1370
  catch (error) {
1369
1371
  success = true;
@@ -1438,13 +1440,13 @@ class BalanceService {
1438
1440
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`, {
1439
1441
  headers: {
1440
1442
  "Authorization": `Bearer ${this.apiKey}`,
1441
- "X-Requested-With": userAgent
1443
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1442
1444
  }
1443
1445
  }));
1444
1446
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1445
1447
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1446
1448
  try {
1447
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1449
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1448
1450
  }
1449
1451
  catch (error) {
1450
1452
  success = true;
@@ -1703,12 +1705,13 @@ class OtherFees {
1703
1705
  *
1704
1706
  */
1705
1707
  class BaseService {
1706
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
1708
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
1707
1709
  this.apiKey = apiKey;
1708
1710
  this.debug = debug;
1709
1711
  this.threadCount = threadCount;
1710
1712
  this.is_key_valid = is_key_valid;
1711
1713
  this.enableRetry = enableRetry;
1714
+ this.source = source;
1712
1715
  this.LIMIT = pLimit$1(this.threadCount);
1713
1716
  }
1714
1717
  /**
@@ -1743,13 +1746,13 @@ class BaseService {
1743
1746
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${blockHeight}/?${urlParams}`, {
1744
1747
  headers: {
1745
1748
  "Authorization": `Bearer ${this.apiKey}`,
1746
- "X-Requested-With": userAgent
1749
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1747
1750
  }
1748
1751
  }));
1749
1752
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1750
1753
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1751
1754
  try {
1752
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1755
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1753
1756
  }
1754
1757
  catch (error) {
1755
1758
  success = true;
@@ -1817,13 +1820,13 @@ class BaseService {
1817
1820
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, {
1818
1821
  headers: {
1819
1822
  "Authorization": `Bearer ${this.apiKey}`,
1820
- "X-Requested-With": userAgent
1823
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1821
1824
  }
1822
1825
  }));
1823
1826
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1824
1827
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1825
1828
  try {
1826
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1829
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1827
1830
  }
1828
1831
  catch (error) {
1829
1832
  success = true;
@@ -1886,7 +1889,7 @@ class BaseService {
1886
1889
  if (queryParamOpts?.pageNumber !== undefined) {
1887
1890
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
1888
1891
  }
1889
- 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)) {
1892
+ 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)) {
1890
1893
  yield res;
1891
1894
  }
1892
1895
  success = true;
@@ -1939,13 +1942,13 @@ class BaseService {
1939
1942
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_v2/${startDate}/${endDate}/?${urlParams}`, {
1940
1943
  headers: {
1941
1944
  "Authorization": `Bearer ${this.apiKey}`,
1942
- "X-Requested-With": userAgent
1945
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
1943
1946
  }
1944
1947
  }));
1945
1948
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
1946
1949
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
1947
1950
  try {
1948
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
1951
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
1949
1952
  }
1950
1953
  catch (error) {
1951
1954
  success = true;
@@ -2037,13 +2040,13 @@ class BaseService {
2037
2040
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/?${urlParams}`, {
2038
2041
  headers: {
2039
2042
  "Authorization": `Bearer ${this.apiKey}`,
2040
- "X-Requested-With": userAgent
2043
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2041
2044
  }
2042
2045
  }));
2043
2046
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2044
2047
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2045
2048
  try {
2046
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2049
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2047
2050
  }
2048
2051
  catch (error) {
2049
2052
  success = true;
@@ -2113,7 +2116,7 @@ class BaseService {
2113
2116
  if (queryParamOpts?.pageNumber !== undefined) {
2114
2117
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
2115
2118
  }
2116
- 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)) {
2119
+ 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)) {
2117
2120
  yield res;
2118
2121
  }
2119
2122
  success = true;
@@ -2173,13 +2176,13 @@ class BaseService {
2173
2176
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/address/${contractAddress}/?${urlParams}`, {
2174
2177
  headers: {
2175
2178
  "Authorization": `Bearer ${this.apiKey}`,
2176
- "X-Requested-With": userAgent
2179
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2177
2180
  }
2178
2181
  }));
2179
2182
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2180
2183
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2181
2184
  try {
2182
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2185
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2183
2186
  }
2184
2187
  catch (error) {
2185
2188
  success = true;
@@ -2253,7 +2256,7 @@ class BaseService {
2253
2256
  if (queryParamOpts?.pageNumber !== undefined) {
2254
2257
  urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
2255
2258
  }
2256
- 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)) {
2259
+ 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)) {
2257
2260
  yield res;
2258
2261
  }
2259
2262
  success = true;
@@ -2317,13 +2320,13 @@ class BaseService {
2317
2320
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/events/topics/${topicHash}/?${urlParams}`, {
2318
2321
  headers: {
2319
2322
  "Authorization": `Bearer ${this.apiKey}`,
2320
- "X-Requested-With": userAgent
2323
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2321
2324
  }
2322
2325
  }));
2323
2326
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2324
2327
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2325
2328
  try {
2326
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2329
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2327
2330
  }
2328
2331
  catch (error) {
2329
2332
  success = true;
@@ -2389,13 +2392,13 @@ class BaseService {
2389
2392
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/chains/?${urlParams}`, {
2390
2393
  headers: {
2391
2394
  "Authorization": `Bearer ${this.apiKey}`,
2392
- "X-Requested-With": userAgent
2395
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2393
2396
  }
2394
2397
  }));
2395
2398
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2396
2399
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2397
2400
  try {
2398
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2401
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2399
2402
  }
2400
2403
  catch (error) {
2401
2404
  success = true;
@@ -2461,13 +2464,13 @@ class BaseService {
2461
2464
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/chains/status/?${urlParams}`, {
2462
2465
  headers: {
2463
2466
  "Authorization": `Bearer ${this.apiKey}`,
2464
- "X-Requested-With": userAgent
2467
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2465
2468
  }
2466
2469
  }));
2467
2470
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2468
2471
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2469
2472
  try {
2470
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2473
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2471
2474
  }
2472
2475
  catch (error) {
2473
2476
  success = true;
@@ -2539,13 +2542,13 @@ class BaseService {
2539
2542
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/address/${walletAddress}/activity/?${urlParams}`, {
2540
2543
  headers: {
2541
2544
  "Authorization": `Bearer ${this.apiKey}`,
2542
- "X-Requested-With": userAgent
2545
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2543
2546
  }
2544
2547
  }));
2545
2548
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2546
2549
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2547
2550
  try {
2548
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2551
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2549
2552
  }
2550
2553
  catch (error) {
2551
2554
  success = true;
@@ -2616,13 +2619,13 @@ class BaseService {
2616
2619
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/event/${eventType}/gas_prices/?${urlParams}`, {
2617
2620
  headers: {
2618
2621
  "Authorization": `Bearer ${this.apiKey}`,
2619
- "X-Requested-With": userAgent
2622
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
2620
2623
  }
2621
2624
  }));
2622
2625
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
2623
2626
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
2624
2627
  try {
2625
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
2628
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
2626
2629
  }
2627
2630
  catch (error) {
2628
2631
  success = true;
@@ -2982,12 +2985,13 @@ class MarketFloorPriceItem {
2982
2985
  *
2983
2986
  */
2984
2987
  class NftService {
2985
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
2988
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
2986
2989
  this.apiKey = apiKey;
2987
2990
  this.debug = debug;
2988
2991
  this.threadCount = threadCount;
2989
2992
  this.is_key_valid = is_key_valid;
2990
2993
  this.enableRetry = enableRetry;
2994
+ this.source = source;
2991
2995
  this.LIMIT = pLimit$1(this.threadCount);
2992
2996
  }
2993
2997
  /**
@@ -3019,7 +3023,7 @@ class NftService {
3019
3023
  if (queryParamOpts?.noSpam !== undefined) {
3020
3024
  urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
3021
3025
  }
3022
- for await (res of paginateEndpoint$1(`https://api.covalenthq.com/v1/${chainName}/nft/collections/`, this.apiKey, urlParams, ChainCollectionItem, this.debug, this.threadCount, this.enableRetry)) {
3026
+ 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)) {
3023
3027
  yield res;
3024
3028
  }
3025
3029
  success = true;
@@ -3074,13 +3078,13 @@ class NftService {
3074
3078
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/collections/?${urlParams}`, {
3075
3079
  headers: {
3076
3080
  "Authorization": `Bearer ${this.apiKey}`,
3077
- "X-Requested-With": userAgent
3081
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3078
3082
  }
3079
3083
  }));
3080
3084
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3081
3085
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3082
3086
  try {
3083
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3087
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3084
3088
  }
3085
3089
  catch (error) {
3086
3090
  success = true;
@@ -3161,13 +3165,13 @@ class NftService {
3161
3165
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_nft/?${urlParams}`, {
3162
3166
  headers: {
3163
3167
  "Authorization": `Bearer ${this.apiKey}`,
3164
- "X-Requested-With": userAgent
3168
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3165
3169
  }
3166
3170
  }));
3167
3171
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3168
3172
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3169
3173
  try {
3170
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3174
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3171
3175
  }
3172
3176
  catch (error) {
3173
3177
  success = true;
@@ -3245,7 +3249,7 @@ class NftService {
3245
3249
  if (queryParamOpts?.withUncached !== undefined) {
3246
3250
  urlParams.append("with-uncached", queryParamOpts?.withUncached.toString());
3247
3251
  }
3248
- 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)) {
3252
+ 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)) {
3249
3253
  yield res;
3250
3254
  }
3251
3255
  success = true;
@@ -3313,13 +3317,13 @@ class NftService {
3313
3317
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/?${urlParams}`, {
3314
3318
  headers: {
3315
3319
  "Authorization": `Bearer ${this.apiKey}`,
3316
- "X-Requested-With": userAgent
3320
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3317
3321
  }
3318
3322
  }));
3319
3323
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3320
3324
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3321
3325
  try {
3322
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3326
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3323
3327
  }
3324
3328
  catch (error) {
3325
3329
  success = true;
@@ -3397,13 +3401,13 @@ class NftService {
3397
3401
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${contractAddress}/metadata/${tokenId}/?${urlParams}`, {
3398
3402
  headers: {
3399
3403
  "Authorization": `Bearer ${this.apiKey}`,
3400
- "X-Requested-With": userAgent
3404
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3401
3405
  }
3402
3406
  }));
3403
3407
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3404
3408
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3405
3409
  try {
3406
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3410
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3407
3411
  }
3408
3412
  catch (error) {
3409
3413
  success = true;
@@ -3477,13 +3481,13 @@ class NftService {
3477
3481
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/?${urlParams}`, {
3478
3482
  headers: {
3479
3483
  "Authorization": `Bearer ${this.apiKey}`,
3480
- "X-Requested-With": userAgent
3484
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3481
3485
  }
3482
3486
  }));
3483
3487
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3484
3488
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3485
3489
  try {
3486
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3490
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3487
3491
  }
3488
3492
  catch (error) {
3489
3493
  success = true;
@@ -3551,13 +3555,13 @@ class NftService {
3551
3555
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/?${urlParams}`, {
3552
3556
  headers: {
3553
3557
  "Authorization": `Bearer ${this.apiKey}`,
3554
- "X-Requested-With": userAgent
3558
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3555
3559
  }
3556
3560
  }));
3557
3561
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3558
3562
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3559
3563
  try {
3560
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3564
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3561
3565
  }
3562
3566
  catch (error) {
3563
3567
  success = true;
@@ -3626,13 +3630,13 @@ class NftService {
3626
3630
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/?${urlParams}`, {
3627
3631
  headers: {
3628
3632
  "Authorization": `Bearer ${this.apiKey}`,
3629
- "X-Requested-With": userAgent
3633
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3630
3634
  }
3631
3635
  }));
3632
3636
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3633
3637
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3634
3638
  try {
3635
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3639
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3636
3640
  }
3637
3641
  catch (error) {
3638
3642
  success = true;
@@ -3700,13 +3704,13 @@ class NftService {
3700
3704
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft/${collectionContract}/traits_summary/?${urlParams}`, {
3701
3705
  headers: {
3702
3706
  "Authorization": `Bearer ${this.apiKey}`,
3703
- "X-Requested-With": userAgent
3707
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3704
3708
  }
3705
3709
  }));
3706
3710
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3707
3711
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3708
3712
  try {
3709
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3713
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3710
3714
  }
3711
3715
  catch (error) {
3712
3716
  success = true;
@@ -3775,13 +3779,13 @@ class NftService {
3775
3779
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/?${urlParams}`, {
3776
3780
  headers: {
3777
3781
  "Authorization": `Bearer ${this.apiKey}`,
3778
- "X-Requested-With": userAgent
3782
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3779
3783
  }
3780
3784
  }));
3781
3785
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3782
3786
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3783
3787
  try {
3784
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3788
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3785
3789
  }
3786
3790
  catch (error) {
3787
3791
  success = true;
@@ -3851,13 +3855,13 @@ class NftService {
3851
3855
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/?${urlParams}`, {
3852
3856
  headers: {
3853
3857
  "Authorization": `Bearer ${this.apiKey}`,
3854
- "X-Requested-With": userAgent
3858
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3855
3859
  }
3856
3860
  }));
3857
3861
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3858
3862
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3859
3863
  try {
3860
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3864
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3861
3865
  }
3862
3866
  catch (error) {
3863
3867
  success = true;
@@ -3934,13 +3938,13 @@ class NftService {
3934
3938
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/sale_count/?${urlParams}`, {
3935
3939
  headers: {
3936
3940
  "Authorization": `Bearer ${this.apiKey}`,
3937
- "X-Requested-With": userAgent
3941
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
3938
3942
  }
3939
3943
  }));
3940
3944
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
3941
3945
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
3942
3946
  try {
3943
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
3947
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
3944
3948
  }
3945
3949
  catch (error) {
3946
3950
  success = true;
@@ -4017,13 +4021,13 @@ class NftService {
4017
4021
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/volume/?${urlParams}`, {
4018
4022
  headers: {
4019
4023
  "Authorization": `Bearer ${this.apiKey}`,
4020
- "X-Requested-With": userAgent
4024
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4021
4025
  }
4022
4026
  }));
4023
4027
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4024
4028
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4025
4029
  try {
4026
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4030
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4027
4031
  }
4028
4032
  catch (error) {
4029
4033
  success = true;
@@ -4100,13 +4104,13 @@ class NftService {
4100
4104
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/nft_market/${contractAddress}/floor_price/?${urlParams}`, {
4101
4105
  headers: {
4102
4106
  "Authorization": `Bearer ${this.apiKey}`,
4103
- "X-Requested-With": userAgent
4107
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4104
4108
  }
4105
4109
  }));
4106
4110
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4107
4111
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4108
4112
  try {
4109
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4113
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4110
4114
  }
4111
4115
  catch (error) {
4112
4116
  success = true;
@@ -4177,12 +4181,13 @@ let ContractMetadata$2 = class ContractMetadata {
4177
4181
  }
4178
4182
  };
4179
4183
  class PricingService {
4180
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
4184
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
4181
4185
  this.apiKey = apiKey;
4182
4186
  this.debug = debug;
4183
4187
  this.threadCount = threadCount;
4184
4188
  this.is_key_valid = is_key_valid;
4185
4189
  this.enableRetry = enableRetry;
4190
+ this.source = source;
4186
4191
  this.LIMIT = pLimit$1(this.threadCount);
4187
4192
  }
4188
4193
  /**
@@ -4231,13 +4236,13 @@ class PricingService {
4231
4236
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/pricing/historical_by_addresses_v2/${chainName}/${quoteCurrency}/${contractAddress}/?${urlParams}`, {
4232
4237
  headers: {
4233
4238
  "Authorization": `Bearer ${this.apiKey}`,
4234
- "X-Requested-With": userAgent
4239
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
4235
4240
  }
4236
4241
  }));
4237
4242
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4238
4243
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4239
4244
  try {
4240
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
4245
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
4241
4246
  }
4242
4247
  catch (error) {
4243
4248
  success = true;
@@ -4493,12 +4498,13 @@ class Param {
4493
4498
  }
4494
4499
  }
4495
4500
  class RecentTransactionsResponse {
4496
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
4501
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4497
4502
  this._debug = _debug;
4498
4503
  this._apiKey = _apiKey;
4499
4504
  this._threadCount = _threadCount;
4500
4505
  this._urlParams = _urlParams;
4501
4506
  this._enableRetry = _enableRetry;
4507
+ this._source = _source;
4502
4508
  this.address = data.address;
4503
4509
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
4504
4510
  this.quote_currency = data.quote_currency;
@@ -4533,13 +4539,13 @@ class RecentTransactionsResponse {
4533
4539
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4534
4540
  headers: {
4535
4541
  "Authorization": `Bearer ${this._apiKey}`,
4536
- "X-Requested-With": userAgent
4542
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4537
4543
  }
4538
4544
  }));
4539
4545
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4540
4546
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4541
4547
  try {
4542
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
4548
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4543
4549
  }
4544
4550
  catch (error) {
4545
4551
  success = true;
@@ -4554,7 +4560,7 @@ class RecentTransactionsResponse {
4554
4560
  else {
4555
4561
  data = await response.json();
4556
4562
  }
4557
- const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
4563
+ const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4558
4564
  checkAndModifyResponse(dataClass);
4559
4565
  success = true;
4560
4566
  return {
@@ -4600,13 +4606,13 @@ class RecentTransactionsResponse {
4600
4606
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4601
4607
  headers: {
4602
4608
  "Authorization": `Bearer ${this._apiKey}`,
4603
- "X-Requested-With": userAgent
4609
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4604
4610
  }
4605
4611
  }));
4606
4612
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4607
4613
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4608
4614
  try {
4609
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
4615
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4610
4616
  }
4611
4617
  catch (error) {
4612
4618
  success = true;
@@ -4621,7 +4627,7 @@ class RecentTransactionsResponse {
4621
4627
  else {
4622
4628
  data = await response.json();
4623
4629
  }
4624
- const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
4630
+ const dataClass = new RecentTransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4625
4631
  checkAndModifyResponse(dataClass);
4626
4632
  success = true;
4627
4633
  return {
@@ -4649,6 +4655,155 @@ class PaginationLinks {
4649
4655
  this.next = data.next;
4650
4656
  }
4651
4657
  }
4658
+ class TransactionsBlockPageResponse {
4659
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4660
+ this._debug = _debug;
4661
+ this._apiKey = _apiKey;
4662
+ this._threadCount = _threadCount;
4663
+ this._urlParams = _urlParams;
4664
+ this._enableRetry = _enableRetry;
4665
+ this._source = _source;
4666
+ this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
4667
+ this.chain_id = data.chain_id;
4668
+ this.chain_name = data.chain_name;
4669
+ this.links = data.links && data.links !== null ? new PaginationLinks(data.links) : null;
4670
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new Transaction(itemData)) : null;
4671
+ }
4672
+ async prev() {
4673
+ let success = false;
4674
+ let data;
4675
+ let response;
4676
+ const backoff = new ExponentialBackoff(this._apiKey, this._debug);
4677
+ const LIMIT = pLimit$1(this._threadCount);
4678
+ while (!success) {
4679
+ try {
4680
+ let startTime;
4681
+ if (this._debug) {
4682
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
4683
+ }
4684
+ if (this.links.prev === null) {
4685
+ success = true;
4686
+ return {
4687
+ data: null,
4688
+ error: true,
4689
+ error_code: 400,
4690
+ error_message: "Invalid URL: URL link cannot be null"
4691
+ };
4692
+ }
4693
+ const url = `${this.links.prev}?${this._urlParams}`;
4694
+ response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4695
+ headers: {
4696
+ "Authorization": `Bearer ${this._apiKey}`,
4697
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4698
+ }
4699
+ }));
4700
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4701
+ if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4702
+ try {
4703
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4704
+ }
4705
+ catch (error) {
4706
+ success = true;
4707
+ return {
4708
+ data: null,
4709
+ error: true,
4710
+ error_code: response.status ?? 429,
4711
+ error_message: error.message
4712
+ };
4713
+ }
4714
+ }
4715
+ else {
4716
+ data = await response.json();
4717
+ }
4718
+ const dataClass = new TransactionsBlockPageResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4719
+ checkAndModifyResponse(dataClass);
4720
+ success = true;
4721
+ return {
4722
+ data: dataClass,
4723
+ error: data.error,
4724
+ error_code: data ? data.error_code : response.status,
4725
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
4726
+ };
4727
+ }
4728
+ catch (error) {
4729
+ success = true;
4730
+ return {
4731
+ data: null,
4732
+ error: true,
4733
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
4734
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
4735
+ };
4736
+ }
4737
+ }
4738
+ }
4739
+ async next() {
4740
+ let success = false;
4741
+ let data;
4742
+ let response;
4743
+ const backoff = new ExponentialBackoff(this._apiKey, this._debug);
4744
+ const LIMIT = pLimit$1(this._threadCount);
4745
+ while (!success) {
4746
+ try {
4747
+ let startTime;
4748
+ if (this._debug) {
4749
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
4750
+ }
4751
+ if (this.links.next === null) {
4752
+ success = true;
4753
+ return {
4754
+ data: null,
4755
+ error: true,
4756
+ error_code: 400,
4757
+ error_message: "Invalid URL: URL link cannot be null"
4758
+ };
4759
+ }
4760
+ const url = `${this.links.next}?${this._urlParams}`;
4761
+ response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4762
+ headers: {
4763
+ "Authorization": `Bearer ${this._apiKey}`,
4764
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4765
+ }
4766
+ }));
4767
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4768
+ if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4769
+ try {
4770
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4771
+ }
4772
+ catch (error) {
4773
+ success = true;
4774
+ return {
4775
+ data: null,
4776
+ error: true,
4777
+ error_code: response.status ?? 429,
4778
+ error_message: error.message
4779
+ };
4780
+ }
4781
+ }
4782
+ else {
4783
+ data = await response.json();
4784
+ }
4785
+ const dataClass = new TransactionsBlockPageResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4786
+ checkAndModifyResponse(dataClass);
4787
+ success = true;
4788
+ return {
4789
+ data: dataClass,
4790
+ error: data.error,
4791
+ error_code: data ? data.error_code : response.status,
4792
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
4793
+ };
4794
+ }
4795
+ catch (error) {
4796
+ success = true;
4797
+ return {
4798
+ data: null,
4799
+ error: true,
4800
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
4801
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
4802
+ };
4803
+ }
4804
+ }
4805
+ }
4806
+ }
4652
4807
  class TransactionsBlockResponse {
4653
4808
  constructor(data) {
4654
4809
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
@@ -4681,12 +4836,13 @@ class TransactionSummary {
4681
4836
  }
4682
4837
  }
4683
4838
  class TransactionsResponse {
4684
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
4839
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4685
4840
  this._debug = _debug;
4686
4841
  this._apiKey = _apiKey;
4687
4842
  this._threadCount = _threadCount;
4688
4843
  this._urlParams = _urlParams;
4689
4844
  this._enableRetry = _enableRetry;
4845
+ this._source = _source;
4690
4846
  this.address = data.address;
4691
4847
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
4692
4848
  this.quote_currency = data.quote_currency;
@@ -4721,13 +4877,13 @@ class TransactionsResponse {
4721
4877
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4722
4878
  headers: {
4723
4879
  "Authorization": `Bearer ${this._apiKey}`,
4724
- "X-Requested-With": userAgent
4880
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4725
4881
  }
4726
4882
  }));
4727
4883
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4728
4884
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4729
4885
  try {
4730
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
4886
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4731
4887
  }
4732
4888
  catch (error) {
4733
4889
  success = true;
@@ -4742,7 +4898,7 @@ class TransactionsResponse {
4742
4898
  else {
4743
4899
  data = await response.json();
4744
4900
  }
4745
- const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
4901
+ const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4746
4902
  checkAndModifyResponse(dataClass);
4747
4903
  success = true;
4748
4904
  return {
@@ -4788,13 +4944,13 @@ class TransactionsResponse {
4788
4944
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4789
4945
  headers: {
4790
4946
  "Authorization": `Bearer ${this._apiKey}`,
4791
- "X-Requested-With": userAgent
4947
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4792
4948
  }
4793
4949
  }));
4794
4950
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4795
4951
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4796
4952
  try {
4797
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
4953
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4798
4954
  }
4799
4955
  catch (error) {
4800
4956
  success = true;
@@ -4809,7 +4965,7 @@ class TransactionsResponse {
4809
4965
  else {
4810
4966
  data = await response.json();
4811
4967
  }
4812
- const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
4968
+ const dataClass = new TransactionsResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4813
4969
  checkAndModifyResponse(dataClass);
4814
4970
  success = true;
4815
4971
  return {
@@ -4832,12 +4988,13 @@ class TransactionsResponse {
4832
4988
  }
4833
4989
  }
4834
4990
  class TransactionsTimeBucketResponse {
4835
- constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry) {
4991
+ constructor(data, _debug, _apiKey, _threadCount, _urlParams, _enableRetry, _source) {
4836
4992
  this._debug = _debug;
4837
4993
  this._apiKey = _apiKey;
4838
4994
  this._threadCount = _threadCount;
4839
4995
  this._urlParams = _urlParams;
4840
4996
  this._enableRetry = _enableRetry;
4997
+ this._source = _source;
4841
4998
  this.address = data.address;
4842
4999
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
4843
5000
  this.quote_currency = data.quote_currency;
@@ -4873,13 +5030,13 @@ class TransactionsTimeBucketResponse {
4873
5030
  response = await LIMIT(() => fetch(`${this.links.prev}?${this._urlParams}`, {
4874
5031
  headers: {
4875
5032
  "Authorization": `Bearer ${this._apiKey}`,
4876
- "X-Requested-With": userAgent
5033
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4877
5034
  }
4878
5035
  }));
4879
5036
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4880
5037
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4881
5038
  try {
4882
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
5039
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4883
5040
  }
4884
5041
  catch (error) {
4885
5042
  success = true;
@@ -4894,7 +5051,7 @@ class TransactionsTimeBucketResponse {
4894
5051
  else {
4895
5052
  data = await response.json();
4896
5053
  }
4897
- const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
5054
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4898
5055
  checkAndModifyResponse(dataClass);
4899
5056
  success = true;
4900
5057
  return {
@@ -4940,13 +5097,13 @@ class TransactionsTimeBucketResponse {
4940
5097
  response = await LIMIT(() => fetch(`${this.links.next}?${this._urlParams}`, {
4941
5098
  headers: {
4942
5099
  "Authorization": `Bearer ${this._apiKey}`,
4943
- "X-Requested-With": userAgent
5100
+ "X-Requested-With": this._source ? this._source + " " + "(" + userAgent + ")" : userAgent
4944
5101
  }
4945
5102
  }));
4946
5103
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
4947
5104
  if ((this._enableRetry === true) && (!response || response.status === null || response.status === 429)) {
4948
5105
  try {
4949
- data = await LIMIT(() => backoff.backOff(response ? response.url : url));
5106
+ data = await LIMIT(() => backoff.backOff(response ? response.url : url, this._source));
4950
5107
  }
4951
5108
  catch (error) {
4952
5109
  success = true;
@@ -4961,7 +5118,7 @@ class TransactionsTimeBucketResponse {
4961
5118
  else {
4962
5119
  data = await response.json();
4963
5120
  }
4964
- const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry);
5121
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this._debug, this._apiKey, this._threadCount, this._urlParams, this._enableRetry, this._source);
4965
5122
  checkAndModifyResponse(dataClass);
4966
5123
  success = true;
4967
5124
  return {
@@ -4987,7 +5144,7 @@ class TransactionsTimeBucketResponse {
4987
5144
  * Transactions APIs
4988
5145
  *
4989
5146
  */
4990
- async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, enableRetry) {
5147
+ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, enableRetry, source) {
4991
5148
  let hasNext = true;
4992
5149
  let response;
4993
5150
  let data;
@@ -5002,13 +5159,13 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, en
5002
5159
  response = await LIMIT(() => fetch(`${url}?${urlsParams}`, {
5003
5160
  headers: {
5004
5161
  "Authorization": `Bearer ${apiKey}`,
5005
- "X-Requested-With": userAgent
5162
+ "X-Requested-With": source ? source + " " + "(" + userAgent + ")" : userAgent
5006
5163
  }
5007
5164
  }));
5008
5165
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5009
5166
  if ((enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5010
5167
  try {
5011
- data = await LIMIT(() => backoff.backOff(response ? response.url : `${url}?${urlsParams}`));
5168
+ data = await LIMIT(() => backoff.backOff(response ? response.url : `${url}?${urlsParams}`, this.source));
5012
5169
  }
5013
5170
  catch (error) {
5014
5171
  hasNext = false;
@@ -5044,12 +5201,13 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount, en
5044
5201
  }
5045
5202
  }
5046
5203
  class TransactionService {
5047
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
5204
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
5048
5205
  this.apiKey = apiKey;
5049
5206
  this.debug = debug;
5050
5207
  this.threadCount = threadCount;
5051
5208
  this.is_key_valid = is_key_valid;
5052
5209
  this.enableRetry = enableRetry;
5210
+ this.source = source;
5053
5211
  this.LIMIT = pLimit$1(this.threadCount);
5054
5212
  }
5055
5213
  /**
@@ -5109,13 +5267,13 @@ class TransactionService {
5109
5267
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/transaction_v2/${txHash}/?${urlParams}`, {
5110
5268
  headers: {
5111
5269
  "Authorization": `Bearer ${this.apiKey}`,
5112
- "X-Requested-With": userAgent
5270
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5113
5271
  }
5114
5272
  }));
5115
5273
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5116
5274
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5117
5275
  try {
5118
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5276
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5119
5277
  }
5120
5278
  catch (error) {
5121
5279
  success = true;
@@ -5185,7 +5343,7 @@ class TransactionService {
5185
5343
  if (queryParamOpts?.withSafe !== undefined) {
5186
5344
  urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
5187
5345
  }
5188
- for await (tx of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/`, this.apiKey, urlParams, this.debug, this.threadCount, this.enableRetry)) {
5346
+ 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)) {
5189
5347
  yield tx;
5190
5348
  }
5191
5349
  success = true;
@@ -5245,13 +5403,13 @@ class TransactionService {
5245
5403
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/?${urlParams}`, {
5246
5404
  headers: {
5247
5405
  "Authorization": `Bearer ${this.apiKey}`,
5248
- "X-Requested-With": userAgent
5406
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5249
5407
  }
5250
5408
  }));
5251
5409
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5252
5410
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5253
5411
  try {
5254
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5412
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5255
5413
  }
5256
5414
  catch (error) {
5257
5415
  success = true;
@@ -5266,7 +5424,7 @@ class TransactionService {
5266
5424
  else {
5267
5425
  data = await response.json();
5268
5426
  }
5269
- const dataClass = new RecentTransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
5427
+ const dataClass = new RecentTransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5270
5428
  checkAndModifyResponse(dataClass);
5271
5429
  success = true;
5272
5430
  return {
@@ -5332,13 +5490,13 @@ class TransactionService {
5332
5490
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block/${blockHeight}/transactions_v3/?${urlParams}`, {
5333
5491
  headers: {
5334
5492
  "Authorization": `Bearer ${this.apiKey}`,
5335
- "X-Requested-With": userAgent
5493
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5336
5494
  }
5337
5495
  }));
5338
5496
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5339
5497
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5340
5498
  try {
5341
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5499
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5342
5500
  }
5343
5501
  catch (error) {
5344
5502
  success = true;
@@ -5406,13 +5564,13 @@ class TransactionService {
5406
5564
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_summary/?${urlParams}`, {
5407
5565
  headers: {
5408
5566
  "Authorization": `Bearer ${this.apiKey}`,
5409
- "X-Requested-With": userAgent
5567
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5410
5568
  }
5411
5569
  }));
5412
5570
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5413
5571
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5414
5572
  try {
5415
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5573
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5416
5574
  }
5417
5575
  catch (error) {
5418
5576
  success = true;
@@ -5496,13 +5654,13 @@ class TransactionService {
5496
5654
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/?${urlParams}`, {
5497
5655
  headers: {
5498
5656
  "Authorization": `Bearer ${this.apiKey}`,
5499
- "X-Requested-With": userAgent
5657
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5500
5658
  }
5501
5659
  }));
5502
5660
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5503
5661
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5504
5662
  try {
5505
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5663
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5506
5664
  }
5507
5665
  catch (error) {
5508
5666
  success = true;
@@ -5517,7 +5675,7 @@ class TransactionService {
5517
5675
  else {
5518
5676
  data = await response.json();
5519
5677
  }
5520
- const dataClass = new TransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
5678
+ const dataClass = new TransactionsResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5521
5679
  checkAndModifyResponse(dataClass);
5522
5680
  success = true;
5523
5681
  return {
@@ -5582,13 +5740,188 @@ class TransactionService {
5582
5740
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/?${urlParams}`, {
5583
5741
  headers: {
5584
5742
  "Authorization": `Bearer ${this.apiKey}`,
5585
- "X-Requested-With": userAgent
5743
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5744
+ }
5745
+ }));
5746
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5747
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5748
+ try {
5749
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5750
+ }
5751
+ catch (error) {
5752
+ success = true;
5753
+ return {
5754
+ data: null,
5755
+ error: true,
5756
+ error_code: response.status ?? 429,
5757
+ error_message: error.message
5758
+ };
5759
+ }
5760
+ }
5761
+ else {
5762
+ data = await response.json();
5763
+ }
5764
+ const dataClass = new TransactionsTimeBucketResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5765
+ checkAndModifyResponse(dataClass);
5766
+ success = true;
5767
+ return {
5768
+ data: dataClass,
5769
+ error: data.error,
5770
+ error_code: data ? data.error_code : response.status,
5771
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
5772
+ };
5773
+ }
5774
+ catch (error) {
5775
+ success = true;
5776
+ return {
5777
+ data: null,
5778
+ error: true,
5779
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
5780
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
5781
+ };
5782
+ }
5783
+ }
5784
+ }
5785
+ /**
5786
+ *
5787
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
5788
+ *
5789
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
5790
+ * @param {string} blockHash - The requested block hash.
5791
+ * @param {number} page - The requested 0-indexed page number.
5792
+ * @param {GetTransactionsForBlockHashByPageQueryParamOpts} queryParamOpts
5793
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
5794
+ * - `noLogs`: Omit log events.
5795
+ * - `withSafe`: Include safe details.
5796
+ *
5797
+ */
5798
+ async getTransactionsForBlockHashByPage(chainName, blockHash, page, queryParamOpts) {
5799
+ let success = false;
5800
+ let data;
5801
+ let response;
5802
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
5803
+ while (!success) {
5804
+ try {
5805
+ const urlParams = new URLSearchParams();
5806
+ if (!this.is_key_valid) {
5807
+ return {
5808
+ data: null,
5809
+ error: true,
5810
+ error_code: 401,
5811
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5812
+ };
5813
+ }
5814
+ if (queryParamOpts?.quoteCurrency !== undefined) {
5815
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
5816
+ }
5817
+ if (queryParamOpts?.noLogs !== undefined) {
5818
+ urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
5819
+ }
5820
+ if (queryParamOpts?.withSafe !== undefined) {
5821
+ urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
5822
+ }
5823
+ const url = `https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/page/${page}/?${urlParams}`;
5824
+ let startTime;
5825
+ if (this.debug) {
5826
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
5827
+ }
5828
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/page/${page}/?${urlParams}`, {
5829
+ headers: {
5830
+ "Authorization": `Bearer ${this.apiKey}`,
5831
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5832
+ }
5833
+ }));
5834
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5835
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5836
+ try {
5837
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5838
+ }
5839
+ catch (error) {
5840
+ success = true;
5841
+ return {
5842
+ data: null,
5843
+ error: true,
5844
+ error_code: response.status ?? 429,
5845
+ error_message: error.message
5846
+ };
5847
+ }
5848
+ }
5849
+ else {
5850
+ data = await response.json();
5851
+ }
5852
+ const dataClass = new TransactionsBlockPageResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry, this.source);
5853
+ checkAndModifyResponse(dataClass);
5854
+ success = true;
5855
+ return {
5856
+ data: dataClass,
5857
+ error: data.error,
5858
+ error_code: data ? data.error_code : response.status,
5859
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
5860
+ };
5861
+ }
5862
+ catch (error) {
5863
+ success = true;
5864
+ return {
5865
+ data: null,
5866
+ error: true,
5867
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
5868
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
5869
+ };
5870
+ }
5871
+ }
5872
+ }
5873
+ /**
5874
+ *
5875
+ * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
5876
+ *
5877
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
5878
+ * @param {string} blockHash - The requested block hash.
5879
+ * @param {GetTransactionsForBlockHashQueryParamOpts} queryParamOpts
5880
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
5881
+ * - `noLogs`: Omit log events.
5882
+ * - `withSafe`: Include safe details.
5883
+ *
5884
+ */
5885
+ async getTransactionsForBlockHash(chainName, blockHash, queryParamOpts) {
5886
+ let success = false;
5887
+ let data;
5888
+ let response;
5889
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
5890
+ while (!success) {
5891
+ try {
5892
+ const urlParams = new URLSearchParams();
5893
+ if (!this.is_key_valid) {
5894
+ return {
5895
+ data: null,
5896
+ error: true,
5897
+ error_code: 401,
5898
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
5899
+ };
5900
+ }
5901
+ if (queryParamOpts?.quoteCurrency !== undefined) {
5902
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
5903
+ }
5904
+ if (queryParamOpts?.noLogs !== undefined) {
5905
+ urlParams.append("no-logs", queryParamOpts?.noLogs.toString());
5906
+ }
5907
+ if (queryParamOpts?.withSafe !== undefined) {
5908
+ urlParams.append("with-safe", queryParamOpts?.withSafe.toString());
5909
+ }
5910
+ const url = `https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/?${urlParams}`;
5911
+ let startTime;
5912
+ if (this.debug) {
5913
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
5914
+ }
5915
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/block_hash/${blockHash}/transactions_v3/?${urlParams}`, {
5916
+ headers: {
5917
+ "Authorization": `Bearer ${this.apiKey}`,
5918
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
5586
5919
  }
5587
5920
  }));
5588
5921
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
5589
5922
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
5590
5923
  try {
5591
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
5924
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
5592
5925
  }
5593
5926
  catch (error) {
5594
5927
  success = true;
@@ -5603,7 +5936,7 @@ class TransactionService {
5603
5936
  else {
5604
5937
  data = await response.json();
5605
5938
  }
5606
- const dataClass = new TransactionsTimeBucketResponse(data.data, this.debug, this.apiKey, this.threadCount, urlParams, this.enableRetry);
5939
+ const dataClass = new TransactionsBlockResponse(data.data);
5607
5940
  checkAndModifyResponse(dataClass);
5608
5941
  success = true;
5609
5942
  return {
@@ -5868,23 +6201,55 @@ class UniswapLikeTokenWithSupply {
5868
6201
  this.contract_ticker_symbol = data.contract_ticker_symbol;
5869
6202
  this.contract_address = data.contract_address;
5870
6203
  this.logo_url = data.logo_url;
5871
- this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
5872
- this.quote = data.quote;
5873
- this.pretty_quote = data.pretty_quote;
6204
+ this.balance = data.balance && data.balance !== null ? BigInt(data.balance) : null;
6205
+ this.quote = data.quote;
6206
+ this.pretty_quote = data.pretty_quote;
6207
+ this.quote_rate = data.quote_rate;
6208
+ this.total_supply = data.total_supply && data.total_supply !== null ? BigInt(data.total_supply) : null;
6209
+ }
6210
+ }
6211
+ class NetworkExchangeTokensResponse {
6212
+ constructor(data) {
6213
+ this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
6214
+ this.chain_id = data.chain_id;
6215
+ this.chain_name = data.chain_name;
6216
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2Volume(itemData)) : null;
6217
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
6218
+ }
6219
+ }
6220
+ class TokenV2Volume {
6221
+ constructor(data) {
6222
+ this.chain_name = data.chain_name;
6223
+ this.chain_id = data.chain_id;
6224
+ this.dex_name = data.dex_name;
6225
+ this.contract_address = data.contract_address;
6226
+ this.contract_name = data.contract_name;
6227
+ this.total_liquidity = data.total_liquidity;
6228
+ this.total_volume_24h = data.total_volume_24h;
6229
+ this.logo_url = data.logo_url;
6230
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
6231
+ this.contract_decimals = data.contract_decimals;
6232
+ this.swap_count_24h = data.swap_count_24h;
5874
6233
  this.quote_rate = data.quote_rate;
5875
- this.total_supply = data.total_supply && data.total_supply !== null ? BigInt(data.total_supply) : null;
6234
+ this.quote_rate_24h = data.quote_rate_24h;
6235
+ this.pretty_quote_rate = data.pretty_quote_rate;
6236
+ this.pretty_quote_rate_24h = data.pretty_quote_rate_24h;
6237
+ this.pretty_total_liquidity_quote = data.pretty_total_liquidity_quote;
6238
+ this.pretty_total_volume_24h_quote = data.pretty_total_volume_24h_quote;
6239
+ this.total_liquidity_quote = data.total_liquidity_quote;
6240
+ this.total_volume_24h_quote = data.total_volume_24h_quote;
5876
6241
  }
5877
6242
  }
5878
- class NetworkExchangeTokensResponse {
6243
+ class NetworkExchangeTokenViewResponse {
5879
6244
  constructor(data) {
5880
6245
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
5881
6246
  this.chain_id = data.chain_id;
5882
6247
  this.chain_name = data.chain_name;
5883
- this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2Volume(itemData)) : null;
6248
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2VolumeWithChartData(itemData)) : null;
5884
6249
  this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
5885
6250
  }
5886
6251
  }
5887
- class TokenV2Volume {
6252
+ class TokenV2VolumeWithChartData {
5888
6253
  constructor(data) {
5889
6254
  this.chain_name = data.chain_name;
5890
6255
  this.chain_id = data.chain_id;
@@ -5905,6 +6270,43 @@ class TokenV2Volume {
5905
6270
  this.pretty_total_volume_24h_quote = data.pretty_total_volume_24h_quote;
5906
6271
  this.total_liquidity_quote = data.total_liquidity_quote;
5907
6272
  this.total_volume_24h_quote = data.total_volume_24h_quote;
6273
+ this.transactions_24h = data.transactions_24h;
6274
+ this.volume_timeseries_7d = data.volume_timeseries_7d && data.volume_timeseries_7d !== null ? data.volume_timeseries_7d.map((itemData) => new VolumeTokenTimeseries(itemData)) : null;
6275
+ this.volume_timeseries_30d = data.volume_timeseries_30d && data.volume_timeseries_30d !== null ? data.volume_timeseries_30d.map((itemData) => new VolumeTokenTimeseries(itemData)) : null;
6276
+ this.liquidity_timeseries_7d = data.liquidity_timeseries_7d && data.liquidity_timeseries_7d !== null ? data.liquidity_timeseries_7d.map((itemData) => new LiquidityTokenTimeseries(itemData)) : null;
6277
+ this.liquidity_timeseries_30d = data.liquidity_timeseries_30d && data.liquidity_timeseries_30d !== null ? data.liquidity_timeseries_30d.map((itemData) => new LiquidityTokenTimeseries(itemData)) : null;
6278
+ this.price_timeseries_7d = data.price_timeseries_7d && data.price_timeseries_7d !== null ? data.price_timeseries_7d.map((itemData) => new PriceTokenTimeseries(itemData)) : null;
6279
+ this.price_timeseries_30d = data.price_timeseries_30d && data.price_timeseries_30d !== null ? data.price_timeseries_30d.map((itemData) => new PriceTokenTimeseries(itemData)) : null;
6280
+ }
6281
+ }
6282
+ class VolumeTokenTimeseries {
6283
+ constructor(data) {
6284
+ this.dex_name = data.dex_name;
6285
+ this.chain_id = data.chain_id;
6286
+ this.dt = data.dt;
6287
+ this.total_volume = data.total_volume;
6288
+ this.volume_quote = data.volume_quote;
6289
+ this.pretty_volume_quote = data.pretty_volume_quote;
6290
+ }
6291
+ }
6292
+ class LiquidityTokenTimeseries {
6293
+ constructor(data) {
6294
+ this.dex_name = data.dex_name;
6295
+ this.chain_id = data.chain_id;
6296
+ this.dt = data.dt;
6297
+ this.total_liquidity = data.total_liquidity;
6298
+ this.liquidity_quote = data.liquidity_quote;
6299
+ this.pretty_liquidity_quote = data.pretty_liquidity_quote;
6300
+ }
6301
+ }
6302
+ class PriceTokenTimeseries {
6303
+ constructor(data) {
6304
+ this.dex_name = data.dex_name;
6305
+ this.chain_id = data.chain_id;
6306
+ this.dt = data.dt;
6307
+ this.quote_currency = data.quote_currency;
6308
+ this.quote_rate = data.quote_rate;
6309
+ this.pretty_quote_rate = data.pretty_quote_rate;
5908
6310
  }
5909
6311
  }
5910
6312
  class SupportedDexesResponse {
@@ -6005,6 +6407,15 @@ class TransactionsForExchangeResponse {
6005
6407
  this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
6006
6408
  }
6007
6409
  }
6410
+ class NetworkTransactionsResponse {
6411
+ constructor(data) {
6412
+ this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
6413
+ this.chain_id = data.chain_id;
6414
+ this.chain_name = data.chain_name;
6415
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new ExchangeTransaction(itemData)) : null;
6416
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
6417
+ }
6418
+ }
6008
6419
  class EcosystemChartDataResponse {
6009
6420
  constructor(data) {
6010
6421
  this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
@@ -6074,12 +6485,13 @@ class HealthData {
6074
6485
  *
6075
6486
  */
6076
6487
  class XykService {
6077
- constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
6488
+ constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true, source) {
6078
6489
  this.apiKey = apiKey;
6079
6490
  this.debug = debug;
6080
6491
  this.threadCount = threadCount;
6081
6492
  this.is_key_valid = is_key_valid;
6082
6493
  this.enableRetry = enableRetry;
6494
+ this.source = source;
6083
6495
  this.LIMIT = pLimit$1(this.threadCount);
6084
6496
  }
6085
6497
  /**
@@ -6088,9 +6500,12 @@ class XykService {
6088
6500
  *
6089
6501
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6090
6502
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6503
+ * @param {GetPoolsQueryParamOpts} queryParamOpts
6504
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6505
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6091
6506
  *
6092
6507
  */
6093
- async getPools(chainName, dexName) {
6508
+ async getPools(chainName, dexName, queryParamOpts) {
6094
6509
  let success = false;
6095
6510
  let data;
6096
6511
  let response;
@@ -6098,6 +6513,12 @@ class XykService {
6098
6513
  while (!success) {
6099
6514
  try {
6100
6515
  const urlParams = new URLSearchParams();
6516
+ if (queryParamOpts?.pageSize !== undefined) {
6517
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
6518
+ }
6519
+ if (queryParamOpts?.pageNumber !== undefined) {
6520
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
6521
+ }
6101
6522
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`;
6102
6523
  if (!this.is_key_valid) {
6103
6524
  return {
@@ -6114,13 +6535,13 @@ class XykService {
6114
6535
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`, {
6115
6536
  headers: {
6116
6537
  "Authorization": `Bearer ${this.apiKey}`,
6117
- "X-Requested-With": userAgent
6538
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6118
6539
  }
6119
6540
  }));
6120
6541
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6121
6542
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6122
6543
  try {
6123
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6544
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6124
6545
  }
6125
6546
  catch (error) {
6126
6547
  success = true;
@@ -6188,13 +6609,13 @@ class XykService {
6188
6609
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/address/${poolAddress}/dex_name/?${urlParams}`, {
6189
6610
  headers: {
6190
6611
  "Authorization": `Bearer ${this.apiKey}`,
6191
- "X-Requested-With": userAgent
6612
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6192
6613
  }
6193
6614
  }));
6194
6615
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6195
6616
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6196
6617
  try {
6197
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6618
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6198
6619
  }
6199
6620
  catch (error) {
6200
6621
  success = true;
@@ -6263,13 +6684,13 @@ class XykService {
6263
6684
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/?${urlParams}`, {
6264
6685
  headers: {
6265
6686
  "Authorization": `Bearer ${this.apiKey}`,
6266
- "X-Requested-With": userAgent
6687
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6267
6688
  }
6268
6689
  }));
6269
6690
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6270
6691
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6271
6692
  try {
6272
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6693
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6273
6694
  }
6274
6695
  catch (error) {
6275
6696
  success = true;
@@ -6314,6 +6735,8 @@ class XykService {
6314
6735
  * @param {number} page - The requested 0-indexed page number.
6315
6736
  * @param {GetPoolsForTokenAddressQueryParamOpts} queryParamOpts
6316
6737
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
6738
+ * - `dexName`: The DEX name eg: `uniswap_v2`.
6739
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6317
6740
  *
6318
6741
  */
6319
6742
  async getPoolsForTokenAddress(chainName, tokenAddress, page, queryParamOpts) {
@@ -6338,6 +6761,9 @@ class XykService {
6338
6761
  if (queryParamOpts?.dexName !== undefined) {
6339
6762
  urlParams.append("dex-name", queryParamOpts?.dexName.toString());
6340
6763
  }
6764
+ if (queryParamOpts?.pageSize !== undefined) {
6765
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
6766
+ }
6341
6767
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/tokens/address/${tokenAddress}/pools/page/${page}/?${urlParams}`;
6342
6768
  let startTime;
6343
6769
  if (this.debug) {
@@ -6346,13 +6772,13 @@ class XykService {
6346
6772
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/tokens/address/${tokenAddress}/pools/page/${page}/?${urlParams}`, {
6347
6773
  headers: {
6348
6774
  "Authorization": `Bearer ${this.apiKey}`,
6349
- "X-Requested-With": userAgent
6775
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6350
6776
  }
6351
6777
  }));
6352
6778
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6353
6779
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6354
6780
  try {
6355
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6781
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6356
6782
  }
6357
6783
  catch (error) {
6358
6784
  success = true;
@@ -6421,13 +6847,13 @@ class XykService {
6421
6847
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/balances/?${urlParams}`, {
6422
6848
  headers: {
6423
6849
  "Authorization": `Bearer ${this.apiKey}`,
6424
- "X-Requested-With": userAgent
6850
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6425
6851
  }
6426
6852
  }));
6427
6853
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6428
6854
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6429
6855
  try {
6430
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6856
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6431
6857
  }
6432
6858
  catch (error) {
6433
6859
  success = true;
@@ -6473,6 +6899,8 @@ class XykService {
6473
6899
  * @param {GetPoolsForWalletAddressQueryParamOpts} queryParamOpts
6474
6900
  * - `tokenAddress`: The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
6475
6901
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
6902
+ * - `dexName`: The DEX name eg: `uniswap_v2`.
6903
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6476
6904
  *
6477
6905
  */
6478
6906
  async getPoolsForWalletAddress(chainName, walletAddress, page, queryParamOpts) {
@@ -6500,6 +6928,9 @@ class XykService {
6500
6928
  if (queryParamOpts?.dexName !== undefined) {
6501
6929
  urlParams.append("dex-name", queryParamOpts?.dexName.toString());
6502
6930
  }
6931
+ if (queryParamOpts?.pageSize !== undefined) {
6932
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
6933
+ }
6503
6934
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/address/${walletAddress}/pools/page/${page}/?${urlParams}`;
6504
6935
  let startTime;
6505
6936
  if (this.debug) {
@@ -6508,13 +6939,13 @@ class XykService {
6508
6939
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/address/${walletAddress}/pools/page/${page}/?${urlParams}`, {
6509
6940
  headers: {
6510
6941
  "Authorization": `Bearer ${this.apiKey}`,
6511
- "X-Requested-With": userAgent
6942
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6512
6943
  }
6513
6944
  }));
6514
6945
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6515
6946
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6516
6947
  try {
6517
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
6948
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6518
6949
  }
6519
6950
  catch (error) {
6520
6951
  success = true;
@@ -6556,9 +6987,12 @@ class XykService {
6556
6987
  *
6557
6988
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6558
6989
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6990
+ * @param {GetNetworkExchangeTokensQueryParamOpts} queryParamOpts
6991
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
6992
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6559
6993
  *
6560
6994
  */
6561
- async getNetworkExchangeTokens(chainName, dexName) {
6995
+ async getNetworkExchangeTokens(chainName, dexName, queryParamOpts) {
6562
6996
  let success = false;
6563
6997
  let data;
6564
6998
  let response;
@@ -6566,6 +7000,12 @@ class XykService {
6566
7000
  while (!success) {
6567
7001
  try {
6568
7002
  const urlParams = new URLSearchParams();
7003
+ if (queryParamOpts?.pageSize !== undefined) {
7004
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
7005
+ }
7006
+ if (queryParamOpts?.pageNumber !== undefined) {
7007
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
7008
+ }
6569
7009
  if (!this.is_key_valid) {
6570
7010
  return {
6571
7011
  data: null,
@@ -6582,13 +7022,13 @@ class XykService {
6582
7022
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/?${urlParams}`, {
6583
7023
  headers: {
6584
7024
  "Authorization": `Bearer ${this.apiKey}`,
6585
- "X-Requested-With": userAgent
7025
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6586
7026
  }
6587
7027
  }));
6588
7028
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6589
7029
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6590
7030
  try {
6591
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7031
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6592
7032
  }
6593
7033
  catch (error) {
6594
7034
  success = true;
@@ -6624,6 +7064,86 @@ class XykService {
6624
7064
  }
6625
7065
  }
6626
7066
  }
7067
+ /**
7068
+ *
7069
+ * Commonly used to get a detailed view for a single liquidity pool token. Includes time series data.
7070
+ *
7071
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
7072
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
7073
+ * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
7074
+ * @param {GetLpTokenViewQueryParamOpts} queryParamOpts
7075
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
7076
+ *
7077
+ */
7078
+ async getLpTokenView(chainName, dexName, tokenAddress, queryParamOpts) {
7079
+ let success = false;
7080
+ let data;
7081
+ let response;
7082
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
7083
+ while (!success) {
7084
+ try {
7085
+ const urlParams = new URLSearchParams();
7086
+ if (!this.is_key_valid) {
7087
+ return {
7088
+ data: null,
7089
+ error: true,
7090
+ error_code: 401,
7091
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
7092
+ };
7093
+ }
7094
+ if (queryParamOpts?.quoteCurrency !== undefined) {
7095
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
7096
+ }
7097
+ const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/view/?${urlParams}`;
7098
+ let startTime;
7099
+ if (this.debug) {
7100
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
7101
+ }
7102
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/view/?${urlParams}`, {
7103
+ headers: {
7104
+ "Authorization": `Bearer ${this.apiKey}`,
7105
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7106
+ }
7107
+ }));
7108
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7109
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7110
+ try {
7111
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7112
+ }
7113
+ catch (error) {
7114
+ success = true;
7115
+ return {
7116
+ data: null,
7117
+ error: true,
7118
+ error_code: response.status ?? 429,
7119
+ error_message: error.message
7120
+ };
7121
+ }
7122
+ }
7123
+ else {
7124
+ data = await response.json();
7125
+ }
7126
+ const dataClass = new NetworkExchangeTokenViewResponse(data.data);
7127
+ checkAndModifyResponse(dataClass);
7128
+ success = true;
7129
+ return {
7130
+ data: dataClass,
7131
+ error: data.error,
7132
+ error_code: data ? data.error_code : response.status,
7133
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
7134
+ };
7135
+ }
7136
+ catch (error) {
7137
+ success = true;
7138
+ return {
7139
+ data: null,
7140
+ error: true,
7141
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
7142
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
7143
+ };
7144
+ }
7145
+ }
7146
+ }
6627
7147
  /**
6628
7148
  *
6629
7149
  * Commonly used to get all the supported DEXs available for the xy=k endpoints, along with the swap fees and factory addresses.
@@ -6654,13 +7174,13 @@ class XykService {
6654
7174
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/xy=k/supported_dexes/?${urlParams}`, {
6655
7175
  headers: {
6656
7176
  "Authorization": `Bearer ${this.apiKey}`,
6657
- "X-Requested-With": userAgent
7177
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6658
7178
  }
6659
7179
  }));
6660
7180
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6661
7181
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6662
7182
  try {
6663
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7183
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6664
7184
  }
6665
7185
  catch (error) {
6666
7186
  success = true;
@@ -6703,9 +7223,12 @@ class XykService {
6703
7223
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6704
7224
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6705
7225
  * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
7226
+ * @param {GetSingleNetworkExchangeTokenQueryParamOpts} queryParamOpts
7227
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
7228
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6706
7229
  *
6707
7230
  */
6708
- async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) {
7231
+ async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress, queryParamOpts) {
6709
7232
  let success = false;
6710
7233
  let data;
6711
7234
  let response;
@@ -6713,6 +7236,12 @@ class XykService {
6713
7236
  while (!success) {
6714
7237
  try {
6715
7238
  const urlParams = new URLSearchParams();
7239
+ if (queryParamOpts?.pageSize !== undefined) {
7240
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
7241
+ }
7242
+ if (queryParamOpts?.pageNumber !== undefined) {
7243
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
7244
+ }
6716
7245
  if (!this.is_key_valid) {
6717
7246
  return {
6718
7247
  data: null,
@@ -6729,13 +7258,13 @@ class XykService {
6729
7258
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, {
6730
7259
  headers: {
6731
7260
  "Authorization": `Bearer ${this.apiKey}`,
6732
- "X-Requested-With": userAgent
7261
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6733
7262
  }
6734
7263
  }));
6735
7264
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6736
7265
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6737
7266
  try {
6738
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7267
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6739
7268
  }
6740
7269
  catch (error) {
6741
7270
  success = true;
@@ -6804,13 +7333,13 @@ class XykService {
6804
7333
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, {
6805
7334
  headers: {
6806
7335
  "Authorization": `Bearer ${this.apiKey}`,
6807
- "X-Requested-With": userAgent
7336
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6808
7337
  }
6809
7338
  }));
6810
7339
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6811
7340
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6812
7341
  try {
6813
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7342
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6814
7343
  }
6815
7344
  catch (error) {
6816
7345
  success = true;
@@ -6853,9 +7382,12 @@ class XykService {
6853
7382
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6854
7383
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6855
7384
  * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
7385
+ * @param {GetTransactionsForTokenAddressQueryParamOpts} queryParamOpts
7386
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
7387
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6856
7388
  *
6857
7389
  */
6858
- async getTransactionsForTokenAddress(chainName, dexName, tokenAddress) {
7390
+ async getTransactionsForTokenAddress(chainName, dexName, tokenAddress, queryParamOpts) {
6859
7391
  let success = false;
6860
7392
  let data;
6861
7393
  let response;
@@ -6871,6 +7403,12 @@ class XykService {
6871
7403
  error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6872
7404
  };
6873
7405
  }
7406
+ if (queryParamOpts?.pageSize !== undefined) {
7407
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
7408
+ }
7409
+ if (queryParamOpts?.pageNumber !== undefined) {
7410
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
7411
+ }
6874
7412
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`;
6875
7413
  let startTime;
6876
7414
  if (this.debug) {
@@ -6879,13 +7417,13 @@ class XykService {
6879
7417
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, {
6880
7418
  headers: {
6881
7419
  "Authorization": `Bearer ${this.apiKey}`,
6882
- "X-Requested-With": userAgent
7420
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6883
7421
  }
6884
7422
  }));
6885
7423
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6886
7424
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6887
7425
  try {
6888
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7426
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6889
7427
  }
6890
7428
  catch (error) {
6891
7429
  success = true;
@@ -6928,9 +7466,12 @@ class XykService {
6928
7466
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
6929
7467
  * @param {string} dexName - The DEX name eg: `uniswap_v2`.
6930
7468
  * @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
7469
+ * @param {GetTransactionsForExchangeQueryParamOpts} queryParamOpts
7470
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
7471
+ * - `pageNumber`: 0-indexed page number to begin pagination.
6931
7472
  *
6932
7473
  */
6933
- async getTransactionsForExchange(chainName, dexName, poolAddress) {
7474
+ async getTransactionsForExchange(chainName, dexName, poolAddress, queryParamOpts) {
6934
7475
  let success = false;
6935
7476
  let data;
6936
7477
  let response;
@@ -6946,6 +7487,12 @@ class XykService {
6946
7487
  error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
6947
7488
  };
6948
7489
  }
7490
+ if (queryParamOpts?.pageSize !== undefined) {
7491
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
7492
+ }
7493
+ if (queryParamOpts?.pageNumber !== undefined) {
7494
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
7495
+ }
6949
7496
  const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`;
6950
7497
  let startTime;
6951
7498
  if (this.debug) {
@@ -6954,13 +7501,13 @@ class XykService {
6954
7501
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, {
6955
7502
  headers: {
6956
7503
  "Authorization": `Bearer ${this.apiKey}`,
6957
- "X-Requested-With": userAgent
7504
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
6958
7505
  }
6959
7506
  }));
6960
7507
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
6961
7508
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
6962
7509
  try {
6963
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7510
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
6964
7511
  }
6965
7512
  catch (error) {
6966
7513
  success = true;
@@ -6996,6 +7543,93 @@ class XykService {
6996
7543
  }
6997
7544
  }
6998
7545
  }
7546
+ /**
7547
+ *
7548
+ * Commonly used to get all the the transactions for a given DEX. Useful for building DEX activity views.
7549
+ *
7550
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
7551
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
7552
+ * @param {GetTransactionsForDexQueryParamOpts} queryParamOpts
7553
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
7554
+ * - `pageSize`: Number of items per page. Omitting this parameter defaults to 100.
7555
+ * - `pageNumber`: 0-indexed page number to begin pagination.
7556
+ *
7557
+ */
7558
+ async getTransactionsForDex(chainName, dexName, queryParamOpts) {
7559
+ let success = false;
7560
+ let data;
7561
+ let response;
7562
+ const backoff = new ExponentialBackoff(this.apiKey, this.debug);
7563
+ while (!success) {
7564
+ try {
7565
+ const urlParams = new URLSearchParams();
7566
+ if (!this.is_key_valid) {
7567
+ return {
7568
+ data: null,
7569
+ error: true,
7570
+ error_code: 401,
7571
+ error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
7572
+ };
7573
+ }
7574
+ if (queryParamOpts?.quoteCurrency !== undefined) {
7575
+ urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
7576
+ }
7577
+ if (queryParamOpts?.pageSize !== undefined) {
7578
+ urlParams.append("page-size", queryParamOpts?.pageSize.toString());
7579
+ }
7580
+ if (queryParamOpts?.pageNumber !== undefined) {
7581
+ urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
7582
+ }
7583
+ const url = `https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/transactions/?${urlParams}`;
7584
+ let startTime;
7585
+ if (this.debug) {
7586
+ startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
7587
+ }
7588
+ response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/transactions/?${urlParams}`, {
7589
+ headers: {
7590
+ "Authorization": `Bearer ${this.apiKey}`,
7591
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7592
+ }
7593
+ }));
7594
+ debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7595
+ if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7596
+ try {
7597
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7598
+ }
7599
+ catch (error) {
7600
+ success = true;
7601
+ return {
7602
+ data: null,
7603
+ error: true,
7604
+ error_code: response.status ?? 429,
7605
+ error_message: error.message
7606
+ };
7607
+ }
7608
+ }
7609
+ else {
7610
+ data = await response.json();
7611
+ }
7612
+ const dataClass = new NetworkTransactionsResponse(data.data);
7613
+ checkAndModifyResponse(dataClass);
7614
+ success = true;
7615
+ return {
7616
+ data: dataClass,
7617
+ error: data.error,
7618
+ error_code: data ? data.error_code : response.status,
7619
+ error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
7620
+ };
7621
+ }
7622
+ catch (error) {
7623
+ success = true;
7624
+ return {
7625
+ data: null,
7626
+ error: true,
7627
+ error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
7628
+ error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
7629
+ };
7630
+ }
7631
+ }
7632
+ }
6999
7633
  /**
7000
7634
  *
7001
7635
  * Commonly used to get a 7d and 30d time-series chart of DEX activity. Includes volume and swap count.
@@ -7028,13 +7662,13 @@ class XykService {
7028
7662
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/ecosystem/?${urlParams}`, {
7029
7663
  headers: {
7030
7664
  "Authorization": `Bearer ${this.apiKey}`,
7031
- "X-Requested-With": userAgent
7665
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7032
7666
  }
7033
7667
  }));
7034
7668
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7035
7669
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7036
7670
  try {
7037
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7671
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7038
7672
  }
7039
7673
  catch (error) {
7040
7674
  success = true;
@@ -7102,13 +7736,13 @@ class XykService {
7102
7736
  response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/health/?${urlParams}`, {
7103
7737
  headers: {
7104
7738
  "Authorization": `Bearer ${this.apiKey}`,
7105
- "X-Requested-With": userAgent
7739
+ "X-Requested-With": this.source ? this.source + " " + "(" + userAgent + ")" : userAgent
7106
7740
  }
7107
7741
  }));
7108
7742
  debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
7109
7743
  if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
7110
7744
  try {
7111
- data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
7745
+ data = await this.LIMIT(() => backoff.backOff(response ? response.url : url, this.source));
7112
7746
  }
7113
7747
  catch (error) {
7114
7748
  success = true;
@@ -7146,22 +7780,22 @@ class XykService {
7146
7780
  }
7147
7781
  }
7148
7782
 
7149
- const userAgent = "com.covalenthq.sdk.typescript/0.7.6";
7783
+ const userAgent = "com.covalenthq.sdk.typescript/0.8.0";
7150
7784
  /**
7151
7785
  * CovalentClient Class
7152
7786
  */
7153
7787
  class CovalentClient {
7154
- constructor(apiKey, settings) {
7788
+ constructor(apiKey, settings, source) {
7155
7789
  const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
7156
7790
  const validator = new ApiKeyValidator(apiKey);
7157
7791
  this._is_key_valid = validator.isValidApiKey();
7158
- this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7159
- this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7160
- this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7161
- this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7162
- this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7163
- this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7164
- this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7792
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7793
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7794
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7795
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7796
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7797
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7798
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7165
7799
  }
7166
7800
  }
7167
7801
  /**
@@ -7171,17 +7805,17 @@ class CovalentClient {
7171
7805
  * CovalentClient Class
7172
7806
  */
7173
7807
  class Client {
7174
- constructor(apiKey, settings) {
7808
+ constructor(apiKey, settings, source) {
7175
7809
  const { debug = false, threadCount = 3, enableRetry = true } = settings || {};
7176
7810
  const validator = new ApiKeyValidator(apiKey);
7177
7811
  this._is_key_valid = validator.isValidApiKey();
7178
- this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7179
- this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7180
- this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7181
- this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7182
- this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7183
- this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7184
- this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry);
7812
+ this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7813
+ this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7814
+ this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7815
+ this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7816
+ this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7817
+ this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7818
+ this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid, enableRetry, source);
7185
7819
  }
7186
7820
  }
7187
7821