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 accepted and rejected events to ApprovalController #5127

Closed

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Jan 10, 2025

Explanation

This PR introduces two new ApprovalController event which is emitted on the Approval reject or accept actions.

  • ApprovalController:accepted
  • ApprovalController:rejected

References

Need to be used in extension: MetaMask/metamask-extension#29656

Changelog

@metamask/approval-controller

  • Added: Add accepted and rejected events.

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

@metamaskbot publish-preview

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

@OGPoyraz OGPoyraz marked this pull request as ready for review January 13, 2025 12:31
@OGPoyraz OGPoyraz requested a review from a team as a code owner January 13, 2025 12:31
digiwand
digiwand previously approved these changes Jan 15, 2025
type: `${typeof controllerName}:rejected`;
payload: [
{
approval: ApprovalRequest<ApprovalRequestData>;
Copy link
Member

Choose a reason for hiding this comment

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

Would request be more explicit here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -826,6 +832,15 @@ describe('approval controller', () => {

const result = await approvalPromise;
expect(result).toBe('success');

expect(acceptedEvent.mock.calls[0][0]).toEqual({
Copy link
Member

Choose a reason for hiding this comment

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

For maintainability and modularity, should we have distinct tests to verify the events are fired?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@OGPoyraz OGPoyraz dismissed stale reviews from digiwand and pedronfigueiredo via 445749e January 16, 2025 07:25
@OGPoyraz OGPoyraz closed this Jan 17, 2025
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