@imtbl/sdk 0.36.3 → 0.36.5

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.js CHANGED
@@ -4234,7 +4234,7 @@ class MultiRollupApiClients {
4234
4234
  }
4235
4235
 
4236
4236
  // eslint-disable-next-line @typescript-eslint/naming-convention
4237
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.3' };
4237
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.5' };
4238
4238
  const createConfig = ({ basePath, headers, }) => {
4239
4239
  if (!basePath.trim()) {
4240
4240
  throw Error('basePath can not be empty');
@@ -4294,7 +4294,7 @@ class APIError extends Error {
4294
4294
 
4295
4295
  /* eslint-disable implicit-arrow-linebreak */
4296
4296
  const defaultHeaders = {
4297
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.3',
4297
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.5',
4298
4298
  };
4299
4299
  /**
4300
4300
  * createAPIConfiguration to create a custom Configuration
@@ -4733,7 +4733,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4733
4733
  chainID,
4734
4734
  coreContractAddress,
4735
4735
  registrationContractAddress,
4736
- sdkVersion: 'ts-immutable-sdk-0.36.3',
4736
+ sdkVersion: 'ts-immutable-sdk-0.36.5',
4737
4737
  });
4738
4738
  /**
4739
4739
  * Sets `sdkVersion` at the time of build
@@ -17468,105 +17468,6 @@ axios.default = axios;
17468
17468
  // this module should only have a default export
17469
17469
  var axios$1 = axios;
17470
17470
 
17471
- /* eslint-disable @typescript-eslint/naming-convention */
17472
- /**
17473
- * @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
17474
- */
17475
- const ETH_SEPOLIA_CHAIN_ID = '11155111';
17476
- /**
17477
- * @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
17478
- */
17479
- const ETH_MAINNET_CHAIN_ID = '1';
17480
- /**
17481
- * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
17482
- */
17483
- const ZKEVM_DEVNET_CHAIN_ID = '15003';
17484
- /**
17485
- * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
17486
- */
17487
- const ZKEVM_TESTNET_CHAIN_ID = '13473';
17488
- /**
17489
- * @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
17490
- */
17491
- const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
17492
- /**
17493
- * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
17494
- * the Ethereum Sepolia testnet and the zkEVM devnet.
17495
- */
17496
- const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
17497
- rootChainID: ETH_SEPOLIA_CHAIN_ID,
17498
- childChainID: ZKEVM_DEVNET_CHAIN_ID,
17499
- };
17500
- /**
17501
- * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
17502
- * between the Ethereum Sepolia testnet and the zkEVM testnet.
17503
- */
17504
- const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
17505
- rootChainID: ETH_SEPOLIA_CHAIN_ID,
17506
- childChainID: ZKEVM_TESTNET_CHAIN_ID,
17507
- };
17508
- /**
17509
- * @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
17510
- * between the Ethereum mainnet and the zkEVM mainnet.
17511
- */
17512
- const ETH_MAINNET_TO_ZKEVM_MAINNET = {
17513
- rootChainID: ETH_MAINNET_CHAIN_ID,
17514
- childChainID: ZKEVM_MAINNET_CHAIN_ID,
17515
- };
17516
- /**
17517
- * @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
17518
- */
17519
- const axelarAPIEndpoints = {
17520
- testnet: 'https://testnet.api.gmp.axelarscan.io',
17521
- mainnet: 'https://api.gmp.axelarscan.io',
17522
- devnet: '',
17523
- };
17524
- /**
17525
- * @typedef {Object} axelarChains
17526
- * @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
17527
- */
17528
- const axelarChains = {
17529
- 11155111: {
17530
- id: 'ethereum-sepolia',
17531
- symbol: 'ETH',
17532
- },
17533
- 1: {
17534
- id: 'ethereum',
17535
- symbol: 'ETH',
17536
- },
17537
- 15003: {
17538
- id: 'immutable',
17539
- symbol: 'IMX',
17540
- },
17541
- 13473: {
17542
- id: 'immutable',
17543
- symbol: 'IMX',
17544
- },
17545
- 13371: {
17546
- id: 'immutable',
17547
- symbol: 'IMX',
17548
- }, // immutable zkevm mainnet
17549
- };
17550
- /**
17551
- * @typedef {Object} bridgeMethods
17552
- * @property {string} deposit - The set of contract methods for depositing.
17553
- * @property {string} withdraw - The set of contract methods for withdrawing.
17554
- */
17555
- const bridgeMethods = {
17556
- deposit: {
17557
- token: 'deposit',
17558
- tokenTo: 'depositTo',
17559
- native: 'depositETH',
17560
- nativeTo: 'depositToETH',
17561
- },
17562
- withdraw: {
17563
- token: 'withdraw',
17564
- tokenTo: 'withdrawTo',
17565
- native: 'withdrawIMX',
17566
- nativeTo: 'withdrawIMXTo',
17567
- },
17568
- };
17569
-
17570
17471
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17571
17472
 
17572
17473
  function getDefaultExportFromCjs (x) {
@@ -26753,6 +26654,105 @@ function parseUnits(value, unitName) {
26753
26654
  return parseFixed(value, (unitName != null) ? unitName : 18);
26754
26655
  }
26755
26656
 
26657
+ /* eslint-disable @typescript-eslint/naming-convention */
26658
+ /**
26659
+ * @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
26660
+ */
26661
+ const ETH_SEPOLIA_CHAIN_ID = '11155111';
26662
+ /**
26663
+ * @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
26664
+ */
26665
+ const ETH_MAINNET_CHAIN_ID = '1';
26666
+ /**
26667
+ * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
26668
+ */
26669
+ const ZKEVM_DEVNET_CHAIN_ID = '15003';
26670
+ /**
26671
+ * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
26672
+ */
26673
+ const ZKEVM_TESTNET_CHAIN_ID = '13473';
26674
+ /**
26675
+ * @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
26676
+ */
26677
+ const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
26678
+ /**
26679
+ * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
26680
+ * the Ethereum Sepolia testnet and the zkEVM devnet.
26681
+ */
26682
+ const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
26683
+ rootChainID: ETH_SEPOLIA_CHAIN_ID,
26684
+ childChainID: ZKEVM_DEVNET_CHAIN_ID,
26685
+ };
26686
+ /**
26687
+ * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
26688
+ * between the Ethereum Sepolia testnet and the zkEVM testnet.
26689
+ */
26690
+ const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
26691
+ rootChainID: ETH_SEPOLIA_CHAIN_ID,
26692
+ childChainID: ZKEVM_TESTNET_CHAIN_ID,
26693
+ };
26694
+ /**
26695
+ * @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
26696
+ * between the Ethereum mainnet and the zkEVM mainnet.
26697
+ */
26698
+ const ETH_MAINNET_TO_ZKEVM_MAINNET = {
26699
+ rootChainID: ETH_MAINNET_CHAIN_ID,
26700
+ childChainID: ZKEVM_MAINNET_CHAIN_ID,
26701
+ };
26702
+ /**
26703
+ * @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
26704
+ */
26705
+ const axelarAPIEndpoints = {
26706
+ testnet: 'https://testnet.api.gmp.axelarscan.io',
26707
+ mainnet: 'https://api.gmp.axelarscan.io',
26708
+ devnet: '',
26709
+ };
26710
+ /**
26711
+ * @typedef {Object} axelarChains
26712
+ * @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
26713
+ */
26714
+ const axelarChains = {
26715
+ 11155111: {
26716
+ id: 'ethereum-sepolia',
26717
+ symbol: 'ETH',
26718
+ },
26719
+ 1: {
26720
+ id: 'ethereum',
26721
+ symbol: 'ETH',
26722
+ },
26723
+ 15003: {
26724
+ id: 'immutable',
26725
+ symbol: 'IMX',
26726
+ },
26727
+ 13473: {
26728
+ id: 'immutable',
26729
+ symbol: 'IMX',
26730
+ },
26731
+ 13371: {
26732
+ id: 'immutable',
26733
+ symbol: 'IMX',
26734
+ }, // immutable zkevm mainnet
26735
+ };
26736
+ /**
26737
+ * @typedef {Object} bridgeMethods
26738
+ * @property {string} deposit - The set of contract methods for depositing.
26739
+ * @property {string} withdraw - The set of contract methods for withdrawing.
26740
+ */
26741
+ const bridgeMethods = {
26742
+ deposit: {
26743
+ token: 'deposit',
26744
+ tokenTo: 'depositTo',
26745
+ native: 'depositETH',
26746
+ nativeTo: 'depositToETH',
26747
+ },
26748
+ withdraw: {
26749
+ token: 'withdraw',
26750
+ tokenTo: 'withdrawTo',
26751
+ native: 'withdrawIMX',
26752
+ nativeTo: 'withdrawIMXTo',
26753
+ },
26754
+ };
26755
+
26756
26756
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
26757
26757
  {
26758
26758
  inputs: [
@@ -29013,6 +29013,7 @@ var BridgeErrorType;
29013
29013
  BridgeErrorType["AXELAR_CHAIN_NOT_FOUND"] = "AXELAR_CHAIN_NOT_FOUND";
29014
29014
  BridgeErrorType["AXELAR_GAS_ESTIMATE_FAILED"] = "AXELAR_GAS_ESTIMATE_FAILED";
29015
29015
  BridgeErrorType["INVALID_RECIPIENT"] = "INVALID_RECIPIENT";
29016
+ BridgeErrorType["FLOW_RATE_ERROR"] = "FLOW_RATE_ERROR";
29016
29017
  })(BridgeErrorType || (BridgeErrorType = {}));
