Skip to content

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Aug 22, 2025

Explanation

Publishes validation failure events for bridge-api responses. This enables us to proactively monitor validation failure rates and adjust the backend's responses (or the controller validation) as needed.

Sample validation failure payload for getQuotes QuoteValidationFailed

 {
      "action_type": "swapbridge-v1",
      "chain_id_destination": "eip155:1",
      "chain_id_source": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
      "failures": Array [
        "socket|quote.srcAsset.decimals",
        "socket|quote.destAsset.address",
        "lifi|quote.srcAsset.decimals",
      ],
      "refresh_count": 1,
      "token_address_destination": "eip155:1/slip44:60",
      "token_address_source": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:NATIVE",
    }

Sample validation failure payload for getTxStatus StatusValidationFailed

 {
    "action_type": "swapbridge-v1",
    "chain_id_destination": "eip155:10",
    "chain_id_source": "eip155:42161",
    "failures": Array [
      "across|status",
    ],
    "refresh_count": 0,
    "token_address_destination": "eip155:10/slip44:60",
    "token_address_source": "eip155:42161/slip44:60",
  },

References

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

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 August 22, 2025 00:13
@micaelae micaelae marked this pull request as draft August 22, 2025 00:13
@micaelae micaelae changed the title feat: add ResponseValidationFailure event for swap and bridge quotes feat: add ResponseValidationFailure events for bridge quote and status responses Aug 25, 2025
@micaelae micaelae changed the title feat: add ResponseValidationFailure events for bridge quote and status responses feat: publish ResponseValidationFailure events for bridge quote and status responses Aug 25, 2025
bergarces and others added 17 commits August 25, 2025 16:18
## 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?
-->

The format for EVM addresses for AccountTrackerController in mobile
differs from extension and from the other controller states. This was
causing it to miss native account balances.

It also uses the correct internal account type in the assets, so that
BTC account types can be identified.

Finally, it fixes an issue with the `mergeAssets` function mutating
internal parts of cached objects.

## 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
-->

## 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/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [X] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
…6354)

## Explanation

The TokenBalancesController.updateBalances function was creating
duplicate entries for the same token when addresses came in different
cases (lowercase vs mixed case). This resulted in token balance state

solution was to normalized all token addresses to lowercase before using
them as object keys
<!--
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?
-->

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## Explanation

**Problem**

The `TokenBalancesController` was using `safelyExecuteWithTimeout` which
has a critical flaw: it never throws errors on timeout. Instead, it
silently catches all errors (including timeouts) and returns undefined.
This prevented the controller's catch blocks from executing, breaking
the intended fallback mechanism between different balance fetchers.
Additionally, the timeout was set to 3 minutes (DEFAULT_INTERVAL_MS =
180,000ms), which is excessively long for RPC calls and could lead to
poor user experience.

**Solution**
1. Replace safelyExecuteWithTimeout with Promise.race

- Implemented direct Promise.race that properly throws timeout errors
- Now timeout errors are correctly caught by the existing error handling
logic
- Enables proper fallback between API and RPC balance fetchers

2. Reduce RPC timeout duration

- Added new constant RPC_TIMEOUT_MS = 5000 (5 seconds)
- Reduced timeout from 3 minutes to 5 seconds for better responsiveness
- 5 seconds is sufficient for most RPC calls while still allowing for
network latency with 100 batch size


<!--
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?
-->

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
#6367)

…tests

## Explanation

This PR implements 

- the `enableAllPopularNetworks()` to enable all popular networks
- modifies the `enableNetwork()` function to use exclusive behavior,
ensuring only one network is enabled per namespace at a time.

<!--
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?
-->

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## Explanation

Add optional `metamaskPay` and `requiredTransactionIds` properties to
`TransactionMeta`.

Also add `updateRequiredTransactionIds` method to update new property.

## References

## 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/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## Explanation

Minor release for the network-enablement-controllers

<!--
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?
-->

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## Explanation

This PR implements functionality for AccountTrackerController to fetch
native balances using the AccountsAPI when external services are
enabled, with comprehensive test coverage to ensure proper behavior
across different configurations.

<!--
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?
-->

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## Explanation

For MetaMask Transaction Shield we want to reroute all transaction
simulation requests through a dedicated proxy.
This PR adds the following functionality to the TransactionController to
accomplish that.

- Add optional `getSimulationConfig` parameter to constructor.
- If `getSimulationConfig` parameter is present, call the function to
retrieve a new simulation URL and an authorization header. Replace the
simulation URL and add the authorization header to the simulation
request.

<!--
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?
-->

## References

[Transaction Shield Notion
Page](https://www.notion.so/Shield-1c3f86d67d68801f8821dae7af4de4bc?source=copy_link)

<!--
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
-->

## 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/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
## 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?
-->

New minor release for `@metamask/assets-controllers`.

## 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
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes

---------

Co-authored-by: salimtb <salim.toubal@consensys.net>
Updates bridge controller to account for newly added minDestTokenAmount
field from bridge API

<!--
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?
-->

<!--
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
-->

- [ ] 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
@micaelae micaelae marked this pull request as ready for review August 26, 2025 03:13
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@micaelae micaelae changed the title feat: publish ResponseValidationFailure events for bridge quote and status responses feat: publish QuoteValidationFailed and StatusValidationFailed events for bridge-api responses Aug 26, 2025
@micaelae micaelae merged commit 6cccc28 into main Aug 26, 2025
231 checks passed
@micaelae micaelae deleted the swaps2730-quote-validation-failure-event branch August 26, 2025 17:11
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.

7 participants