@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/cjs/index.js
CHANGED
|
@@ -25,9 +25,9 @@ class ExponentialBackoff {
|
|
|
25
25
|
"X-Requested-With": userAgent
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
debugOutput(response.url, response.status, startTime);
|
|
29
|
-
if (response.status === 429) {
|
|
30
|
-
throw new Error(`Received status code: ${response.status}`);
|
|
28
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
29
|
+
if (response.status === null || response.status === 429) {
|
|
30
|
+
throw new Error(`Received status code: ${response.status ?? 429}`);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
return response.json();
|
|
@@ -240,14 +240,14 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
240
240
|
"X-Requested-With": userAgent
|
|
241
241
|
}
|
|
242
242
|
}));
|
|
243
|
-
debugOutput(response.url, response.status, startTime);
|
|
244
|
-
if (response.status === 429) {
|
|
243
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
244
|
+
if (response.status === null || response.status === 429) {
|
|
245
245
|
try {
|
|
246
246
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
247
247
|
}
|
|
248
248
|
catch (error) {
|
|
249
249
|
hasNext = false;
|
|
250
|
-
throw new Error(`An error occurred ${response.status}: ${error.message}`);
|
|
250
|
+
throw new Error(`An error occurred ${response.status ?? 429}: ${error.message}`);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
else {
|
|
@@ -285,6 +285,19 @@ async function* paginateEndpoint$1(url, apiKey, urlsParams, dataClassConstructor
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
class ApiKeyValidator {
|
|
289
|
+
constructor(apiKey) {
|
|
290
|
+
this._apiKey = apiKey;
|
|
291
|
+
}
|
|
292
|
+
isValidApiKey() {
|
|
293
|
+
return ApiKeyValidator._apiKeyV1Pattern.test(this._apiKey) || ApiKeyValidator._apiKeyV2Pattern.test(this._apiKey);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// Regular expression patterns
|
|
297
|
+
ApiKeyValidator._apiKeyV1Pattern = /^ckey_([a-f0-9]{27})$/;
|
|
298
|
+
ApiKeyValidator._apiKeyV2Pattern = /^cqt_(wF|rQ)([bcdfghjkmpqrtvwxyBCDFGHJKMPQRTVWXY346789]{26})$/;
|
|
299
|
+
ApiKeyValidator.INVALID_API_KEY_MESSAGE = "Invalid or missing API key (sign up at covalenthq.com/platform)";
|
|
300
|
+
|
|
288
301
|
class ApprovalsResponse {
|
|
289
302
|
constructor(data) {
|
|
290
303
|
this.address = data.address;
|
|
@@ -372,10 +385,11 @@ class NftApprovalSpender {
|
|
|
372
385
|
*
|
|
373
386
|
*/
|
|
374
387
|
class SecurityService {
|
|
375
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
388
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
376
389
|
this.apiKey = apiKey;
|
|
377
390
|
this.debug = debug;
|
|
378
391
|
this.threadCount = threadCount;
|
|
392
|
+
this.is_key_valid = is_key_valid;
|
|
379
393
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
380
394
|
}
|
|
381
395
|
/**
|
|
@@ -394,6 +408,14 @@ class SecurityService {
|
|
|
394
408
|
while (!success) {
|
|
395
409
|
try {
|
|
396
410
|
const urlParams = new URLSearchParams();
|
|
411
|
+
if (!this.is_key_valid) {
|
|
412
|
+
return {
|
|
413
|
+
data: null,
|
|
414
|
+
error: true,
|
|
415
|
+
error_code: 401,
|
|
416
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
417
|
+
};
|
|
418
|
+
}
|
|
397
419
|
let startTime;
|
|
398
420
|
if (this.debug) {
|
|
399
421
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -404,8 +426,8 @@ class SecurityService {
|
|
|
404
426
|
"X-Requested-With": userAgent
|
|
405
427
|
}
|
|
406
428
|
}));
|
|
407
|
-
debugOutput(response.url, response.status, startTime);
|
|
408
|
-
if (response.status === 429) {
|
|
429
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
430
|
+
if (response.status === null || response.status === 429) {
|
|
409
431
|
try {
|
|
410
432
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
411
433
|
}
|
|
@@ -414,7 +436,7 @@ class SecurityService {
|
|
|
414
436
|
return {
|
|
415
437
|
data: null,
|
|
416
438
|
error: true,
|
|
417
|
-
error_code: response.status,
|
|
439
|
+
error_code: response.status ?? 429,
|
|
418
440
|
error_message: error.message
|
|
419
441
|
};
|
|
420
442
|
}
|
|
@@ -458,6 +480,14 @@ class SecurityService {
|
|
|
458
480
|
while (!success) {
|
|
459
481
|
try {
|
|
460
482
|
const urlParams = new URLSearchParams();
|
|
483
|
+
if (!this.is_key_valid) {
|
|
484
|
+
return {
|
|
485
|
+
data: null,
|
|
486
|
+
error: true,
|
|
487
|
+
error_code: 401,
|
|
488
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
489
|
+
};
|
|
490
|
+
}
|
|
461
491
|
let startTime;
|
|
462
492
|
if (this.debug) {
|
|
463
493
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -468,8 +498,8 @@ class SecurityService {
|
|
|
468
498
|
"X-Requested-With": userAgent
|
|
469
499
|
}
|
|
470
500
|
}));
|
|
471
|
-
debugOutput(response.url, response.status, startTime);
|
|
472
|
-
if (response.status === 429) {
|
|
501
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
502
|
+
if (response.status === null || response.status === 429) {
|
|
473
503
|
try {
|
|
474
504
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
475
505
|
}
|
|
@@ -478,7 +508,7 @@ class SecurityService {
|
|
|
478
508
|
return {
|
|
479
509
|
data: null,
|
|
480
510
|
error: true,
|
|
481
|
-
error_code: response.status,
|
|
511
|
+
error_code: response.status ?? 429,
|
|
482
512
|
error_message: error.message
|
|
483
513
|
};
|
|
484
514
|
}
|
|
@@ -790,10 +820,11 @@ class NativeBalanceItem {
|
|
|
790
820
|
*
|
|
791
821
|
*/
|
|
792
822
|
class BalanceService {
|
|
793
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
823
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
794
824
|
this.apiKey = apiKey;
|
|
795
825
|
this.debug = debug;
|
|
796
826
|
this.threadCount = threadCount;
|
|
827
|
+
this.is_key_valid = is_key_valid;
|
|
797
828
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
798
829
|
}
|
|
799
830
|
/**
|
|
@@ -818,6 +849,14 @@ class BalanceService {
|
|
|
818
849
|
while (!success) {
|
|
819
850
|
try {
|
|
820
851
|
const urlParams = new URLSearchParams();
|
|
852
|
+
if (!this.is_key_valid) {
|
|
853
|
+
return {
|
|
854
|
+
data: null,
|
|
855
|
+
error: true,
|
|
856
|
+
error_code: 401,
|
|
857
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
858
|
+
};
|
|
859
|
+
}
|
|
821
860
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
822
861
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
823
862
|
}
|
|
@@ -843,8 +882,8 @@ class BalanceService {
|
|
|
843
882
|
"X-Requested-With": userAgent
|
|
844
883
|
}
|
|
845
884
|
}));
|
|
846
|
-
debugOutput(response.url, response.status, startTime);
|
|
847
|
-
if (response.status === 429) {
|
|
885
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
886
|
+
if (response.status === null || response.status === 429) {
|
|
848
887
|
try {
|
|
849
888
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
850
889
|
}
|
|
@@ -853,7 +892,7 @@ class BalanceService {
|
|
|
853
892
|
return {
|
|
854
893
|
data: null,
|
|
855
894
|
error: true,
|
|
856
|
-
error_code: response.status,
|
|
895
|
+
error_code: response.status ?? 429,
|
|
857
896
|
error_message: error.message
|
|
858
897
|
};
|
|
859
898
|
}
|
|
@@ -901,6 +940,14 @@ class BalanceService {
|
|
|
901
940
|
while (!success) {
|
|
902
941
|
try {
|
|
903
942
|
const urlParams = new URLSearchParams();
|
|
943
|
+
if (!this.is_key_valid) {
|
|
944
|
+
return {
|
|
945
|
+
data: null,
|
|
946
|
+
error: true,
|
|
947
|
+
error_code: 401,
|
|
948
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
949
|
+
};
|
|
950
|
+
}
|
|
904
951
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
905
952
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
906
953
|
}
|
|
@@ -917,8 +964,8 @@ class BalanceService {
|
|
|
917
964
|
"X-Requested-With": userAgent
|
|
918
965
|
}
|
|
919
966
|
}));
|
|
920
|
-
debugOutput(response.url, response.status, startTime);
|
|
921
|
-
if (response.status === 429) {
|
|
967
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
968
|
+
if (response.status === null || response.status === 429) {
|
|
922
969
|
try {
|
|
923
970
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
924
971
|
}
|
|
@@ -927,7 +974,7 @@ class BalanceService {
|
|
|
927
974
|
return {
|
|
928
975
|
data: null,
|
|
929
976
|
error: true,
|
|
930
|
-
error_code: response.status,
|
|
977
|
+
error_code: response.status ?? 429,
|
|
931
978
|
error_message: error.message
|
|
932
979
|
};
|
|
933
980
|
}
|
|
@@ -977,6 +1024,9 @@ class BalanceService {
|
|
|
977
1024
|
while (!success) {
|
|
978
1025
|
try {
|
|
979
1026
|
const urlParams = new URLSearchParams();
|
|
1027
|
+
if (!this.is_key_valid) {
|
|
1028
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1029
|
+
}
|
|
980
1030
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
981
1031
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
982
1032
|
}
|
|
@@ -1029,6 +1079,14 @@ class BalanceService {
|
|
|
1029
1079
|
while (!success) {
|
|
1030
1080
|
try {
|
|
1031
1081
|
const urlParams = new URLSearchParams();
|
|
1082
|
+
if (!this.is_key_valid) {
|
|
1083
|
+
return {
|
|
1084
|
+
data: null,
|
|
1085
|
+
error: true,
|
|
1086
|
+
error_code: 401,
|
|
1087
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1032
1090
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1033
1091
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1034
1092
|
}
|
|
@@ -1057,8 +1115,8 @@ class BalanceService {
|
|
|
1057
1115
|
"X-Requested-With": userAgent
|
|
1058
1116
|
}
|
|
1059
1117
|
}));
|
|
1060
|
-
debugOutput(response.url, response.status, startTime);
|
|
1061
|
-
if (response.status === 429) {
|
|
1118
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1119
|
+
if (response.status === null || response.status === 429) {
|
|
1062
1120
|
try {
|
|
1063
1121
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1064
1122
|
}
|
|
@@ -1067,7 +1125,7 @@ class BalanceService {
|
|
|
1067
1125
|
return {
|
|
1068
1126
|
data: null,
|
|
1069
1127
|
error: true,
|
|
1070
|
-
error_code: response.status,
|
|
1128
|
+
error_code: response.status ?? 429,
|
|
1071
1129
|
error_message: error.message
|
|
1072
1130
|
};
|
|
1073
1131
|
}
|
|
@@ -1115,6 +1173,9 @@ class BalanceService {
|
|
|
1115
1173
|
while (!success) {
|
|
1116
1174
|
try {
|
|
1117
1175
|
const urlParams = new URLSearchParams();
|
|
1176
|
+
if (!this.is_key_valid) {
|
|
1177
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1178
|
+
}
|
|
1118
1179
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1119
1180
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1120
1181
|
}
|
|
@@ -1159,6 +1220,14 @@ class BalanceService {
|
|
|
1159
1220
|
while (!success) {
|
|
1160
1221
|
try {
|
|
1161
1222
|
const urlParams = new URLSearchParams();
|
|
1223
|
+
if (!this.is_key_valid) {
|
|
1224
|
+
return {
|
|
1225
|
+
data: null,
|
|
1226
|
+
error: true,
|
|
1227
|
+
error_code: 401,
|
|
1228
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1162
1231
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
1163
1232
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
1164
1233
|
}
|
|
@@ -1181,8 +1250,8 @@ class BalanceService {
|
|
|
1181
1250
|
"X-Requested-With": userAgent
|
|
1182
1251
|
}
|
|
1183
1252
|
}));
|
|
1184
|
-
debugOutput(response.url, response.status, startTime);
|
|
1185
|
-
if (response.status === 429) {
|
|
1253
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1254
|
+
if (response.status === null || response.status === 429) {
|
|
1186
1255
|
try {
|
|
1187
1256
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1188
1257
|
}
|
|
@@ -1191,7 +1260,7 @@ class BalanceService {
|
|
|
1191
1260
|
return {
|
|
1192
1261
|
data: null,
|
|
1193
1262
|
error: true,
|
|
1194
|
-
error_code: response.status,
|
|
1263
|
+
error_code: response.status ?? 429,
|
|
1195
1264
|
error_message: error.message
|
|
1196
1265
|
};
|
|
1197
1266
|
}
|
|
@@ -1244,6 +1313,14 @@ class BalanceService {
|
|
|
1244
1313
|
while (!success) {
|
|
1245
1314
|
try {
|
|
1246
1315
|
const urlParams = new URLSearchParams();
|
|
1316
|
+
if (!this.is_key_valid) {
|
|
1317
|
+
return {
|
|
1318
|
+
data: null,
|
|
1319
|
+
error: true,
|
|
1320
|
+
error_code: 401,
|
|
1321
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1247
1324
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1248
1325
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1249
1326
|
}
|
|
@@ -1275,8 +1352,8 @@ class BalanceService {
|
|
|
1275
1352
|
"X-Requested-With": userAgent
|
|
1276
1353
|
}
|
|
1277
1354
|
}));
|
|
1278
|
-
debugOutput(response.url, response.status, startTime);
|
|
1279
|
-
if (response.status === 429) {
|
|
1355
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1356
|
+
if (response.status === null || response.status === 429) {
|
|
1280
1357
|
try {
|
|
1281
1358
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1282
1359
|
}
|
|
@@ -1285,7 +1362,7 @@ class BalanceService {
|
|
|
1285
1362
|
return {
|
|
1286
1363
|
data: null,
|
|
1287
1364
|
error: true,
|
|
1288
|
-
error_code: response.status,
|
|
1365
|
+
error_code: response.status ?? 429,
|
|
1289
1366
|
error_message: error.message
|
|
1290
1367
|
};
|
|
1291
1368
|
}
|
|
@@ -1331,6 +1408,14 @@ class BalanceService {
|
|
|
1331
1408
|
while (!success) {
|
|
1332
1409
|
try {
|
|
1333
1410
|
const urlParams = new URLSearchParams();
|
|
1411
|
+
if (!this.is_key_valid) {
|
|
1412
|
+
return {
|
|
1413
|
+
data: null,
|
|
1414
|
+
error: true,
|
|
1415
|
+
error_code: 401,
|
|
1416
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1334
1419
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
1335
1420
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
1336
1421
|
}
|
|
@@ -1347,8 +1432,8 @@ class BalanceService {
|
|
|
1347
1432
|
"X-Requested-With": userAgent
|
|
1348
1433
|
}
|
|
1349
1434
|
}));
|
|
1350
|
-
debugOutput(response.url, response.status, startTime);
|
|
1351
|
-
if (response.status === 429) {
|
|
1435
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1436
|
+
if (response.status === null || response.status === 429) {
|
|
1352
1437
|
try {
|
|
1353
1438
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1354
1439
|
}
|
|
@@ -1357,7 +1442,7 @@ class BalanceService {
|
|
|
1357
1442
|
return {
|
|
1358
1443
|
data: null,
|
|
1359
1444
|
error: true,
|
|
1360
|
-
error_code: response.status,
|
|
1445
|
+
error_code: response.status ?? 429,
|
|
1361
1446
|
error_message: error.message
|
|
1362
1447
|
};
|
|
1363
1448
|
}
|
|
@@ -1577,15 +1662,43 @@ class ChainActivityEvent extends ChainItem {
|
|
|
1577
1662
|
this.last_seen_at = data.last_seen_at && data.last_seen_at !== null ? dateFns.parseISO(data.last_seen_at.toString()) : null;
|
|
1578
1663
|
}
|
|
1579
1664
|
}
|
|
1665
|
+
class GasPricesResponse {
|
|
1666
|
+
constructor(data) {
|
|
1667
|
+
this.chain_id = data.chain_id;
|
|
1668
|
+
this.chain_name = data.chain_name;
|
|
1669
|
+
this.quote_currency = data.quote_currency;
|
|
1670
|
+
this.updated_at = data.updated_at && data.updated_at !== null ? dateFns.parseISO(data.updated_at.toString()) : null;
|
|
1671
|
+
this.event_type = data.event_type;
|
|
1672
|
+
this.gas_quote_rate = data.gas_quote_rate;
|
|
1673
|
+
this.items = data.items && data.items !== null ? data.items.map((itemData) => new PriceItem(itemData)) : null;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
class PriceItem {
|
|
1677
|
+
constructor(data) {
|
|
1678
|
+
this.gas_price = data.gas_price;
|
|
1679
|
+
this.gas_spent = data.gas_spent;
|
|
1680
|
+
this.gas_quote = data.gas_quote;
|
|
1681
|
+
this.total_gas_quote = data.total_gas_quote;
|
|
1682
|
+
this.pretty_total_gas_quote = data.pretty_total_gas_quote;
|
|
1683
|
+
this.interval = data.interval;
|
|
1684
|
+
this.other_fees = data.other_fees && data.other_fees !== null ? new OtherFees(data.other_fees) : null;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
class OtherFees {
|
|
1688
|
+
constructor(data) {
|
|
1689
|
+
this.l1_gas_quote = data.l1_gas_quote;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1580
1692
|
/**
|
|
1581
1693
|
* Class A - Base
|
|
1582
1694
|
*
|
|
1583
1695
|
*/
|
|
1584
1696
|
class BaseService {
|
|
1585
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
1697
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
1586
1698
|
this.apiKey = apiKey;
|
|
1587
1699
|
this.debug = debug;
|
|
1588
1700
|
this.threadCount = threadCount;
|
|
1701
|
+
this.is_key_valid = is_key_valid;
|
|
1589
1702
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
1590
1703
|
}
|
|
1591
1704
|
/**
|
|
@@ -1604,6 +1717,14 @@ class BaseService {
|
|
|
1604
1717
|
while (!success) {
|
|
1605
1718
|
try {
|
|
1606
1719
|
const urlParams = new URLSearchParams();
|
|
1720
|
+
if (!this.is_key_valid) {
|
|
1721
|
+
return {
|
|
1722
|
+
data: null,
|
|
1723
|
+
error: true,
|
|
1724
|
+
error_code: 401,
|
|
1725
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1607
1728
|
let startTime;
|
|
1608
1729
|
if (this.debug) {
|
|
1609
1730
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1614,8 +1735,8 @@ class BaseService {
|
|
|
1614
1735
|
"X-Requested-With": userAgent
|
|
1615
1736
|
}
|
|
1616
1737
|
}));
|
|
1617
|
-
debugOutput(response.url, response.status, startTime);
|
|
1618
|
-
if (response.status === 429) {
|
|
1738
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1739
|
+
if (response.status === null || response.status === 429) {
|
|
1619
1740
|
try {
|
|
1620
1741
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1621
1742
|
}
|
|
@@ -1624,7 +1745,7 @@ class BaseService {
|
|
|
1624
1745
|
return {
|
|
1625
1746
|
data: null,
|
|
1626
1747
|
error: true,
|
|
1627
|
-
error_code: response.status,
|
|
1748
|
+
error_code: response.status ?? 429,
|
|
1628
1749
|
error_message: error.message
|
|
1629
1750
|
};
|
|
1630
1751
|
}
|
|
@@ -1669,6 +1790,14 @@ class BaseService {
|
|
|
1669
1790
|
while (!success) {
|
|
1670
1791
|
try {
|
|
1671
1792
|
const urlParams = new URLSearchParams();
|
|
1793
|
+
if (!this.is_key_valid) {
|
|
1794
|
+
return {
|
|
1795
|
+
data: null,
|
|
1796
|
+
error: true,
|
|
1797
|
+
error_code: 401,
|
|
1798
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1672
1801
|
let startTime;
|
|
1673
1802
|
if (this.debug) {
|
|
1674
1803
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -1679,8 +1808,8 @@ class BaseService {
|
|
|
1679
1808
|
"X-Requested-With": userAgent
|
|
1680
1809
|
}
|
|
1681
1810
|
}));
|
|
1682
|
-
debugOutput(response.url, response.status, startTime);
|
|
1683
|
-
if (response.status === 429) {
|
|
1811
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1812
|
+
if (response.status === null || response.status === 429) {
|
|
1684
1813
|
try {
|
|
1685
1814
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1686
1815
|
}
|
|
@@ -1689,7 +1818,7 @@ class BaseService {
|
|
|
1689
1818
|
return {
|
|
1690
1819
|
data: null,
|
|
1691
1820
|
error: true,
|
|
1692
|
-
error_code: response.status,
|
|
1821
|
+
error_code: response.status ?? 429,
|
|
1693
1822
|
error_message: error.message
|
|
1694
1823
|
};
|
|
1695
1824
|
}
|
|
@@ -1736,6 +1865,9 @@ class BaseService {
|
|
|
1736
1865
|
while (!success) {
|
|
1737
1866
|
try {
|
|
1738
1867
|
const urlParams = new URLSearchParams();
|
|
1868
|
+
if (!this.is_key_valid) {
|
|
1869
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
1870
|
+
}
|
|
1739
1871
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
1740
1872
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1741
1873
|
}
|
|
@@ -1773,6 +1905,14 @@ class BaseService {
|
|
|
1773
1905
|
while (!success) {
|
|
1774
1906
|
try {
|
|
1775
1907
|
const urlParams = new URLSearchParams();
|
|
1908
|
+
if (!this.is_key_valid) {
|
|
1909
|
+
return {
|
|
1910
|
+
data: null,
|
|
1911
|
+
error: true,
|
|
1912
|
+
error_code: 401,
|
|
1913
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1776
1916
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
1777
1917
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
1778
1918
|
}
|
|
@@ -1789,8 +1929,8 @@ class BaseService {
|
|
|
1789
1929
|
"X-Requested-With": userAgent
|
|
1790
1930
|
}
|
|
1791
1931
|
}));
|
|
1792
|
-
debugOutput(response.url, response.status, startTime);
|
|
1793
|
-
if (response.status === 429) {
|
|
1932
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
1933
|
+
if (response.status === null || response.status === 429) {
|
|
1794
1934
|
try {
|
|
1795
1935
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1796
1936
|
}
|
|
@@ -1799,7 +1939,7 @@ class BaseService {
|
|
|
1799
1939
|
return {
|
|
1800
1940
|
data: null,
|
|
1801
1941
|
error: true,
|
|
1802
|
-
error_code: response.status,
|
|
1942
|
+
error_code: response.status ?? 429,
|
|
1803
1943
|
error_message: error.message
|
|
1804
1944
|
};
|
|
1805
1945
|
}
|
|
@@ -1850,6 +1990,14 @@ class BaseService {
|
|
|
1850
1990
|
while (!success) {
|
|
1851
1991
|
try {
|
|
1852
1992
|
const urlParams = new URLSearchParams();
|
|
1993
|
+
if (!this.is_key_valid) {
|
|
1994
|
+
return {
|
|
1995
|
+
data: null,
|
|
1996
|
+
error: true,
|
|
1997
|
+
error_code: 401,
|
|
1998
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
1853
2001
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1854
2002
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1855
2003
|
}
|
|
@@ -1878,8 +2026,8 @@ class BaseService {
|
|
|
1878
2026
|
"X-Requested-With": userAgent
|
|
1879
2027
|
}
|
|
1880
2028
|
}));
|
|
1881
|
-
debugOutput(response.url, response.status, startTime);
|
|
1882
|
-
if (response.status === 429) {
|
|
2029
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2030
|
+
if (response.status === null || response.status === 429) {
|
|
1883
2031
|
try {
|
|
1884
2032
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
1885
2033
|
}
|
|
@@ -1888,7 +2036,7 @@ class BaseService {
|
|
|
1888
2036
|
return {
|
|
1889
2037
|
data: null,
|
|
1890
2038
|
error: true,
|
|
1891
|
-
error_code: response.status,
|
|
2039
|
+
error_code: response.status ?? 429,
|
|
1892
2040
|
error_message: error.message
|
|
1893
2041
|
};
|
|
1894
2042
|
}
|
|
@@ -1936,6 +2084,9 @@ class BaseService {
|
|
|
1936
2084
|
while (!success) {
|
|
1937
2085
|
try {
|
|
1938
2086
|
const urlParams = new URLSearchParams();
|
|
2087
|
+
if (!this.is_key_valid) {
|
|
2088
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2089
|
+
}
|
|
1939
2090
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1940
2091
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1941
2092
|
}
|
|
@@ -1980,6 +2131,14 @@ class BaseService {
|
|
|
1980
2131
|
while (!success) {
|
|
1981
2132
|
try {
|
|
1982
2133
|
const urlParams = new URLSearchParams();
|
|
2134
|
+
if (!this.is_key_valid) {
|
|
2135
|
+
return {
|
|
2136
|
+
data: null,
|
|
2137
|
+
error: true,
|
|
2138
|
+
error_code: 401,
|
|
2139
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
1983
2142
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
1984
2143
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
1985
2144
|
}
|
|
@@ -2002,8 +2161,8 @@ class BaseService {
|
|
|
2002
2161
|
"X-Requested-With": userAgent
|
|
2003
2162
|
}
|
|
2004
2163
|
}));
|
|
2005
|
-
debugOutput(response.url, response.status, startTime);
|
|
2006
|
-
if (response.status === 429) {
|
|
2164
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2165
|
+
if (response.status === null || response.status === 429) {
|
|
2007
2166
|
try {
|
|
2008
2167
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2009
2168
|
}
|
|
@@ -2012,7 +2171,7 @@ class BaseService {
|
|
|
2012
2171
|
return {
|
|
2013
2172
|
data: null,
|
|
2014
2173
|
error: true,
|
|
2015
|
-
error_code: response.status,
|
|
2174
|
+
error_code: response.status ?? 429,
|
|
2016
2175
|
error_message: error.message
|
|
2017
2176
|
};
|
|
2018
2177
|
}
|
|
@@ -2061,6 +2220,9 @@ class BaseService {
|
|
|
2061
2220
|
while (!success) {
|
|
2062
2221
|
try {
|
|
2063
2222
|
const urlParams = new URLSearchParams();
|
|
2223
|
+
if (!this.is_key_valid) {
|
|
2224
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2225
|
+
}
|
|
2064
2226
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
2065
2227
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
2066
2228
|
}
|
|
@@ -2109,6 +2271,14 @@ class BaseService {
|
|
|
2109
2271
|
while (!success) {
|
|
2110
2272
|
try {
|
|
2111
2273
|
const urlParams = new URLSearchParams();
|
|
2274
|
+
if (!this.is_key_valid) {
|
|
2275
|
+
return {
|
|
2276
|
+
data: null,
|
|
2277
|
+
error: true,
|
|
2278
|
+
error_code: 401,
|
|
2279
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2112
2282
|
if (queryParamOpts?.startingBlock !== undefined) {
|
|
2113
2283
|
urlParams.append("starting-block", queryParamOpts?.startingBlock.toString());
|
|
2114
2284
|
}
|
|
@@ -2134,8 +2304,8 @@ class BaseService {
|
|
|
2134
2304
|
"X-Requested-With": userAgent
|
|
2135
2305
|
}
|
|
2136
2306
|
}));
|
|
2137
|
-
debugOutput(response.url, response.status, startTime);
|
|
2138
|
-
if (response.status === 429) {
|
|
2307
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2308
|
+
if (response.status === null || response.status === 429) {
|
|
2139
2309
|
try {
|
|
2140
2310
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2141
2311
|
}
|
|
@@ -2144,7 +2314,7 @@ class BaseService {
|
|
|
2144
2314
|
return {
|
|
2145
2315
|
data: null,
|
|
2146
2316
|
error: true,
|
|
2147
|
-
error_code: response.status,
|
|
2317
|
+
error_code: response.status ?? 429,
|
|
2148
2318
|
error_message: error.message
|
|
2149
2319
|
};
|
|
2150
2320
|
}
|
|
@@ -2187,6 +2357,14 @@ class BaseService {
|
|
|
2187
2357
|
while (!success) {
|
|
2188
2358
|
try {
|
|
2189
2359
|
const urlParams = new URLSearchParams();
|
|
2360
|
+
if (!this.is_key_valid) {
|
|
2361
|
+
return {
|
|
2362
|
+
data: null,
|
|
2363
|
+
error: true,
|
|
2364
|
+
error_code: 401,
|
|
2365
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2190
2368
|
let startTime;
|
|
2191
2369
|
if (this.debug) {
|
|
2192
2370
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -2197,8 +2375,8 @@ class BaseService {
|
|
|
2197
2375
|
"X-Requested-With": userAgent
|
|
2198
2376
|
}
|
|
2199
2377
|
}));
|
|
2200
|
-
debugOutput(response.url, response.status, startTime);
|
|
2201
|
-
if (response.status === 429) {
|
|
2378
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2379
|
+
if (response.status === null || response.status === 429) {
|
|
2202
2380
|
try {
|
|
2203
2381
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2204
2382
|
}
|
|
@@ -2207,7 +2385,7 @@ class BaseService {
|
|
|
2207
2385
|
return {
|
|
2208
2386
|
data: null,
|
|
2209
2387
|
error: true,
|
|
2210
|
-
error_code: response.status,
|
|
2388
|
+
error_code: response.status ?? 429,
|
|
2211
2389
|
error_message: error.message
|
|
2212
2390
|
};
|
|
2213
2391
|
}
|
|
@@ -2250,6 +2428,14 @@ class BaseService {
|
|
|
2250
2428
|
while (!success) {
|
|
2251
2429
|
try {
|
|
2252
2430
|
const urlParams = new URLSearchParams();
|
|
2431
|
+
if (!this.is_key_valid) {
|
|
2432
|
+
return {
|
|
2433
|
+
data: null,
|
|
2434
|
+
error: true,
|
|
2435
|
+
error_code: 401,
|
|
2436
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2253
2439
|
let startTime;
|
|
2254
2440
|
if (this.debug) {
|
|
2255
2441
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -2260,8 +2446,8 @@ class BaseService {
|
|
|
2260
2446
|
"X-Requested-With": userAgent
|
|
2261
2447
|
}
|
|
2262
2448
|
}));
|
|
2263
|
-
debugOutput(response.url, response.status, startTime);
|
|
2264
|
-
if (response.status === 429) {
|
|
2449
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2450
|
+
if (response.status === null || response.status === 429) {
|
|
2265
2451
|
try {
|
|
2266
2452
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2267
2453
|
}
|
|
@@ -2270,7 +2456,7 @@ class BaseService {
|
|
|
2270
2456
|
return {
|
|
2271
2457
|
data: null,
|
|
2272
2458
|
error: true,
|
|
2273
|
-
error_code: response.status,
|
|
2459
|
+
error_code: response.status ?? 429,
|
|
2274
2460
|
error_message: error.message
|
|
2275
2461
|
};
|
|
2276
2462
|
}
|
|
@@ -2316,6 +2502,14 @@ class BaseService {
|
|
|
2316
2502
|
while (!success) {
|
|
2317
2503
|
try {
|
|
2318
2504
|
const urlParams = new URLSearchParams();
|
|
2505
|
+
if (!this.is_key_valid) {
|
|
2506
|
+
return {
|
|
2507
|
+
data: null,
|
|
2508
|
+
error: true,
|
|
2509
|
+
error_code: 401,
|
|
2510
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2319
2513
|
if (queryParamOpts?.testnets !== undefined) {
|
|
2320
2514
|
urlParams.append("testnets", queryParamOpts?.testnets.toString());
|
|
2321
2515
|
}
|
|
@@ -2329,6 +2523,82 @@ class BaseService {
|
|
|
2329
2523
|
"X-Requested-With": userAgent
|
|
2330
2524
|
}
|
|
2331
2525
|
}));
|
|
2526
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
2527
|
+
if (response.status === null || response.status === 429) {
|
|
2528
|
+
try {
|
|
2529
|
+
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2530
|
+
}
|
|
2531
|
+
catch (error) {
|
|
2532
|
+
success = true;
|
|
2533
|
+
return {
|
|
2534
|
+
data: null,
|
|
2535
|
+
error: true,
|
|
2536
|
+
error_code: response.status ?? 429,
|
|
2537
|
+
error_message: error.message
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
else {
|
|
2542
|
+
data = await response.json();
|
|
2543
|
+
}
|
|
2544
|
+
const dataClass = new ChainActivityResponse(data.data);
|
|
2545
|
+
checkAndModifyResponse(dataClass);
|
|
2546
|
+
success = true;
|
|
2547
|
+
return {
|
|
2548
|
+
data: dataClass,
|
|
2549
|
+
error: data.error,
|
|
2550
|
+
error_code: data ? data.error_code : response.status,
|
|
2551
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
catch (error) {
|
|
2555
|
+
success = true;
|
|
2556
|
+
return {
|
|
2557
|
+
data: null,
|
|
2558
|
+
error: true,
|
|
2559
|
+
error_code: data ? data.error_code : response.status,
|
|
2560
|
+
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
*
|
|
2567
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
2568
|
+
* @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
|
|
2569
|
+
* @param {GetGasPricesQueryParamOpts} queryParamOpts
|
|
2570
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
2571
|
+
*
|
|
2572
|
+
*/
|
|
2573
|
+
async getGasPrices(chainName, eventType, queryParamOpts) {
|
|
2574
|
+
let success = false;
|
|
2575
|
+
let data;
|
|
2576
|
+
let response;
|
|
2577
|
+
const backoff = new ExponentialBackoff(this.apiKey, this.debug);
|
|
2578
|
+
while (!success) {
|
|
2579
|
+
try {
|
|
2580
|
+
const urlParams = new URLSearchParams();
|
|
2581
|
+
if (!this.is_key_valid) {
|
|
2582
|
+
return {
|
|
2583
|
+
data: null,
|
|
2584
|
+
error: true,
|
|
2585
|
+
error_code: 401,
|
|
2586
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
2590
|
+
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
2591
|
+
}
|
|
2592
|
+
let startTime;
|
|
2593
|
+
if (this.debug) {
|
|
2594
|
+
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
2595
|
+
}
|
|
2596
|
+
response = await this.LIMIT(() => fetch(`https://api.covalenthq.com/v1/${chainName}/event/${eventType}/gas_prices/?${urlParams}`, {
|
|
2597
|
+
headers: {
|
|
2598
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
2599
|
+
"X-Requested-With": userAgent
|
|
2600
|
+
}
|
|
2601
|
+
}));
|
|
2332
2602
|
debugOutput(response.url, response.status, startTime);
|
|
2333
2603
|
if (response.status === 429) {
|
|
2334
2604
|
try {
|
|
@@ -2347,7 +2617,7 @@ class BaseService {
|
|
|
2347
2617
|
else {
|
|
2348
2618
|
data = await response.json();
|
|
2349
2619
|
}
|
|
2350
|
-
const dataClass = new
|
|
2620
|
+
const dataClass = new GasPricesResponse(data.data);
|
|
2351
2621
|
checkAndModifyResponse(dataClass);
|
|
2352
2622
|
success = true;
|
|
2353
2623
|
return {
|
|
@@ -2692,10 +2962,11 @@ class MarketFloorPriceItem {
|
|
|
2692
2962
|
*
|
|
2693
2963
|
*/
|
|
2694
2964
|
class NftService {
|
|
2695
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
2965
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
2696
2966
|
this.apiKey = apiKey;
|
|
2697
2967
|
this.debug = debug;
|
|
2698
2968
|
this.threadCount = threadCount;
|
|
2969
|
+
this.is_key_valid = is_key_valid;
|
|
2699
2970
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
2700
2971
|
}
|
|
2701
2972
|
/**
|
|
@@ -2715,6 +2986,9 @@ class NftService {
|
|
|
2715
2986
|
while (!success) {
|
|
2716
2987
|
try {
|
|
2717
2988
|
const urlParams = new URLSearchParams();
|
|
2989
|
+
if (!this.is_key_valid) {
|
|
2990
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
2991
|
+
}
|
|
2718
2992
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
2719
2993
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2720
2994
|
}
|
|
@@ -2754,6 +3028,14 @@ class NftService {
|
|
|
2754
3028
|
while (!success) {
|
|
2755
3029
|
try {
|
|
2756
3030
|
const urlParams = new URLSearchParams();
|
|
3031
|
+
if (!this.is_key_valid) {
|
|
3032
|
+
return {
|
|
3033
|
+
data: null,
|
|
3034
|
+
error: true,
|
|
3035
|
+
error_code: 401,
|
|
3036
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
2757
3039
|
if (queryParamOpts?.pageSize !== undefined) {
|
|
2758
3040
|
urlParams.append("page-size", queryParamOpts?.pageSize.toString());
|
|
2759
3041
|
}
|
|
@@ -2773,8 +3055,8 @@ class NftService {
|
|
|
2773
3055
|
"X-Requested-With": userAgent
|
|
2774
3056
|
}
|
|
2775
3057
|
}));
|
|
2776
|
-
debugOutput(response.url, response.status, startTime);
|
|
2777
|
-
if (response.status === 429) {
|
|
3058
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3059
|
+
if (response.status === null || response.status === 429) {
|
|
2778
3060
|
try {
|
|
2779
3061
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2780
3062
|
}
|
|
@@ -2783,7 +3065,7 @@ class NftService {
|
|
|
2783
3065
|
return {
|
|
2784
3066
|
data: null,
|
|
2785
3067
|
error: true,
|
|
2786
|
-
error_code: response.status,
|
|
3068
|
+
error_code: response.status ?? 429,
|
|
2787
3069
|
error_message: error.message
|
|
2788
3070
|
};
|
|
2789
3071
|
}
|
|
@@ -2832,6 +3114,14 @@ class NftService {
|
|
|
2832
3114
|
while (!success) {
|
|
2833
3115
|
try {
|
|
2834
3116
|
const urlParams = new URLSearchParams();
|
|
3117
|
+
if (!this.is_key_valid) {
|
|
3118
|
+
return {
|
|
3119
|
+
data: null,
|
|
3120
|
+
error: true,
|
|
3121
|
+
error_code: 401,
|
|
3122
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
2835
3125
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
2836
3126
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
2837
3127
|
}
|
|
@@ -2851,8 +3141,8 @@ class NftService {
|
|
|
2851
3141
|
"X-Requested-With": userAgent
|
|
2852
3142
|
}
|
|
2853
3143
|
}));
|
|
2854
|
-
debugOutput(response.url, response.status, startTime);
|
|
2855
|
-
if (response.status === 429) {
|
|
3144
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3145
|
+
if (response.status === null || response.status === 429) {
|
|
2856
3146
|
try {
|
|
2857
3147
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2858
3148
|
}
|
|
@@ -2861,7 +3151,7 @@ class NftService {
|
|
|
2861
3151
|
return {
|
|
2862
3152
|
data: null,
|
|
2863
3153
|
error: true,
|
|
2864
|
-
error_code: response.status,
|
|
3154
|
+
error_code: response.status ?? 429,
|
|
2865
3155
|
error_message: error.message
|
|
2866
3156
|
};
|
|
2867
3157
|
}
|
|
@@ -2911,6 +3201,9 @@ class NftService {
|
|
|
2911
3201
|
while (!success) {
|
|
2912
3202
|
try {
|
|
2913
3203
|
const urlParams = new URLSearchParams();
|
|
3204
|
+
if (!this.is_key_valid) {
|
|
3205
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
3206
|
+
}
|
|
2914
3207
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2915
3208
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2916
3209
|
}
|
|
@@ -2963,6 +3256,14 @@ class NftService {
|
|
|
2963
3256
|
while (!success) {
|
|
2964
3257
|
try {
|
|
2965
3258
|
const urlParams = new URLSearchParams();
|
|
3259
|
+
if (!this.is_key_valid) {
|
|
3260
|
+
return {
|
|
3261
|
+
data: null,
|
|
3262
|
+
error: true,
|
|
3263
|
+
error_code: 401,
|
|
3264
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
2966
3267
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
2967
3268
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
2968
3269
|
}
|
|
@@ -2991,8 +3292,8 @@ class NftService {
|
|
|
2991
3292
|
"X-Requested-With": userAgent
|
|
2992
3293
|
}
|
|
2993
3294
|
}));
|
|
2994
|
-
debugOutput(response.url, response.status, startTime);
|
|
2995
|
-
if (response.status === 429) {
|
|
3295
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3296
|
+
if (response.status === null || response.status === 429) {
|
|
2996
3297
|
try {
|
|
2997
3298
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
2998
3299
|
}
|
|
@@ -3001,7 +3302,7 @@ class NftService {
|
|
|
3001
3302
|
return {
|
|
3002
3303
|
data: null,
|
|
3003
3304
|
error: true,
|
|
3004
|
-
error_code: response.status,
|
|
3305
|
+
error_code: response.status ?? 429,
|
|
3005
3306
|
error_message: error.message
|
|
3006
3307
|
};
|
|
3007
3308
|
}
|
|
@@ -3050,6 +3351,14 @@ class NftService {
|
|
|
3050
3351
|
while (!success) {
|
|
3051
3352
|
try {
|
|
3052
3353
|
const urlParams = new URLSearchParams();
|
|
3354
|
+
if (!this.is_key_valid) {
|
|
3355
|
+
return {
|
|
3356
|
+
data: null,
|
|
3357
|
+
error: true,
|
|
3358
|
+
error_code: 401,
|
|
3359
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3053
3362
|
if (queryParamOpts?.noMetadata !== undefined) {
|
|
3054
3363
|
urlParams.append("no-metadata", queryParamOpts?.noMetadata.toString());
|
|
3055
3364
|
}
|
|
@@ -3066,8 +3375,8 @@ class NftService {
|
|
|
3066
3375
|
"X-Requested-With": userAgent
|
|
3067
3376
|
}
|
|
3068
3377
|
}));
|
|
3069
|
-
debugOutput(response.url, response.status, startTime);
|
|
3070
|
-
if (response.status === 429) {
|
|
3378
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3379
|
+
if (response.status === null || response.status === 429) {
|
|
3071
3380
|
try {
|
|
3072
3381
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3073
3382
|
}
|
|
@@ -3076,7 +3385,7 @@ class NftService {
|
|
|
3076
3385
|
return {
|
|
3077
3386
|
data: null,
|
|
3078
3387
|
error: true,
|
|
3079
|
-
error_code: response.status,
|
|
3388
|
+
error_code: response.status ?? 429,
|
|
3080
3389
|
error_message: error.message
|
|
3081
3390
|
};
|
|
3082
3391
|
}
|
|
@@ -3124,6 +3433,14 @@ class NftService {
|
|
|
3124
3433
|
while (!success) {
|
|
3125
3434
|
try {
|
|
3126
3435
|
const urlParams = new URLSearchParams();
|
|
3436
|
+
if (!this.is_key_valid) {
|
|
3437
|
+
return {
|
|
3438
|
+
data: null,
|
|
3439
|
+
error: true,
|
|
3440
|
+
error_code: 401,
|
|
3441
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3442
|
+
};
|
|
3443
|
+
}
|
|
3127
3444
|
if (queryParamOpts?.noSpam !== undefined) {
|
|
3128
3445
|
urlParams.append("no-spam", queryParamOpts?.noSpam.toString());
|
|
3129
3446
|
}
|
|
@@ -3137,8 +3454,8 @@ class NftService {
|
|
|
3137
3454
|
"X-Requested-With": userAgent
|
|
3138
3455
|
}
|
|
3139
3456
|
}));
|
|
3140
|
-
debugOutput(response.url, response.status, startTime);
|
|
3141
|
-
if (response.status === 429) {
|
|
3457
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3458
|
+
if (response.status === null || response.status === 429) {
|
|
3142
3459
|
try {
|
|
3143
3460
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3144
3461
|
}
|
|
@@ -3147,7 +3464,7 @@ class NftService {
|
|
|
3147
3464
|
return {
|
|
3148
3465
|
data: null,
|
|
3149
3466
|
error: true,
|
|
3150
|
-
error_code: response.status,
|
|
3467
|
+
error_code: response.status ?? 429,
|
|
3151
3468
|
error_message: error.message
|
|
3152
3469
|
};
|
|
3153
3470
|
}
|
|
@@ -3192,6 +3509,14 @@ class NftService {
|
|
|
3192
3509
|
while (!success) {
|
|
3193
3510
|
try {
|
|
3194
3511
|
const urlParams = new URLSearchParams();
|
|
3512
|
+
if (!this.is_key_valid) {
|
|
3513
|
+
return {
|
|
3514
|
+
data: null,
|
|
3515
|
+
error: true,
|
|
3516
|
+
error_code: 401,
|
|
3517
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3518
|
+
};
|
|
3519
|
+
}
|
|
3195
3520
|
let startTime;
|
|
3196
3521
|
if (this.debug) {
|
|
3197
3522
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3202,8 +3527,8 @@ class NftService {
|
|
|
3202
3527
|
"X-Requested-With": userAgent
|
|
3203
3528
|
}
|
|
3204
3529
|
}));
|
|
3205
|
-
debugOutput(response.url, response.status, startTime);
|
|
3206
|
-
if (response.status === 429) {
|
|
3530
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3531
|
+
if (response.status === null || response.status === 429) {
|
|
3207
3532
|
try {
|
|
3208
3533
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3209
3534
|
}
|
|
@@ -3212,7 +3537,7 @@ class NftService {
|
|
|
3212
3537
|
return {
|
|
3213
3538
|
data: null,
|
|
3214
3539
|
error: true,
|
|
3215
|
-
error_code: response.status,
|
|
3540
|
+
error_code: response.status ?? 429,
|
|
3216
3541
|
error_message: error.message
|
|
3217
3542
|
};
|
|
3218
3543
|
}
|
|
@@ -3258,6 +3583,14 @@ class NftService {
|
|
|
3258
3583
|
while (!success) {
|
|
3259
3584
|
try {
|
|
3260
3585
|
const urlParams = new URLSearchParams();
|
|
3586
|
+
if (!this.is_key_valid) {
|
|
3587
|
+
return {
|
|
3588
|
+
data: null,
|
|
3589
|
+
error: true,
|
|
3590
|
+
error_code: 401,
|
|
3591
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3261
3594
|
let startTime;
|
|
3262
3595
|
if (this.debug) {
|
|
3263
3596
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3268,8 +3601,8 @@ class NftService {
|
|
|
3268
3601
|
"X-Requested-With": userAgent
|
|
3269
3602
|
}
|
|
3270
3603
|
}));
|
|
3271
|
-
debugOutput(response.url, response.status, startTime);
|
|
3272
|
-
if (response.status === 429) {
|
|
3604
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3605
|
+
if (response.status === null || response.status === 429) {
|
|
3273
3606
|
try {
|
|
3274
3607
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3275
3608
|
}
|
|
@@ -3278,7 +3611,7 @@ class NftService {
|
|
|
3278
3611
|
return {
|
|
3279
3612
|
data: null,
|
|
3280
3613
|
error: true,
|
|
3281
|
-
error_code: response.status,
|
|
3614
|
+
error_code: response.status ?? 429,
|
|
3282
3615
|
error_message: error.message
|
|
3283
3616
|
};
|
|
3284
3617
|
}
|
|
@@ -3323,6 +3656,14 @@ class NftService {
|
|
|
3323
3656
|
while (!success) {
|
|
3324
3657
|
try {
|
|
3325
3658
|
const urlParams = new URLSearchParams();
|
|
3659
|
+
if (!this.is_key_valid) {
|
|
3660
|
+
return {
|
|
3661
|
+
data: null,
|
|
3662
|
+
error: true,
|
|
3663
|
+
error_code: 401,
|
|
3664
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3326
3667
|
let startTime;
|
|
3327
3668
|
if (this.debug) {
|
|
3328
3669
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3333,8 +3674,8 @@ class NftService {
|
|
|
3333
3674
|
"X-Requested-With": userAgent
|
|
3334
3675
|
}
|
|
3335
3676
|
}));
|
|
3336
|
-
debugOutput(response.url, response.status, startTime);
|
|
3337
|
-
if (response.status === 429) {
|
|
3677
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3678
|
+
if (response.status === null || response.status === 429) {
|
|
3338
3679
|
try {
|
|
3339
3680
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3340
3681
|
}
|
|
@@ -3343,7 +3684,7 @@ class NftService {
|
|
|
3343
3684
|
return {
|
|
3344
3685
|
data: null,
|
|
3345
3686
|
error: true,
|
|
3346
|
-
error_code: response.status,
|
|
3687
|
+
error_code: response.status ?? 429,
|
|
3347
3688
|
error_message: error.message
|
|
3348
3689
|
};
|
|
3349
3690
|
}
|
|
@@ -3389,6 +3730,14 @@ class NftService {
|
|
|
3389
3730
|
while (!success) {
|
|
3390
3731
|
try {
|
|
3391
3732
|
const urlParams = new URLSearchParams();
|
|
3733
|
+
if (!this.is_key_valid) {
|
|
3734
|
+
return {
|
|
3735
|
+
data: null,
|
|
3736
|
+
error: true,
|
|
3737
|
+
error_code: 401,
|
|
3738
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3739
|
+
};
|
|
3740
|
+
}
|
|
3392
3741
|
let startTime;
|
|
3393
3742
|
if (this.debug) {
|
|
3394
3743
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3399,8 +3748,8 @@ class NftService {
|
|
|
3399
3748
|
"X-Requested-With": userAgent
|
|
3400
3749
|
}
|
|
3401
3750
|
}));
|
|
3402
|
-
debugOutput(response.url, response.status, startTime);
|
|
3403
|
-
if (response.status === 429) {
|
|
3751
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3752
|
+
if (response.status === null || response.status === 429) {
|
|
3404
3753
|
try {
|
|
3405
3754
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3406
3755
|
}
|
|
@@ -3409,7 +3758,7 @@ class NftService {
|
|
|
3409
3758
|
return {
|
|
3410
3759
|
data: null,
|
|
3411
3760
|
error: true,
|
|
3412
|
-
error_code: response.status,
|
|
3761
|
+
error_code: response.status ?? 429,
|
|
3413
3762
|
error_message: error.message
|
|
3414
3763
|
};
|
|
3415
3764
|
}
|
|
@@ -3456,6 +3805,14 @@ class NftService {
|
|
|
3456
3805
|
while (!success) {
|
|
3457
3806
|
try {
|
|
3458
3807
|
const urlParams = new URLSearchParams();
|
|
3808
|
+
if (!this.is_key_valid) {
|
|
3809
|
+
return {
|
|
3810
|
+
data: null,
|
|
3811
|
+
error: true,
|
|
3812
|
+
error_code: 401,
|
|
3813
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3814
|
+
};
|
|
3815
|
+
}
|
|
3459
3816
|
let startTime;
|
|
3460
3817
|
if (this.debug) {
|
|
3461
3818
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -3466,8 +3823,8 @@ class NftService {
|
|
|
3466
3823
|
"X-Requested-With": userAgent
|
|
3467
3824
|
}
|
|
3468
3825
|
}));
|
|
3469
|
-
debugOutput(response.url, response.status, startTime);
|
|
3470
|
-
if (response.status === 429) {
|
|
3826
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3827
|
+
if (response.status === null || response.status === 429) {
|
|
3471
3828
|
try {
|
|
3472
3829
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3473
3830
|
}
|
|
@@ -3476,7 +3833,7 @@ class NftService {
|
|
|
3476
3833
|
return {
|
|
3477
3834
|
data: null,
|
|
3478
3835
|
error: true,
|
|
3479
|
-
error_code: response.status,
|
|
3836
|
+
error_code: response.status ?? 429,
|
|
3480
3837
|
error_message: error.message
|
|
3481
3838
|
};
|
|
3482
3839
|
}
|
|
@@ -3524,6 +3881,14 @@ class NftService {
|
|
|
3524
3881
|
while (!success) {
|
|
3525
3882
|
try {
|
|
3526
3883
|
const urlParams = new URLSearchParams();
|
|
3884
|
+
if (!this.is_key_valid) {
|
|
3885
|
+
return {
|
|
3886
|
+
data: null,
|
|
3887
|
+
error: true,
|
|
3888
|
+
error_code: 401,
|
|
3889
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3890
|
+
};
|
|
3891
|
+
}
|
|
3527
3892
|
if (queryParamOpts?.days !== undefined) {
|
|
3528
3893
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3529
3894
|
}
|
|
@@ -3540,8 +3905,8 @@ class NftService {
|
|
|
3540
3905
|
"X-Requested-With": userAgent
|
|
3541
3906
|
}
|
|
3542
3907
|
}));
|
|
3543
|
-
debugOutput(response.url, response.status, startTime);
|
|
3544
|
-
if (response.status === 429) {
|
|
3908
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3909
|
+
if (response.status === null || response.status === 429) {
|
|
3545
3910
|
try {
|
|
3546
3911
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3547
3912
|
}
|
|
@@ -3550,7 +3915,7 @@ class NftService {
|
|
|
3550
3915
|
return {
|
|
3551
3916
|
data: null,
|
|
3552
3917
|
error: true,
|
|
3553
|
-
error_code: response.status,
|
|
3918
|
+
error_code: response.status ?? 429,
|
|
3554
3919
|
error_message: error.message
|
|
3555
3920
|
};
|
|
3556
3921
|
}
|
|
@@ -3598,6 +3963,14 @@ class NftService {
|
|
|
3598
3963
|
while (!success) {
|
|
3599
3964
|
try {
|
|
3600
3965
|
const urlParams = new URLSearchParams();
|
|
3966
|
+
if (!this.is_key_valid) {
|
|
3967
|
+
return {
|
|
3968
|
+
data: null,
|
|
3969
|
+
error: true,
|
|
3970
|
+
error_code: 401,
|
|
3971
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
3972
|
+
};
|
|
3973
|
+
}
|
|
3601
3974
|
if (queryParamOpts?.days !== undefined) {
|
|
3602
3975
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3603
3976
|
}
|
|
@@ -3614,8 +3987,8 @@ class NftService {
|
|
|
3614
3987
|
"X-Requested-With": userAgent
|
|
3615
3988
|
}
|
|
3616
3989
|
}));
|
|
3617
|
-
debugOutput(response.url, response.status, startTime);
|
|
3618
|
-
if (response.status === 429) {
|
|
3990
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
3991
|
+
if (response.status === null || response.status === 429) {
|
|
3619
3992
|
try {
|
|
3620
3993
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3621
3994
|
}
|
|
@@ -3624,7 +3997,7 @@ class NftService {
|
|
|
3624
3997
|
return {
|
|
3625
3998
|
data: null,
|
|
3626
3999
|
error: true,
|
|
3627
|
-
error_code: response.status,
|
|
4000
|
+
error_code: response.status ?? 429,
|
|
3628
4001
|
error_message: error.message
|
|
3629
4002
|
};
|
|
3630
4003
|
}
|
|
@@ -3672,6 +4045,14 @@ class NftService {
|
|
|
3672
4045
|
while (!success) {
|
|
3673
4046
|
try {
|
|
3674
4047
|
const urlParams = new URLSearchParams();
|
|
4048
|
+
if (!this.is_key_valid) {
|
|
4049
|
+
return {
|
|
4050
|
+
data: null,
|
|
4051
|
+
error: true,
|
|
4052
|
+
error_code: 401,
|
|
4053
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4054
|
+
};
|
|
4055
|
+
}
|
|
3675
4056
|
if (queryParamOpts?.days !== undefined) {
|
|
3676
4057
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
3677
4058
|
}
|
|
@@ -3688,8 +4069,8 @@ class NftService {
|
|
|
3688
4069
|
"X-Requested-With": userAgent
|
|
3689
4070
|
}
|
|
3690
4071
|
}));
|
|
3691
|
-
debugOutput(response.url, response.status, startTime);
|
|
3692
|
-
if (response.status === 429) {
|
|
4072
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4073
|
+
if (response.status === null || response.status === 429) {
|
|
3693
4074
|
try {
|
|
3694
4075
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3695
4076
|
}
|
|
@@ -3698,7 +4079,7 @@ class NftService {
|
|
|
3698
4079
|
return {
|
|
3699
4080
|
data: null,
|
|
3700
4081
|
error: true,
|
|
3701
|
-
error_code: response.status,
|
|
4082
|
+
error_code: response.status ?? 429,
|
|
3702
4083
|
error_message: error.message
|
|
3703
4084
|
};
|
|
3704
4085
|
}
|
|
@@ -3762,10 +4143,11 @@ let ContractMetadata$1 = class ContractMetadata {
|
|
|
3762
4143
|
}
|
|
3763
4144
|
};
|
|
3764
4145
|
class PricingService {
|
|
3765
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
4146
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
3766
4147
|
this.apiKey = apiKey;
|
|
3767
4148
|
this.debug = debug;
|
|
3768
4149
|
this.threadCount = threadCount;
|
|
4150
|
+
this.is_key_valid = is_key_valid;
|
|
3769
4151
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
3770
4152
|
}
|
|
3771
4153
|
/**
|
|
@@ -3789,6 +4171,14 @@ class PricingService {
|
|
|
3789
4171
|
while (!success) {
|
|
3790
4172
|
try {
|
|
3791
4173
|
const urlParams = new URLSearchParams();
|
|
4174
|
+
if (!this.is_key_valid) {
|
|
4175
|
+
return {
|
|
4176
|
+
data: null,
|
|
4177
|
+
error: true,
|
|
4178
|
+
error_code: 401,
|
|
4179
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4180
|
+
};
|
|
4181
|
+
}
|
|
3792
4182
|
if (queryParamOpts?.from !== undefined) {
|
|
3793
4183
|
urlParams.append("from", queryParamOpts?.from.toString());
|
|
3794
4184
|
}
|
|
@@ -3808,8 +4198,8 @@ class PricingService {
|
|
|
3808
4198
|
"X-Requested-With": userAgent
|
|
3809
4199
|
}
|
|
3810
4200
|
}));
|
|
3811
|
-
debugOutput(response.url, response.status, startTime);
|
|
3812
|
-
if (response.status === 429) {
|
|
4201
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4202
|
+
if (response.status === null || response.status === 429) {
|
|
3813
4203
|
try {
|
|
3814
4204
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
3815
4205
|
}
|
|
@@ -3818,7 +4208,7 @@ class PricingService {
|
|
|
3818
4208
|
return {
|
|
3819
4209
|
data: null,
|
|
3820
4210
|
error: true,
|
|
3821
|
-
error_code: response.status,
|
|
4211
|
+
error_code: response.status ?? 429,
|
|
3822
4212
|
error_message: error.message
|
|
3823
4213
|
};
|
|
3824
4214
|
}
|
|
@@ -3886,9 +4276,9 @@ class Transaction {
|
|
|
3886
4276
|
this.gas_quote_rate = data.gas_quote_rate;
|
|
3887
4277
|
this.gas_metadata = data.gas_metadata && data.gas_metadata !== null ? new ContractMetadata(data.gas_metadata) : null;
|
|
3888
4278
|
this.explorers = data.explorers && data.explorers !== null ? data.explorers.map((itemData) => new Explorer(itemData)) : null;
|
|
3889
|
-
this.dex_details = data.dex_details && data.dex_details !== null ? new DexReport(
|
|
3890
|
-
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? new NftSalesReport(
|
|
3891
|
-
this.lending_details = data.lending_details && data.lending_details !== null ? new LendingReport(
|
|
4279
|
+
this.dex_details = data.dex_details && data.dex_details !== null ? data.dex_details.map((itemData) => new DexReport(itemData)) : null;
|
|
4280
|
+
this.nft_sale_details = data.nft_sale_details && data.nft_sale_details !== null ? data.nft_sale_details.map((itemData) => new NftSalesReport(itemData)) : null;
|
|
4281
|
+
this.lending_details = data.lending_details && data.lending_details !== null ? data.lending_details.map((itemData) => new LendingReport(itemData)) : null;
|
|
3892
4282
|
this.log_events = data.log_events && data.log_events !== null ? data.log_events.map((itemData) => new LogEvent(itemData)) : null;
|
|
3893
4283
|
this.safe_details = data.safe_details && data.safe_details !== null ? data.safe_details.map((itemData) => new SafeDetails(itemData)) : null;
|
|
3894
4284
|
}
|
|
@@ -4108,8 +4498,8 @@ class RecentTransactionsResponse {
|
|
|
4108
4498
|
"X-Requested-With": userAgent
|
|
4109
4499
|
}
|
|
4110
4500
|
}));
|
|
4111
|
-
debugOutput(response.url, response.status, startTime);
|
|
4112
|
-
if (response.status === 429) {
|
|
4501
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4502
|
+
if (response.status === null || response.status === 429) {
|
|
4113
4503
|
try {
|
|
4114
4504
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4115
4505
|
}
|
|
@@ -4118,7 +4508,7 @@ class RecentTransactionsResponse {
|
|
|
4118
4508
|
return {
|
|
4119
4509
|
data: null,
|
|
4120
4510
|
error: true,
|
|
4121
|
-
error_code: response.status,
|
|
4511
|
+
error_code: response.status ?? 429,
|
|
4122
4512
|
error_message: error.message
|
|
4123
4513
|
};
|
|
4124
4514
|
}
|
|
@@ -4174,8 +4564,8 @@ class RecentTransactionsResponse {
|
|
|
4174
4564
|
"X-Requested-With": userAgent
|
|
4175
4565
|
}
|
|
4176
4566
|
}));
|
|
4177
|
-
debugOutput(response.url, response.status, startTime);
|
|
4178
|
-
if (response.status === 429) {
|
|
4567
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4568
|
+
if (response.status === null || response.status === 429) {
|
|
4179
4569
|
try {
|
|
4180
4570
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4181
4571
|
}
|
|
@@ -4184,7 +4574,7 @@ class RecentTransactionsResponse {
|
|
|
4184
4574
|
return {
|
|
4185
4575
|
data: null,
|
|
4186
4576
|
error: true,
|
|
4187
|
-
error_code: response.status,
|
|
4577
|
+
error_code: response.status ?? 429,
|
|
4188
4578
|
error_message: error.message
|
|
4189
4579
|
};
|
|
4190
4580
|
}
|
|
@@ -4293,8 +4683,8 @@ class TransactionsResponse {
|
|
|
4293
4683
|
"X-Requested-With": userAgent
|
|
4294
4684
|
}
|
|
4295
4685
|
}));
|
|
4296
|
-
debugOutput(response.url, response.status, startTime);
|
|
4297
|
-
if (response.status === 429) {
|
|
4686
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4687
|
+
if (response.status === null || response.status === 429) {
|
|
4298
4688
|
try {
|
|
4299
4689
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4300
4690
|
}
|
|
@@ -4303,7 +4693,7 @@ class TransactionsResponse {
|
|
|
4303
4693
|
return {
|
|
4304
4694
|
data: null,
|
|
4305
4695
|
error: true,
|
|
4306
|
-
error_code: response.status,
|
|
4696
|
+
error_code: response.status ?? 429,
|
|
4307
4697
|
error_message: error.message
|
|
4308
4698
|
};
|
|
4309
4699
|
}
|
|
@@ -4359,8 +4749,8 @@ class TransactionsResponse {
|
|
|
4359
4749
|
"X-Requested-With": userAgent
|
|
4360
4750
|
}
|
|
4361
4751
|
}));
|
|
4362
|
-
debugOutput(response.url, response.status, startTime);
|
|
4363
|
-
if (response.status === 429) {
|
|
4752
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4753
|
+
if (response.status === null || response.status === 429) {
|
|
4364
4754
|
try {
|
|
4365
4755
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4366
4756
|
}
|
|
@@ -4369,7 +4759,7 @@ class TransactionsResponse {
|
|
|
4369
4759
|
return {
|
|
4370
4760
|
data: null,
|
|
4371
4761
|
error: true,
|
|
4372
|
-
error_code: response.status,
|
|
4762
|
+
error_code: response.status ?? 429,
|
|
4373
4763
|
error_message: error.message
|
|
4374
4764
|
};
|
|
4375
4765
|
}
|
|
@@ -4421,8 +4811,8 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
4421
4811
|
"X-Requested-With": userAgent
|
|
4422
4812
|
}
|
|
4423
4813
|
}));
|
|
4424
|
-
debugOutput(response.url, response.status, startTime);
|
|
4425
|
-
if (response.status === 429) {
|
|
4814
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4815
|
+
if (response.status === null || response.status === 429) {
|
|
4426
4816
|
try {
|
|
4427
4817
|
data = await LIMIT(() => backoff.backOff(response.url));
|
|
4428
4818
|
}
|
|
@@ -4460,10 +4850,11 @@ async function* paginateEndpoint(url, apiKey, urlsParams, debug, threadCount) {
|
|
|
4460
4850
|
}
|
|
4461
4851
|
}
|
|
4462
4852
|
class TransactionService {
|
|
4463
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
4853
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
4464
4854
|
this.apiKey = apiKey;
|
|
4465
4855
|
this.debug = debug;
|
|
4466
4856
|
this.threadCount = threadCount;
|
|
4857
|
+
this.is_key_valid = is_key_valid;
|
|
4467
4858
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
4468
4859
|
}
|
|
4469
4860
|
/**
|
|
@@ -4489,6 +4880,14 @@ class TransactionService {
|
|
|
4489
4880
|
while (!success) {
|
|
4490
4881
|
try {
|
|
4491
4882
|
const urlParams = new URLSearchParams();
|
|
4883
|
+
if (!this.is_key_valid) {
|
|
4884
|
+
return {
|
|
4885
|
+
data: null,
|
|
4886
|
+
error: true,
|
|
4887
|
+
error_code: 401,
|
|
4888
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
4889
|
+
};
|
|
4890
|
+
}
|
|
4492
4891
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4493
4892
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4494
4893
|
}
|
|
@@ -4517,8 +4916,8 @@ class TransactionService {
|
|
|
4517
4916
|
"X-Requested-With": userAgent
|
|
4518
4917
|
}
|
|
4519
4918
|
}));
|
|
4520
|
-
debugOutput(response.url, response.status, startTime);
|
|
4521
|
-
if (response.status === 429) {
|
|
4919
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
4920
|
+
if (response.status === null || response.status === 429) {
|
|
4522
4921
|
try {
|
|
4523
4922
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4524
4923
|
}
|
|
@@ -4527,7 +4926,7 @@ class TransactionService {
|
|
|
4527
4926
|
return {
|
|
4528
4927
|
data: null,
|
|
4529
4928
|
error: true,
|
|
4530
|
-
error_code: response.status,
|
|
4929
|
+
error_code: response.status ?? 429,
|
|
4531
4930
|
error_message: error.message
|
|
4532
4931
|
};
|
|
4533
4932
|
}
|
|
@@ -4575,6 +4974,9 @@ class TransactionService {
|
|
|
4575
4974
|
while (!success) {
|
|
4576
4975
|
try {
|
|
4577
4976
|
const urlParams = new URLSearchParams();
|
|
4977
|
+
if (!this.is_key_valid) {
|
|
4978
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
4979
|
+
}
|
|
4578
4980
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4579
4981
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4580
4982
|
}
|
|
@@ -4619,6 +5021,14 @@ class TransactionService {
|
|
|
4619
5021
|
while (!success) {
|
|
4620
5022
|
try {
|
|
4621
5023
|
const urlParams = new URLSearchParams();
|
|
5024
|
+
if (!this.is_key_valid) {
|
|
5025
|
+
return {
|
|
5026
|
+
data: null,
|
|
5027
|
+
error: true,
|
|
5028
|
+
error_code: 401,
|
|
5029
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5030
|
+
};
|
|
5031
|
+
}
|
|
4622
5032
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4623
5033
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4624
5034
|
}
|
|
@@ -4641,8 +5051,8 @@ class TransactionService {
|
|
|
4641
5051
|
"X-Requested-With": userAgent
|
|
4642
5052
|
}
|
|
4643
5053
|
}));
|
|
4644
|
-
debugOutput(response.url, response.status, startTime);
|
|
4645
|
-
if (response.status === 429) {
|
|
5054
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5055
|
+
if (response.status === null || response.status === 429) {
|
|
4646
5056
|
try {
|
|
4647
5057
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4648
5058
|
}
|
|
@@ -4651,7 +5061,7 @@ class TransactionService {
|
|
|
4651
5061
|
return {
|
|
4652
5062
|
data: null,
|
|
4653
5063
|
error: true,
|
|
4654
|
-
error_code: response.status,
|
|
5064
|
+
error_code: response.status ?? 429,
|
|
4655
5065
|
error_message: error.message
|
|
4656
5066
|
};
|
|
4657
5067
|
}
|
|
@@ -4700,6 +5110,14 @@ class TransactionService {
|
|
|
4700
5110
|
while (!success) {
|
|
4701
5111
|
try {
|
|
4702
5112
|
const urlParams = new URLSearchParams();
|
|
5113
|
+
if (!this.is_key_valid) {
|
|
5114
|
+
return {
|
|
5115
|
+
data: null,
|
|
5116
|
+
error: true,
|
|
5117
|
+
error_code: 401,
|
|
5118
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5119
|
+
};
|
|
5120
|
+
}
|
|
4703
5121
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4704
5122
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4705
5123
|
}
|
|
@@ -4719,8 +5137,8 @@ class TransactionService {
|
|
|
4719
5137
|
"X-Requested-With": userAgent
|
|
4720
5138
|
}
|
|
4721
5139
|
}));
|
|
4722
|
-
debugOutput(response.url, response.status, startTime);
|
|
4723
|
-
if (response.status === 429) {
|
|
5140
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5141
|
+
if (response.status === null || response.status === 429) {
|
|
4724
5142
|
try {
|
|
4725
5143
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4726
5144
|
}
|
|
@@ -4729,7 +5147,7 @@ class TransactionService {
|
|
|
4729
5147
|
return {
|
|
4730
5148
|
data: null,
|
|
4731
5149
|
error: true,
|
|
4732
|
-
error_code: response.status,
|
|
5150
|
+
error_code: response.status ?? 429,
|
|
4733
5151
|
error_message: error.message
|
|
4734
5152
|
};
|
|
4735
5153
|
}
|
|
@@ -4774,6 +5192,14 @@ class TransactionService {
|
|
|
4774
5192
|
while (!success) {
|
|
4775
5193
|
try {
|
|
4776
5194
|
const urlParams = new URLSearchParams();
|
|
5195
|
+
if (!this.is_key_valid) {
|
|
5196
|
+
return {
|
|
5197
|
+
data: null,
|
|
5198
|
+
error: true,
|
|
5199
|
+
error_code: 401,
|
|
5200
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5201
|
+
};
|
|
5202
|
+
}
|
|
4777
5203
|
let startTime;
|
|
4778
5204
|
if (this.debug) {
|
|
4779
5205
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -4784,8 +5210,8 @@ class TransactionService {
|
|
|
4784
5210
|
"X-Requested-With": userAgent
|
|
4785
5211
|
}
|
|
4786
5212
|
}));
|
|
4787
|
-
debugOutput(response.url, response.status, startTime);
|
|
4788
|
-
if (response.status === 429) {
|
|
5213
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5214
|
+
if (response.status === null || response.status === 429) {
|
|
4789
5215
|
try {
|
|
4790
5216
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4791
5217
|
}
|
|
@@ -4794,7 +5220,7 @@ class TransactionService {
|
|
|
4794
5220
|
return {
|
|
4795
5221
|
data: null,
|
|
4796
5222
|
error: true,
|
|
4797
|
-
error_code: response.status,
|
|
5223
|
+
error_code: response.status ?? 429,
|
|
4798
5224
|
error_message: error.message
|
|
4799
5225
|
};
|
|
4800
5226
|
}
|
|
@@ -4843,6 +5269,14 @@ class TransactionService {
|
|
|
4843
5269
|
while (!success) {
|
|
4844
5270
|
try {
|
|
4845
5271
|
const urlParams = new URLSearchParams();
|
|
5272
|
+
if (!this.is_key_valid) {
|
|
5273
|
+
return {
|
|
5274
|
+
data: null,
|
|
5275
|
+
error: true,
|
|
5276
|
+
error_code: 401,
|
|
5277
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5278
|
+
};
|
|
5279
|
+
}
|
|
4846
5280
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
4847
5281
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
4848
5282
|
}
|
|
@@ -4865,8 +5299,8 @@ class TransactionService {
|
|
|
4865
5299
|
"X-Requested-With": userAgent
|
|
4866
5300
|
}
|
|
4867
5301
|
});
|
|
4868
|
-
debugOutput(response.url, response.status, startTime);
|
|
4869
|
-
if (response.status === 429) {
|
|
5302
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5303
|
+
if (response.status === null || response.status === 429) {
|
|
4870
5304
|
try {
|
|
4871
5305
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
4872
5306
|
}
|
|
@@ -4875,7 +5309,7 @@ class TransactionService {
|
|
|
4875
5309
|
return {
|
|
4876
5310
|
data: null,
|
|
4877
5311
|
error: true,
|
|
4878
|
-
error_code: response.status,
|
|
5312
|
+
error_code: response.status ?? 429,
|
|
4879
5313
|
error_message: error.message
|
|
4880
5314
|
};
|
|
4881
5315
|
}
|
|
@@ -5304,10 +5738,11 @@ class HealthData {
|
|
|
5304
5738
|
*
|
|
5305
5739
|
*/
|
|
5306
5740
|
class XykService {
|
|
5307
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
5741
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
5308
5742
|
this.apiKey = apiKey;
|
|
5309
5743
|
this.debug = debug;
|
|
5310
5744
|
this.threadCount = threadCount;
|
|
5745
|
+
this.is_key_valid = is_key_valid;
|
|
5311
5746
|
this.LIMIT = pLimit$1(this.threadCount);
|
|
5312
5747
|
}
|
|
5313
5748
|
/**
|
|
@@ -5326,6 +5761,14 @@ class XykService {
|
|
|
5326
5761
|
while (!success) {
|
|
5327
5762
|
try {
|
|
5328
5763
|
const urlParams = new URLSearchParams();
|
|
5764
|
+
if (!this.is_key_valid) {
|
|
5765
|
+
return {
|
|
5766
|
+
data: null,
|
|
5767
|
+
error: true,
|
|
5768
|
+
error_code: 401,
|
|
5769
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5770
|
+
};
|
|
5771
|
+
}
|
|
5329
5772
|
let startTime;
|
|
5330
5773
|
if (this.debug) {
|
|
5331
5774
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5336,8 +5779,8 @@ class XykService {
|
|
|
5336
5779
|
"X-Requested-With": userAgent
|
|
5337
5780
|
}
|
|
5338
5781
|
}));
|
|
5339
|
-
debugOutput(response.url, response.status, startTime);
|
|
5340
|
-
if (response.status === 429) {
|
|
5782
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5783
|
+
if (response.status === null || response.status === 429) {
|
|
5341
5784
|
try {
|
|
5342
5785
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5343
5786
|
}
|
|
@@ -5346,7 +5789,7 @@ class XykService {
|
|
|
5346
5789
|
return {
|
|
5347
5790
|
data: null,
|
|
5348
5791
|
error: true,
|
|
5349
|
-
error_code: response.status,
|
|
5792
|
+
error_code: response.status ?? 429,
|
|
5350
5793
|
error_message: error.message
|
|
5351
5794
|
};
|
|
5352
5795
|
}
|
|
@@ -5391,6 +5834,14 @@ class XykService {
|
|
|
5391
5834
|
while (!success) {
|
|
5392
5835
|
try {
|
|
5393
5836
|
const urlParams = new URLSearchParams();
|
|
5837
|
+
if (!this.is_key_valid) {
|
|
5838
|
+
return {
|
|
5839
|
+
data: null,
|
|
5840
|
+
error: true,
|
|
5841
|
+
error_code: 401,
|
|
5842
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5843
|
+
};
|
|
5844
|
+
}
|
|
5394
5845
|
let startTime;
|
|
5395
5846
|
if (this.debug) {
|
|
5396
5847
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5401,8 +5852,8 @@ class XykService {
|
|
|
5401
5852
|
"X-Requested-With": userAgent
|
|
5402
5853
|
}
|
|
5403
5854
|
}));
|
|
5404
|
-
debugOutput(response.url, response.status, startTime);
|
|
5405
|
-
if (response.status === 429) {
|
|
5855
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5856
|
+
if (response.status === null || response.status === 429) {
|
|
5406
5857
|
try {
|
|
5407
5858
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5408
5859
|
}
|
|
@@ -5411,7 +5862,7 @@ class XykService {
|
|
|
5411
5862
|
return {
|
|
5412
5863
|
data: null,
|
|
5413
5864
|
error: true,
|
|
5414
|
-
error_code: response.status,
|
|
5865
|
+
error_code: response.status ?? 429,
|
|
5415
5866
|
error_message: error.message
|
|
5416
5867
|
};
|
|
5417
5868
|
}
|
|
@@ -5457,6 +5908,14 @@ class XykService {
|
|
|
5457
5908
|
while (!success) {
|
|
5458
5909
|
try {
|
|
5459
5910
|
const urlParams = new URLSearchParams();
|
|
5911
|
+
if (!this.is_key_valid) {
|
|
5912
|
+
return {
|
|
5913
|
+
data: null,
|
|
5914
|
+
error: true,
|
|
5915
|
+
error_code: 401,
|
|
5916
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5917
|
+
};
|
|
5918
|
+
}
|
|
5460
5919
|
let startTime;
|
|
5461
5920
|
if (this.debug) {
|
|
5462
5921
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5467,8 +5926,8 @@ class XykService {
|
|
|
5467
5926
|
"X-Requested-With": userAgent
|
|
5468
5927
|
}
|
|
5469
5928
|
}));
|
|
5470
|
-
debugOutput(response.url, response.status, startTime);
|
|
5471
|
-
if (response.status === 429) {
|
|
5929
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
5930
|
+
if (response.status === null || response.status === 429) {
|
|
5472
5931
|
try {
|
|
5473
5932
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5474
5933
|
}
|
|
@@ -5477,7 +5936,7 @@ class XykService {
|
|
|
5477
5936
|
return {
|
|
5478
5937
|
data: null,
|
|
5479
5938
|
error: true,
|
|
5480
|
-
error_code: response.status,
|
|
5939
|
+
error_code: response.status ?? 429,
|
|
5481
5940
|
error_message: error.message
|
|
5482
5941
|
};
|
|
5483
5942
|
}
|
|
@@ -5525,6 +5984,14 @@ class XykService {
|
|
|
5525
5984
|
while (!success) {
|
|
5526
5985
|
try {
|
|
5527
5986
|
const urlParams = new URLSearchParams();
|
|
5987
|
+
if (!this.is_key_valid) {
|
|
5988
|
+
return {
|
|
5989
|
+
data: null,
|
|
5990
|
+
error: true,
|
|
5991
|
+
error_code: 401,
|
|
5992
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
5993
|
+
};
|
|
5994
|
+
}
|
|
5528
5995
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
5529
5996
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
5530
5997
|
}
|
|
@@ -5541,8 +6008,8 @@ class XykService {
|
|
|
5541
6008
|
"X-Requested-With": userAgent
|
|
5542
6009
|
}
|
|
5543
6010
|
}));
|
|
5544
|
-
debugOutput(response.url, response.status, startTime);
|
|
5545
|
-
if (response.status === 429) {
|
|
6011
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6012
|
+
if (response.status === null || response.status === 429) {
|
|
5546
6013
|
try {
|
|
5547
6014
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5548
6015
|
}
|
|
@@ -5551,7 +6018,7 @@ class XykService {
|
|
|
5551
6018
|
return {
|
|
5552
6019
|
data: null,
|
|
5553
6020
|
error: true,
|
|
5554
|
-
error_code: response.status,
|
|
6021
|
+
error_code: response.status ?? 429,
|
|
5555
6022
|
error_message: error.message
|
|
5556
6023
|
};
|
|
5557
6024
|
}
|
|
@@ -5597,6 +6064,14 @@ class XykService {
|
|
|
5597
6064
|
while (!success) {
|
|
5598
6065
|
try {
|
|
5599
6066
|
const urlParams = new URLSearchParams();
|
|
6067
|
+
if (!this.is_key_valid) {
|
|
6068
|
+
return {
|
|
6069
|
+
data: null,
|
|
6070
|
+
error: true,
|
|
6071
|
+
error_code: 401,
|
|
6072
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6073
|
+
};
|
|
6074
|
+
}
|
|
5600
6075
|
let startTime;
|
|
5601
6076
|
if (this.debug) {
|
|
5602
6077
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5607,8 +6082,8 @@ class XykService {
|
|
|
5607
6082
|
"X-Requested-With": userAgent
|
|
5608
6083
|
}
|
|
5609
6084
|
}));
|
|
5610
|
-
debugOutput(response.url, response.status, startTime);
|
|
5611
|
-
if (response.status === 429) {
|
|
6085
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6086
|
+
if (response.status === null || response.status === 429) {
|
|
5612
6087
|
try {
|
|
5613
6088
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5614
6089
|
}
|
|
@@ -5617,7 +6092,7 @@ class XykService {
|
|
|
5617
6092
|
return {
|
|
5618
6093
|
data: null,
|
|
5619
6094
|
error: true,
|
|
5620
|
-
error_code: response.status,
|
|
6095
|
+
error_code: response.status ?? 429,
|
|
5621
6096
|
error_message: error.message
|
|
5622
6097
|
};
|
|
5623
6098
|
}
|
|
@@ -5666,6 +6141,14 @@ class XykService {
|
|
|
5666
6141
|
while (!success) {
|
|
5667
6142
|
try {
|
|
5668
6143
|
const urlParams = new URLSearchParams();
|
|
6144
|
+
if (!this.is_key_valid) {
|
|
6145
|
+
return {
|
|
6146
|
+
data: null,
|
|
6147
|
+
error: true,
|
|
6148
|
+
error_code: 401,
|
|
6149
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6150
|
+
};
|
|
6151
|
+
}
|
|
5669
6152
|
if (queryParamOpts?.tokenAddress !== undefined) {
|
|
5670
6153
|
urlParams.append("token-address", queryParamOpts?.tokenAddress.toString());
|
|
5671
6154
|
}
|
|
@@ -5685,8 +6168,8 @@ class XykService {
|
|
|
5685
6168
|
"X-Requested-With": userAgent
|
|
5686
6169
|
}
|
|
5687
6170
|
}));
|
|
5688
|
-
debugOutput(response.url, response.status, startTime);
|
|
5689
|
-
if (response.status === 429) {
|
|
6171
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6172
|
+
if (response.status === null || response.status === 429) {
|
|
5690
6173
|
try {
|
|
5691
6174
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5692
6175
|
}
|
|
@@ -5695,7 +6178,7 @@ class XykService {
|
|
|
5695
6178
|
return {
|
|
5696
6179
|
data: null,
|
|
5697
6180
|
error: true,
|
|
5698
|
-
error_code: response.status,
|
|
6181
|
+
error_code: response.status ?? 429,
|
|
5699
6182
|
error_message: error.message
|
|
5700
6183
|
};
|
|
5701
6184
|
}
|
|
@@ -5740,6 +6223,14 @@ class XykService {
|
|
|
5740
6223
|
while (!success) {
|
|
5741
6224
|
try {
|
|
5742
6225
|
const urlParams = new URLSearchParams();
|
|
6226
|
+
if (!this.is_key_valid) {
|
|
6227
|
+
return {
|
|
6228
|
+
data: null,
|
|
6229
|
+
error: true,
|
|
6230
|
+
error_code: 401,
|
|
6231
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6232
|
+
};
|
|
6233
|
+
}
|
|
5743
6234
|
let startTime;
|
|
5744
6235
|
if (this.debug) {
|
|
5745
6236
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5750,8 +6241,8 @@ class XykService {
|
|
|
5750
6241
|
"X-Requested-With": userAgent
|
|
5751
6242
|
}
|
|
5752
6243
|
}));
|
|
5753
|
-
debugOutput(response.url, response.status, startTime);
|
|
5754
|
-
if (response.status === 429) {
|
|
6244
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6245
|
+
if (response.status === null || response.status === 429) {
|
|
5755
6246
|
try {
|
|
5756
6247
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5757
6248
|
}
|
|
@@ -5760,7 +6251,7 @@ class XykService {
|
|
|
5760
6251
|
return {
|
|
5761
6252
|
data: null,
|
|
5762
6253
|
error: true,
|
|
5763
|
-
error_code: response.status,
|
|
6254
|
+
error_code: response.status ?? 429,
|
|
5764
6255
|
error_message: error.message
|
|
5765
6256
|
};
|
|
5766
6257
|
}
|
|
@@ -5803,6 +6294,14 @@ class XykService {
|
|
|
5803
6294
|
while (!success) {
|
|
5804
6295
|
try {
|
|
5805
6296
|
const urlParams = new URLSearchParams();
|
|
6297
|
+
if (!this.is_key_valid) {
|
|
6298
|
+
return {
|
|
6299
|
+
data: null,
|
|
6300
|
+
error: true,
|
|
6301
|
+
error_code: 401,
|
|
6302
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6303
|
+
};
|
|
6304
|
+
}
|
|
5806
6305
|
let startTime;
|
|
5807
6306
|
if (this.debug) {
|
|
5808
6307
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5813,8 +6312,8 @@ class XykService {
|
|
|
5813
6312
|
"X-Requested-With": userAgent
|
|
5814
6313
|
}
|
|
5815
6314
|
}));
|
|
5816
|
-
debugOutput(response.url, response.status, startTime);
|
|
5817
|
-
if (response.status === 429) {
|
|
6315
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6316
|
+
if (response.status === null || response.status === 429) {
|
|
5818
6317
|
try {
|
|
5819
6318
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5820
6319
|
}
|
|
@@ -5823,7 +6322,7 @@ class XykService {
|
|
|
5823
6322
|
return {
|
|
5824
6323
|
data: null,
|
|
5825
6324
|
error: true,
|
|
5826
|
-
error_code: response.status,
|
|
6325
|
+
error_code: response.status ?? 429,
|
|
5827
6326
|
error_message: error.message
|
|
5828
6327
|
};
|
|
5829
6328
|
}
|
|
@@ -5869,6 +6368,14 @@ class XykService {
|
|
|
5869
6368
|
while (!success) {
|
|
5870
6369
|
try {
|
|
5871
6370
|
const urlParams = new URLSearchParams();
|
|
6371
|
+
if (!this.is_key_valid) {
|
|
6372
|
+
return {
|
|
6373
|
+
data: null,
|
|
6374
|
+
error: true,
|
|
6375
|
+
error_code: 401,
|
|
6376
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6377
|
+
};
|
|
6378
|
+
}
|
|
5872
6379
|
let startTime;
|
|
5873
6380
|
if (this.debug) {
|
|
5874
6381
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5879,8 +6386,8 @@ class XykService {
|
|
|
5879
6386
|
"X-Requested-With": userAgent
|
|
5880
6387
|
}
|
|
5881
6388
|
}));
|
|
5882
|
-
debugOutput(response.url, response.status, startTime);
|
|
5883
|
-
if (response.status === 429) {
|
|
6389
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6390
|
+
if (response.status === null || response.status === 429) {
|
|
5884
6391
|
try {
|
|
5885
6392
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5886
6393
|
}
|
|
@@ -5889,7 +6396,7 @@ class XykService {
|
|
|
5889
6396
|
return {
|
|
5890
6397
|
data: null,
|
|
5891
6398
|
error: true,
|
|
5892
|
-
error_code: response.status,
|
|
6399
|
+
error_code: response.status ?? 429,
|
|
5893
6400
|
error_message: error.message
|
|
5894
6401
|
};
|
|
5895
6402
|
}
|
|
@@ -5935,6 +6442,14 @@ class XykService {
|
|
|
5935
6442
|
while (!success) {
|
|
5936
6443
|
try {
|
|
5937
6444
|
const urlParams = new URLSearchParams();
|
|
6445
|
+
if (!this.is_key_valid) {
|
|
6446
|
+
return {
|
|
6447
|
+
data: null,
|
|
6448
|
+
error: true,
|
|
6449
|
+
error_code: 401,
|
|
6450
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6451
|
+
};
|
|
6452
|
+
}
|
|
5938
6453
|
let startTime;
|
|
5939
6454
|
if (this.debug) {
|
|
5940
6455
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -5945,8 +6460,8 @@ class XykService {
|
|
|
5945
6460
|
"X-Requested-With": userAgent
|
|
5946
6461
|
}
|
|
5947
6462
|
}));
|
|
5948
|
-
debugOutput(response.url, response.status, startTime);
|
|
5949
|
-
if (response.status === 429) {
|
|
6463
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6464
|
+
if (response.status === null || response.status === 429) {
|
|
5950
6465
|
try {
|
|
5951
6466
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
5952
6467
|
}
|
|
@@ -5955,7 +6470,7 @@ class XykService {
|
|
|
5955
6470
|
return {
|
|
5956
6471
|
data: null,
|
|
5957
6472
|
error: true,
|
|
5958
|
-
error_code: response.status,
|
|
6473
|
+
error_code: response.status ?? 429,
|
|
5959
6474
|
error_message: error.message
|
|
5960
6475
|
};
|
|
5961
6476
|
}
|
|
@@ -6001,6 +6516,14 @@ class XykService {
|
|
|
6001
6516
|
while (!success) {
|
|
6002
6517
|
try {
|
|
6003
6518
|
const urlParams = new URLSearchParams();
|
|
6519
|
+
if (!this.is_key_valid) {
|
|
6520
|
+
return {
|
|
6521
|
+
data: null,
|
|
6522
|
+
error: true,
|
|
6523
|
+
error_code: 401,
|
|
6524
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6525
|
+
};
|
|
6526
|
+
}
|
|
6004
6527
|
let startTime;
|
|
6005
6528
|
if (this.debug) {
|
|
6006
6529
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6011,8 +6534,8 @@ class XykService {
|
|
|
6011
6534
|
"X-Requested-With": userAgent
|
|
6012
6535
|
}
|
|
6013
6536
|
}));
|
|
6014
|
-
debugOutput(response.url, response.status, startTime);
|
|
6015
|
-
if (response.status === 429) {
|
|
6537
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6538
|
+
if (response.status === null || response.status === 429) {
|
|
6016
6539
|
try {
|
|
6017
6540
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6018
6541
|
}
|
|
@@ -6021,7 +6544,7 @@ class XykService {
|
|
|
6021
6544
|
return {
|
|
6022
6545
|
data: null,
|
|
6023
6546
|
error: true,
|
|
6024
|
-
error_code: response.status,
|
|
6547
|
+
error_code: response.status ?? 429,
|
|
6025
6548
|
error_message: error.message
|
|
6026
6549
|
};
|
|
6027
6550
|
}
|
|
@@ -6067,6 +6590,14 @@ class XykService {
|
|
|
6067
6590
|
while (!success) {
|
|
6068
6591
|
try {
|
|
6069
6592
|
const urlParams = new URLSearchParams();
|
|
6593
|
+
if (!this.is_key_valid) {
|
|
6594
|
+
return {
|
|
6595
|
+
data: null,
|
|
6596
|
+
error: true,
|
|
6597
|
+
error_code: 401,
|
|
6598
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6599
|
+
};
|
|
6600
|
+
}
|
|
6070
6601
|
let startTime;
|
|
6071
6602
|
if (this.debug) {
|
|
6072
6603
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6077,8 +6608,8 @@ class XykService {
|
|
|
6077
6608
|
"X-Requested-With": userAgent
|
|
6078
6609
|
}
|
|
6079
6610
|
}));
|
|
6080
|
-
debugOutput(response.url, response.status, startTime);
|
|
6081
|
-
if (response.status === 429) {
|
|
6611
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6612
|
+
if (response.status === null || response.status === 429) {
|
|
6082
6613
|
try {
|
|
6083
6614
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6084
6615
|
}
|
|
@@ -6087,7 +6618,7 @@ class XykService {
|
|
|
6087
6618
|
return {
|
|
6088
6619
|
data: null,
|
|
6089
6620
|
error: true,
|
|
6090
|
-
error_code: response.status,
|
|
6621
|
+
error_code: response.status ?? 429,
|
|
6091
6622
|
error_message: error.message
|
|
6092
6623
|
};
|
|
6093
6624
|
}
|
|
@@ -6132,6 +6663,14 @@ class XykService {
|
|
|
6132
6663
|
while (!success) {
|
|
6133
6664
|
try {
|
|
6134
6665
|
const urlParams = new URLSearchParams();
|
|
6666
|
+
if (!this.is_key_valid) {
|
|
6667
|
+
return {
|
|
6668
|
+
data: null,
|
|
6669
|
+
error: true,
|
|
6670
|
+
error_code: 401,
|
|
6671
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6672
|
+
};
|
|
6673
|
+
}
|
|
6135
6674
|
let startTime;
|
|
6136
6675
|
if (this.debug) {
|
|
6137
6676
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6142,8 +6681,8 @@ class XykService {
|
|
|
6142
6681
|
"X-Requested-With": userAgent
|
|
6143
6682
|
}
|
|
6144
6683
|
}));
|
|
6145
|
-
debugOutput(response.url, response.status, startTime);
|
|
6146
|
-
if (response.status === 429) {
|
|
6684
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6685
|
+
if (response.status === null || response.status === 429) {
|
|
6147
6686
|
try {
|
|
6148
6687
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6149
6688
|
}
|
|
@@ -6152,7 +6691,7 @@ class XykService {
|
|
|
6152
6691
|
return {
|
|
6153
6692
|
data: null,
|
|
6154
6693
|
error: true,
|
|
6155
|
-
error_code: response.status,
|
|
6694
|
+
error_code: response.status ?? 429,
|
|
6156
6695
|
error_message: error.message
|
|
6157
6696
|
};
|
|
6158
6697
|
}
|
|
@@ -6197,6 +6736,14 @@ class XykService {
|
|
|
6197
6736
|
while (!success) {
|
|
6198
6737
|
try {
|
|
6199
6738
|
const urlParams = new URLSearchParams();
|
|
6739
|
+
if (!this.is_key_valid) {
|
|
6740
|
+
return {
|
|
6741
|
+
data: null,
|
|
6742
|
+
error: true,
|
|
6743
|
+
error_code: 401,
|
|
6744
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
6745
|
+
};
|
|
6746
|
+
}
|
|
6200
6747
|
let startTime;
|
|
6201
6748
|
if (this.debug) {
|
|
6202
6749
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -6207,8 +6754,8 @@ class XykService {
|
|
|
6207
6754
|
"X-Requested-With": userAgent
|
|
6208
6755
|
}
|
|
6209
6756
|
}));
|
|
6210
|
-
debugOutput(response.url, response.status, startTime);
|
|
6211
|
-
if (response.status === 429) {
|
|
6757
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
6758
|
+
if (response.status === null || response.status === 429) {
|
|
6212
6759
|
try {
|
|
6213
6760
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
6214
6761
|
}
|
|
@@ -6217,7 +6764,7 @@ class XykService {
|
|
|
6217
6764
|
return {
|
|
6218
6765
|
data: null,
|
|
6219
6766
|
error: true,
|
|
6220
|
-
error_code: response.status,
|
|
6767
|
+
error_code: response.status ?? 429,
|
|
6221
6768
|
error_message: error.message
|
|
6222
6769
|
};
|
|
6223
6770
|
}
|
|
@@ -6248,20 +6795,22 @@ class XykService {
|
|
|
6248
6795
|
}
|
|
6249
6796
|
}
|
|
6250
6797
|
|
|
6251
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
6798
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.7.1";
|
|
6252
6799
|
/**
|
|
6253
6800
|
* CovalentClient Class
|
|
6254
6801
|
*/
|
|
6255
6802
|
class CovalentClient {
|
|
6256
6803
|
constructor(apiKey, settings) {
|
|
6257
6804
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
6258
|
-
|
|
6259
|
-
this.
|
|
6260
|
-
this.
|
|
6261
|
-
this.
|
|
6262
|
-
this.
|
|
6263
|
-
this.
|
|
6264
|
-
this.
|
|
6805
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
6806
|
+
this._is_key_valid = validator.isValidApiKey();
|
|
6807
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6808
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6809
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6810
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6811
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6812
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6813
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6265
6814
|
}
|
|
6266
6815
|
}
|
|
6267
6816
|
/**
|
|
@@ -6273,13 +6822,15 @@ class CovalentClient {
|
|
|
6273
6822
|
class Client {
|
|
6274
6823
|
constructor(apiKey, settings) {
|
|
6275
6824
|
const { debug = false, threadCount = 3 } = settings || {};
|
|
6276
|
-
|
|
6277
|
-
this.
|
|
6278
|
-
this.
|
|
6279
|
-
this.
|
|
6280
|
-
this.
|
|
6281
|
-
this.
|
|
6282
|
-
this.
|
|
6825
|
+
const validator = new ApiKeyValidator(apiKey);
|
|
6826
|
+
this._is_key_valid = validator.isValidApiKey();
|
|
6827
|
+
this.SecurityService = new SecurityService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6828
|
+
this.BalanceService = new BalanceService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6829
|
+
this.BaseService = new BaseService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6830
|
+
this.NftService = new NftService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6831
|
+
this.PricingService = new PricingService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6832
|
+
this.TransactionService = new TransactionService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6833
|
+
this.XykService = new XykService(apiKey, debug, threadCount, this._is_key_valid);
|
|
6283
6834
|
}
|
|
6284
6835
|
}
|
|
6285
6836
|
|