@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.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.4' };
4259
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.5' };
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.4',
4319
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.5',
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.4',
4758
+ sdkVersion: 'ts-immutable-sdk-0.36.5',
4759
4759
  });
4760
4760
  /**
4761
4761
  * Sets `sdkVersion` at the time of build
@@ -17490,105 +17490,6 @@ axios.default = axios;
17490
17490
  // this module should only have a default export
17491
17491
  var axios$1 = axios;
17492
17492
 
17493
- /* eslint-disable @typescript-eslint/naming-convention */
17494
- /**
17495
- * @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
17496
- */
17497
- const ETH_SEPOLIA_CHAIN_ID = '11155111';
17498
- /**
17499
- * @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
17500
- */
17501
- const ETH_MAINNET_CHAIN_ID = '1';
17502
- /**
17503
- * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
17504
- */
17505
- const ZKEVM_DEVNET_CHAIN_ID = '15003';
17506
- /**
17507
- * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
17508
- */
17509
- const ZKEVM_TESTNET_CHAIN_ID = '13473';
17510
- /**
17511
- * @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
17512
- */
17513
- const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
17514
- /**
17515
- * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
17516
- * the Ethereum Sepolia testnet and the zkEVM devnet.
17517
- */
17518
- const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
17519
- rootChainID: ETH_SEPOLIA_CHAIN_ID,
17520
- childChainID: ZKEVM_DEVNET_CHAIN_ID,
17521
- };
17522
- /**
17523
- * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
17524
- * between the Ethereum Sepolia testnet and the zkEVM testnet.
17525
- */
17526
- const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
17527
- rootChainID: ETH_SEPOLIA_CHAIN_ID,
17528
- childChainID: ZKEVM_TESTNET_CHAIN_ID,
17529
- };
17530
- /**
17531
- * @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
17532
- * between the Ethereum mainnet and the zkEVM mainnet.
17533
- */
17534
- const ETH_MAINNET_TO_ZKEVM_MAINNET = {
17535
- rootChainID: ETH_MAINNET_CHAIN_ID,
17536
- childChainID: ZKEVM_MAINNET_CHAIN_ID,
17537
- };
17538
- /**
17539
- * @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
17540
- */
17541
- const axelarAPIEndpoints = {
17542
- testnet: 'https://testnet.api.gmp.axelarscan.io',
17543
- mainnet: 'https://api.gmp.axelarscan.io',
17544
- devnet: '',
17545
- };
17546
- /**
17547
- * @typedef {Object} axelarChains
17548
- * @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
17549
- */
17550
- const axelarChains = {
17551
- 11155111: {
17552
- id: 'ethereum-sepolia',
17553
- symbol: 'ETH',
17554
- },
17555
- 1: {
17556
- id: 'ethereum',
17557
- symbol: 'ETH',
17558
- },
17559
- 15003: {
17560
- id: 'immutable',
17561
- symbol: 'IMX',
17562
- },
17563
- 13473: {
17564
- id: 'immutable',
17565
- symbol: 'IMX',
17566
- },
17567
- 13371: {
17568
- id: 'immutable',
17569
- symbol: 'IMX',
17570
- }, // immutable zkevm mainnet
17571
- };
17572
- /**
17573
- * @typedef {Object} bridgeMethods
17574
- * @property {string} deposit - The set of contract methods for depositing.
17575
- * @property {string} withdraw - The set of contract methods for withdrawing.
17576
- */
17577
- const bridgeMethods = {
17578
- deposit: {
17579
- token: 'deposit',
17580
- tokenTo: 'depositTo',
17581
- native: 'depositETH',
17582
- nativeTo: 'depositToETH',
17583
- },
17584
- withdraw: {
17585
- token: 'withdraw',
17586
- tokenTo: 'withdrawTo',
17587
- native: 'withdrawIMX',
17588
- nativeTo: 'withdrawIMXTo',
17589
- },
17590
- };
17591
-
17592
17493
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17593
17494
 
