@imtbl/sdk 0.36.4 → 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.4' };
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.4',
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.4',
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',
@@ -35440,7 +35658,7 @@ const GAS_OVERRIDES = {
35440
35658
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
35441
35659
  };
35442
35660
 
35443
- const SDK_VERSION_MARKER = '0.36.4';
35661
+ const SDK_VERSION_MARKER = '0.36.5';
35444
35662
  // This SDK version is replaced by the `yarn build` command ran on the root level
35445
35663
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35446
35664
 
package/dist/passport.js CHANGED
@@ -2349,7 +2349,7 @@ class MultiRollupApiClients {
2349
2349
  }
2350
2350
 
2351
2351
  // eslint-disable-next-line @typescript-eslint/naming-convention
2352
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.36.4' };
2352
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.36.5' };
2353
2353
  const createConfig = ({ basePath, headers, }) => {
2354
2354
  if (!basePath.trim()) {
2355
2355
  throw Error('basePath can not be empty');
@@ -2405,7 +2405,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2405
2405
  chainID,
2406
2406
  coreContractAddress,
2407
2407
  registrationContractAddress,
2408
- sdkVersion: 'ts-immutable-sdk-0.36.4',
2408
+ sdkVersion: 'ts-immutable-sdk-0.36.5',
2409
2409
  });
2410
2410
  /**
2411
2411
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.36.4",
4
+ "version": "0.36.5",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",