Skip to content

Commit

Permalink
Added information about specifying version when installing snaps (Met…
Browse files Browse the repository at this point in the history
…aMask#433)

* Added information about specyfing version when installing snaps
* Added Awesome Metamask Snaps link

Co-authored-by: Erik Marks <[email protected]>
  • Loading branch information
ritave and rekmarks authored Mar 24, 2022
1 parent 0aca9ee commit 8aa24a9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 3 additions & 1 deletion docs/guide/snaps-development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ await ethereum.request({
params: [
{
wallet_snap: {
'npm:hello-snap': {},
'npm:hello-snap': {
version: '^1.0.0',
},
},
},
],
Expand Down
27 changes: 23 additions & 4 deletions docs/guide/snaps-rpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Do you have feature requests? Other ideas? We'd love to hear about them! [Click
```typescript
interface WalletEnableParam {
wallet_snap: {
[snapId: string]: {};
[snapId: string]: {
version?: string;
};
};
[permissionName: string]: {};
}
Expand Down Expand Up @@ -75,7 +77,12 @@ try {
{
wallet_snap: {
'npm:@metamask/example-snap': {},
'npm:fooSnap': {},
'npm:fooSnap': {
// The optional version argument allows requesting
// SemVer version range, with semantics same as in
// package.json ranges.
version: '^1.0.2',
},
},
eth_accounts: {},
},
Expand Down Expand Up @@ -199,7 +206,9 @@ You probably want to use [`wallet_enable`](#wallet-enable) instead, which both r

```typescript
interface InstallSnapsParam {
[snapId: string]: {};
[snapId: string]: {
version?: string;
};
}
```

Expand All @@ -226,6 +235,12 @@ interface WalletInstallSnapsResult {
This method attempts to install the requested snaps, if they are permitted.
If the installation of any snap fails, its object value on the result will contain an `error` property with the error that caused the installation to fail.

Optionally, you can specify a [SemVer range](https://www.npmjs.com/package/semver) for any snap to be installed.
If you do so, MetaMask will try to install a version of the snap that satisfies the requested range.
If a compatible version of a snap is already installed, the request to install that snap will automatically succeed.
If an incompatible version is installed, MetaMask will attempt to update the snap to the latest version that satisfies the requested range.
The request will succeed if the snap is successfully updated, and fail if the update could not be completed.

#### Example

```javascript
Expand All @@ -234,7 +249,11 @@ const result = await ethereum.request({
params: [
{
'npm:@metamask/example-snap': {},
'npm:fooSnap': {},
'npm:fooSnap': {
// The optional version argument allows requesting a SemVer version
// range, with the same semantics as npm package.json ranges.
version: '^1.0.2',
},
},
],
});
Expand Down
9 changes: 4 additions & 5 deletions docs/guide/snaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ Once you've connected to Flask, smash that `Send Hello` button, and watch the sn

## Where to Go from Here

If you're interested in developing your own snap, your next destination is probably [the snaps development guide](./snaps-development-guide.html).

You may also wish to check out the first functional key management snap ever made, [the Filecoin Snap, or `filsnap`](https://github.com/Chainsafe/filsnap/).

Currently, snaps are discovered through word-of-mouth. As the system matures, MetaMask will provide means for both developers and users to discover snaps.
- If you're interested in developing your own snap, your next destination is probably [the snaps development guide](./snaps-development-guide.html).
- You may also wish to check out the first functional key management snap ever made, [the Filecoin Snap, or `filsnap`](https://github.com/Chainsafe/filsnap/).
- Check out the list of [Awesome MetaMask Snaps](https://github.com/piotr-roslaniec/awesome-metamask-snaps) and other resources.
- Currently, snaps are mostly discovered through word-of-mouth. As the system matures, MetaMask will provide means for both developers and users to discover snaps.

0 comments on commit 8aa24a9

Please sign in to comment.