@cryptorubic/web3 1.0.0-alpha.no-sdk.32 → 1.0.0-alpha.no-sdk.33

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.0.0-alpha.no-sdk.32",
3
+ "version": "1.0.0-alpha.no-sdk.33",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -129,24 +129,28 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
129
129
  this.logger?.customError('RPC list is empty');
130
130
  return null;
131
131
  }
132
- const transports = rpcList.map((rpc) => (0, viem_1.http)(rpc, {
132
+ const customViemConfig = this.clientParams?.viemConfig?.[this.blockchain];
133
+ const defaultTransportConfig = {
133
134
  batch: { batchSize: 2000, wait: 16 },
134
- onFetchResponse: (response) => {
135
- this.handlePossibleError(response);
136
- },
135
+ onFetchResponse: (response) => this.handlePossibleError(response),
137
136
  retryCount: 2,
138
137
  retryDelay: 100,
139
138
  timeout: 5000
140
- }));
141
- const chain = this.clientParams?.viemConfig?.[this.blockchain] || viem_blockchain_mapping_1.viemBlockchainMapping[this.blockchain];
139
+ };
140
+ const defaultFallbackConfig = {
141
+ rank: {
142
+ interval: 1800000
143
+ }
144
+ };
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;
149
+ const chain = viem_blockchain_mapping_1.viemBlockchainMapping[this.blockchain];
142
150
  return (0, viem_1.createPublicClient)({
143
151
  // @ts-ignore
144
152
  chain,
145
- transport: (0, viem_1.fallback)(transports, {
146
- rank: {
147
- interval: 1800000
148
- }
149
- })
153
+ transport: (0, viem_1.fallback)(transports, fallbackConfig)
150
154
  });
151
155
  }
152
156
  async multicallByContract(contracts, allowErrors = true) {
@@ -2,7 +2,7 @@ import { EvmBlockchainName, HttpClient, ICustomLogger, SolanaBlockchainName, Sui
2
2
  import { EnvType } from '../constants/models/env-type';
3
3
  import { TronWebProvider } from '../adapters/adapter-tron/models/tron-web-provider';
4
4
  import { TonAdapterConfig } from '../adapters/models/ton-adapter-config';
5
- import { ViemChain } from '../constants/models/viem-chain-type';
5
+ import { FallbackTransportConfig, HttpTransportConfig } from 'viem';
6
6
  export type RpcListType = Record<EvmBlockchainName, string[]> & Record<TronBlockchainName, TronWebProvider[]> & Record<SolanaBlockchainName, string[]> & Record<SuiBlockchainName, string[]>;
7
7
  export interface AdapterFactoryParams {
8
8
  rpcList: RpcListType;
@@ -13,6 +13,11 @@ export interface AdapterFactoryParams {
13
13
  }
14
14
  export interface ClientAdaptersFactoryParams {
15
15
  envType: EnvType;
16
- viemConfig?: Partial<Record<EvmBlockchainName, ViemChain>>;
16
+ viemConfig?: ViemChainConfig;
17
17
  lazyLoadWeb3?: boolean;
18
18
  }
19
+ export type ViemChainConfig = Partial<Record<EvmBlockchainName, ViemConfig>>;
20
+ export interface ViemConfig {
21
+ transportConfig?: HttpTransportConfig;
22
+ fallbackConfig?: FallbackTransportConfig;
23
+ }