@covalenthq/client-sdk 0.6.7 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/index.js +744 -193
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +2 -1
- package/dist/cjs/services/BaseService.d.ts +55 -2
- package/dist/cjs/services/CovalentClient.d.ts +3 -1
- package/dist/cjs/services/NftService.d.ts +2 -1
- package/dist/cjs/services/PricingService.d.ts +2 -1
- package/dist/cjs/services/SecurityService.d.ts +2 -1
- package/dist/cjs/services/TransactionService.d.ts +5 -4
- package/dist/cjs/services/XykService.d.ts +2 -1
- package/dist/cjs/util/ApiKeyValidator.d.ts +8 -0
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/es/index.js +744 -193
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +2 -1
- package/dist/es/services/BaseService.d.ts +55 -2
- package/dist/es/services/CovalentClient.d.ts +3 -1
- package/dist/es/services/NftService.d.ts +2 -1
- package/dist/es/services/PricingService.d.ts +2 -1
- package/dist/es/services/SecurityService.d.ts +2 -1
- package/dist/es/services/TransactionService.d.ts +5 -4
- package/dist/es/services/XykService.d.ts +2 -1
- package/dist/es/util/ApiKeyValidator.d.ts +8 -0
- package/dist/es/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/es/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/esm/index.js +744 -193
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +2 -1
- package/dist/esm/services/BaseService.d.ts +55 -2
- package/dist/esm/services/CovalentClient.d.ts +3 -1
- package/dist/esm/services/NftService.d.ts +2 -1
- package/dist/esm/services/PricingService.d.ts +2 -1
- package/dist/esm/services/SecurityService.d.ts +2 -1
- package/dist/esm/services/TransactionService.d.ts +5 -4
- package/dist/esm/services/XykService.d.ts +2 -1
- package/dist/esm/util/ApiKeyValidator.d.ts +8 -0
- package/dist/esm/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/services/BalanceService.d.ts +2 -1
- package/dist/services/BalanceService.js +75 -19
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +55 -2
- package/dist/services/BaseService.js +212 -26
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +3 -1
- package/dist/services/CovalentClient.js +20 -15
- package/dist/services/CovalentClient.js.map +1 -1
- package/dist/services/NftService.d.ts +2 -1
- package/dist/services/NftService.js +152 -40
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.d.ts +2 -1
- package/dist/services/PricingService.js +14 -4
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +2 -1
- package/dist/services/SecurityService.js +25 -7
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +5 -4
- package/dist/services/TransactionService.js +78 -33
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +2 -1
- package/dist/services/XykService.js +157 -43
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.js +3 -3
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/ApiKeyValidator.d.ts +8 -0
- package/dist/util/ApiKeyValidator.js +13 -0
- package/dist/util/ApiKeyValidator.js.map +1 -0
- package/dist/util/backoff.js +3 -3
- package/dist/util/backoff.js.map +1 -1
- package/dist/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/util/types/TransactionServiceTypes.d.ts +3 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -23,9 +23,9 @@ class ExponentialBackoff {
|
|
|
23
23
|
"X-Requested-With": userAgent
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
debugOutput(response.url, response.status, startTime);
|
|
27
|
-
if (response.status === 429) {
|
|
28
|
-
throw new Error(`Received status code: ${response.status}`);
|
|
26
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
27
|
+
if (response.status === null || response.status === 429) {
|
|
28
|
+
throw new Error(`Received status code: ${response.status ?? 429}`);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
return response.json();
|
|
@@ -238,14 +238,14 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
238
238
|
"X-Requested-With": userAgent
|
|
239
239
|
}
|
|
240
240
|
}));
|
|
241
|
-
debugOutput(response.url, response.status, startTime);
|
|
242
|
-
if (response.status === 429) {
|
|
241
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
242
|
+
if (response.status === null || response.status === 429) {
|
|
243
243
|
try {
|
|
244
244
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
245
245
|
}
|
|
246
246
|
catch (error) {
|
|
247
247
|
hasNext = false;
|
|
248
|
-
throw new Error(`An error occurred ${response.status}: ${error.message}`);
|
|
248
|
+
throw new Error(`An error occurred ${response.status ?? 429}: ${error.message}`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
else {
|
|
@@ -283,6 +283,19 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
class ApiKeyValidator {
|
|
287
|
+
constructor(apiKey) {
|
|
288
|
+
this._apiKey = apiKey;
|
|
289
|
+
}
|
|
290
|
+
isValidApiKey() {
|
|
291
|
+
return ApiKeyValidator._apiKeyV1Pattern.test(this._apiKey) || ApiKeyValidator._apiKeyV2Pattern.test(this._apiKey);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Regular expression patterns
|
|
295
|
+
ApiKeyValidator._apiKeyV1Pattern = /^ckey_([a-f0-9]{27})$/;
|
|
296
|
+
ApiKeyValidator._apiKeyV2Pattern = /^cqt_(wF|rQ)([bcdfghjkmpqrtvwxyBCDFGHJKMPQRTVWXY346789]{26})$/;
|
|
297
|
+
ApiKeyValidator.INVALID_API_KEY_MESSAGE = "Invalid or missing API key (sign up at covalenthq.com/platform)";
|
|
298
|
+
|
|
286
299
|
class ApprovalsResponse {
|
|
287
300
|
constructor(data) {
|
|
288
301
|
this.address = data.address;
|
|
@@ -370,10 +383,11 @@ class NftApprovalSpender {
|
|
|
370
383
|
*
|
|
371
384
|
*/
|
|
372
385
|
class SecurityService {
|
|
373
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
386
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
374
387
|
this.apiKey = apiKey;
|
|
375
388
|
this.debug = debug;
|
|
376
389
|
this.threadCount = threadCount;
|
|
390
|
+
this.is_key_valid = is_key_valid;
|
|
377
391
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
378
392
|
}
|
|
379
393
|
/**
|
|
@@ -392,6 +406,14 @@ class SecurityService {
|
|
|
392
406
|
while (!success) {
|
|
393
407
|
try {
|
|
394
408
|
const urlParams = new URLSearchParams();
|
|
409
|
+
if (!this.is_key_valid) {
|
|
410
|
+
return {
|
|
411
|
+
data: null,
|
|
412
|
+
error: true,
|
|
413
|
+
error_code: 401,
|
|
414
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
415
|
+
};
|
|
416
|
+
}
|
|
395
417
|
let startTime;
|
|
396
418
|
if (this.debug) {
|
|
397
419
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -402,8 +424,8 @@ class SecurityService {
|
|
|
402
424
|
"X-Requested-With": userAgent
|
|
403
425
|
}
|
|
404
426
|
}));
|
|
405
|
-
debugOutput(response.url, response.status, startTime);
|
|
406
|
-
if (response.status === 429) {
|
|
427
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
428
|
+
if (response.status === null || response.status === 429) {
|
|
407
429
|
try {
|
|
408
430
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
409
431
|
}
|
|
@@ -412,7 +434,7 @@ class SecurityService {
|
|
|
412
434
|
return {
|
|
413
435
|
data: null,
|
|
414
436
|
error: true,
|
|
415
|
-
error_code: response.status,
|
|
437
|
+
error_code: response.status ?? 429,
|
|
416
438
|
error_message: error.message
|
|
417
439
|
};
|
|
418
440
|
}
|
|
@@ -456,6 +478,14 @@ class SecurityService {
|
|
|
456
478
|
while (!success) {
|
|
457
479
|
try {
|
|
458
480
|
const urlParams = new URLSearchParams();
|
|
481
|
+
if (!this.is_key_valid) {
|
|
482
|
+
return {
|
|
483
|
+
data: null,
|
|
484
|
+
error: true,
|
|
485
|
+
error_code: 401,
|
|
486
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
487
|
+
};
|
|
488
|
+
}
|
|
459
489
|
let startTime;
|
|
460
490
|
if (this.debug) {
|
|
461
491
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -466,8 +496,8 @@ class SecurityService {
|
|
|
466
496
|
"X-Requested-With": userAgent
|
|
467
497
|
}
|
|
468
498
|
}));
|
|
469
|
-
debugOutput(response.url, response.status, startTime);
|
|
470
|
-
if (response.status === 429) {
|
|
499
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
500
|
+
if (response.status === null || response.status === 429) {
|
|
471
501
|
try {
|
|
472
502
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
473
503
|
}
|
|
@@ -476,7 +506,7 @@ class SecurityService {
|
|
|
476
506
|
return {
|
|
477
507
|
data: null,
|
|
478
508
|
error: true,
|
|
479
|
-
error_code: response.status,
|
|
509
|
+
error_code: response.status ?? 429,
|
|
480
510
|
error_message: error.message
|
|
481
511
|
};
|
|
482
512
|
}
|
|
@@ -788,10 +818,11 @@ class NativeBalanceItem {
|
|
|
788
818
|
*
|
|
789
819
|
*/
|
|
790
820
|
class BalanceService {
|
|
791
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
821
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
792
822
|
this.apiKey = apiKey;
|
|
793
823
|
this.debug = debug;
|
|
794
824
|
this.threadCount = threadCount;
|
|
825
|
+
this.is_key_valid = is_key_valid;
|
|
795
826
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
796
827
|
}
|
|
797
828
|
/**
|
|
@@ -816,6 +847,14 @@ class BalanceService {
|
|
|
816
847
|
while (!success) {
|
|
817
848
|
try {
|
|
818
849
|
const urlParams = new URLSearchParams();
|
|
850
|
+
if (!this.is_key_valid) {
|
|
851
|
+
return {
|
|
852
|
+
data: null,
|
|
853
|
+
error: true,
|
|
854
|
+
error_code: 401,
|
|
855
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
856
|
+
};
|
|
857
|
+
}
|
|
819
858
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
820
859
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
821
860
|
}
|
|
@@ -841,8 +880,8 @@ class BalanceService {
|
|
|
841
880
|
"X-Requested-With": userAgent
|
|
842
881
|
}
|
|
843
882
|
}));
|
|
844
|
-
debugOutput(response.url, response.status, startTime);
|
|
845
|
-
if (response.status === 429) {
|
|
883
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
884
|
+
if (response.status === null || response.status === 429) {
|
|
846
885
|
try {
|
|
847
886
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
848
887
|
}
|
|
@@ -851,7 +890,7 @@ class BalanceService {
|
|
|
851
890
|
return {
|
|
852
891
|
data: null,
|
|
853
892
|
error: true,
|
|
854
|
-
error_code: response.status,
|
|
893
|
+
error_code: response.status ?? 429,
|
|
855
894
|
error_message: error.message
|
|
856
895
|
};
|
|
857
896
|
}
|
|
@@ -899,6 +938,14 @@ class BalanceService {
|
|
|
899
938
|
while (!success) {
|
|
900
939
|
try {
|
|
901
940
|
const urlParams = new URLSearchParams();
|
|
941
|
+
if (!this.is_key_valid) {
|
|
942
|
+
return {
|
|
943
|
+
data: null,
|
|
944
|
+
error: true,
|
|
945
|
+
error_code: 401,
|
|
946
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
947
|
+
};
|
|
948
|
+
}
|
|
902
949
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
903
950
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
904
951
|
}
|
|
@@ -915,8 +962,8 @@ class BalanceService {
|
|
|
915
962
|
"X-Requested-With": userAgent
|
|
916
963
|
}
|
|
917
964
|
}));
|
|
918
|
-
debugOutput(response.url, response.status, startTime);
|
|
919
|
-
if (response.status === 429) {
|
|
965
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
966
|
+
if (response.status === null || response.status === 429) {
|
|
920
967
|
try {
|
|
921
968
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
922
969
|
}
|
|
@@ -925,7 +972,7 @@ class BalanceService {
|
|
|
925
972
|
return {
|
|
926
973
|
data: null,
|
|
927
974
|
error: true,
|
|
928
|
-
error_code: response.status,
|
|
975
|
+
error_code: response.status ?? 429,
|
|
929
976
|
error_message: error.message
|
|
930
977
|
};
|
|
931
978
|
}
|
|
@@ -975,6 +1022,9 @@ class BalanceService {
|
|
|
975
1022
|
while (!success) {
|
|
976
1023
|
try {
|
|
977
1024
|
const urlParams = new URLSearchParams();
|
|
1025
|
+
if (!this.is_key_valid) {
|
|
1026
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1027
|
+
}
|
|
978
1028
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
979
1029
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
980
1030
|
}
|
|
@@ -1027,6 +1077,14 @@ class BalanceService {
|
|
|
1027
1077
|
while (!success) {
|
|
1028
1078
|
try {
|
|
1029
1079
|
const urlParams = new URLSearchParams();
|
|
1080
|
+
if (!this.is_key_valid) {
|
|
1081
|
+
return {
|
|
1082
|
+
data: null,
|
|
1083
|
+
error: true,
|
|
1084
|
+
error_code: 401,
|
|
1085
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1030
1088
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1031
1089
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1032
1090
|
}
|
|
@@ -1055,8 +1113,8 @@ class BalanceService {
|
|
|
1055
1113
|
"X-Requested-With": userAgent
|
|
1056
1114
|
}
|
|
1057
1115
|
}));
|
|
1058
|
-
debugOutput(response.url, response.status, startTime);
|
|
1059
|
-
if (response.status === 429) {
|
|
1116
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1117
|
+
if (response.status === null || response.status === 429) {
|
|
1060
1118
|
try {
|
|
1061
1119
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1062
1120
|
}
|
|
@@ -1065,7 +1123,7 @@ class BalanceService {
|
|
|
1065
1123
|
return {
|
|
1066
1124
|
data: null,
|
|
1067
1125
|
error: true,
|
|
1068
|
-
error_code: response.status,
|
|
1126
|
+
error_code: response.status ?? 429,
|
|
1069
1127
|
error_message: error.message
|
|
1070
1128
|
};
|
|
1071
1129
|
}
|
|
@@ -1113,6 +1171,9 @@ class BalanceService {
|
|
|
1113
1171
|
while (!success) {
|
|
1114
1172
|
try {
|
|
1115
1173
|
const urlParams = new URLSearchParams();
|
|
1174
|
+
if (!this.is_key_valid) {
|
|
1175
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1176
|
+
}
|
|
1116
1177
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1117
1178
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1118
1179
|
}
|
|
@@ -1157,6 +1218,14 @@ class BalanceService {
|
|
|
1157
1218
|
while (!success) {
|
|
1158
1219
|
try {
|
|
1159
1220
|
const urlParams = new URLSearchParams();
|
|
1221
|
+
if (!this.is_key_valid) {
|
|
1222
|
+
return {
|
|
1223
|
+
data: null,
|
|
1224
|
+
error: true,
|
|
1225
|
+
error_code: 401,
|
|
1226
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1160
1229
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1161
1230
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1162
1231
|
}
|
|
@@ -1179,8 +1248,8 @@ class BalanceService {
|
|
|
1179
1248
|
"X-Requested-With": userAgent
|
|
1180
1249
|
}
|
|
1181
1250
|
}));
|
|
1182
|
-
debugOutput(response.url, response.status, startTime);
|
|
1183
|
-
if (response.status === 429) {
|
|
1251
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1252
|
+
if (response.status === null || response.status === 429) {
|
|
1184
1253
|
try {
|
|
1185
1254
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1186
1255
|
}
|
|
@@ -1189,7 +1258,7 @@ class BalanceService {
|
|
|
1189
1258
|
return {
|
|
1190
1259
|
data: null,
|
|
1191
1260
|
error: true,
|
|
1192
|
-
error_code: response.status,
|
|
1261
|
+
error_code: response.status ?? 429,
|
|
1193
1262
|
error_message: error.message
|
|
1194
1263
|
};
|
|
1195
1264
|
}
|
|
@@ -1242,6 +1311,14 @@ class BalanceService {
|
|
|
1242
1311
|
while (!success) {
|
|
1243
1312
|
try {
|
|
1244
1313
|
const urlParams = new URLSearchParams();
|
|
1314
|
+
if (!this.is_key_valid) {
|
|
1315
|
+
return {
|
|
1316
|
+
data: null,
|
|
1317
|
+
error: true,
|
|
1318
|
+
error_code: 401,
|
|
1319
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1245
1322
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1246
1323
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1247
1324
|
}
|
|
@@ -1273,8 +1350,8 @@ class BalanceService {
|
|
|
1273
1350
|
"X-Requested-With": userAgent
|
|
1274
1351
|
}
|
|
1275
1352
|
}));
|
|
1276
|
-
debugOutput(response.url, response.status, startTime);
|
|
1277
|
-
if (response.status === 429) {
|
|
1353
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1354
|
+
if (response.status === null || response.status === 429) {
|
|
1278
1355
|
try {
|
|
1279
1356
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1280
1357
|
}
|
|
@@ -1283,7 +1360,7 @@ class BalanceService {
|
|
|
1283
1360
|
return {
|
|
1284
1361
|
data: null,
|
|
1285
1362
|
error: true,
|
|
1286
|
-
error_code: response.status,
|
|
1363
|
+
error_code: response.status ?? 429,
|
|
1287
1364
|
error_message: error.message
|
|
1288
1365
|
};
|
|
1289
1366
|
}
|
|
@@ -1329,6 +1406,14 @@ class BalanceService {
|
|
|
1329
1406
|
while (!success) {
|
|
1330
1407
|
try {
|
|
1331
1408
|
const urlParams = new URLSearchParams();
|
|
1409
|
+
if (!this.is_key_valid) {
|
|
1410
|
+
return {
|
|
1411
|
+
data: null,
|
|
1412
|
+
error: true,
|
|
1413
|
+
error_code: 401,
|
|
1414
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1332
1417
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1333
1418
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1334
1419
|
}
|
|
@@ -1345,8 +1430,8 @@ class BalanceService {
|
|
|
1345
1430
|
"X-Requested-With": userAgent
|
|
1346
1431
|
}
|
|
1347
1432
|
}));
|
|
1348
|
-
debugOutput(response.url, response.status, startTime);
|
|
1349
|
-
if (response.status === 429) {
|
|
1433
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1434
|
+
if (response.status === null || response.status === 429) {
|
|
1350
1435
|
try {
|
|
1351
1436
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1352
1437
|
}
|
|
@@ -1355,7 +1440,7 @@ class BalanceService {
|
|
|
1355
1440
|
return {
|
|
1356
1441
|
data: null,
|
|
1357
1442
|
error: true,
|
|
1358
|
-
error_code: response.status,
|
|
1443
|
+
error_code: response.status ?? 429,
|
|
1359
1444
|
error_message: error.message
|
|
1360
1445
|
};
|
|
1361
1446
|
}
|
|
@@ -1575,15 +1660,43 @@ class ChainActivityEvent extends ChainItem {
|
|
|
1575
1660
|
this.last_seen_at = data.last_seen_at && data.last_seen_at !== null ? parseISO(data.last_seen_at.toString()) : null;
|
|
1576
1661
|
}
|
|
1577
1662
|
}
|
|
1663
|
+
class GasPricesResponse {
|
|
1664
|
+
constructor(data) {
|
|
1665
|
+
this.chain_id = data.chain_id;
|
|
1666
|
+
this.chain_name = data.chain_name;
|
|
1667
|
+
this.quote_currency = data.quote_currency;
|
|
1668
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? parseISO(data.updated_at.toString()) : null;
|
|
1669
|
+
this.event_type = data.event_type;
|
|
1670
|
+
this.gas_quote_rate = data.gas_quote_rate;
|
|
1671
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new PriceItem(itemData)) : null;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
class PriceItem {
|
|
1675
|
+
constructor(data) {
|
|
1676
|
+
this.gas_price = data.gas_price;
|
|
1677
|
+
this.gas_spent = data.gas_spent;
|
|
1678
|
+
this.gas_quote = data.gas_quote;
|
|
1679
|
+
this.total_gas_quote = data.total_gas_quote;
|
|
1680
|
+
this.pretty_total_gas_quote = data.pretty_total_gas_quote;
|
|
1681
|
+
this.interval = data.interval;
|
|
1682
|
+
this.other_fees = data.other_fees && data.other_fees !== null ? new OtherFees(data.other_fees) : null;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
class OtherFees {
|
|
1686
|
+
constructor(data) {
|
|
1687
|
+
this.l1_gas_quote = data.l1_gas_quote;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1578
1690
|
/**
|
|
1579
1691
|
* Class A - Base
|
|
1580
1692
|
*
|
|
1581
1693
|
*/
|
|
1582
1694
|
class BaseService {
|
|
1583
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
1695
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
1584
1696
|
this.apiKey = apiKey;
|
|
1585
1697
|
this.debug = debug;
|
|
1586
1698
|
this.threadCount = threadCount;
|
|
1699
|
+
this.is_key_valid = is_key_valid;
|
|
1587
1700
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
1588
1701
|
}
|
|
1589
1702
|
/**
|
|
@@ -1602,6 +1715,14 @@ class BaseService {
|
|
|
1602
1715
|
while (!success) {
|
|
1603
1716
|
try {
|
|
1604
1717
|
const urlParams = new URLSearchParams();
|
|
1718
|
+
if (!this.is_key_valid) {
|
|
1719
|
+
return {
|
|
1720
|
+
data: null,
|
|
1721
|
+
error: true,
|
|
1722
|
+
error_code: 401,
|
|
1723
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1605
1726
|
let startTime;
|
|
1606
1727
|
if (this.debug) {
|
|
1607
1728
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1612,8 +1733,8 @@ class BaseService {
|
|
|
1612
1733
|
"X-Requested-With": userAgent
|
|
1613
1734
|
}
|
|
1614
1735
|
}));
|
|
1615
|
-
debugOutput(response.url, response.status, startTime);
|
|
1616
|
-
if (response.status === 429) {
|
|
1736
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1737
|
+
if (response.status === null || response.status === 429) {
|
|
1617
1738
|
try {
|
|
1618
1739
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1619
1740
|
}
|
|
@@ -1622,7 +1743,7 @@ class BaseService {
|
|
|
1622
1743
|
return {
|
|
1623
1744
|
data: null,
|
|
1624
1745
|
error: true,
|
|
1625
|
-
error_code: response.status,
|
|
1746
|
+
error_code: response.status ?? 429,
|
|
1626
1747
|
error_message: error.message
|
|
1627
1748
|
};
|
|
1628
1749
|
}
|
|
@@ -1667,6 +1788,14 @@ class BaseService {
|
|
|
1667
1788
|
while (!success) {
|
|
1668
1789
|
try {
|
|
1669
1790
|
const urlParams = new URLSearchParams();
|
|
1791
|
+
if (!this.is_key_valid) {
|
|
1792
|
+
return {
|
|
1793
|
+
data: null,
|
|
1794
|
+
error: true,
|
|
1795
|
+
error_code: 401,
|
|
1796
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1670
1799
|
let startTime;
|
|
1671
1800
|
if (this.debug) {
|
|
1672
1801
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1677,8 +1806,8 @@ class BaseService {
|
|
|
1677
1806
|
"X-Requested-With": userAgent
|
|
1678
1807
|
}
|
|
1679
1808
|
}));
|
|
1680
|
-
debugOutput(response.url, response.status, startTime);
|
|
1681
|
-
if (response.status === 429) {
|
|
1809
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1810
|
+
if (response.status === null || response.status === 429) {
|
|
1682
1811
|
try {
|
|
1683
1812
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1684
1813
|
}
|
|
@@ -1687,7 +1816,7 @@ class BaseService {
|
|
|
1687
1816
|
return {
|
|
1688
1817
|
data: null,
|
|
1689
1818
|
error: true,
|
|
1690
|
-
error_code: response.status,
|
|
1819
|
+
error_code: response.status ?? 429,
|
|
1691
1820
|
error_message: error.message
|
|
1692
1821
|
};
|
|
1693
1822
|
}
|
|
@@ -1734,6 +1863,9 @@ class BaseService {
|
|
|
1734
1863
|
while (!success) {
|
|
1735
1864
|
try {
|
|
1736
1865
|
const urlParams = new URLSearchParams();
|
|
1866
|
+
if (!this.is_key_valid) {
|
|
1867
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1868
|
+
}
|
|
1737
1869
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
1738
1870
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1739
1871
|
}
|
|
@@ -1771,6 +1903,14 @@ class BaseService {
|
|
|
1771
1903
|
while (!success) {
|
|
1772
1904
|
try {
|
|
1773
1905
|
const urlParams = new URLSearchParams();
|
|
1906
|
+
if (!this.is_key_valid) {
|
|
1907
|
+
return {
|
|
1908
|
+
data: null,
|
|
1909
|
+
error: true,
|
|
1910
|
+
error_code: 401,
|
|
1911
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1774
1914
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
1775
1915
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1776
1916
|
}
|
|
@@ -1787,8 +1927,8 @@ class BaseService {
|
|
|
1787
1927
|
"X-Requested-With": userAgent
|
|
1788
1928
|
}
|
|
1789
1929
|
}));
|
|
1790
|
-
debugOutput(response.url, response.status, startTime);
|
|
1791
|
-
if (response.status === 429) {
|
|
1930
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1931
|
+
if (response.status === null || response.status === 429) {
|
|
1792
1932
|
try {
|
|
1793
1933
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1794
1934
|
}
|
|
@@ -1797,7 +1937,7 @@ class BaseService {
|
|
|
1797
1937
|
return {
|
|
1798
1938
|
data: null,
|
|
1799
1939
|
error: true,
|
|
1800
|
-
error_code: response.status,
|
|
1940
|
+
error_code: response.status ?? 429,
|
|
1801
1941
|
error_message: error.message
|
|
1802
1942
|
};
|
|
1803
1943
|
}
|
|
@@ -1848,6 +1988,14 @@ class BaseService {
|
|
|
1848
1988
|
while (!success) {
|
|
1849
1989
|
try {
|
|
1850
1990
|
const urlParams = new URLSearchParams();
|
|
1991
|
+
if (!this.is_key_valid) {
|
|
1992
|
+
return {
|
|
1993
|
+
data: null,
|
|
1994
|
+
error: true,
|
|
1995
|
+
error_code: 401,
|
|
1996
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1851
1999
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1852
2000
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1853
2001
|
}
|
|
@@ -1876,8 +2024,8 @@ class BaseService {
|
|
|
1876
2024
|
"X-Requested-With": userAgent
|
|
1877
2025
|
}
|
|
1878
2026
|
}));
|
|
1879
|
-
debugOutput(response.url, response.status, startTime);
|
|
1880
|
-
if (response.status === 429) {
|
|
2027
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2028
|
+
if (response.status === null || response.status === 429) {
|
|
1881
2029
|
try {
|
|
1882
2030
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1883
2031
|
}
|
|
@@ -1886,7 +2034,7 @@ class BaseService {
|
|
|
1886
2034
|
return {
|
|
1887
2035
|
data: null,
|
|
1888
2036
|
error: true,
|
|
1889
|
-
error_code: response.status,
|
|
2037
|
+
error_code: response.status ?? 429,
|
|
1890
2038
|
error_message: error.message
|
|
1891
2039
|
};
|
|
1892
2040
|
}
|
|
@@ -1934,6 +2082,9 @@ class BaseService {
|
|
|
1934
2082
|
while (!success) {
|
|
1935
2083
|
try {
|
|
1936
2084
|
const urlParams = new URLSearchParams();
|
|
2085
|
+
if (!this.is_key_valid) {
|
|
2086
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2087
|
+
}
|
|
1937
2088
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1938
2089
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1939
2090
|
}
|
|
@@ -1978,6 +2129,14 @@ class BaseService {
|
|
|
1978
2129
|
while (!success) {
|
|
1979
2130
|
try {
|
|
1980
2131
|
const urlParams = new URLSearchParams();
|
|
2132
|
+
if (!this.is_key_valid) {
|
|
2133
|
+
return {
|
|
2134
|
+
data: null,
|
|
2135
|
+
error: true,
|
|
2136
|
+
error_code: 401,
|
|
2137
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
1981
2140
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1982
2141
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1983
2142
|
}
|
|
@@ -2000,8 +2159,8 @@ class BaseService {
|
|
|
2000
2159
|
"X-Requested-With": userAgent
|
|
2001
2160
|
}
|
|
2002
2161
|
}));
|
|
2003
|
-
debugOutput(response.url, response.status, startTime);
|
|
2004
|
-
if (response.status === 429) {
|
|
2162
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2163
|
+
if (response.status === null || response.status === 429) {
|
|
2005
2164
|
try {
|
|
2006
2165
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2007
2166
|
}
|
|
@@ -2010,7 +2169,7 @@ class BaseService {
|
|
|
2010
2169
|
return {
|
|
2011
2170
|
data: null,
|
|
2012
2171
|
error: true,
|
|
2013
|
-
error_code: response.status,
|
|
2172
|
+
error_code: response.status ?? 429,
|
|
2014
2173
|
error_message: error.message
|
|
2015
2174
|
};
|
|
2016
2175
|
}
|
|
@@ -2059,6 +2218,9 @@ class BaseService {
|
|
|
2059
2218
|
while (!success) {
|
|
2060
2219
|
try {
|
|
2061
2220
|
const urlParams = new URLSearchParams();
|
|
2221
|
+
if (!this.is_key_valid) {
|
|
2222
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2223
|
+
}
|
|
2062
2224
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
2063
2225
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
2064
2226
|
}
|
|
@@ -2107,6 +2269,14 @@ class BaseService {
|
|
|
2107
2269
|
while (!success) {
|
|
2108
2270
|
try {
|
|
2109
2271
|
const urlParams = new URLSearchParams();
|
|
2272
|
+
if (!this.is_key_valid) {
|
|
2273
|
+
return {
|
|
2274
|
+
data: null,
|
|
2275
|
+
error: true,
|
|
2276
|
+
error_code: 401,
|
|
2277
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2110
2280
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
2111
2281
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
2112
2282
|
}
|
|
@@ -2132,8 +2302,8 @@ class BaseService {
|
|
|
2132
2302
|
"X-Requested-With": userAgent
|
|
2133
2303
|
}
|
|
2134
2304
|
}));
|
|
2135
|
-
debugOutput(response.url, response.status, startTime);
|
|
2136
|
-
if (response.status === 429) {
|
|
2305
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2306
|
+
if (response.status === null || response.status === 429) {
|
|
2137
2307
|
try {
|
|
2138
2308
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2139
2309
|
}
|
|
@@ -2142,7 +2312,7 @@ class BaseService {
|
|
|
2142
2312
|
return {
|
|
2143
2313
|
data: null,
|
|
2144
2314
|
error: true,
|
|
2145
|
-
error_code: response.status,
|
|
2315
|
+
error_code: response.status ?? 429,
|
|
2146
2316
|
error_message: error.message
|
|
2147
2317
|
};
|
|
2148
2318
|
}
|
|
@@ -2185,6 +2355,14 @@ class BaseService {
|
|
|
2185
2355
|
while (!success) {
|
|
2186
2356
|
try {
|
|
2187
2357
|
const urlParams = new URLSearchParams();
|
|
2358
|
+
if (!this.is_key_valid) {
|
|
2359
|
+
return {
|
|
2360
|
+
data: null,
|
|
2361
|
+
error: true,
|
|
2362
|
+
error_code: 401,
|
|
2363
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2188
2366
|
let startTime;
|
|
2189
2367
|
if (this.debug) {
|
|
2190
2368
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -2195,8 +2373,8 @@ class BaseService {
|
|
|
2195
2373
|
"X-Requested-With": userAgent
|
|
2196
2374
|
}
|
|
2197
2375
|
}));
|
|
2198
|
-
debugOutput(response.url, response.status, startTime);
|
|
2199
|
-
if (response.status === 429) {
|
|
2376
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2377
|
+
if (response.status === null || response.status === 429) {
|
|
2200
2378
|
try {
|
|
2201
2379
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2202
2380
|
}
|
|
@@ -2205,7 +2383,7 @@ class BaseService {
|
|
|
2205
2383
|
return {
|
|
2206
2384
|
data: null,
|
|
2207
2385
|
error: true,
|
|
2208
|
-
error_code: response.status,
|
|
2386
|
+
error_code: response.status ?? 429,
|
|
2209
2387
|
error_message: error.message
|
|
2210
2388
|
};
|
|
2211
2389
|
}
|
|
@@ -2248,6 +2426,14 @@ class BaseService {
|
|
|
2248
2426
|
while (!success) {
|
|
2249
2427
|
try {
|
|
2250
2428
|
const urlParams = new URLSearchParams();
|
|
2429
|
+
if (!this.is_key_valid) {
|
|
2430
|
+
return {
|
|
2431
|
+
data: null,
|
|
2432
|
+
error: true,
|
|
2433
|
+
error_code: 401,
|
|
2434
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2251
2437
|
let startTime;
|
|
2252
2438
|
if (this.debug) {
|
|
2253
2439
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -2258,8 +2444,8 @@ class BaseService {
|
|
|
2258
2444
|
"X-Requested-With": userAgent
|
|
2259
2445
|
}
|
|
2260
2446
|
}));
|
|
2261
|
-
debugOutput(response.url, response.status, startTime);
|
|
2262
|
-
if (response.status === 429) {
|
|
2447
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2448
|
+
if (response.status === null || response.status === 429) {
|
|
2263
2449
|
try {
|
|
2264
2450
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2265
2451
|
}
|
|
@@ -2268,7 +2454,7 @@ class BaseService {
|
|
|
2268
2454
|
return {
|
|
2269
2455
|
data: null,
|
|
2270
2456
|
error: true,
|
|
2271
|
-
error_code: response.status,
|
|
2457
|
+
error_code: response.status ?? 429,
|
|
2272
2458
|
error_message: error.message
|
|
2273
2459
|
};
|
|
2274
2460
|
}
|
|
@@ -2314,6 +2500,14 @@ class BaseService {
|
|
|
2314
2500
|
while (!success) {
|
|
2315
2501
|
try {
|
|
2316
2502
|
const urlParams = new URLSearchParams();
|
|
2503
|
+
if (!this.is_key_valid) {
|
|
2504
|
+
return {
|
|
2505
|
+
data: null,
|
|
2506
|
+
error: true,
|
|
2507
|
+
error_code: 401,
|
|
2508
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2317
2511
|
if (queryParamOpts?.testnets !== undefined) {
|
|
2318
2512
|
urlParams.append("testnets", queryParamOpts?.testnets.toString());
|
|
2319
2513
|
}
|
|
@@ -2327,6 +2521,82 @@ class BaseService {
|
|
|
2327
2521
|
"X-Requested-With": userAgent
|
|
2328
2522
|
}
|
|
2329
2523
|
}));
|
|
2524
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2525
|
+
if (response.status === null || response.status === 429) {
|
|
2526
|
+
try {
|
|
2527
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2528
|
+
}
|
|
2529
|
+
catch (error) {
|
|
2530
|
+
success = true;
|
|
2531
|
+
return {
|
|
2532
|
+
data: null,
|
|
2533
|
+
error: true,
|
|
2534
|
+
error_code: response.status ?? 429,
|
|
2535
|
+
error_message: error.message
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
else {
|
|
2540
|
+
data = await response.json();
|
|
2541
|
+
}
|
|
2542
|
+
const dataClass = new ChainActivityResponse(data.data);
|
|
2543
|
+
checkAndModifyResponse(dataClass);
|
|
2544
|
+
success = true;
|
|
2545
|
+
return {
|
|
2546
|
+
data: dataClass,
|
|
2547
|
+
error: data.error,
|
|
2548
|
+
error_code: data ? data.error_code : response.status,
|
|
2549
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
catch (error) {
|
|
2553
|
+
success = true;
|
|
2554
|
+
return {
|
|
2555
|
+
data: null,
|
|
2556
|
+
error: true,
|
|
2557
|
+
error_code: data ? data.error_code : response.status,
|
|
2558
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
*
|
|
2565
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2566
|
+
* @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
|
|
2567
|
+
* @param {GetGasPricesQueryParamOpts} queryParamOpts
|
|
2568
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2569
|
+
*
|
|
2570
|
+
*/
|
|
2571
|
+
async getGasPrices(chainName, eventType, queryParamOpts) {
|
|
2572
|
+
let success = false;
|
|
2573
|
+
let data;
|
|
2574
|
+
let response;
|
|
2575
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2576
|
+
while (!success) {
|
|
2577
|
+
try {
|
|
2578
|
+
const urlParams = new URLSearchParams();
|
|
2579
|
+
if (!this.is_key_valid) {
|
|
2580
|
+
return {
|
|
2581
|
+
data: null,
|
|
2582
|
+
error: true,
|
|
2583
|
+
error_code: 401,
|
|
2584
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
2588
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
2589
|
+
}
|
|
2590
|
+
let startTime;
|
|
2591
|
+
if (this.debug) {
|
|
2592
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2593
|
+
}
|
|
2594
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/event/${eventType}/gas_prices/?${urlParams}`, {
|
|
2595
|
+
headers: {
|
|
2596
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2597
|
+
"X-Requested-With": userAgent
|
|
2598
|
+
}
|
|
2599
|
+
}));
|
|
2330
2600
|
debugOutput(response.url, response.status, startTime);
|
|
2331
2601
|
if (response.status === 429) {
|
|
2332
2602
|
try {
|
|
@@ -2345,7 +2615,7 @@ class BaseService {
|
|
|
2345
2615
|
else {
|
|
2346
2616
|
data = await response.json();
|
|
2347
2617
|
}
|
|
2348
|
-
const dataClass = new
|
|
2618
|
+
const dataClass = new GasPricesResponse(data.data);
|
|
2349
2619
|
checkAndModifyResponse(dataClass);
|
|
2350
2620
|
success = true;
|
|
2351
2621
|
return {
|
|
@@ -2690,10 +2960,11 @@ class MarketFloorPriceItem {
|
|
|
2690
2960
|
*
|
|
2691
2961
|
*/
|
|
2692
2962
|
class NftService {
|
|
2693
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
2963
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
2694
2964
|
this.apiKey = apiKey;
|
|
2695
2965
|
this.debug = debug;
|
|
2696
2966
|
this.threadCount = threadCount;
|
|
2967
|
+
this.is_key_valid = is_key_valid;
|
|
2697
2968
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
2698
2969
|
}
|
|
2699
2970
|
/**
|
|
@@ -2713,6 +2984,9 @@ class NftService {
|
|
|
2713
2984
|
while (!success) {
|
|
2714
2985
|
try {
|
|
2715
2986
|
const urlParams = new URLSearchParams();
|
|
2987
|
+
if (!this.is_key_valid) {
|
|
2988
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2989
|
+
}
|
|
2716
2990
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
2717
2991
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2718
2992
|
}
|
|
@@ -2752,6 +3026,14 @@ class NftService {
|
|
|
2752
3026
|
while (!success) {
|
|
2753
3027
|
try {
|
|
2754
3028
|
const urlParams = new URLSearchParams();
|
|
3029
|
+
if (!this.is_key_valid) {
|
|
3030
|
+
return {
|
|
3031
|
+
data: null,
|
|
3032
|
+
error: true,
|
|
3033
|
+
error_code: 401,
|
|
3034
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
2755
3037
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
2756
3038
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2757
3039
|
}
|
|
@@ -2771,8 +3053,8 @@ class NftService {
|
|
|
2771
3053
|
"X-Requested-With": userAgent
|
|
2772
3054
|
}
|
|
2773
3055
|
}));
|
|
2774
|
-
debugOutput(response.url, response.status, startTime);
|
|
2775
|
-
if (response.status === 429) {
|
|
3056
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3057
|
+
if (response.status === null || response.status === 429) {
|
|
2776
3058
|
try {
|
|
2777
3059
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2778
3060
|
}
|
|
@@ -2781,7 +3063,7 @@ class NftService {
|
|
|
2781
3063
|
return {
|
|
2782
3064
|
data: null,
|
|
2783
3065
|
error: true,
|
|
2784
|
-
error_code: response.status,
|
|
3066
|
+
error_code: response.status ?? 429,
|
|
2785
3067
|
error_message: error.message
|
|
2786
3068
|
};
|
|
2787
3069
|
}
|
|
@@ -2830,6 +3112,14 @@ class NftService {
|
|
|
2830
3112
|
while (!success) {
|
|
2831
3113
|
try {
|
|
2832
3114
|
const urlParams = new URLSearchParams();
|
|
3115
|
+
if (!this.is_key_valid) {
|
|
3116
|
+
return {
|
|
3117
|
+
data: null,
|
|
3118
|
+
error: true,
|
|
3119
|
+
error_code: 401,
|
|
3120
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
2833
3123
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
2834
3124
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2835
3125
|
}
|
|
@@ -2849,8 +3139,8 @@ class NftService {
|
|
|
2849
3139
|
"X-Requested-With": userAgent
|
|
2850
3140
|
}
|
|
2851
3141
|
}));
|
|
2852
|
-
debugOutput(response.url, response.status, startTime);
|
|
2853
|
-
if (response.status === 429) {
|
|
3142
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3143
|
+
if (response.status === null || response.status === 429) {
|
|
2854
3144
|
try {
|
|
2855
3145
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2856
3146
|
}
|
|
@@ -2859,7 +3149,7 @@ class NftService {
|
|
|
2859
3149
|
return {
|
|
2860
3150
|
data: null,
|
|
2861
3151
|
error: true,
|
|
2862
|
-
error_code: response.status,
|
|
3152
|
+
error_code: response.status ?? 429,
|
|
2863
3153
|
error_message: error.message
|
|
2864
3154
|
};
|
|
2865
3155
|
}
|
|
@@ -2909,6 +3199,9 @@ class NftService {
|
|
|
2909
3199
|
while (!success) {
|
|
2910
3200
|
try {
|
|
2911
3201
|
const urlParams = new URLSearchParams();
|
|
3202
|
+
if (!this.is_key_valid) {
|
|
3203
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
3204
|
+
}
|
|
2912
3205
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2913
3206
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2914
3207
|
}
|
|
@@ -2961,6 +3254,14 @@ class NftService {
|
|
|
2961
3254
|
while (!success) {
|
|
2962
3255
|
try {
|
|
2963
3256
|
const urlParams = new URLSearchParams();
|
|
3257
|
+
if (!this.is_key_valid) {
|
|
3258
|
+
return {
|
|
3259
|
+
data: null,
|
|
3260
|
+
error: true,
|
|
3261
|
+
error_code: 401,
|
|
3262
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
2964
3265
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2965
3266
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2966
3267
|
}
|
|
@@ -2989,8 +3290,8 @@ class NftService {
|
|
|
2989
3290
|
"X-Requested-With": userAgent
|
|
2990
3291
|
}
|
|
2991
3292
|
}));
|
|
2992
|
-
debugOutput(response.url, response.status, startTime);
|
|
2993
|
-
if (response.status === 429) {
|
|
3293
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3294
|
+
if (response.status === null || response.status === 429) {
|
|
2994
3295
|
try {
|
|
2995
3296
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2996
3297
|
}
|
|
@@ -2999,7 +3300,7 @@ class NftService {
|
|
|
2999
3300
|
return {
|
|
3000
3301
|
data: null,
|
|
3001
3302
|
error: true,
|
|
3002
|
-
error_code: response.status,
|
|
3303
|
+
error_code: response.status ?? 429,
|
|
3003
3304
|
error_message: error.message
|
|
3004
3305
|
};
|
|
3005
3306
|
}
|
|
@@ -3048,6 +3349,14 @@ class NftService {
|
|
|
3048
3349
|
while (!success) {
|
|
3049
3350
|
try {
|
|
3050
3351
|
const urlParams = new URLSearchParams();
|
|
3352
|
+
if (!this.is_key_valid) {
|
|
3353
|
+
return {
|
|
3354
|
+
data: null,
|
|
3355
|
+
error: true,
|
|
3356
|
+
error_code: 401,
|
|
3357
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3051
3360
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
3052
3361
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
3053
3362
|
}
|
|
@@ -3064,8 +3373,8 @@ class NftService {
|
|
|
3064
3373
|
"X-Requested-With": userAgent
|
|
3065
3374
|
}
|
|
3066
3375
|
}));
|
|
3067
|
-
debugOutput(response.url, response.status, startTime);
|
|
3068
|
-
if (response.status === 429) {
|
|
3376
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3377
|
+
if (response.status === null || response.status === 429) {
|
|
3069
3378
|
try {
|
|
3070
3379
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3071
3380
|
}
|
|
@@ -3074,7 +3383,7 @@ class NftService {
|
|
|
3074
3383
|
return {
|
|
3075
3384
|
data: null,
|
|
3076
3385
|
error: true,
|
|
3077
|
-
error_code: response.status,
|
|
3386
|
+
error_code: response.status ?? 429,
|
|
3078
3387
|
error_message: error.message
|
|
3079
3388
|
};
|
|
3080
3389
|
}
|
|
@@ -3122,6 +3431,14 @@ class NftService {
|
|
|
3122
3431
|
while (!success) {
|
|
3123
3432
|
try {
|
|
3124
3433
|
const urlParams = new URLSearchParams();
|
|
3434
|
+
if (!this.is_key_valid) {
|
|
3435
|
+
return {
|
|
3436
|
+
data: null,
|
|
3437
|
+
error: true,
|
|
3438
|
+
error_code: 401,
|
|
3439
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3440
|
+
};
|
|
3441
|
+
}
|
|
3125
3442
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
3126
3443
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
3127
3444
|
}
|
|
@@ -3135,8 +3452,8 @@ class NftService {
|
|
|
3135
3452
|
"X-Requested-With": userAgent
|
|
3136
3453
|
}
|
|
3137
3454
|
}));
|
|
3138
|
-
debugOutput(response.url, response.status, startTime);
|
|
3139
|
-
if (response.status === 429) {
|
|
3455
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3456
|
+
if (response.status === null || response.status === 429) {
|
|
3140
3457
|
try {
|
|
3141
3458
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3142
3459
|
}
|
|
@@ -3145,7 +3462,7 @@ class NftService {
|
|
|
3145
3462
|
return {
|
|
3146
3463
|
data: null,
|
|
3147
3464
|
error: true,
|
|
3148
|
-
error_code: response.status,
|
|
3465
|
+
error_code: response.status ?? 429,
|
|
3149
3466
|
error_message: error.message
|
|
3150
3467
|
};
|
|
3151
3468
|
}
|
|
@@ -3190,6 +3507,14 @@ class NftService {
|
|
|
3190
3507
|
while (!success) {
|
|
3191
3508
|
try {
|
|
3192
3509
|
const urlParams = new URLSearchParams();
|
|
3510
|
+
if (!this.is_key_valid) {
|
|
3511
|
+
return {
|
|
3512
|
+
data: null,
|
|
3513
|
+
error: true,
|
|
3514
|
+
error_code: 401,
|
|
3515
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3193
3518
|
let startTime;
|
|
3194
3519
|
if (this.debug) {
|
|
3195
3520
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3200,8 +3525,8 @@ class NftService {
|
|
|
3200
3525
|
"X-Requested-With": userAgent
|
|
3201
3526
|
}
|
|
3202
3527
|
}));
|
|
3203
|
-
debugOutput(response.url, response.status, startTime);
|
|
3204
|
-
if (response.status === 429) {
|
|
3528
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3529
|
+
if (response.status === null || response.status === 429) {
|
|
3205
3530
|
try {
|
|
3206
3531
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3207
3532
|
}
|
|
@@ -3210,7 +3535,7 @@ class NftService {
|
|
|
3210
3535
|
return {
|
|
3211
3536
|
data: null,
|
|
3212
3537
|
error: true,
|
|
3213
|
-
error_code: response.status,
|
|
3538
|
+
error_code: response.status ?? 429,
|
|
3214
3539
|
error_message: error.message
|
|
3215
3540
|
};
|
|
3216
3541
|
}
|
|
@@ -3256,6 +3581,14 @@ class NftService {
|
|
|
3256
3581
|
while (!success) {
|
|
3257
3582
|
try {
|
|
3258
3583
|
const urlParams = new URLSearchParams();
|
|
3584
|
+
if (!this.is_key_valid) {
|
|
3585
|
+
return {
|
|
3586
|
+
data: null,
|
|
3587
|
+
error: true,
|
|
3588
|
+
error_code: 401,
|
|
3589
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3259
3592
|
let startTime;
|
|
3260
3593
|
if (this.debug) {
|
|
3261
3594
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3266,8 +3599,8 @@ class NftService {
|
|
|
3266
3599
|
"X-Requested-With": userAgent
|
|
3267
3600
|
}
|
|
3268
3601
|
}));
|
|
3269
|
-
debugOutput(response.url, response.status, startTime);
|
|
3270
|
-
if (response.status === 429) {
|
|
3602
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3603
|
+
if (response.status === null || response.status === 429) {
|
|
3271
3604
|
try {
|
|
3272
3605
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3273
3606
|
}
|
|
@@ -3276,7 +3609,7 @@ class NftService {
|
|
|
3276
3609
|
return {
|
|
3277
3610
|
data: null,
|
|
3278
3611
|
error: true,
|
|
3279
|
-
error_code: response.status,
|
|
3612
|
+
error_code: response.status ?? 429,
|
|
3280
3613
|
error_message: error.message
|
|
3281
3614
|
};
|
|
3282
3615
|
}
|
|
@@ -3321,6 +3654,14 @@ class NftService {
|
|
|
3321
3654
|
while (!success) {
|
|
3322
3655
|
try {
|
|
3323
3656
|
const urlParams = new URLSearchParams();
|
|
3657
|
+
if (!this.is_key_valid) {
|
|
3658
|
+
return {
|
|
3659
|
+
data: null,
|
|
3660
|
+
error: true,
|
|
3661
|
+
error_code: 401,
|
|
3662
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3663
|
+
};
|
|
3664
|
+
}
|
|
3324
3665
|
let startTime;
|
|
3325
3666
|
if (this.debug) {
|
|
3326
3667
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3331,8 +3672,8 @@ class NftService {
|
|
|
3331
3672
|
"X-Requested-With": userAgent
|
|
3332
3673
|
}
|
|
3333
3674
|
}));
|
|
3334
|
-
debugOutput(response.url, response.status, startTime);
|
|
3335
|
-
if (response.status === 429) {
|
|
3675
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3676
|
+
if (response.status === null || response.status === 429) {
|
|
3336
3677
|
try {
|
|
3337
3678
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3338
3679
|
}
|
|
@@ -3341,7 +3682,7 @@ class NftService {
|
|
|
3341
3682
|
return {
|
|
3342
3683
|
data: null,
|
|
3343
3684
|
error: true,
|
|
3344
|
-
error_code: response.status,
|
|
3685
|
+
error_code: response.status ?? 429,
|
|
3345
3686
|
error_message: error.message
|
|
3346
3687
|
};
|
|
3347
3688
|
}
|
|
@@ -3387,6 +3728,14 @@ class NftService {
|
|
|
3387
3728
|
while (!success) {
|
|
3388
3729
|
try {
|
|
3389
3730
|
const urlParams = new URLSearchParams();
|
|
3731
|
+
if (!this.is_key_valid) {
|
|
3732
|
+
return {
|
|
3733
|
+
data: null,
|
|
3734
|
+
error: true,
|
|
3735
|
+
error_code: 401,
|
|
3736
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3737
|
+
};
|
|
3738
|
+
}
|
|
3390
3739
|
let startTime;
|
|
3391
3740
|
if (this.debug) {
|
|
3392
3741
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3397,8 +3746,8 @@ class NftService {
|
|
|
3397
3746
|
"X-Requested-With": userAgent
|
|
3398
3747
|
}
|
|
3399
3748
|
}));
|
|
3400
|
-
debugOutput(response.url, response.status, startTime);
|
|
3401
|
-
if (response.status === 429) {
|
|
3749
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3750
|
+
if (response.status === null || response.status === 429) {
|
|
3402
3751
|
try {
|
|
3403
3752
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3404
3753
|
}
|
|
@@ -3407,7 +3756,7 @@ class NftService {
|
|
|
3407
3756
|
return {
|
|
3408
3757
|
data: null,
|
|
3409
3758
|
error: true,
|
|
3410
|
-
error_code: response.status,
|
|
3759
|
+
error_code: response.status ?? 429,
|
|
3411
3760
|
error_message: error.message
|
|
3412
3761
|
};
|
|
3413
3762
|
}
|
|
@@ -3454,6 +3803,14 @@ class NftService {
|
|
|
3454
3803
|
while (!success) {
|
|
3455
3804
|
try {
|
|
3456
3805
|
const urlParams = new URLSearchParams();
|
|
3806
|
+
if (!this.is_key_valid) {
|
|
3807
|
+
return {
|
|
3808
|
+
data: null,
|
|
3809
|
+
error: true,
|
|
3810
|
+
error_code: 401,
|
|
3811
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3457
3814
|
let startTime;
|
|
3458
3815
|
if (this.debug) {
|
|
3459
3816
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3464,8 +3821,8 @@ class NftService {
|
|
|
3464
3821
|
"X-Requested-With": userAgent
|
|
3465
3822
|
}
|
|
3466
3823
|
}));
|
|
3467
|
-
debugOutput(response.url, response.status, startTime);
|
|
3468
|
-
if (response.status === 429) {
|
|
3824
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3825
|
+
if (response.status === null || response.status === 429) {
|
|
3469
3826
|
try {
|
|
3470
3827
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3471
3828
|
}
|
|
@@ -3474,7 +3831,7 @@ class NftService {
|
|
|
3474
3831
|
return {
|
|
3475
3832
|
data: null,
|
|
3476
3833
|
error: true,
|
|
3477
|
-
error_code: response.status,
|
|
3834
|
+
error_code: response.status ?? 429,
|
|
3478
3835
|
error_message: error.message
|
|
3479
3836
|
};
|
|
3480
3837
|
}
|
|
@@ -3522,6 +3879,14 @@ class NftService {
|
|
|
3522
3879
|
while (!success) {
|
|
3523
3880
|
try {
|
|
3524
3881
|
const urlParams = new URLSearchParams();
|
|
3882
|
+
if (!this.is_key_valid) {
|
|
3883
|
+
return {
|
|
3884
|
+
data: null,
|
|
3885
|
+
error: true,
|
|
3886
|
+
error_code: 401,
|
|
3887
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3525
3890
|
if (queryParamOpts?.days !== undefined) {
|
|
3526
3891
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3527
3892
|
}
|
|
@@ -3538,8 +3903,8 @@ class NftService {
|
|
|
3538
3903
|
"X-Requested-With": userAgent
|
|
3539
3904
|
}
|
|
3540
3905
|
}));
|
|
3541
|
-
debugOutput(response.url, response.status, startTime);
|
|
3542
|
-
if (response.status === 429) {
|
|
3906
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3907
|
+
if (response.status === null || response.status === 429) {
|
|
3543
3908
|
try {
|
|
3544
3909
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3545
3910
|
}
|
|
@@ -3548,7 +3913,7 @@ class NftService {
|
|
|
3548
3913
|
return {
|
|
3549
3914
|
data: null,
|
|
3550
3915
|
error: true,
|
|
3551
|
-
error_code: response.status,
|
|
3916
|
+
error_code: response.status ?? 429,
|
|
3552
3917
|
error_message: error.message
|
|
3553
3918
|
};
|
|
3554
3919
|
}
|
|
@@ -3596,6 +3961,14 @@ class NftService {
|
|
|
3596
3961
|
while (!success) {
|
|
3597
3962
|
try {
|
|
3598
3963
|
const urlParams = new URLSearchParams();
|
|
3964
|
+
if (!this.is_key_valid) {
|
|
3965
|
+
return {
|
|
3966
|
+
data: null,
|
|
3967
|
+
error: true,
|
|
3968
|
+
error_code: 401,
|
|
3969
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3599
3972
|
if (queryParamOpts?.days !== undefined) {
|
|
3600
3973
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3601
3974
|
}
|
|
@@ -3612,8 +3985,8 @@ class NftService {
|
|
|
3612
3985
|
"X-Requested-With": userAgent
|
|
3613
3986
|
}
|
|
3614
3987
|
}));
|
|
3615
|
-
debugOutput(response.url, response.status, startTime);
|
|
3616
|
-
if (response.status === 429) {
|
|
3988
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3989
|
+
if (response.status === null || response.status === 429) {
|
|
3617
3990
|
try {
|
|
3618
3991
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3619
3992
|
}
|
|
@@ -3622,7 +3995,7 @@ class NftService {
|
|
|
3622
3995
|
return {
|
|
3623
3996
|
data: null,
|
|
3624
3997
|
error: true,
|
|
3625
|
-
error_code: response.status,
|
|
3998
|
+
error_code: response.status ?? 429,
|
|
3626
3999
|
error_message: error.message
|
|
3627
4000
|
};
|
|
3628
4001
|
}
|
|
@@ -3670,6 +4043,14 @@ class NftService {
|
|
|
3670
4043
|
while (!success) {
|
|
3671
4044
|
try {
|
|
3672
4045
|
const urlParams = new URLSearchParams();
|
|
4046
|
+
if (!this.is_key_valid) {
|
|
4047
|
+
return {
|
|
4048
|
+
data: null,
|
|
4049
|
+
error: true,
|
|
4050
|
+
error_code: 401,
|
|
4051
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4052
|
+
};
|
|
4053
|
+
}
|
|
3673
4054
|
if (queryParamOpts?.days !== undefined) {
|
|
3674
4055
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3675
4056
|
}
|
|
@@ -3686,8 +4067,8 @@ class NftService {
|
|
|
3686
4067
|
"X-Requested-With": userAgent
|
|
3687
4068
|
}
|
|
3688
4069
|
}));
|
|
3689
|
-
debugOutput(response.url, response.status, startTime);
|
|
3690
|
-
if (response.status === 429) {
|
|
4070
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4071
|
+
if (response.status === null || response.status === 429) {
|
|
3691
4072
|
try {
|
|
3692
4073
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3693
4074
|
}
|
|
@@ -3696,7 +4077,7 @@ class NftService {
|
|
|
3696
4077
|
return {
|
|
3697
4078
|
data: null,
|
|
3698
4079
|
error: true,
|
|
3699
|
-
error_code: response.status,
|
|
4080
|
+
error_code: response.status ?? 429,
|
|
3700
4081
|
error_message: error.message
|
|
3701
4082
|
};
|
|
3702
4083
|
}
|
|
@@ -3760,10 +4141,11 @@ let ContractMetadata$1 = class ContractMetadata {
|
|
|
3760
4141
|
}
|
|
3761
4142
|
};
|
|
3762
4143
|
class PricingService {
|
|
3763
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
4144
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
3764
4145
|
this.apiKey = apiKey;
|
|
3765
4146
|
this.debug = debug;
|
|
3766
4147
|
this.threadCount = threadCount;
|
|
4148
|
+
this.is_key_valid = is_key_valid;
|
|
3767
4149
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
3768
4150
|
}
|
|
3769
4151
|
/**
|
|
@@ -3787,6 +4169,14 @@ class PricingService {
|
|
|
3787
4169
|
while (!success) {
|
|
3788
4170
|
try {
|
|
3789
4171
|
const urlParams = new URLSearchParams();
|
|
4172
|
+
if (!this.is_key_valid) {
|
|
4173
|
+
return {
|
|
4174
|
+
data: null,
|
|
4175
|
+
error: true,
|
|
4176
|
+
error_code: 401,
|
|
4177
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4178
|
+
};
|
|
4179
|
+
}
|
|
3790
4180
|
if (queryParamOpts?.from !== undefined) {
|
|
3791
4181
|
urlParams.append("from", queryParamOpts?.from.toString());
|
|
3792
4182
|
}
|
|
@@ -3806,8 +4196,8 @@ class PricingService {
|
|
|
3806
4196
|
"X-Requested-With": userAgent
|
|
3807
4197
|
}
|
|
3808
4198
|
}));
|
|
3809
|
-
debugOutput(response.url, response.status, startTime);
|
|
3810
|
-
if (response.status === 429) {
|
|
4199
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4200
|
+
if (response.status === null || response.status === 429) {
|
|
3811
4201
|
try {
|
|
3812
4202
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3813
4203
|
}
|
|
@@ -3816,7 +4206,7 @@ class PricingService {
|
|
|
3816
4206
|
return {
|
|
3817
4207
|
data: null,
|
|
3818
4208
|
error: true,
|
|
3819
|
-
error_code: response.status,
|
|
4209
|
+
error_code: response.status ?? 429,
|
|
3820
4210
|
error_message: error.message
|
|
3821
4211
|
};
|
|
3822
4212
|
}
|
|
@@ -3884,9 +4274,9 @@ class Transaction {
|
|
|
3884
4274
|
this.gas_quote_rate = data.gas_quote_rate;
|
|
3885
4275
|
this.gas_metadata = data.gas_metadata && data.gas_metadata !== null ? new ContractMetadata(data.gas_metadata) : null;
|
|
3886
4276
|
this.explorers = data.explorers && data.explorers !== null ? data.explorers.map((itemData) => new Explorer(itemData)) : null;
|
|
3887
|
-
this.dex_details = data.dex_details && data.dex_details !== null ? new DexReport(
|
|
3888
|
-
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? new NftSalesReport(
|
|
3889
|
-
this.lending_details = data.lending_details && data.lending_details !== null ? new LendingReport(
|
|
4277
|
+
this.dex_details = data.dex_details && data.dex_details !== null ? data.dex_details.map((itemData) => new DexReport(itemData)) : null;
|
|
4278
|
+
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? data.nft_sale_details.map((itemData) => new NftSalesReport(itemData)) : null;
|
|
4279
|
+
this.lending_details = data.lending_details && data.lending_details !== null ? data.lending_details.map((itemData) => new LendingReport(itemData)) : null;
|
|
3890
4280
|
this.log_events = data.log_events && data.log_events !== null ? data.log_events.map((itemData) => new LogEvent(itemData)) : null;
|
|
3891
4281
|
this.safe_details = data.safe_details && data.safe_details !== null ? data.safe_details.map((itemData) => new SafeDetails(itemData)) : null;
|
|
3892
4282
|
}
|
|
@@ -4106,8 +4496,8 @@ class RecentTransactionsResponse {
|
|
|
4106
4496
|
"X-Requested-With": userAgent
|
|
4107
4497
|
}
|
|
4108
4498
|
}));
|
|
4109
|
-
debugOutput(response.url, response.status, startTime);
|
|
4110
|
-
if (response.status === 429) {
|
|
4499
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4500
|
+
if (response.status === null || response.status === 429) {
|
|
4111
4501
|
try {
|
|
4112
4502
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4113
4503
|
}
|
|
@@ -4116,7 +4506,7 @@ class RecentTransactionsResponse {
|
|
|
4116
4506
|
return {
|
|
4117
4507
|
data: null,
|
|
4118
4508
|
error: true,
|
|
4119
|
-
error_code: response.status,
|
|
4509
|
+
error_code: response.status ?? 429,
|
|
4120
4510
|
error_message: error.message
|
|
4121
4511
|
};
|
|
4122
4512
|
}
|
|
@@ -4172,8 +4562,8 @@ class RecentTransactionsResponse {
|
|
|
4172
4562
|
"X-Requested-With": userAgent
|
|
4173
4563
|
}
|
|
4174
4564
|
}));
|
|
4175
|
-
debugOutput(response.url, response.status, startTime);
|
|
4176
|
-
if (response.status === 429) {
|
|
4565
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4566
|
+
if (response.status === null || response.status === 429) {
|
|
4177
4567
|
try {
|
|
4178
4568
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4179
4569
|
}
|
|
@@ -4182,7 +4572,7 @@ class RecentTransactionsResponse {
|
|
|
4182
4572
|
return {
|
|
4183
4573
|
data: null,
|
|
4184
4574
|
error: true,
|
|
4185
|
-
error_code: response.status,
|
|
4575
|
+
error_code: response.status ?? 429,
|
|
4186
4576
|
error_message: error.message
|
|
4187
4577
|
};
|
|
4188
4578
|
}
|
|
@@ -4291,8 +4681,8 @@ class TransactionsResponse {
|
|
|
4291
4681
|
"X-Requested-With": userAgent
|
|
4292
4682
|
}
|
|
4293
4683
|
}));
|
|
4294
|
-
debugOutput(response.url, response.status, startTime);
|
|
4295
|
-
if (response.status === 429) {
|
|
4684
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4685
|
+
if (response.status === null || response.status === 429) {
|
|
4296
4686
|
try {
|
|
4297
4687
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4298
4688
|
}
|
|
@@ -4301,7 +4691,7 @@ class TransactionsResponse {
|
|
|
4301
4691
|
return {
|
|
4302
4692
|
data: null,
|
|
4303
4693
|
error: true,
|
|
4304
|
-
error_code: response.status,
|
|
4694
|
+
error_code: response.status ?? 429,
|
|
4305
4695
|
error_message: error.message
|
|
4306
4696
|
};
|
|
4307
4697
|
}
|
|
@@ -4357,8 +4747,8 @@ class TransactionsResponse {
|
|
|
4357
4747
|
"X-Requested-With": userAgent
|
|
4358
4748
|
}
|
|
4359
4749
|
}));
|
|
4360
|
-
debugOutput(response.url, response.status, startTime);
|
|
4361
|
-
if (response.status === 429) {
|
|
4750
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4751
|
+
if (response.status === null || response.status === 429) {
|
|
4362
4752
|
try {
|
|
4363
4753
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4364
4754
|
}
|
|
@@ -4367,7 +4757,7 @@ class TransactionsResponse {
|
|
|
4367
4757
|
return {
|
|
4368
4758
|
data: null,
|
|
4369
4759
|
error: true,
|
|
4370
|
-
error_code: response.status,
|
|
4760
|
+
error_code: response.status ?? 429,
|
|
4371
4761
|
error_message: error.message
|
|
4372
4762
|
};
|
|
4373
4763
|
}
|
|
@@ -4419,8 +4809,8 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
4419
4809
|
"X-Requested-With": userAgent
|
|
4420
4810
|
}
|
|
4421
4811
|
}));
|
|
4422
|
-
debugOutput(response.url, response.status, startTime);
|
|
4423
|
-
if (response.status === 429) {
|
|
4812
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4813
|
+
if (response.status === null || response.status === 429) {
|
|
4424
4814
|
try {
|
|
4425
4815
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4426
4816
|
}
|
|
@@ -4458,10 +4848,11 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
4458
4848
|
}
|
|
4459
4849
|
}
|
|
4460
4850
|
class TransactionService {
|
|
4461
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
4851
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
4462
4852
|
this.apiKey = apiKey;
|
|
4463
4853
|
this.debug = debug;
|
|
4464
4854
|
this.threadCount = threadCount;
|
|
4855
|
+
this.is_key_valid = is_key_valid;
|
|
4465
4856
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
4466
4857
|
}
|
|
4467
4858
|
/**
|
|
@@ -4487,6 +4878,14 @@ class TransactionService {
|
|
|
4487
4878
|
while (!success) {
|
|
4488
4879
|
try {
|
|
4489
4880
|
const urlParams = new URLSearchParams();
|
|
4881
|
+
if (!this.is_key_valid) {
|
|
4882
|
+
return {
|
|
4883
|
+
data: null,
|
|
4884
|
+
error: true,
|
|
4885
|
+
error_code: 401,
|
|
4886
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4887
|
+
};
|
|
4888
|
+
}
|
|
4490
4889
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4491
4890
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4492
4891
|
}
|
|
@@ -4515,8 +4914,8 @@ class TransactionService {
|
|
|
4515
4914
|
"X-Requested-With": userAgent
|
|
4516
4915
|
}
|
|
4517
4916
|
}));
|
|
4518
|
-
debugOutput(response.url, response.status, startTime);
|
|
4519
|
-
if (response.status === 429) {
|
|
4917
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4918
|
+
if (response.status === null || response.status === 429) {
|
|
4520
4919
|
try {
|
|
4521
4920
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4522
4921
|
}
|
|
@@ -4525,7 +4924,7 @@ class TransactionService {
|
|
|
4525
4924
|
return {
|
|
4526
4925
|
data: null,
|
|
4527
4926
|
error: true,
|
|
4528
|
-
error_code: response.status,
|
|
4927
|
+
error_code: response.status ?? 429,
|
|
4529
4928
|
error_message: error.message
|
|
4530
4929
|
};
|
|
4531
4930
|
}
|
|
@@ -4573,6 +4972,9 @@ class TransactionService {
|
|
|
4573
4972
|
while (!success) {
|
|
4574
4973
|
try {
|
|
4575
4974
|
const urlParams = new URLSearchParams();
|
|
4975
|
+
if (!this.is_key_valid) {
|
|
4976
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
4977
|
+
}
|
|
4576
4978
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4577
4979
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4578
4980
|
}
|
|
@@ -4617,6 +5019,14 @@ class TransactionService {
|
|
|
4617
5019
|
while (!success) {
|
|
4618
5020
|
try {
|
|
4619
5021
|
const urlParams = new URLSearchParams();
|
|
5022
|
+
if (!this.is_key_valid) {
|
|
5023
|
+
return {
|
|
5024
|
+
data: null,
|
|
5025
|
+
error: true,
|
|
5026
|
+
error_code: 401,
|
|
5027
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
4620
5030
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4621
5031
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4622
5032
|
}
|
|
@@ -4639,8 +5049,8 @@ class TransactionService {
|
|
|
4639
5049
|
"X-Requested-With": userAgent
|
|
4640
5050
|
}
|
|
4641
5051
|
}));
|
|
4642
|
-
debugOutput(response.url, response.status, startTime);
|
|
4643
|
-
if (response.status === 429) {
|
|
5052
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5053
|
+
if (response.status === null || response.status === 429) {
|
|
4644
5054
|
try {
|
|
4645
5055
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4646
5056
|
}
|
|
@@ -4649,7 +5059,7 @@ class TransactionService {
|
|
|
4649
5059
|
return {
|
|
4650
5060
|
data: null,
|
|
4651
5061
|
error: true,
|
|
4652
|
-
error_code: response.status,
|
|
5062
|
+
error_code: response.status ?? 429,
|
|
4653
5063
|
error_message: error.message
|
|
4654
5064
|
};
|
|
4655
5065
|
}
|
|
@@ -4698,6 +5108,14 @@ class TransactionService {
|
|
|
4698
5108
|
while (!success) {
|
|
4699
5109
|
try {
|
|
4700
5110
|
const urlParams = new URLSearchParams();
|
|
5111
|
+
if (!this.is_key_valid) {
|
|
5112
|
+
return {
|
|
5113
|
+
data: null,
|
|
5114
|
+
error: true,
|
|
5115
|
+
error_code: 401,
|
|
5116
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
4701
5119
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4702
5120
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4703
5121
|
}
|
|
@@ -4717,8 +5135,8 @@ class TransactionService {
|
|
|
4717
5135
|
"X-Requested-With": userAgent
|
|
4718
5136
|
}
|
|
4719
5137
|
}));
|
|
4720
|
-
debugOutput(response.url, response.status, startTime);
|
|
4721
|
-
if (response.status === 429) {
|
|
5138
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5139
|
+
if (response.status === null || response.status === 429) {
|
|
4722
5140
|
try {
|
|
4723
5141
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4724
5142
|
}
|
|
@@ -4727,7 +5145,7 @@ class TransactionService {
|
|
|
4727
5145
|
return {
|
|
4728
5146
|
data: null,
|
|
4729
5147
|
error: true,
|
|
4730
|
-
error_code: response.status,
|
|
5148
|
+
error_code: response.status ?? 429,
|
|
4731
5149
|
error_message: error.message
|
|
4732
5150
|
};
|
|
4733
5151
|
}
|
|
@@ -4772,6 +5190,14 @@ class TransactionService {
|
|
|
4772
5190
|
while (!success) {
|
|
4773
5191
|
try {
|
|
4774
5192
|
const urlParams = new URLSearchParams();
|
|
5193
|
+
if (!this.is_key_valid) {
|
|
5194
|
+
return {
|
|
5195
|
+
data: null,
|
|
5196
|
+
error: true,
|
|
5197
|
+
error_code: 401,
|
|
5198
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5199
|
+
};
|
|
5200
|
+
}
|
|
4775
5201
|
let startTime;
|
|
4776
5202
|
if (this.debug) {
|
|
4777
5203
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -4782,8 +5208,8 @@ class TransactionService {
|
|
|
4782
5208
|
"X-Requested-With": userAgent
|
|
4783
5209
|
}
|
|
4784
5210
|
}));
|
|
4785
|
-
debugOutput(response.url, response.status, startTime);
|
|
4786
|
-
if (response.status === 429) {
|
|
5211
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5212
|
+
if (response.status === null || response.status === 429) {
|
|
4787
5213
|
try {
|
|
4788
5214
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4789
5215
|
}
|
|
@@ -4792,7 +5218,7 @@ class TransactionService {
|
|
|
4792
5218
|
return {
|
|
4793
5219
|
data: null,
|
|
4794
5220
|
error: true,
|
|
4795
|
-
error_code: response.status,
|
|
5221
|
+
error_code: response.status ?? 429,
|
|
4796
5222
|
error_message: error.message
|
|
4797
5223
|
};
|
|
4798
5224
|
}
|
|
@@ -4841,6 +5267,14 @@ class TransactionService {
|
|
|
4841
5267
|
while (!success) {
|
|
4842
5268
|
try {
|
|
4843
5269
|
const urlParams = new URLSearchParams();
|
|
5270
|
+
if (!this.is_key_valid) {
|
|
5271
|
+
return {
|
|
5272
|
+
data: null,
|
|
5273
|
+
error: true,
|
|
5274
|
+
error_code: 401,
|
|
5275
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5276
|
+
};
|
|
5277
|
+
}
|
|
4844
5278
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4845
5279
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4846
5280
|
}
|
|
@@ -4863,8 +5297,8 @@ class TransactionService {
|
|
|
4863
5297
|
"X-Requested-With": userAgent
|
|
4864
5298
|
}
|
|
4865
5299
|
});
|
|
4866
|
-
debugOutput(response.url, response.status, startTime);
|
|
4867
|
-
if (response.status === 429) {
|
|
5300
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5301
|
+
if (response.status === null || response.status === 429) {
|
|
4868
5302
|
try {
|
|
4869
5303
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4870
5304
|
}
|
|
@@ -4873,7 +5307,7 @@ class TransactionService {
|
|
|
4873
5307
|
return {
|
|
4874
5308
|
data: null,
|
|
4875
5309
|
error: true,
|
|
4876
|
-
error_code: response.status,
|
|
5310
|
+
error_code: response.status ?? 429,
|
|
4877
5311
|
error_message: error.message
|
|
4878
5312
|
};
|
|
4879
5313
|
}
|
|
@@ -5302,10 +5736,11 @@ class HealthData {
|
|
|
5302
5736
|
*
|
|
5303
5737
|
*/
|
|
5304
5738
|
class XykService {
|
|
5305
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
5739
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
5306
5740
|
this.apiKey = apiKey;
|
|
5307
5741
|
this.debug = debug;
|
|
5308
5742
|
this.threadCount = threadCount;
|
|
5743
|
+
this.is_key_valid = is_key_valid;
|
|
5309
5744
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
5310
5745
|
}
|
|
5311
5746
|
/**
|
|
@@ -5324,6 +5759,14 @@ class XykService {
|
|
|
5324
5759
|
while (!success) {
|
|
5325
5760
|
try {
|
|
5326
5761
|
const urlParams = new URLSearchParams();
|
|
5762
|
+
if (!this.is_key_valid) {
|
|
5763
|
+
return {
|
|
5764
|
+
data: null,
|
|
5765
|
+
error: true,
|
|
5766
|
+
error_code: 401,
|
|
5767
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5768
|
+
};
|
|
5769
|
+
}
|
|
5327
5770
|
let startTime;
|
|
5328
5771
|
if (this.debug) {
|
|
5329
5772
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5334,8 +5777,8 @@ class XykService {
|
|
|
5334
5777
|
"X-Requested-With": userAgent
|
|
5335
5778
|
}
|
|
5336
5779
|
}));
|
|
5337
|
-
debugOutput(response.url, response.status, startTime);
|
|
5338
|
-
if (response.status === 429) {
|
|
5780
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5781
|
+
if (response.status === null || response.status === 429) {
|
|
5339
5782
|
try {
|
|
5340
5783
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5341
5784
|
}
|
|
@@ -5344,7 +5787,7 @@ class XykService {
|
|
|
5344
5787
|
return {
|
|
5345
5788
|
data: null,
|
|
5346
5789
|
error: true,
|
|
5347
|
-
error_code: response.status,
|
|
5790
|
+
error_code: response.status ?? 429,
|
|
5348
5791
|
error_message: error.message
|
|
5349
5792
|
};
|
|
5350
5793
|
}
|
|
@@ -5389,6 +5832,14 @@ class XykService {
|
|
|
5389
5832
|
while (!success) {
|
|
5390
5833
|
try {
|
|
5391
5834
|
const urlParams = new URLSearchParams();
|
|
5835
|
+
if (!this.is_key_valid) {
|
|
5836
|
+
return {
|
|
5837
|
+
data: null,
|
|
5838
|
+
error: true,
|
|
5839
|
+
error_code: 401,
|
|
5840
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5392
5843
|
let startTime;
|
|
5393
5844
|
if (this.debug) {
|
|
5394
5845
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5399,8 +5850,8 @@ class XykService {
|
|
|
5399
5850
|
"X-Requested-With": userAgent
|
|
5400
5851
|
}
|
|
5401
5852
|
}));
|
|
5402
|
-
debugOutput(response.url, response.status, startTime);
|
|
5403
|
-
if (response.status === 429) {
|
|
5853
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5854
|
+
if (response.status === null || response.status === 429) {
|
|
5404
5855
|
try {
|
|
5405
5856
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5406
5857
|
}
|
|
@@ -5409,7 +5860,7 @@ class XykService {
|
|
|
5409
5860
|
return {
|
|
5410
5861
|
data: null,
|
|
5411
5862
|
error: true,
|
|
5412
|
-
error_code: response.status,
|
|
5863
|
+
error_code: response.status ?? 429,
|
|
5413
5864
|
error_message: error.message
|
|
5414
5865
|
};
|
|
5415
5866
|
}
|
|
@@ -5455,6 +5906,14 @@ class XykService {
|
|
|
5455
5906
|
while (!success) {
|
|
5456
5907
|
try {
|
|
5457
5908
|
const urlParams = new URLSearchParams();
|
|
5909
|
+
if (!this.is_key_valid) {
|
|
5910
|
+
return {
|
|
5911
|
+
data: null,
|
|
5912
|
+
error: true,
|
|
5913
|
+
error_code: 401,
|
|
5914
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5915
|
+
};
|
|
5916
|
+
}
|
|
5458
5917
|
let startTime;
|
|
5459
5918
|
if (this.debug) {
|
|
5460
5919
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5465,8 +5924,8 @@ class XykService {
|
|
|
5465
5924
|
"X-Requested-With": userAgent
|
|
5466
5925
|
}
|
|
5467
5926
|
}));
|
|
5468
|
-
debugOutput(response.url, response.status, startTime);
|
|
5469
|
-
if (response.status === 429) {
|
|
5927
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5928
|
+
if (response.status === null || response.status === 429) {
|
|
5470
5929
|
try {
|
|
5471
5930
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5472
5931
|
}
|
|
@@ -5475,7 +5934,7 @@ class XykService {
|
|
|
5475
5934
|
return {
|
|
5476
5935
|
data: null,
|
|
5477
5936
|
error: true,
|
|
5478
|
-
error_code: response.status,
|
|
5937
|
+
error_code: response.status ?? 429,
|
|
5479
5938
|
error_message: error.message
|
|
5480
5939
|
};
|
|
5481
5940
|
}
|
|
@@ -5523,6 +5982,14 @@ class XykService {
|
|
|
5523
5982
|
while (!success) {
|
|
5524
5983
|
try {
|
|
5525
5984
|
const urlParams = new URLSearchParams();
|
|
5985
|
+
if (!this.is_key_valid) {
|
|
5986
|
+
return {
|
|
5987
|
+
data: null,
|
|
5988
|
+
error: true,
|
|
5989
|
+
error_code: 401,
|
|
5990
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5991
|
+
};
|
|
5992
|
+
}
|
|
5526
5993
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
5527
5994
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
5528
5995
|
}
|
|
@@ -5539,8 +6006,8 @@ class XykService {
|
|
|
5539
6006
|
"X-Requested-With": userAgent
|
|
5540
6007
|
}
|
|
5541
6008
|
}));
|
|
5542
|
-
debugOutput(response.url, response.status, startTime);
|
|
5543
|
-
if (response.status === 429) {
|
|
6009
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6010
|
+
if (response.status === null || response.status === 429) {
|
|
5544
6011
|
try {
|
|
5545
6012
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5546
6013
|
}
|
|
@@ -5549,7 +6016,7 @@ class XykService {
|
|
|
5549
6016
|
return {
|
|
5550
6017
|
data: null,
|
|
5551
6018
|
error: true,
|
|
5552
|
-
error_code: response.status,
|
|
6019
|
+
error_code: response.status ?? 429,
|
|
5553
6020
|
error_message: error.message
|
|
5554
6021
|
};
|
|
5555
6022
|
}
|
|
@@ -5595,6 +6062,14 @@ class XykService {
|
|
|
5595
6062
|
while (!success) {
|
|
5596
6063
|
try {
|
|
5597
6064
|
const urlParams = new URLSearchParams();
|
|
6065
|
+
if (!this.is_key_valid) {
|
|
6066
|
+
return {
|
|
6067
|
+
data: null,
|
|
6068
|
+
error: true,
|
|
6069
|
+
error_code: 401,
|
|
6070
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6071
|
+
};
|
|
6072
|
+
}
|
|
5598
6073
|
let startTime;
|
|
5599
6074
|
if (this.debug) {
|
|
5600
6075
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5605,8 +6080,8 @@ class XykService {
|
|
|
5605
6080
|
"X-Requested-With": userAgent
|
|
5606
6081
|
}
|
|
5607
6082
|
}));
|
|
5608
|
-
debugOutput(response.url, response.status, startTime);
|
|
5609
|
-
if (response.status === 429) {
|
|
6083
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6084
|
+
if (response.status === null || response.status === 429) {
|
|
5610
6085
|
try {
|
|
5611
6086
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5612
6087
|
}
|
|
@@ -5615,7 +6090,7 @@ class XykService {
|
|
|
5615
6090
|
return {
|
|
5616
6091
|
data: null,
|
|
5617
6092
|
error: true,
|
|
5618
|
-
error_code: response.status,
|
|
6093
|
+
error_code: response.status ?? 429,
|
|
5619
6094
|
error_message: error.message
|
|
5620
6095
|
};
|
|
5621
6096
|
}
|
|
@@ -5664,6 +6139,14 @@ class XykService {
|
|
|
5664
6139
|
while (!success) {
|
|
5665
6140
|
try {
|
|
5666
6141
|
const urlParams = new URLSearchParams();
|
|
6142
|
+
if (!this.is_key_valid) {
|
|
6143
|
+
return {
|
|
6144
|
+
data: null,
|
|
6145
|
+
error: true,
|
|
6146
|
+
error_code: 401,
|
|
6147
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6148
|
+
};
|
|
6149
|
+
}
|
|
5667
6150
|
if (queryParamOpts?.tokenAddress !== undefined) {
|
|
5668
6151
|
urlParams.append("token-address", queryParamOpts?.tokenAddress.toString());
|
|
5669
6152
|
}
|
|
@@ -5683,8 +6166,8 @@ class XykService {
|
|
|
5683
6166
|
"X-Requested-With": userAgent
|
|
5684
6167
|
}
|
|
5685
6168
|
}));
|
|
5686
|
-
debugOutput(response.url, response.status, startTime);
|
|
5687
|
-
if (response.status === 429) {
|
|
6169
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6170
|
+
if (response.status === null || response.status === 429) {
|
|
5688
6171
|
try {
|
|
5689
6172
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5690
6173
|
}
|
|
@@ -5693,7 +6176,7 @@ class XykService {
|
|
|
5693
6176
|
return {
|
|
5694
6177
|
data: null,
|
|
5695
6178
|
error: true,
|
|
5696
|
-
error_code: response.status,
|
|
6179
|
+
error_code: response.status ?? 429,
|
|
5697
6180
|
error_message: error.message
|
|
5698
6181
|
};
|
|
5699
6182
|
}
|
|
@@ -5738,6 +6221,14 @@ class XykService {
|
|
|
5738
6221
|
while (!success) {
|
|
5739
6222
|
try {
|
|
5740
6223
|
const urlParams = new URLSearchParams();
|
|
6224
|
+
if (!this.is_key_valid) {
|
|
6225
|
+
return {
|
|
6226
|
+
data: null,
|
|
6227
|
+
error: true,
|
|
6228
|
+
error_code: 401,
|
|
6229
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6230
|
+
};
|
|
6231
|
+
}
|
|
5741
6232
|
let startTime;
|
|
5742
6233
|
if (this.debug) {
|
|
5743
6234
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5748,8 +6239,8 @@ class XykService {
|
|
|
5748
6239
|
"X-Requested-With": userAgent
|
|
5749
6240
|
}
|
|
5750
6241
|
}));
|
|
5751
|
-
debugOutput(response.url, response.status, startTime);
|
|
5752
|
-
if (response.status === 429) {
|
|
6242
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6243
|
+
if (response.status === null || response.status === 429) {
|
|
5753
6244
|
try {
|
|
5754
6245
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5755
6246
|
}
|
|
@@ -5758,7 +6249,7 @@ class XykService {
|
|
|
5758
6249
|
return {
|
|
5759
6250
|
data: null,
|
|
5760
6251
|
error: true,
|
|
5761
|
-
error_code: response.status,
|
|
6252
|
+
error_code: response.status ?? 429,
|
|
5762
6253
|
error_message: error.message
|
|
5763
6254
|
};
|
|
5764
6255
|
}
|
|
@@ -5801,6 +6292,14 @@ class XykService {
|
|
|
5801
6292
|
while (!success) {
|
|
5802
6293
|
try {
|
|
5803
6294
|
const urlParams = new URLSearchParams();
|
|
6295
|
+
if (!this.is_key_valid) {
|
|
6296
|
+
return {
|
|
6297
|
+
data: null,
|
|
6298
|
+
error: true,
|
|
6299
|
+
error_code: 401,
|
|
6300
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6301
|
+
};
|
|
6302
|
+
}
|
|
5804
6303
|
let startTime;
|
|
5805
6304
|
if (this.debug) {
|
|
5806
6305
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5811,8 +6310,8 @@ class XykService {
|
|
|
5811
6310
|
"X-Requested-With": userAgent
|
|
5812
6311
|
}
|
|
5813
6312
|
}));
|
|
5814
|
-
debugOutput(response.url, response.status, startTime);
|
|
5815
|
-
if (response.status === 429) {
|
|
6313
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6314
|
+
if (response.status === null || response.status === 429) {
|
|
5816
6315
|
try {
|
|
5817
6316
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5818
6317
|
}
|
|
@@ -5821,7 +6320,7 @@ class XykService {
|
|
|
5821
6320
|
return {
|
|
5822
6321
|
data: null,
|
|
5823
6322
|
error: true,
|
|
5824
|
-
error_code: response.status,
|
|
6323
|
+
error_code: response.status ?? 429,
|
|
5825
6324
|
error_message: error.message
|
|
5826
6325
|
};
|
|
5827
6326
|
}
|
|
@@ -5867,6 +6366,14 @@ class XykService {
|
|
|
5867
6366
|
while (!success) {
|
|
5868
6367
|
try {
|
|
5869
6368
|
const urlParams = new URLSearchParams();
|
|
6369
|
+
if (!this.is_key_valid) {
|
|
6370
|
+
return {
|
|
6371
|
+
data: null,
|
|
6372
|
+
error: true,
|
|
6373
|
+
error_code: 401,
|
|
6374
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6375
|
+
};
|
|
6376
|
+
}
|
|
5870
6377
|
let startTime;
|
|
5871
6378
|
if (this.debug) {
|
|
5872
6379
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5877,8 +6384,8 @@ class XykService {
|
|
|
5877
6384
|
"X-Requested-With": userAgent
|
|
5878
6385
|
}
|
|
5879
6386
|
}));
|
|
5880
|
-
debugOutput(response.url, response.status, startTime);
|
|
5881
|
-
if (response.status === 429) {
|
|
6387
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6388
|
+
if (response.status === null || response.status === 429) {
|
|
5882
6389
|
try {
|
|
5883
6390
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5884
6391
|
}
|
|
@@ -5887,7 +6394,7 @@ class XykService {
|
|
|
5887
6394
|
return {
|
|
5888
6395
|
data: null,
|
|
5889
6396
|
error: true,
|
|
5890
|
-
error_code: response.status,
|
|
6397
|
+
error_code: response.status ?? 429,
|
|
5891
6398
|
error_message: error.message
|
|
5892
6399
|
};
|
|
5893
6400
|
}
|
|
@@ -5933,6 +6440,14 @@ class XykService {
|
|
|
5933
6440
|
while (!success) {
|
|
5934
6441
|
try {
|
|
5935
6442
|
const urlParams = new URLSearchParams();
|
|
6443
|
+
if (!this.is_key_valid) {
|
|
6444
|
+
return {
|
|
6445
|
+
data: null,
|
|
6446
|
+
error: true,
|
|
6447
|
+
error_code: 401,
|
|
6448
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6449
|
+
};
|
|
6450
|
+
}
|
|
5936
6451
|
let startTime;
|
|
5937
6452
|
if (this.debug) {
|
|
5938
6453
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5943,8 +6458,8 @@ class XykService {
|
|
|
5943
6458
|
"X-Requested-With": userAgent
|
|
5944
6459
|
}
|
|
5945
6460
|
}));
|
|
5946
|
-
debugOutput(response.url, response.status, startTime);
|
|
5947
|
-
if (response.status === 429) {
|
|
6461
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6462
|
+
if (response.status === null || response.status === 429) {
|
|
5948
6463
|
try {
|
|
5949
6464
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5950
6465
|
}
|
|
@@ -5953,7 +6468,7 @@ class XykService {
|
|
|
5953
6468
|
return {
|
|
5954
6469
|
data: null,
|
|
5955
6470
|
error: true,
|
|
5956
|
-
error_code: response.status,
|
|
6471
|
+
error_code: response.status ?? 429,
|
|
5957
6472
|
error_message: error.message
|
|
5958
6473
|
};
|
|
5959
6474
|
}
|
|
@@ -5999,6 +6514,14 @@ class XykService {
|
|
|
5999
6514
|
while (!success) {
|
|
6000
6515
|
try {
|
|
6001
6516
|
const urlParams = new URLSearchParams();
|
|
6517
|
+
if (!this.is_key_valid) {
|
|
6518
|
+
return {
|
|
6519
|
+
data: null,
|
|
6520
|
+
error: true,
|
|
6521
|
+
error_code: 401,
|
|
6522
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6523
|
+
};
|
|
6524
|
+
}
|
|
6002
6525
|
let startTime;
|
|
6003
6526
|
if (this.debug) {
|
|
6004
6527
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6009,8 +6532,8 @@ class XykService {
|
|
|
6009
6532
|
"X-Requested-With": userAgent
|
|
6010
6533
|
}
|
|
6011
6534
|
}));
|
|
6012
|
-
debugOutput(response.url, response.status, startTime);
|
|
6013
|
-
if (response.status === 429) {
|
|
6535
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6536
|
+
if (response.status === null || response.status === 429) {
|
|
6014
6537
|
try {
|
|
6015
6538
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6016
6539
|
}
|
|
@@ -6019,7 +6542,7 @@ class XykService {
|
|
|
6019
6542
|
return {
|
|
6020
6543
|
data: null,
|
|
6021
6544
|
error: true,
|
|
6022
|
-
error_code: response.status,
|
|
6545
|
+
error_code: response.status ?? 429,
|
|
6023
6546
|
error_message: error.message
|
|
6024
6547
|
};
|
|
6025
6548
|
}
|
|
@@ -6065,6 +6588,14 @@ class XykService {
|
|
|
6065
6588
|
while (!success) {
|
|
6066
6589
|
try {
|
|
6067
6590
|
const urlParams = new URLSearchParams();
|
|
6591
|
+
if (!this.is_key_valid) {
|
|
6592
|
+
return {
|
|
6593
|
+
data: null,
|
|
6594
|
+
error: true,
|
|
6595
|
+
error_code: 401,
|
|
6596
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6597
|
+
};
|
|
6598
|
+
}
|
|
6068
6599
|
let startTime;
|
|
6069
6600
|
if (this.debug) {
|
|
6070
6601
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6075,8 +6606,8 @@ class XykService {
|
|
|
6075
6606
|
"X-Requested-With": userAgent
|
|
6076
6607
|
}
|
|
6077
6608
|
}));
|
|
6078
|
-
debugOutput(response.url, response.status, startTime);
|
|
6079
|
-
if (response.status === 429) {
|
|
6609
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6610
|
+
if (response.status === null || response.status === 429) {
|
|
6080
6611
|
try {
|
|
6081
6612
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6082
6613
|
}
|
|
@@ -6085,7 +6616,7 @@ class XykService {
|
|
|
6085
6616
|
return {
|
|
6086
6617
|
data: null,
|
|
6087
6618
|
error: true,
|
|
6088
|
-
error_code: response.status,
|
|
6619
|
+
error_code: response.status ?? 429,
|
|
6089
6620
|
error_message: error.message
|
|
6090
6621
|
};
|
|
6091
6622
|
}
|
|
@@ -6130,6 +6661,14 @@ class XykService {
|
|
|
6130
6661
|
while (!success) {
|
|
6131
6662
|
try {
|
|
6132
6663
|
const urlParams = new URLSearchParams();
|
|
6664
|
+
if (!this.is_key_valid) {
|
|
6665
|
+
return {
|
|
6666
|
+
data: null,
|
|
6667
|
+
error: true,
|
|
6668
|
+
error_code: 401,
|
|
6669
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6670
|
+
};
|
|
6671
|
+
}
|
|
6133
6672
|
let startTime;
|
|
6134
6673
|
if (this.debug) {
|
|
6135
6674
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6140,8 +6679,8 @@ class XykService {
|
|
|
6140
6679
|
"X-Requested-With": userAgent
|
|
6141
6680
|
}
|
|
6142
6681
|
}));
|
|
6143
|
-
debugOutput(response.url, response.status, startTime);
|
|
6144
|
-
if (response.status === 429) {
|
|
6682
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6683
|
+
if (response.status === null || response.status === 429) {
|
|
6145
6684
|
try {
|
|
6146
6685
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6147
6686
|
}
|
|
@@ -6150,7 +6689,7 @@ class XykService {
|
|
|
6150
6689
|
return {
|
|
6151
6690
|
data: null,
|
|
6152
6691
|
error: true,
|
|
6153
|
-
error_code: response.status,
|
|
6692
|
+
error_code: response.status ?? 429,
|
|
6154
6693
|
error_message: error.message
|
|
6155
6694
|
};
|
|
6156
6695
|
}
|
|
@@ -6195,6 +6734,14 @@ class XykService {
|
|
|
6195
6734
|
while (!success) {
|
|
6196
6735
|
try {
|
|
6197
6736
|
const urlParams = new URLSearchParams();
|
|
6737
|
+
if (!this.is_key_valid) {
|
|
6738
|
+
return {
|
|
6739
|
+
data: null,
|
|
6740
|
+
error: true,
|
|
6741
|
+
error_code: 401,
|
|
6742
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6743
|
+
};
|
|
6744
|
+
}
|
|
6198
6745
|
let startTime;
|
|
6199
6746
|
if (this.debug) {
|
|
6200
6747
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6205,8 +6752,8 @@ class XykService {
|
|
|
6205
6752
|
"X-Requested-With": userAgent
|
|
6206
6753
|
}
|
|
6207
6754
|
}));
|
|
6208
|
-
debugOutput(response.url, response.status, startTime);
|
|
6209
|
-
if (response.status === 429) {
|
|
6755
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6756
|
+
if (response.status === null || response.status === 429) {
|
|
6210
6757
|
try {
|
|
6211
6758
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6212
6759
|
}
|
|
@@ -6215,7 +6762,7 @@ class XykService {
|
|
|
6215
6762
|
return {
|
|
6216
6763
|
data: null,
|
|
6217
6764
|
error: true,
|
|
6218
|
-
error_code: response.status,
|
|
6765
|
+
error_code: response.status ?? 429,
|
|
6219
6766
|
error_message: error.message
|
|
6220
6767
|
};
|
|
6221
6768
|
}
|
|
@@ -6246,20 +6793,22 @@ class XykService {
|
|
|
6246
6793
|
}
|
|
6247
6794
|
}
|
|
6248
6795
|
|
|
6249
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
6796
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.7.1";
|
|
6250
6797
|
/**
|
|
6251
6798
|
* CovalentClient Class
|
|
6252
6799
|
*/
|
|
6253
6800
|
class CovalentClient {
|
|
6254
6801
|
constructor(apiKey, settings) {
|
|
6255
6802
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
6256
|
-
|
|
6257
|
-
this.
|
|
6258
|
-
this.
|
|
6259
|
-
this.
|
|
6260
|
-
this.
|
|
6261
|
-
this.
|
|
6262
|
-
this.
|
|
6803
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
6804
|
+
this._is_key_valid = validator.isValidApiKey();
|
|
6805
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6806
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6807
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6808
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6809
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6810
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6811
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6263
6812
|
}
|
|
6264
6813
|
}
|
|
6265
6814
|
/**
|
|
@@ -6271,13 +6820,15 @@ class CovalentClient {
|
|
|
6271
6820
|
class Client {
|
|
6272
6821
|
constructor(apiKey, settings) {
|
|
6273
6822
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
6274
|
-
|
|
6275
|
-
this.
|
|
6276
|
-
this.
|
|
6277
|
-
this.
|
|
6278
|
-
this.
|
|
6279
|
-
this.
|
|
6280
|
-
this.
|
|
6823
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
6824
|
+
this._is_key_valid = validator.isValidApiKey();
|
|
6825
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6826
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6827
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6828
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6829
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6830
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6831
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6281
6832
|
}
|
|
6282
6833
|
}
|
|
6283
6834
|
|