@imtbl/sdk 0.36.4 → 0.37.0

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.37.0' };
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.37.0',
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.37.0',
4737
4737
  });
4738
4738
  /**
4739
4739
  * Sets `sdkVersion` at the time of build
@@ -12232,13 +12232,13 @@ var ProtocolData;
12232
12232
  })(ProtocolData.order_type || (ProtocolData.order_type = {}));
12233
12233
  })(ProtocolData || (ProtocolData = {}));
12234
12234
 
12235
- var FeeType;
12235
+ var FeeType$1;
12236
12236
  (function (FeeType) {
12237
12237
  FeeType["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
12238
12238
  FeeType["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
12239
12239
  FeeType["PROTOCOL"] = "PROTOCOL";
12240
12240
  FeeType["ROYALTY"] = "ROYALTY";
12241
- })(FeeType || (FeeType = {}));
12241
+ })(FeeType$1 || (FeeType$1 = {}));
12242
12242
  var TransactionPurpose;
12243
12243
  (function (TransactionPurpose) {
12244
12244
  TransactionPurpose["APPROVAL"] = "APPROVAL";
@@ -12800,7 +12800,7 @@ class ImmutableApiClient {
12800
12800
  ],
12801
12801
  fees: makerFees.map((x) => ({
12802
12802
  amount: x.amount,
12803
- type: FeeType.MAKER_ECOSYSTEM,
12803
+ type: FeeType$1.MAKER_ECOSYSTEM,
12804
12804
  recipient_address: x.recipientAddress,
12805
12805
  })),
12806
12806
  end_at: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
@@ -13014,7 +13014,7 @@ class Orderbook {
13014
13014
  order_id: listingId,
13015
13015
  fees: takerFees.map((fee) => ({
13016
13016
  amount: fee.amount,
13017
- type: FeeType.TAKER_ECOSYSTEM,
13017
+ type: FeeType$1.TAKER_ECOSYSTEM,
13018
13018
  recipient_address: fee.recipientAddress,
13019
13019
  })),
13020
13020
  },
@@ -13037,7 +13037,7 @@ class Orderbook {
13037
13037
  order_id: listingRequest.listingId,
13038
13038
  fees: listingRequest.takerFees.map((fee) => ({
13039
13039
  amount: fee.amount,
13040
- type: FeeType.TAKER_ECOSYSTEM,
13040
+ type: FeeType$1.TAKER_ECOSYSTEM,
13041
13041
  recipient_address: fee.recipientAddress,
13042
13042
  })),
13043
13043
  })));
@@ -13168,7 +13168,7 @@ const constants = {
13168
13168
  var orderbook = /*#__PURE__*/Object.freeze({
13169
13169
  __proto__: null,
13170
13170
  get ActionType () { return ActionType; },
13171
- get FeeType () { return FeeType; },
13171
+ get FeeType () { return FeeType$1; },
13172
13172
  get OrderStatusName () { return OrderStatusName; },
13173
13173
  Orderbook: Orderbook,
13174
13174
  get SignablePurpose () { return SignablePurpose; },
@@ -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',
@@ -34835,6 +35053,21 @@ var RoutingOutcomeType;
34835
35053
  RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
34836
35054
  RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
34837
35055
  })(RoutingOutcomeType || (RoutingOutcomeType = {}));