17594
17495
  function getDefaultExportFromCjs (x) {
@@ -26775,6 +26676,105 @@ function parseUnits(value, unitName) {
26775
26676
  return parseFixed(value, (unitName != null) ? unitName : 18);
26776
26677
  }
26777
26678
 
26679
+ /* eslint-disable @typescript-eslint/naming-convention */
26680
+ /**
26681
+ * @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
26682
+ */
26683
+ const ETH_SEPOLIA_CHAIN_ID = '11155111';
26684
+ /**
26685
+ * @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
26686
+ */
26687
+ const ETH_MAINNET_CHAIN_ID = '1';
26688
+ /**
26689
+ * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
26690
+ */
26691
+ const ZKEVM_DEVNET_CHAIN_ID = '15003';
26692
+ /**
26693
+ * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
26694
+ */
26695
+ const ZKEVM_TESTNET_CHAIN_ID = '13473';
26696
+ /**
26697
+ * @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
26698
+ */
26699
+ const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
26700
+ /**
26701
+ * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
26702
+ * the Ethereum Sepolia testnet and the zkEVM devnet.
26703
+ */
26704
+ const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
26705
+ rootChainID: ETH_SEPOLIA_CHAIN_ID,
26706
+ childChainID: ZKEVM_DEVNET_CHAIN_ID,
26707
+ };
26708
+ /**
26709
+ * @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
26710
+ * between the Ethereum Sepolia testnet and the zkEVM testnet.
26711
+ */
26712
+ const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
26713
+ rootChainID: ETH_SEPOLIA_CHAIN_ID,
26714
+ childChainID: ZKEVM_TESTNET_CHAIN_ID,
26715
+ };
26716
+ /**
26717
+ * @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
26718
+ * between the Ethereum mainnet and the zkEVM mainnet.
26719
+ */
26720
+ const ETH_MAINNET_TO_ZKEVM_MAINNET = {
26721
+ rootChainID: ETH_MAINNET_CHAIN_ID,
26722
+ childChainID: ZKEVM_MAINNET_CHAIN_ID,
26723
+ };
26724
+ /**
26725
+ * @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
26726
+ */
26727
+ const axelarAPIEndpoints = {
26728
+ testnet: 'https://testnet.api.gmp.axelarscan.io',
26729
+ mainnet: 'https://api.gmp.axelarscan.io',
26730
+ devnet: '',
26731
+ };
26732
+ /**
26733
+ * @typedef {Object} axelarChains
26734
+ * @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
26735
+ */
26736
+ const axelarChains = {
26737
+ 11155111: {
26738
+ id: 'ethereum-sepolia',
26739
+ symbol: 'ETH',
26740
+ },
26741
+ 1: {
26742
+ id: 'ethereum',
26743
+ symbol: 'ETH',
26744
+ },
26745
+ 15003: {
26746
+ id: 'immutable',
26747
+ symbol: 'IMX',
26748
+ },
26749
+ 13473: {
26750
+ id: 'immutable',
26751
+ symbol: 'IMX',
26752
+ },
26753
+ 13371: {
26754
+ id: 'immutable',
26755
+ symbol: 'IMX',
26756
+ }, // immutable zkevm mainnet
26757
+ };
26758
+ /**
26759
+ * @typedef {Object} bridgeMethods
26760
+ * @property {string} deposit - The set of contract methods for depositing.
26761
+ * @property {string} withdraw - The set of contract methods for withdrawing.
26762
+ */
26763
+ const bridgeMethods = {
26764
+ deposit: {
26765
+ token: 'deposit',
26766
+ tokenTo: 'depositTo',
26767
+ native: 'depositETH',
26768
+ nativeTo: 'depositToETH',
26769
+ },
26770
+ withdraw: {
26771
+ token: 'withdraw',
26772
+ tokenTo: 'withdrawTo',
26773
+ native: 'withdrawIMX',
26774
+ nativeTo: 'withdrawIMXTo',
26775
+ },
26776
+ };
26777
+
26778
26778
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
26779
26779
  {
26780
26780
  inputs: [
@@ -29035,6 +29035,7 @@ var BridgeErrorType;
29035
29035
  BridgeErrorType["AXELAR_CHAIN_NOT_FOUND"] = "AXELAR_CHAIN_NOT_FOUND";
29036
29036
  BridgeErrorType["AXELAR_GAS_ESTIMATE_FAILED"] = "AXELAR_GAS_ESTIMATE_FAILED";
29037
29037
  BridgeErrorType["INVALID_RECIPIENT"] = "INVALID_RECIPIENT";
29038
+ BridgeErrorType["FLOW_RATE_ERROR"] = "FLOW_RATE_ERROR";
29038
29039
  })(BridgeErrorType || (BridgeErrorType = {}));
