@metamask/bridge-status-controller 71.1.3 → 71.2.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/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [71.2.0]
11
+
12
+ ### Changed
13
+
14
+ - Pass `isInternal: true` to all internal `addTransaction` / `addTransactionBatch` calls to adopt the explicit `isInternal` flag introduced in `@metamask/transaction-controller` ([#8633](https://github.com/MetaMask/core/pull/8633))
15
+ - Bump `@metamask/profile-sync-controller` from `^28.0.2` to `^28.1.0` ([#8783](https://github.com/MetaMask/core/pull/8783))
16
+ - Bump `@metamask/transaction-controller` from `^65.3.0` to `^66.0.0` ([#8796](https://github.com/MetaMask/core/pull/8796), [#8848](https://github.com/MetaMask/core/pull/8848))
17
+ - Bump `@metamask/gas-fee-controller` from `^26.2.1` to `^26.2.2` ([#8834](https://github.com/MetaMask/core/pull/8834))
18
+ - Bump `@metamask/polling-controller` from `^16.0.5` to `^16.0.6` ([#8834](https://github.com/MetaMask/core/pull/8834))
19
+
20
+ ## [71.1.4]
21
+
22
+ ### Changed
23
+
24
+ - Bump `@metamask/accounts-controller` from `^38.1.0` to `^38.1.1` ([#8774](https://github.com/MetaMask/core/pull/8774))
25
+ - Bump `@metamask/bridge-controller` from `^72.0.3` to `^72.0.4` ([#8774](https://github.com/MetaMask/core/pull/8774))
26
+ - Bump `@metamask/network-controller` from `^31.1.0` to `^32.0.0` ([#8774](https://github.com/MetaMask/core/pull/8774))
27
+ - Bump `@metamask/controller-utils` from `^12.0.0` to `^12.1.0` ([#8774](https://github.com/MetaMask/core/pull/8774))
28
+
10
29
  ## [71.1.3]
11
30
 
12
31
  ### Changed
@@ -1181,7 +1200,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1181
1200
 
1182
1201
  - Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
1183
1202
 
1184
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.3...HEAD
1203
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.2.0...HEAD
1204
+ [71.2.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.4...@metamask/bridge-status-controller@71.2.0
1205
+ [71.1.4]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.3...@metamask/bridge-status-controller@71.1.4
1185
1206
  [71.1.3]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.2...@metamask/bridge-status-controller@71.1.3
1186
1207
  [71.1.2]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.1...@metamask/bridge-status-controller@71.1.2
1187
1208
  [71.1.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@71.1.0...@metamask/bridge-status-controller@71.1.1
@@ -139,6 +139,7 @@ const addSyntheticTransaction = async (messenger, ...args) => {
139
139
  origin: 'metamask',
140
140
  actionId: (0, exports.generateActionId)(),
141
141
  isStateOnly: true,
142
+ isInternal: true,
142
143
  ...args[1],
143
144
  });
144
145
  return transactionMeta;
@@ -271,6 +272,7 @@ const getAddTransactionBatchParams = async ({ messenger, isBridgeTx, approval, r
271
272
  networkClientId,
272
273
  requireApproval,
273
274
  origin: 'metamask',
275
+ isInternal: true,
274
276
  from: trade.from,
275
277
  transactions,
276
278
  };
@@ -400,6 +402,7 @@ actionId = (0, exports.generateActionId)(), }) => {
400
402
  requireApproval,
401
403
  type: transactionType,
402
404
  origin: 'metamask',
405
+ isInternal: true,
403
406
  };
404
407
  // Exclude gasLimit from trade to avoid type issues (it can be null)
405
408
  const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,qEAAq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S,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,IAAA,sCAAkB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAA,qCAA2B,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE3E,MAAM,cAAc,GAAG;QACrB,QAAQ;QACR,eAAe;QACf,eAAe;QACf,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,UAAU;KACnB,CAAC;IACF,oEAAoE;IACpE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAEnE,MAAM,iBAAiB,GAEhB;QACL,GAAG,oBAAoB;QACvB,OAAO,EAAE,UAAU;QACnB,uEAAuE;QACvE,GAAG,CAAC,aAAa;YACf,aAAa,KAAK,CAAC,IAAI;YACrB,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE;YAClC,GAAG,EAAE,aAAa,CAAC,QAAQ,EAAE;SAC9B,CAAC;KACL,CAAC;IACF,MAAM,2BAA2B,GAAsB;QACrD,GAAG,iBAAiB;QACpB,GAAG,CAAC,MAAM,uBAAuB,CAC/B,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,KAAK,CACN,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,IAAA,sBAAc,EACzB,SAAS,EACT,2BAA2B,EAC3B,cAAc,CACf,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n} from '@metamask/bridge-controller';\nimport type {\n QuoteMetadata,\n QuoteResponse,\n TxData,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\nimport { getAccountByAddress } from './accounts';\nimport { getNetworkClientIdByChainId } from './network';\n\nconst isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nconst isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n): Promise<{ maxFeePerGas?: string; maxPriorityFeePerGas?: string }> => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n if (\n BRIDGE_PREFERRED_GAS_ESTIMATE in estimates &&\n typeof estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] === 'object' &&\n 'maxFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] &&\n 'maxPriorityFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]\n ) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n return {};\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param estimateGasFeeParams - The parameters for the {@link TransactionController.estimateGasFee} method\n \n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n estimateGasFeeParams: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const estimatedBaseFee =\n 'estimatedBaseFee' in gasFeeEstimates\n ? gasFeeEstimates.estimatedBaseFee\n : '0';\n\n // Get transaction's 1559 gas fee estimates\n const { maxFeePerGas, maxPriorityFeePerGas } = await getGasFeeEstimates(\n messenger,\n estimateGasFeeParams,\n );\n\n /**\n * @deprecated this is unused\n */\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n networkClientId,\n chainId,\n },\n );\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponse['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toBatchTxParams = (\n skipGasFields: boolean,\n { chainId, gasLimit, ...trade }: TxData,\n {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas,\n }: { maxFeePerGas?: string; maxPriorityFeePerGas?: string; gas?: string },\n): BatchTransactionParams => {\n const params = {\n ...trade,\n data: trade.data as Hex,\n to: trade.to as Hex,\n value: trade.value as Hex,\n };\n if (skipGasFields) {\n return params;\n }\n\n return {\n ...params,\n gas: toHex(gas ?? 0),\n maxFeePerGas: toHex(maxFeePerGas ?? 0),\n maxPriorityFeePerGas: toHex(maxPriorityFeePerGas ?? 0),\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n isBridgeTx,\n approval,\n resetApproval,\n trade,\n quoteResponse: {\n quote: {\n feeData: { txFee },\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n sentAmount,\n toTokenAmount,\n },\n requireApproval = false,\n isDelegatedAccount = false,\n}: {\n messenger: BridgeStatusControllerMessenger;\n isBridgeTx: boolean;\n trade: TxData;\n quoteResponse: Omit<QuoteResponse, 'approval' | 'trade'> &\n Partial<QuoteMetadata>;\n approval?: TxData;\n resetApproval?: TxData;\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const isGasless = gasIncluded || gasIncluded7702;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n // Gas fields should be omitted only when gas is sponsored via 7702\n const skipGasFields = gasIncluded7702 === true;\n // Enable 7702 batching when the quote includes gasless 7702 support,\n // or when the account is already delegated (to avoid the in-flight\n // transaction limit for delegated accounts)\n let disable7702 = !skipGasFields && !isDelegatedAccount;\n\n // For gasless transactions with STX/sendBundle we keep disabling 7702.\n if (gasIncluded && !gasIncluded7702) {\n disable7702 = true;\n }\n\n const transactions: TransactionBatchSingleRequest[] = [];\n if (resetApproval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n resetApproval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, resetApproval, gasFees),\n });\n }\n if (approval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n approval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, approval, gasFees),\n });\n }\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n trade,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n params: toBatchTxParams(skipGasFields, trade, gasFees),\n assetsFiatValues: {\n sending: sentAmount?.valueInCurrency?.toString(),\n receiving: toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n const transactionParams: Parameters<\n TransactionController['addTransactionBatch']\n >[0] = {\n disable7702,\n isGasFeeIncluded: Boolean(gasIncluded7702),\n isGasFeeSponsored: Boolean(gasSponsored),\n networkClientId,\n requireApproval,\n origin: 'metamask',\n from: trade.from as Hex,\n transactions,\n };\n\n return transactionParams;\n};\n\nexport const findAndUpdateTransactionsInBatch = ({\n messenger,\n batchId,\n txDataByType,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n txDataByType: { [key in TransactionType]?: string };\n}) => {\n const txs = getTransactions(messenger);\n const txBatch: {\n approvalMeta?: TransactionMeta;\n tradeMeta?: TransactionMeta;\n } = {\n approvalMeta: undefined,\n tradeMeta: undefined,\n };\n\n // This is a workaround to update the tx type after the tx is signed\n // TODO: remove this once the tx type for batch txs is preserved in the tx controller\n const txEntries = Object.entries(txDataByType) as [TransactionType, string][];\n txEntries.forEach(([txType, txData]) => {\n // Skip types not present in the batch (e.g. swap entry is undefined for bridge txs)\n if (txData === undefined) {\n return;\n }\n\n // Find transaction by batchId and either matching data or delegation characteristics\n const txMeta = txs.find((tx: TransactionMeta) => {\n if (tx.batchId !== batchId) {\n return false;\n }\n\n // For 7702 delegated transactions, check for delegation-specific fields\n // These transactions might have authorizationList or delegationAddress\n const is7702Transaction =\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress);\n\n if (is7702Transaction) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(txType) && tx.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(txType) && tx.txParams.data === txData) {\n return true;\n }\n }\n\n // Default matching logic for non-7702 transactions\n return tx.txParams.data === txData;\n });\n\n if (txMeta) {\n const updatedTx = { ...txMeta, type: txType };\n updateTransaction(\n messenger,\n txMeta,\n { type: txType },\n `Update tx type to ${txType}`,\n );\n const txTypes = [\n TransactionType.bridgeApproval,\n TransactionType.swapApproval,\n ] as readonly string[];\n txBatch[txTypes.includes(txType) ? 'approvalMeta' : 'tradeMeta'] =\n updatedTx;\n }\n });\n\n return txBatch;\n};\n\nexport const addTransactionBatch = async (\n messenger: BridgeStatusControllerMessenger,\n addTransactionBatchFn: TransactionController['addTransactionBatch'],\n ...args: Parameters<TransactionController['addTransactionBatch']>\n) => {\n const txDataByType = {\n [TransactionType.bridgeApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridgeApproval,\n )?.params.data,\n [TransactionType.swapApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swapApproval,\n )?.params.data,\n [TransactionType.bridge]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridge,\n )?.params.data,\n [TransactionType.swap]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swap,\n )?.params.data,\n };\n\n const { batchId } = await addTransactionBatchFn(...args);\n\n const { approvalMeta, tradeMeta } = findAndUpdateTransactionsInBatch({\n messenger,\n batchId,\n txDataByType,\n });\n\n if (!tradeMeta) {\n throw new Error(\n 'Failed to update cross-chain swap transaction batch: tradeMeta not found',\n );\n }\n\n return { approvalMeta, tradeMeta };\n};\n\n// TODO rename\nconst getGasFeesForSubmission = async (\n messenger: BridgeStatusControllerMessenger,\n transactionParams: TransactionParams,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n): Promise<{\n maxFeePerGas?: string; // Hex\n maxPriorityFeePerGas?: string; // Hex\n gas?: Hex;\n}> => {\n const { gas } = transactionParams;\n // If txFee is provided (gasIncluded case), use the quote's gas fees\n // Convert to hex since txFee values from the quote are decimal strings\n if (txFee) {\n return {\n maxFeePerGas: toHex(txFee.maxFeePerGas),\n maxPriorityFeePerGas: toHex(txFee.maxPriorityFeePerGas),\n gas: gas ? toHex(gas) : undefined,\n };\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n chainId,\n networkClientId,\n },\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: gas ? toHex(gas) : undefined,\n };\n};\n\n/**\n * Submits an EVM transaction to the TransactionController\n *\n * @param params - The parameters for the transaction\n * @param params.transactionType - The type of transaction to submit\n * @param params.trade - The trade data to confirm\n * @param params.requireApproval - Whether to require approval for the transaction\n * @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)\n * @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote\n * @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote\n * @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)\n * @param params.messenger - The messenger to use for the transaction\n * @returns The transaction meta\n */\nexport const submitEvmTransaction = async ({\n messenger,\n trade,\n transactionType,\n requireApproval = false,\n txFee,\n // Use provided actionId (for pre-submission history) or generate one\n actionId = generateActionId(),\n}: {\n messenger: BridgeStatusControllerMessenger;\n transactionType: TransactionType;\n trade: TxData;\n requireApproval?: boolean;\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string };\n actionId?: string;\n}): Promise<TransactionMeta> => {\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const requestOptions = {\n actionId,\n networkClientId,\n requireApproval,\n type: transactionType,\n origin: 'metamask',\n };\n // Exclude gasLimit from trade to avoid type issues (it can be null)\n const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;\n\n const transactionParams: Parameters<\n TransactionController['addTransaction']\n >[0] = {\n ...tradeWithoutGasLimit,\n chainId: hexChainId,\n // Only add gasLimit and gas if they're valid (not undefined/null/zero)\n ...(tradeGasLimit &&\n tradeGasLimit !== 0 && {\n gasLimit: tradeGasLimit.toString(),\n gas: tradeGasLimit.toString(),\n }),\n };\n const transactionParamsWithMaxGas: TransactionParams = {\n ...transactionParams,\n ...(await getGasFeesForSubmission(\n messenger,\n transactionParams,\n networkClientId,\n hexChainId,\n txFee,\n )),\n };\n\n return await addTransaction(\n messenger,\n transactionParamsWithMaxGas,\n requestOptions,\n );\n};\n"]}
1
+ {"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mEAIqC;AAMrC,iEAAmD;AACnD,6EAG0C;AAS1C,2CAA2D;AAC3D,+CAAyC;AAEzC,gDAAiD;AAEjD,6CAAiD;AACjD,2CAAwD;AAExD,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,EAAE,CAC7C,IAAI,KAAK,wCAAe,CAAC,cAAc;IACvC,IAAI,KAAK,wCAAe,CAAC,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OAAO,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAA,qCAA2B,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE3E,MAAM,cAAc,GAAG;QACrB,QAAQ;QACR,eAAe;QACf,eAAe;QACf,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI;KACjB,CAAC;IACF,oEAAoE;IACpE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAEnE,MAAM,iBAAiB,GAEhB;QACL,GAAG,oBAAoB;QACvB,OAAO,EAAE,UAAU;QACnB,uEAAuE;QACvE,GAAG,CAAC,aAAa;YACf,aAAa,KAAK,CAAC,IAAI;YACrB,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE;YAClC,GAAG,EAAE,aAAa,CAAC,QAAQ,EAAE;SAC9B,CAAC;KACL,CAAC;IACF,MAAM,2BAA2B,GAAsB;QACrD,GAAG,iBAAiB;QACpB,GAAG,CAAC,MAAM,uBAAuB,CAC/B,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,KAAK,CACN,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,IAAA,sBAAc,EACzB,SAAS,EACT,2BAA2B,EAC3B,cAAc,CACf,CAAC;AACJ,CAAC,CAAC;AAhEW,QAAA,oBAAoB,wBAgE/B","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n} from '@metamask/bridge-controller';\nimport type {\n QuoteMetadata,\n QuoteResponse,\n TxData,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\nimport { getAccountByAddress } from './accounts';\nimport { getNetworkClientIdByChainId } from './network';\n\nconst isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nconst isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n): Promise<{ maxFeePerGas?: string; maxPriorityFeePerGas?: string }> => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n if (\n BRIDGE_PREFERRED_GAS_ESTIMATE in estimates &&\n typeof estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] === 'object' &&\n 'maxFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] &&\n 'maxPriorityFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]\n ) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n return {};\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param estimateGasFeeParams - The parameters for the {@link TransactionController.estimateGasFee} method\n \n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n estimateGasFeeParams: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const estimatedBaseFee =\n 'estimatedBaseFee' in gasFeeEstimates\n ? gasFeeEstimates.estimatedBaseFee\n : '0';\n\n // Get transaction's 1559 gas fee estimates\n const { maxFeePerGas, maxPriorityFeePerGas } = await getGasFeeEstimates(\n messenger,\n estimateGasFeeParams,\n );\n\n /**\n * @deprecated this is unused\n */\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n networkClientId,\n chainId,\n },\n );\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n isInternal: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponse['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toBatchTxParams = (\n skipGasFields: boolean,\n { chainId, gasLimit, ...trade }: TxData,\n {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas,\n }: { maxFeePerGas?: string; maxPriorityFeePerGas?: string; gas?: string },\n): BatchTransactionParams => {\n const params = {\n ...trade,\n data: trade.data as Hex,\n to: trade.to as Hex,\n value: trade.value as Hex,\n };\n if (skipGasFields) {\n return params;\n }\n\n return {\n ...params,\n gas: toHex(gas ?? 0),\n maxFeePerGas: toHex(maxFeePerGas ?? 0),\n maxPriorityFeePerGas: toHex(maxPriorityFeePerGas ?? 0),\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n isBridgeTx,\n approval,\n resetApproval,\n trade,\n quoteResponse: {\n quote: {\n feeData: { txFee },\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n sentAmount,\n toTokenAmount,\n },\n requireApproval = false,\n isDelegatedAccount = false,\n}: {\n messenger: BridgeStatusControllerMessenger;\n isBridgeTx: boolean;\n trade: TxData;\n quoteResponse: Omit<QuoteResponse, 'approval' | 'trade'> &\n Partial<QuoteMetadata>;\n approval?: TxData;\n resetApproval?: TxData;\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const isGasless = gasIncluded || gasIncluded7702;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n // Gas fields should be omitted only when gas is sponsored via 7702\n const skipGasFields = gasIncluded7702 === true;\n // Enable 7702 batching when the quote includes gasless 7702 support,\n // or when the account is already delegated (to avoid the in-flight\n // transaction limit for delegated accounts)\n let disable7702 = !skipGasFields && !isDelegatedAccount;\n\n // For gasless transactions with STX/sendBundle we keep disabling 7702.\n if (gasIncluded && !gasIncluded7702) {\n disable7702 = true;\n }\n\n const transactions: TransactionBatchSingleRequest[] = [];\n if (resetApproval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n resetApproval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, resetApproval, gasFees),\n });\n }\n if (approval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n approval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, approval, gasFees),\n });\n }\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n trade,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n params: toBatchTxParams(skipGasFields, trade, gasFees),\n assetsFiatValues: {\n sending: sentAmount?.valueInCurrency?.toString(),\n receiving: toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n const transactionParams: Parameters<\n TransactionController['addTransactionBatch']\n >[0] = {\n disable7702,\n isGasFeeIncluded: Boolean(gasIncluded7702),\n isGasFeeSponsored: Boolean(gasSponsored),\n networkClientId,\n requireApproval,\n origin: 'metamask',\n isInternal: true,\n from: trade.from as Hex,\n transactions,\n };\n\n return transactionParams;\n};\n\nexport const findAndUpdateTransactionsInBatch = ({\n messenger,\n batchId,\n txDataByType,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n txDataByType: { [key in TransactionType]?: string };\n}) => {\n const txs = getTransactions(messenger);\n const txBatch: {\n approvalMeta?: TransactionMeta;\n tradeMeta?: TransactionMeta;\n } = {\n approvalMeta: undefined,\n tradeMeta: undefined,\n };\n\n // This is a workaround to update the tx type after the tx is signed\n // TODO: remove this once the tx type for batch txs is preserved in the tx controller\n const txEntries = Object.entries(txDataByType) as [TransactionType, string][];\n txEntries.forEach(([txType, txData]) => {\n // Skip types not present in the batch (e.g. swap entry is undefined for bridge txs)\n if (txData === undefined) {\n return;\n }\n\n // Find transaction by batchId and either matching data or delegation characteristics\n const txMeta = txs.find((tx: TransactionMeta) => {\n if (tx.batchId !== batchId) {\n return false;\n }\n\n // For 7702 delegated transactions, check for delegation-specific fields\n // These transactions might have authorizationList or delegationAddress\n const is7702Transaction =\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress);\n\n if (is7702Transaction) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(txType) && tx.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(txType) && tx.txParams.data === txData) {\n return true;\n }\n }\n\n // Default matching logic for non-7702 transactions\n return tx.txParams.data === txData;\n });\n\n if (txMeta) {\n const updatedTx = { ...txMeta, type: txType };\n updateTransaction(\n messenger,\n txMeta,\n { type: txType },\n `Update tx type to ${txType}`,\n );\n const txTypes = [\n TransactionType.bridgeApproval,\n TransactionType.swapApproval,\n ] as readonly string[];\n txBatch[txTypes.includes(txType) ? 'approvalMeta' : 'tradeMeta'] =\n updatedTx;\n }\n });\n\n return txBatch;\n};\n\nexport const addTransactionBatch = async (\n messenger: BridgeStatusControllerMessenger,\n addTransactionBatchFn: TransactionController['addTransactionBatch'],\n ...args: Parameters<TransactionController['addTransactionBatch']>\n) => {\n const txDataByType = {\n [TransactionType.bridgeApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridgeApproval,\n )?.params.data,\n [TransactionType.swapApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swapApproval,\n )?.params.data,\n [TransactionType.bridge]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridge,\n )?.params.data,\n [TransactionType.swap]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swap,\n )?.params.data,\n };\n\n const { batchId } = await addTransactionBatchFn(...args);\n\n const { approvalMeta, tradeMeta } = findAndUpdateTransactionsInBatch({\n messenger,\n batchId,\n txDataByType,\n });\n\n if (!tradeMeta) {\n throw new Error(\n 'Failed to update cross-chain swap transaction batch: tradeMeta not found',\n );\n }\n\n return { approvalMeta, tradeMeta };\n};\n\n// TODO rename\nconst getGasFeesForSubmission = async (\n messenger: BridgeStatusControllerMessenger,\n transactionParams: TransactionParams,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n): Promise<{\n maxFeePerGas?: string; // Hex\n maxPriorityFeePerGas?: string; // Hex\n gas?: Hex;\n}> => {\n const { gas } = transactionParams;\n // If txFee is provided (gasIncluded case), use the quote's gas fees\n // Convert to hex since txFee values from the quote are decimal strings\n if (txFee) {\n return {\n maxFeePerGas: toHex(txFee.maxFeePerGas),\n maxPriorityFeePerGas: toHex(txFee.maxPriorityFeePerGas),\n gas: gas ? toHex(gas) : undefined,\n };\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n chainId,\n networkClientId,\n },\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: gas ? toHex(gas) : undefined,\n };\n};\n\n/**\n * Submits an EVM transaction to the TransactionController\n *\n * @param params - The parameters for the transaction\n * @param params.transactionType - The type of transaction to submit\n * @param params.trade - The trade data to confirm\n * @param params.requireApproval - Whether to require approval for the transaction\n * @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)\n * @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote\n * @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote\n * @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)\n * @param params.messenger - The messenger to use for the transaction\n * @returns The transaction meta\n */\nexport const submitEvmTransaction = async ({\n messenger,\n trade,\n transactionType,\n requireApproval = false,\n txFee,\n // Use provided actionId (for pre-submission history) or generate one\n actionId = generateActionId(),\n}: {\n messenger: BridgeStatusControllerMessenger;\n transactionType: TransactionType;\n trade: TxData;\n requireApproval?: boolean;\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string };\n actionId?: string;\n}): Promise<TransactionMeta> => {\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const requestOptions = {\n actionId,\n networkClientId,\n requireApproval,\n type: transactionType,\n origin: 'metamask',\n isInternal: true,\n };\n // Exclude gasLimit from trade to avoid type issues (it can be null)\n const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;\n\n const transactionParams: Parameters<\n TransactionController['addTransaction']\n >[0] = {\n ...tradeWithoutGasLimit,\n chainId: hexChainId,\n // Only add gasLimit and gas if they're valid (not undefined/null/zero)\n ...(tradeGasLimit &&\n tradeGasLimit !== 0 && {\n gasLimit: tradeGasLimit.toString(),\n gas: tradeGasLimit.toString(),\n }),\n };\n const transactionParamsWithMaxGas: TransactionParams = {\n ...transactionParams,\n ...(await getGasFeesForSubmission(\n messenger,\n transactionParams,\n networkClientId,\n hexChainId,\n txFee,\n )),\n };\n\n return await addTransaction(\n messenger,\n transactionParamsWithMaxGas,\n requestOptions,\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,MAAM,EACP,oCAAoC;AAErC,OAAO,EAEL,eAAe,EAChB,yCAAyC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EAEtB,qBAAqB,EACrB,eAAe,EAEf,iBAAiB,EAClB,yCAAyC;AAC1C,OAAO,EAAuB,GAAG,EAAE,wBAAwB;AAC3D,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAGzC,OAAO,KAAK,EAAE,+BAA+B,EAAE,qBAAiB;AAShE,eAAO,MAAM,cAAc,SAAU,eAAe,YACb,CAAC;AAExC,eAAO,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,eAAO,MAAM,oBAAoB;;qBAUd,eAAe;WACzB,MAAM;;;sBAEW,MAAM;8BAAwB,MAAM;;;MAE1D,QAAQ,eAAe,CAiD1B,CAAC"}
@@ -125,6 +125,7 @@ export const addSyntheticTransaction = async (messenger, ...args) => {
125
125
  origin: 'metamask',
126
126
  actionId: generateActionId(),
127
127
  isStateOnly: true,
128
+ isInternal: true,
128
129
  ...args[1],
129
130
  });
130
131
  return transactionMeta;
@@ -252,6 +253,7 @@ export const getAddTransactionBatchParams = async ({ messenger, isBridgeTx, appr
252
253
  networkClientId,
253
254
  requireApproval,
254
255
  origin: 'metamask',
256
+ isInternal: true,
255
257
  from: trade.from,
256
258
  transactions,
257
259
  };
@@ -378,6 +380,7 @@ actionId = generateActionId(), }) => {
378
380
  requireApproval,
379
381
  type: transactionType,
380
382
  origin: 'metamask',
383
+ isInternal: true,
381
384
  };
382
385
  // Exclude gasLimit from trade to avoid type issues (it can be null)
383
386
  const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,6BAA6B,EAC9B,oCAAoC;AAMrC,OAAO,EAAE,KAAK,EAAE,mCAAmC;AACnD,OAAO,EACL,iBAAiB,EACjB,eAAe,EAChB,yCAAyC;AAS1C,OAAO,EAAE,mBAAmB,EAAO,wBAAwB;AAC3D,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EAAE,iBAAiB,EAAE,yBAAqB;AAEjD,OAAO,EAAE,mBAAmB,EAAE,uBAAmB;AACjD,OAAO,EAAE,2BAA2B,EAAE,sBAAkB;AAExD,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,EAAE,CAC7C,IAAI,KAAK,eAAe,CAAC,cAAc;IACvC,IAAI,KAAK,eAAe,CAAC,YAAY,CAAC;AAC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,MAAM,uBAAuB,CAC/B,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,KAAK,CACN,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,cAAc,CACzB,SAAS,EACT,2BAA2B,EAC3B,cAAc,CACf,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n} from '@metamask/bridge-controller';\nimport type {\n QuoteMetadata,\n QuoteResponse,\n TxData,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\nimport { getAccountByAddress } from './accounts';\nimport { getNetworkClientIdByChainId } from './network';\n\nconst isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nconst isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n): Promise<{ maxFeePerGas?: string; maxPriorityFeePerGas?: string }> => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n if (\n BRIDGE_PREFERRED_GAS_ESTIMATE in estimates &&\n typeof estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] === 'object' &&\n 'maxFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] &&\n 'maxPriorityFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]\n ) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n return {};\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param estimateGasFeeParams - The parameters for the {@link TransactionController.estimateGasFee} method\n \n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n estimateGasFeeParams: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const estimatedBaseFee =\n 'estimatedBaseFee' in gasFeeEstimates\n ? gasFeeEstimates.estimatedBaseFee\n : '0';\n\n // Get transaction's 1559 gas fee estimates\n const { maxFeePerGas, maxPriorityFeePerGas } = await getGasFeeEstimates(\n messenger,\n estimateGasFeeParams,\n );\n\n /**\n * @deprecated this is unused\n */\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n networkClientId,\n chainId,\n },\n );\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponse['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toBatchTxParams = (\n skipGasFields: boolean,\n { chainId, gasLimit, ...trade }: TxData,\n {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas,\n }: { maxFeePerGas?: string; maxPriorityFeePerGas?: string; gas?: string },\n): BatchTransactionParams => {\n const params = {\n ...trade,\n data: trade.data as Hex,\n to: trade.to as Hex,\n value: trade.value as Hex,\n };\n if (skipGasFields) {\n return params;\n }\n\n return {\n ...params,\n gas: toHex(gas ?? 0),\n maxFeePerGas: toHex(maxFeePerGas ?? 0),\n maxPriorityFeePerGas: toHex(maxPriorityFeePerGas ?? 0),\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n isBridgeTx,\n approval,\n resetApproval,\n trade,\n quoteResponse: {\n quote: {\n feeData: { txFee },\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n sentAmount,\n toTokenAmount,\n },\n requireApproval = false,\n isDelegatedAccount = false,\n}: {\n messenger: BridgeStatusControllerMessenger;\n isBridgeTx: boolean;\n trade: TxData;\n quoteResponse: Omit<QuoteResponse, 'approval' | 'trade'> &\n Partial<QuoteMetadata>;\n approval?: TxData;\n resetApproval?: TxData;\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const isGasless = gasIncluded || gasIncluded7702;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n // Gas fields should be omitted only when gas is sponsored via 7702\n const skipGasFields = gasIncluded7702 === true;\n // Enable 7702 batching when the quote includes gasless 7702 support,\n // or when the account is already delegated (to avoid the in-flight\n // transaction limit for delegated accounts)\n let disable7702 = !skipGasFields && !isDelegatedAccount;\n\n // For gasless transactions with STX/sendBundle we keep disabling 7702.\n if (gasIncluded && !gasIncluded7702) {\n disable7702 = true;\n }\n\n const transactions: TransactionBatchSingleRequest[] = [];\n if (resetApproval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n resetApproval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, resetApproval, gasFees),\n });\n }\n if (approval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n approval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, approval, gasFees),\n });\n }\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n trade,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n params: toBatchTxParams(skipGasFields, trade, gasFees),\n assetsFiatValues: {\n sending: sentAmount?.valueInCurrency?.toString(),\n receiving: toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n const transactionParams: Parameters<\n TransactionController['addTransactionBatch']\n >[0] = {\n disable7702,\n isGasFeeIncluded: Boolean(gasIncluded7702),\n isGasFeeSponsored: Boolean(gasSponsored),\n networkClientId,\n requireApproval,\n origin: 'metamask',\n from: trade.from as Hex,\n transactions,\n };\n\n return transactionParams;\n};\n\nexport const findAndUpdateTransactionsInBatch = ({\n messenger,\n batchId,\n txDataByType,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n txDataByType: { [key in TransactionType]?: string };\n}) => {\n const txs = getTransactions(messenger);\n const txBatch: {\n approvalMeta?: TransactionMeta;\n tradeMeta?: TransactionMeta;\n } = {\n approvalMeta: undefined,\n tradeMeta: undefined,\n };\n\n // This is a workaround to update the tx type after the tx is signed\n // TODO: remove this once the tx type for batch txs is preserved in the tx controller\n const txEntries = Object.entries(txDataByType) as [TransactionType, string][];\n txEntries.forEach(([txType, txData]) => {\n // Skip types not present in the batch (e.g. swap entry is undefined for bridge txs)\n if (txData === undefined) {\n return;\n }\n\n // Find transaction by batchId and either matching data or delegation characteristics\n const txMeta = txs.find((tx: TransactionMeta) => {\n if (tx.batchId !== batchId) {\n return false;\n }\n\n // For 7702 delegated transactions, check for delegation-specific fields\n // These transactions might have authorizationList or delegationAddress\n const is7702Transaction =\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress);\n\n if (is7702Transaction) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(txType) && tx.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(txType) && tx.txParams.data === txData) {\n return true;\n }\n }\n\n // Default matching logic for non-7702 transactions\n return tx.txParams.data === txData;\n });\n\n if (txMeta) {\n const updatedTx = { ...txMeta, type: txType };\n updateTransaction(\n messenger,\n txMeta,\n { type: txType },\n `Update tx type to ${txType}`,\n );\n const txTypes = [\n TransactionType.bridgeApproval,\n TransactionType.swapApproval,\n ] as readonly string[];\n txBatch[txTypes.includes(txType) ? 'approvalMeta' : 'tradeMeta'] =\n updatedTx;\n }\n });\n\n return txBatch;\n};\n\nexport const addTransactionBatch = async (\n messenger: BridgeStatusControllerMessenger,\n addTransactionBatchFn: TransactionController['addTransactionBatch'],\n ...args: Parameters<TransactionController['addTransactionBatch']>\n) => {\n const txDataByType = {\n [TransactionType.bridgeApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridgeApproval,\n )?.params.data,\n [TransactionType.swapApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swapApproval,\n )?.params.data,\n [TransactionType.bridge]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridge,\n )?.params.data,\n [TransactionType.swap]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swap,\n )?.params.data,\n };\n\n const { batchId } = await addTransactionBatchFn(...args);\n\n const { approvalMeta, tradeMeta } = findAndUpdateTransactionsInBatch({\n messenger,\n batchId,\n txDataByType,\n });\n\n if (!tradeMeta) {\n throw new Error(\n 'Failed to update cross-chain swap transaction batch: tradeMeta not found',\n );\n }\n\n return { approvalMeta, tradeMeta };\n};\n\n// TODO rename\nconst getGasFeesForSubmission = async (\n messenger: BridgeStatusControllerMessenger,\n transactionParams: TransactionParams,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n): Promise<{\n maxFeePerGas?: string; // Hex\n maxPriorityFeePerGas?: string; // Hex\n gas?: Hex;\n}> => {\n const { gas } = transactionParams;\n // If txFee is provided (gasIncluded case), use the quote's gas fees\n // Convert to hex since txFee values from the quote are decimal strings\n if (txFee) {\n return {\n maxFeePerGas: toHex(txFee.maxFeePerGas),\n maxPriorityFeePerGas: toHex(txFee.maxPriorityFeePerGas),\n gas: gas ? toHex(gas) : undefined,\n };\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n chainId,\n networkClientId,\n },\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: gas ? toHex(gas) : undefined,\n };\n};\n\n/**\n * Submits an EVM transaction to the TransactionController\n *\n * @param params - The parameters for the transaction\n * @param params.transactionType - The type of transaction to submit\n * @param params.trade - The trade data to confirm\n * @param params.requireApproval - Whether to require approval for the transaction\n * @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)\n * @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote\n * @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote\n * @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)\n * @param params.messenger - The messenger to use for the transaction\n * @returns The transaction meta\n */\nexport const submitEvmTransaction = async ({\n messenger,\n trade,\n transactionType,\n requireApproval = false,\n txFee,\n // Use provided actionId (for pre-submission history) or generate one\n actionId = generateActionId(),\n}: {\n messenger: BridgeStatusControllerMessenger;\n transactionType: TransactionType;\n trade: TxData;\n requireApproval?: boolean;\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string };\n actionId?: string;\n}): Promise<TransactionMeta> => {\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const requestOptions = {\n actionId,\n networkClientId,\n requireApproval,\n type: transactionType,\n origin: 'metamask',\n };\n // Exclude gasLimit from trade to avoid type issues (it can be null)\n const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;\n\n const transactionParams: Parameters<\n TransactionController['addTransaction']\n >[0] = {\n ...tradeWithoutGasLimit,\n chainId: hexChainId,\n // Only add gasLimit and gas if they're valid (not undefined/null/zero)\n ...(tradeGasLimit &&\n tradeGasLimit !== 0 && {\n gasLimit: tradeGasLimit.toString(),\n gas: tradeGasLimit.toString(),\n }),\n };\n const transactionParamsWithMaxGas: TransactionParams = {\n ...transactionParams,\n ...(await getGasFeesForSubmission(\n messenger,\n transactionParams,\n networkClientId,\n hexChainId,\n txFee,\n )),\n };\n\n return await addTransaction(\n messenger,\n transactionParamsWithMaxGas,\n requestOptions,\n );\n};\n"]}
1
+ {"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,6BAA6B,EAC9B,oCAAoC;AAMrC,OAAO,EAAE,KAAK,EAAE,mCAAmC;AACnD,OAAO,EACL,iBAAiB,EACjB,eAAe,EAChB,yCAAyC;AAS1C,OAAO,EAAE,mBAAmB,EAAO,wBAAwB;AAC3D,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EAAE,iBAAiB,EAAE,yBAAqB;AAEjD,OAAO,EAAE,mBAAmB,EAAE,uBAAmB;AACjD,OAAO,EAAE,2BAA2B,EAAE,sBAAkB;AAExD,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,EAAE,CAC7C,IAAI,KAAK,eAAe,CAAC,cAAc;IACvC,IAAI,KAAK,eAAe,CAAC,YAAY,CAAC;AACxC,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE,CAC1C,IAAI,KAAK,eAAe,CAAC,MAAM,IAAI,IAAI,KAAK,eAAe,CAAC,IAAI,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqB,EAAE,EAAE,CACtD,SAAS,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAA0C,EAC1C,IAA4D,EACO,EAAE;IACrE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,SAAS,CAAC,IAAI,CACxC,sCAAsC,EACtC,IAAI,CACL,CAAC;IACF,IACE,6BAA6B,IAAI,SAAS;QAC1C,OAAO,SAAS,CAAC,6BAA6B,CAAC,KAAK,QAAQ;QAC5D,cAAc,IAAI,SAAS,CAAC,6BAA6B,CAAC;QAC1D,sBAAsB,IAAI,SAAS,CAAC,6BA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C;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,2BAA2B,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE3E,MAAM,cAAc,GAAG;QACrB,QAAQ;QACR,eAAe;QACf,eAAe;QACf,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI;KACjB,CAAC;IACF,oEAAoE;IACpE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAEnE,MAAM,iBAAiB,GAEhB;QACL,GAAG,oBAAoB;QACvB,OAAO,EAAE,UAAU;QACnB,uEAAuE;QACvE,GAAG,CAAC,aAAa;YACf,aAAa,KAAK,CAAC,IAAI;YACrB,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE;YAClC,GAAG,EAAE,aAAa,CAAC,QAAQ,EAAE;SAC9B,CAAC;KACL,CAAC;IACF,MAAM,2BAA2B,GAAsB;QACrD,GAAG,iBAAiB;QACpB,GAAG,CAAC,MAAM,uBAAuB,CAC/B,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,KAAK,CACN,CAAC;KACH,CAAC;IAEF,OAAO,MAAM,cAAc,CACzB,SAAS,EACT,2BAA2B,EAC3B,cAAc,CACf,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n} from '@metamask/bridge-controller';\nimport type {\n QuoteMetadata,\n QuoteResponse,\n TxData,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\nimport { getAccountByAddress } from './accounts';\nimport { getNetworkClientIdByChainId } from './network';\n\nconst isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nconst isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n): Promise<{ maxFeePerGas?: string; maxPriorityFeePerGas?: string }> => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n if (\n BRIDGE_PREFERRED_GAS_ESTIMATE in estimates &&\n typeof estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] === 'object' &&\n 'maxFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE] &&\n 'maxPriorityFeePerGas' in estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]\n ) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n return {};\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param estimateGasFeeParams - The parameters for the {@link TransactionController.estimateGasFee} method\n \n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n estimateGasFeeParams: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const estimatedBaseFee =\n 'estimatedBaseFee' in gasFeeEstimates\n ? gasFeeEstimates.estimatedBaseFee\n : '0';\n\n // Get transaction's 1559 gas fee estimates\n const { maxFeePerGas, maxPriorityFeePerGas } = await getGasFeeEstimates(\n messenger,\n estimateGasFeeParams,\n );\n\n /**\n * @deprecated this is unused\n */\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n networkClientId,\n chainId,\n },\n );\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n isInternal: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponse['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toBatchTxParams = (\n skipGasFields: boolean,\n { chainId, gasLimit, ...trade }: TxData,\n {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas,\n }: { maxFeePerGas?: string; maxPriorityFeePerGas?: string; gas?: string },\n): BatchTransactionParams => {\n const params = {\n ...trade,\n data: trade.data as Hex,\n to: trade.to as Hex,\n value: trade.value as Hex,\n };\n if (skipGasFields) {\n return params;\n }\n\n return {\n ...params,\n gas: toHex(gas ?? 0),\n maxFeePerGas: toHex(maxFeePerGas ?? 0),\n maxPriorityFeePerGas: toHex(maxPriorityFeePerGas ?? 0),\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n isBridgeTx,\n approval,\n resetApproval,\n trade,\n quoteResponse: {\n quote: {\n feeData: { txFee },\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n sentAmount,\n toTokenAmount,\n },\n requireApproval = false,\n isDelegatedAccount = false,\n}: {\n messenger: BridgeStatusControllerMessenger;\n isBridgeTx: boolean;\n trade: TxData;\n quoteResponse: Omit<QuoteResponse, 'approval' | 'trade'> &\n Partial<QuoteMetadata>;\n approval?: TxData;\n resetApproval?: TxData;\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const isGasless = gasIncluded || gasIncluded7702;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n // Gas fields should be omitted only when gas is sponsored via 7702\n const skipGasFields = gasIncluded7702 === true;\n // Enable 7702 batching when the quote includes gasless 7702 support,\n // or when the account is already delegated (to avoid the in-flight\n // transaction limit for delegated accounts)\n let disable7702 = !skipGasFields && !isDelegatedAccount;\n\n // For gasless transactions with STX/sendBundle we keep disabling 7702.\n if (gasIncluded && !gasIncluded7702) {\n disable7702 = true;\n }\n\n const transactions: TransactionBatchSingleRequest[] = [];\n if (resetApproval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n resetApproval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, resetApproval, gasFees),\n });\n }\n if (approval) {\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n approval,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval,\n params: toBatchTxParams(skipGasFields, approval, gasFees),\n });\n }\n const gasFees = await calculateGasFees(\n skipGasFields,\n messenger,\n trade,\n networkClientId,\n hexChainId,\n isGasless ? txFee : undefined,\n );\n transactions.push({\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n params: toBatchTxParams(skipGasFields, trade, gasFees),\n assetsFiatValues: {\n sending: sentAmount?.valueInCurrency?.toString(),\n receiving: toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n const transactionParams: Parameters<\n TransactionController['addTransactionBatch']\n >[0] = {\n disable7702,\n isGasFeeIncluded: Boolean(gasIncluded7702),\n isGasFeeSponsored: Boolean(gasSponsored),\n networkClientId,\n requireApproval,\n origin: 'metamask',\n isInternal: true,\n from: trade.from as Hex,\n transactions,\n };\n\n return transactionParams;\n};\n\nexport const findAndUpdateTransactionsInBatch = ({\n messenger,\n batchId,\n txDataByType,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n txDataByType: { [key in TransactionType]?: string };\n}) => {\n const txs = getTransactions(messenger);\n const txBatch: {\n approvalMeta?: TransactionMeta;\n tradeMeta?: TransactionMeta;\n } = {\n approvalMeta: undefined,\n tradeMeta: undefined,\n };\n\n // This is a workaround to update the tx type after the tx is signed\n // TODO: remove this once the tx type for batch txs is preserved in the tx controller\n const txEntries = Object.entries(txDataByType) as [TransactionType, string][];\n txEntries.forEach(([txType, txData]) => {\n // Skip types not present in the batch (e.g. swap entry is undefined for bridge txs)\n if (txData === undefined) {\n return;\n }\n\n // Find transaction by batchId and either matching data or delegation characteristics\n const txMeta = txs.find((tx: TransactionMeta) => {\n if (tx.batchId !== batchId) {\n return false;\n }\n\n // For 7702 delegated transactions, check for delegation-specific fields\n // These transactions might have authorizationList or delegationAddress\n const is7702Transaction =\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress);\n\n if (is7702Transaction) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(txType) && tx.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(txType) && tx.txParams.data === txData) {\n return true;\n }\n }\n\n // Default matching logic for non-7702 transactions\n return tx.txParams.data === txData;\n });\n\n if (txMeta) {\n const updatedTx = { ...txMeta, type: txType };\n updateTransaction(\n messenger,\n txMeta,\n { type: txType },\n `Update tx type to ${txType}`,\n );\n const txTypes = [\n TransactionType.bridgeApproval,\n TransactionType.swapApproval,\n ] as readonly string[];\n txBatch[txTypes.includes(txType) ? 'approvalMeta' : 'tradeMeta'] =\n updatedTx;\n }\n });\n\n return txBatch;\n};\n\nexport const addTransactionBatch = async (\n messenger: BridgeStatusControllerMessenger,\n addTransactionBatchFn: TransactionController['addTransactionBatch'],\n ...args: Parameters<TransactionController['addTransactionBatch']>\n) => {\n const txDataByType = {\n [TransactionType.bridgeApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridgeApproval,\n )?.params.data,\n [TransactionType.swapApproval]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swapApproval,\n )?.params.data,\n [TransactionType.bridge]: args[0].transactions.find(\n ({ type }) => type === TransactionType.bridge,\n )?.params.data,\n [TransactionType.swap]: args[0].transactions.find(\n ({ type }) => type === TransactionType.swap,\n )?.params.data,\n };\n\n const { batchId } = await addTransactionBatchFn(...args);\n\n const { approvalMeta, tradeMeta } = findAndUpdateTransactionsInBatch({\n messenger,\n batchId,\n txDataByType,\n });\n\n if (!tradeMeta) {\n throw new Error(\n 'Failed to update cross-chain swap transaction batch: tradeMeta not found',\n );\n }\n\n return { approvalMeta, tradeMeta };\n};\n\n// TODO rename\nconst getGasFeesForSubmission = async (\n messenger: BridgeStatusControllerMessenger,\n transactionParams: TransactionParams,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n): Promise<{\n maxFeePerGas?: string; // Hex\n maxPriorityFeePerGas?: string; // Hex\n gas?: Hex;\n}> => {\n const { gas } = transactionParams;\n // If txFee is provided (gasIncluded case), use the quote's gas fees\n // Convert to hex since txFee values from the quote are decimal strings\n if (txFee) {\n return {\n maxFeePerGas: toHex(txFee.maxFeePerGas),\n maxPriorityFeePerGas: toHex(txFee.maxPriorityFeePerGas),\n gas: gas ? toHex(gas) : undefined,\n };\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = await getTxGasEstimates(\n messenger,\n {\n transactionParams,\n chainId,\n networkClientId,\n },\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: gas ? toHex(gas) : undefined,\n };\n};\n\n/**\n * Submits an EVM transaction to the TransactionController\n *\n * @param params - The parameters for the transaction\n * @param params.transactionType - The type of transaction to submit\n * @param params.trade - The trade data to confirm\n * @param params.requireApproval - Whether to require approval for the transaction\n * @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)\n * @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote\n * @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote\n * @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)\n * @param params.messenger - The messenger to use for the transaction\n * @returns The transaction meta\n */\nexport const submitEvmTransaction = async ({\n messenger,\n trade,\n transactionType,\n requireApproval = false,\n txFee,\n // Use provided actionId (for pre-submission history) or generate one\n actionId = generateActionId(),\n}: {\n messenger: BridgeStatusControllerMessenger;\n transactionType: TransactionType;\n trade: TxData;\n requireApproval?: boolean;\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string };\n actionId?: string;\n}): Promise<TransactionMeta> => {\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const requestOptions = {\n actionId,\n networkClientId,\n requireApproval,\n type: transactionType,\n origin: 'metamask',\n isInternal: true,\n };\n // Exclude gasLimit from trade to avoid type issues (it can be null)\n const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;\n\n const transactionParams: Parameters<\n TransactionController['addTransaction']\n >[0] = {\n ...tradeWithoutGasLimit,\n chainId: hexChainId,\n // Only add gasLimit and gas if they're valid (not undefined/null/zero)\n ...(tradeGasLimit &&\n tradeGasLimit !== 0 && {\n gasLimit: tradeGasLimit.toString(),\n gas: tradeGasLimit.toString(),\n }),\n };\n const transactionParamsWithMaxGas: TransactionParams = {\n ...transactionParams,\n ...(await getGasFeesForSubmission(\n messenger,\n transactionParams,\n networkClientId,\n hexChainId,\n txFee,\n )),\n };\n\n return await addTransaction(\n messenger,\n transactionParamsWithMaxGas,\n requestOptions,\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/bridge-status-controller",
3
- "version": "71.1.3",
3
+ "version": "71.2.0",
4
4
  "description": "Manages bridge-related status fetching functionality for MetaMask",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -52,19 +52,19 @@
52
52
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
53
53
  },
54
54
  "dependencies": {
55
- "@metamask/accounts-controller": "^38.1.0",
55
+ "@metamask/accounts-controller": "^38.1.1",
56
56
  "@metamask/base-controller": "^9.1.0",
57
- "@metamask/bridge-controller": "^72.0.3",
58
- "@metamask/controller-utils": "^12.0.0",
59
- "@metamask/gas-fee-controller": "^26.2.1",
57
+ "@metamask/bridge-controller": "^72.0.4",
58
+ "@metamask/controller-utils": "^12.1.0",
59
+ "@metamask/gas-fee-controller": "^26.2.2",
60
60
  "@metamask/keyring-controller": "^25.5.0",
61
61
  "@metamask/messenger": "^1.2.0",
62
- "@metamask/network-controller": "^31.1.0",
63
- "@metamask/polling-controller": "^16.0.5",
64
- "@metamask/profile-sync-controller": "^28.0.2",
62
+ "@metamask/network-controller": "^32.0.0",
63
+ "@metamask/polling-controller": "^16.0.6",
64
+ "@metamask/profile-sync-controller": "^28.1.0",
65
65
  "@metamask/snaps-controllers": "^19.0.0",
66
66
  "@metamask/superstruct": "^3.1.0",
67
- "@metamask/transaction-controller": "^65.3.0",
67
+ "@metamask/transaction-controller": "^66.0.0",
68
68
  "@metamask/utils": "^11.9.0",
69
69
  "bignumber.js": "^9.1.2",
70
70
  "uuid": "^8.3.2"