From d230a27ae0c067b0e3767f84b0f145d671fc6aa6 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 7 Oct 2024 14:52:17 +0200 Subject: [PATCH 01/11] Add platform version field to manifest --- .../packages/bip32/snap.manifest.json | 3 +- .../packages/bip44/snap.manifest.json | 3 +- .../browserify-plugin/snap.manifest.json | 3 +- .../packages/browserify/snap.manifest.json | 3 +- .../packages/client-status/snap.manifest.json | 3 +- .../packages/cronjobs/snap.manifest.json | 3 +- .../packages/dialogs/snap.manifest.json | 3 +- .../packages/errors/snap.manifest.json | 3 +- .../ethereum-provider/snap.manifest.json | 3 +- .../packages/ethers-js/snap.manifest.json | 3 +- .../packages/file-upload/snap.manifest.json | 3 +- .../packages/get-entropy/snap.manifest.json | 3 +- .../packages/get-file/snap.manifest.json | 3 +- .../packages/home-page/snap.manifest.json | 3 +- .../packages/images/snap.manifest.json | 3 +- .../interactive-ui/snap.manifest.json | 3 +- .../consumer-signer/snap.manifest.json | 3 +- .../packages/core-signer/snap.manifest.json | 3 +- .../packages/json-rpc/snap.manifest.json | 3 +- .../examples/packages/jsx/snap.manifest.json | 3 +- .../lifecycle-hooks/snap.manifest.json | 3 +- .../packages/localization/snap.manifest.json | 3 +- .../packages/manage-state/snap.manifest.json | 3 +- .../packages/name-lookup/snap.manifest.json | 3 +- .../network-access/snap.manifest.json | 3 +- .../packages/notifications/snap.manifest.json | 3 +- .../packages/preinstalled/snap.manifest.json | 3 +- .../packages/rollup-plugin/snap.manifest.json | 3 +- .../packages/send-flow/snap.manifest.json | 3 +- .../signature-insights/snap.manifest.json | 3 +- .../transaction-insights/snap.manifest.json | 3 +- .../examples/packages/wasm/snap.manifest.json | 3 +- .../webpack-plugin/snap.manifest.json | 3 +- packages/snaps-controllers/coverage.json | 6 +- packages/snaps-controllers/package.json | 2 + .../src/snaps/SnapController.test.tsx | 104 ++++++++++++++++++ .../src/snaps/SnapController.ts | 33 ++++++ .../src/snaps/registry/json.test.ts | 2 +- .../src/test-utils/controller.ts | 5 +- packages/snaps-utils/coverage.json | 4 +- packages/snaps-utils/src/index.ts | 1 + .../snaps-utils/src/manifest/manifest.test.ts | 67 ++++++++--- packages/snaps-utils/src/manifest/manifest.ts | 3 +- .../snaps-utils/src/manifest/validation.ts | 1 + .../src/manifest/validators/index.ts | 1 + .../validators/platform-version.test.ts | 90 +++++++++++++++ .../manifest/validators/platform-version.ts | 44 ++++++++ .../snaps-utils/src/platform-version.test.ts | 10 ++ packages/snaps-utils/src/platform-version.ts | 14 +++ .../snaps-utils/src/test-utils/manifest.ts | 11 +- yarn.lock | 2 + 51 files changed, 439 insertions(+), 60 deletions(-) create mode 100644 packages/snaps-utils/src/manifest/validators/platform-version.test.ts create mode 100644 packages/snaps-utils/src/manifest/validators/platform-version.ts create mode 100644 packages/snaps-utils/src/platform-version.test.ts create mode 100644 packages/snaps-utils/src/platform-version.ts diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index 4b9136702f..a796c0480e 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "PxNHa0ebJ1qA/LXiY4vTzUsBKNl3rdfbHwg198YtOH4=", + "shasum": "C+PL5IlfLt5gJSrLw67s5xqCUuTquV0i5P6mVIEyzvc=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -43,5 +43,6 @@ } ] }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index 2c39cfc189..a81c964a7a 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Nb4y6u121k+rnDRGblkG77S7s9IFt1TZTQeSZOXNdyY=", + "shasum": "HsQqFbJSviMTXT4kNx+Cw8o4Q3tbpMmazitpC5e4J4w=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -31,5 +31,6 @@ } ] }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index 3fa785166d..b1b59f9019 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "zA6fni0b6B+ELhkMRiw6vcAgKj1/9A/Rm+dxkPY/oxM=", + "shasum": "TaJFXpS2ECCYQrYEPzvvtV+iN9agVwDfVaU5fG4nDps=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 1f1ce212a2..4c8f349fa5 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "diJJzn5l3lSAKQvHldlYmQXjTcO/IDnLOnxH7kGmkW0=", + "shasum": "aGkLvDgAQnByDlFaRayI2zI8CbJ/9Jci5bFBi2YYmI8=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 722cc84de1..abebd241ff 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "fyBeeuYGaIpBnxm6MVoRe19JR+8QiIeFtJM+nlOWnsU=", + "shasum": "zbzbZ5RbBUMDZewEZ+19Mfq5/JZNcabBuBKLFcjdYhY=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ "snaps": false } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index 72e5804a10..db0a10751b 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "52lYQY0bh6ZtKx4ZNtQNO17ustuhQBewko/WzQkS68A=", + "shasum": "aRkKWMsk1fg+bW/DxO0Ff1dgcIXvVbcdMlFKCaW82sE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -29,5 +29,6 @@ }, "snap_dialog": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index 75edcaa8a6..50bec984e6 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "v2oIs3UY5j/3dXW5eRh3rg7Tv5qcVzHon7qzPQeRsAE=", + "shasum": "/7vhR2s6a2hwLS31z0IQMGwYrLmUMthVNJuEXrdrZxA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "snap_dialog": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/errors/snap.manifest.json b/packages/examples/packages/errors/snap.manifest.json index f4e1bff846..d3bd192d90 100644 --- a/packages/examples/packages/errors/snap.manifest.json +++ b/packages/examples/packages/errors/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "yBkP0yx/0fYCe3r3hglrIJJAXuxTgMpCsR0HMJ/KV7o=", + "shasum": "wztrad9mrmSL20LAQN0oYVOUBaB9EGBJRLK2sxCFzPA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 80264829d5..6c5552ac91 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "pSiTZjO5nox8zYh+fQtQfZLp5HwbxKByu+WOo+tAAH0=", + "shasum": "9fmgm42mFtb9fhjnLylggCUE8jF+inUUYdqwZWxulGU=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "endowment:ethereum-provider": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index ff001e07a2..12440a7f07 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "3ec/uMXW2lAaVxSJJRjsAmQ1oSqVJpHUkF4i4YTa9Gk=", + "shasum": "8Z62OTAMc1vl1gT8pa/5dUlGnZ9V0A6AoCIZs66IgaY=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ "snap_dialog": {}, "snap_getEntropy": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index a34c9a115e..46337fe07c 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "z4vMdrs40TdVE+vk7sPruIvWi0q669V+p3jc6WQIib4=", + "shasum": "01klLEVRzNMW3bQor2YoGD7CQQ2/9+XvCja+s1KeVnA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -24,5 +24,6 @@ "snap_dialog": {}, "snap_manageState": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index eaa27579dd..35773661c6 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "OYSzxQ1qHApZ2MHWvQ/XYWRwKJptpyVQ5VgyhgFEmmo=", + "shasum": "EfFv98OsBbvYmS8Jzxnv4WX6kgU+lAwckpbNCKWU93g=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ "snap_dialog": {}, "snap_getEntropy": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index 771cf66e98..ffef5e610e 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "aTuxZCIXcq/FP7XjSoBY4e4pHQbuoDJ1U6FUe/rAfiQ=", + "shasum": "P+Naux1efbcYAPhgOs9Kn77QwhdRvVFeBe3kuYJt0vY=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 3afc05d1c9..82507f75a4 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "emnlXHvrhsGBMi/y1IPhiQPX9ogHmjmOU/iujBu5GB8=", + "shasum": "46WN8y6FgObZQUc1R6t8G8RDxXJlgGAM2PzyL/Do+jA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -19,5 +19,6 @@ "initialPermissions": { "endowment:page-home": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index d0a0d9eef2..0576f51aa5 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "kbuZtLjZiY9+HOtc7DIpuGUjMes2id67dES3Ze/Z3dY=", + "shasum": "94CNMWQRWTxxJH0yZ+oKrU8A3BvAwaOTfvHH3bRpj1I=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ }, "snap_dialog": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index 16385ab7df..5c98fccc35 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Q2JcD7CoRLqjextX7QhYK6SOIK6ROF4NpvbUEwtITe8=", + "shasum": "1wPPQqfkexl9jjQFKDdhNbEzQJjkbe94yCd7uinD7Wo=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -25,5 +25,6 @@ "endowment:transaction-insight": {}, "endowment:page-home": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index fe8c817357..d616aa5076 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "KFAIwiPcEKSJL79+hVHmZPCTIrqAnWJN7uM7vFuaDj0=", + "shasum": "xK+0xffragaVg05a1zQMIbcibBNwAdKJnOdCTxVPH7Y=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index 0367556298..d742db564f 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "EMv6OrPDoNKIb8YjY5cbjumuwN8Oz3x6ASB1AODM/jM=", + "shasum": "JqTuGspBroEi3vLyCIPs09qFFQJwZ1aD/fovVToIPRw=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ "snap_dialog": {}, "snap_manageState": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index 4ca36a011d..1a022b719d 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "loHXuvuW/Zb4kMSSdekMiV20UVtxXYyoDC0iRZbV274=", + "shasum": "jQeujNPPhG8qpKR+KRBod55gAR3Qu+NoffIM8kBbW2M=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -26,5 +26,6 @@ } } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index f9a9c92dcf..b2ed52d556 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "3U9+Lvmmdc9JRmaHLcwGgi9lpnaj25joBF9+zXY4644=", + "shasum": "InQK+TFR3jg4Zs/ZwfCSS9iMwafkzdR/Jhbdi6/d6d8=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ "snap_dialog": {}, "snap_manageState": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index bd7003b5f6..0132d3566c 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "U+ry3tQOBH2gb+WQYNBYTqKst27YLCCNPNrL3mzwxY8=", + "shasum": "UBfsZeBErxBxxe7K+JAjSKIvOl4SZ9x1bsNBnaQLSTQ=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -20,5 +20,6 @@ "snap_dialog": {}, "endowment:lifecycle-hooks": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index 66585bec34..e4abf19373 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "KHrWdamfUEJ10ak4/oE/C4/oTO9BRnLSLjOiS9RFlHw=", + "shasum": "ZpSw3wbSVW4bCNxWU02BVrH5uHpvngd9B+i/ATDiKqo=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ }, "snap_getPreferences": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index bb792bf7a1..af9570270e 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "5FNiUEpsrVxG3rTbJvhx/IBZ/jIYYu0ZbnCX9A6dAPE=", + "shasum": "jen+Zz1ISbr1EaWj2oYgHO7JL7GHr4kRjc4QblUP3P4=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "snap_manageState": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/name-lookup/snap.manifest.json b/packages/examples/packages/name-lookup/snap.manifest.json index a32e40a940..8283ef6fdc 100644 --- a/packages/examples/packages/name-lookup/snap.manifest.json +++ b/packages/examples/packages/name-lookup/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "xk7O5itVsuV3Dfldq3rI3WgggHa3z7HX7e17jzheE8w=", + "shasum": "eEhkb8o8fsXQxY+NetYLNdkRUljzT/qdZCYs338uc/8=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "chains": ["eip155:1"] } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index 39bb82c00e..135743366d 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "+V4EDf0266FOJDTVrhQ91ZaycBruUesJqSoAzohWnO0=", + "shasum": "OsZifnVDWfwM5/f4jO0+ttIFKO9M5VZmqtGUGN7Knm4=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ }, "endowment:network-access": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index db46bad3d9..a5d25f0cd6 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "S3wZGdkOLX7tdJYssmy+UxBXe+VuwZaNUQNqK+G3hu4=", + "shasum": "nuIHOpoyl/f5twY5vKHdsK29N8bAFFkp3jSb0I5Gi28=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "snap_notify": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/preinstalled/snap.manifest.json b/packages/examples/packages/preinstalled/snap.manifest.json index cf6a42afee..7362e1feaa 100644 --- a/packages/examples/packages/preinstalled/snap.manifest.json +++ b/packages/examples/packages/preinstalled/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "KUHZC+FvI4Ll48Ngy9ufvs6CFMsxqaNVw+dd2iyRNNE=", + "shasum": "j6Oifwy3b46n82GjfzR5WSS22qa3ZYRTHZGLczJtSMM=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "snap_dialog": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index f9310a6e8a..04b5e963d1 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "FvkhD/R3iN0i/0P4OTlD0rPX+697OZ0a5kns8T669Jk=", + "shasum": "dmIJl9Tp4iR0GTfe+RwO1QAgZIJVHQ4p6q8U3tf1fXw=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/send-flow/snap.manifest.json b/packages/examples/packages/send-flow/snap.manifest.json index f2ff99c36e..67e8d20ed9 100644 --- a/packages/examples/packages/send-flow/snap.manifest.json +++ b/packages/examples/packages/send-flow/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "PTmRKwKUzSGr2ZBWOMDRHn1HTmmgk32dzd7zqmvcoMo=", + "shasum": "a+ldFYz6DKWCG7g2mCOORwWwJi/2jECIODp33wnzZkQ=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -23,5 +23,6 @@ "snap_dialog": {}, "endowment:page-home": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index 6b0b7cd139..1f2ce2b0cc 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "hlMIB9kls/72D0A77vdvIkZEbJNUDj3Py9PIxm7aWOM=", + "shasum": "9STUPY6eRjt+TIFdMPIjpciA2r8oBk44hAIQ/6E75uc=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -19,5 +19,6 @@ "initialPermissions": { "endowment:signature-insight": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index d75cd30980..95fe2ac45b 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "oKKYF+AERJAyRBABHRf4nsfQ6IrhKele+Fei+JXxGzA=", + "shasum": "cpJ6yas3+V8X8S2JYF4HaC+YY45DuqMWDXZNPIYugyQ=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -19,5 +19,6 @@ "initialPermissions": { "endowment:transaction-insight": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index 206f6e4e8e..8e34137842 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "rNBULIRBi45r+MXpWUNwkSaWog2pNTfG5VYKZ676w6g=", + "shasum": "0pkqwmT8vlu9P/sk7KfbiQcCHJ8BbnP5O5zHLed0Upw=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -22,5 +22,6 @@ }, "endowment:webassembly": {} }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index 67c98679a9..29cc1974fd 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "YvikqvHw0838qOaBrqjfegOyMSFM4ZwdyOH2qXode5M=", + "shasum": "EbfOl/zvZDz1RMTPV5xtXeqe2uorl9iaxHH2kGiRGko=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -21,5 +21,6 @@ "dapps": true } }, + "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/snaps-controllers/coverage.json b/packages/snaps-controllers/coverage.json index cb15fa2386..55aa5aaa9f 100644 --- a/packages/snaps-controllers/coverage.json +++ b/packages/snaps-controllers/coverage.json @@ -1,6 +1,6 @@ { - "branches": 92.63, + "branches": 92.67, "functions": 96.65, - "lines": 97.97, - "statements": 97.67 + "lines": 97.99, + "statements": 97.69 } diff --git a/packages/snaps-controllers/package.json b/packages/snaps-controllers/package.json index a94355dce6..daf6f486a6 100644 --- a/packages/snaps-controllers/package.json +++ b/packages/snaps-controllers/package.json @@ -102,6 +102,7 @@ "nanoid": "^3.1.31", "readable-stream": "^3.6.2", "readable-web-to-node-stream": "^3.0.2", + "semver": "^7.5.4", "tar-stream": "^3.1.7" }, "devDependencies": { @@ -125,6 +126,7 @@ "@types/mocha": "^10.0.1", "@types/node": "18.14.2", "@types/readable-stream": "^4.0.15", + "@types/semver": "^7.5.0", "@types/tar-stream": "^3.1.1", "@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/parser": "^6.21.0", diff --git a/packages/snaps-controllers/src/snaps/SnapController.test.tsx b/packages/snaps-controllers/src/snaps/SnapController.test.tsx index dad16aed3f..094f26e5e5 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.test.tsx +++ b/packages/snaps-controllers/src/snaps/SnapController.test.tsx @@ -23,6 +23,7 @@ import { AuxiliaryFileEncoding, text } from '@metamask/snaps-sdk'; import { Text } from '@metamask/snaps-sdk/jsx'; import type { SnapPermissions, RpcOrigins } from '@metamask/snaps-utils'; import { + getPlatformVersion, DEFAULT_ENDOWMENTS, DEFAULT_REQUESTED_SNAP_VERSION, getLocalizedSnapManifest, @@ -64,6 +65,7 @@ import { webcrypto } from 'crypto'; import fetchMock from 'jest-fetch-mock'; import { pipeline } from 'readable-stream'; import type { Duplex } from 'readable-stream'; +import semver from 'semver'; import { setupMultiplex } from '../services'; import type { NodeThreadExecutionService } from '../services/node'; @@ -5360,6 +5362,108 @@ describe('SnapController', () => { controller.destroy(); }); + it('does not throw an error if the manifest does not specify a platform version', async () => { + const rawManifest = getSnapManifest(); + delete rawManifest.platformVersion; + + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: rawManifest, + }); + + const messenger = getSnapControllerMessenger(); + const controller = getSnapController( + getSnapControllerOptions({ + messenger, + detectSnapLocation: loopbackDetect({ + manifest: manifest.result, + }), + }), + ); + + await expect( + controller.installSnaps(MOCK_ORIGIN, { + [MOCK_SNAP_ID]: {}, + }), + // eslint-disable-next-line jest/no-restricted-matchers + ).resolves.not.toThrow(); + + controller.destroy(); + }); + + it('throws an error if the specified platform version is newer than the supported platform version', async () => { + const newerVersion = semver.inc( + getPlatformVersion(), + 'minor', + ) as SemVerVersion; + + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: getSnapManifest({ + platformVersion: newerVersion, + }), + }); + + const messenger = getSnapControllerMessenger(); + const controller = getSnapController( + getSnapControllerOptions({ + messenger, + detectSnapLocation: loopbackDetect({ + manifest: manifest.result, + }), + }), + ); + + await expect( + controller.installSnaps(MOCK_ORIGIN, { + [MOCK_SNAP_ID]: {}, + }), + ).rejects.toThrow( + `The Snap requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, + ); + + controller.destroy(); + }); + + it('logs a warning if the specified platform version is newer than the supported platform version and `rejectInvalidPlatformVersion` is disabled', async () => { + const log = jest.spyOn(console, 'warn').mockImplementation(); + + const newerVersion = semver.inc( + getPlatformVersion(), + 'minor', + ) as SemVerVersion; + + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: getSnapManifest({ + platformVersion: newerVersion, + }), + }); + + const messenger = getSnapControllerMessenger(); + const controller = getSnapController( + getSnapControllerOptions({ + messenger, + featureFlags: { + rejectInvalidPlatformVersion: false, + }, + detectSnapLocation: loopbackDetect({ + manifest: manifest.result, + }), + }), + ); + + await expect( + controller.installSnaps(MOCK_ORIGIN, { + [MOCK_SNAP_ID]: {}, + }), + // eslint-disable-next-line jest/no-restricted-matchers + ).resolves.not.toThrow(); + + expect(log).toHaveBeenCalledWith( + `The Snap requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, + ); + + controller.destroy(); + }); + it('maps permission caveats to the proper format', async () => { const initialPermissions = { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/packages/snaps-controllers/src/snaps/SnapController.ts b/packages/snaps-controllers/src/snaps/SnapController.ts index 532ddf41d1..3361f467e3 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -63,6 +63,8 @@ import type { TruncatedSnapFields, } from '@metamask/snaps-utils'; import { + logWarning, + getPlatformVersion, assertIsSnapManifest, assertIsValidSnapId, DEFAULT_ENDOWMENTS, @@ -108,6 +110,7 @@ import type { StateMachine } from '@xstate/fsm'; import { createMachine, interpret } from '@xstate/fsm'; import type { Patch } from 'immer'; import { nanoid } from 'nanoid'; +import semver from 'semver'; import { forceStrict, validateMachine } from '../fsm'; import type { CreateInterface, GetInterface } from '../interface'; @@ -601,6 +604,7 @@ type FeatureFlags = { requireAllowlist?: boolean; allowLocalSnaps?: boolean; disableSnapInstallation?: boolean; + rejectInvalidPlatformVersion?: boolean; }; type DynamicFeatureFlags = { @@ -1337,6 +1341,7 @@ export class SnapController extends BaseController< const results = await this.messagingSystem.call('SnapsRegistry:get', { [snapId]: snapInfo, }); + const result = results[snapId]; if (result.status === SnapsRegistryStatus.Blocked) { throw new Error( @@ -2550,6 +2555,7 @@ export class SnapController extends BaseController< ); } + this.#validatePlatformVersion(manifest); await this.#assertIsInstallAllowed(snapId, { version: newVersion, checksum: manifest.source.shasum, @@ -2735,6 +2741,7 @@ export class SnapController extends BaseController< ); } + this.#validatePlatformVersion(manifest); await this.#assertIsInstallAllowed(snapId, { version: manifest.version, checksum: manifest.source.shasum, @@ -3010,6 +3017,32 @@ export class SnapController extends BaseController< ); } + /** + * Validate that the platform version specified in the manifest (if any) is + * compatible with the current platform version. + * + * @param manifest - The Snap manifest. + * @throws If the platform version is greater than the current platform + * version. + */ + #validatePlatformVersion(manifest: SnapManifest) { + if (manifest.platformVersion === undefined) { + return; + } + + if (semver.gt(manifest.platformVersion, getPlatformVersion())) { + const message = `The Snap requires platform version "${ + manifest.platformVersion + }" which is greater than the current platform version "${getPlatformVersion()}".`; + + if (this.#featureFlags.rejectInvalidPlatformVersion) { + throw new Error(message); + } + + logWarning(message); + } + } + /** * Initiates a request for the given snap's initial permissions. * Must be called in order. See processRequestedSnap. diff --git a/packages/snaps-controllers/src/snaps/registry/json.test.ts b/packages/snaps-controllers/src/snaps/registry/json.test.ts index b31afd1f78..eed626f789 100644 --- a/packages/snaps-controllers/src/snaps/registry/json.test.ts +++ b/packages/snaps-controllers/src/snaps/registry/json.test.ts @@ -66,7 +66,7 @@ const MOCK_DATABASE: SnapsRegistryDatabase = { // 3. Run the `sign-registry` script. // 4. Copy the signature from the `signature.json` file. const MOCK_SIGNATURE = - '0x304402201bfe1a98837631b669643135766de58deb426dc3eeb0a908c8000f85a047db3102207ac621072ea59737287099ac830323b34e59bfc41fb62119b16ce24d0c433f9e'; + '0x3045022100fd130773d66931560f199e783c48cf7d8c28d73ea8366add5b64ebcf61f98eca02206f6c56070d5d5899a50fea68add84570d5171c6fae812d4c3a89d5ccdcf396b2'; const MOCK_SIGNATURE_FILE = { signature: MOCK_SIGNATURE, curve: 'secp256k1', diff --git a/packages/snaps-controllers/src/test-utils/controller.ts b/packages/snaps-controllers/src/test-utils/controller.ts index bcb7e27708..52978aacaf 100644 --- a/packages/snaps-controllers/src/test-utils/controller.ts +++ b/packages/snaps-controllers/src/test-utils/controller.ts @@ -565,7 +565,10 @@ export const getSnapControllerOptions = ( environmentEndowmentPermissions: [], closeAllConnections: jest.fn(), messenger: getSnapControllerMessenger(), - featureFlags: { dappsCanUpdateSnaps: true }, + featureFlags: { + dappsCanUpdateSnaps: true, + rejectInvalidPlatformVersion: true, + }, state: undefined, fetchFunction: jest.fn(), getMnemonic: async () => Promise.resolve(TEST_SECRET_RECOVERY_PHRASE_BYTES), diff --git a/packages/snaps-utils/coverage.json b/packages/snaps-utils/coverage.json index 8676915a5a..102bd1c6df 100644 --- a/packages/snaps-utils/coverage.json +++ b/packages/snaps-utils/coverage.json @@ -1,6 +1,6 @@ { "branches": 99.74, - "functions": 98.92, + "functions": 98.93, "lines": 99.46, - "statements": 96.32 + "statements": 96.37 } diff --git a/packages/snaps-utils/src/index.ts b/packages/snaps-utils/src/index.ts index c3488c1d33..7cfb076bdf 100644 --- a/packages/snaps-utils/src/index.ts +++ b/packages/snaps-utils/src/index.ts @@ -22,6 +22,7 @@ export * from './logging'; export * from './manifest'; export * from './namespace'; export * from './path'; +export * from './platform-version'; export * from './snaps'; export * from './strings'; export * from './structs'; diff --git a/packages/snaps-utils/src/manifest/manifest.test.ts b/packages/snaps-utils/src/manifest/manifest.test.ts index c8486fa2bc..1b22eaabf2 100644 --- a/packages/snaps-utils/src/manifest/manifest.test.ts +++ b/packages/snaps-utils/src/manifest/manifest.test.ts @@ -2,10 +2,11 @@ import { promises as fs } from 'fs'; import { join } from 'path'; import { readJsonFile } from '../fs'; +import { getPlatformVersion } from '../platform-version'; +import { getSnapChecksum } from '../snaps'; import { DEFAULT_SNAP_BUNDLE, DEFAULT_SNAP_ICON, - DEFAULT_SNAP_SHASUM, MOCK_AUXILIARY_FILE, getPackageJson, getSnapManifest, @@ -33,6 +34,23 @@ const BASE_PATH = '/snap'; const MANIFEST_PATH = join(BASE_PATH, NpmSnapFileNames.Manifest); const PACKAGE_JSON_PATH = join(BASE_PATH, NpmSnapFileNames.PackageJson); +/** + * Get the default manifest for the current platform version. + * + * @returns The default manifest. + */ +// TODO: When we support top-level await, we can make this a constant variable, +// and remove this function. +async function getDefaultManifest() { + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: getSnapManifest({ + platformVersion: getPlatformVersion(), + }), + }); + + return manifest.result; +} + /** * Clears out all the files in the in-memory file system, and writes the default * files to the `BASE_PATH` folder, including sub-folders. @@ -46,7 +64,7 @@ async function resetFileSystem() { await fs.mkdir(join(BASE_PATH, 'src'), { recursive: true }); // Write default files. - await fs.writeFile(MANIFEST_PATH, JSON.stringify(getSnapManifest())); + await fs.writeFile(MANIFEST_PATH, JSON.stringify(await getDefaultManifest())); await fs.writeFile(PACKAGE_JSON_PATH, JSON.stringify(getPackageJson())); await fs.writeFile(join(BASE_PATH, 'dist/bundle.js'), DEFAULT_SNAP_BUNDLE); await fs.writeFile(join(BASE_PATH, 'images/icon.svg'), DEFAULT_SNAP_ICON); @@ -70,6 +88,7 @@ describe('checkManifest', () => { JSON.stringify( getSnapManifest({ shasum: '29MYwcRiruhy9BEJpN/TBIhxoD3t0P4OdXztV9rW8tc=', + platformVersion: getPlatformVersion(), }), ), ); @@ -78,14 +97,16 @@ describe('checkManifest', () => { const unfixed = reports.filter((report) => !report.wasFixed); const fixed = reports.filter((report) => report.wasFixed); - expect(files?.manifest.result).toStrictEqual(getSnapManifest()); + const defaultManifest = await getDefaultManifest(); + + expect(files?.manifest.result).toStrictEqual(defaultManifest); expect(updated).toBe(true); expect(unfixed).toHaveLength(0); expect(fixed).toHaveLength(1); const file = await readJsonFile(MANIFEST_PATH); const { source } = file.result; - expect(source.shasum).toBe(DEFAULT_SNAP_SHASUM); + expect(source.shasum).toBe(defaultManifest.source.shasum); }); it('fixes multiple problems in the manifest', async () => { @@ -95,6 +116,7 @@ describe('checkManifest', () => { getSnapManifest({ version: '0.0.1', shasum: '29MYwcRiruhy9BEJpN/TBIhxoD3t0P4OdXztV9rW8tc=', + platformVersion: getPlatformVersion(), }), ), ); @@ -103,14 +125,16 @@ describe('checkManifest', () => { const unfixed = reports.filter((report) => !report.wasFixed); const fixed = reports.filter((report) => report.wasFixed); - expect(files?.manifest.result).toStrictEqual(getSnapManifest()); + const defaultManifest = await getDefaultManifest(); + + expect(files?.manifest.result).toStrictEqual(defaultManifest); expect(updated).toBe(true); expect(unfixed).toHaveLength(0); expect(fixed).toHaveLength(2); const file = await readJsonFile(MANIFEST_PATH); const { source, version } = file.result; - expect(source.shasum).toBe(DEFAULT_SNAP_SHASUM); + expect(source.shasum).toBe(defaultManifest.source.shasum); expect(version).toBe('1.0.0'); }); @@ -148,7 +172,9 @@ describe('checkManifest', () => { }); it('returns a warning if manifest has with a non 1:1 ratio', async () => { - const manifest = getSnapManifest(); + const manifest = getSnapManifest({ + platformVersion: getPlatformVersion(), + }); await fs.writeFile( join(BASE_PATH, 'images/icon.svg'), @@ -165,27 +191,31 @@ describe('checkManifest', () => { }); it('return errors if the manifest is invalid', async () => { - await fs.writeFile( - MANIFEST_PATH, - JSON.stringify( - getSnapManifest({ - version: '0.0.1', - shasum: '1234567890123456789012345678901234567890123=', - }), - ), - ); + const manifest = getSnapManifest({ + version: '0.0.1', + shasum: '1234567890123456789012345678901234567890123=', + platformVersion: getPlatformVersion(), + }); + + await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)); const { reports } = await checkManifest(BASE_PATH, { updateAndWriteManifest: false, }); + const expectedChecksum = await getSnapChecksum( + getMockSnapFiles({ + manifest, + }), + ); + expect(reports).toHaveLength(2); // Make this test order independent // eslint-disable-next-line jest/prefer-strict-equal expect(reports.map(({ message }) => message)).toEqual( expect.arrayContaining([ '"snap.manifest.json" npm package version ("0.0.1") does not match the "package.json" "version" field ("1.0.0").', - '"snap.manifest.json" "shasum" field does not match computed shasum. Got "1234567890123456789012345678901234567890123=", expected "TVOA4znZze3/eDErYSzrFF6z67fu9cL70+ZfgUM6nCQ=".', + `"snap.manifest.json" "shasum" field does not match computed shasum. Got "1234567890123456789012345678901234567890123=", expected "${expectedChecksum}".`, ]), ); }); @@ -196,6 +226,7 @@ describe('checkManifest', () => { JSON.stringify( getSnapManifest({ locales: ['foo.json'], + platformVersion: getPlatformVersion(), }), ), ); @@ -215,6 +246,7 @@ describe('checkManifest', () => { const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ manifest: getSnapManifest({ locales: ['locales/en.json'], + platformVersion: getPlatformVersion(), }), localizationFiles: [localizationFile], }); @@ -242,6 +274,7 @@ describe('checkManifest', () => { manifest: getSnapManifest({ proposedName: '{{ name }}', locales: ['locales/en.json'], + platformVersion: getPlatformVersion(), }), localizationFiles: [localizationFile], }); diff --git a/packages/snaps-utils/src/manifest/manifest.ts b/packages/snaps-utils/src/manifest/manifest.ts index 8ae7554629..6e0e5cf312 100644 --- a/packages/snaps-utils/src/manifest/manifest.ts +++ b/packages/snaps-utils/src/manifest/manifest.ts @@ -24,7 +24,8 @@ const MANIFEST_SORT_ORDER: Record = { source: 6, initialConnections: 7, initialPermissions: 8, - manifestVersion: 9, + platformVersion: 9, + manifestVersion: 10, }; export type CheckManifestReport = Omit & { diff --git a/packages/snaps-utils/src/manifest/validation.ts b/packages/snaps-utils/src/manifest/validation.ts index 6ed252ae52..dd65132a10 100644 --- a/packages/snaps-utils/src/manifest/validation.ts +++ b/packages/snaps-utils/src/manifest/validation.ts @@ -292,6 +292,7 @@ export const SnapManifestStruct = object({ initialConnections: optional(InitialConnectionsStruct), initialPermissions: PermissionsStruct, manifestVersion: literal('0.1'), + platformVersion: optional(VersionStruct), $schema: optional(string()), // enables JSON-Schema linting in VSC and other IDEs }); diff --git a/packages/snaps-utils/src/manifest/validators/index.ts b/packages/snaps-utils/src/manifest/validators/index.ts index e27230b9cf..8fd5cfd760 100644 --- a/packages/snaps-utils/src/manifest/validators/index.ts +++ b/packages/snaps-utils/src/manifest/validators/index.ts @@ -8,6 +8,7 @@ export * from './is-snap-manifest'; export * from './manifest-localization'; export * from './package-json-recommended-fields'; export * from './package-name-match'; +export * from './platform-version'; export * from './repository-match'; export * from './version-match'; export * from './icon-declared'; diff --git a/packages/snaps-utils/src/manifest/validators/platform-version.test.ts b/packages/snaps-utils/src/manifest/validators/platform-version.test.ts new file mode 100644 index 0000000000..708c104cd5 --- /dev/null +++ b/packages/snaps-utils/src/manifest/validators/platform-version.test.ts @@ -0,0 +1,90 @@ +import { + getMockSnapFiles, + getSnapManifest, +} from '@metamask/snaps-utils/test-utils'; +import type { SemVerVersion } from '@metamask/utils'; +import assert from 'assert'; +import { createRequire } from 'module'; + +import { platformVersion } from './platform-version'; + +describe('platformVersion', () => { + const require = createRequire(__filename); + const packageJson = require.resolve('@metamask/snaps-sdk/package.json'); + // eslint-disable-next-line import/no-dynamic-require + const sdkVersion = require(packageJson).version; + + it('does nothing if the version matches', async () => { + const report = jest.fn(); + assert(platformVersion.semanticCheck); + + await platformVersion.semanticCheck( + getMockSnapFiles({ + manifest: getSnapManifest({ platformVersion: sdkVersion }), + manifestPath: __filename, + }), + { report }, + ); + + expect(report).toHaveBeenCalledTimes(0); + }); + + it('reports if the version is not set', async () => { + const report = jest.fn(); + assert(platformVersion.semanticCheck); + + const rawManifest = getSnapManifest(); + delete rawManifest.platformVersion; + + const files = getMockSnapFiles({ + manifest: rawManifest, + manifestPath: __filename, + }); + + await platformVersion.semanticCheck(files, { report }); + + expect(report).toHaveBeenCalledTimes(1); + expect(report).toHaveBeenCalledWith( + expect.stringContaining( + `The "platformVersion" field is missing from the manifest.`, + ), + expect.any(Function), + ); + + const fix = report.mock.calls[0][1]; + expect(fix).toBeInstanceOf(Function); + assert(fix); + + const { manifest } = await fix(files); + expect(manifest.platformVersion).toStrictEqual(sdkVersion); + }); + + it('reports if the version does not match', async () => { + const report = jest.fn(); + assert(platformVersion.semanticCheck); + + const files = getMockSnapFiles({ + manifest: getSnapManifest({ + platformVersion: '1.2.3' as SemVerVersion, + }), + manifestPath: __filename, + }); + + await platformVersion.semanticCheck(files, { report }); + + expect(report).toHaveBeenCalledTimes(1); + expect(report).toHaveBeenCalledWith( + expect.stringContaining( + `The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "1.2.3", expected "${sdkVersion}".`, + ), + expect.any(Function), + ); + + const fix = report.mock.calls[0][1]; + expect(fix).toBeInstanceOf(Function); + assert(fix); + + const { manifest } = await fix(files); + expect(manifest.platformVersion).toStrictEqual(sdkVersion); + }); +}); diff --git a/packages/snaps-utils/src/manifest/validators/platform-version.ts b/packages/snaps-utils/src/manifest/validators/platform-version.ts new file mode 100644 index 0000000000..f3393e8d23 --- /dev/null +++ b/packages/snaps-utils/src/manifest/validators/platform-version.ts @@ -0,0 +1,44 @@ +import { createRequire } from 'module'; + +import type { ValidatorMeta } from '../validator-types'; + +/** + * Check if the platform version in manifest matches the version of the Snaps + * SDK. + */ +export const platformVersion: ValidatorMeta = { + severity: 'error', + async semanticCheck(files, context) { + const manifestPlatformVersion = files.manifest.result.platformVersion; + + // Create a require function in the context of the location of the manifest + // file to avoid potentially loading the wrong version of the Snaps SDK. + const require = createRequire(files.manifest.path); + + const packageJson = require.resolve('@metamask/snaps-sdk/package.json'); + // eslint-disable-next-line import/no-dynamic-require + const actualVersion = require(packageJson).version; + + if (!manifestPlatformVersion) { + context.report( + 'The "platformVersion" field is missing from the manifest.', + ({ manifest }) => { + manifest.platformVersion = actualVersion; + return { manifest }; + }, + ); + + return; + } + + if (manifestPlatformVersion !== actualVersion) { + context.report( + `The "platformVersion" field in the manifest must match the version of the Snaps SDK. Got "${manifestPlatformVersion}", expected "${actualVersion}".`, + async ({ manifest }) => { + manifest.platformVersion = actualVersion; + return { manifest }; + }, + ); + } + }, +}; diff --git a/packages/snaps-utils/src/platform-version.test.ts b/packages/snaps-utils/src/platform-version.test.ts new file mode 100644 index 0000000000..16c12892c1 --- /dev/null +++ b/packages/snaps-utils/src/platform-version.test.ts @@ -0,0 +1,10 @@ +import { isValidSemVerVersion } from '@metamask/utils'; + +import { getPlatformVersion } from './platform-version'; + +describe('getPlatformVersion', () => { + it('returns the version of the SDK', () => { + const version = getPlatformVersion(); + expect(isValidSemVerVersion(version)).toBe(true); + }); +}); diff --git a/packages/snaps-utils/src/platform-version.ts b/packages/snaps-utils/src/platform-version.ts new file mode 100644 index 0000000000..c1013142a7 --- /dev/null +++ b/packages/snaps-utils/src/platform-version.ts @@ -0,0 +1,14 @@ +/** + * Get the current supported platform version. + * + * Note: This function assumes that the same SDK version is used across all + * dependencies. If this is not the case, the version of the SDK that is + * closest to the `snaps-utils` package will be returned. + * + * @returns The platform version. + */ +export function getPlatformVersion() { + const packageJson = require.resolve('@metamask/snaps-sdk/package.json'); + // eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires + return require(packageJson).version; +} diff --git a/packages/snaps-utils/src/test-utils/manifest.ts b/packages/snaps-utils/src/test-utils/manifest.ts index b6e2fff84f..a07bf7ed83 100644 --- a/packages/snaps-utils/src/test-utils/manifest.ts +++ b/packages/snaps-utils/src/test-utils/manifest.ts @@ -16,6 +16,7 @@ type GetSnapManifestOptions = Partial> & { iconPath?: string; files?: string[]; locales?: string[]; + platformVersion?: string; }; type GetPackageJsonOptions = Partial>; @@ -69,7 +70,8 @@ export const ALTERNATIVE_SNAP_ICON = // This will need to be recalculated if the checksum inputs change. export const DEFAULT_SNAP_SHASUM = - 'rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg='; + '/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE='; + /** * Get a mock snap manifest, based on the provided options. This is useful for * quickly generating a manifest file, while being able to override any of the @@ -88,6 +90,7 @@ export const DEFAULT_SNAP_SHASUM = * @param manifest.files - Auxiliary files loaded at runtime by the snap. * @param manifest.locales - Localization files of the snap. * @param manifest.initialConnections - Initial connections for the snap. + * @param manifest.platformVersion - The platform version of the snap. * @returns The snap manifest. */ export const getSnapManifest = ({ @@ -103,6 +106,7 @@ export const getSnapManifest = ({ files = undefined, locales = undefined, initialConnections = undefined, + platformVersion = '1.0.0' as SemVerVersion, }: GetSnapManifestOptions = {}): SnapManifest => { return { version: version as SemVerVersion, @@ -124,6 +128,7 @@ export const getSnapManifest = ({ }, ...(initialConnections ? { initialConnections } : {}), initialPermissions, + platformVersion, manifestVersion: '0.1' as const, }; }; @@ -159,6 +164,7 @@ export const getPackageJson = ({ export const getMockSnapFiles = ({ manifest = getSnapManifest(), + manifestPath = DEFAULT_MANIFEST_PATH, packageJson = getPackageJson(), sourceCode = DEFAULT_SNAP_BUNDLE, svgIcon = DEFAULT_SNAP_ICON, @@ -166,6 +172,7 @@ export const getMockSnapFiles = ({ localizationFiles = [], }: { manifest?: SnapManifest | VirtualFile; + manifestPath?: string; sourceCode?: string | VirtualFile; packageJson?: NpmSnapPackageJson; svgIcon?: string | VirtualFile; @@ -179,7 +186,7 @@ export const getMockSnapFiles = ({ : new VirtualFile({ value: JSON.stringify(manifest), result: manifest, - path: DEFAULT_MANIFEST_PATH, + path: manifestPath, }), packageJson: new VirtualFile({ value: JSON.stringify(packageJson), diff --git a/yarn.lock b/yarn.lock index 835c9e7f6f..b2742a032e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5746,6 +5746,7 @@ __metadata: "@types/mocha": "npm:^10.0.1" "@types/node": "npm:18.14.2" "@types/readable-stream": "npm:^4.0.15" + "@types/semver": "npm:^7.5.0" "@types/tar-stream": "npm:^3.1.1" "@typescript-eslint/eslint-plugin": "npm:^5.42.1" "@typescript-eslint/parser": "npm:^6.21.0" @@ -5786,6 +5787,7 @@ __metadata: readable-stream: "npm:^3.6.2" readable-web-to-node-stream: "npm:^3.0.2" rimraf: "npm:^4.1.2" + semver: "npm:^7.5.4" tar-stream: "npm:^3.1.7" ts-node: "npm:^10.9.1" typescript: "npm:~5.3.3" From cf9c97f22e8f339055ede39263f5f76e3250f3aa Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 7 Oct 2024 17:50:53 +0200 Subject: [PATCH 02/11] Fix some tests --- .../src/commands/build/implementation.test.ts | 13 ++++++++-- .../commands/manifest/implementation.test.ts | 26 ++++++++++++------- .../snaps-webpack-plugin/src/manifest.test.ts | 9 ++++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/packages/snaps-cli/src/commands/build/implementation.test.ts b/packages/snaps-cli/src/commands/build/implementation.test.ts index 40e6246cc8..79ff01c15a 100644 --- a/packages/snaps-cli/src/commands/build/implementation.test.ts +++ b/packages/snaps-cli/src/commands/build/implementation.test.ts @@ -1,5 +1,8 @@ +import { getPlatformVersion } from '@metamask/snaps-utils'; import { DEFAULT_SNAP_BUNDLE, + DEFAULT_SNAP_ICON, + getMockSnapFilesWithUpdatedChecksum, getPackageJson, getSnapManifest, } from '@metamask/snaps-utils/test-utils'; @@ -61,15 +64,21 @@ jest.mock('../../webpack/utils', () => ({ describe('build', () => { beforeEach(async () => { + const { manifest } = await getMockSnapFilesWithUpdatedChecksum({ + manifest: getSnapManifest({ + platformVersion: getPlatformVersion(), + }), + }); + await fs.mkdir('/snap'); await fs.writeFile('/snap/input.js', DEFAULT_SNAP_BUNDLE); await fs.writeFile( '/snap/snap.manifest.json', - JSON.stringify(getSnapManifest()), + JSON.stringify(manifest.result), ); await fs.writeFile('/snap/package.json', JSON.stringify(getPackageJson())); await fs.mkdir('/snap/images'); - await fs.writeFile('/snap/images/icon.svg', ''); + await fs.writeFile('/snap/images/icon.svg', DEFAULT_SNAP_ICON); await fs.mkdir(dirname(BROWSERSLIST_FILE), { recursive: true }); await fs.writeFile( BROWSERSLIST_FILE, diff --git a/packages/snaps-cli/src/commands/manifest/implementation.test.ts b/packages/snaps-cli/src/commands/manifest/implementation.test.ts index 792e100dc1..83acf966a2 100644 --- a/packages/snaps-cli/src/commands/manifest/implementation.test.ts +++ b/packages/snaps-cli/src/commands/manifest/implementation.test.ts @@ -1,5 +1,8 @@ +import { getPlatformVersion } from '@metamask/snaps-utils'; import { DEFAULT_SNAP_BUNDLE, + DEFAULT_SNAP_ICON, + getMockSnapFilesWithUpdatedChecksum, getPackageJson, getSnapManifest, } from '@metamask/snaps-utils/test-utils'; @@ -32,19 +35,23 @@ jest.mock('../../webpack', () => ({ describe('manifest', () => { beforeEach(async () => { + const { manifest: newManifest } = await getMockSnapFilesWithUpdatedChecksum( + { + manifest: getSnapManifest({ + platformVersion: getPlatformVersion(), + }), + }, + ); + await fs.mkdir('/snap/dist', { recursive: true }); await fs.writeFile('/snap/dist/bundle.js', DEFAULT_SNAP_BUNDLE); await fs.writeFile( '/snap/snap.manifest.json', - JSON.stringify( - getSnapManifest({ - shasum: 'G/W5b2JZVv+epgNX9pkN63X6Lye9EJVJ4NLSgAw/afc=', - }), - ), + JSON.stringify(newManifest.result), ); await fs.writeFile('/snap/package.json', JSON.stringify(getPackageJson())); await fs.mkdir('/snap/images'); - await fs.writeFile('/snap/images/icon.svg', ''); + await fs.writeFile('/snap/images/icon.svg', DEFAULT_SNAP_ICON); }); afterEach(async () => { @@ -52,9 +59,9 @@ describe('manifest', () => { }); it('validates a snap manifest', async () => { - const error = jest.spyOn(console, 'error').mockImplementation(); + const error = jest.spyOn(console, 'error'); const warn = jest.spyOn(console, 'warn').mockImplementation(); - const log = jest.spyOn(console, 'log').mockImplementation(); + const log = jest.spyOn(console, 'log'); const spinner = ora(); const result = await manifest('/snap/snap.manifest.json', false, spinner); @@ -157,7 +164,7 @@ describe('manifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "d4W7f1lzpVGMj8jjCn1lYhhHmKc/9TSk5QLH5ldKQoI=", + "shasum": "c3Dn62ZSKu7fATN+40MhI9UqEInE9qE7u5tDjb7ylyk=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -172,6 +179,7 @@ describe('manifest', () => { "chains": ["eip155:1", "eip155:2", "eip155:3"] } }, + "platformVersion": "6.7.0", "manifestVersion": "0.1" } " diff --git a/packages/snaps-webpack-plugin/src/manifest.test.ts b/packages/snaps-webpack-plugin/src/manifest.test.ts index 163fb71551..451ccb5701 100644 --- a/packages/snaps-webpack-plugin/src/manifest.test.ts +++ b/packages/snaps-webpack-plugin/src/manifest.test.ts @@ -26,7 +26,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -40,6 +40,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " @@ -63,7 +64,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -77,6 +78,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " @@ -99,7 +101,7 @@ describe('writeManifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "rNyfINgNh161cBmUop+F7xlE+GSEDZH53Y/HDpGLGGg=", + "shasum": "/17SwI03+Cn9sk45Z6Czp+Sktru1oLzOmkJW+YbP9WE=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -113,6 +115,7 @@ describe('writeManifest', () => { "snap_dialog": {}, "endowment:rpc": { "snaps": true, "dapps": false } }, + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " From fe8bf2b55dbed60d4a5fdf1cad73482a3f27f67a Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 7 Oct 2024 17:55:59 +0200 Subject: [PATCH 03/11] Fix lint error --- .../src/manifest/validators/platform-version.test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/snaps-utils/src/manifest/validators/platform-version.test.ts b/packages/snaps-utils/src/manifest/validators/platform-version.test.ts index 708c104cd5..5d101530a8 100644 --- a/packages/snaps-utils/src/manifest/validators/platform-version.test.ts +++ b/packages/snaps-utils/src/manifest/validators/platform-version.test.ts @@ -1,11 +1,8 @@ -import { - getMockSnapFiles, - getSnapManifest, -} from '@metamask/snaps-utils/test-utils'; import type { SemVerVersion } from '@metamask/utils'; import assert from 'assert'; import { createRequire } from 'module'; +import { getMockSnapFiles, getSnapManifest } from '../../test-utils'; import { platformVersion } from './platform-version'; describe('platformVersion', () => { From 8b55f08f41ae20cc95710371b072d24ee25731aa Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 9 Oct 2024 10:41:02 +0200 Subject: [PATCH 04/11] Simplify `getPlatformVersion` function --- packages/snaps-utils/src/platform-version.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/snaps-utils/src/platform-version.ts b/packages/snaps-utils/src/platform-version.ts index c1013142a7..c2880ebe2a 100644 --- a/packages/snaps-utils/src/platform-version.ts +++ b/packages/snaps-utils/src/platform-version.ts @@ -8,7 +8,6 @@ * @returns The platform version. */ export function getPlatformVersion() { - const packageJson = require.resolve('@metamask/snaps-sdk/package.json'); // eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires - return require(packageJson).version; + return require('@metamask/snaps-sdk/package.json').version; } From fe59029fa889a227d42d85a61f71972fcdcc9bf3 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Wed, 9 Oct 2024 10:45:09 +0200 Subject: [PATCH 05/11] Temporarily remove CLI logic --- packages/snaps-utils/src/manifest/validators/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/snaps-utils/src/manifest/validators/index.ts b/packages/snaps-utils/src/manifest/validators/index.ts index 8fd5cfd760..50ba6fe985 100644 --- a/packages/snaps-utils/src/manifest/validators/index.ts +++ b/packages/snaps-utils/src/manifest/validators/index.ts @@ -8,7 +8,8 @@ export * from './is-snap-manifest'; export * from './manifest-localization'; export * from './package-json-recommended-fields'; export * from './package-name-match'; -export * from './platform-version'; +// TODO: Uncomment the following line after the next release. +// export * from './platform-version'; export * from './repository-match'; export * from './version-match'; export * from './icon-declared'; From 58dad1ef3e3e5ecbb99e63de6aa809d30f55983d Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 13:05:36 +0200 Subject: [PATCH 06/11] Remove platform version fields from examples --- packages/examples/packages/bip32/snap.manifest.json | 1 - packages/examples/packages/bip44/snap.manifest.json | 1 - .../examples/packages/browserify-plugin/snap.manifest.json | 1 - packages/examples/packages/browserify/snap.manifest.json | 1 - packages/examples/packages/client-status/snap.manifest.json | 1 - packages/examples/packages/cronjobs/snap.manifest.json | 1 - packages/examples/packages/dialogs/snap.manifest.json | 1 - packages/examples/packages/errors/snap.manifest.json | 1 - .../examples/packages/ethereum-provider/snap.manifest.json | 1 - packages/examples/packages/ethers-js/snap.manifest.json | 1 - packages/examples/packages/file-upload/snap.manifest.json | 1 - packages/examples/packages/get-entropy/snap.manifest.json | 1 - packages/examples/packages/get-file/snap.manifest.json | 1 - packages/examples/packages/home-page/snap.manifest.json | 1 - packages/examples/packages/images/snap.manifest.json | 1 - packages/examples/packages/interactive-ui/snap.manifest.json | 1 - .../invoke-snap/packages/consumer-signer/snap.manifest.json | 1 - .../invoke-snap/packages/core-signer/snap.manifest.json | 1 - packages/examples/packages/jsx/snap.manifest.json | 1 - packages/examples/packages/lifecycle-hooks/snap.manifest.json | 1 - packages/examples/packages/localization/snap.manifest.json | 1 - packages/examples/packages/manage-state/snap.manifest.json | 1 - packages/examples/packages/name-lookup/snap.manifest.json | 1 - packages/examples/packages/network-access/snap.manifest.json | 1 - packages/examples/packages/notifications/snap.manifest.json | 1 - packages/examples/packages/preinstalled/snap.manifest.json | 1 - packages/examples/packages/rollup-plugin/snap.manifest.json | 1 - packages/examples/packages/send-flow/snap.manifest.json | 1 - .../examples/packages/signature-insights/snap.manifest.json | 1 - .../examples/packages/transaction-insights/snap.manifest.json | 1 - packages/examples/packages/wasm/snap.manifest.json | 1 - packages/examples/packages/webpack-plugin/snap.manifest.json | 1 - .../snaps-cli/src/commands/manifest/implementation.test.ts | 4 ++-- 33 files changed, 2 insertions(+), 34 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index a796c0480e..d8f9dd8bfe 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -43,6 +43,5 @@ } ] }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index a81c964a7a..b7ae3156ce 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -31,6 +31,5 @@ } ] }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index b1b59f9019..fe88e1e176 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 4c8f349fa5..0e01d05a45 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index abebd241ff..54650ae18d 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -22,6 +22,5 @@ "snaps": false } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index db0a10751b..da3b9f7245 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -29,6 +29,5 @@ }, "snap_dialog": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index 50bec984e6..f87f1b0d39 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -22,6 +22,5 @@ }, "snap_dialog": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/errors/snap.manifest.json b/packages/examples/packages/errors/snap.manifest.json index d3bd192d90..20439d39f0 100644 --- a/packages/examples/packages/errors/snap.manifest.json +++ b/packages/examples/packages/errors/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 6c5552ac91..cea80cdb77 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -22,6 +22,5 @@ }, "endowment:ethereum-provider": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index 12440a7f07..1a68973dc1 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -23,6 +23,5 @@ "snap_dialog": {}, "snap_getEntropy": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index 46337fe07c..44b23de48e 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -24,6 +24,5 @@ "snap_dialog": {}, "snap_manageState": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index 35773661c6..6a213c1a32 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -23,6 +23,5 @@ "snap_dialog": {}, "snap_getEntropy": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index ffef5e610e..d5b6bfdd62 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -22,6 +22,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 82507f75a4..f92a6a8d6c 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -19,6 +19,5 @@ "initialPermissions": { "endowment:page-home": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 0576f51aa5..84d8023018 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -23,6 +23,5 @@ }, "snap_dialog": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index 5c98fccc35..b08dda53d6 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -25,6 +25,5 @@ "endowment:transaction-insight": {}, "endowment:page-home": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index d616aa5076..ed43242157 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index d742db564f..b52cc08d98 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -23,6 +23,5 @@ "snap_dialog": {}, "snap_manageState": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index b2ed52d556..457b93ed47 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -23,6 +23,5 @@ "snap_dialog": {}, "snap_manageState": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index 0132d3566c..ba5e5b7c06 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -20,6 +20,5 @@ "snap_dialog": {}, "endowment:lifecycle-hooks": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index e4abf19373..e9d3db620f 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -23,6 +23,5 @@ }, "snap_getPreferences": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index af9570270e..7eb8242a32 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -22,6 +22,5 @@ }, "snap_manageState": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/name-lookup/snap.manifest.json b/packages/examples/packages/name-lookup/snap.manifest.json index 8283ef6fdc..5445bddfdd 100644 --- a/packages/examples/packages/name-lookup/snap.manifest.json +++ b/packages/examples/packages/name-lookup/snap.manifest.json @@ -21,6 +21,5 @@ "chains": ["eip155:1"] } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index 135743366d..652bd47528 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -23,6 +23,5 @@ }, "endowment:network-access": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index a5d25f0cd6..33d5fd553a 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -22,6 +22,5 @@ }, "snap_notify": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/preinstalled/snap.manifest.json b/packages/examples/packages/preinstalled/snap.manifest.json index 7362e1feaa..990c07b2ca 100644 --- a/packages/examples/packages/preinstalled/snap.manifest.json +++ b/packages/examples/packages/preinstalled/snap.manifest.json @@ -22,6 +22,5 @@ }, "snap_dialog": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 04b5e963d1..6abea39e02 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/send-flow/snap.manifest.json b/packages/examples/packages/send-flow/snap.manifest.json index 67e8d20ed9..cddd0c2348 100644 --- a/packages/examples/packages/send-flow/snap.manifest.json +++ b/packages/examples/packages/send-flow/snap.manifest.json @@ -23,6 +23,5 @@ "snap_dialog": {}, "endowment:page-home": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index 1f2ce2b0cc..28222abac3 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -19,6 +19,5 @@ "initialPermissions": { "endowment:signature-insight": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index 95fe2ac45b..aaec26245e 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -19,6 +19,5 @@ "initialPermissions": { "endowment:transaction-insight": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index 8e34137842..f5d2b4a2be 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -22,6 +22,5 @@ }, "endowment:webassembly": {} }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index 29cc1974fd..2a6eb9b691 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -21,6 +21,5 @@ "dapps": true } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } diff --git a/packages/snaps-cli/src/commands/manifest/implementation.test.ts b/packages/snaps-cli/src/commands/manifest/implementation.test.ts index 83acf966a2..8ad1dcf7cb 100644 --- a/packages/snaps-cli/src/commands/manifest/implementation.test.ts +++ b/packages/snaps-cli/src/commands/manifest/implementation.test.ts @@ -164,7 +164,7 @@ describe('manifest', () => { "url": "https://github.com/MetaMask/example-snap.git" }, "source": { - "shasum": "c3Dn62ZSKu7fATN+40MhI9UqEInE9qE7u5tDjb7ylyk=", + "shasum": "itjh0enng42nO6BxNCEhDH8wm3yl4xlVclfd5LsZ2wA=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -179,7 +179,7 @@ describe('manifest', () => { "chains": ["eip155:1", "eip155:2", "eip155:3"] } }, - "platformVersion": "6.7.0", + "platformVersion": "1.0.0", "manifestVersion": "0.1" } " From 77ab66ee0928ee5b988cc35af4580212342ec6c0 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 13:13:47 +0200 Subject: [PATCH 07/11] Fix example shasum --- packages/examples/packages/json-rpc/snap.manifest.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index 1a022b719d..4ca36a011d 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "jQeujNPPhG8qpKR+KRBod55gAR3Qu+NoffIM8kBbW2M=", + "shasum": "loHXuvuW/Zb4kMSSdekMiV20UVtxXYyoDC0iRZbV274=", "location": { "npm": { "filePath": "dist/bundle.js", @@ -26,6 +26,5 @@ } } }, - "platformVersion": "6.9.0", "manifestVersion": "0.1" } From 50b8f80fcef05fe7e0966763a04c997cf5c4875d Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 13:21:30 +0200 Subject: [PATCH 08/11] Move `#validatePlatformVersion` call to `#assertIsInstallAllowed` --- .../src/snaps/SnapController.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/snaps-controllers/src/snaps/SnapController.ts b/packages/snaps-controllers/src/snaps/SnapController.ts index 3361f467e3..e12f29ad35 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -1336,7 +1336,10 @@ export class SnapController extends BaseController< async #assertIsInstallAllowed( snapId: SnapId, - snapInfo: SnapsRegistryInfo & { permissions: SnapPermissions }, + snapInfo: SnapsRegistryInfo & { + permissions: SnapPermissions; + platformVersion: string | undefined; + }, ) { const results = await this.messagingSystem.call('SnapsRegistry:get', { [snapId]: snapInfo, @@ -1370,6 +1373,8 @@ export class SnapController extends BaseController< }`, ); } + + this.#validatePlatformVersion(snapId, snapInfo.platformVersion); } /** @@ -2555,11 +2560,11 @@ export class SnapController extends BaseController< ); } - this.#validatePlatformVersion(manifest); await this.#assertIsInstallAllowed(snapId, { version: newVersion, checksum: manifest.source.shasum, permissions: manifest.initialPermissions, + platformVersion: manifest.platformVersion, }); const processedPermissions = processSnapPermissions( @@ -2741,11 +2746,11 @@ export class SnapController extends BaseController< ); } - this.#validatePlatformVersion(manifest); await this.#assertIsInstallAllowed(snapId, { version: manifest.version, checksum: manifest.source.shasum, permissions: manifest.initialPermissions, + platformVersion: manifest.platformVersion, }); return this.#set({ @@ -3021,19 +3026,21 @@ export class SnapController extends BaseController< * Validate that the platform version specified in the manifest (if any) is * compatible with the current platform version. * - * @param manifest - The Snap manifest. + * @param snapId - The ID of the Snap. + * @param platformVersion - The platform version to validate against. * @throws If the platform version is greater than the current platform * version. */ - #validatePlatformVersion(manifest: SnapManifest) { - if (manifest.platformVersion === undefined) { + #validatePlatformVersion( + snapId: SnapId, + platformVersion: string | undefined, + ) { + if (platformVersion === undefined) { return; } - if (semver.gt(manifest.platformVersion, getPlatformVersion())) { - const message = `The Snap requires platform version "${ - manifest.platformVersion - }" which is greater than the current platform version "${getPlatformVersion()}".`; + if (semver.gt(platformVersion, getPlatformVersion())) { + const message = `The Snap "${snapId}" requires platform version "${platformVersion}" which is greater than the current platform version "${getPlatformVersion()}".`; if (this.#featureFlags.rejectInvalidPlatformVersion) { throw new Error(message); From 9cbcdeb9c5a76f1b8d79353b057c3a1186850d11 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 13:34:20 +0200 Subject: [PATCH 09/11] Fix example shasums --- packages/examples/packages/bip32/snap.manifest.json | 2 +- packages/examples/packages/bip44/snap.manifest.json | 2 +- packages/examples/packages/browserify-plugin/snap.manifest.json | 2 +- packages/examples/packages/browserify/snap.manifest.json | 2 +- packages/examples/packages/client-status/snap.manifest.json | 2 +- packages/examples/packages/cronjobs/snap.manifest.json | 2 +- packages/examples/packages/dialogs/snap.manifest.json | 2 +- packages/examples/packages/errors/snap.manifest.json | 2 +- packages/examples/packages/ethereum-provider/snap.manifest.json | 2 +- packages/examples/packages/ethers-js/snap.manifest.json | 2 +- packages/examples/packages/file-upload/snap.manifest.json | 2 +- packages/examples/packages/get-entropy/snap.manifest.json | 2 +- packages/examples/packages/get-file/snap.manifest.json | 2 +- packages/examples/packages/home-page/snap.manifest.json | 2 +- packages/examples/packages/images/snap.manifest.json | 2 +- packages/examples/packages/interactive-ui/snap.manifest.json | 2 +- .../invoke-snap/packages/consumer-signer/snap.manifest.json | 2 +- .../invoke-snap/packages/core-signer/snap.manifest.json | 2 +- packages/examples/packages/jsx/snap.manifest.json | 2 +- packages/examples/packages/lifecycle-hooks/snap.manifest.json | 2 +- packages/examples/packages/localization/snap.manifest.json | 2 +- packages/examples/packages/manage-state/snap.manifest.json | 2 +- packages/examples/packages/name-lookup/snap.manifest.json | 2 +- packages/examples/packages/network-access/snap.manifest.json | 2 +- packages/examples/packages/notifications/snap.manifest.json | 2 +- packages/examples/packages/preinstalled/snap.manifest.json | 2 +- packages/examples/packages/rollup-plugin/snap.manifest.json | 2 +- packages/examples/packages/send-flow/snap.manifest.json | 2 +- .../examples/packages/signature-insights/snap.manifest.json | 2 +- .../examples/packages/transaction-insights/snap.manifest.json | 2 +- packages/examples/packages/wasm/snap.manifest.json | 2 +- packages/examples/packages/webpack-plugin/snap.manifest.json | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index d8f9dd8bfe..4b9136702f 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "C+PL5IlfLt5gJSrLw67s5xqCUuTquV0i5P6mVIEyzvc=", + "shasum": "PxNHa0ebJ1qA/LXiY4vTzUsBKNl3rdfbHwg198YtOH4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index b7ae3156ce..2c39cfc189 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "HsQqFbJSviMTXT4kNx+Cw8o4Q3tbpMmazitpC5e4J4w=", + "shasum": "Nb4y6u121k+rnDRGblkG77S7s9IFt1TZTQeSZOXNdyY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index fe88e1e176..3fa785166d 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "TaJFXpS2ECCYQrYEPzvvtV+iN9agVwDfVaU5fG4nDps=", + "shasum": "zA6fni0b6B+ELhkMRiw6vcAgKj1/9A/Rm+dxkPY/oxM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 0e01d05a45..1f1ce212a2 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "aGkLvDgAQnByDlFaRayI2zI8CbJ/9Jci5bFBi2YYmI8=", + "shasum": "diJJzn5l3lSAKQvHldlYmQXjTcO/IDnLOnxH7kGmkW0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 54650ae18d..722cc84de1 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "zbzbZ5RbBUMDZewEZ+19Mfq5/JZNcabBuBKLFcjdYhY=", + "shasum": "fyBeeuYGaIpBnxm6MVoRe19JR+8QiIeFtJM+nlOWnsU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index da3b9f7245..72e5804a10 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "aRkKWMsk1fg+bW/DxO0Ff1dgcIXvVbcdMlFKCaW82sE=", + "shasum": "52lYQY0bh6ZtKx4ZNtQNO17ustuhQBewko/WzQkS68A=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index f87f1b0d39..75edcaa8a6 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "/7vhR2s6a2hwLS31z0IQMGwYrLmUMthVNJuEXrdrZxA=", + "shasum": "v2oIs3UY5j/3dXW5eRh3rg7Tv5qcVzHon7qzPQeRsAE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/errors/snap.manifest.json b/packages/examples/packages/errors/snap.manifest.json index 20439d39f0..f4e1bff846 100644 --- a/packages/examples/packages/errors/snap.manifest.json +++ b/packages/examples/packages/errors/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "wztrad9mrmSL20LAQN0oYVOUBaB9EGBJRLK2sxCFzPA=", + "shasum": "yBkP0yx/0fYCe3r3hglrIJJAXuxTgMpCsR0HMJ/KV7o=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index cea80cdb77..80264829d5 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9fmgm42mFtb9fhjnLylggCUE8jF+inUUYdqwZWxulGU=", + "shasum": "pSiTZjO5nox8zYh+fQtQfZLp5HwbxKByu+WOo+tAAH0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index 1a68973dc1..ff001e07a2 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "8Z62OTAMc1vl1gT8pa/5dUlGnZ9V0A6AoCIZs66IgaY=", + "shasum": "3ec/uMXW2lAaVxSJJRjsAmQ1oSqVJpHUkF4i4YTa9Gk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index 44b23de48e..a34c9a115e 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "01klLEVRzNMW3bQor2YoGD7CQQ2/9+XvCja+s1KeVnA=", + "shasum": "z4vMdrs40TdVE+vk7sPruIvWi0q669V+p3jc6WQIib4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index 6a213c1a32..eaa27579dd 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "EfFv98OsBbvYmS8Jzxnv4WX6kgU+lAwckpbNCKWU93g=", + "shasum": "OYSzxQ1qHApZ2MHWvQ/XYWRwKJptpyVQ5VgyhgFEmmo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index d5b6bfdd62..771cf66e98 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "P+Naux1efbcYAPhgOs9Kn77QwhdRvVFeBe3kuYJt0vY=", + "shasum": "aTuxZCIXcq/FP7XjSoBY4e4pHQbuoDJ1U6FUe/rAfiQ=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index f92a6a8d6c..3afc05d1c9 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "46WN8y6FgObZQUc1R6t8G8RDxXJlgGAM2PzyL/Do+jA=", + "shasum": "emnlXHvrhsGBMi/y1IPhiQPX9ogHmjmOU/iujBu5GB8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 84d8023018..d0a0d9eef2 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "94CNMWQRWTxxJH0yZ+oKrU8A3BvAwaOTfvHH3bRpj1I=", + "shasum": "kbuZtLjZiY9+HOtc7DIpuGUjMes2id67dES3Ze/Z3dY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index b08dda53d6..16385ab7df 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "1wPPQqfkexl9jjQFKDdhNbEzQJjkbe94yCd7uinD7Wo=", + "shasum": "Q2JcD7CoRLqjextX7QhYK6SOIK6ROF4NpvbUEwtITe8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index ed43242157..fe8c817357 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "xK+0xffragaVg05a1zQMIbcibBNwAdKJnOdCTxVPH7Y=", + "shasum": "KFAIwiPcEKSJL79+hVHmZPCTIrqAnWJN7uM7vFuaDj0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index b52cc08d98..0367556298 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "JqTuGspBroEi3vLyCIPs09qFFQJwZ1aD/fovVToIPRw=", + "shasum": "EMv6OrPDoNKIb8YjY5cbjumuwN8Oz3x6ASB1AODM/jM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index 457b93ed47..f9a9c92dcf 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "InQK+TFR3jg4Zs/ZwfCSS9iMwafkzdR/Jhbdi6/d6d8=", + "shasum": "3U9+Lvmmdc9JRmaHLcwGgi9lpnaj25joBF9+zXY4644=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index ba5e5b7c06..bd7003b5f6 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "UBfsZeBErxBxxe7K+JAjSKIvOl4SZ9x1bsNBnaQLSTQ=", + "shasum": "U+ry3tQOBH2gb+WQYNBYTqKst27YLCCNPNrL3mzwxY8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index e9d3db620f..66585bec34 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ZpSw3wbSVW4bCNxWU02BVrH5uHpvngd9B+i/ATDiKqo=", + "shasum": "KHrWdamfUEJ10ak4/oE/C4/oTO9BRnLSLjOiS9RFlHw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index 7eb8242a32..bb792bf7a1 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "jen+Zz1ISbr1EaWj2oYgHO7JL7GHr4kRjc4QblUP3P4=", + "shasum": "5FNiUEpsrVxG3rTbJvhx/IBZ/jIYYu0ZbnCX9A6dAPE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/name-lookup/snap.manifest.json b/packages/examples/packages/name-lookup/snap.manifest.json index 5445bddfdd..a32e40a940 100644 --- a/packages/examples/packages/name-lookup/snap.manifest.json +++ b/packages/examples/packages/name-lookup/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "eEhkb8o8fsXQxY+NetYLNdkRUljzT/qdZCYs338uc/8=", + "shasum": "xk7O5itVsuV3Dfldq3rI3WgggHa3z7HX7e17jzheE8w=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index 652bd47528..39bb82c00e 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "OsZifnVDWfwM5/f4jO0+ttIFKO9M5VZmqtGUGN7Knm4=", + "shasum": "+V4EDf0266FOJDTVrhQ91ZaycBruUesJqSoAzohWnO0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index 33d5fd553a..db46bad3d9 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "nuIHOpoyl/f5twY5vKHdsK29N8bAFFkp3jSb0I5Gi28=", + "shasum": "S3wZGdkOLX7tdJYssmy+UxBXe+VuwZaNUQNqK+G3hu4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/preinstalled/snap.manifest.json b/packages/examples/packages/preinstalled/snap.manifest.json index 990c07b2ca..cf6a42afee 100644 --- a/packages/examples/packages/preinstalled/snap.manifest.json +++ b/packages/examples/packages/preinstalled/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "j6Oifwy3b46n82GjfzR5WSS22qa3ZYRTHZGLczJtSMM=", + "shasum": "KUHZC+FvI4Ll48Ngy9ufvs6CFMsxqaNVw+dd2iyRNNE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 6abea39e02..f9310a6e8a 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "dmIJl9Tp4iR0GTfe+RwO1QAgZIJVHQ4p6q8U3tf1fXw=", + "shasum": "FvkhD/R3iN0i/0P4OTlD0rPX+697OZ0a5kns8T669Jk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/send-flow/snap.manifest.json b/packages/examples/packages/send-flow/snap.manifest.json index cddd0c2348..f2ff99c36e 100644 --- a/packages/examples/packages/send-flow/snap.manifest.json +++ b/packages/examples/packages/send-flow/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "a+ldFYz6DKWCG7g2mCOORwWwJi/2jECIODp33wnzZkQ=", + "shasum": "PTmRKwKUzSGr2ZBWOMDRHn1HTmmgk32dzd7zqmvcoMo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index 28222abac3..6b0b7cd139 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9STUPY6eRjt+TIFdMPIjpciA2r8oBk44hAIQ/6E75uc=", + "shasum": "hlMIB9kls/72D0A77vdvIkZEbJNUDj3Py9PIxm7aWOM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index aaec26245e..d75cd30980 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "cpJ6yas3+V8X8S2JYF4HaC+YY45DuqMWDXZNPIYugyQ=", + "shasum": "oKKYF+AERJAyRBABHRf4nsfQ6IrhKele+Fei+JXxGzA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index f5d2b4a2be..206f6e4e8e 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "0pkqwmT8vlu9P/sk7KfbiQcCHJ8BbnP5O5zHLed0Upw=", + "shasum": "rNBULIRBi45r+MXpWUNwkSaWog2pNTfG5VYKZ676w6g=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index 2a6eb9b691..67c98679a9 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "EbfOl/zvZDz1RMTPV5xtXeqe2uorl9iaxHH2kGiRGko=", + "shasum": "YvikqvHw0838qOaBrqjfegOyMSFM4ZwdyOH2qXode5M=", "location": { "npm": { "filePath": "dist/bundle.js", From 424c69ea63b9493d3c98c70f21e0d1747f809c96 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 15:15:29 +0200 Subject: [PATCH 10/11] Fix test --- packages/snaps-controllers/src/snaps/SnapController.ts | 7 +++++-- packages/snaps-utils/coverage.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/snaps-controllers/src/snaps/SnapController.ts b/packages/snaps-controllers/src/snaps/SnapController.ts index e12f29ad35..a29da71243 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -1336,7 +1336,10 @@ export class SnapController extends BaseController< async #assertIsInstallAllowed( snapId: SnapId, - snapInfo: SnapsRegistryInfo & { + { + platformVersion, + ...snapInfo + }: SnapsRegistryInfo & { permissions: SnapPermissions; platformVersion: string | undefined; }, @@ -1374,7 +1377,7 @@ export class SnapController extends BaseController< ); } - this.#validatePlatformVersion(snapId, snapInfo.platformVersion); + this.#validatePlatformVersion(snapId, platformVersion); } /** diff --git a/packages/snaps-utils/coverage.json b/packages/snaps-utils/coverage.json index 102bd1c6df..185df0be9d 100644 --- a/packages/snaps-utils/coverage.json +++ b/packages/snaps-utils/coverage.json @@ -2,5 +2,5 @@ "branches": 99.74, "functions": 98.93, "lines": 99.46, - "statements": 96.37 + "statements": 96.36 } From 3296c2b44a458424aa0add221a75f640f3014b1a Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 22 Oct 2024 15:54:28 +0200 Subject: [PATCH 11/11] Update coverage again --- packages/snaps-controllers/coverage.json | 4 ++-- packages/snaps-controllers/src/snaps/SnapController.test.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/snaps-controllers/coverage.json b/packages/snaps-controllers/coverage.json index 55aa5aaa9f..5620fbae4d 100644 --- a/packages/snaps-controllers/coverage.json +++ b/packages/snaps-controllers/coverage.json @@ -1,6 +1,6 @@ { "branches": 92.67, "functions": 96.65, - "lines": 97.99, - "statements": 97.69 + "lines": 97.98, + "statements": 97.68 } diff --git a/packages/snaps-controllers/src/snaps/SnapController.test.tsx b/packages/snaps-controllers/src/snaps/SnapController.test.tsx index 094f26e5e5..575b495317 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.test.tsx +++ b/packages/snaps-controllers/src/snaps/SnapController.test.tsx @@ -5417,7 +5417,7 @@ describe('SnapController', () => { [MOCK_SNAP_ID]: {}, }), ).rejects.toThrow( - `The Snap requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, + `The Snap "${MOCK_SNAP_ID}" requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, ); controller.destroy(); @@ -5458,7 +5458,7 @@ describe('SnapController', () => { ).resolves.not.toThrow(); expect(log).toHaveBeenCalledWith( - `The Snap requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, + `The Snap "${MOCK_SNAP_ID}" requires platform version "${newerVersion}" which is greater than the current platform version "${getPlatformVersion()}".`, ); controller.destroy();