Skip to content

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

Merged
merged 25 commits into from
Jul 2, 2025
Merged

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Jul 2, 2025

Explanation

Replaces the STX tx submission logic with a call to TransactionController:addTransactionBatch. Batched transactions are keyed by batchId in txHistory, and have incomplete metadata until they either fail or are confirmed

After 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 txs

References

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@micaelae micaelae requested review from a team as code owners July 2, 2025 01:13
cursor[bot]

This comment was marked as outdated.

@micaelae micaelae changed the title feat: submit STX using addTransactionBatch feat: submit swap STX using addTransactionBatch Jul 2, 2025
@micaelae micaelae changed the title feat: submit swap STX using addTransactionBatch feat: submit swap STX with addTransactionBatch Jul 2, 2025
bfullam
bfullam previously approved these changes Jul 2, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@micaelae micaelae enabled auto-merge (squash) July 2, 2025 21:29
Copy link

@cursor cursor bot left a 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

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,
};
};

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@micaelae micaelae merged commit bfcb274 into main Jul 2, 2025
211 checks passed
@micaelae micaelae deleted the swaps1367-add-stx-batch branch July 2, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants