Skip to content

Extends GasFeePoller to update gas properties for unapproved transaction batches #5950

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

Open
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Jun 10, 2025

Explanation

This PR extends the GasFeePoller to track/update gas properties for unapproved transactionBatches.

Changes

The GasFeePoller now:

  • Detects unapproved transactionBatches via #getUnapprovedTransactionBatches.
  • Fetches gas estimates using DefaultGasFeeFlow.
  • Emits transaction-batch-updated events with updated gasFeeEstimates.

Updates are applied to the TransactionBatchMeta for each batch, mirroring the behaviour already in place for single transactions.
This enhancement ensures that unapproved transaction batches receive timely gas updates similar to individual transactions, improving consistency across transaction types.

References

Fixes https://github.com/MetaMask/MetaMask-planning/issues/5090

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

vinistevam and others added 30 commits May 13, 2025 17:18
…:MetaMask/core into feat/add-batch-transaction-approval-type
@vinistevam vinistevam changed the title Extends GasFeePoller to update gas properties for unapproved transactionBatches Extends GasFeePoller to update gas properties for unapproved transaction batches Jun 10, 2025
@vinistevam vinistevam marked this pull request as ready for review June 10, 2025 12:58
@vinistevam vinistevam requested review from a team as code owners June 10, 2025 12:58
Base automatically changed from feat/add-estimate-gas-fee-batch-tx to main June 11, 2025 13:25
requireApproval: false,
},
);
const txMeta = { ...txBatchMeta, txParams: { ...params, from } };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, is it confusing to have this and transactionMeta below? Maybe we call this transactionMetaForGasEstimates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, done.

}

log(
'Found unapproved batch transactions',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, transaction batches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

this.#updateTransactionBatch(batch);
}

#updateTransactionBatch(batch: TransactionBatchMeta) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than accepting the full state which can lead to race conditions in future, could we accept a callback like we do with updateTransactionInternal so we only update specific properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, changed this function to accept a callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants