Skip to content

feat: Default addTransactionBatch to EIP7702 if supported, otherwise use sequential batch #5853

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 7 commits into
base: main
Choose a base branch
from

Conversation

pedronfigueiredo
Copy link
Contributor

Explanation

We previously relied on the useHook property in the request. Instead, the deciding factor is only whether or not EIP 7702 is supported on the chain of the batch transaction.

References

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

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

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/4991 branch 5 times, most recently from 8808f3d to 96e2cdd Compare May 27, 2025 12:32
useHook: true,
disable7702: true,
disableHook: false,
disableSequential: false,
Copy link
Member

Choose a reason for hiding this comment

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

This also has be true as we only want to use smart transactions here, to trigger gas station, and ensure it's atomic.

* Defaults to false.
*/
useHook?: boolean;
/** Whether or not to disable batch transaction processing through an EIP 7702 upgraded account. */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** Whether or not to disable batch transaction processing through an EIP 7702 upgraded account. */
/** Whether to disable batch transaction processing via an EIP-7702 upgraded account. */

/** Whether or not to disable batch transaction processing through an EIP 7702 upgraded account. */
disable7702?: boolean;

/** Whether or not to disable batch transaction processing through a hook. */
Copy link
Member

@matthewwalsh0 matthewwalsh0 May 28, 2025

Choose a reason for hiding this comment

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

Suggested change
/** Whether or not to disable batch transaction processing through a hook. */
/** Whether to disable batch transaction via the `publishBatch` hook. */

/** Whether or not to disable batch transaction processing through a hook. */
disableHook?: boolean;

/** Whether or not to disable batch transaction through sequential batching. */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** Whether or not to disable batch transaction through sequential batching. */
/** Whether to disable batch transaction via sequential transactions. */

if (useHook) {
return await addTransactionBatchWithHook(request);
if (!transactionBatchRequest.disable7702) {
return await addTransactionBatchWith7702(request);
Copy link
Member

Choose a reason for hiding this comment

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

Does this not mean that if 7702 is enabled, but the chain isn't supported, it will throw and not fallback to anything else?

Do we need to use a try catch and only handle the specific chain not supported error?

(!transactionBatchRequest.disableSequential &&
sequentialPublishBatchHook.getHook());
if (!publishBatchHook) {
log(`Can't process batch`, {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log(`Can't process batch`, {
log(`No supported batch methods found`, {

sequentialPublishBatchHook.getHook());
if (!publishBatchHook) {
log(`Can't process batch`, {
disable7702: transactionBatchRequest.disable7702,
Copy link
Member

Choose a reason for hiding this comment

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

Minor, could we destructure these above?


const chainId = getChainId(networkClientId);
const batchId = generateBatchId();
const transactionCount = nestedTransactions.length;
const collectHook = new CollectPublishHook(transactionCount);
try {
if (requireApproval && useHook) {
if (requireApproval) {
Copy link
Member

Choose a reason for hiding this comment

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

Good spot, if we've made it here, we're not doing the 7702 flow.

OGPoyraz
OGPoyraz previously approved these changes Jun 2, 2025
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