29017
29018
  /**
29018
29019
  * Represents a custom error for bridge operations.
@@ -30325,16 +30326,17 @@ var BridgeFeeActions;
30325
30326
  */
30326
30327
  var BridgeMethodsGasLimit;
30327
30328
  (function (BridgeMethodsGasLimit) {
30328
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
30329
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
30330
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
30331
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
30332
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
30333
- BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
30329
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 200000] = "DEPOSIT_SOURCE";
30330
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 200000] = "DEPOSIT_DESTINATION";
30331
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 200000] = "WITHDRAW_SOURCE";
30332
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 250000] = "WITHDRAW_DESTINATION";
30333
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
30334
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
30334
30335
  BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
30335
30336
  })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
30336
30337
  var StatusResponse;
30337
30338
  (function (StatusResponse) {
30339
+ StatusResponse["PENDING"] = "PENDING";
30338
30340
  StatusResponse["PROCESSING"] = "PROCESSING";
30339
30341
  StatusResponse["COMPLETE"] = "COMPLETE";
30340
30342
  StatusResponse["RETRY"] = "RETRY";
@@ -30343,6 +30345,109 @@ var StatusResponse;
30343
30345
  StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
30344
30346
  })(StatusResponse || (StatusResponse = {}));
30345
30347
 
30348
+ var GMPStatus;
30349
+ (function (GMPStatus) {
30350
+ GMPStatus["SRC_GATEWAY_CALLED"] = "source_gateway_called";
30351
+ GMPStatus["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
30352
+ GMPStatus["DEST_EXECUTED"] = "destination_executed";
30353
+ GMPStatus["EXPRESS_EXECUTED"] = "express_executed";
30354
+ GMPStatus["DEST_EXECUTE_ERROR"] = "error";
30355
+ GMPStatus["DEST_EXECUTING"] = "executing";
30356
+ GMPStatus["APPROVING"] = "approving";
30357
+ GMPStatus["FORECALLED"] = "forecalled";
30358
+ GMPStatus["FORECALLED_WITHOUT_GAS_PAID"] = "forecalled_without_gas_paid";
30359
+ GMPStatus["NOT_EXECUTED"] = "not_executed";
30360
+ GMPStatus["NOT_EXECUTED_WITHOUT_GAS_PAID"] = "not_executed_without_gas_paid";
30361
+ GMPStatus["INSUFFICIENT_FEE"] = "insufficient_fee";
30362
+ GMPStatus["UNKNOWN_ERROR"] = "unknown_error";
30363
+ GMPStatus["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
30364
+ GMPStatus["SRC_GATEWAY_CONFIRMED"] = "confirmed";
30365
+ })(GMPStatus || (GMPStatus = {}));
30366
+ var GasPaidStatus;
30367
+ (function (GasPaidStatus) {
30368
+ GasPaidStatus["GAS_UNPAID"] = "gas_unpaid";
30369
+ GasPaidStatus["GAS_PAID"] = "gas_paid";
30370
+ GasPaidStatus["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
30371
+ GasPaidStatus["GAS_PAID_ENOUGH_GAS"] = "gas_paid_enough_gas";
30372
+ })(GasPaidStatus || (GasPaidStatus = {}));
30373
+
30374
+ /* eslint-disable @typescript-eslint/naming-convention */
30375
+ const parseGMPStatus = (response) => {
30376
+ const { error, status } = response;
30377
+ if (status === 'error' && error)
30378
+ return GMPStatus.DEST_EXECUTE_ERROR;
30379
+ if (status === 'executed')
30380
+ return GMPStatus.DEST_EXECUTED;
30381
+ if (status === 'approved')
30382
+ return GMPStatus.DEST_GATEWAY_APPROVED;
30383
+ if (status === 'called')
30384
+ return GMPStatus.SRC_GATEWAY_CALLED;
30385
+ if (status === 'executing')
30386
+ return GMPStatus.DEST_EXECUTING;
30387
+ return status;
30388
+ };
30389
+ const parseGMPError = (response) => {
30390
+ if (response.error) {
30391
+ return {
30392
+ message: response.error.error.message,
30393
+ txHash: response.error.error.transactionHash,
30394
+ chain: response.error.chain,
30395
+ };
30396
+ }
30397
+ if (response.is_insufficient_fee) {
30398
+ return {
30399
+ message: 'Insufficient fee',
30400
+ txHash: response.call.transaction.hash,
30401
+ chain: response.call.chain,
30402
+ };
30403
+ }
30404
+ return undefined;
30405
+ };
30406
+ const execGet = async (base, params) => fetch(`${base}?${new URLSearchParams(params).toString()}`, {
30407
+ method: 'GET',
30408
+ headers: { 'Content-Type': 'application/json' },
30409
+ cache: 'no-store',
30410
+ })
30411
+ .then((res) => res.json())
30412
+ .then((res) => res.data);
30413
+ const fetchGMPTransaction = async (axelarGMPApiUrl, txHash, txLogIndex) => execGet(axelarGMPApiUrl, {
30414
+ method: 'searchGMP',
30415
+ txHash,
30416
+ txLogIndex,
30417
+ })
30418
+ .then((data) => data.find((gmpTx) => gmpTx.id.indexOf(txHash) > -1 || gmpTx.call.transactionHash.indexOf(txHash) > -1))
30419
+ .catch(() => undefined);
30420
+ const queryTransactionStatus = async (axelarGMPApiUrl, txHash, txLogIndex) => {
30421
+ const txDetails = await fetchGMPTransaction(axelarGMPApiUrl, txHash, txLogIndex);
30422
+ if (!txDetails)
30423
+ return { status: GMPStatus.CANNOT_FETCH_STATUS };
30424
+ const { call, gas_status, gas_paid, executed, express_executed, approved, callback, } = txDetails;
30425
+ const gasPaidInfo = {
30426
+ status: gas_status,
30427
+ details: gas_paid,
30428
+ };
30429
+ // Note: Currently, the GMP API doesn't always return the `total` field in the `time_spent` object
30430
+ // This is a temporary fix to ensure that the `total` field is always present
30431
+ // TODO: Remove this once the API is fixed
30432
+ const timeSpent = txDetails.time_spent;
30433
+ if (timeSpent) {
30434
+ timeSpent.total = timeSpent.total
30435
+ || Object.values(timeSpent).reduce((accumulator, value) => accumulator + value, 0);
30436
+ }
30437
+ return {
30438
+ status: parseGMPStatus(txDetails),
30439
+ error: parseGMPError(txDetails),
30440
+ timeSpent,
30441
+ gasPaidInfo,
30442
+ callTx: call,
30443
+ executed,
30444
+ expressExecuted: express_executed,
30445
+ approved,
30446
+ callback,
30447
+ };
30448
+ };
30449
+
30450
+ /* eslint-disable no-console */
30346
30451
  /* eslint-disable class-methods-use-this */
30347
30452
  /**
30348
30453
  * Represents a token bridge, which manages asset transfers between two chains.
@@ -30534,6 +30639,7 @@ class TokenBridge {
30534
30639
  to: req.token,
30535
30640
  value: 0,
30536
30641
  from: req.senderAddress,
30642
+ chainId: parseInt(req.sourceChainId, 10),
30537
30643
  };
30538
30644
  return {
30539
30645
  contractToApprove: sourceBridgeAddress,
@@ -30679,6 +30785,7 @@ class TokenBridge {
30679
30785
  data,
30680
30786
  to: contractAddress,
30681
30787
  value: amount.add(fees.bridgeFee).toString(),
30788
+ chainId: parseInt(sourceChainId, 10),
30682
30789
  },
30683
30790
  };
30684
30791
  }
@@ -30698,6 +30805,7 @@ class TokenBridge {
30698
30805
  data,
30699
30806
  to: contractAddress,
30700
30807
  value: fees.bridgeFee.toString(),
30808
+ chainId: parseInt(sourceChainId, 10),
30701
30809
  },
30702
30810
  };
30703
30811
  }
@@ -30746,6 +30854,21 @@ class TokenBridge {
30746
30854
  throw new BridgeError(`Childchain provider chainID ${childNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.childChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
30747
30855
  }
30748
30856
  }
30857
+ getAxelarEndpoint(source) {
30858
+ let axelarAPIEndpoint;
30859
+ if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
30860
+ || source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
30861
+ axelarAPIEndpoint = axelarAPIEndpoints.mainnet;
30862
+ }
30863
+ else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
30864
+ || source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
30865
+ axelarAPIEndpoint = axelarAPIEndpoints.testnet;
30866
+ }
30867
+ else {
30868
+ axelarAPIEndpoint = axelarAPIEndpoints.devnet;
30869
+ }
30870
+ return axelarAPIEndpoint;
30871
+ }
30749
30872
  /**
30750
30873
  * Calculate the gas amount for a transaction using axelarjs-sdk.
30751
30874
  * @param {*} source - The source chainId.
@@ -30764,18 +30887,7 @@ class TokenBridge {
30764
30887
  if (!destinationAxelar) {
30765
30888
  throw new BridgeError(`Destination chainID ${destination} can not be matched to an Axelar chain.`, BridgeErrorType.AXELAR_CHAIN_NOT_FOUND);
30766
30889
  }
30767
- let axelarApiEndpoint;
30768
- if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
30769
- || source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
30770
- axelarApiEndpoint = axelarAPIEndpoints.mainnet;
30771
- }
30772
- else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
30773
- || source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
30774
- axelarApiEndpoint = axelarAPIEndpoints.testnet;
30775
- }
30776
- else {
30777
- axelarApiEndpoint = axelarAPIEndpoints.devnet;
30778
- }
30890
+ const axelarAPIEndpoint = this.getAxelarEndpoint(source);
30779
30891
  let axiosResponse;
30780
30892
  const estimateGasReq = {
30781
30893
  method: 'estimateGasFee',
@@ -30786,7 +30898,7 @@ class TokenBridge {
30786
30898
  gasMultiplier,
30787
30899
  };
30788
30900
  try {
30789
- axiosResponse = await axios$1.post(axelarApiEndpoint, estimateGasReq);
30901
+ axiosResponse = await axios$1.post(axelarAPIEndpoint, estimateGasReq);
30790
30902
  }
30791
30903
  catch (error) {
30792
30904
  axiosResponse = error.response;
@@ -30803,30 +30915,136 @@ class TokenBridge {
30803
30915
  throw new BridgeError(`Estimating Axelar Gas failed with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
30804
30916
  }
30805
30917
  }
30806
- // STUBBED ENDPOINTS FOR PHASE 2 -------------------------------------------
30807
30918
  /**
30808
30919
  * Queries the status of a bridge transaction.
30809
30920
  *
30810
- * @param {TokenMappingRequest} req - The request object containing the token, rootChainId and childChainId.
30811
- * @returns {Promise<TokenMappingResponse>} - A promise that resolves to an object containing the token mappings.
30921
+ * @param {TxStatusRequest} req - The request object containing an array of transactions to query.
30922
+ * @returns {Promise<TxStatusResponse>} - A promise that resolves to an array of transaction statuses.
30812
30923
  * @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
30813
- * @dev this SDK method is currently stubbed
30814
30924
  */
30815
30925
  async getTransactionStatus(req) {
30816
- // eslint-disable-next-line no-console
30817
- console.log('stubbed response with req', req);
30818
- // Return the token mappings
30819
- return {
30820
- transactions: [{
30821
- transactionHash: '0x1234....',
30822
- status: StatusResponse.COMPLETE,
30823
- data: 'stubbed data',
30824
- }, {
30825
- transactionHash: '0xABCD....',
30826
- status: StatusResponse.PROCESSING,
30827
- data: 'stubbed data',
30828
- }],
30926
+ const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
30927
+ const txStatusResponse = {
30928
+ transactions: [],
30829
30929
  };
30930
+ const abiCoder = new AbiCoder();
30931
+ const statusPromises = [];
30932
+ for (const transaction of req.transactions) {
30933
+ statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
30934
+ }
30935
+ let statusResponses;
30936
+ try {
30937
+ statusResponses = await Promise.all(statusPromises);
30938
+ }
30939
+ catch (err) {
30940
+ throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
30941
+ }
30942
+ const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
30943
+ const isWithdraw = [
30944
+ ZKEVM_DEVNET_CHAIN_ID,
30945
+ ZKEVM_TESTNET_CHAIN_ID,
30946
+ ZKEVM_MAINNET_CHAIN_ID
30947
+ ].includes(req.sourceChainId);
30948
+ let rootBridge;
30949
+ if (isWithdraw) {
30950
+ rootBridge = await withBridgeError(async () => {
30951
+ const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
30952
+ return contract;
30953
+ }, BridgeErrorType.INTERNAL_ERROR);
30954
+ }
30955
+ const flowRatePromises = [];
30956
+ const flowRatePromisesReceivers = [];
30957
+ for (let i = 0, l = statusResponses.length; i < l; i++) {
30958
+ let metaStatus;
30959
+ // consolidate axelar statuses to our own simplified metaStatus
30960
+ switch (statusResponses[i].status) {
30961
+ case GMPStatus.CANNOT_FETCH_STATUS:
30962
+ metaStatus = StatusResponse.PENDING;
30963
+ break;
30964
+ case GMPStatus.SRC_GATEWAY_CALLED:
30965
+ case GMPStatus.DEST_GATEWAY_APPROVED:
30966
+ case GMPStatus.DEST_EXECUTING:
30967
+ case GMPStatus.SRC_GATEWAY_CONFIRMED:
30968
+ case GMPStatus.APPROVING:
30969
+ metaStatus = StatusResponse.PROCESSING;
30970
+ break;
30971
+ case GMPStatus.NOT_EXECUTED:
30972
+ metaStatus = StatusResponse.RETRY;
30973
+ break;
30974
+ case GMPStatus.NOT_EXECUTED_WITHOUT_GAS_PAID:
30975
+ case GMPStatus.INSUFFICIENT_FEE:
30976
+ metaStatus = StatusResponse.NOT_ENOUGH_GAS;
30977
+ break;
30978
+ case GMPStatus.DEST_EXECUTED:
30979
+ metaStatus = StatusResponse.COMPLETE;
30980
+ break;
30981
+ default:
30982
+ metaStatus = StatusResponse.ERROR;
30983
+ }
30984
+ if (statusResponses[i].gasPaidInfo) {
30985
+ if (unpaidGasStatus.includes(statusResponses[i].gasPaidInfo.status)) {
30986
+ metaStatus = StatusResponse.NOT_ENOUGH_GAS;
30987
+ }
30988
+ }
30989
+ let txItem = {
30990
+ txHash: req.transactions[i].txHash,
30991
+ status: metaStatus,
30992
+ data: {
30993
+ gmpResponse: statusResponses[i].status,
30994
+ },
30995
+ };
30996
+ let decodedData;
30997
+ if (statusResponses[i]?.callTx?.returnValues?.payload) {
30998
+ decodedData = abiCoder.decode(['bytes32', 'address', 'address', 'address', 'uint256'], statusResponses[i].callTx.returnValues.payload);
30999
+ txItem = {
31000
+ ...txItem,
31001
+ token: decodedData[1],
31002
+ sender: decodedData[2],
31003
+ receiver: decodedData[3],
31004
+ amount: decodedData[4],
31005
+ };
31006
+ }
31007
+ let flowRatePromiseIndex;
31008
+ if (metaStatus === StatusResponse.COMPLETE
31009
+ && isWithdraw && txItem.receiver) {
31010
+ // consolidate the calls we have to make to the flow rate by receiver
31011
+ if (!flowRatePromisesReceivers.includes(txItem.receiver)) {
31012
+ flowRatePromises.push(rootBridge.getPendingWithdrawals(txItem.receiver, [0]));
31013
+ flowRatePromisesReceivers.push(txItem.receiver);
31014
+ flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
31015
+ }
31016
+ else {
31017
+ flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.receiver);
31018
+ }
31019
+ txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
31020
+ }
31021
+ txStatusResponse.transactions.push(txItem);
31022
+ } // for
31023
+ let flowRateResponses = [];
31024
+ if (flowRatePromises.length > 0) {
31025
+ try {
31026
+ flowRateResponses = await Promise.all(flowRatePromises);
31027
+ }
31028
+ catch (err) {
31029
+ throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
31030
+ }
31031
+ }
31032
+ for (const txStatusRes of txStatusResponse.transactions) {
31033
+ if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
31034
+ const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
31035
+ && el.token === txStatusRes.token
31036
+ && el.withdrawer === txStatusRes.sender));
31037
+ if (flowRatedTx) {
31038
+ txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
31039
+ txStatusRes.data = {
31040
+ timestamp: flowRatedTx.timestamp.toString(),
31041
+ };
31042
+ }
31043
+ }
31044
+ delete txStatusRes.data.flowRatePromiseIndex;
31045
+ }
31046
+ // Return the tx status response
31047
+ return txStatusResponse;
30830
31048
  }
