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

Support swaps using user operations #3749

Merged
merged 57 commits into from
Jan 12, 2024

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Jan 9, 2024

Explanation

Support swaps using user operations.

  • Add the type option to force a TransactionType such as swap or swapApproval.
  • Add the swaps option to specify swaps specific metadata such as sourceTokenSymbol and swapTokenValue.
  • Emit the user-operation-added event to allow the clients to check for a swap transaction type and notify other controllers.

In addition:

  • Remove the hardcoded entrypoint in favour of a required constructor option.
  • Update payload when estimating gas to use zero gas fees and gas limits excluding verificationGasLimit.

Changelog

@metamask/user-operation-controller

  • BREAKING: Add required constructor option entrypoint to specify address of 4337 entrypoint smart contract.
  • BREAKING: Change type of destinationTokenDecimals property in TransactionMetadata to number.
  • ADDED: Add type and swaps properties to AddUserOperationOptions.
  • ADDED: Emit user-operation-added event.
  • CHANGED: Update request when estimating gas with bundler.

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

Add unit tests for Bundler helper.
Estimate gas only if not provided by account.
Do not throw unless hash function called.
Create associated unit tests.
Emit transaction-updated events.
Add isUserOperation property to transactions.
Add associated unit tests.
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Jan 9, 2024

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": "7.0.1-preview.353ee83b",
  "@metamask-previews/address-book-controller": "3.1.6-preview.353ee83b",
  "@metamask-previews/announcement-controller": "5.0.1-preview.353ee83b",
  "@metamask-previews/approval-controller": "5.1.1-preview.353ee83b",
  "@metamask-previews/assets-controllers": "23.1.0-preview.353ee83b",
  "@metamask-previews/base-controller": "4.0.1-preview.353ee83b",
  "@metamask-previews/build-utils": "1.0.1-preview.353ee83b",
  "@metamask-previews/composable-controller": "5.0.0-preview.353ee83b",
  "@metamask-previews/controller-utils": "8.0.1-preview.353ee83b",
  "@metamask-previews/ens-controller": "8.0.0-preview.353ee83b",
  "@metamask-previews/eth-json-rpc-provider": "2.3.1-preview.353ee83b",
  "@metamask-previews/gas-fee-controller": "12.0.0-preview.353ee83b",
  "@metamask-previews/json-rpc-engine": "7.3.1-preview.353ee83b",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.1-preview.353ee83b",
  "@metamask-previews/keyring-controller": "11.0.0-preview.353ee83b",
  "@metamask-previews/logging-controller": "2.0.1-preview.353ee83b",
  "@metamask-previews/message-manager": "7.3.7-preview.353ee83b",
  "@metamask-previews/name-controller": "4.1.0-preview.353ee83b",
  "@metamask-previews/network-controller": "17.1.0-preview.353ee83b",
  "@metamask-previews/notification-controller": "4.0.1-preview.353ee83b",
  "@metamask-previews/permission-controller": "7.1.0-preview.353ee83b",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.353ee83b",
  "@metamask-previews/phishing-controller": "8.0.1-preview.353ee83b",
  "@metamask-previews/polling-controller": "4.0.0-preview.353ee83b",
  "@metamask-previews/preferences-controller": "5.0.1-preview.353ee83b",
  "@metamask-previews/queued-request-controller": "0.3.0-preview.353ee83b",
  "@metamask-previews/rate-limit-controller": "4.0.1-preview.353ee83b",
  "@metamask-previews/selected-network-controller": "6.0.0-preview.353ee83b",
  "@metamask-previews/signature-controller": "9.0.0-preview.353ee83b",
  "@metamask-previews/transaction-controller": "19.0.1-preview.353ee83b",
  "@metamask-previews/user-operation-controller": "0.0.0-preview.353ee83b"
}

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review January 10, 2024 08:28
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner January 10, 2024 08:28
@matthewwalsh0 matthewwalsh0 merged commit f8437e9 into main Jan 12, 2024
@matthewwalsh0 matthewwalsh0 deleted the feat/user-operation-swap-support branch January 12, 2024 16:09
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.

3 participants