@metamask/snaps-controllers 11.0.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/interface/SnapInterfaceController.cjs +21 -4
- package/dist/interface/SnapInterfaceController.cjs.map +1 -1
- package/dist/interface/SnapInterfaceController.d.cts +16 -3
- package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
- package/dist/interface/SnapInterfaceController.d.mts +16 -3
- package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
- package/dist/interface/SnapInterfaceController.mjs +23 -6
- package/dist/interface/SnapInterfaceController.mjs.map +1 -1
- package/dist/interface/utils.cjs +124 -23
- package/dist/interface/utils.cjs.map +1 -1
- package/dist/interface/utils.d.cts +82 -2
- package/dist/interface/utils.d.cts.map +1 -1
- package/dist/interface/utils.d.mts +82 -2
- package/dist/interface/utils.d.mts.map +1 -1
- package/dist/interface/utils.mjs +120 -22
- package/dist/interface/utils.mjs.map +1 -1
- package/dist/multichain/MultichainRouter.cjs.map +1 -1
- package/dist/multichain/MultichainRouter.d.cts +1 -15
- package/dist/multichain/MultichainRouter.d.cts.map +1 -1
- package/dist/multichain/MultichainRouter.d.mts +1 -15
- package/dist/multichain/MultichainRouter.d.mts.map +1 -1
- package/dist/multichain/MultichainRouter.mjs.map +1 -1
- package/dist/snaps/SnapController.cjs +24 -20
- package/dist/snaps/SnapController.cjs.map +1 -1
- package/dist/snaps/SnapController.d.cts +4 -0
- package/dist/snaps/SnapController.d.cts.map +1 -1
- package/dist/snaps/SnapController.d.mts +4 -0
- package/dist/snaps/SnapController.d.mts.map +1 -1
- package/dist/snaps/SnapController.mjs +24 -20
- package/dist/snaps/SnapController.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -443,26 +443,29 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
443
443
|
*/
|
|
444
444
|
async getSnapState(snapId, encrypted) {
|
|
445
445
|
const runtime = __classPrivateFieldGet(this, _SnapController_instances, "m", _SnapController_getRuntimeExpect).call(this, snapId);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
446
|
+
return await runtime.getStateMutex.runExclusive(async () => {
|
|
447
|
+
const cachedState = encrypted ? runtime.state : runtime.unencryptedState;
|
|
448
|
+
if (cachedState !== undefined) {
|
|
449
|
+
return cachedState;
|
|
450
|
+
}
|
|
451
|
+
const state = encrypted
|
|
452
|
+
? this.state.snapStates[snapId]
|
|
453
|
+
: this.state.unencryptedSnapStates[snapId];
|
|
454
|
+
if (state === null || state === undefined) {
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
if (!encrypted) {
|
|
458
|
+
// For performance reasons, we do not validate that the state is JSON,
|
|
459
|
+
// since we control serialization.
|
|
460
|
+
const json = JSON.parse(state);
|
|
461
|
+
runtime.unencryptedState = json;
|
|
462
|
+
return json;
|
|
463
|
+
}
|
|
464
|
+
const decrypted = await __classPrivateFieldGet(this, _SnapController_instances, "m", _SnapController_decryptSnapState).call(this, snapId, state);
|
|
465
|
+
// eslint-disable-next-line require-atomic-updates
|
|
466
|
+
runtime.state = decrypted;
|
|
467
|
+
return decrypted;
|
|
468
|
+
});
|
|
466
469
|
}
|
|
467
470
|
/**
|
|
468
471
|
* Gets a static auxiliary snap file in a chosen file encoding.
|
|
@@ -1985,6 +1988,7 @@ async function _SnapController_rollbackSnaps(snapIds) {
|
|
|
1985
1988
|
interpreter,
|
|
1986
1989
|
stopping: false,
|
|
1987
1990
|
stateMutex: new async_mutex_1.Mutex(),
|
|
1991
|
+
getStateMutex: new async_mutex_1.Mutex(),
|
|
1988
1992
|
});
|
|
1989
1993
|
}, _SnapController_calculatePermissionsChange = function _SnapController_calculatePermissionsChange(snapId, desiredPermissionsSet) {
|
|
1990
1994
|
const oldPermissions = this.messagingSystem.call('PermissionController:getPermissions', snapId) ?? {};
|