30831
31049
  /**
30832
31050
  * Queries for the information about which tokens are flowrated and how long the delay is.
@@ -30965,7 +31183,7 @@ const CONTRACTS_FOR_BRIDGE = new Map()
30965
31183
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
30966
31184
  rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30967
31185
  childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30968
- wrappedIMX: '0xa86C6C6d3D51c0592BE85dA05A9b06B62360D56E',
31186
+ wrappedIMX: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
30969
31187
  })
30970
31188
  .set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
30971
31189
  rootERC20BridgeFlowRate: '0x0',
@@ -34676,12 +34894,12 @@ var ChainId;
34676
34894
  })(ChainId || (ChainId = {}));
34677
34895
  /**
34678
34896
  * Enum representing different chain names.
34679
- * @enum {number}
34680
- * @property {number} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
34681
- * @property {number} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
34682
- * @property {number} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
34683
- * @property {number} ETHEREUM - The chain name for Ethereum.
34684
- * @property {number} SEPOLIA - The chain name for Sepolia.
34897
+ * @enum {string}
34898
+ * @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
34899
+ * @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
34900
+ * @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
34901
+ * @property {string} ETHEREUM - The chain name for Ethereum.
34902
+ * @property {string} SEPOLIA - The chain name for Sepolia.
34685
34903
  */
