Skip to content

fix: incorrect token balance changes for simulations of multiple tokens that include an NFT mint#4290

Merged
dbrans merged 2 commits intomainfrom
dbrans/fix-nft-mint
May 21, 2024
Merged

fix: incorrect token balance changes for simulations of multiple tokens that include an NFT mint#4290
dbrans merged 2 commits intomainfrom
dbrans/fix-nft-mint

Conversation

@dbrans
Copy link
Copy Markdown
Contributor

@dbrans dbrans commented May 17, 2024

Explanation

When simulating a transaction resulting in an NFT mint, we skip the prior owner check for the NFT since the token does not exist yet. However, for subsequent tokens, we were using the incorrect index for the prior balance transaction.

The fix is to keep a separate prevBalanceIndex, which we only increment if a prior balance transaction was included in the simulation.

References

Changelog

@metamask/transaction-controller

  • FIXED: Incorrect token balance changes for simulations of multiple tokens that include an NFT mint.

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 highlighted breaking changes using the "BREAKING" category above as appropriate

@dbrans dbrans marked this pull request as ready for review May 17, 2024 14:32
@dbrans dbrans requested a review from a team May 17, 2024 14:32
@dbrans
Copy link
Copy Markdown
Contributor Author

dbrans commented May 17, 2024

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

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

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "14.0.0-preview-73f66baf",
  "@metamask-previews/address-book-controller": "4.0.1-preview-73f66baf",
  "@metamask-previews/announcement-controller": "6.1.0-preview-73f66baf",
  "@metamask-previews/approval-controller": "6.0.2-preview-73f66baf",
  "@metamask-previews/assets-controllers": "29.0.0-preview-73f66baf",
  "@metamask-previews/base-controller": "5.0.2-preview-73f66baf",
  "@metamask-previews/build-utils": "2.0.1-preview-73f66baf",
  "@metamask-previews/composable-controller": "6.0.1-preview-73f66baf",
  "@metamask-previews/controller-utils": "9.1.0-preview-73f66baf",
  "@metamask-previews/ens-controller": "10.0.1-preview-73f66baf",
  "@metamask-previews/eth-json-rpc-provider": "3.0.2-preview-73f66baf",
  "@metamask-previews/gas-fee-controller": "15.1.2-preview-73f66baf",
  "@metamask-previews/json-rpc-engine": "8.0.2-preview-73f66baf",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-73f66baf",
  "@metamask-previews/keyring-controller": "16.0.0-preview-73f66baf",
  "@metamask-previews/logging-controller": "3.0.1-preview-73f66baf",
  "@metamask-previews/message-manager": "8.0.2-preview-73f66baf",
  "@metamask-previews/name-controller": "6.0.1-preview-73f66baf",
  "@metamask-previews/network-controller": "18.1.0-preview-73f66baf",
  "@metamask-previews/notification-controller": "5.0.1-preview-73f66baf",
  "@metamask-previews/permission-controller": "9.0.2-preview-73f66baf",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-73f66baf",
  "@metamask-previews/phishing-controller": "9.0.2-preview-73f66baf",
  "@metamask-previews/polling-controller": "6.0.2-preview-73f66baf",
  "@metamask-previews/preferences-controller": "11.0.0-preview-73f66baf",
  "@metamask-previews/profile-sync-controller": "0.0.0-preview-73f66baf",
  "@metamask-previews/queued-request-controller": "0.10.0-preview-73f66baf",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-73f66baf",
  "@metamask-previews/selected-network-controller": "13.0.0-preview-73f66baf",
  "@metamask-previews/signature-controller": "16.0.0-preview-73f66baf",
  "@metamask-previews/transaction-controller": "29.0.0-preview-73f66baf",
  "@metamask-previews/user-operation-controller": "10.0.0-preview-73f66baf"
}

@dbrans dbrans merged commit 06b8c5f into main May 21, 2024
@dbrans dbrans deleted the dbrans/fix-nft-mint branch May 21, 2024 12:55
@dbrans dbrans mentioned this pull request May 21, 2024
dbrans added a commit that referenced this pull request May 21, 2024
## Explanation
Patch release of TransactionController with
#4290

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

For example:

* Fixes #12345
* Related to #67890
-->
* Related to MetaMask/metamask-extension#24586
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