@cryptorubic/web3 1.9.0-alpha.rub-3140.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "1.9.0-alpha.rub-3140.0",
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",
@@ -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 defaultTransportConfig = {
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 defaultFallbackConfig = {
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
- const body = JSON.stringify(response.body);
488
- const isError = !response.ok || 'error' in response || possible_errors_1.possibleErrors.some((error) => body.includes(error));
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: await response.text(),
496
+ text: body,
493
497
  url: response.url
494
498
  });
495
499
  }