34686
34904
  var ChainName;
34687
34905
  (function (ChainName) {
@@ -34691,6 +34909,23 @@ var ChainName;
34691
34909
  ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
34692
34910
  ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
34693
34911
  })(ChainName || (ChainName = {}));
34912
+ /**
34913
+ * Enum representing different chain slugs.
34914
+ * @enum {string}
34915
+ * @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
34916
+ * @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
34917
+ * @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
34918
+ * @property {string} ETHEREUM - The chain slug for Ethereum.
34919
+ * @property {string} SEPOLIA - The chain slug for Sepolia.
34920
+ */
34921
+ var ChainSlug;
34922
+ (function (ChainSlug) {
34923
+ ChainSlug["ETHEREUM"] = "ethereum";
34924
+ ChainSlug["SEPOLIA"] = "sepolia";
34925
+ ChainSlug["IMTBL_ZKEVM_MAINNET"] = "imtbl-zkevm-mainnet";
34926
+ ChainSlug["IMTBL_ZKEVM_TESTNET"] = "imtbl-zkevm-testnet";
34927
+ ChainSlug["IMTBL_ZKEVM_DEVNET"] = "imtbl-zkevm-devnet";
34928
+ })(ChainSlug || (ChainSlug = {}));
34694
34929
 
34695
34930
  var OnRampProvider;
