Skip to content

fix: preserve transaction type of batched transactions #6056

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

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Jul 1, 2025

Explanation

When a batch of transactions with specific TransactionType values is submitted (example: bridgeApproval, swap, bridge), the txs get published with generic types like contractInteraction and approve, and the requested types are not preserved

The type values are needed in the swaps and bridge experiences in order to track and display accurate transaction statuses so they need to be propagated

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 1, 2025 20:53
cursor[bot]

This comment was marked as outdated.

bfullam
bfullam previously approved these changes Jul 1, 2025
@bfullam
Copy link
Contributor

bfullam commented Jul 2, 2025

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Jul 2, 2025

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "0.4.0-preview-9cc92e6f",
  "@metamask-previews/accounts-controller": "31.0.0-preview-9cc92e6f",
  "@metamask-previews/address-book-controller": "6.1.0-preview-9cc92e6f",
  "@metamask-previews/announcement-controller": "7.0.3-preview-9cc92e6f",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/approval-controller": "7.1.3-preview-9cc92e6f",
  "@metamask-previews/assets-controllers": "69.0.0-preview-9cc92e6f",
  "@metamask-previews/base-controller": "8.0.1-preview-9cc92e6f",
  "@metamask-previews/bridge-controller": "34.0.0-preview-9cc92e6f",
  "@metamask-previews/bridge-status-controller": "33.0.0-preview-9cc92e6f",
  "@metamask-previews/build-utils": "3.0.3-preview-9cc92e6f",
  "@metamask-previews/chain-agnostic-permission": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/composable-controller": "11.0.0-preview-9cc92e6f",
  "@metamask-previews/controller-utils": "11.10.0-preview-9cc92e6f",
  "@metamask-previews/delegation-controller": "0.5.0-preview-9cc92e6f",
  "@metamask-previews/earn-controller": "2.0.1-preview-9cc92e6f",
  "@metamask-previews/eip1193-permission-middleware": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/ens-controller": "17.0.0-preview-9cc92e6f",
  "@metamask-previews/error-reporting-service": "2.0.0-preview-9cc92e6f",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-9cc92e6f",
  "@metamask-previews/foundryup": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/gas-fee-controller": "24.0.0-preview-9cc92e6f",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-9cc92e6f",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-9cc92e6f",
  "@metamask-previews/keyring-controller": "22.0.2-preview-9cc92e6f",
  "@metamask-previews/logging-controller": "6.0.4-preview-9cc92e6f",
  "@metamask-previews/message-manager": "12.0.1-preview-9cc92e6f",
  "@metamask-previews/multichain-api-middleware": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/multichain-network-controller": "0.9.0-preview-9cc92e6f",
  "@metamask-previews/multichain-transactions-controller": "3.0.0-preview-9cc92e6f",
  "@metamask-previews/name-controller": "8.0.3-preview-9cc92e6f",
  "@metamask-previews/network-controller": "24.0.0-preview-9cc92e6f",
  "@metamask-previews/notification-services-controller": "12.0.0-preview-9cc92e6f",
  "@metamask-previews/permission-controller": "11.0.6-preview-9cc92e6f",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-9cc92e6f",
  "@metamask-previews/phishing-controller": "12.6.0-preview-9cc92e6f",
  "@metamask-previews/polling-controller": "14.0.0-preview-9cc92e6f",
  "@metamask-previews/preferences-controller": "18.4.0-preview-9cc92e6f",
  "@metamask-previews/profile-sync-controller": "19.0.0-preview-9cc92e6f",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-9cc92e6f",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-9cc92e6f",
  "@metamask-previews/sample-controllers": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/seedless-onboarding-controller": "1.0.0-preview-9cc92e6f",
  "@metamask-previews/selected-network-controller": "23.0.0-preview-9cc92e6f",
  "@metamask-previews/signature-controller": "31.0.0-preview-9cc92e6f",
  "@metamask-previews/token-search-discovery-controller": "3.3.0-preview-9cc92e6f",
  "@metamask-previews/transaction-controller": "58.1.0-preview-9cc92e6f",
  "@metamask-previews/user-operation-controller": "37.0.0-preview-9cc92e6f"
}

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 requested a review from a team as a code owner July 11, 2025 08:39
@micaelae micaelae enabled auto-merge (squash) July 11, 2025 08:40
@@ -1722,6 +1722,9 @@ export type PublishBatchHookTransaction = {

/** Signed transaction data to publish. */
signedTx: Hex;

/** Type of the nested transaction. */
type?: TransactionType;
Copy link
Member

@matthewwalsh0 matthewwalsh0 Jul 14, 2025

Choose a reason for hiding this comment

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

Why do we need the type here?

The intent of providing the id is so the hook can require any specific transaction metadata it needs via the transaction controller state and that reference.

expect(publishBatchHook.mock.calls[0][0].transactions[0].type).toBe(
TransactionType.swap,
);
expect(publishBatchHook.mock.calls[0][0].transactions[1].type).toBe(
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 asserting the hook is called with the type, ideally the hook wouldn't know, and instead we could verify that addTransaction is called multiple times with the correct types?

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.

4 participants