29039
29040
  /**
29040
29041
  * Represents a custom error for bridge operations.
@@ -30347,16 +30348,17 @@ var BridgeFeeActions;
30347
30348
  */
30348
30349
  var BridgeMethodsGasLimit;
30349
30350
  (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";
30351
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 200000] = "DEPOSIT_SOURCE";
30352
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 200000] = "DEPOSIT_DESTINATION";
30353
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 200000] = "WITHDRAW_SOURCE";
30354
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 250000] = "WITHDRAW_DESTINATION";
30355
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
30356
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
30356
30357
  BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
30357
30358
  })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
30358
30359
  var StatusResponse;
30359
30360
  (function (StatusResponse) {
30361
+ StatusResponse["PENDING"] = "PENDING";
30360
30362
  StatusResponse["PROCESSING"] = "PROCESSING";
30361
30363
  StatusResponse["COMPLETE"] = "COMPLETE";
30362
30364
  StatusResponse["RETRY"] = "RETRY";
@@ -30365,6 +30367,109 @@ var StatusResponse;
30365
30367
  StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
30366
30368
  })(StatusResponse || (StatusResponse = {}));
30367
30369
 
30370
+ var GMPStatus;
30371
+ (function (GMPStatus) {
30372
+ GMPStatus["SRC_GATEWAY_CALLED"] = "source_gateway_called";
30373
+ GMPStatus["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
30374
+ GMPStatus["DEST_EXECUTED"] = "destination_executed";
30375
+ GMPStatus["EXPRESS_EXECUTED"] = "express_executed";
30376
+ GMPStatus["DEST_EXECUTE_ERROR"] = "error";
30377
+ GMPStatus["DEST_EXECUTING"] = "executing";
30378
+ GMPStatus["APPROVING"] = "approving";
30379
+ GMPStatus["FORECALLED"] = "forecalled";
30380
+ GMPStatus["FORECALLED_WITHOUT_GAS_PAID"] = "forecalled_without_gas_paid";
30381
+ GMPStatus["NOT_EXECUTED"] = "not_executed";
30382
+ GMPStatus["NOT_EXECUTED_WITHOUT_GAS_PAID"] = "not_executed_without_gas_paid";
30383
+ GMPStatus["INSUFFICIENT_FEE"] = "insufficient_fee";
30384
+ GMPStatus["UNKNOWN_ERROR"] = "unknown_error";
30385
+ GMPStatus["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
30386
+ GMPStatus["SRC_GATEWAY_CONFIRMED"] = "confirmed";
30387
+ })(GMPStatus || (GMPStatus = {}));
30388
+ var GasPaidStatus;
30389
+ (function (GasPaidStatus) {
30390
+ GasPaidStatus["GAS_UNPAID"] = "gas_unpaid";
30391
+ GasPaidStatus["GAS_PAID"] = "gas_paid";
30392
+ GasPaidStatus["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
30393
+ GasPaidStatus["GAS_PAID_ENOUGH_GAS"] = "gas_paid_enough_gas";
30394
+ })(GasPaidStatus || (GasPaidStatus = {}));
30395
+
30396
+ /* eslint-disable @typescript-eslint/naming-convention */
30397
+ const parseGMPStatus = (response) => {
30398
+ const { error, status } = response;
30399
+ if (status === 'error' && error)
30400
+ return GMPStatus.DEST_EXECUTE_ERROR;
30401
+ if (status === 'executed')
30402
+ return GMPStatus.DEST_EXECUTED;
30403
+ if (status === 'approved')
30404
+ return GMPStatus.DEST_GATEWAY_APPROVED;
30405
+ if (status === 'called')
30406
+ return GMPStatus.SRC_GATEWAY_CALLED;
30407
+ if (status === 'executing')
30408
+ return GMPStatus.DEST_EXECUTING;
30409
+ return status;
30410
+ };
30411
+ const parseGMPError = (response) => {
30412
+ if (response.error) {
30413
+ return {
30414
+ message: response.error.error.message,
30415
+ txHash: response.error.error.transactionHash,
30416
+ chain: response.error.chain,
30417
+ };
30418
+ }
30419
+ if (response.is_insufficient_fee) {
30420
+ return {
30421
+ message: 'Insufficient fee',
30422
+ txHash: response.call.transaction.hash,
30423
+ chain: response.call.chain,
30424
+ };
30425
+ }
30426
+ return undefined;
30427
+ };
30428
+ const execGet = async (base, params) => fetch(`${base}?${new URLSearchParams(params).toString()}`, {
30429
+ method: 'GET',
30430
+ headers: { 'Content-Type': 'application/json' },
30431
+ cache: 'no-store',
30432
+ })
30433
+ .then((res) => res.json())
30434
+ .then((res) => res.data);
30435
+ const fetchGMPTransaction = async (axelarGMPApiUrl, txHash, txLogIndex) => execGet(axelarGMPApiUrl, {
30436
+ method: 'searchGMP',
30437
+ txHash,
30438
+ txLogIndex,
30439
+ })
30440
+ .then((data) => data.find((gmpTx) => gmpTx.id.indexOf(txHash) > -1 || gmpTx.call.transactionHash.indexOf(txHash) > -1))
30441
+ .catch(() => undefined);
30442
+ const queryTransactionStatus = async (axelarGMPApiUrl, txHash, txLogIndex) => {
30443
+ const txDetails = await fetchGMPTransaction(axelarGMPApiUrl, txHash, txLogIndex);
30444
+ if (!txDetails)
30445
+ return { status: GMPStatus.CANNOT_FETCH_STATUS };
30446
+ const { call, gas_status, gas_paid, executed, express_executed, approved, callback, } = txDetails;
30447
+ const gasPaidInfo = {
30448
+ status: gas_status,
30449
+ details: gas_paid,
30450
+ };
30451
+ // Note: Currently, the GMP API doesn't always return the `total` field in the `time_spent` object
30452
+ // This is a temporary fix to ensure that the `total` field is always present
30453
+ // TODO: Remove this once the API is fixed
30454
+ const timeSpent = txDetails.time_spent;
30455
+ if (timeSpent) {
30456
+ timeSpent.total = timeSpent.total
30457
+ || Object.values(timeSpent).reduce((accumulator, value) => accumulator + value, 0);
30458
+ }
30459
+ return {
30460
+ status: parseGMPStatus(txDetails),
30461
+ error: parseGMPError(txDetails),
30462
+ timeSpent,
30463
+ gasPaidInfo,
30464
+ callTx: call,
30465
+ executed,
30466
+ expressExecuted: express_executed,
30467
+ approved,
30468
+ callback,
30469
+ };
30470
+ };
30471
+
30472
+ /* eslint-disable no-console */
30368
30473
  /* eslint-disable class-methods-use-this */
30369
30474
  /**
30370
30475
  * Represents a token bridge, which manages asset transfers between two chains.
@@ -30556,6 +30661,7 @@ class TokenBridge {
30556
30661
  to: req.token,
30557
30662
  value: 0,
30558
30663
  from: req.senderAddress,
30664
+ chainId: parseInt(req.sourceChainId, 10),
30559
30665
  };
30560
30666
  return {
30561
30667
  contractToApprove: sourceBridgeAddress,
@@ -30701,6 +30807,7 @@ class TokenBridge {
30701
30807
  data,
30702
30808
  to: contractAddress,
30703
30809
  value: amount.add(fees.bridgeFee).toString(),
30810
+ chainId: parseInt(sourceChainId, 10),
30704
30811
  },
30705
30812
  };
30706
30813
  }
@@ -30720,6 +30827,7 @@ class TokenBridge {
30720
30827
  data,
30721
30828
  to: contractAddress,
30722
30829
  value: fees.bridgeFee.toString(),
30830
+ chainId: parseInt(sourceChainId, 10),
30723
30831
  },
30724
30832
  };
30725
30833
  }
@@ -30768,6 +30876,21 @@ class TokenBridge {
30768
30876
  throw new BridgeError(`Childchain provider chainID ${childNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.childChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
30769
30877
  }
30770
30878
  }
30879
+ getAxelarEndpoint(source) {
30880
+ let axelarAPIEndpoint;
30881
+ if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
30882
+ || source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
30883
+ axelarAPIEndpoint = axelarAPIEndpoints.mainnet;
30884
+ }
30885
+ else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
30886
+ || source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
30887
+ axelarAPIEndpoint = axelarAPIEndpoints.testnet;
30888
+ }
30889
+ else {
30890
+ axelarAPIEndpoint = axelarAPIEndpoints.devnet;
30891
+ }
30892
+ return axelarAPIEndpoint;
30893
+ }
30771
30894
  /**
30772
30895
  * Calculate the gas amount for a transaction using axelarjs-sdk.
30773
30896
  * @param {*} source - The source chainId.
@@ -30786,18 +30909,7 @@ class TokenBridge {
30786
30909
  if (!destinationAxelar) {
30787
30910
  throw new BridgeError(`Destination chainID ${destination} can not be matched to an Axelar chain.`, BridgeErrorType.AXELAR_CHAIN_NOT_FOUND);
30788
30911
  }
30789
- let axelarApiEndpoint;
30790
- if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
30791
- || source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
30792
- axelarApiEndpoint = axelarAPIEndpoints.mainnet;
30793
- }
30794
- else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
30795
- || source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
30796
- axelarApiEndpoint = axelarAPIEndpoints.testnet;
30797
- }
30798
- else {
30799
- axelarApiEndpoint = axelarAPIEndpoints.devnet;
30800
- }
30912
+ const axelarAPIEndpoint = this.getAxelarEndpoint(source);
30801
30913
  let axiosResponse;
30802
30914
  const estimateGasReq = {
30803
30915
  method: 'estimateGasFee',
@@ -30808,7 +30920,7 @@ class TokenBridge {
30808
30920
  gasMultiplier,
30809
30921
  };
30810
30922
  try {
30811
- axiosResponse = await axios$1.post(axelarApiEndpoint, estimateGasReq);
30923
+ axiosResponse = await axios$1.post(axelarAPIEndpoint, estimateGasReq);
30812
30924
  }
30813
30925
  catch (error) {
30814
30926
  axiosResponse = error.response;
@@ -30825,30 +30937,136 @@ class TokenBridge {
30825
30937
  throw new BridgeError(`Estimating Axelar Gas failed with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
30826
30938
  }
30827
30939
  }
30828
- // STUBBED ENDPOINTS FOR PHASE 2 -------------------------------------------
30829
30940
  /**
30830
30941
  * Queries the status of a bridge transaction.
30831
30942
  *
30832
- * @param {TokenMappingRequest} req - The request object containing the token, rootChainId and childChainId.
30833
- * @returns {Promise<TokenMappingResponse>} - A promise that resolves to an object containing the token mappings.
30943
+ * @param {TxStatusRequest} req - The request object containing an array of transactions to query.
30944
+ * @returns {Promise<TxStatusResponse>} - A promise that resolves to an array of transaction statuses.
30834
30945
  * @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
30835
- * @dev this SDK method is currently stubbed
30836
30946
  */
30837
30947
  async getTransactionStatus(req) {
30838
- // eslint-disable-next-line no-console
30839
- console.log('stubbed response with req', req);
30840
- // Return the token mappings
30841
- return {
30842
- transactions: [{
30843
- transactionHash: '0x1234....',
30844
- status: StatusResponse.COMPLETE,
30845
- data: 'stubbed data',
30846
- }, {
30847
- transactionHash: '0xABCD....',
30848
- status: StatusResponse.PROCESSING,
30849
- data: 'stubbed data',
30850
- }],
30948
+ const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
30949
+ const txStatusResponse = {
30950
+ transactions: [],
30851
30951
  };
30952
+ const abiCoder = new AbiCoder();
30953
+ const statusPromises = [];
30954
+ for (const transaction of req.transactions) {
30955
+ statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
30956
+ }
30957
+ let statusResponses;
30958
+ try {
30959
+ statusResponses = await Promise.all(statusPromises);
30960
+ }
30961
+ catch (err) {
30962
+ throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
30963
+ }
30964
+ const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
30965
+ const isWithdraw = [
30966
+ ZKEVM_DEVNET_CHAIN_ID,
30967
+ ZKEVM_TESTNET_CHAIN_ID,
30968
+ ZKEVM_MAINNET_CHAIN_ID
30969
+ ].includes(req.sourceChainId);
30970
+ let rootBridge;
30971
+ if (isWithdraw) {
30972
+ rootBridge = await withBridgeError(async () => {
30973
+ const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
30974
+ return contract;
30975
+ }, BridgeErrorType.INTERNAL_ERROR);
30976
+ }
30977
+ const flowRatePromises = [];
30978
+ const flowRatePromisesReceivers = [];
30979
+ for (let i = 0, l = statusResponses.length; i < l; i++) {
30980
+ let metaStatus;
30981
+ // consolidate axelar statuses to our own simplified metaStatus
30982
+ switch (statusResponses[i].status) {
30983
+ case GMPStatus.CANNOT_FETCH_STATUS:
30984
+ metaStatus = StatusResponse.PENDING;
30985
+ break;
30986
+ case GMPStatus.SRC_GATEWAY_CALLED:
30987
+ case GMPStatus.DEST_GATEWAY_APPROVED:
30988
+ case GMPStatus.DEST_EXECUTING:
30989
+ case GMPStatus.SRC_GATEWAY_CONFIRMED:
30990
+ case GMPStatus.APPROVING:
30991
+ metaStatus = StatusResponse.PROCESSING;
30992
+ break;
30993
+ case GMPStatus.NOT_EXECUTED:
30994
+ metaStatus = StatusResponse.RETRY;
30995
+ break;
30996
+ case GMPStatus.NOT_EXECUTED_WITHOUT_GAS_PAID:
30997
+ case GMPStatus.INSUFFICIENT_FEE:
30998
+ metaStatus = StatusResponse.NOT_ENOUGH_GAS;
30999
+ break;
31000
+ case GMPStatus.DEST_EXECUTED:
31001
+ metaStatus = StatusResponse.COMPLETE;
31002
+ break;
31003
+ default:
31004
+ metaStatus = StatusResponse.ERROR;
31005
+ }
31006
+ if (statusResponses[i].gasPaidInfo) {
31007
+ if (unpaidGasStatus.includes(statusResponses[i].gasPaidInfo.status)) {
31008
+ metaStatus = StatusResponse.NOT_ENOUGH_GAS;
31009
+ }
31010
+ }
31011
+ let txItem = {
31012
+ txHash: req.transactions[i].txHash,
31013
+ status: metaStatus,
31014
+ data: {
31015
+ gmpResponse: statusResponses[i].status,
31016
+ },
31017
+ };
31018
+ let decodedData;
31019
+ if (statusResponses[i]?.callTx?.returnValues?.payload) {
31020
+ decodedData = abiCoder.decode(['bytes32', 'address', 'address', 'address', 'uint256'], statusResponses[i].callTx.returnValues.payload);
31021
+ txItem = {
31022
+ ...txItem,
31023
+ token: decodedData[1],
31024
+ sender: decodedData[2],
31025
+ receiver: decodedData[3],
31026
+ amount: decodedData[4],
31027
+ };
31028
+ }
31029
+ let flowRatePromiseIndex;
31030
+ if (metaStatus === StatusResponse.COMPLETE
31031
+ && isWithdraw && txItem.receiver) {
31032
+ // consolidate the calls we have to make to the flow rate by receiver
31033
+ if (!flowRatePromisesReceivers.includes(txItem.receiver)) {
31034
+ flowRatePromises.push(rootBridge.getPendingWithdrawals(txItem.receiver, [0]));
31035
+ flowRatePromisesReceivers.push(txItem.receiver);
31036
+ flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
31037
+ }
31038
+ else {
31039
+ flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.receiver);
31040
+ }
31041
+ txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
31042
+ }
31043
+ txStatusResponse.transactions.push(txItem);
31044
+ } // for
31045
+ let flowRateResponses = [];
31046
+ if (flowRatePromises.length > 0) {
31047
+ try {
31048
+ flowRateResponses = await Promise.all(flowRatePromises);
31049
+ }
31050
+ catch (err) {
31051
+ throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
31052
+ }
31053
+ }
31054
+ for (const txStatusRes of txStatusResponse.transactions) {
31055
+ if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
31056
+ const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
31057
+ && el.token === txStatusRes.token
31058
+ && el.withdrawer === txStatusRes.sender));
31059
+ if (flowRatedTx) {
31060
+ txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
31061
+ txStatusRes.data = {
31062
+ timestamp: flowRatedTx.timestamp.toString(),
31063
+ };
31064
+ }
31065
+ }
31066
+ delete txStatusRes.data.flowRatePromiseIndex;
31067
+ }
31068
+ // Return the tx status response
31069
+ return txStatusResponse;
30852
31070
  }
