@cryptorubic/web3 0.2.7 → 0.2.8
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/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptorubic/web3",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
6
|
"bignumber.js": "9.1.2",
|
|
7
|
-
"@cryptorubic/core": "0.2.
|
|
7
|
+
"@cryptorubic/core": "0.2.8",
|
|
8
8
|
"viem": "^2.19.1",
|
|
9
9
|
"web3-utils": "^4.3.1",
|
|
10
10
|
"@ton/ton": "^15.1.0",
|
|
11
11
|
"@solana/web3.js": "1.95.3",
|
|
12
12
|
"@solflare-wallet/utl-sdk": "^1.4.0",
|
|
13
13
|
"@ethersproject/bignumber": "^5.7.0",
|
|
14
|
-
"@cryptorubic/tron-types": "0.2.
|
|
14
|
+
"@cryptorubic/tron-types": "0.2.8",
|
|
15
15
|
"bitcoin-address-validation": "^2.2.3",
|
|
16
16
|
"axios": "0.27.2",
|
|
17
17
|
"crc-32": "^1.2.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const possibleErrors: string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.possibleErrors = void 0;
|
|
4
|
+
exports.possibleErrors = [
|
|
5
|
+
'not authorized',
|
|
6
|
+
'daily request count exceeded',
|
|
7
|
+
'invalid json rpc response',
|
|
8
|
+
"we can't execute this request",
|
|
9
|
+
'your account has been suspended',
|
|
10
|
+
'account suspended, please top up to reenable',
|
|
11
|
+
'your account has been suspended',
|
|
12
|
+
'too many requests, we recommend you to use free api key',
|
|
13
|
+
'origin not allowed',
|
|
14
|
+
];
|
|
@@ -8,6 +8,7 @@ const abstract_adapter_1 = require("./abstract-adapter");
|
|
|
8
8
|
const core_1 = require("@cryptorubic/core");
|
|
9
9
|
const bignumber_js_1 = require("bignumber.js");
|
|
10
10
|
const web3_pure_1 = require("../../utils/web3-pure");
|
|
11
|
+
const possible_errors_1 = require("./constants/possible-errors");
|
|
11
12
|
class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
12
13
|
async needPreswapAction(token, contractAddress, walletAddress, amount) {
|
|
13
14
|
return this.needApprove(token, contractAddress, walletAddress, amount);
|
|
@@ -38,10 +39,10 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
38
39
|
batch: { batchSize: 2000, wait: 16 },
|
|
39
40
|
onFetchResponse: (response) => {
|
|
40
41
|
if ('error' in response) {
|
|
41
|
-
this.
|
|
42
|
+
this.handlePossibleError(response);
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
|
-
retryCount:
|
|
45
|
+
retryCount: 2,
|
|
45
46
|
retryDelay: 100,
|
|
46
47
|
timeout: 5000,
|
|
47
48
|
}));
|
|
@@ -336,5 +337,18 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
336
337
|
const feedSum = feeHistory.baseFeePerGas.reduce((acc, v) => acc.plus(v.toString() || 0), new bignumber_js_1.default(0));
|
|
337
338
|
return feedSum.dividedBy(feeHistory.baseFeePerGas.length).toNumber();
|
|
338
339
|
}
|
|
340
|
+
async handlePossibleError(response) {
|
|
341
|
+
const body = JSON.stringify(response.body);
|
|
342
|
+
const isError = !response.ok ||
|
|
343
|
+
'error' in response ||
|
|
344
|
+
possible_errors_1.possibleErrors.some((error) => body.includes(error));
|
|
345
|
+
if (isError) {
|
|
346
|
+
this.logger?.customError('Rpc fetch error', {
|
|
347
|
+
blockchain: this.blockchain,
|
|
348
|
+
text: await response.text(),
|
|
349
|
+
url: response.url,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
339
353
|
}
|
|
340
354
|
exports.EvmAdapter = EvmAdapter;
|