@imtbl/sdk 0.36.2 → 0.36.4

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/dist/index.cjs CHANGED
@@ -4256,7 +4256,7 @@ class MultiRollupApiClients {
4256
4256
  }
4257
4257
 
4258
4258
  // eslint-disable-next-line @typescript-eslint/naming-convention
4259
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.2' };
4259
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.4' };
4260
4260
  const createConfig = ({ basePath, headers, }) => {
4261
4261
  if (!basePath.trim()) {
4262
4262
  throw Error('basePath can not be empty');
@@ -4316,7 +4316,7 @@ class APIError extends Error {
4316
4316
 
4317
4317
  /* eslint-disable implicit-arrow-linebreak */
4318
4318
  const defaultHeaders = {
4319
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.2',
4319
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.4',
4320
4320
  };
4321
4321
  /**
4322
4322
  * createAPIConfiguration to create a custom Configuration
@@ -4755,7 +4755,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4755
4755
  chainID,
4756
4756
  coreContractAddress,
4757
4757
  registrationContractAddress,
4758
- sdkVersion: 'ts-immutable-sdk-0.36.2',
4758
+ sdkVersion: 'ts-immutable-sdk-0.36.4',
4759
4759
  });
4760
4760
  /**
4761
4761
  * Sets `sdkVersion` at the time of build
@@ -26775,59 +26775,18 @@ function parseUnits(value, unitName) {
26775
26775
  return parseFixed(value, (unitName != null) ? unitName : 18);
26776
26776
  }
26777
26777
 
26778
- /**
26779
- * @typedef {Object} CompletionStatus
26780
- * @property {string} SUCCESS - The transaction has been successfully synced.
26781
- * @property {string} PENDING - The transaction is still pending.
26782
- * @property {string} FAILED - The transaction has failed.
26783
- */
26784
- var CompletionStatus;
26785
- (function (CompletionStatus) {
26786
- CompletionStatus["SUCCESS"] = "SUCCESS";
26787
- CompletionStatus["PENDING"] = "PENDING";
26788
- CompletionStatus["FAILED"] = "FAILED";
26789
- })(CompletionStatus || (CompletionStatus = {}));
26790
- /**
26791
- * @typedef {Object} BridgeFeeActions
26792
- * @property {string} DEPOSIT - The transaction has been successfully synced.
26793
- * @property {string} WITHDRAW - The transaction is still pending.
26794
- * @property {string} FINALISE_WITHDRAWAL - Calculate gas .
26795
- */
26796
- var BridgeFeeActions;
26797
- (function (BridgeFeeActions) {
26798
- BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
26799
- BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
26800
- BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
26801
- })(BridgeFeeActions || (BridgeFeeActions = {}));
26802
- /**
26803
- * @typedef {Object} BridgeMethodGas
26804
- * @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
26805
- * @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
26806
- * @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
26807
- * @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
26808
- * @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
26809
- */
26810
- var BridgeMethodsGasLimit;
26811
- (function (BridgeMethodsGasLimit) {
26812
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
26813
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
26814
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
26815
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
26816
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
26817
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
26818
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
26819
- })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
26820
- var StatusResponse;
26821
- (function (StatusResponse) {
26822
- StatusResponse["PROCESSING"] = "PROCESSING";
26823
- StatusResponse["COMPLETE"] = "COMPLETE";
26824
- StatusResponse["RETRY"] = "RETRY";
26825
- StatusResponse["ERROR"] = "ERROR";
26826
- StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
26827
- StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
26828
- })(StatusResponse || (StatusResponse = {}));
26829
-
26830
26778
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
26779
+ {
26780
+ inputs: [
26781
+ {
26782
+ internalType: 'address',
26783
+ name: '_initializerAddress',
26784
+ type: 'address',
26785
+ },
26786
+ ],
26787
+ stateMutability: 'nonpayable',
26788
+ type: 'constructor',
26789
+ },
26831
26790
  {
26832
26791
  inputs: [],
26833
26792
  name: 'AlreadyMapped',
@@ -26978,6 +26937,16 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
26978
26937
  name: 'TokenIsZero',
26979
26938
  type: 'error',
26980
26939
  },
26940
+ {
26941
+ inputs: [],
26942
+ name: 'TokenNotSupported',
26943
+ type: 'error',
26944
+ },
26945
+ {
26946
+ inputs: [],
26947
+ name: 'UnauthorizedInitializer',
26948
+ type: 'error',
26949
+ },
26981
26950
  {
26982
26951
  inputs: [
26983
26952
  {
@@ -28401,6 +28370,19 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
28401
28370
  stateMutability: 'pure',
28402
28371
  type: 'function',
28403
28372
  },
28373
+ {
28374
+ inputs: [],
28375
+ name: 'initializerAddress',
28376
+ outputs: [
28377
+ {
28378
+ internalType: 'address',
28379
+ name: '',
28380
+ type: 'address',
28381
+ },
28382
+ ],
28383
+ stateMutability: 'view',
28384
+ type: 'function',
28385
+ },
28404
28386
  {
28405
28387
  inputs: [
28406
28388
  {
@@ -29097,6 +29079,17 @@ const withBridgeError = async (fn, customErrorType, details) => {
29097
29079
  };
29098
29080
 
29099
29081
  const CHILD_ERC20_BRIDGE = [
29082
+ {
29083
+ inputs: [
29084
+ {
29085
+ internalType: 'address',
29086
+ name: '_initializerAddress',
29087
+ type: 'address',
29088
+ },
29089
+ ],
29090
+ stateMutability: 'nonpayable',
29091
+ type: 'constructor',
29092
+ },
29100
29093
  {
29101
29094
  inputs: [],
29102
29095
  name: 'AlreadyMapped',
@@ -29199,6 +29192,11 @@ const CHILD_ERC20_BRIDGE = [
29199
29192
  name: 'TransferWIMXFailed',
29200
29193
  type: 'error',
29201
29194
  },
29195
+ {
29196
+ inputs: [],
29197
+ name: 'UnauthorizedInitializer',
29198
+ type: 'error',
29199
+ },
29202
29200
  {
29203
29201
  inputs: [],
29204
29202
  name: 'ZeroAddress',
@@ -29953,6 +29951,19 @@ const CHILD_ERC20_BRIDGE = [
29953
29951
  stateMutability: 'nonpayable',
29954
29952
  type: 'function',
29955
29953
  },
29954
+ {
29955
+ inputs: [],
29956
+ name: 'initializerAddress',
29957
+ outputs: [
29958
+ {
29959
+ internalType: 'address',
29960
+ name: '',
29961
+ type: 'address',
29962
+ },
29963
+ ],
29964
+ stateMutability: 'view',
29965
+ type: 'function',
29966
+ },
29956
29967
  {
29957
29968
  inputs: [
29958
29969
  {
@@ -30302,6 +30313,58 @@ const getGasPriceInWei$1 = (feeData) => {
30302
30313
  return null;
30303
30314
  };
30304
30315
 
30316
+ /**
30317
+ * @typedef {Object} CompletionStatus
30318
+ * @property {string} SUCCESS - The transaction has been successfully synced.
30319
+ * @property {string} PENDING - The transaction is still pending.
30320
+ * @property {string} FAILED - The transaction has failed.
30321
+ */
30322
+ var CompletionStatus;
30323
+ (function (CompletionStatus) {
30324
+ CompletionStatus["SUCCESS"] = "SUCCESS";
30325
+ CompletionStatus["PENDING"] = "PENDING";
30326
+ CompletionStatus["FAILED"] = "FAILED";
30327
+ })(CompletionStatus || (CompletionStatus = {}));
30328
+ /**
30329
+ * @typedef {Object} BridgeFeeActions
30330
+ * @property {string} DEPOSIT - The transaction has been successfully synced.
30331
+ * @property {string} WITHDRAW - The transaction is still pending.
30332
+ * @property {string} FINALISE_WITHDRAWAL - Calculate gas .
30333
+ */
30334
+ var BridgeFeeActions;
30335
+ (function (BridgeFeeActions) {
30336
+ BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
30337
+ BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
30338
+ BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
30339
+ })(BridgeFeeActions || (BridgeFeeActions = {}));
30340
+ /**
30341
+ * @typedef {Object} BridgeMethodGas
30342
+ * @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
30343
+ * @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
30344
+ * @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
30345
+ * @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
30346
+ * @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
30347
+ */
30348
+ var BridgeMethodsGasLimit;
30349
+ (function (BridgeMethodsGasLimit) {
30350
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
30351
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
30352
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
30353
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
30354
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
30355
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
30356
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
30357
+ })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
30358
+ var StatusResponse;
30359
+ (function (StatusResponse) {
30360
+ StatusResponse["PROCESSING"] = "PROCESSING";
30361
+ StatusResponse["COMPLETE"] = "COMPLETE";
30362
+ StatusResponse["RETRY"] = "RETRY";
30363
+ StatusResponse["ERROR"] = "ERROR";
30364
+ StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
30365
+ StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
30366
+ })(StatusResponse || (StatusResponse = {}));
30367
+
30305
30368
  /* eslint-disable class-methods-use-this */
30306
30369
  /**
30307
30370
  * Represents a token bridge, which manages asset transfers between two chains.
@@ -30922,8 +30985,8 @@ const CONTRACTS_FOR_BRIDGE = new Map()
30922
30985
  wrappedIMX: '0x0',
30923
30986
  })
30924
30987
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
30925
- rootERC20BridgeFlowRate: '0x8d4528775a4406Def316DC2b450eE539750F8FAA',
30926
- childERC20Bridge: '0xb0f971e2d11A4D410148af51b170D64E725c0bB9',
30988
+ rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30989
+ childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30927
30990
  wrappedIMX: '0xa86C6C6d3D51c0592BE85dA05A9b06B62360D56E',
30928
30991
  })
30929
30992
  .set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
@@ -34635,12 +34698,12 @@ var ChainId;
34635
34698
  })(ChainId || (ChainId = {}));
34636
34699
  /**
34637
34700
  * Enum representing different chain names.
34638
- * @enum {number}
34639
- * @property {number} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
34640
- * @property {number} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
34641
- * @property {number} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
34642
- * @property {number} ETHEREUM - The chain name for Ethereum.
34643
- * @property {number} SEPOLIA - The chain name for Sepolia.
34701
+ * @enum {string}
34702
+ * @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
34703
+ * @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
34704
+ * @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
34705
+ * @property {string} ETHEREUM - The chain name for Ethereum.
34706
+ * @property {string} SEPOLIA - The chain name for Sepolia.
34644
34707
  */
34645
34708
  var ChainName;
34646
34709
  (function (ChainName) {
@@ -34650,6 +34713,23 @@ var ChainName;
34650
34713
  ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
34651
34714
  ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
34652
34715
  })(ChainName || (ChainName = {}));
34716
+ /**
34717
+ * Enum representing different chain slugs.
34718
+ * @enum {string}
34719
+ * @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
34720
+ * @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
34721
+ * @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
34722
+ * @property {string} ETHEREUM - The chain slug for Ethereum.
34723
+ * @property {string} SEPOLIA - The chain slug for Sepolia.
34724
+ */
34725
+ var ChainSlug;
34726
+ (function (ChainSlug) {
34727
+ ChainSlug["ETHEREUM"] = "ethereum";
34728
+ ChainSlug["SEPOLIA"] = "sepolia";
34729
+ ChainSlug["IMTBL_ZKEVM_MAINNET"] = "imtbl-zkevm-mainnet";
34730
+ ChainSlug["IMTBL_ZKEVM_TESTNET"] = "imtbl-zkevm-testnet";
34731
+ ChainSlug["IMTBL_ZKEVM_DEVNET"] = "imtbl-zkevm-devnet";
34732
+ })(ChainSlug || (ChainSlug = {}));
34653
34733
 
34654
34734
  var OnRampProvider;
34655
34735
  (function (OnRampProvider) {
@@ -34807,12 +34887,14 @@ var ExchangeType;
34807
34887
  */
34808
34888
  var CheckoutErrorType;
34809
34889
  (function (CheckoutErrorType) {
34890
+ CheckoutErrorType["MISSING_PARAMS"] = "MISSING_PARAMS";
34810
34891
  CheckoutErrorType["WEB3_PROVIDER_ERROR"] = "WEB3_PROVIDER_ERROR";
34811
34892
  CheckoutErrorType["PROVIDER_ERROR"] = "PROVIDER_ERROR";
34812
34893
  CheckoutErrorType["DEFAULT_PROVIDER_ERROR"] = "DEFAULT_PROVIDER_ERROR";
34813
34894
  CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
34814
34895
  CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
34815
34896
  CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
34897
+ CheckoutErrorType["GET_ERC20_INFO_ERROR"] = "GET_ERC20_INFO_ERROR";
34816
34898
  CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
34817
34899
  CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
34818
34900
  CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
@@ -35168,7 +35250,7 @@ const BLOCKSCOUT_CHAIN_URL_MAP = {
35168
35250
  nativeToken: SANDBOX_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_TESTNET).nativeCurrency,
35169
35251
  },
35170
35252
  [ChainId.IMTBL_ZKEVM_MAINNET]: {
35171
- url: 'https://explorer.mainnet.immutable.com',
35253
+ url: 'https://explorer.immutable.com',
35172
35254
  nativeToken: PRODUCTION_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_MAINNET).nativeCurrency,
35173
35255
  },
35174
35256
  [ChainId.SEPOLIA]: {
@@ -35380,7 +35462,7 @@ const GAS_OVERRIDES = {
35380
35462
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
35381
35463
  };
35382
35464
 
35383
- const SDK_VERSION_MARKER = '0.36.2';
35465
+ const SDK_VERSION_MARKER = '0.36.4';
35384
35466
  // This SDK version is replaced by the `yarn build` command ran on the root level
35385
35467
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35386
35468
 
@@ -35541,6 +35623,22 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
35541
35623
  };
35542
35624
  };
35543
35625
  const isNativeToken = (address) => !address || address.toLocaleLowerCase() === NATIVE;
35626
+ async function getERC20TokenInfo(web3Provider, tokenAddress) {
35627
+ return await withCheckoutError(async () => {
35628
+ const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
35629
+ const [name, symbol, decimals] = await Promise.all([
35630
+ contract.name(),
35631
+ contract.symbol(),
35632
+ contract.decimals(),
35633
+ ]);
35634
+ return {
35635
+ name,
35636
+ symbol,
35637
+ decimals,
35638
+ address: tokenAddress,
35639
+ };
35640
+ }, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
35641
+ }
35544
35642
 
35545
35643
  const CACHE_DATA_TTL = 60; // seconds
35546
35644
  /**
@@ -35711,20 +35809,18 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
35711
35809
  return await withCheckoutError(async () => {
35712
35810
  const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
35713
35811
  return Promise.all([
35714
- contract.name(),
35715
- contract.symbol(),
35812
+ getERC20TokenInfo(web3Provider, tokenAddress),
35716
35813
  contract.balanceOf(walletAddress),
35717
- contract.decimals(),
35718
35814
  ])
35719
- .then(([name, symbol, balance, decimals]) => {
35720
- const formattedBalance = ethers.utils.formatUnits(balance, decimals);
35815
+ .then(([tokenInfo, balance]) => {
35816
+ const formattedBalance = ethers.utils.formatUnits(balance, tokenInfo.decimals);
35721
35817
  return {
35722
35818
  balance,
35723
35819
  formattedBalance,
35724
35820
  token: {
35725
- name,
35726
- symbol,
35727
- decimals,
35821
+ name: tokenInfo.name,
35822
+ symbol: tokenInfo.symbol,
35823
+ decimals: tokenInfo.decimals,
35728
35824
  address: tokenAddress,
35729
35825
  },
35730
35826
  };
@@ -35824,6 +35920,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
35824
35920
  const allBalancePromises = [];
35825
35921
  tokens
35826
35922
  .forEach((token) => {
35923
+ // For some reason isNativeToken always returns undefined.
35924
+ // We have spent way too much time figuring out why this is happening.
35925
+ // That we have given up -- keep it as it is for now.
35827
35926
  if (!token.address || token.address.toLocaleLowerCase() === NATIVE) {
35828
35927
  allBalancePromises.push(getBalance(config, web3Provider, walletAddress));
35829
35928
  }
@@ -35832,12 +35931,25 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
35832
35931
  }
35833
35932
  });
35834
35933
  const balanceResults = await Promise.allSettled(allBalancePromises);
35835
- const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => result.value);
35934
+ const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => {
35935
+ const resp = result;
35936
+ const { token } = resp.value;
35937
+ // For some reason isNativeToken always returns undefined.
35938
+ // We have spent way too much time figuring out why this is happening.
35939
+ // That we have given up -- keep it as it is for now.
35940
+ if (!token.address || token.address.toLocaleLowerCase() === NATIVE)
35941
+ resp.value.token.address = NATIVE;
35942
+ return resp.value;
35943
+ });
35836
35944
  return { balances };
35837
35945
  };
35838
35946
  const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
35839
- // eslint-disable-next-line no-param-reassign
35840
- chainId ||= await web3Provider.getSigner().getChainId();
35947
+ if (!walletAddress && !web3Provider) {
35948
+ throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
35949
+ }
35950
+ if (!config.networkMap.get(chainId)) {
35951
+ throw new CheckoutError(`chain ID ${chainId} not supported by the environment`, CheckoutErrorType.CHAIN_NOT_SUPPORTED_ERROR);
35952
+ }
35841
35953
  const { tokens } = await getTokenAllowList(config, {
35842
35954
  type: TokenFilterTypes.ALL,
35843
35955
  chainId,
@@ -35853,6 +35965,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
35853
35965
  // eslint-disable-next-line no-console
35854
35966
  console.error(err);
35855
35967
  }
35968
+ let address = walletAddress;
35856
35969
  if (flag && Blockscout.isChainSupported(chainId)) {
35857
35970
  // This is a hack because the widgets are still using the tokens symbol
35858
35971
  // to drive the conversions. If we remove all the token symbols from e.g. zkevm
@@ -35860,12 +35973,18 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
35860
35973
  // Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
35861
35974
  // is done.
35862
35975
  const isL1Chain = getL1ChainId(config) === chainId;
35863
- return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : undefined));
35976
+ if (!address)
35977
+ address = await web3Provider?.getSigner().getAddress();
35978
+ return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(address, chainId, isL1Chain ? tokens : undefined));
35979
+ }
35980
+ if (!web3Provider) {
35981
+ throw new CheckoutError('indexer is disabled for this chain, you must provide a provider.', CheckoutErrorType.MISSING_PARAMS);
35864
35982
  }
35865
35983
  // This fallback to use ERC20s calls which is a best effort solution
35866
35984
  // Fails in fetching data from the RCP calls might result in some
35867
35985
  // missing data.
35868
- return await measureAsyncExecution(config, `Time to fetch balances using RPC for ${chainId}`, getBalances(config, web3Provider, walletAddress, tokens));
35986
+ address ||= await web3Provider.getSigner().getAddress();
35987
+ return await measureAsyncExecution(config, `Time to fetch balances using RPC for ${chainId}`, getBalances(config, web3Provider, address, tokens));
35869
35988
  };
35870
35989
 
35871
35990
  async function checkIsWalletConnected(web3Provider) {
@@ -37392,14 +37511,16 @@ const getEthBalance = (balances) => {
37392
37511
  const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toChainId) => {
37393
37512
  const bridge = createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
37394
37513
  try {
37395
- const fee = await bridge.getFee({
37514
+ const bridgeFeeResponse = await bridge.getFee({
37396
37515
  action: BridgeFeeActions.DEPOSIT,
37397
37516
  gasMultiplier: 1.1,
37398
37517
  sourceChainId: fromChainId.toString(),
37399
37518
  destinationChainId: toChainId.toString(),
37400
37519
  });
37401
- fee.approvalGas = ethers.BigNumber.from(0);
37402
- return fee;
37520
+ return {
37521
+ ...bridgeFeeResponse,
37522
+ approvalGas: ethers.BigNumber.from(0),
37523
+ };
37403
37524
  }
37404
37525
  catch (err) {
37405
37526
  throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { message: err.message });
@@ -37410,11 +37531,11 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
37410
37531
  const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000eee';
37411
37532
  const getIndexerChainName = (chainId) => {
37412
37533
  if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
37413
- return 'imtbl-zkevm-mainnet';
37534
+ return ChainSlug.IMTBL_ZKEVM_MAINNET;
37414
37535
  if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
37415
- return 'imtbl-zkevm-testnet';
37536
+ return ChainSlug.IMTBL_ZKEVM_TESTNET;
37416
37537
  if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
37417
- return 'imtbl-zkevm-devent';
37538
+ return ChainSlug.IMTBL_ZKEVM_DEVNET;
37418
37539
  return '';
37419
37540
  };
37420
37541
  // Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
@@ -38860,6 +38981,8 @@ class Checkout {
38860
38981
  */
38861
38982
  async widgets(init) {
38862
38983
  const checkout = this;
38984
+ // Preload the configurations
38985
+ await checkout.config.remote.getConfig();
38863
38986
  const factory = new Promise((resolve, reject) => {
38864
38987
  function checkForWidgetsBundleLoaded() {
38865
38988
  if (typeof ImmutableCheckoutWidgets !== 'undefined') {
@@ -38875,8 +38998,6 @@ class Checkout {
38875
38998
  try {
38876
38999
  const script = loadUnresolved(init.version);
38877
39000
  if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
38878
- // eslint-disable-next-line no-console
38879
- console.warn('Checkout widgets script is already loaded');
38880
39001
  resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
38881
39002
  }
38882
39003
  else {
@@ -38930,6 +39051,15 @@ class Checkout {
38930
39051
  const switchNetworkRes = await switchWalletNetwork(this.config, web3Provider, params.chainId);
38931
39052
  return switchNetworkRes;
38932
39053
  }
39054
+ /**
39055
+ * Retrieves the token information given the token address. This function makes RPC calls to
39056
+ * ERC20 contracts to fetch the main contract information (e.g. symbol).
39057
+ * @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
39058
+ * @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
39059
+ */
39060
+ async getTokenInfo(params) {
39061
+ return await getERC20TokenInfo(params.provider, params.tokenAddress);
39062
+ }
38933
39063
  /**
38934
39064
  * Retrieves the balance of a wallet address.
38935
39065
  * @param {GetBalanceParams} params - The parameters for retrieving the balance.
@@ -38948,8 +39078,7 @@ class Checkout {
38948
39078
  * @returns {Promise<GetAllBalancesResult>} - A promise that resolves to the result of retrieving the balances.
38949
39079
  */
38950
39080
  async getAllBalances(params) {
38951
- const web3Provider = await validateProvider(this.config, params.provider);
38952
- return getAllBalances(this.config, web3Provider, params.walletAddress, params.chainId);
39081
+ return getAllBalances(this.config, params.provider, params.walletAddress, params.chainId);
38953
39082
  }
38954
39083
  /**
38955
39084
  * Retrieves the supported networks based on the provided parameters.
@@ -39115,6 +39244,7 @@ var checkout = /*#__PURE__*/Object.freeze({
39115
39244
  get BridgeEventType () { return BridgeEventType; },
39116
39245
  get ChainId () { return ChainId; },
39117
39246
  get ChainName () { return ChainName; },
39247
+ get ChainSlug () { return ChainSlug; },
39118
39248
  Checkout: Checkout,
39119
39249
  CheckoutConfiguration: CheckoutConfiguration,
39120
39250
  get CheckoutErrorType () { return CheckoutErrorType; },