Skip to content

Conversation

@matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented May 2, 2025

Explanation

Include gas limit and gas fees in balance change simulation requests.

Specifically:

  • Create alternate simulation request specifically for gas fee tokens in new utils/gas-fee-tokens.ts.
  • Rename utils/simulation.ts to utils/balance-changes.ts.
  • Add withGas and withDefaultBlockOverrides to balance change simulation requests.
  • Override balance in balance change requests if insufficient balance.
  • Subtract gas cost from native balance change.
  • Replace code override with authorizationList including from property.
  • Retrieve MetaMask fee from simulation API.

References

Fixes #4756

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

@matthewwalsh0 matthewwalsh0 force-pushed the fix/simulation-include-gas branch from 6c3d296 to 4d99de2 Compare May 2, 2025 23:23
@matthewwalsh0 matthewwalsh0 force-pushed the fix/simulation-include-gas branch from e5a0379 to 9126697 Compare May 5, 2025 15:50
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review May 5, 2025 16:09
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners May 5, 2025 16:09
@matthewwalsh0 matthewwalsh0 force-pushed the fix/simulation-include-gas branch from 1a8ff2b to 4ec8b2d Compare May 19, 2025 12:13
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

@github-actions
Copy link
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": "29.0.0-preview-4ec8b2d",
  "@metamask-previews/address-book-controller": "6.0.3-preview-4ec8b2d",
  "@metamask-previews/announcement-controller": "7.0.3-preview-4ec8b2d",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-4ec8b2d",
  "@metamask-previews/approval-controller": "7.1.3-preview-4ec8b2d",
  "@metamask-previews/assets-controllers": "63.0.0-preview-4ec8b2d",
  "@metamask-previews/base-controller": "8.0.1-preview-4ec8b2d",
  "@metamask-previews/bridge-controller": "25.0.1-preview-4ec8b2d",
  "@metamask-previews/bridge-status-controller": "21.0.0-preview-4ec8b2d",
  "@metamask-previews/build-utils": "3.0.3-preview-4ec8b2d",
  "@metamask-previews/chain-agnostic-permission": "0.7.0-preview-4ec8b2d",
  "@metamask-previews/composable-controller": "11.0.0-preview-4ec8b2d",
  "@metamask-previews/controller-utils": "11.9.0-preview-4ec8b2d",
  "@metamask-previews/delegation-controller": "0.3.0-preview-4ec8b2d",
  "@metamask-previews/earn-controller": "0.14.0-preview-4ec8b2d",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-4ec8b2d",
  "@metamask-previews/ens-controller": "16.0.0-preview-4ec8b2d",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-4ec8b2d",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-4ec8b2d",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-4ec8b2d",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-4ec8b2d",
  "@metamask-previews/keyring-controller": "22.0.0-preview-4ec8b2d",
  "@metamask-previews/logging-controller": "6.0.4-preview-4ec8b2d",
  "@metamask-previews/message-manager": "12.0.1-preview-4ec8b2d",
  "@metamask-previews/multichain": "4.1.0-preview-4ec8b2d",
  "@metamask-previews/multichain-api-middleware": "0.3.0-preview-4ec8b2d",
  "@metamask-previews/multichain-network-controller": "0.7.0-preview-4ec8b2d",
  "@metamask-previews/multichain-transactions-controller": "1.0.0-preview-4ec8b2d",
  "@metamask-previews/name-controller": "8.0.3-preview-4ec8b2d",
  "@metamask-previews/network-controller": "23.5.0-preview-4ec8b2d",
  "@metamask-previews/notification-services-controller": "8.0.0-preview-4ec8b2d",
  "@metamask-previews/permission-controller": "11.0.6-preview-4ec8b2d",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-4ec8b2d",
  "@metamask-previews/phishing-controller": "12.5.0-preview-4ec8b2d",
  "@metamask-previews/polling-controller": "13.0.0-preview-4ec8b2d",
  "@metamask-previews/preferences-controller": "18.0.0-preview-4ec8b2d",
  "@metamask-previews/profile-sync-controller": "15.0.0-preview-4ec8b2d",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-4ec8b2d",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-4ec8b2d",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-4ec8b2d",
  "@metamask-previews/sample-controllers": "0.1.0-preview-4ec8b2d",
  "@metamask-previews/selected-network-controller": "22.1.0-preview-4ec8b2d",
  "@metamask-previews/signature-controller": "29.0.0-preview-4ec8b2d",
  "@metamask-previews/token-search-discovery-controller": "3.1.0-preview-4ec8b2d",
  "@metamask-previews/transaction-controller": "56.1.0-preview-4ec8b2d",
  "@metamask-previews/user-operation-controller": "35.0.0-preview-4ec8b2d"
}

@matthewwalsh0 matthewwalsh0 force-pushed the fix/simulation-include-gas branch 3 times, most recently from 16c451b to 27e53e1 Compare May 28, 2025 12:32
@matthewwalsh0 matthewwalsh0 enabled auto-merge (squash) June 2, 2025 13:50
@matthewwalsh0 matthewwalsh0 force-pushed the fix/simulation-include-gas branch from 27e53e1 to 8a24e34 Compare June 2, 2025 13:51
@matthewwalsh0 matthewwalsh0 merged commit 873b4f6 into main Jun 2, 2025
209 of 210 checks passed
@matthewwalsh0 matthewwalsh0 deleted the fix/simulation-include-gas branch June 2, 2025 13:56
matthewwalsh0 added a commit that referenced this pull request Jun 11, 2025
Include gas limit and gas fees in balance change simulation requests.

Specifically:

- Create alternate simulation request specifically for gas fee tokens in
new `utils/gas-fee-tokens.ts`.
- Rename `utils/simulation.ts` to `utils/balance-changes.ts`.
- Add `withGas` and `withDefaultBlockOverrides` to balance change
simulation requests.
- Override balance in balance change requests if insufficient balance.
- Subtract gas cost from native balance change.
- Replace code override with `authorizationList` including `from`
property.
- Retrieve MetaMask fee from simulation API.

- [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants