Skip to content

Commit

Permalink
Add support for new Snaps state methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Dec 9, 2024
1 parent cbb57a1 commit 3646fe2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/scripts/controllers/permissions/specifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,16 @@ export const unrestrictedMethods = Object.freeze([
'wallet_invokeSnap',
'wallet_invokeKeyring',
'snap_getClientStatus',
'snap_getCurrencyRate',
'snap_clearState',
'snap_getFile',
'snap_getState',
'snap_createInterface',
'snap_updateInterface',
'snap_getInterfaceState',
'snap_getInterfaceContext',
'snap_resolveInterface',
'snap_getCurrencyRate',
'snap_setState',
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
'metamaskinstitutional_authenticate',
'metamaskinstitutional_reauthenticate',
Expand Down
12 changes: 12 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6113,6 +6113,10 @@ export default class MetamaskController extends EventEmitter {

engine.push(
createSnapsMethodMiddleware(subjectType === SubjectType.Snap, {
clearSnapState: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:clearSnapState',
),
getUnlockPromise: this.appStateController.getUnlockPromise.bind(
this.appStateController,
),
Expand All @@ -6135,6 +6139,14 @@ export default class MetamaskController extends EventEmitter {
'SnapController:getFile',
origin,
),
getSnapState: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:getSnapState',
),
updateSnapState: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:updateSnapState',
),
installSnaps: this.controllerMessenger.call.bind(
this.controllerMessenger,
'SnapController:install',
Expand Down

0 comments on commit 3646fe2

Please sign in to comment.