[pull] main from MetaMask:main#784
Merged
Merged
Conversation
#8781) …nces Two fixes that together stop entries like `eip155:4326/erc20:0x000…000: { amount: "NaN" }` from leaking into `assetsBalance`. - `#collectMetadataForBalances`: only reuse existing native metadata when it has finite `decimals` (via new `#hasValidDecimals` helper). Empty `name`/`symbol` are still accepted, and `decimals: 0` is valid. Bad state metadata (e.g. `{ decimals: null, name: '', symbol: '', type: 'native' }`) is replaced by the chain-status stub so the pipeline resolves a usable `decimals`. - `#convertToHumanReadable`: defensively return `'0'` when `decimals` isn't a finite non-negative number or when `rawBalance` can't be parsed. Defaulting decimals to a fixed value (e.g. 18) would silently produce wrong amounts; `'0'` matches the existing safe fallback used in the error path. Adds 7 tests covering the bug payload (`decimals: null`), `NaN` decimals, negative decimals, non-numeric raw balance, and the `decimals: 0` / missing `name`/`symbol` valid cases. ## 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? --> ## 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/processes/updating-changelogs.md) - [ ] 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] > **Medium Risk** > Touches balance formatting and native metadata selection in `RpcDataSource`, which can affect emitted `assetsBalance`/`assetsInfo` values across chains and accounts. Changes are defensive and well-tested but could alter behavior for edge-case metadata payloads. > > **Overview** > Prevents `RpcDataSource` from emitting `{ amount: "NaN" }` (or silently wrong `'0'`) balances when native asset metadata in state contains invalid `decimals`. > > Native metadata reuse is now gated by a new `#hasValidDecimals` (finite, non-negative; `0` allowed), otherwise falling back to the chain-status stub, and decimals selection no longer uses `??`—a new `#pickValidDecimals` skips `NaN`/negative values so stale state can’t shadow valid pipeline metadata. > > `#convertToHumanReadable` now returns `'0'` when `decimals` is invalid or the raw balance is unparsable, and the PR adds focused unit tests covering null/NaN/negative decimals and invalid raw balances (plus valid `decimals: 0` cases). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 37b8e8c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## Summary This is PR 2 of 4 in the core stack for Predict withdraws over Across. - Adds Across quote construction for post-quote Predict withdraws. - Uses exact-input quotes without destination actions for the post-quote withdraw flow. - Preserves provider fees, target totals, and original transaction gas when normalizing quotes. - Re-quotes post-quote withdraws after reserving source token for source-chain gas paid with the source token. ## Stack 1. #8759: plumbing to identify Predict Across withdraws 2. This PR: quote support 3. #8761: submit support 4. #8762: gas payment edge cases ## Validation - `yarn workspace @metamask/transaction-pay-controller run jest --no-coverage src/strategy/across/across-quotes.test.ts src/strategy/across/AcrossStrategy.test.ts` - Full stack validation was run on the final stacked branch: - `yarn changelog:validate` - `yarn workspace @metamask/transaction-pay-controller run test` - `yarn workspace @metamask/transaction-controller run test` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it changes Across quote construction and gas/fee calculations for post-quote Predict withdraw flows, including special-casing EIP-7702 authorization-list handling and multi-phase re-quoting logic that could affect pricing and execution safety. > > **Overview** > Adds Across **quote support for post-quote Predict withdraws**, switching these requests to `exactInput` quoting with **no destination actions** and passing `refundAddress` through to the Across `/swap/approval` request. > > Updates gas/fee normalization to **include the original withdrawal transaction’s gas** in `sourceNetwork`/`gasLimits` for post-quote quotes, and extends the existing two-phase “reserve source token for gas-fee-token” re-quote flow to *also* apply to post-quote Predict withdraws (now failing hard on unsafe/invalid phase-2 outcomes instead of falling back). > > Relaxes Across strategy quote support checks to allow first-time EIP-7702 `requiresAuthorizationList` **only** for post-quote Predict withdraw quotes that have no embedded Across actions, and updates types/tests accordingly (including persisting `actions` in the quote’s `original.request`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a65c549. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…ts (#8786) This change ensures the mUSD address is consistently checksummed, preventing potential discrepancies in asset ID generation and data source emissions. The update is crucial for maintaining data integrity across different chains. ## 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? --> ## 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/processes/updating-changelogs.md) - [ ] 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] > **Medium Risk** > Changes the canonical casing of default CAIP-19 keys and makes `getDefaultAssetMetadata` case-sensitive, so any caller not normalizing asset IDs could stop receiving seeded metadata. > > **Overview** > Fixes mUSD default asset IDs to use an EIP-55 checksummed contract address so the `assetsInfo` entries pre-seeded by `buildDefaultAssetsInfo()` match the checksummed IDs emitted by data sources, preventing duplicate metadata entries for the same token. > > Updates defaults lookup behavior by keying `DEFAULT_ASSET_METADATA` by checksummed CAIP-19 IDs (removing `.toLowerCase()` normalization) and adds a regression test asserting seeded ERC-20 asset IDs contain checksum casing; changelog is updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d8eca2c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…ld not be reset when accountOverride is changed (#8787) ## Explanation For postquote payments payment token for MM Pay transaction should not be reset when accountOverride is changed. This is ensure on UI token selection is not reset when account selection is changes. ## References Related to https://consensyssoftware.atlassian.net/browse/CONF-1381 ## 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] > **Low Risk** > Low risk: small conditional change to when `paymentToken` is cleared, limited to post-quote flows and covered by a new unit test. > > **Overview** > Prevents `TransactionPayController.setTransactionConfig` from clearing `transactionData.paymentToken` when `accountOverride` changes in **post-quote** flows (`isPostQuote: true`), avoiding UI token selection resets. > > Adds a regression test covering the new behavior, and documents the fix in `CHANGELOG.md`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6811719. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )