Skip to content

Conversation

@infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Jan 21, 2026

Description

This PR attempts to look up historyItems by actionId where possible in order to set the provider field properly in analytics on failed txs.

It also fixes an issue where swaps were not being picked up properly on the tx activity list. Also if you notice, there is no more flash of Swaps Transaction anymore before turning into Swap X to Y, this is because we now always have the historyItem data for non-STX txs.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591

Related to MetaMask/core#7696

Manual testing steps

Feature: fix for provider not being set on failed txs

  Scenario: user is trying to swap
    Given user is using a smart account on Polygon and trying to swap an ERC20 that needs an approval

    When user swaps
    Then the swap tx fails

Screenshots/Recordings

Before

After

Screen.Recording.2026-01-22.at.1.21.27.PM.mov
Screenshot 2026-01-22 at 1 23 19 PM

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Jan 21, 2026
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@infiniteflower infiniteflower force-pushed the swaps-3591-provider-not-set branch from a541798 to 4233c7f Compare January 22, 2026 19:37
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeWalletPlatform
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes affect two key areas:

  1. TransactionElement component (app/components/UI/TransactionElement/index.js): Adds support for "unified swap" transactions (swap transactions with bridge history data) to display proper activity titles. Previously only bridge transactions got the special title from getSwapBridgeTxActivityTitle, now swap transactions with bridge history data will also get this title.

  2. useBridgeTxHistoryData hook (app/util/bridge/hooks/useBridgeTxHistoryData.ts): Adds a fallback lookup mechanism - if a bridge history item isn't found by transaction ID, it will also try to find it by actionId. This is important for unified swaps where the history might be keyed differently.

SmokeTrade is selected because:

  • The swap and bridge E2E tests (bridge-action-smoke.spec.ts, swap-action-smoke.spec.ts) verify activity display after swaps/bridges complete
  • bridge-action-smoke.spec.ts specifically checks ActivitiesView.bridgeActivityTitle(destNetwork) which relies on the TransactionElement component
  • The changes directly affect how swap/bridge transactions appear in the activity list

SmokeWalletPlatform is selected because:

  • It tests transaction history display (incoming-transactions.spec.ts)
  • TransactionElement is used in the unified transactions view for displaying EVM transactions
  • Changes to transaction display could affect how transactions appear in the wallet activity view

The changes are additive (new condition for unified swaps, fallback lookup) and include unit tests, making this a medium-risk change. The unit test file adds comprehensive coverage for the new actionId lookup functionality.

View GitHub Actions results

@sonarqubecloud
Copy link

github-merge-queue bot pushed a commit to MetaMask/core that referenced this pull request Jan 22, 2026
…TX where it fails before submission (#7696)

## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

This PR changes the way that `BridgeStatusController`'s history items
are keyed for non-STX to improve status tracking and addressing some
gaps in analytics.

1. Generate a custom `actionId`, key `historyItem` by `actionId` and add
to state BEFORE submitting tx. Previously we would not even have a
`historyItem`, if the the tx failed before being submitted on chain.
2. Pass `actionId` to `TransactionController.addTransaction()` as a part
of the request
3. For txs that actually get submitted on chain, rekey their `actionId`
to their `txMeta.id`
4. On `transactionFailed` use `txMeta.actionId` to identify txs that
failed before actually being submitted on chain and handle metrics

You can test this by using a Smart Account on Polygon and attempting to
do a USDT > POL swap that requires an approval. You should see error `In
flight transaction limit reached for delegate accounts` in the logs.
When you check Mixpanel, the `provider` field should be properly filled
out. A video of the whole process in in
MetaMask/metamask-mobile#25010.

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591
Related to MetaMask/metamask-mobile#25010

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [x] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Improves robustness of transaction tracking and analytics around
pre-submission failures.
> 
> - Use `actionId` as a temporary history key for non-batch EVM
submissions; store `actionId` in `BridgeHistoryItem` and rekey to
`txMeta.id` after successful submission (updating `txMetaId` and
`srcTxHash`)
> - On `TransactionController:transactionFailed`, look up history by
`txMeta.id` then `actionId` to mark failed and track metrics; skip
tracking for `rejected` status
> - Enforce `bridgeTxMeta.id` requirement in
`startPollingForBridgeTxStatus`; exclude items without `txMetaId` from
restart polling
> - Add `getHistoryKey` and `getIntentFromQuote` utils; make
`BridgeHistoryItem.txMetaId` optional and
`StartPollingForBridgeTxStatusArgs.bridgeTxMeta` optional; expand tests
and snapshots accordingly
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
385b6d8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@infiniteflower infiniteflower changed the title Swaps 3591 provider not set fix: Swaps metrics provider not set Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants