Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add gasLimitNoBuffer to transactionMeta #5113

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Jan 8, 2025

Explanation

This PR aims to add gasLimitNoBuffer to transactionMeta to show minimum value while calculating network fee.

References

Changelog

@metamask/transaction-controller

  • Added: Add gasLimitNoBuffer to transactionMeta
    • gasLimitNoBuffer is the estimated gas (via eth_estimateGas) for the transaction without buffer.

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
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@OGPoyraz
Copy link
Member Author

OGPoyraz commented Jan 8, 2025

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Jan 8, 2025

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": "20.0.2-preview-bf2027a",
  "@metamask-previews/address-book-controller": "6.0.2-preview-bf2027a",
  "@metamask-previews/announcement-controller": "7.0.2-preview-bf2027a",
  "@metamask-previews/approval-controller": "7.1.1-preview-bf2027a",
  "@metamask-previews/assets-controllers": "45.1.2-preview-bf2027a",
  "@metamask-previews/base-controller": "7.1.0-preview-bf2027a",
  "@metamask-previews/build-utils": "3.0.2-preview-bf2027a",
  "@metamask-previews/chain-controller": "0.2.2-preview-bf2027a",
  "@metamask-previews/composable-controller": "10.0.0-preview-bf2027a",
  "@metamask-previews/controller-utils": "11.4.4-preview-bf2027a",
  "@metamask-previews/ens-controller": "15.0.1-preview-bf2027a",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-bf2027a",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-bf2027a",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-bf2027a",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-bf2027a",
  "@metamask-previews/keyring-controller": "19.0.2-preview-bf2027a",
  "@metamask-previews/logging-controller": "6.0.3-preview-bf2027a",
  "@metamask-previews/message-manager": "11.0.3-preview-bf2027a",
  "@metamask-previews/multichain": "2.0.0-preview-bf2027a",
  "@metamask-previews/name-controller": "8.0.2-preview-bf2027a",
  "@metamask-previews/network-controller": "22.1.1-preview-bf2027a",
  "@metamask-previews/notification-services-controller": "0.15.0-preview-bf2027a",
  "@metamask-previews/permission-controller": "11.0.4-preview-bf2027a",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-bf2027a",
  "@metamask-previews/phishing-controller": "12.3.1-preview-bf2027a",
  "@metamask-previews/polling-controller": "12.0.2-preview-bf2027a",
  "@metamask-previews/preferences-controller": "15.0.1-preview-bf2027a",
  "@metamask-previews/profile-sync-controller": "3.1.1-preview-bf2027a",
  "@metamask-previews/queued-request-controller": "8.0.2-preview-bf2027a",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-bf2027a",
  "@metamask-previews/remote-feature-flag-controller": "1.2.0-preview-bf2027a",
  "@metamask-previews/selected-network-controller": "20.0.2-preview-bf2027a",
  "@metamask-previews/signature-controller": "23.2.0-preview-bf2027a",
  "@metamask-previews/transaction-controller": "42.1.0-preview-bf2027a",
  "@metamask-previews/user-operation-controller": "21.0.0-preview-bf2027a"
}

@OGPoyraz OGPoyraz changed the title feat: Add estimatedGas to transactionMeta feat: Add gasLimitNoBuffer to transactionMeta Jan 8, 2025
@OGPoyraz OGPoyraz marked this pull request as ready for review January 8, 2025 11:42
@OGPoyraz OGPoyraz requested review from a team as code owners January 8, 2025 11:42
@OGPoyraz
Copy link
Member Author

OGPoyraz commented Jan 8, 2025

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Jan 8, 2025

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": "20.0.2-preview-981e1d0",
  "@metamask-previews/address-book-controller": "6.0.2-preview-981e1d0",
  "@metamask-previews/announcement-controller": "7.0.2-preview-981e1d0",
  "@metamask-previews/approval-controller": "7.1.1-preview-981e1d0",
  "@metamask-previews/assets-controllers": "45.1.2-preview-981e1d0",
  "@metamask-previews/base-controller": "7.1.0-preview-981e1d0",
  "@metamask-previews/build-utils": "3.0.2-preview-981e1d0",
  "@metamask-previews/chain-controller": "0.2.2-preview-981e1d0",
  "@metamask-previews/composable-controller": "10.0.0-preview-981e1d0",
  "@metamask-previews/controller-utils": "11.4.4-preview-981e1d0",
  "@metamask-previews/ens-controller": "15.0.1-preview-981e1d0",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-981e1d0",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-981e1d0",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-981e1d0",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-981e1d0",
  "@metamask-previews/keyring-controller": "19.0.2-preview-981e1d0",
  "@metamask-previews/logging-controller": "6.0.3-preview-981e1d0",
  "@metamask-previews/message-manager": "11.0.3-preview-981e1d0",
  "@metamask-previews/multichain": "2.0.0-preview-981e1d0",
  "@metamask-previews/name-controller": "8.0.2-preview-981e1d0",
  "@metamask-previews/network-controller": "22.1.1-preview-981e1d0",
  "@metamask-previews/notification-services-controller": "0.15.0-preview-981e1d0",
  "@metamask-previews/permission-controller": "11.0.4-preview-981e1d0",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-981e1d0",
  "@metamask-previews/phishing-controller": "12.3.1-preview-981e1d0",
  "@metamask-previews/polling-controller": "12.0.2-preview-981e1d0",
  "@metamask-previews/preferences-controller": "15.0.1-preview-981e1d0",
  "@metamask-previews/profile-sync-controller": "3.1.1-preview-981e1d0",
  "@metamask-previews/queued-request-controller": "8.0.2-preview-981e1d0",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-981e1d0",
  "@metamask-previews/remote-feature-flag-controller": "1.2.0-preview-981e1d0",
  "@metamask-previews/selected-network-controller": "20.0.2-preview-981e1d0",
  "@metamask-previews/signature-controller": "23.2.0-preview-981e1d0",
  "@metamask-previews/transaction-controller": "42.1.0-preview-981e1d0",
  "@metamask-previews/user-operation-controller": "21.0.0-preview-981e1d0"
}

@@ -170,7 +171,7 @@ async function getGas(
bufferMultiplier,
);

return [bufferedGas, simulationFails];
return [bufferedGas, simulationFails, estimatedGas];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this is only being persisted if we actually do an eth_estimateGas but is it simpler to always save a value so the UI can always use it directly even if fixed or provided by the dApp?

@@ -184,6 +184,11 @@ type TransactionMetaBase = {
/** Whether the gas fee estimates have been checked at least once. */
gasFeeEstimatesLoaded?: boolean;

/**
* The estimated gas for the transaction without buffer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The estimated gas for the transaction without buffer.
* The estimated gas for the transaction without any buffer applied.

### Added

- Add `gasLimitNoBuffer` property to `TransactionMeta` type ([#5113](https://github.com/MetaMask/core/pull/5113))
- `gasLimitNoBuffer` is the estimated gas (via `eth_estimateGas`) for the transaction without buffer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `gasLimitNoBuffer` is the estimated gas (via `eth_estimateGas`) for the transaction without buffer.
- `gasLimitNoBuffer` is the estimated gas for the transaction without any buffer applied.

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.

2 participants