@cryptorubic/web3 1.8.2 → 1.9.0-alpha.rub-3140.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 -1
- package/package.json +2 -2
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.js +15 -11
- package/src/lib/adapter/constants/viem-blockchain-mapping.js +2 -1
- package/src/lib/utils/constants/changenow-api-blockchain.d.ts +2 -0
- package/src/lib/utils/constants/changenow-api-blockchain.js +2 -1
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# web3
|
|
1
|
+
# web3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptorubic/web3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0-alpha.rub-3140.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@ethersproject/bignumber": "^5.8.0",
|
|
6
6
|
"@mysten/sui": "^1.24.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"js-base64": "^3.7.8",
|
|
22
22
|
"tronweb": "^6.0.0-beta.4",
|
|
23
23
|
"tslib": "*",
|
|
24
|
-
"viem": "^2.
|
|
24
|
+
"viem": "^2.56.5"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {},
|
|
27
27
|
"type": "commonjs",
|
|
@@ -130,22 +130,24 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
132
|
const customViemConfig = this.clientParams?.viemConfig?.[this.blockchain];
|
|
133
|
-
const
|
|
133
|
+
const transportConfig = {
|
|
134
134
|
batch: { batchSize: 2000, wait: 16 },
|
|
135
|
+
// viem reads the response body as a stream to enforce this limit, which fails on
|
|
136
|
+
// `node-fetch`-based fetch polyfills, where `response.body` is not a ReadableStream.
|
|
137
|
+
maxResponseBodySize: false,
|
|
135
138
|
onFetchResponse: (response) => this.handlePossibleError(response),
|
|
136
139
|
retryCount: 2,
|
|
137
140
|
retryDelay: 100,
|
|
138
|
-
timeout: 5000
|
|
141
|
+
timeout: 5000,
|
|
142
|
+
...customViemConfig?.transportConfig
|
|
139
143
|
};
|
|
140
|
-
const
|
|
144
|
+
const fallbackConfig = {
|
|
141
145
|
rank: {
|
|
142
146
|
interval: 1800000
|
|
143
|
-
}
|
|
147
|
+
},
|
|
148
|
+
...customViemConfig?.fallbackConfig
|
|
144
149
|
};
|
|
145
|
-
const transports = rpcList.map((rpc) =>
|
|
146
|
-
return (0, viem_1.http)(rpc, customViemConfig?.transportConfig ? customViemConfig.transportConfig : defaultTransportConfig);
|
|
147
|
-
});
|
|
148
|
-
const fallbackConfig = customViemConfig?.fallbackConfig ? customViemConfig?.fallbackConfig : defaultFallbackConfig;
|
|
150
|
+
const transports = rpcList.map((rpc) => (0, viem_1.http)(rpc, transportConfig));
|
|
149
151
|
const chain = viem_blockchain_mapping_1.viemBlockchainMapping[this.blockchain];
|
|
150
152
|
return (0, viem_1.createPublicClient)({
|
|
151
153
|
// @ts-ignore
|
|
@@ -484,12 +486,14 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
484
486
|
return feedSum.dividedBy(feeHistory.baseFeePerGas.length).toNumber();
|
|
485
487
|
}
|
|
486
488
|
async handlePossibleError(response) {
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
+
// The body is read from a clone, since viem consumes the original one after this callback.
|
|
490
|
+
const body = await response.clone().text();
|
|
491
|
+
const lowerCasedBody = body.toLowerCase();
|
|
492
|
+
const isError = !response.ok || possible_errors_1.possibleErrors.some((error) => lowerCasedBody.includes(error));
|
|
489
493
|
if (isError) {
|
|
490
494
|
this.logger?.customError('Rpc fetch error', {
|
|
491
495
|
blockchain: this.blockchain,
|
|
492
|
-
text:
|
|
496
|
+
text: body,
|
|
493
497
|
url: response.url
|
|
494
498
|
});
|
|
495
499
|
}
|
|
@@ -78,5 +78,6 @@ exports.viemBlockchainMapping = {
|
|
|
78
78
|
[core_1.BLOCKCHAIN_NAME.PLASMA]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.PLASMA],
|
|
79
79
|
[core_1.BLOCKCHAIN_NAME.HYPER_EVM]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.HYPER_EVM],
|
|
80
80
|
[core_1.BLOCKCHAIN_NAME.MONAD]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MONAD],
|
|
81
|
-
[core_1.BLOCKCHAIN_NAME.MEGAETH]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MEGAETH]
|
|
81
|
+
[core_1.BLOCKCHAIN_NAME.MEGAETH]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MEGAETH],
|
|
82
|
+
[core_1.BLOCKCHAIN_NAME.ROBINHOOD]: chains_1.robinhood
|
|
82
83
|
};
|
|
@@ -18,6 +18,7 @@ export declare const changeNowEvmSupportedBlockchain: {
|
|
|
18
18
|
PULSECHAIN: string;
|
|
19
19
|
BASE: string;
|
|
20
20
|
ZK_SYNC: string;
|
|
21
|
+
ROBINHOOD: string;
|
|
21
22
|
};
|
|
22
23
|
export type ChangenowEvmCrossChainSupportedBlockchain = keyof typeof changeNowEvmSupportedBlockchain;
|
|
23
24
|
export declare const changenowApiBlockchain: {
|
|
@@ -118,5 +119,6 @@ export declare const changenowApiBlockchain: {
|
|
|
118
119
|
PULSECHAIN: string;
|
|
119
120
|
BASE: string;
|
|
120
121
|
ZK_SYNC: string;
|
|
122
|
+
ROBINHOOD: string;
|
|
121
123
|
};
|
|
122
124
|
export type ChangenowCrossChainSupportedBlockchain = keyof typeof changenowApiBlockchain;
|
|
@@ -21,7 +21,8 @@ exports.changeNowEvmSupportedBlockchain = {
|
|
|
21
21
|
[core_1.BLOCKCHAIN_NAME.XDC]: 'xdc',
|
|
22
22
|
[core_1.BLOCKCHAIN_NAME.PULSECHAIN]: 'pulse',
|
|
23
23
|
[core_1.BLOCKCHAIN_NAME.BASE]: 'base',
|
|
24
|
-
[core_1.BLOCKCHAIN_NAME.ZK_SYNC]: 'zksync'
|
|
24
|
+
[core_1.BLOCKCHAIN_NAME.ZK_SYNC]: 'zksync',
|
|
25
|
+
[core_1.BLOCKCHAIN_NAME.ROBINHOOD]: 'hood'
|
|
25
26
|
};
|
|
26
27
|
exports.changenowApiBlockchain = {
|
|
27
28
|
// Evm
|