30853
31071
  /**
30854
31072
  * Queries for the information about which tokens are flowrated and how long the delay is.
@@ -30987,7 +31205,7 @@ const CONTRACTS_FOR_BRIDGE = new Map()
30987
31205
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
30988
31206
  rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30989
31207
  childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
30990
- wrappedIMX: '0xa86C6C6d3D51c0592BE85dA05A9b06B62360D56E',
31208
+ wrappedIMX: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
30991
31209
  })
30992
31210
  .set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
30993
31211
  rootERC20BridgeFlowRate: '0x0',
@@ -35462,7 +35680,7 @@ const GAS_OVERRIDES = {
35462
35680
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
35463
35681
  };
35464
35682
 
35465
- const SDK_VERSION_MARKER = '0.36.4';
35683
+ const SDK_VERSION_MARKER = '0.36.5';
35466
35684
  // This SDK version is replaced by the `yarn build` command ran on the root level
35467
35685
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35468
35686
 
package/dist/index.d.ts CHANGED
@@ -17548,10 +17548,10 @@ type ImxAddressConfig = {
17548
17548
  };
17549
17549
  /**
17550
17550
  * A type representing the telemetry configurations.
17551
- * @property {string} publishableApiKey
17551
+ * @property {string} segmentPublishableKey
17552
17552
  */
17553
17553
  type TelemetryConfig = {
17554
- publishableApiKey: string;
17554
+ segmentPublishableKey: string;
17555
17555
  };
17556
17556
  /**
17557
17557
  * A type representing the required information to estimate gas for a transaction.