35056
+ /**
35057
+ * An enum representing the funding step types
35058
+ * @enum {string}
35059
+ * @property {string} GAS - If the fee is a gas fee.
35060
+ * @property {string} BRIDGE_FEE - If the fee is a bridge fee.
35061
+ * @property {string} SWAP_FEE - If the fee is a swap fee.
35062
+ * @property {string} IMMUTABLE_FEE - If the fee is an immutable fee.
35063
+ */
35064
+ var FeeType;
35065
+ (function (FeeType) {
35066
+ FeeType["GAS"] = "GAS";
35067
+ FeeType["BRIDGE_FEE"] = "BRIDGE_FEE";
35068
+ FeeType["SWAP_FEE"] = "SWAP_FEE";
35069
+ FeeType["IMMUTABLE_FEE"] = "IMMUTABLE_FEE";
35070
+ })(FeeType || (FeeType = {}));
34838
35071
  /**
34839
35072
  * An enum representing the funding step types
34840
35073
  * @enum {string}
@@ -35440,7 +35673,7 @@ const GAS_OVERRIDES = {
35440
35673
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
35441
35674
  };
35442
35675
 
35443
- const SDK_VERSION_MARKER = '0.36.4';
35676
+ const SDK_VERSION_MARKER = '0.37.0';
35444
35677
  // This SDK version is replaced by the `yarn build` command ran on the root level
35445
35678
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35446
35679
 
@@ -36334,8 +36567,8 @@ const erc20ItemAggregator = (itemRequirements) => {
36334
36567
  aggregatedItemRequirements.push(itemRequirement);
36335
36568
  return;
36336
36569
  }
36337
- const { contractAddress, spenderAddress, amount } = itemRequirement;
36338
- const key = `${contractAddress}${spenderAddress}`;
36570
+ const { tokenAddress, spenderAddress, amount } = itemRequirement;
36571
+ const key = `${tokenAddress}${spenderAddress}`;
36339
36572
  const aggregateItem = aggregatedMap.get(key);
36340
36573
  if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
36341
36574
  aggregateItem.amount = BigNumber$1.from(aggregateItem.amount).add(amount);
@@ -36401,10 +36634,10 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
36401
36634
  for (const itemRequirement of itemRequirements) {
36402
36635
  if (itemRequirement.type !== ItemType.ERC20)
36403
36636
  continue;
36404
- const { contractAddress, spenderAddress } = itemRequirement;
36405
- const key = `${contractAddress}${spenderAddress}`;
36637
+ const { tokenAddress, spenderAddress } = itemRequirement;
36638
+ const key = `${tokenAddress}${spenderAddress}`;
36406
36639
  erc20s.set(key, itemRequirement);
36407
- allowancePromises.set(key, getERC20Allowance(provider, ownerAddress, contractAddress, spenderAddress));
36640
+ allowancePromises.set(key, getERC20Allowance(provider, ownerAddress, tokenAddress, spenderAddress));
36408
36641
  }
36409
36642
  const allowances = await Promise.all(allowancePromises.values());
36410
36643
  const allowancePromiseIds = Array.from(allowancePromises.keys());
@@ -36423,8 +36656,8 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
36423
36656
  continue;
36424
36657
  }
36425
36658
  sufficient = false; // Set sufficient false on the root of the return object when an ERC20 is insufficient
36426
- const { contractAddress, spenderAddress } = itemRequirement;
36427
- const key = `${contractAddress}${spenderAddress}`;
36659
+ const { tokenAddress, spenderAddress } = itemRequirement;
36660
+ const key = `${tokenAddress}${spenderAddress}`;
36428
36661
  const delta = itemRequirement.amount.sub(allowances[index]);
36429
36662
  // Create maps for both the insufficient ERC20 data and the transaction promises using the same key so the results can be merged
36430
36663
  insufficientERC20s.set(key, {
@@ -36434,7 +36667,7 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
36434
36667
  itemRequirement,
36435
36668
  approvalTransaction: undefined,
36436
36669
  });
36437
- transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress, contractAddress, spenderAddress, delta));
36670
+ transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress, tokenAddress, spenderAddress, delta));
36438
36671
  }
36439
36672
  // Resolves the approval transactions and merges them with the insufficient ERC20 data
36440
36673
  const transactions = await Promise.all(transactionPromises.values());
@@ -36619,8 +36852,8 @@ const erc20BalanceAggregator = (itemRequirements) => {
36619
36852
  aggregatedItemRequirements.push(itemRequirement);
36620
36853
  return;
36621
36854
  }
36622
- const { contractAddress, amount } = itemRequirement;
36623
- const key = `${contractAddress}`;
36855
+ const { tokenAddress, amount } = itemRequirement;
36856
+ const key = `${tokenAddress}`;
36624
36857
  const aggregateItem = aggregatedMap.get(key);
36625
36858
  if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
36626
36859
  aggregateItem.amount = BigNumber$1.from(aggregateItem.amount).add(amount);
@@ -36653,14 +36886,21 @@ const balanceAggregator = (itemRequirements) => erc721BalanceAggregator(erc20Bal
36653
36886
  /* eslint-disable arrow-body-style */
36654
36887
  const getTokensFromRequirements = (itemRequirements) => itemRequirements
