@cryptorubic/web3 0.2.7 → 0.2.9
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.9",
|
|
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.9",
|
|
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.9",
|
|
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);
|
|
@@ -37,11 +38,9 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
37
38
|
const transports = rpcList.map((rpc) => (0, viem_1.http)(rpc, {
|
|
38
39
|
batch: { batchSize: 2000, wait: 16 },
|
|
39
40
|
onFetchResponse: (response) => {
|
|
40
|
-
|
|
41
|
-
this.logger?.customError('Rpc fetch error', response.error);
|
|
42
|
-
}
|
|
41
|
+
this.handlePossibleError(response);
|
|
43
42
|
},
|
|
44
|
-
retryCount:
|
|
43
|
+
retryCount: 2,
|
|
45
44
|
retryDelay: 100,
|
|
46
45
|
timeout: 5000,
|
|
47
46
|
}));
|
|
@@ -336,5 +335,18 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
336
335
|
const feedSum = feeHistory.baseFeePerGas.reduce((acc, v) => acc.plus(v.toString() || 0), new bignumber_js_1.default(0));
|
|
337
336
|
return feedSum.dividedBy(feeHistory.baseFeePerGas.length).toNumber();
|
|
338
337
|
}
|
|
338
|
+
async handlePossibleError(response) {
|
|
339
|
+
const body = JSON.stringify(response.body);
|
|
340
|
+
const isError = !response.ok ||
|
|
341
|
+
'error' in response ||
|
|
342
|
+
possible_errors_1.possibleErrors.some((error) => body.includes(error));
|
|
343
|
+
if (isError) {
|
|
344
|
+
this.logger?.customError('Rpc fetch error', {
|
|
345
|
+
blockchain: this.blockchain,
|
|
346
|
+
text: await response.text(),
|
|
347
|
+
url: response.url,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
339
351
|
}
|
|
340
352
|
exports.EvmAdapter = EvmAdapter;
|