@toruslabs/ethereum-controllers 9.5.0 → 9.6.0

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.
@@ -26,7 +26,7 @@ async function getDelegationAddress(walletAddress, chainId, getEthCode) {
26
26
  * Check if the wallet is supported for EIP-7702 on provided chain.
27
27
  */
28
28
  async function getIsEip7702UpgradeSupported(address, chainId, getEthCode) {
29
- if (!constants.SUPPORTED_NETWORKS[chainId]) {
29
+ if (!constants.SUPPORTED_CHAIN_IDS.includes(chainId)) {
30
30
  return {
31
31
  isSupported: false,
32
32
  delegationAddress: null
@@ -126,13 +126,13 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
126
126
  high,
127
127
  estimatedBaseFee
128
128
  } = gasFeeEstimates;
129
- const maxPriorityFeePerGasInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxPriorityFeePerGas)), 16);
130
- const maxFeePerGasInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxFeePerGas)), 16);
131
- const estimatedBaseFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(estimatedBaseFee)), 16);
129
+ const maxPriorityFeePerGasInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxPriorityFeePerGas));
130
+ const maxFeePerGasInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxFeePerGas));
131
+ const estimatedBaseFeeInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(estimatedBaseFee));
132
132
  const effectiveMaxPriorityFee = bignumber_js.BigNumber.min(maxPriorityFeePerGasInWEI, maxFeePerGasInWEI.minus(estimatedBaseFeeInWEI));
133
- const lowMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(low.suggestedMaxPriorityFeePerGas)), 16);
134
- const mediumMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(medium.suggestedMaxPriorityFeePerGas)), 16);
135
- const highMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(high.suggestedMaxPriorityFeePerGas)), 16);
133
+ const lowMaxPriorityFeeInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(low.suggestedMaxPriorityFeePerGas));
134
+ const mediumMaxPriorityFeeInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(medium.suggestedMaxPriorityFeePerGas));
135
+ const highMaxPriorityFeeInWEI = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(high.suggestedMaxPriorityFeePerGas));
136
136
  let lowerTimeBound;
137
137
  let upperTimeBound;
