@imtbl/sdk 0.36.2 → 0.36.3

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.
@@ -10700,13 +10700,13 @@ interface GetBalanceResult {
10700
10700
  }
10701
10701
  /**
10702
10702
  * Interface representing the parameters for {@link Checkout.getAllBalances}.
10703
- * @property {Web3Provider} provider - The provider used to get the balances.
10704
- * @property {string} walletAddress - The wallet address.
10703
+ * @property {Web3Provider} provider - The provider used to get the balances, it is a required parameter if no walletAddress is provided.
10704
+ * @property {string} walletAddress - The wallet address, it is a required parameter if no provider is provided.
10705
10705
  * @property {ChainId} chainId - The ID of the network.
10706
10706
  */
10707
10707
  interface GetAllBalancesParams {
10708
- provider: Web3Provider;
10709
- walletAddress: string;
10708
+ provider?: Web3Provider;
10709
+ walletAddress?: string;
10710
10710
  chainId: ChainId;
10711
10711
  }
10712
10712
  /**
@@ -12929,6 +12929,7 @@ declare const IMMUTABLE_API_BASE_URL: {
12929
12929
  * Enum representing different types of errors that can occur during the checkout process.
12930
12930
  */
12931
12931
  declare enum CheckoutErrorType {
12932
+ MISSING_PARAMS = "MISSING_PARAMS",
12932
12933
  WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
12933
12934
  PROVIDER_ERROR = "PROVIDER_ERROR",
12934
12935
  DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
package/dist/checkout.js CHANGED
@@ -12519,59 +12519,18 @@ function parseUnits(value, unitName) {
12519
12519
  return parseFixed(value, (unitName != null) ? unitName : 18);
12520
12520
  }
12521
12521
 
12522
- /**
12523
- * @typedef {Object} CompletionStatus
12524
- * @property {string} SUCCESS - The transaction has been successfully synced.
12525
- * @property {string} PENDING - The transaction is still pending.
12526
- * @property {string} FAILED - The transaction has failed.
12527
- */
12528
- var CompletionStatus;
12529
- (function (CompletionStatus) {
12530
- CompletionStatus["SUCCESS"] = "SUCCESS";
12531
- CompletionStatus["PENDING"] = "PENDING";
12532
- CompletionStatus["FAILED"] = "FAILED";
12533
- })(CompletionStatus || (CompletionStatus = {}));
12534
- /**
12535
- * @typedef {Object} BridgeFeeActions
12536
- * @property {string} DEPOSIT - The transaction has been successfully synced.
12537
- * @property {string} WITHDRAW - The transaction is still pending.
12538
- * @property {string} FINALISE_WITHDRAWAL - Calculate gas .
12539
- */
12540
- var BridgeFeeActions;
12541
- (function (BridgeFeeActions) {
12542
- BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
12543
- BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
12544
- BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
12545
- })(BridgeFeeActions || (BridgeFeeActions = {}));
12546
- /**
12547
- * @typedef {Object} BridgeMethodGas
12548
- * @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
12549
- * @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
12550
- * @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
12551
- * @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
12552
- * @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
12553
- */
12554
- var BridgeMethodsGasLimit;
12555
- (function (BridgeMethodsGasLimit) {
12556
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
12557
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
12558
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
12559
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
12560
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
12561
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
12562
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
12563
- })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
12564
- var StatusResponse;
12565
- (function (StatusResponse) {
12566
- StatusResponse["PROCESSING"] = "PROCESSING";
12567
- StatusResponse["COMPLETE"] = "COMPLETE";
12568
- StatusResponse["RETRY"] = "RETRY";
12569
- StatusResponse["ERROR"] = "ERROR";
12570
- StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
12571
- StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
12572
- })(StatusResponse || (StatusResponse = {}));
12573
-
12574
12522
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
12523
+ {
12524
+ inputs: [
12525
+ {
12526
+ internalType: 'address',
12527
+ name: '_initializerAddress',
12528
+ type: 'address',
12529
+ },
12530
+ ],
12531
+ stateMutability: 'nonpayable',
12532
+ type: 'constructor',
12533
+ },
12575
12534
  {
12576
12535
  inputs: [],
12577
12536
  name: 'AlreadyMapped',
@@ -12722,6 +12681,16 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
12722
12681
  name: 'TokenIsZero',
12723
12682
  type: 'error',
12724
12683
  },
12684
+ {
12685
+ inputs: [],
12686
+ name: 'TokenNotSupported',
12687
+ type: 'error',
12688
+ },
12689
+ {
12690
+ inputs: [],
12691
+ name: 'UnauthorizedInitializer',
12692
+ type: 'error',
12693
+ },
12725
12694
  {
12726
12695
  inputs: [
12727
12696
  {
@@ -14145,6 +14114,19 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
14145
14114
  stateMutability: 'pure',
14146
14115
  type: 'function',
14147
14116
  },
14117
+ {
14118
+ inputs: [],
14119
+ name: 'initializerAddress',
14120
+ outputs: [
14121
+ {
14122
+ internalType: 'address',
14123
+ name: '',
14124
+ type: 'address',
14125
+ },
14126
+ ],
14127
+ stateMutability: 'view',
14128
+ type: 'function',
14129
+ },
14148
14130
  {
14149
14131
  inputs: [
14150
14132
  {
@@ -14841,6 +14823,17 @@ const withBridgeError = async (fn, customErrorType, details) => {
14841
14823
  };
14842
14824
 
14843
14825
  const CHILD_ERC20_BRIDGE = [
14826
+ {
14827
+ inputs: [
14828
+ {
14829
+ internalType: 'address',
14830
+ name: '_initializerAddress',
14831
+ type: 'address',
14832
+ },
14833
+ ],
14834
+ stateMutability: 'nonpayable',
14835
+ type: 'constructor',
14836
+ },
14844
14837
  {
14845
14838
  inputs: [],
14846
14839
  name: 'AlreadyMapped',
@@ -14943,6 +14936,11 @@ const CHILD_ERC20_BRIDGE = [
14943
14936
  name: 'TransferWIMXFailed',
14944
14937
  type: 'error',
14945
14938
  },
14939
+ {
14940
+ inputs: [],
14941
+ name: 'UnauthorizedInitializer',
14942
+ type: 'error',
14943
+ },
14946
14944
  {
14947
14945
  inputs: [],
14948
14946
  name: 'ZeroAddress',
@@ -15697,6 +15695,19 @@ const CHILD_ERC20_BRIDGE = [
15697
15695
  stateMutability: 'nonpayable',
15698
15696
  type: 'function',
15699
15697
  },
15698
+ {
15699
+ inputs: [],
15700
+ name: 'initializerAddress',
15701
+ outputs: [
15702
+ {
15703
+ internalType: 'address',
15704
+ name: '',
15705
+ type: 'address',
15706
+ },
15707
+ ],
15708
+ stateMutability: 'view',
15709
+ type: 'function',
15710
+ },
15700
15711
  {
15701
15712
  inputs: [
15702
15713
  {
@@ -16046,6 +16057,58 @@ const getGasPriceInWei$1 = (feeData) => {
16046
16057
  return null;
16047
16058
  };
16048
16059
 
16060
+ /**
16061
+ * @typedef {Object} CompletionStatus
16062
+ * @property {string} SUCCESS - The transaction has been successfully synced.
16063
+ * @property {string} PENDING - The transaction is still pending.
16064
+ * @property {string} FAILED - The transaction has failed.
16065
+ */
16066
+ var CompletionStatus;
16067
+ (function (CompletionStatus) {
16068
+ CompletionStatus["SUCCESS"] = "SUCCESS";
16069
+ CompletionStatus["PENDING"] = "PENDING";
16070
+ CompletionStatus["FAILED"] = "FAILED";
16071
+ })(CompletionStatus || (CompletionStatus = {}));
16072
+ /**
16073
+ * @typedef {Object} BridgeFeeActions
16074
+ * @property {string} DEPOSIT - The transaction has been successfully synced.
16075
+ * @property {string} WITHDRAW - The transaction is still pending.
16076
+ * @property {string} FINALISE_WITHDRAWAL - Calculate gas .
16077
+ */
16078
+ var BridgeFeeActions;
16079
+ (function (BridgeFeeActions) {
16080
+ BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
16081
+ BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
16082
+ BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
16083
+ })(BridgeFeeActions || (BridgeFeeActions = {}));
16084
+ /**
16085
+ * @typedef {Object} BridgeMethodGas
16086
+ * @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
16087
+ * @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
16088
+ * @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
16089
+ * @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
16090
+ * @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
16091
+ */
16092
+ var BridgeMethodsGasLimit;
16093
+ (function (BridgeMethodsGasLimit) {
16094
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
16095
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
16096
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
16097
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
16098
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
16099
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
16100
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
16101
+ })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
16102
+ var StatusResponse;
16103
+ (function (StatusResponse) {
16104
+ StatusResponse["PROCESSING"] = "PROCESSING";
16105
+ StatusResponse["COMPLETE"] = "COMPLETE";
16106
+ StatusResponse["RETRY"] = "RETRY";
16107
+ StatusResponse["ERROR"] = "ERROR";
16108
+ StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
16109
+ StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
16110
+ })(StatusResponse || (StatusResponse = {}));
16111
+
16049
16112
  /* eslint-disable class-methods-use-this */
16050
16113
  /**
16051
16114
  * Represents a token bridge, which manages asset transfers between two chains.
@@ -16666,8 +16729,8 @@ const CONTRACTS_FOR_BRIDGE = new Map()
16666
16729
  wrappedIMX: '0x0',
16667
16730
  })
16668
16731
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
16669
- rootERC20BridgeFlowRate: '0x8d4528775a4406Def316DC2b450eE539750F8FAA',
16670
- childERC20Bridge: '0xb0f971e2d11A4D410148af51b170D64E725c0bB9',
16732
+ rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
16733
+ childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
16671
16734
  wrappedIMX: '0xa86C6C6d3D51c0592BE85dA05A9b06B62360D56E',
16672
16735
  })
16673
16736
  .set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
@@ -25770,7 +25833,7 @@ class APIError extends Error {
25770
25833
 
25771
25834
  /* eslint-disable implicit-arrow-linebreak */
25772
25835
  const defaultHeaders = {
25773
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.2',
25836
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.3',
25774
25837
  };
25775
25838
  /**
25776
25839
  * createAPIConfiguration to create a custom Configuration
@@ -26502,6 +26565,7 @@ var ExchangeType;
26502
26565
  */
26503
26566
  var CheckoutErrorType;
26504
26567
  (function (CheckoutErrorType) {
26568
+ CheckoutErrorType["MISSING_PARAMS"] = "MISSING_PARAMS";
26505
26569
  CheckoutErrorType["WEB3_PROVIDER_ERROR"] = "WEB3_PROVIDER_ERROR";
26506
26570
  CheckoutErrorType["PROVIDER_ERROR"] = "PROVIDER_ERROR";
26507
26571
  CheckoutErrorType["DEFAULT_PROVIDER_ERROR"] = "DEFAULT_PROVIDER_ERROR";
@@ -26863,7 +26927,7 @@ const BLOCKSCOUT_CHAIN_URL_MAP = {
26863
26927
  nativeToken: SANDBOX_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_TESTNET).nativeCurrency,
26864
26928
  },
26865
26929
  [ChainId.IMTBL_ZKEVM_MAINNET]: {
26866
- url: 'https://explorer.mainnet.immutable.com',
26930
+ url: 'https://explorer.immutable.com',
26867
26931
  nativeToken: PRODUCTION_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_MAINNET).nativeCurrency,
26868
26932
  },
26869
26933
  [ChainId.SEPOLIA]: {
@@ -27075,7 +27139,7 @@ const GAS_OVERRIDES = {
27075
27139
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
27076
27140
  };
27077
27141
 
27078
- const SDK_VERSION_MARKER = '0.36.2';
27142
+ const SDK_VERSION_MARKER = '0.36.3';
27079
27143
  // This SDK version is replaced by the `yarn build` command ran on the root level
27080
27144
  const globalPackageVersion = () => SDK_VERSION_MARKER;
27081
27145
 
@@ -27531,8 +27595,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
27531
27595
  return { balances };
27532
27596
  };
27533
27597
  const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
27534
- // eslint-disable-next-line no-param-reassign
27535
- chainId ||= await web3Provider.getSigner().getChainId();
27598
+ if (!walletAddress && !web3Provider) {
27599
+ throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
27600
+ }
27536
27601
  const { tokens } = await getTokenAllowList(config, {
27537
27602
  type: TokenFilterTypes.ALL,
27538
27603
  chainId,
@@ -27548,6 +27613,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
27548
27613
  // eslint-disable-next-line no-console
27549
27614
  console.error(err);
27550
27615
  }
27616
+ let address = walletAddress;
27551
27617
  if (flag && Blockscout.isChainSupported(chainId)) {
27552
27618
  // This is a hack because the widgets are still using the tokens symbol
27553
27619
  // to drive the conversions. If we remove all the token symbols from e.g. zkevm
@@ -27555,12 +27621,18 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
27555
27621
  // Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
27556
27622
  // is done.
27557
27623
  const isL1Chain = getL1ChainId(config) === chainId;
27558
- return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : undefined));
27624
+ if (!address)
27625
+ address = await web3Provider?.getSigner().getAddress();
27626
+ return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(address, chainId, isL1Chain ? tokens : undefined));
27627
+ }
27628
+ if (!web3Provider) {
27629
+ throw new CheckoutError('indexer is disabled for this chain, you must provide a provider.', CheckoutErrorType.MISSING_PARAMS);
27559
27630
  }
27560
27631
  // This fallback to use ERC20s calls which is a best effort solution
27561
27632
  // Fails in fetching data from the RCP calls might result in some
27562
27633
  // missing data.
27563
- return await measureAsyncExecution(config, `Time to fetch balances using RPC for ${chainId}`, getBalances(config, web3Provider, walletAddress, tokens));
27634
+ address ||= await web3Provider.getSigner().getAddress();
27635
+ return await measureAsyncExecution(config, `Time to fetch balances using RPC for ${chainId}`, getBalances(config, web3Provider, address, tokens));
27564
27636
  };
27565
27637
 
27566
27638
  async function checkIsWalletConnected(web3Provider) {
@@ -29087,14 +29159,16 @@ const getEthBalance = (balances) => {
29087
29159
  const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toChainId) => {
29088
29160
  const bridge = createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
29089
29161
  try {
29090
- const fee = await bridge.getFee({
29162
+ const bridgeFeeResponse = await bridge.getFee({
29091
29163
  action: BridgeFeeActions.DEPOSIT,
29092
29164
  gasMultiplier: 1.1,
29093
29165
  sourceChainId: fromChainId.toString(),
29094
29166
  destinationChainId: toChainId.toString(),
29095
29167
  });
29096
- fee.approvalGas = BigNumber$1.from(0);
29097
- return fee;
29168
+ return {
29169
+ ...bridgeFeeResponse,
29170
+ approvalGas: BigNumber$1.from(0),
29171
+ };
29098
29172
  }
29099
29173
  catch (err) {
29100
29174
  throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { message: err.message });
@@ -30643,8 +30717,7 @@ class Checkout {
30643
30717
  * @returns {Promise<GetAllBalancesResult>} - A promise that resolves to the result of retrieving the balances.
30644
30718
  */
30645
30719
  async getAllBalances(params) {
30646
- const web3Provider = await validateProvider(this.config, params.provider);
30647
- return getAllBalances(this.config, web3Provider, params.walletAddress, params.chainId);
30720
+ return getAllBalances(this.config, params.provider, params.walletAddress, params.chainId);
30648
30721
  }
30649
30722
  /**
30650
30723
  * Retrieves the supported networks based on the provided parameters.
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
17
17
  chainID,
18
18
  coreContractAddress,
19
19
  registrationContractAddress,
20
- sdkVersion: 'ts-immutable-sdk-0.36.2',
20
+ sdkVersion: 'ts-immutable-sdk-0.36.3',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build