1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Simplify removeSnap functionality after snaps-skunkworks update (#14646)

This commit is contained in:
Frederik Bolding 2022-05-09 18:19:34 +02:00 committed by GitHub
parent a2ea1cacc8
commit 9e401b14bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 23 deletions

View File

@ -1731,7 +1731,7 @@ export default class MetamaskController extends EventEmitter {
),
disableSnap: this.snapController.disableSnap.bind(this.snapController),
enableSnap: this.snapController.enableSnap.bind(this.snapController),
removeSnap: this.removeSnap.bind(this),
removeSnap: this.snapController.removeSnap.bind(this.snapController),
///: END:ONLY_INCLUDE_IN
// swaps
@ -4121,23 +4121,4 @@ export default class MetamaskController extends EventEmitter {
}
return this.keyringController.setLocked();
}
///: BEGIN:ONLY_INCLUDE_IN(flask)
// SNAPS
/**
* Removes the specified snap, and all of its associated permissions.
* If we didn't revoke the permission to access the snap from all subjects,
* they could just reinstall without any confirmation.
*
* TODO: This should be implemented in `SnapController.removeSnap` via a controller action.
*
* @param {{ id: string, permissionName: string }} snap - The wrapper object of the snap to remove.
*/
removeSnap(snap) {
this.snapController.removeSnap(snap.id);
this.permissionController.revokePermissionForAllSubjects(
snap.permissionName,
);
}
///: END:ONLY_INCLUDE_IN
}

View File

@ -190,7 +190,7 @@ function ViewSnap() {
<SnapRemoveWarning
onCancel={() => setIsShowingRemoveWarning(false)}
onSubmit={async () => {
await dispatch(removeSnap(snap));
await dispatch(removeSnap(snap.id));
}}
snapName={snap.manifest.proposedName}
/>

View File

@ -991,9 +991,9 @@ export function enableSnap(snapId) {
};
}
export function removeSnap(snap) {
export function removeSnap(snapId) {
return async (dispatch) => {
await promisifiedBackground.removeSnap(snap);
await promisifiedBackground.removeSnap(snapId);
await forceUpdateMetamaskState(dispatch);
};
}