-
-
Notifications
You must be signed in to change notification settings - Fork 242
feat: submit swap STX with addTransactionBatch #6058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Inconsistent Gas Fee Format Causes Processing Errors
The calculateGasFees
function returns the gas
property in an inconsistent format: a decimal string when txFee
is provided, and a hex string otherwise. This causes issues in downstream consumers like toBatchTxParams
, which always applies toHex
to the value, leading to incorrect processing.
packages/bridge-status-controller/src/utils/gas.ts#L58-L98
core/packages/bridge-status-controller/src/utils/gas.ts
Lines 58 to 98 in 8fc679b
export const calculateGasFees = async ( | |
disable7702: boolean, | |
messagingSystem: BridgeStatusControllerMessenger, | |
estimateGasFeeFn: typeof TransactionController.prototype.estimateGasFee, | |
{ chainId: _, gasLimit, ...trade }: TxData, | |
networkClientId: string, | |
chainId: Hex, | |
txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string }, | |
) => { | |
if (!disable7702) { | |
return {}; | |
} | |
if (txFee) { | |
return { ...txFee, gas: gasLimit?.toString() }; | |
} | |
const transactionParams = { | |
...trade, | |
gas: gasLimit?.toString(), | |
data: trade.data as `0x${string}`, | |
to: trade.to as `0x${string}`, | |
value: trade.value as `0x${string}`, | |
}; | |
const { gasFeeEstimates } = messagingSystem.call('GasFeeController:getState'); | |
const { estimates: txGasFeeEstimates } = await estimateGasFeeFn({ | |
transactionParams, | |
chainId, | |
networkClientId, | |
}); | |
const { maxFeePerGas, maxPriorityFeePerGas } = getTxGasEstimates({ | |
networkGasFeeEstimates: gasFeeEstimates, | |
txGasFeeEstimates, | |
}); | |
const maxGasLimit = toHex(transactionParams.gas ?? 0); | |
return { | |
maxFeePerGas, | |
maxPriorityFeePerGas, | |
gas: maxGasLimit, | |
}; | |
}; |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Explanation
Replaces the STX tx submission logic with a call to
TransactionController:addTransactionBatch
. Batched transactions are keyed bybatchId
in txHistory, and have incomplete metadata until they either fail or are confirmedAfter confirmation/failure, the txHistoryItem is re-keyed with txId and missing fields are populated
updateTransaction
is called after tx signing to set the tx type of batched txsReferences
Changelog
Checklist