@metamask/snaps-controllers 15.0.1 → 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,12 @@ 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
+
10
16
  ## [15.0.1]
11
17
 
12
18
  ### Fixed
@@ -917,7 +923,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
917
923
  - The version of the package no longer needs to match the version of all other
918
924
  MetaMask Snaps packages.
919
925
 
920
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.1...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
921
928
  [15.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.0...@metamask/snaps-controllers@15.0.1
922
929
  [15.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@14.2.2...@metamask/snaps-controllers@15.0.0
923
930
  [14.2.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@14.2.1...@metamask/snaps-controllers@14.2.2
@@ -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);