138
138
  if (effectiveMaxPriorityFee.lt(lowMaxPriorityFeeInWEI)) {
@@ -8,6 +8,7 @@ var auth = require('@web3auth/auth');
8
8
  var asyncMutex = require('async-mutex');
9
9
  var log = require('loglevel');
10
10
  var constants = require('../utils/constants.js');
11
+ var helpers = require('../utils/helpers.js');
11
12
  var createEthereumMiddleware = require('./createEthereumMiddleware.js');
12
13
  var createJsonRpcClient = require('./createJsonRpcClient.js');
13
14
 
@@ -32,12 +33,20 @@ class NetworkController extends baseControllers.BaseController {
32
33
  _defineProperty(this, "baseProviderHandlers", void 0);
33
34
  _defineProperty(this, "idleTimeTracker", void 0);
34
35
  _defineProperty(this, "analytics", void 0);
36
+ let providerConfig;
37
+ if (config !== null && config !== void 0 && config.providerConfig) {
38
+ providerConfig = config.providerConfig;
39
+ } else if (config !== null && config !== void 0 && config.infuraKey) {
40
+ providerConfig = helpers.toRpcConfig(config.infuraKey)[constants.MAINNET_CHAIN_ID];
41
+ } else {
42
+ throw new Error("providerConfig or infuraKey must be provided");
43
+ }
35
44
  this.defaultState = {
36
45
  chainId: "loading",
37
46
  properties: {
38
47
  EIPS_1559: undefined
39
48
  },
40
- providerConfig: constants.SUPPORTED_NETWORKS[constants.MAINNET_CHAIN_ID]
49
+ providerConfig
41
50
  };
42
51
  this.analytics = analytics;
43
52
  // when a new network is set,
@@ -4,7 +4,6 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var baseControllers = require('@toruslabs/base-controllers');
5
5
  var metadataHelpers = require('@toruslabs/metadata-helpers');
6
6
  var log = require('loglevel');
7
- var constants = require('../utils/constants.js');
8
7
 
9
8
  class PreferencesController extends baseControllers.BasePreferencesController {
10
9
  constructor({
@@ -27,8 +26,10 @@ class PreferencesController extends baseControllers.BasePreferencesController {
27
26
  _defineProperty(this, "chainNamespace", baseControllers.CHAIN_NAMESPACES.EIP155);
28
27
  _defineProperty(this, "getProviderConfig", void 0);
29
28
  _defineProperty(this, "setProviderConfig", void 0);
29
+ _defineProperty(this, "supportedNetworks", void 0);
30
30
  this.getProviderConfig = getProviderConfig;
31
31
  this.setProviderConfig = setProviderConfig;
32
+ this.supportedNetworks = config.supportedNetworks;
32
33
  }
33
34
  async initPreferences(params) {
34
35
  const {
@@ -141,7 +142,7 @@ class PreferencesController extends baseControllers.BasePreferencesController {
141
142
  }
142
143
  }
143
144
  getChainOptions() {
144
- return Object.values(constants.SUPPORTED_NETWORKS);
145
+ return Object.values(this.supportedNetworks);
145
146
  }
146
147
  }
147
148
 
@@ -154,11 +154,11 @@ exports.erc721Abi = abis.erc721Abi;
154
154
  exports.erc7821Abi = abis.erc7821Abi;
155
155
  exports.singleBalanceCheckerAbi = abis.singleBalanceCheckerAbi;
156
156
  exports.ARBITRUM_MAINNET_CHAIN_ID = constants.ARBITRUM_MAINNET_CHAIN_ID;
157
- exports.ARBITRUM_TESTNET_CHAIN_ID = constants.ARBITRUM_TESTNET_CHAIN_ID;
157
+ exports.ARBITRUM_SEPOLIA_CHAIN_ID = constants.ARBITRUM_SEPOLIA_CHAIN_ID;
158
+ exports.AVALANCHE_FUJI_CHAIN_ID = constants.AVALANCHE_FUJI_CHAIN_ID;
158
159
  exports.AVALANCHE_MAINNET_CHAIN_ID = constants.AVALANCHE_MAINNET_CHAIN_ID;
159
- exports.AVALANCHE_TESTNET_CHAIN_ID = constants.AVALANCHE_TESTNET_CHAIN_ID;
160
160
  exports.BASE_CHAIN_ID = constants.BASE_CHAIN_ID;
161
- exports.BASE_TESTNET_CHAIN_ID = constants.BASE_TESTNET_CHAIN_ID;
161
+ exports.BASE_SEPOLIA_CHAIN_ID = constants.BASE_SEPOLIA_CHAIN_ID;
162
162
  exports.BSC_MAINNET_CHAIN_ID = constants.BSC_MAINNET_CHAIN_ID;
163
163
  exports.BSC_TESTNET_CHAIN_ID = constants.BSC_TESTNET_CHAIN_ID;
164
164
  exports.BUNDLER_METHOD_TYPES = constants.BUNDLER_METHOD_TYPES;
@@ -171,12 +171,14 @@ exports.CONTRACT_TYPE_ERC20 = constants.CONTRACT_TYPE_ERC20;
171
171
  exports.CONTRACT_TYPE_ERC721 = constants.CONTRACT_TYPE_ERC721;
172
172
  exports.CONTRACT_TYPE_ERC7821 = constants.CONTRACT_TYPE_ERC7821;
173
173
  exports.CONTRACT_TYPE_ETH = constants.CONTRACT_TYPE_ETH;
174
+ exports.DEFAULT_SUPPORTED_NETWORKS = constants.DEFAULT_SUPPORTED_NETWORKS;
174
175
  exports.EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES = constants.EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES;
175
176
  exports.ERC1155_INTERFACE_ID = constants.ERC1155_INTERFACE_ID;
176
177
  exports.ERC721_ENUMERABLE_INTERFACE_ID = constants.ERC721_ENUMERABLE_INTERFACE_ID;
177
178
  exports.ERC721_INTERFACE_ID = constants.ERC721_INTERFACE_ID;
178
179
  exports.ERC721_METADATA_INTERFACE_ID = constants.ERC721_METADATA_INTERFACE_ID;
179
180
  exports.GAS_ESTIMATE_TYPES = constants.GAS_ESTIMATE_TYPES;
181
+ exports.INFURA_SUB_DOMAINS = constants.INFURA_SUB_DOMAINS;
180
182
  exports.LINEA_CHAIN_ID = constants.LINEA_CHAIN_ID;
181
183
  exports.LINEA_SEPOLIA_CHAIN_ID = constants.LINEA_SEPOLIA_CHAIN_ID;
182
184
  exports.LOCALHOST = constants.LOCALHOST;
@@ -186,14 +188,14 @@ exports.MM_NFT_API_SUPPORTED_CHAINS = constants.MM_NFT_API_SUPPORTED_CHAINS;
186
188
  exports.MM_TOKEN_API_SUPPORTED_CHAINS = constants.MM_TOKEN_API_SUPPORTED_CHAINS;
187
189
  exports.OLD_ERC721_LIST = constants.OLD_ERC721_LIST;
188
190
  exports.OPTIMISM_MAINNET_CHAIN_ID = constants.OPTIMISM_MAINNET_CHAIN_ID;
189
- exports.OPTIMISM_TESTNET_CHAIN_ID = constants.OPTIMISM_TESTNET_CHAIN_ID;
191
+ exports.OPTIMISM_SEPOLIA_CHAIN_ID = constants.OPTIMISM_SEPOLIA_CHAIN_ID;
190
192
  exports.PAYMASTER_METHOD_TYPES = constants.PAYMASTER_METHOD_TYPES;
191
193
  exports.POLYGON_AMOY_CHAIN_ID = constants.POLYGON_AMOY_CHAIN_ID;
192
194
  exports.POLYGON_CHAIN_ID = constants.POLYGON_CHAIN_ID;
193
195
  exports.SEPOLIA_CHAIN_ID = constants.SEPOLIA_CHAIN_ID;
194
196
  exports.SMART_ACCOUNT = constants.SMART_ACCOUNT;
195
197
  exports.SMART_ACCOUNT_EIP_STANDARD = constants.SMART_ACCOUNT_EIP_STANDARD;
196
- exports.SUPPORTED_NETWORKS = constants.SUPPORTED_NETWORKS;
198
+ exports.SUPPORTED_CHAIN_IDS = constants.SUPPORTED_CHAIN_IDS;
197
199
  exports.TEST_CHAINS = constants.TEST_CHAINS;
198
200
  exports.TRANSACTION_ENVELOPE_TYPES = constants.TRANSACTION_ENVELOPE_TYPES;
199
201
  exports.XDAI_CHAIN_ID = constants.XDAI_CHAIN_ID;
@@ -226,9 +228,11 @@ exports.formatTime = helpers.formatTime;
226
228
  exports.getChainType = helpers.getChainType;
227
229
  exports.getEthTxStatus = helpers.getEthTxStatus;
228
230
  exports.getEtherScanHashLink = helpers.getEtherScanHashLink;
231
+ exports.getEvmRpcUrl = helpers.getEvmRpcUrl;
229
232
  exports.getIpfsEndpoint = helpers.getIpfsEndpoint;
230
233
  exports.hexToBn = helpers.hexToBn;
231
234
  exports.isAddressByChainId = helpers.isAddressByChainId;
232
235
  exports.sanitizeNftMetdataUrl = helpers.sanitizeNftMetdataUrl;
233
236
  exports.toChecksumAddressByChainId = helpers.toChecksumAddressByChainId;
237
+ exports.toRpcConfig = helpers.toRpcConfig;
234
238
  exports.TRANSACTION_CATEGORY_EIP7702 = interfaces.TRANSACTION_CATEGORY_EIP7702;
@@ -1,4 +1,5 @@
1
1
  import { SafeEventEmitterProvider } from "@web3auth/auth";
2
+ import { BigNumber } from "bignumber.js";
2
3
  import { EthereumGasFeeEstimates, EthereumLegacyGasFeeEstimates, GasFeeTimeBounds } from "./IGasFeeController";
3
4
  export declare function normalizeGWEIDecimalNumbers(n: string | number): number | BigNumber;
4
5
  export declare function fetchGasEstimates(url: string): Promise<EthereumGasFeeEstimates>;
@@ -2,10 +2,13 @@ import { AuthHttpClientGetter, BasePreferencesController, CustomNft, CustomToken
2
2
  import { KeyringController } from "../Keyring/KeyringController";
3
3
  import { NetworkController } from "../Network/NetworkController";
4
4
  import { EthereumNftInfo as CustomNftInfo } from "../Nfts/INftsController";
5
- import type { AddChainMessageParams, CustomTokenInfo } from "../utils/interfaces";
5
+ import type { AddChainMessageParams, CustomTokenInfo, EthereumProviderConfig } from "../utils/interfaces";
6
6
  import { ExtendedAddressPreferences } from "./IPreferencesController";
7
7
  export interface IPreferencesControllerOptions {
8
- config?: Partial<PreferencesConfig> & Pick<PreferencesConfig, "api" | "commonApiHost">;
8
+ config?: Partial<PreferencesConfig> & Pick<PreferencesConfig, "api" | "commonApiHost"> & {
9
+ /** supported networks */
10
+ supportedNetworks: Record<string, EthereumProviderConfig>;
11
+ };
9
12
  state?: Partial<PreferencesState<ExtendedAddressPreferences>>;
10
13
  signAuthMessage?: KeyringController["signAuthMessage"];
11
14
  getProviderConfig?: NetworkController["getProviderConfig"];
@@ -17,6 +20,7 @@ export declare class PreferencesController extends BasePreferencesController<Ext
17
20
  protected chainNamespace: "eip155";
18
21
  private getProviderConfig;
19
22
  private setProviderConfig;
23
+ private supportedNetworks;
20
24
  constructor({ config, state, signAuthMessage, getProviderConfig, setProviderConfig, validateSignMessage, getAuthHttpClient, }: IPreferencesControllerOptions);
21
25
  initPreferences(params: InitPreferencesParams & {
22
26
  eoaAddress?: string;
@@ -1,3 +1,4 @@
1
+ import { Hex } from "@toruslabs/metadata-helpers";
1
2
  import { EthereumProviderConfig } from "./interfaces";
2
3
  export declare const LOCALHOST = "localhost";
3
4
  export declare const CONTRACT_TYPE_ETH = "eth";
@@ -22,12 +23,17 @@ export declare const LINEA_CHAIN_ID = "0xe708";
22
23
  export declare const SEPOLIA_CHAIN_ID = "0xaa36a7";
23
24
  export declare const POLYGON_AMOY_CHAIN_ID = "0x13882";
24
25
  export declare const BSC_TESTNET_CHAIN_ID = "0x61";
25
- export declare const AVALANCHE_TESTNET_CHAIN_ID = "0xa869";
26
- export declare const ARBITRUM_TESTNET_CHAIN_ID = "0x66eee";
27
- export declare const OPTIMISM_TESTNET_CHAIN_ID = "0xaa37dc";
28
- export declare const BASE_TESTNET_CHAIN_ID = "0x14a34";
26
+ export declare const AVALANCHE_FUJI_CHAIN_ID = "0xa869";
27
+ export declare const ARBITRUM_SEPOLIA_CHAIN_ID = "0x66eee";
28
+ export declare const OPTIMISM_SEPOLIA_CHAIN_ID = "0xaa37dc";
29
+ export declare const BASE_SEPOLIA_CHAIN_ID = "0x14a34";
29
30
  export declare const LINEA_SEPOLIA_CHAIN_ID = "0xe705";
30
- export declare const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig>;
31
+ export declare const INFURA_SUB_DOMAINS: Record<string, string>;
32
+ /**
33
+ * Default supported networks for the Ethereum controllers.
34
+ */
35
+ export declare const DEFAULT_SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig>;
36
+ export declare const SUPPORTED_CHAIN_IDS: Hex[];
31
37
  export declare const METHOD_TYPES: {
32
38
  readonly GET_ACCOUNTS: "eth_accounts";
33
39
  readonly ETH_TRANSACTION: "eth_sendTransaction";
@@ -1,3 +1,4 @@
1
+ import { BigNumber } from "bignumber.js";
1
2
  type NumericBase = "hex" | "dec" | "BN";
2
3
  type EthDenomination = "WEI" | "GWEI" | "ETH";
3
4
  type ConverterOptions = {
@@ -1,5 +1,7 @@
1
1
  import { TransactionStatus } from "@toruslabs/base-controllers";
2
2
  import { SafeEventEmitterProvider } from "@web3auth/auth";
3
+ import { BigNumber } from "bignumber.js";
4
+ import { EthereumProviderConfig } from "./interfaces";
3
5
  export declare function hexToBn(hex: string): BigNumber;
4
6
  export declare function BNToHex(bn: BigNumber): string;
5
7
  export declare function getEtherScanHashLink(txHash: string, chainId: string): string;
@@ -15,7 +17,9 @@ export declare const GAS_LIMITS: {
15
17
  SIMPLE: `0x${string}`;
16
18
  BASE_TOKEN_ESTIMATE: `0x${string}`;
17
19
  };
18
- export declare function bnLessThan(a: string | number, b: string | number): boolean;
20
+ export declare function bnLessThan(a: string, b: string): boolean;
19
21
  export declare const getIpfsEndpoint: (path: string) => string;
20
22
  export declare function sanitizeNftMetdataUrl(url: string): string;
21
- export declare function getChainType(chainId: string): "custom" | "mainnet" | "testnet";
23
+ export declare function getChainType(chainId: string): "mainnet" | "testnet" | "custom";
24
+ export declare function getEvmRpcUrl(infuraKey: string, chainId: string): string;
25
+ export declare function toRpcConfig(infuraKey: string, providerOverrides?: Record<string, EthereumProviderConfig>): Record<string, EthereumProviderConfig>;
@@ -256,11 +256,13 @@ export interface EthereumProviderConfig extends ProviderConfig {
256
256
  isErc20?: boolean;
257
257
  tokenAddress?: string;
258
258
  }
259
+ export type EthereumProviderConfigWithoutRpcTarget = Omit<EthereumProviderConfig, "rpcTarget">;
259
260
  export interface EthereumNetworkState extends NetworkState {
260
261
  providerConfig: EthereumProviderConfig;
261
262
  }
262
263
  export interface EthereumNetworkConfig extends NetworkConfig, Partial<PollingBlockTrackerConfig> {
263
264
  providerConfig: EthereumProviderConfig;
265
+ infuraKey?: string;
264
266
  }
265
267
  export interface ContractParams {
266
268
  erc20?: boolean;
@@ -25,15 +25,34 @@ const LINEA_CHAIN_ID = "0xe708";
25
25
  const SEPOLIA_CHAIN_ID = "0xaa36a7";
26
26
  const POLYGON_AMOY_CHAIN_ID = "0x13882";
27
27
  const BSC_TESTNET_CHAIN_ID = "0x61";
28
- const AVALANCHE_TESTNET_CHAIN_ID = "0xa869";
29
- const ARBITRUM_TESTNET_CHAIN_ID = "0x66eee";
30
- const OPTIMISM_TESTNET_CHAIN_ID = "0xaa37dc";
31
- const BASE_TESTNET_CHAIN_ID = "0x14a34";
28
+ const AVALANCHE_FUJI_CHAIN_ID = "0xa869";
29
+ const ARBITRUM_SEPOLIA_CHAIN_ID = "0x66eee";
30
+ const OPTIMISM_SEPOLIA_CHAIN_ID = "0xaa37dc";
31
+ const BASE_SEPOLIA_CHAIN_ID = "0x14a34";
32
32
  const LINEA_SEPOLIA_CHAIN_ID = "0xe705";
33
- // Don't change this. It will break production builds.
34
- // We use this syntax because if both injections fail, we replace the "process.env.VITE_APP_INFURA_PROJECT_KEY" using define replacement
35
- const INFURA_KEY = baseControllers.getEnvVariable("VITE_APP_INFURA_PROJECT_KEY") || process.env.VITE_APP_INFURA_PROJECT_KEY;
36
- const SUPPORTED_NETWORKS = {
33
+ const INFURA_SUB_DOMAINS = {
34
+ [MAINNET_CHAIN_ID]: "mainnet",
35
+ [POLYGON_CHAIN_ID]: "polygon-mainnet",
36
+ [BSC_MAINNET_CHAIN_ID]: "bsc-mainnet",
37
+ [AVALANCHE_MAINNET_CHAIN_ID]: "avalanche-mainnet",
38
+ [OPTIMISM_MAINNET_CHAIN_ID]: "optimism-mainnet",
39
+ [CELO_MAINNET_CHAIN_ID]: "celo-mainnet",
40
+ [ARBITRUM_MAINNET_CHAIN_ID]: "arbitrum-mainnet",
41
+ [BASE_CHAIN_ID]: "base-mainnet",
42
+ [LINEA_CHAIN_ID]: "linea-mainnet",
43
+ [SEPOLIA_CHAIN_ID]: "sepolia",
44
+ [LINEA_SEPOLIA_CHAIN_ID]: "linea-sepolia",
45
+ [POLYGON_AMOY_CHAIN_ID]: "polygon-amoy",
46
+ [BSC_TESTNET_CHAIN_ID]: "bsc-testnet",
47
+ [AVALANCHE_FUJI_CHAIN_ID]: "avalanche-fuji",
48
+ [ARBITRUM_SEPOLIA_CHAIN_ID]: "arbitrum-sepolia",
49
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: "optimism-sepolia",
50
+ [BASE_SEPOLIA_CHAIN_ID]: "base-sepolia"
51
+ };
52
+ /**
53
+ * Default supported networks for the Ethereum controllers.
54
+ */
55
+ const DEFAULT_SUPPORTED_NETWORKS = {
37
56
  [MAINNET_CHAIN_ID]: {
38
57
  chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
39
58
  decimals: 18,
@@ -41,7 +60,7 @@ const SUPPORTED_NETWORKS = {
41
60
  chainId: MAINNET_CHAIN_ID,
42
61
  displayName: "Ethereum",
43
62
  logo: "eth.svg",
44
- rpcTarget: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
63
+ rpcTarget: "https://ethereum-rpc.publicnode.com",
45
64
  ticker: "ETH",
46
65
  tickerName: "Ethereum"
47
66
  },
@@ -52,7 +71,7 @@ const SUPPORTED_NETWORKS = {
52
71
  chainId: POLYGON_CHAIN_ID,
53
72
  displayName: "Polygon",
54
73
  logo: "polygon.svg",
55
- rpcTarget: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
74
+ rpcTarget: "https://polygon-bor-rpc.publicnode.com",
56
75
  ticker: "POL",
57
76
  tickerName: "Polygon Ecosystem Token"
58
77
  },
@@ -85,7 +104,7 @@ const SUPPORTED_NETWORKS = {
85
104
  chainId: OPTIMISM_MAINNET_CHAIN_ID,
86
105
  displayName: "Optimism",
87
106
  logo: "optimism.svg",
88
- rpcTarget: `https://optimism-mainnet.infura.io/v3/${INFURA_KEY}`,
107
+ rpcTarget: "https://optimism-rpc.publicnode.com",
89
108
  ticker: "ETH",
90
109
  tickerName: "Ethereum"
91
110
  },
@@ -96,7 +115,7 @@ const SUPPORTED_NETWORKS = {
96
115
  chainId: CELO_MAINNET_CHAIN_ID,
97
116
  displayName: "Celo Mainnet",
98
117
  logo: "celo.svg",
99
- rpcTarget: `https://celo-mainnet.infura.io/v3/${INFURA_KEY}`,
118
+ rpcTarget: "https://forno.celo.org",
100
119
  ticker: "CELO",
101
120
  tickerName: "Celo"
102
121
  },
@@ -107,7 +126,7 @@ const SUPPORTED_NETWORKS = {
107
126
  chainId: ARBITRUM_MAINNET_CHAIN_ID,
108
127
  displayName: "Arbitrum One",
109
128
  logo: "arbitrum.svg",
110
- rpcTarget: `https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`,
129
+ rpcTarget: "https://arbitrum-one-rpc.publicnode.com",
111
130
  ticker: "ETH",
112
131
  tickerName: "Ethereum"
113
132
  },
@@ -129,7 +148,7 @@ const SUPPORTED_NETWORKS = {
129
148
  chainId: LINEA_CHAIN_ID,
130
149
  displayName: "Linea",
131
150
  logo: "linea.svg",
132
- rpcTarget: `https://linea-mainnet.infura.io/v3/${INFURA_KEY}`,
151
+ rpcTarget: "https://rpc.linea.build",
133
152
  ticker: "ETH",
134
153
  tickerName: "Ethereum"
135
154
  },
@@ -140,7 +159,7 @@ const SUPPORTED_NETWORKS = {
140
159
  chainId: SEPOLIA_CHAIN_ID,
141
160
  displayName: "Sepolia Test Network",
142
161
  logo: "eth.svg",
143
- rpcTarget: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
162
+ rpcTarget: "https://ethereum-sepolia-rpc.publicnode.com",
144
163
  ticker: "ETH",
145
164
  tickerName: "Ethereum",
146
165
  isTestnet: true
@@ -152,7 +171,7 @@ const SUPPORTED_NETWORKS = {
152
171
  chainId: LINEA_SEPOLIA_CHAIN_ID,
153
172
  displayName: "Linea Sepolia Testnet",
154
173
  logo: "linea.svg",
155
- rpcTarget: `https://linea-sepolia.infura.io/v3/${INFURA_KEY}`,
174
+ rpcTarget: "https://rpc.sepolia.linea.build",
156
175
  ticker: "ETH",
157
176
  tickerName: "Ethereum",
158
177
  isTestnet: true
@@ -164,7 +183,7 @@ const SUPPORTED_NETWORKS = {
164
183
  chainId: POLYGON_AMOY_CHAIN_ID,
165
184
  displayName: "Polygon Amoy",
166
185
  logo: "polygon.svg",
167
- rpcTarget: `https://polygon-amoy.infura.io/v3/${INFURA_KEY}`,
186
+ rpcTarget: "https://rpc-amoy.polygon.technology",
168
187
  ticker: "POL",
169
188
  tickerName: "Polygon Ecosystem Token",
170
189
  isTestnet: true
@@ -181,11 +200,11 @@ const SUPPORTED_NETWORKS = {
181
200
  tickerName: "Binance Coin",
182
201
  isTestnet: true
183
202
  },
184
- [AVALANCHE_TESTNET_CHAIN_ID]: {
203
+ [AVALANCHE_FUJI_CHAIN_ID]: {
185
204
  chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
186
205
  decimals: 18,
187
206
  blockExplorerUrl: "https://testnet.snowtrace.io",
188
- chainId: AVALANCHE_TESTNET_CHAIN_ID,
207
+ chainId: AVALANCHE_FUJI_CHAIN_ID,
189
208
  displayName: "Avalanche Testnet C-Chain",
190
209
  logo: "avax.svg",
191
210
  rpcTarget: `https://api.avax-test.network/ext/bc/C/rpc`,
@@ -193,35 +212,35 @@ const SUPPORTED_NETWORKS = {
193
212
  tickerName: "Avalanche",
194
213
  isTestnet: true
195
214
  },
196
- [ARBITRUM_TESTNET_CHAIN_ID]: {
215
+ [ARBITRUM_SEPOLIA_CHAIN_ID]: {
197
216
  chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
198
217
  decimals: 18,
199
218
  blockExplorerUrl: "https://sepolia.arbiscan.io",
200
- chainId: ARBITRUM_TESTNET_CHAIN_ID,
219
+ chainId: ARBITRUM_SEPOLIA_CHAIN_ID,
201
220
  displayName: "Arbitrum Sepolia",
202
221
  logo: "arbitrum.svg",
203
- rpcTarget: `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}`,
222
+ rpcTarget: "https://arbitrum-sepolia-rpc.publicnode.com",
204
223
  ticker: "ETH",
205
224
  tickerName: "Ethereum",
206
225
  isTestnet: true
207
226
  },
208
- [OPTIMISM_TESTNET_CHAIN_ID]: {
227
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: {
209
228
  chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
210
229
  decimals: 18,
211
230
  blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
212
- chainId: OPTIMISM_TESTNET_CHAIN_ID,
231
+ chainId: OPTIMISM_SEPOLIA_CHAIN_ID,
213
232
  displayName: "Optimism Sepolia",
214
233
  logo: "optimism.svg",
215
- rpcTarget: `https://optimism-sepolia.infura.io/v3/${INFURA_KEY}`,
234
+ rpcTarget: "https://optimism-sepolia-rpc.publicnode.com",
216
235
  ticker: "ETH",
217
236
  tickerName: "Ethereum",
218
237
  isTestnet: true
219
238
  },
220
- [BASE_TESTNET_CHAIN_ID]: {
239
+ [BASE_SEPOLIA_CHAIN_ID]: {
221
240
  chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
222
241
  decimals: 18,
223
242
  blockExplorerUrl: "https://sepolia.basescan.org",
224
- chainId: BASE_TESTNET_CHAIN_ID,
243
+ chainId: BASE_SEPOLIA_CHAIN_ID,
225
244
  displayName: "Base Sepolia",
226
245
  logo: "base.svg",
227
246
  rpcTarget: `https://sepolia.base.org`,
@@ -230,6 +249,7 @@ const SUPPORTED_NETWORKS = {
230
249
  isTestnet: true
231
250
  }
232
251
  };
252
+ const SUPPORTED_CHAIN_IDS = Object.keys(DEFAULT_SUPPORTED_NETWORKS);
233
253
  const METHOD_TYPES = {
234
254
  GET_ACCOUNTS: "eth_accounts",
235
255
  ETH_TRANSACTION: "eth_sendTransaction",
@@ -302,7 +322,7 @@ const GAS_ESTIMATE_TYPES = {
302
322
  // https://help.optimism.io/hc/en-us/articles/4411895794715-Transaction-fees
303
323
  const CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP = {
304
324
  [OPTIMISM_MAINNET_CHAIN_ID]: 1,
305
- [OPTIMISM_TESTNET_CHAIN_ID]: 1
325
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: 1
306
326
  };
307
327
  const OLD_ERC721_LIST = {
308
328
  "0x06012c8cf97bead5deae237070f9587f8e7a266d": {
@@ -314,7 +334,7 @@ const OLD_ERC721_LIST = {
314
334
  }
315
335
  };
316
336
  const TEST_CHAINS = [SEPOLIA_CHAIN_ID];
317
- const MM_TOKEN_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, POLYGON_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, CELO_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID];
337
+ const MM_TOKEN_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_SEPOLIA_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_FUJI_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_SEPOLIA_CHAIN_ID, POLYGON_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, CELO_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID];
318
338
  const MM_NFT_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, POLYGON_CHAIN_ID, BSC_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, LINEA_CHAIN_ID, BASE_CHAIN_ID];
319
339
  const COINGECKO_SUPPORTED_CURRENCIES = new Set(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats"]);
320
340
  const COINGECKO_PLATFORMS_CHAIN_CODE_MAP = {
@@ -373,11 +393,11 @@ const SMART_ACCOUNT_EIP_STANDARD = {
373
393
  const EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES = [SMART_ACCOUNT.METAMASK];
374
394
 
375
395
  exports.ARBITRUM_MAINNET_CHAIN_ID = ARBITRUM_MAINNET_CHAIN_ID;
376
- exports.ARBITRUM_TESTNET_CHAIN_ID = ARBITRUM_TESTNET_CHAIN_ID;
396
+ exports.ARBITRUM_SEPOLIA_CHAIN_ID = ARBITRUM_SEPOLIA_CHAIN_ID;
397
+ exports.AVALANCHE_FUJI_CHAIN_ID = AVALANCHE_FUJI_CHAIN_ID;
377
398
  exports.AVALANCHE_MAINNET_CHAIN_ID = AVALANCHE_MAINNET_CHAIN_ID;
378
- exports.AVALANCHE_TESTNET_CHAIN_ID = AVALANCHE_TESTNET_CHAIN_ID;
379
399
  exports.BASE_CHAIN_ID = BASE_CHAIN_ID;
380
- exports.BASE_TESTNET_CHAIN_ID = BASE_TESTNET_CHAIN_ID;
400
+ exports.BASE_SEPOLIA_CHAIN_ID = BASE_SEPOLIA_CHAIN_ID;
381
401
  exports.BSC_MAINNET_CHAIN_ID = BSC_MAINNET_CHAIN_ID;
382
402
  exports.BSC_TESTNET_CHAIN_ID = BSC_TESTNET_CHAIN_ID;
383
403
  exports.BUNDLER_METHOD_TYPES = BUNDLER_METHOD_TYPES;
@@ -390,12 +410,14 @@ exports.CONTRACT_TYPE_ERC20 = CONTRACT_TYPE_ERC20;
390
410
  exports.CONTRACT_TYPE_ERC721 = CONTRACT_TYPE_ERC721;
391
411
  exports.CONTRACT_TYPE_ERC7821 = CONTRACT_TYPE_ERC7821;
392
412
  exports.CONTRACT_TYPE_ETH = CONTRACT_TYPE_ETH;
413
+ exports.DEFAULT_SUPPORTED_NETWORKS = DEFAULT_SUPPORTED_NETWORKS;
393
414
  exports.EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES = EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES;
394
415
  exports.ERC1155_INTERFACE_ID = ERC1155_INTERFACE_ID;
395
416
  exports.ERC721_ENUMERABLE_INTERFACE_ID = ERC721_ENUMERABLE_INTERFACE_ID;
396
417
  exports.ERC721_INTERFACE_ID = ERC721_INTERFACE_ID;
397
418
  exports.ERC721_METADATA_INTERFACE_ID = ERC721_METADATA_INTERFACE_ID;
398
419
  exports.GAS_ESTIMATE_TYPES = GAS_ESTIMATE_TYPES;
420
+ exports.INFURA_SUB_DOMAINS = INFURA_SUB_DOMAINS;
399
421
  exports.LINEA_CHAIN_ID = LINEA_CHAIN_ID;
400
422
  exports.LINEA_SEPOLIA_CHAIN_ID = LINEA_SEPOLIA_CHAIN_ID;
401
423
  exports.LOCALHOST = LOCALHOST;
@@ -405,14 +427,14 @@ exports.MM_NFT_API_SUPPORTED_CHAINS = MM_NFT_API_SUPPORTED_CHAINS;
405
427
  exports.MM_TOKEN_API_SUPPORTED_CHAINS = MM_TOKEN_API_SUPPORTED_CHAINS;
406
428
  exports.OLD_ERC721_LIST = OLD_ERC721_LIST;
407
429
  exports.OPTIMISM_MAINNET_CHAIN_ID = OPTIMISM_MAINNET_CHAIN_ID;
408
- exports.OPTIMISM_TESTNET_CHAIN_ID = OPTIMISM_TESTNET_CHAIN_ID;
430
+ exports.OPTIMISM_SEPOLIA_CHAIN_ID = OPTIMISM_SEPOLIA_CHAIN_ID;
409
431
  exports.PAYMASTER_METHOD_TYPES = PAYMASTER_METHOD_TYPES;
410
432
  exports.POLYGON_AMOY_CHAIN_ID = POLYGON_AMOY_CHAIN_ID;
411
433
  exports.POLYGON_CHAIN_ID = POLYGON_CHAIN_ID;
412
434
  exports.SEPOLIA_CHAIN_ID = SEPOLIA_CHAIN_ID;
413
435
  exports.SMART_ACCOUNT = SMART_ACCOUNT;
414
436
  exports.SMART_ACCOUNT_EIP_STANDARD = SMART_ACCOUNT_EIP_STANDARD;
415
- exports.SUPPORTED_NETWORKS = SUPPORTED_NETWORKS;
437
+ exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
416
438
  exports.TEST_CHAINS = TEST_CHAINS;
417
439
  exports.TRANSACTION_ENVELOPE_TYPES = TRANSACTION_ENVELOPE_TYPES;
418
440
  exports.XDAI_CHAIN_ID = XDAI_CHAIN_ID;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
3
4
  var baseControllers = require('@toruslabs/base-controllers');
4
5
  var metadataHelpers = require('@toruslabs/metadata-helpers');
5
6
  var bignumber_js = require('bignumber.js');
@@ -14,8 +15,8 @@ function BNToHex(bn) {
14
15
  return metadataHelpers.add0x(bn.toString(16));
15
16
  }
16
17
  function getEtherScanHashLink(txHash, chainId) {
17
- if (!constants.SUPPORTED_NETWORKS[chainId]) return "";
18
- return `${constants.SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
18
+ if (!constants.DEFAULT_SUPPORTED_NETWORKS[chainId]) return "";
19
+ return `${constants.DEFAULT_SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
19
20
  }
20
21
  /**
21
22
  * Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
@@ -65,7 +66,7 @@ function bnLessThan(a, b) {
65
66
  if (a === null || a === undefined || b === null || b === undefined) {
66
67
  return null;
67
68
  }
68
- return new bignumber_js.BigNumber(a, 10).lt(b, 10);
69
+ return new bignumber_js.BigNumber(a, 16).lt(b, 16);
69
70
  }
70
71
  const getIpfsEndpoint = path => `https://infura-ipfs.io/${path}`;
71
72
  function sanitizeNftMetdataUrl(url) {
@@ -84,6 +85,21 @@ function getChainType(chainId) {
84
85
  }
85
86
  return "custom";
86
87
  }
88
+ function getEvmRpcUrl(infuraKey, chainId) {
89
+ const subDomain = constants.INFURA_SUB_DOMAINS[chainId];
90
+ if (!subDomain) {
91
+ throw new Error(`chainId ${chainId} is not supported`);
92
+ }
93
+ return `https://${constants.INFURA_SUB_DOMAINS[chainId]}.infura.io/v3/${infuraKey}`;
94
+ }
95
+ function toRpcConfig(infuraKey, providerOverrides = constants.DEFAULT_SUPPORTED_NETWORKS) {
96
+ return Object.entries(providerOverrides).reduce((acc, [chainId, providerConfig]) => {
97
+ acc[chainId] = _objectSpread(_objectSpread({}, providerConfig), {}, {
98
+ rpcTarget: getEvmRpcUrl(infuraKey, chainId)
99
+ });
100
+ return acc;
101
+ }, {});
102
+ }
87
103
 
88
104
  exports.BNToHex = BNToHex;
89
105
  exports.GAS_LIMITS = GAS_LIMITS;
@@ -93,8 +109,10 @@ exports.formatTime = formatTime;
93
109
  exports.getChainType = getChainType;
94
110
  exports.getEthTxStatus = getEthTxStatus;
95
111
  exports.getEtherScanHashLink = getEtherScanHashLink;
112
+ exports.getEvmRpcUrl = getEvmRpcUrl;
96
113
  exports.getIpfsEndpoint = getIpfsEndpoint;
97
114
  exports.hexToBn = hexToBn;
98
115
  exports.isAddressByChainId = isAddressByChainId;
99
116
  exports.sanitizeNftMetdataUrl = sanitizeNftMetdataUrl;
100
117
  exports.toChecksumAddressByChainId = toChecksumAddressByChainId;
118
+ exports.toRpcConfig = toRpcConfig;
@@ -1,7 +1,7 @@
1
1
  import { add0x } from '@toruslabs/metadata-helpers';
2
2
  import { zeroAddress, encodeAbiParameters, parseAbiParameters, encodeFunctionData } from 'viem';
3
3
  import { erc7821Abi } from '../utils/abis.js';
4
- import { SUPPORTED_NETWORKS } from '../utils/constants.js';
4
+ import { SUPPORTED_CHAIN_IDS } from '../utils/constants.js';
5
5
  import { EIP_7702_PREFIX } from '../utils/eip7702Types.js';
6
6
 
7
7
  /**
@@ -25,7 +25,7 @@ async function getDelegationAddress(walletAddress, chainId, getEthCode) {
25
25
  * Check if the wallet is supported for EIP-7702 on provided chain.
26
26
  */
27
27
  async function getIsEip7702UpgradeSupported(address, chainId, getEthCode) {
28
- if (!SUPPORTED_NETWORKS[chainId]) {
28
+ if (!SUPPORTED_CHAIN_IDS.includes(chainId)) {
29
29
  return {
30
30
  isSupported: false,
31
31
  delegationAddress: null
@@ -125,13 +125,13 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
125
125
  high,
126
126
  estimatedBaseFee
127
127
  } = gasFeeEstimates;
128
- const maxPriorityFeePerGasInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(maxPriorityFeePerGas)), 16);
129
- const maxFeePerGasInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(maxFeePerGas)), 16);
130
- const estimatedBaseFeeInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(estimatedBaseFee)), 16);
128
+ const maxPriorityFeePerGasInWEI = decGWEIToHexWEI(new BigNumber(maxPriorityFeePerGas));
129
+ const maxFeePerGasInWEI = decGWEIToHexWEI(new BigNumber(maxFeePerGas));
130
+ const estimatedBaseFeeInWEI = decGWEIToHexWEI(new BigNumber(estimatedBaseFee));
131
131
  const effectiveMaxPriorityFee = BigNumber.min(maxPriorityFeePerGasInWEI, maxFeePerGasInWEI.minus(estimatedBaseFeeInWEI));
132
- const lowMaxPriorityFeeInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(low.suggestedMaxPriorityFeePerGas)), 16);
133
- const mediumMaxPriorityFeeInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(medium.suggestedMaxPriorityFeePerGas)), 16);
134
- const highMaxPriorityFeeInWEI = new BigNumber(decGWEIToHexWEI(new BigNumber(high.suggestedMaxPriorityFeePerGas)), 16);
132
+ const lowMaxPriorityFeeInWEI = decGWEIToHexWEI(new BigNumber(low.suggestedMaxPriorityFeePerGas));
133
+ const mediumMaxPriorityFeeInWEI = decGWEIToHexWEI(new BigNumber(medium.suggestedMaxPriorityFeePerGas));
134
+ const highMaxPriorityFeeInWEI = decGWEIToHexWEI(new BigNumber(high.suggestedMaxPriorityFeePerGas));
135
135
  let lowerTimeBound;
136
136
  let upperTimeBound;
137
137
  if (effectiveMaxPriorityFee.lt(lowMaxPriorityFeeInWEI)) {
@@ -5,7 +5,8 @@ import { BaseController, createAnalyticsMiddleware, createSwappableProxy, create
5
5
  import { JRPCEngineV2, providerFromEngineV2 } from '@web3auth/auth';
6
6
  import { Mutex } from 'async-mutex';
7
7
  import log from 'loglevel';
8
- import { SUPPORTED_NETWORKS, MAINNET_CHAIN_ID } from '../utils/constants.js';
8
+ import { MAINNET_CHAIN_ID } from '../utils/constants.js';
9
+ import { toRpcConfig } from '../utils/helpers.js';
9
10
  import { createEthereumMiddleware } from './createEthereumMiddleware.js';
10
11
  import { createJsonRpcClient } from './createJsonRpcClient.js';
11
12
 
@@ -30,12 +31,20 @@ class NetworkController extends BaseController {
30
31
  _defineProperty(this, "baseProviderHandlers", void 0);
31
32
  _defineProperty(this, "idleTimeTracker", void 0);
32
33
  _defineProperty(this, "analytics", void 0);
34
+ let providerConfig;
35
+ if (config !== null && config !== void 0 && config.providerConfig) {
36
+ providerConfig = config.providerConfig;
37
+ } else if (config !== null && config !== void 0 && config.infuraKey) {
38
+ providerConfig = toRpcConfig(config.infuraKey)[MAINNET_CHAIN_ID];
39
+ } else {
40
+ throw new Error("providerConfig or infuraKey must be provided");
41
+ }
33
42
  this.defaultState = {
34
43
  chainId: "loading",
35
44
  properties: {
36
45
  EIPS_1559: undefined
37
46
  },
38
- providerConfig: SUPPORTED_NETWORKS[MAINNET_CHAIN_ID]
47
+ providerConfig
39
48
  };
40
49
  this.analytics = analytics;
41
50
 
@@ -2,7 +2,6 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import { BasePreferencesController, CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
3
3
  import { remove0x } from '@toruslabs/metadata-helpers';
4
4
  import log from 'loglevel';
5
- import { SUPPORTED_NETWORKS } from '../utils/constants.js';
6
5
 
7
6
  class PreferencesController extends BasePreferencesController {
8
7
  constructor({
@@ -25,8 +24,10 @@ class PreferencesController extends BasePreferencesController {
25
24
  _defineProperty(this, "chainNamespace", CHAIN_NAMESPACES.EIP155);
26
25
  _defineProperty(this, "getProviderConfig", void 0);
27
26
  _defineProperty(this, "setProviderConfig", void 0);
27
+ _defineProperty(this, "supportedNetworks", void 0);
28
28
  this.getProviderConfig = getProviderConfig;
29
29
  this.setProviderConfig = setProviderConfig;
30
+ this.supportedNetworks = config.supportedNetworks;
30
31
  }
31
32
  async initPreferences(params) {
32
33
  const {
@@ -140,7 +141,7 @@ class PreferencesController extends BasePreferencesController {
140
141
  }
141
142
  }
142
143
  getChainOptions() {
143
- return Object.values(SUPPORTED_NETWORKS);
144
+ return Object.values(this.supportedNetworks);
144
145
  }
145
146
  }
146
147
 
@@ -25,11 +25,11 @@ export { generateHistoryEntry, replayHistory, snapshotFromTxMeta } from './Trans
25
25
  export { TransactionStateManager } from './Transaction/TransactionStateManager.js';
26
26
  export { createNestedTransactionMeta, determineTransactionType, ensureFieldIsString, ensureMutuallyExclusiveFieldsNotProvided, getFinalStates, isEIP1559Transaction, isEip7702SetCodeTx, isEip7702UpgradeWithDataToSelfTransaction, isLegacyTransaction, normalizeAndValidateTxParams, normalizeTxParameters, parseStandardTokenTransactionData, readAddressAsContract, transactionMatchesNetwork, validateFrom, validateRecipient, validateTxParameters } from './Transaction/TransactionUtils.js';
27
27
  export { erc1155Abi, erc20Abi, erc721Abi, erc7821Abi, singleBalanceCheckerAbi } from './utils/abis.js';
28
- export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SMART_ACCOUNT_EIP_STANDARD, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID } from './utils/constants.js';
28
+ export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_SEPOLIA_CHAIN_ID, AVALANCHE_FUJI_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, DEFAULT_SUPPORTED_NETWORKS, EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, INFURA_SUB_DOMAINS, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_SEPOLIA_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SMART_ACCOUNT_EIP_STANDARD, SUPPORTED_CHAIN_IDS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID } from './utils/constants.js';
29
29
  export { addCurrencies, conversionGTE, conversionGreaterThan, conversionLTE, conversionLessThan, conversionMax, conversionUtil, decGWEIToHexWEI, getBigNumber, hexWEIToDecGWEI, multiplyCurrencies, subtractCurrencies, toNegative } from './utils/conversionUtils.js';
30
30
  export { EIP5792ErrorCode, EIP_5792_METHODS, Eip5792AtomicStatus, GetCallsStatusCode } from './utils/eip5792Types.js';
31
31
  export { DUMMY_AUTHORIZATION_SIGNATURE, EIP_7702_METHODS, EIP_7702_PREFIX, EIP_7702_REVOKE_ADDRESS } from './utils/eip7702Types.js';
32
- export { BNToHex, GAS_LIMITS, bnLessThan, formatDate, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId } from './utils/helpers.js';
32
+ export { BNToHex, GAS_LIMITS, bnLessThan, formatDate, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getEvmRpcUrl, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId, toRpcConfig } from './utils/helpers.js';
33
33
  export { TRANSACTION_CATEGORY_EIP7702 } from './utils/interfaces.js';
34
34
  export { BiconomySmartAccount } from './AccountAbstraction/smartAccounts/BiconomySmartAccount.js';
35
35
  export { CacheStrategy, blockTagParamIndex, cacheIdentifierForRequest, cacheTypeForMethod } from './Network/cacheIdentifier.js';
@@ -1,4 +1,4 @@
1
- import { CHAIN_NAMESPACES, getEnvVariable } from '@toruslabs/base-controllers';
1
+ import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
2
2
 
3
3
  const LOCALHOST = "localhost";
4
4
  const CONTRACT_TYPE_ETH = "eth";
@@ -23,16 +23,35 @@ const LINEA_CHAIN_ID = "0xe708";
23
23
  const SEPOLIA_CHAIN_ID = "0xaa36a7";
24
24
  const POLYGON_AMOY_CHAIN_ID = "0x13882";
25
25
  const BSC_TESTNET_CHAIN_ID = "0x61";
26
- const AVALANCHE_TESTNET_CHAIN_ID = "0xa869";
27
- const ARBITRUM_TESTNET_CHAIN_ID = "0x66eee";
28
- const OPTIMISM_TESTNET_CHAIN_ID = "0xaa37dc";
29
- const BASE_TESTNET_CHAIN_ID = "0x14a34";
26
+ const AVALANCHE_FUJI_CHAIN_ID = "0xa869";
27
+ const ARBITRUM_SEPOLIA_CHAIN_ID = "0x66eee";
28
+ const OPTIMISM_SEPOLIA_CHAIN_ID = "0xaa37dc";
29
+ const BASE_SEPOLIA_CHAIN_ID = "0x14a34";
30
30
  const LINEA_SEPOLIA_CHAIN_ID = "0xe705";
31
+ const INFURA_SUB_DOMAINS = {
32
+ [MAINNET_CHAIN_ID]: "mainnet",
33
+ [POLYGON_CHAIN_ID]: "polygon-mainnet",
34
+ [BSC_MAINNET_CHAIN_ID]: "bsc-mainnet",
35
+ [AVALANCHE_MAINNET_CHAIN_ID]: "avalanche-mainnet",
36
+ [OPTIMISM_MAINNET_CHAIN_ID]: "optimism-mainnet",
37
+ [CELO_MAINNET_CHAIN_ID]: "celo-mainnet",
38
+ [ARBITRUM_MAINNET_CHAIN_ID]: "arbitrum-mainnet",
39
+ [BASE_CHAIN_ID]: "base-mainnet",
40
+ [LINEA_CHAIN_ID]: "linea-mainnet",
41
+ [SEPOLIA_CHAIN_ID]: "sepolia",
42
+ [LINEA_SEPOLIA_CHAIN_ID]: "linea-sepolia",
43
+ [POLYGON_AMOY_CHAIN_ID]: "polygon-amoy",
44
+ [BSC_TESTNET_CHAIN_ID]: "bsc-testnet",
45
+ [AVALANCHE_FUJI_CHAIN_ID]: "avalanche-fuji",
46
+ [ARBITRUM_SEPOLIA_CHAIN_ID]: "arbitrum-sepolia",
47
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: "optimism-sepolia",
48
+ [BASE_SEPOLIA_CHAIN_ID]: "base-sepolia"
49
+ };
31
50
 
32
- // Don't change this. It will break production builds.
33
- // We use this syntax because if both injections fail, we replace the "process.env.VITE_APP_INFURA_PROJECT_KEY" using define replacement
34
- const INFURA_KEY = getEnvVariable("VITE_APP_INFURA_PROJECT_KEY") || process.env.VITE_APP_INFURA_PROJECT_KEY;
35
- const SUPPORTED_NETWORKS = {
51
+ /**
52
+ * Default supported networks for the Ethereum controllers.
53
+ */
54
+ const DEFAULT_SUPPORTED_NETWORKS = {
36
55
  [MAINNET_CHAIN_ID]: {
37
56
  chainNamespace: CHAIN_NAMESPACES.EIP155,
38
57
  decimals: 18,
@@ -40,7 +59,7 @@ const SUPPORTED_NETWORKS = {
40
59
  chainId: MAINNET_CHAIN_ID,
41
60
  displayName: "Ethereum",
42
61
  logo: "eth.svg",
43
- rpcTarget: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
62
+ rpcTarget: "https://ethereum-rpc.publicnode.com",
44
63
  ticker: "ETH",
45
64
  tickerName: "Ethereum"
46
65
  },
@@ -51,7 +70,7 @@ const SUPPORTED_NETWORKS = {
51
70
  chainId: POLYGON_CHAIN_ID,
52
71
  displayName: "Polygon",
53
72
  logo: "polygon.svg",
54
- rpcTarget: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
73
+ rpcTarget: "https://polygon-bor-rpc.publicnode.com",
55
74
  ticker: "POL",
56
75
  tickerName: "Polygon Ecosystem Token"
57
76
  },
@@ -84,7 +103,7 @@ const SUPPORTED_NETWORKS = {
84
103
  chainId: OPTIMISM_MAINNET_CHAIN_ID,
85
104
  displayName: "Optimism",
86
105
  logo: "optimism.svg",
87
- rpcTarget: `https://optimism-mainnet.infura.io/v3/${INFURA_KEY}`,
106
+ rpcTarget: "https://optimism-rpc.publicnode.com",
88
107
  ticker: "ETH",
89
108
  tickerName: "Ethereum"
90
109
  },
@@ -95,7 +114,7 @@ const SUPPORTED_NETWORKS = {
95
114
  chainId: CELO_MAINNET_CHAIN_ID,
96
115
  displayName: "Celo Mainnet",
97
116
  logo: "celo.svg",
98
- rpcTarget: `https://celo-mainnet.infura.io/v3/${INFURA_KEY}`,
117
+ rpcTarget: "https://forno.celo.org",
99
118
  ticker: "CELO",
100
119
  tickerName: "Celo"
101
120
  },
@@ -106,7 +125,7 @@ const SUPPORTED_NETWORKS = {
106
125
  chainId: ARBITRUM_MAINNET_CHAIN_ID,
107
126
  displayName: "Arbitrum One",
108
127
  logo: "arbitrum.svg",
109
- rpcTarget: `https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`,
128
+ rpcTarget: "https://arbitrum-one-rpc.publicnode.com",
110
129
  ticker: "ETH",
111
130
  tickerName: "Ethereum"
112
131
  },
@@ -128,7 +147,7 @@ const SUPPORTED_NETWORKS = {
128
147
  chainId: LINEA_CHAIN_ID,
129
148
  displayName: "Linea",
130
149
  logo: "linea.svg",
131
- rpcTarget: `https://linea-mainnet.infura.io/v3/${INFURA_KEY}`,
150
+ rpcTarget: "https://rpc.linea.build",
132
151
  ticker: "ETH",
133
152
  tickerName: "Ethereum"
134
153
  },
@@ -139,7 +158,7 @@ const SUPPORTED_NETWORKS = {
139
158
  chainId: SEPOLIA_CHAIN_ID,
140
159
  displayName: "Sepolia Test Network",
141
160
  logo: "eth.svg",
142
- rpcTarget: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
161
+ rpcTarget: "https://ethereum-sepolia-rpc.publicnode.com",
143
162
  ticker: "ETH",
144
163
  tickerName: "Ethereum",
145
164
  isTestnet: true
@@ -151,7 +170,7 @@ const SUPPORTED_NETWORKS = {
151
170
  chainId: LINEA_SEPOLIA_CHAIN_ID,
152
171
  displayName: "Linea Sepolia Testnet",
153
172
  logo: "linea.svg",
154
- rpcTarget: `https://linea-sepolia.infura.io/v3/${INFURA_KEY}`,
173
+ rpcTarget: "https://rpc.sepolia.linea.build",
155
174
  ticker: "ETH",
156
175
  tickerName: "Ethereum",
157
176
  isTestnet: true
@@ -163,7 +182,7 @@ const SUPPORTED_NETWORKS = {
163
182
  chainId: POLYGON_AMOY_CHAIN_ID,
164
183
  displayName: "Polygon Amoy",
165
184
  logo: "polygon.svg",
166
- rpcTarget: `https://polygon-amoy.infura.io/v3/${INFURA_KEY}`,
185
+ rpcTarget: "https://rpc-amoy.polygon.technology",
167
186
  ticker: "POL",
168
187
  tickerName: "Polygon Ecosystem Token",
169
188
  isTestnet: true
@@ -180,11 +199,11 @@ const SUPPORTED_NETWORKS = {
180
199
  tickerName: "Binance Coin",
181
200
  isTestnet: true
182
201
  },
183
- [AVALANCHE_TESTNET_CHAIN_ID]: {
202
+ [AVALANCHE_FUJI_CHAIN_ID]: {
184
203
  chainNamespace: CHAIN_NAMESPACES.EIP155,
185
204
  decimals: 18,
186
205
  blockExplorerUrl: "https://testnet.snowtrace.io",
187
- chainId: AVALANCHE_TESTNET_CHAIN_ID,
206
+ chainId: AVALANCHE_FUJI_CHAIN_ID,
188
207
  displayName: "Avalanche Testnet C-Chain",
189
208
  logo: "avax.svg",
190
209
  rpcTarget: `https://api.avax-test.network/ext/bc/C/rpc`,
@@ -192,35 +211,35 @@ const SUPPORTED_NETWORKS = {
192
211
  tickerName: "Avalanche",
193
212
  isTestnet: true
194
213
  },
195
- [ARBITRUM_TESTNET_CHAIN_ID]: {
214
+ [ARBITRUM_SEPOLIA_CHAIN_ID]: {
196
215
  chainNamespace: CHAIN_NAMESPACES.EIP155,
197
216
  decimals: 18,
198
217
  blockExplorerUrl: "https://sepolia.arbiscan.io",
199
- chainId: ARBITRUM_TESTNET_CHAIN_ID,
218
+ chainId: ARBITRUM_SEPOLIA_CHAIN_ID,
200
219
  displayName: "Arbitrum Sepolia",
201
220
  logo: "arbitrum.svg",
202
- rpcTarget: `https://arbitrum-sepolia.infura.io/v3/${INFURA_KEY}`,
221
+ rpcTarget: "https://arbitrum-sepolia-rpc.publicnode.com",
203
222
  ticker: "ETH",
204
223
  tickerName: "Ethereum",
205
224
  isTestnet: true
206
225
  },
207
- [OPTIMISM_TESTNET_CHAIN_ID]: {
226
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: {
208
227
  chainNamespace: CHAIN_NAMESPACES.EIP155,
209
228
  decimals: 18,
210
229
  blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
211
- chainId: OPTIMISM_TESTNET_CHAIN_ID,
230
+ chainId: OPTIMISM_SEPOLIA_CHAIN_ID,
212
231
  displayName: "Optimism Sepolia",
213
232
  logo: "optimism.svg",
214
- rpcTarget: `https://optimism-sepolia.infura.io/v3/${INFURA_KEY}`,
233
+ rpcTarget: "https://optimism-sepolia-rpc.publicnode.com",
215
234
  ticker: "ETH",
216
235
  tickerName: "Ethereum",
217
236
  isTestnet: true
218
237
  },
219
- [BASE_TESTNET_CHAIN_ID]: {
238
+ [BASE_SEPOLIA_CHAIN_ID]: {
220
239
  chainNamespace: CHAIN_NAMESPACES.EIP155,
221
240
  decimals: 18,
222
241
  blockExplorerUrl: "https://sepolia.basescan.org",
223
- chainId: BASE_TESTNET_CHAIN_ID,
242
+ chainId: BASE_SEPOLIA_CHAIN_ID,
224
243
  displayName: "Base Sepolia",
225
244
  logo: "base.svg",
226
245
  rpcTarget: `https://sepolia.base.org`,
@@ -229,6 +248,7 @@ const SUPPORTED_NETWORKS = {
229
248
  isTestnet: true
230
249
  }
231
250
  };
251
+ const SUPPORTED_CHAIN_IDS = Object.keys(DEFAULT_SUPPORTED_NETWORKS);
232
252
  const METHOD_TYPES = {
233
253
  GET_ACCOUNTS: "eth_accounts",
234
254
  ETH_TRANSACTION: "eth_sendTransaction",
@@ -302,7 +322,7 @@ const GAS_ESTIMATE_TYPES = {
302
322
  // https://help.optimism.io/hc/en-us/articles/4411895794715-Transaction-fees
303
323
  const CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP = {
304
324
  [OPTIMISM_MAINNET_CHAIN_ID]: 1,
305
- [OPTIMISM_TESTNET_CHAIN_ID]: 1
325
+ [OPTIMISM_SEPOLIA_CHAIN_ID]: 1
306
326
  };
307
327
  const OLD_ERC721_LIST = {
308
328
  "0x06012c8cf97bead5deae237070f9587f8e7a266d": {
@@ -314,7 +334,7 @@ const OLD_ERC721_LIST = {
314
334
  }
315
335
  };
316
336
  const TEST_CHAINS = [SEPOLIA_CHAIN_ID];
317
- const MM_TOKEN_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, POLYGON_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, CELO_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID];
337
+ const MM_TOKEN_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_SEPOLIA_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_FUJI_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_SEPOLIA_CHAIN_ID, POLYGON_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, CELO_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID];
318
338
  const MM_NFT_API_SUPPORTED_CHAINS = [MAINNET_CHAIN_ID, POLYGON_CHAIN_ID, BSC_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, LINEA_CHAIN_ID, BASE_CHAIN_ID];
319
339
  const COINGECKO_SUPPORTED_CURRENCIES = new Set(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats"]);
320
340
  const COINGECKO_PLATFORMS_CHAIN_CODE_MAP = {
@@ -372,4 +392,4 @@ const SMART_ACCOUNT_EIP_STANDARD = {
372
392
  };
373
393
  const EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES = [SMART_ACCOUNT.METAMASK];
374
394
 
375
- export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SMART_ACCOUNT_EIP_STANDARD, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID };
395
+ export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_SEPOLIA_CHAIN_ID, AVALANCHE_FUJI_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, BUNDLER_METHOD_TYPES, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC7821, CONTRACT_TYPE_ETH, DEFAULT_SUPPORTED_NETWORKS, EIP7702_SUPPORTED_SMART_ACCOUNT_TYPES, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, INFURA_SUB_DOMAINS, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_SEPOLIA_CHAIN_ID, PAYMASTER_METHOD_TYPES, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SMART_ACCOUNT_EIP_STANDARD, SUPPORTED_CHAIN_IDS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID };
@@ -1,9 +1,10 @@
1
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
2
  import { TransactionStatus } from '@toruslabs/base-controllers';
2
3
  import { add0x, remove0x } from '@toruslabs/metadata-helpers';
3
4
  import { BigNumber } from 'bignumber.js';
4
5
  import log from 'loglevel';
5
6
  import { toHex, isAddress, getAddress } from 'viem';
6
- import { MAINNET_CHAIN_ID, TEST_CHAINS, METHOD_TYPES, SUPPORTED_NETWORKS } from './constants.js';
7
+ import { DEFAULT_SUPPORTED_NETWORKS, MAINNET_CHAIN_ID, TEST_CHAINS, METHOD_TYPES, INFURA_SUB_DOMAINS } from './constants.js';
7
8
 
8
9
  function hexToBn(hex) {
9
10
  return new BigNumber(remove0x(hex), 16);
@@ -12,8 +13,8 @@ function BNToHex(bn) {
12
13
  return add0x(bn.toString(16));
13
14
  }
14
15
  function getEtherScanHashLink(txHash, chainId) {
15
- if (!SUPPORTED_NETWORKS[chainId]) return "";
16
- return `${SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
16
+ if (!DEFAULT_SUPPORTED_NETWORKS[chainId]) return "";
17
+ return `${DEFAULT_SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
17
18
  }
18
19
 
19
20
  /**
@@ -64,7 +65,7 @@ function bnLessThan(a, b) {
64
65
  if (a === null || a === undefined || b === null || b === undefined) {
65
66
  return null;
66
67
  }
67
- return new BigNumber(a, 10).lt(b, 10);
68
+ return new BigNumber(a, 16).lt(b, 16);
68
69
  }
69
70
  const getIpfsEndpoint = path => `https://infura-ipfs.io/${path}`;
70
71
  function sanitizeNftMetdataUrl(url) {
@@ -83,5 +84,20 @@ function getChainType(chainId) {
83
84
  }
84
85
  return "custom";
85
86
  }
87
+ function getEvmRpcUrl(infuraKey, chainId) {
88
+ const subDomain = INFURA_SUB_DOMAINS[chainId];
89
+ if (!subDomain) {
90
+ throw new Error(`chainId ${chainId} is not supported`);
91
+ }
92
+ return `https://${INFURA_SUB_DOMAINS[chainId]}.infura.io/v3/${infuraKey}`;
93
+ }
94
+ function toRpcConfig(infuraKey, providerOverrides = DEFAULT_SUPPORTED_NETWORKS) {
95
+ return Object.entries(providerOverrides).reduce((acc, [chainId, providerConfig]) => {
96
+ acc[chainId] = _objectSpread(_objectSpread({}, providerConfig), {}, {
97
+ rpcTarget: getEvmRpcUrl(infuraKey, chainId)
98
+ });
99
+ return acc;
100
+ }, {});
101
+ }
86
102
 
87
- export { BNToHex, GAS_LIMITS, bnLessThan, formatDate, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId };
103
+ export { BNToHex, GAS_LIMITS, bnLessThan, formatDate, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getEvmRpcUrl, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId, toRpcConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -21,18 +21,19 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@metamask/smart-accounts-kit": "~1.0.0",
24
- "@toruslabs/base-controllers": "^9.5.0",
24
+ "@toruslabs/base-controllers": "^9.6.0",
25
25
  "@toruslabs/http-helpers": "^9.0.0",
26
26
  "@toruslabs/metadata-helpers": "^8.2.0",
27
- "@web3auth/auth": "^11.4.3",
27
+ "@web3auth/auth": "^11.5.0",
28
28
  "async-mutex": "^0.5.0",
29
- "bignumber.js": "^9.3.1",
29
+ "bignumber.js": "^10.0.2",
30
30
  "deepmerge": "^4.3.1",
31
31
  "ethereum-cryptography": "^3.2.0",
32
32
  "fast-json-patch": "^3.1.1",
33
33
  "fast-safe-stringify": "^2.1.1",
34
34
  "jsonschema": "^1.5.0",
35
35
  "loglevel": "^1.9.2",
36
+ "ox": "^0.11.3",
36
37
  "permissionless": "^0.3.4",
37
38
  "uuid": "^13.0.0"
38
39
  },
@@ -64,7 +65,7 @@
64
65
  "publishConfig": {
65
66
  "access": "public"
66
67
  },
67
- "gitHead": "73ff01e2c500992820714184ab929becd9478813",
68
+ "gitHead": "61db52e87e15b6488acee8766b2db61e541a73eb",
68
69
  "devDependencies": {
69
70
  "@types/uuid": "^11.0.0",
70
71
  "typechain": "^8.3.2"