34696
34931
  (function (OnRampProvider) {
@@ -34855,6 +35090,7 @@ var CheckoutErrorType;
34855
35090
  CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
34856
35091
  CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
34857
35092
  CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
35093
+ CheckoutErrorType["GET_ERC20_INFO_ERROR"] = "GET_ERC20_INFO_ERROR";
34858
35094
  CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
34859
35095
  CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
34860
35096
  CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
@@ -35422,7 +35658,7 @@ const GAS_OVERRIDES = {
35422
35658
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
35423
35659
  };
35424
35660
 
35425
- const SDK_VERSION_MARKER = '0.36.3';
35661
+ const SDK_VERSION_MARKER = '0.36.5';
35426
35662
  // This SDK version is replaced by the `yarn build` command ran on the root level
35427
35663
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35428
35664
 
@@ -35583,6 +35819,22 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
35583
35819
  };
35584
35820
  };
35585
35821
  const isNativeToken = (address) => !address || address.toLocaleLowerCase() === NATIVE;
35822
+ async function getERC20TokenInfo(web3Provider, tokenAddress) {
35823
+ return await withCheckoutError(async () => {
35824
+ const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
35825
+ const [name, symbol, decimals] = await Promise.all([
35826
+ contract.name(),
35827
+ contract.symbol(),
35828
+ contract.decimals(),
35829
+ ]);
35830
+ return {
35831
+ name,
35832
+ symbol,
35833
+ decimals,
35834
+ address: tokenAddress,
35835
+ };
35836
+ }, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
35837
+ }
35586
35838
 
35587
35839
  const CACHE_DATA_TTL = 60; // seconds
35588
35840
  /**
@@ -35753,20 +36005,18 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
35753
36005
  return await withCheckoutError(async () => {
35754
36006
  const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
35755
36007
  return Promise.all([
35756
- contract.name(),
35757
- contract.symbol(),
36008
+ getERC20TokenInfo(web3Provider, tokenAddress),
35758
36009
  contract.balanceOf(walletAddress),
35759
- contract.decimals(),
35760
36010
  ])
35761
- .then(([name, symbol, balance, decimals]) => {
35762
- const formattedBalance = utils$2.formatUnits(balance, decimals);
36011
+ .then(([tokenInfo, balance]) => {
36012
+ const formattedBalance = utils$2.formatUnits(balance, tokenInfo.decimals);
35763
36013
  return {
35764
36014
  balance,
35765
36015
  formattedBalance,
35766
36016
  token: {
35767
- name,
35768
- symbol,
35769
- decimals,
36017
+ name: tokenInfo.name,
36018
+ symbol: tokenInfo.symbol,
36019
+ decimals: tokenInfo.decimals,
35770
36020
  address: tokenAddress,
35771
36021
  },
35772
36022
  };
@@ -35866,6 +36116,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
35866
36116
  const allBalancePromises = [];
35867
36117
  tokens
35868
36118
  .forEach((token) => {
36119
+ // For some reason isNativeToken always returns undefined.
36120
+ // We have spent way too much time figuring out why this is happening.
36121
+ // That we have given up -- keep it as it is for now.
35869
36122
  if (!token.address || token.address.toLocaleLowerCase() === NATIVE) {
35870
36123
  allBalancePromises.push(getBalance(config, web3Provider, walletAddress));
35871
36124
  }
@@ -35874,13 +36127,25 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
35874
36127
  }
35875
36128
  });
35876
36129
  const balanceResults = await Promise.allSettled(allBalancePromises);
35877
- const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => result.value);
36130
+ const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => {
36131
+ const resp = result;
36132
+ const { token } = resp.value;
36133
+ // For some reason isNativeToken always returns undefined.
36134
+ // We have spent way too much time figuring out why this is happening.
36135
+ // That we have given up -- keep it as it is for now.
36136
+ if (!token.address || token.address.toLocaleLowerCase() === NATIVE)
36137
+ resp.value.token.address = NATIVE;
36138
+ return resp.value;
36139
+ });
35878
36140
  return { balances };
35879
36141
  };
35880
36142
  const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
35881
36143
  if (!walletAddress && !web3Provider) {
35882
36144
  throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
35883
36145
  }
36146
+ if (!config.networkMap.get(chainId)) {
36147
+ throw new CheckoutError(`chain ID ${chainId} not supported by the environment`, CheckoutErrorType.CHAIN_NOT_SUPPORTED_ERROR);
36148
+ }
35884
36149
  const { tokens } = await getTokenAllowList(config, {
35885
36150
  type: TokenFilterTypes.ALL,
35886
36151
  chainId,
@@ -37462,11 +37727,11 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
37462
37727
  const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000eee';
37463
37728
  const getIndexerChainName = (chainId) => {
37464
37729
  if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
37465
- return 'imtbl-zkevm-mainnet';
37730
+ return ChainSlug.IMTBL_ZKEVM_MAINNET;
37466
37731
  if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
37467
- return 'imtbl-zkevm-testnet';
37732
+ return ChainSlug.IMTBL_ZKEVM_TESTNET;
37468
37733
  if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
37469
- return 'imtbl-zkevm-devent';
37734
+ return ChainSlug.IMTBL_ZKEVM_DEVNET;
37470
37735
  return '';
37471
37736
  };
37472
37737
  // Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
@@ -38912,6 +39177,8 @@ class Checkout {
38912
39177
  */
38913
39178
  async widgets(init) {
38914
39179
  const checkout = this;
39180
+ // Preload the configurations
39181
+ await checkout.config.remote.getConfig();
38915
39182
  const factory = new Promise((resolve, reject) => {
38916
39183
  function checkForWidgetsBundleLoaded() {
38917
39184
  if (typeof ImmutableCheckoutWidgets !== 'undefined') {
@@ -38927,8 +39194,6 @@ class Checkout {
38927
39194
  try {
38928
39195
  const script = loadUnresolved(init.version);
38929
39196
  if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
38930
- // eslint-disable-next-line no-console
38931
- console.warn('Checkout widgets script is already loaded');
38932
39197
  resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
38933
39198
  }
38934
39199
  else {
@@ -38982,6 +39247,15 @@ class Checkout {
38982
39247
  const switchNetworkRes = await switchWalletNetwork(this.config, web3Provider, params.chainId);
38983
39248
  return switchNetworkRes;
38984
39249
  }
39250
+ /**
39251
+ * Retrieves the token information given the token address. This function makes RPC calls to
39252
+ * ERC20 contracts to fetch the main contract information (e.g. symbol).
39253
+ * @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
39254
+ * @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
39255
+ */
39256
+ async getTokenInfo(params) {
39257
+ return await getERC20TokenInfo(params.provider, params.tokenAddress);
39258
+ }
38985
39259
  /**
38986
39260
  * Retrieves the balance of a wallet address.
38987
39261
  * @param {GetBalanceParams} params - The parameters for retrieving the balance.
@@ -39166,6 +39440,7 @@ var checkout = /*#__PURE__*/Object.freeze({
39166
39440
  get BridgeEventType () { return BridgeEventType; },
39167
39441
  get ChainId () { return ChainId; },
39168
39442
  get ChainName () { return ChainName; },
39443
+ get ChainSlug () { return ChainSlug; },
39169
39444
  Checkout: Checkout,
39170
39445
  CheckoutConfiguration: CheckoutConfiguration,
39171
39446
  get CheckoutErrorType () { return CheckoutErrorType; },