@metamask/snaps-controllers 15.0.0 → 15.0.2

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 CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [15.0.2]
11
+
12
+ ### Fixed
13
+
14
+ - Throw if Snap not installed ([#3666](https://github.com/MetaMask/snaps/pull/3666))
15
+
16
+ ## [15.0.1]
17
+
18
+ ### Fixed
19
+
20
+ - Stop creating errors before needing to throw ([#3664](https://github.com/MetaMask/snaps/pull/3664))
21
+
10
22
  ## [15.0.0]
11
23
 
12
24
  ### Added
@@ -911,7 +923,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
911
923
  - The version of the package no longer needs to match the version of all other
912
924
  MetaMask Snaps packages.
913
925
 
914
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.0...HEAD
926
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.2...HEAD
927
+ [15.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.1...@metamask/snaps-controllers@15.0.2
928
+ [15.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.0...@metamask/snaps-controllers@15.0.1
915
929
  [15.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@14.2.2...@metamask/snaps-controllers@15.0.0
916
930
  [14.2.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@14.2.1...@metamask/snaps-controllers@14.2.2
917
931
  [14.2.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@14.2.0...@metamask/snaps-controllers@14.2.1
@@ -713,7 +713,7 @@ class SnapController extends base_controller_1.BaseController {
713
713
  */
714
714
  getExpect(snapId) {
715
715
  const snap = this.get(snapId);
716
- (0, utils_1.assert)(snap !== undefined, new Error(`Snap "${snapId}" not found.`));
716
+ (0, utils_1.assert)(snap !== undefined, `Snap "${snapId}" not found.`);
717
717
  return snap;
718
718
  }
719
719
  /**
@@ -1832,6 +1832,8 @@ class SnapController extends base_controller_1.BaseController {
1832
1832
  */
1833
1833
  async handleRequest({ snapId, origin, handler: handlerType, request: rawRequest, }) {
1834
1834
  this.#assertCanUsePlatform();
1835
+ const snap = this.get(snapId);
1836
+ (0, utils_1.assert)(snap, `The Snap "${snapId}" is not installed. Please install it before invoking it.`);
1835
1837
  (0, utils_1.assert)(origin === constants_1.METAMASK_ORIGIN || (0, snaps_utils_1.isValidUrl)(origin), "'origin' must be a valid URL or 'metamask'.");
1836
1838
  const request = {
1837
1839
  jsonrpc: '2.0',
@@ -1866,10 +1868,10 @@ class SnapController extends base_controller_1.BaseController {
1866
1868
  constants_1.CLIENT_ONLY_HANDLERS.includes(handlerType)) {
1867
1869
  throw new Error(`"${handlerType}" can only be invoked by MetaMask.`);
1868
1870
  }
1869
- if (!this.state.snaps[snapId].enabled) {
1871
+ if (!snap.enabled) {
1870
1872
  throw new Error(`Snap "${snapId}" is disabled.`);
1871
1873
  }
1872
- if (this.state.snaps[snapId].status === snaps_utils_1.SnapStatus.Installing) {
1874
+ if (snap.status === snaps_utils_1.SnapStatus.Installing) {
1873
1875
  throw new Error(`Snap "${snapId}" is currently being installed. Please try again later.`);
1874
1876
  }
1875
1877
  const timeout = this.#getExecutionTimeout(handlerPermissions);
@@ -2201,14 +2203,14 @@ class SnapController extends base_controller_1.BaseController {
2201
2203
  * @returns A `RollbackSnapshot`.
2202
2204
  */
2203
2205
  #createRollbackSnapshot(snapId) {
2204
- (0, utils_1.assert)(this.#rollbackSnapshots.get(snapId) === undefined, new Error(`Snap "${snapId}" rollback snapshot already exists.`));
2206
+ (0, utils_1.assert)(this.#rollbackSnapshots.get(snapId) === undefined, `Snap "${snapId}" rollback snapshot already exists.`);
2205
2207
  this.#rollbackSnapshots.set(snapId, {
2206
2208
  statePatches: [],
2207
2209
  permissions: {},
2208
2210
  newVersion: '',
2209
2211
  });
2210
2212
  const newRollbackSnapshot = this.#rollbackSnapshots.get(snapId);
2211
- (0, utils_1.assert)(newRollbackSnapshot !== undefined, new Error(`Snapshot creation failed for ${snapId}.`));
2213
+ (0, utils_1.assert)(newRollbackSnapshot !== undefined, `Snapshot creation failed for ${snapId}.`);
2212
2214
  return newRollbackSnapshot;
2213
2215
  }
2214
2216
  /**
@@ -2271,7 +2273,7 @@ class SnapController extends base_controller_1.BaseController {
2271
2273
  }
2272
2274
  #getRuntimeExpect(snapId) {
2273
2275
  const runtime = this.#getRuntime(snapId);
2274
- (0, utils_1.assert)(runtime !== undefined, new Error(`Snap "${snapId}" runtime data not found`));
2276
+ (0, utils_1.assert)(runtime !== undefined, `Snap "${snapId}" runtime data not found`);
2275
2277
  return runtime;
2276
2278
  }
2277
2279
  #setupRuntime(snapId) {