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

[BREAKING] Add snap_resolveInterface RPC method #2509

Merged
merged 12 commits into from
Jun 27, 2024

Conversation

GuillaumeRx
Copy link
Contributor

@GuillaumeRx GuillaumeRx commented Jun 21, 2024

This PR adds a new non-restricted RPC method that allows a snap to resolve a given user interface bound to a snap_dialog with a custom value.

  • Add the resolveInterface method in the SnapInterfaceController
  • Add a new snap_resolveInterface RPC method
  • Update snap_dialog RPC method to set the approval ID to the interface ID
  • [BREAKING] snap_dialog now takes the requestUserApproval hook which is meant to be bind to the addAndShowRequest method of the ApprovalController

Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.89%. Comparing base (35ae1e7) to head (3536bde).

Current head 3536bde differs from pull request most recent head c33b9d3

Please upload reports for the commit c33b9d3 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2509      +/-   ##
==========================================
+ Coverage   93.85%   93.89%   +0.03%     
==========================================
  Files         453      454       +1     
  Lines        9412     9464      +52     
  Branches     1436     1445       +9     
==========================================
+ Hits         8834     8886      +52     
  Misses        578      578              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GuillaumeRx GuillaumeRx marked this pull request as ready for review June 25, 2024 13:13
@GuillaumeRx GuillaumeRx requested a review from a team as a code owner June 25, 2024 13:13
@GuillaumeRx GuillaumeRx force-pushed the gr/resolve-snap-interface branch 3 times, most recently from b097787 to 5492553 Compare June 26, 2024 10:59
@GuillaumeRx GuillaumeRx changed the title Add snap_resolveInterface RPC method [BREAKING] Add snap_resolveInterface RPC method Jun 26, 2024
@MetaMask MetaMask deleted a comment from FrederikBolding Jun 27, 2024
@@ -45,33 +46,33 @@ const MAX_FILE_SIZE = 10_000_000; // 10 MB
*/
export function getInterfaceResponse(
Copy link
Member

Choose a reason for hiding this comment

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

Out of scope for this PR, but the new dialog type should be supported here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I'm going to open a new PR once this one is merged with some support for this new Dialog type in snaps-jest

import type { PayloadAction } from '@reduxjs/toolkit';
import { createAction, createSelector, createSlice } from '@reduxjs/toolkit';

import type { ApplicationState } from './store';

export type Interface = {
type: DialogType;
type: string;
Copy link
Member

Choose a reason for hiding this comment

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

@Mrtenz This type is only used internally, right?

Copy link
Contributor Author

@GuillaumeRx GuillaumeRx Jun 27, 2024

Choose a reason for hiding this comment

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

I think these are internal only, I convert them to the dialog type in getInterfaceResponse

}),
).rejects.toThrow(
'The "type" property must be one of: alert, confirmation, prompt.',
'Invalid params: Expected the value to satisfy a union of `object | object`, but received: [object Object]',
Copy link
Member

Choose a reason for hiding this comment

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

We should improve this, but out of scope

@FrederikBolding
Copy link
Member

Please let @Mrtenz leave a review as well if he wants to request any changes for snaps-jest

@GuillaumeRx GuillaumeRx merged commit ad0eae4 into main Jun 27, 2024
154 checks passed
@GuillaumeRx GuillaumeRx deleted the gr/resolve-snap-interface branch June 27, 2024 09:42
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