36655
36888
  .map((itemRequirement) => {
36656
- if (itemRequirement.type === ItemType.NATIVE) {
36657
- return {
36658
- address: NATIVE,
36659
- };
36889
+ switch (itemRequirement.type) {
36890
+ case ItemType.ERC20:
36891
+ return {
36892
+ address: itemRequirement.tokenAddress,
36893
+ };
36894
+ case ItemType.NATIVE:
36895
+ return {
36896
+ address: NATIVE,
36897
+ };
36898
+ case ItemType.ERC721:
36899
+ default:
36900
+ return {
36901
+ address: itemRequirement.contractAddress,
36902
+ };
36660
36903
  }
36661
- return {
36662
- address: itemRequirement.contractAddress,
36663
- };
36664
36904
  });
36665
36905
  /**
36666
36906
  * Gets the balance requirement with delta for an ERC721 requirement.
@@ -36710,7 +36950,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
36710
36950
  // Get the requirements related balance
36711
36951
  if (itemRequirement.type === ItemType.ERC20) {
36712
36952
  itemBalanceResult = balances.find((balance) => {
36713
- return balance.token?.address === itemRequirement.contractAddress;
36953
+ return balance.token?.address === itemRequirement.tokenAddress;
36714
36954
  });
36715
36955
  }
36716
36956
  else if (itemRequirement.type === ItemType.NATIVE) {
@@ -36774,7 +37014,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
36774
37014
  token: {
36775
37015
  name,
36776
37016
  symbol,
36777
- address: itemRequirement.contractAddress,
37017
+ address: itemRequirement.tokenAddress,
36778
37018
  decimals,
36779
37019
  },
36780
37020
  };
@@ -36933,7 +37173,7 @@ const getGasItemRequirement = (gas, transactionOrGas) => {
36933
37173
  return {
36934
37174
  type: ItemType.ERC20,
36935
37175
  amount: gas,
36936
- contractAddress: transactionOrGas.gasToken.contractAddress,
37176
+ tokenAddress: transactionOrGas.gasToken.tokenAddress,
36937
37177
  spenderAddress: '',
36938
37178
  };
36939
37179
  };
@@ -37156,36 +37396,37 @@ const quoteFetcher = async (config, chainId, walletAddress, requiredToken, swapp
37156
37396
  }
37157
37397
  };
37158
37398
 
37159
- const constructFees$1 = (approvalGasFees, swapGasFees, swapFees) => {
37399
+ const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
37160
37400
  let approvalGasFeeAmount = BigNumber$1.from(0);
37161
37401
  let approvalGasFeeFormatted = '0';
37162
37402
  let approvalToken;
37163
- if (approvalGasFees) {
37164
- approvalGasFeeAmount = approvalGasFees.value;
37165
- approvalGasFeeFormatted = utils$2.formatUnits(approvalGasFees.value, approvalGasFees.token.decimals);
37403
+ if (approvalGasFee) {
37404
+ approvalGasFeeAmount = approvalGasFee.value;
37405
+ approvalGasFeeFormatted = utils$2.formatUnits(approvalGasFee.value, approvalGasFee.token.decimals);
37166
37406
  approvalToken = {
37167
- name: approvalGasFees.token.name ?? '',
37168
- symbol: approvalGasFees.token.symbol ?? '',
37169
- address: approvalGasFees.token.address,
37170
- decimals: approvalGasFees.token.decimals,
37407
+ name: approvalGasFee.token.name ?? '',
37408
+ symbol: approvalGasFee.token.symbol ?? '',
37409
+ address: approvalGasFee.token.address,
37410
+ decimals: approvalGasFee.token.decimals,
37171
37411
  };
37172
37412
  }
37173
37413
  let swapGasFeeAmount = BigNumber$1.from(0);
37174
37414
  let swapGasFeeFormatted = '0';
37175
37415
  let swapGasToken;
37176
- if (swapGasFees) {
37177
- swapGasFeeAmount = swapGasFees.value;
37178
- swapGasFeeFormatted = utils$2.formatUnits(swapGasFees.value, swapGasFees.token.decimals);
37416
+ if (swapGasFee) {
37417
+ swapGasFeeAmount = swapGasFee.value;
37418
+ swapGasFeeFormatted = utils$2.formatUnits(swapGasFee.value, swapGasFee.token.decimals);
37179
37419
  swapGasToken = {
37180
- name: swapGasFees.token.name ?? '',
37181
- symbol: swapGasFees.token.symbol ?? '',
37182
- address: swapGasFees.token.address,
37183
- decimals: swapGasFees.token.decimals,
37420
+ name: swapGasFee.token.name ?? '',
37421
+ symbol: swapGasFee.token.symbol ?? '',
37422
+ address: swapGasFee.token.address,
37423
+ decimals: swapGasFee.token.decimals,
37184
37424
  };
37185
37425
  }
37186
37426
  const fees = [];
37187
37427
  for (const swapFee of swapFees) {
37188
37428
  fees.push({
37429
+ type: FeeType.SWAP_FEE,
37189
37430
  amount: swapFee.amount.value,
37190
37431
  formattedAmount: utils$2.formatUnits(swapFee.amount.value, swapFee.amount.token.decimals),
37191
37432
  token: {
@@ -37197,12 +37438,14 @@ const constructFees$1 = (approvalGasFees, swapGasFees, swapFees) => {
37197
37438
  });
37198
37439
  }
37199
37440
  return {
37200
- approvalGasFees: {
37441
+ approvalGasFee: {
37442
+ type: FeeType.GAS,
37201
37443
  amount: approvalGasFeeAmount,
37202
37444
  formattedAmount: approvalGasFeeFormatted,
37203
37445
  token: approvalToken,
37204
37446
  },
37205
- swapGasFees: {
37447
+ swapGasFee: {
37448
+ type: FeeType.GAS,
37206
37449
  amount: swapGasFeeAmount,
37207
37450
  formattedAmount: swapGasFeeFormatted,
37208
37451
  token: swapGasToken,
@@ -37287,7 +37530,7 @@ const checkUserCanCoverApprovalFees = (l2Balances, approval) => {
37287
37530
  // The user has enough to cover approval gas fees
37288
37531
  return { sufficient: true, approvalGasFee, approvalGasTokenAddress };
37289
37532
  };
37290
- const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFees, swapFees, tokenBeingSwapped) => {
37533
+ const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFee, swapFees, tokenBeingSwapped) => {
37291
37534
  // Set up a map of token addresses to amounts for each of the swap fees
37292
37535
  const feeMap = new Map();
37293
37536
  // Add the approval fee to list of fees
@@ -37295,13 +37538,13 @@ const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFees, swapFe
37295
37538
  feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
37296
37539
  }
37297
37540
  // Add the swap gas fee to list of fees
37298
- if (swapGasFees) {
37299
- const fee = feeMap.get(swapGasFees.token.address);
37541
+ if (swapGasFee) {
37542
+ const fee = feeMap.get(swapGasFee.token.address);
37300
37543
  if (fee) {
37301
- feeMap.set(swapGasFees.token.address, fee.add(swapGasFees.value));
37544
+ feeMap.set(swapGasFee.token.address, fee.add(swapGasFee.value));
37302
37545
  }
37303
37546
  else {
37304
- feeMap.set(swapGasFees.token.address, swapGasFees.value);
37547
+ feeMap.set(swapGasFee.token.address, swapGasFee.value);
37305
37548
  }
37306
37549
  }
37307
37550
  // Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
@@ -37555,31 +37798,39 @@ const hasSufficientL1Eth = (tokenBalanceResult, totalFees) => {
37555
37798
  const balance = getEthBalance(tokenBalanceResult);
37556
37799
  return balance.gte(totalFees);
37557
37800
  };
37558
- const constructFees = (bridgeGasFees, bridgeFee, imtblFee, approvalGasFees, token) => {
37801
+ const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token) => {
37559
37802
  const bridgeFeeDecimals = token?.decimals ?? DEFAULT_TOKEN_DECIMALS$1;
37803
+ const bridgeFees = [];
37804
+ if (bridgeFee.gt(0)) {
37805
+ bridgeFees.push({
37806
+ type: FeeType.BRIDGE_FEE,
37807
+ amount: bridgeFee,
37808
+ formattedAmount: utils$2.formatUnits(bridgeFee, bridgeFeeDecimals),
37809
+ token,
37810
+ });
37811
+ }
37812
+ if (imtblFee.gt(0)) {
37813
+ bridgeFees.push({
37814
+ type: FeeType.IMMUTABLE_FEE,
37815
+ amount: imtblFee,
37816
+ formattedAmount: utils$2.formatUnits(imtblFee, bridgeFeeDecimals),
37817
+ token,
37818
+ });
37819
+ }
37560
37820
  return {
37561
- approvalGasFees: {
37562
- amount: approvalGasFees,
37563
- formattedAmount: utils$2.formatUnits(approvalGasFees, DEFAULT_TOKEN_DECIMALS$1),
37821
+ approvalGasFee: {
37822
+ type: FeeType.GAS,
37823
+ amount: approvalGasFee,
37824
+ formattedAmount: utils$2.formatUnits(approvalGasFee, DEFAULT_TOKEN_DECIMALS$1),
37564
37825
  token,
37565
37826
  },
37566
- bridgeGasFees: {
37567
- amount: bridgeGasFees,
37568
- formattedAmount: utils$2.formatUnits(bridgeGasFees, DEFAULT_TOKEN_DECIMALS$1),
37827
+ bridgeGasFee: {
37828
+ type: FeeType.GAS,
37829
+ amount: bridgeGasFee,
37830
+ formattedAmount: utils$2.formatUnits(bridgeGasFee, DEFAULT_TOKEN_DECIMALS$1),
37569
37831
  token,
37570
37832
  },
37571
- bridgeFees: [
37572
- {
37573
- amount: bridgeFee,
37574
- formattedAmount: utils$2.formatUnits(bridgeFee, bridgeFeeDecimals),
37575
- token,
37576
- },
37577
- {
37578
- amount: imtblFee,
37579
- formattedAmount: utils$2.formatUnits(imtblFee, bridgeFeeDecimals),
37580
- token,
37581
- },
37582
- ],
37833
+ bridgeFees,
37583
37834
  };
37584
37835
  };
37585
37836
  const constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType, fees) => ({
@@ -38438,13 +38689,13 @@ const calculateFees = (orderFees, weiAmount, decimals = 18) => {
38438
38689
  return calculateFeesResult;
38439
38690
  };
38440
38691
 
38441
- const getItemRequirement = (type, contractAddress, amount, spenderAddress) => {
38692
+ const getItemRequirement = (type, tokenAddress, amount, spenderAddress) => {
38442
38693
  switch (type) {
38443
38694
  case ItemType.ERC20:
38444
38695
  return {
38445
38696
  type,
38446
38697
  amount,
38447
- contractAddress,
38698
+ tokenAddress,
38448
38699
  spenderAddress,
38449
38700
  };
38450
38701
  case ItemType.NATIVE:
@@ -38667,7 +38918,7 @@ const getBuyToken = (buyToken, decimals = 18) => {
38667
38918
  return {
38668
38919
  type: ItemType.ERC20,
38669
38920
  amount: bnAmount.toString(),
38670
- contractAddress: buyToken.contractAddress,
38921
+ contractAddress: buyToken.tokenAddress,
38671
38922
  };
38672
38923
  };
38673
38924
  const sell = async (config, provider, orders) => {
@@ -38681,7 +38932,7 @@ const sell = async (config, provider, orders) => {
38681
38932
  let decimals = 18;
38682
38933
  if (buyToken.type === ItemType.ERC20) {
38683
38934
  // get this from the allowed list
38684
- const buyTokenContract = new Contract$1(buyToken.contractAddress, JSON.stringify(ERC20ABI), provider);
38935
+ const buyTokenContract = new Contract$1(buyToken.tokenAddress, JSON.stringify(ERC20ABI), provider);
38685
38936
  decimals = await measureAsyncExecution(config, 'Time to get decimals of token contract for the buy token', buyTokenContract.decimals());
38686
38937
  }
38687
38938
  const buyTokenOrNative = getBuyToken(buyToken, decimals);
@@ -38833,8 +39084,8 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
38833
39084
  const decimalPromises = [];
38834
39085
  requirements.forEach((itemRequirementParam) => {
38835
39086
  if (itemRequirementParam.type === ItemType.ERC20) {
38836
- const { contractAddress } = itemRequirementParam;
38837
- decimalPromises.push(getTokenContract(contractAddress, ERC20ABI, provider).decimals());
39087
+ const { tokenAddress } = itemRequirementParam;
39088
+ decimalPromises.push(getTokenContract(tokenAddress, ERC20ABI, provider).decimals());
38838
39089
  }
38839
39090
  });
38840
39091
  const decimals = await Promise.all(decimalPromises);
@@ -39149,7 +39400,7 @@ class Checkout {
39149
39400
  try {
39150
39401
  itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
39151
39402
  }
39152
- catch {
39403
+ catch (error) {
39153
39404
  throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
39154
39405
  }
39155
39406
  return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
@@ -39230,6 +39481,7 @@ var checkout = /*#__PURE__*/Object.freeze({
39230
39481
  get ConnectEventType () { return ConnectEventType; },
39231
39482
  get ConnectTargetLayer () { return ConnectTargetLayer; },
39232
39483
  get ExchangeType () { return ExchangeType; },
39484
+ get FeeType () { return FeeType; },
39233
39485
  get FundingStepType () { return FundingStepType; },
39234
39486
  get GasEstimateType () { return GasEstimateType; },
39235
39487
  get GasTokenType () { return GasTokenType; },