@metamask/bridge-status-controller 70.0.0 → 70.0.1
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 +14 -1
- package/dist/bridge-status-controller.cjs +48 -172
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +2 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +2 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.cjs +7 -19
- package/dist/bridge-status-controller.intent.cjs.map +1 -1
- package/dist/bridge-status-controller.intent.d.cts +2 -10
- package/dist/bridge-status-controller.intent.d.cts.map +1 -1
- package/dist/bridge-status-controller.intent.d.mts +2 -10
- package/dist/bridge-status-controller.intent.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.mjs +7 -19
- package/dist/bridge-status-controller.intent.mjs.map +1 -1
- package/dist/bridge-status-controller.mjs +51 -175
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +10 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +10 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs +17 -1
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts +8 -2
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts +8 -2
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs +15 -0
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/gas.cjs +1 -58
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +3 -26
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +3 -26
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +0 -55
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/history.cjs +9 -8
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts +3 -2
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts +3 -2
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +9 -8
- package/dist/utils/history.mjs.map +1 -1
- package/dist/utils/intent-api.cjs +26 -26
- package/dist/utils/intent-api.cjs.map +1 -1
- package/dist/utils/intent-api.d.cts +7 -2
- package/dist/utils/intent-api.d.cts.map +1 -1
- package/dist/utils/intent-api.d.mts +7 -2
- package/dist/utils/intent-api.d.mts.map +1 -1
- package/dist/utils/intent-api.mjs +24 -25
- package/dist/utils/intent-api.mjs.map +1 -1
- package/dist/utils/snaps.cjs +5 -5
- package/dist/utils/snaps.cjs.map +1 -1
- package/dist/utils/snaps.d.cts +3 -17
- package/dist/utils/snaps.d.cts.map +1 -1
- package/dist/utils/snaps.d.mts +3 -17
- package/dist/utils/snaps.d.mts.map +1 -1
- package/dist/utils/snaps.mjs +6 -6
- package/dist/utils/snaps.mjs.map +1 -1
- package/dist/utils/transaction.cjs +250 -24
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +91 -169
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +91 -169
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +234 -19
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mEAA0E;AAM1E,iEAAmD;AACnD,6EAG0C;AAO1C,2CAAsD;AAEtD,6CAAiD;AACjD,mCAAyC;AACzC,2CAAwD;AACxD,gDAAiD;AAG1C,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,CAA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C,wCAAe,CAAC,cAAc,EAAE,wCAAe,CAAC,YAAY,CAAC,CAAC,QAAQ,CACrE,MAAyB,CAC1B;gBACC,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,WAAW,CAChB,GAAG,SAAS,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAjFW,QAAA,gCAAgC,oCAiF3C","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { ChainId, formatChainIdToHex } 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 TransactionController,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { TransactionBatchSingleRequest } from '@metamask/transaction-controller';\nimport { createProjectLogger } from '@metamask/utils';\n\nimport { getAccountByAddress } from './accounts';\nimport { calculateGasFees } from './gas';\nimport { getNetworkClientIdByChainId } from './network';\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\nexport const getStatusRequestParams = (quoteResponse: QuoteResponse) => {\n return {\n bridgeId: quoteResponse.quote.bridgeId,\n bridge: quoteResponse.quote.bridges[0],\n srcChainId: quoteResponse.quote.srcChainId,\n destChainId: quoteResponse.quote.destChainId,\n quote: quoteResponse.quote,\n refuel: Boolean(quoteResponse.quote.refuel),\n };\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\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 { transactions } = messenger.call('TransactionController:getState');\n const meta = transactions.find((tx: TransactionMeta) => tx.id === 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 `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\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 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 const disable7702 = !skipGasFields && !isDelegatedAccount;\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 `0x${string}`,\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 = messenger.call('TransactionController:getState').transactions;\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 Object.entries(txDataByType).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 (\n (txType === TransactionType.swap ||\n txType === TransactionType.bridge) &&\n tx.type === TransactionType.batch\n ) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (\n (txType === TransactionType.swapApproval ||\n txType === TransactionType.bridgeApproval) &&\n tx.txParams.data === txData\n ) {\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 as TransactionType };\n messenger.call(\n 'TransactionController:updateTransaction',\n updatedTx,\n `Update tx type to ${txType}`,\n );\n txBatch[\n [TransactionType.bridgeApproval, TransactionType.swapApproval].includes(\n txType as TransactionType,\n )\n ? 'approvalMeta'\n : 'tradeMeta'\n ] = updatedTx;\n }\n });\n\n return txBatch;\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,6CAAiD;AACjD,2CAAwD;AACxD,gDAAiD;AAG1C,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,iDAA6B,IAAI,SAAS;QAC1C,OAAO,SAAS,CAAC,iDAA6B,CAAC,KAAK,QAAQ;QAC5D,cAAc,IAAI,SAAS,CAAC,iDAA6B,CAAC;QAC1D,sBAAsB,IAAI,SAAS,CAAC,iDAA6B,CAAC,EAClE,CAAC;QACD,OAAO,SAAS,CAAC,iDAA6B,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAjBW,QAAA,kBAAkB,sBAiB7B;AAEF;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACpC,SAA0C,EAC1C,oBAA4E,EAC5E,EAAE;IACF,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACxE,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\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 { getAccountByAddress } from './accounts';\nimport { getNetworkClientIdByChainId } from './network';\nimport { APPROVAL_DELAY_MS } from '../constants';\nimport type { BridgeStatusControllerMessenger } from '../types';\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 === txHash,\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 (\n (txType === TransactionType.swap ||\n txType === TransactionType.bridge) &&\n tx.type === TransactionType.batch\n ) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (\n (txType === TransactionType.swapApproval ||\n txType === TransactionType.bridgeApproval) &&\n tx.txParams.data === txData\n ) {\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,176 +1,57 @@
|
|
|
1
1
|
import type { QuoteMetadata, QuoteResponse, TxData } from "@metamask/bridge-controller";
|
|
2
2
|
import { TransactionType } from "@metamask/transaction-controller";
|
|
3
|
-
import type { BatchTransactionParams, TransactionMeta } from "@metamask/transaction-controller";
|
|
3
|
+
import type { BatchTransactionParams, TransactionController, TransactionMeta, TransactionParams } from "@metamask/transaction-controller";
|
|
4
|
+
import { Hex } from "@metamask/utils";
|
|
5
|
+
import { BigNumber } from "bignumber.js";
|
|
4
6
|
import type { BridgeStatusControllerMessenger } from "../types.cjs";
|
|
7
|
+
export declare const getGasFeeEstimates: (messenger: BridgeStatusControllerMessenger, args: Parameters<TransactionController['estimateGasFee']>[0]) => Promise<{
|
|
8
|
+
maxFeePerGas?: string;
|
|
9
|
+
maxPriorityFeePerGas?: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the gas fee estimates for a transaction
|
|
13
|
+
*
|
|
14
|
+
* @param messenger - The messenger for the gas fee estimates
|
|
15
|
+
* @param estimateGasFeeParams - The parameters for the {@link TransactionController.estimateGasFee} method
|
|
16
|
+
|
|
17
|
+
* @returns The gas fee estimates for the transaction
|
|
18
|
+
*/
|
|
19
|
+
export declare const getTxGasEstimates: (messenger: BridgeStatusControllerMessenger, estimateGasFeeParams: Parameters<TransactionController['estimateGasFee']>[0]) => Promise<{
|
|
20
|
+
baseAndPriorityFeePerGas: BigNumber | undefined;
|
|
21
|
+
maxFeePerGas: string | undefined;
|
|
22
|
+
maxPriorityFeePerGas: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const calculateGasFees: (skipGasFields: boolean, messenger: BridgeStatusControllerMessenger, { chainId: _, gasLimit, ...trade }: TxData, networkClientId: string, chainId: Hex, txFee?: {
|
|
25
|
+
maxFeePerGas: string;
|
|
26
|
+
maxPriorityFeePerGas: string;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
maxFeePerGas?: undefined;
|
|
29
|
+
maxPriorityFeePerGas?: undefined;
|
|
30
|
+
gas?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
gas: string | undefined;
|
|
33
|
+
maxFeePerGas: string;
|
|
34
|
+
maxPriorityFeePerGas: string;
|
|
35
|
+
} | {
|
|
36
|
+
maxFeePerGas: string | undefined;
|
|
37
|
+
maxPriorityFeePerGas: string | undefined;
|
|
38
|
+
gas: `0x${string}`;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const getTransactions: (messenger: BridgeStatusControllerMessenger) => TransactionMeta[];
|
|
41
|
+
export declare const getTransactionMetaById: (messenger: BridgeStatusControllerMessenger, txId?: string) => TransactionMeta | undefined;
|
|
42
|
+
export declare const getTransactionMetaByHash: (messenger: BridgeStatusControllerMessenger, txHash?: string) => TransactionMeta | undefined;
|
|
43
|
+
export declare const updateTransaction: (messenger: BridgeStatusControllerMessenger, txMeta: TransactionMeta, txMetaUpdates: Partial<TransactionMeta>, note: string) => void;
|
|
44
|
+
export declare const checkIsDelegatedAccount: (messenger: BridgeStatusControllerMessenger, fromAddress: Hex, chainIds: Hex[]) => Promise<boolean>;
|
|
45
|
+
export declare const addTransaction: (messenger: BridgeStatusControllerMessenger, txParams: TransactionParams, options: import("@metamask/transaction-controller").AddTransactionOptions) => Promise<TransactionMeta>;
|
|
5
46
|
export declare const generateActionId: () => string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
srcAsset: {
|
|
15
|
-
symbol: string;
|
|
16
|
-
chainId: number;
|
|
17
|
-
address: string;
|
|
18
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
19
|
-
name: string;
|
|
20
|
-
decimals: number;
|
|
21
|
-
icon?: string | null | undefined;
|
|
22
|
-
iconUrl?: string | null | undefined;
|
|
23
|
-
};
|
|
24
|
-
destAsset: {
|
|
25
|
-
symbol: string;
|
|
26
|
-
chainId: number;
|
|
27
|
-
address: string;
|
|
28
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
29
|
-
name: string;
|
|
30
|
-
decimals: number;
|
|
31
|
-
icon?: string | null | undefined;
|
|
32
|
-
iconUrl?: string | null | undefined;
|
|
33
|
-
};
|
|
34
|
-
requestId: string;
|
|
35
|
-
srcTokenAmount: string;
|
|
36
|
-
destTokenAmount: string;
|
|
37
|
-
minDestTokenAmount: string;
|
|
38
|
-
feeData: {
|
|
39
|
-
metabridge: {
|
|
40
|
-
amount: string;
|
|
41
|
-
asset: {
|
|
42
|
-
symbol: string;
|
|
43
|
-
chainId: number;
|
|
44
|
-
address: string;
|
|
45
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
46
|
-
name: string;
|
|
47
|
-
decimals: number;
|
|
48
|
-
icon?: string | null | undefined;
|
|
49
|
-
iconUrl?: string | null | undefined;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
txFee?: ({
|
|
53
|
-
amount: string;
|
|
54
|
-
asset: {
|
|
55
|
-
symbol: string;
|
|
56
|
-
chainId: number;
|
|
57
|
-
address: string;
|
|
58
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
59
|
-
name: string;
|
|
60
|
-
decimals: number;
|
|
61
|
-
icon?: string | null | undefined;
|
|
62
|
-
iconUrl?: string | null | undefined;
|
|
63
|
-
};
|
|
64
|
-
} & {
|
|
65
|
-
maxFeePerGas: string;
|
|
66
|
-
maxPriorityFeePerGas: string;
|
|
67
|
-
}) | undefined;
|
|
68
|
-
};
|
|
69
|
-
bridgeId: string;
|
|
70
|
-
bridges: string[];
|
|
71
|
-
steps: {
|
|
72
|
-
action: import("@metamask/bridge-controller").ActionTypes;
|
|
73
|
-
srcChainId: number;
|
|
74
|
-
srcAsset: {
|
|
75
|
-
symbol: string;
|
|
76
|
-
chainId: number;
|
|
77
|
-
address: string;
|
|
78
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
79
|
-
name: string;
|
|
80
|
-
decimals: number;
|
|
81
|
-
icon?: string | null | undefined;
|
|
82
|
-
iconUrl?: string | null | undefined;
|
|
83
|
-
};
|
|
84
|
-
destAsset: {
|
|
85
|
-
symbol: string;
|
|
86
|
-
chainId: number;
|
|
87
|
-
address: string;
|
|
88
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
89
|
-
name: string;
|
|
90
|
-
decimals: number;
|
|
91
|
-
icon?: string | null | undefined;
|
|
92
|
-
iconUrl?: string | null | undefined;
|
|
93
|
-
};
|
|
94
|
-
srcAmount: string;
|
|
95
|
-
destAmount: string;
|
|
96
|
-
protocol: {
|
|
97
|
-
name: string;
|
|
98
|
-
icon?: string | undefined;
|
|
99
|
-
displayName?: string | undefined;
|
|
100
|
-
};
|
|
101
|
-
destChainId?: number | undefined;
|
|
102
|
-
}[];
|
|
103
|
-
refuel?: {
|
|
104
|
-
action: import("@metamask/bridge-controller").ActionTypes;
|
|
105
|
-
srcChainId: number;
|
|
106
|
-
srcAsset: {
|
|
107
|
-
symbol: string;
|
|
108
|
-
chainId: number;
|
|
109
|
-
address: string;
|
|
110
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
111
|
-
name: string;
|
|
112
|
-
decimals: number;
|
|
113
|
-
icon?: string | null | undefined;
|
|
114
|
-
iconUrl?: string | null | undefined;
|
|
115
|
-
};
|
|
116
|
-
destAsset: {
|
|
117
|
-
symbol: string;
|
|
118
|
-
chainId: number;
|
|
119
|
-
address: string;
|
|
120
|
-
assetId: `${string}:${string}/${string}:${string}`;
|
|
121
|
-
name: string;
|
|
122
|
-
decimals: number;
|
|
123
|
-
icon?: string | null | undefined;
|
|
124
|
-
iconUrl?: string | null | undefined;
|
|
125
|
-
};
|
|
126
|
-
srcAmount: string;
|
|
127
|
-
destAmount: string;
|
|
128
|
-
protocol: {
|
|
129
|
-
name: string;
|
|
130
|
-
icon?: string | undefined;
|
|
131
|
-
displayName?: string | undefined;
|
|
132
|
-
};
|
|
133
|
-
destChainId?: number | undefined;
|
|
134
|
-
} | undefined;
|
|
135
|
-
gasIncluded?: boolean | undefined;
|
|
136
|
-
gasIncluded7702?: boolean | undefined;
|
|
137
|
-
priceData?: {
|
|
138
|
-
totalFromAmountUsd?: string | undefined;
|
|
139
|
-
totalToAmountUsd?: string | undefined;
|
|
140
|
-
priceImpact?: string | undefined;
|
|
141
|
-
totalFeeAmountUsd?: string | undefined;
|
|
142
|
-
} | undefined;
|
|
143
|
-
intent?: {
|
|
144
|
-
protocol: string;
|
|
145
|
-
order: {
|
|
146
|
-
sellToken: string;
|
|
147
|
-
buyToken: string;
|
|
148
|
-
validTo: string | number;
|
|
149
|
-
appData: string;
|
|
150
|
-
appDataHash: string;
|
|
151
|
-
feeAmount: string;
|
|
152
|
-
kind: "sell" | "buy";
|
|
153
|
-
partiallyFillable: boolean;
|
|
154
|
-
receiver?: string | undefined;
|
|
155
|
-
sellAmount?: string | undefined;
|
|
156
|
-
buyAmount?: string | undefined;
|
|
157
|
-
from?: string | undefined;
|
|
158
|
-
};
|
|
159
|
-
typedData: {
|
|
160
|
-
types: Record<string, {
|
|
161
|
-
name: string;
|
|
162
|
-
type: string;
|
|
163
|
-
}[]>;
|
|
164
|
-
primaryType: string;
|
|
165
|
-
domain: Record<string, any>;
|
|
166
|
-
message: Record<string, any>;
|
|
167
|
-
};
|
|
168
|
-
settlementContract?: string | undefined;
|
|
169
|
-
} | undefined;
|
|
170
|
-
gasSponsored?: boolean | undefined;
|
|
171
|
-
};
|
|
172
|
-
refuel: boolean;
|
|
173
|
-
};
|
|
47
|
+
/**
|
|
48
|
+
* Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI
|
|
49
|
+
*
|
|
50
|
+
* @param messenger - The messenger to use for the transaction
|
|
51
|
+
* @param args - The arguments for the transaction
|
|
52
|
+
* @returns The transaction meta
|
|
53
|
+
*/
|
|
54
|
+
export declare const addSyntheticTransaction: (messenger: BridgeStatusControllerMessenger, txParams: TransactionParams, options: import("@metamask/transaction-controller").AddTransactionOptions) => Promise<TransactionMeta>;
|
|
174
55
|
export declare const handleApprovalDelay: (srcChainId: QuoteResponse['quote']['srcChainId']) => Promise<void>;
|
|
175
56
|
/**
|
|
176
57
|
* Adds a delay for hardware wallet transactions on mobile to fix an issue
|
|
@@ -180,6 +61,17 @@ export declare const handleApprovalDelay: (srcChainId: QuoteResponse['quote']['s
|
|
|
180
61
|
* @param requireApproval - Whether the delay should be applied
|
|
181
62
|
*/
|
|
182
63
|
export declare const handleMobileHardwareWalletDelay: (requireApproval: boolean) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.
|
|
66
|
+
*
|
|
67
|
+
* @deprecated use addTransaction util
|
|
68
|
+
* @param messenger - the BridgeStatusControllerMessenger
|
|
69
|
+
* @param txId - the transaction ID
|
|
70
|
+
* @param options - the options for the timeout and poll
|
|
71
|
+
* @param options.timeoutMs - the timeout in milliseconds
|
|
72
|
+
* @param options.pollMs - the poll interval in milliseconds
|
|
73
|
+
* @returns the transaction meta
|
|
74
|
+
*/
|
|
183
75
|
export declare const waitForTxConfirmation: (messenger: BridgeStatusControllerMessenger, txId: string, { timeoutMs, pollMs, }?: {
|
|
184
76
|
timeoutMs?: number | undefined;
|
|
185
77
|
pollMs?: number | undefined;
|
|
@@ -237,6 +129,7 @@ export declare const findAndUpdateTransactionsInBatch: ({ messenger, batchId, tx
|
|
|
237
129
|
perpsDeposit?: string | undefined;
|
|
238
130
|
perpsDepositAndOrder?: string | undefined;
|
|
239
131
|
perpsRelayDeposit?: string | undefined;
|
|
132
|
+
perpsWithdraw?: string | undefined;
|
|
240
133
|
personal_sign?: string | undefined;
|
|
241
134
|
predictAcrossDeposit?: string | undefined;
|
|
242
135
|
predictBuy?: string | undefined;
|
|
@@ -270,4 +163,33 @@ export declare const findAndUpdateTransactionsInBatch: ({ messenger, batchId, tx
|
|
|
270
163
|
approvalMeta?: TransactionMeta | undefined;
|
|
271
164
|
tradeMeta?: TransactionMeta | undefined;
|
|
272
165
|
};
|
|
166
|
+
export declare const addTransactionBatch: (messenger: BridgeStatusControllerMessenger, addTransactionBatchFn: TransactionController['addTransactionBatch'], request: import("@metamask/transaction-controller").TransactionBatchRequest) => Promise<{
|
|
167
|
+
approvalMeta: TransactionMeta | undefined;
|
|
168
|
+
tradeMeta: TransactionMeta;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* Submits an EVM transaction to the TransactionController
|
|
172
|
+
*
|
|
173
|
+
* @param params - The parameters for the transaction
|
|
174
|
+
* @param params.transactionType - The type of transaction to submit
|
|
175
|
+
* @param params.trade - The trade data to confirm
|
|
176
|
+
* @param params.requireApproval - Whether to require approval for the transaction
|
|
177
|
+
* @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)
|
|
178
|
+
* @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote
|
|
179
|
+
* @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote
|
|
180
|
+
* @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)
|
|
181
|
+
* @param params.messenger - The messenger to use for the transaction
|
|
182
|
+
* @returns The transaction meta
|
|
183
|
+
*/
|
|
184
|
+
export declare const submitEvmTransaction: ({ messenger, trade, transactionType, requireApproval, txFee, actionId, }: {
|
|
185
|
+
messenger: BridgeStatusControllerMessenger;
|
|
186
|
+
transactionType: TransactionType;
|
|
187
|
+
trade: TxData;
|
|
188
|
+
requireApproval?: boolean | undefined;
|
|
189
|
+
txFee?: {
|
|
190
|
+
maxFeePerGas: string;
|
|
191
|
+
maxPriorityFeePerGas: string;
|
|
192
|
+
} | undefined;
|
|
193
|
+
actionId?: string | undefined;
|
|
194
|
+
}) => Promise<TransactionMeta>;
|
|
273
195
|
//# sourceMappingURL=transaction.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"
|
|
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;AAKzC,OAAO,KAAK,EAAE,+BAA+B,EA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