Skip to content

Commit b4d37c6

Browse files
committed
chore: add new method to list available entropy sources
1 parent 43d32b7 commit b4d37c6

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

SIPS/sip-30.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This SIP proposes additions to entropy retrieval APIs that allows snaps to reque
1414

1515
Interoperability snaps and account management snaps use the methods `snap_getEntropy`, `snap_getBip44Entropy`, `snap_getBip32Entropy`, and `snap_getBip32PublicKey` to generate addresses and other key material.
1616

17-
These methods assume the client contains a single entropy source (the user's primary keyring mnemonic). The proposed API will allow snaps to request entropy from a specific source such as a secondary mnemonic.
17+
These methods assume the client contains a single entropy source (the user's primary keyring mnemonic). The proposed API changes will allow snaps to request entropy from a specific source such as a secondary mnemonic. A new method `snap_listAvailableEntropySources` will be added to allow snaps to request a list of available entropy sources.
1818

1919
## Specification
2020

@@ -26,6 +26,18 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S
2626
"NOT RECOMMENDED", "MAY", and "OPTIONAL" written in uppercase in this document are to be interpreted as described in
2727
[RFC 2119](https://www.ietf.org/rfc/rfc2119.txt)
2828

29+
### Snap Manifest
30+
31+
A new set permission is added to the snap manifest:
32+
33+
```json
34+
{
35+
"initialPermissions": {
36+
"snap_listAvailableEntropySources": {}
37+
}
38+
}
39+
```
40+
2941

3042
### Common Types
3143
```typescript
@@ -38,9 +50,7 @@ type Slip10Node = {
3850
chainCode: string;
3951
curve: "ed25519" | "secp256k1";
4052
};
41-
```
4253

43-
```typescript
4454
export type BIP44Node = {
4555
coin_type: number;
4656
depth: number;
@@ -49,6 +59,12 @@ export type BIP44Node = {
4959
chainCode: string;
5060
path: string[];
5161
};
62+
63+
interface EntropySource {
64+
name: string;
65+
id: string;
66+
type: "mnemonic";
67+
}
5268
```
5369

5470
### Scope
@@ -61,8 +77,12 @@ No changes are required to the snap manifest.
6177

6278
### Client wallet implementation
6379

64-
If a snap requests entropy and includes the `source` parameter, the wallet MUST return entropy corresponding to that source, if it exists.
65-
If it does not exist, the wallet MUST respond with an error.
80+
If a snap requests a list of available entropy sources, and it has the permission to do so, the wallet MUST return a list of `EntropySource` objects.
81+
82+
If a snap requests entropy and includes the `source` parameter for an entropy source of type `mnemonic`, the wallet MUST return entropy corresponding to that source, if it exists.
83+
84+
If the source does not exist, the wallet MUST respond with an error.
85+
6686
If the request does not include the `source` parameter, the wallet MUST return entropy from the default source.
6787

6888
A client wallet MAY invoke the `keyring.createAccount` method with an `entropySource` parameter in the `options` object.
@@ -73,7 +93,23 @@ The `entropySource` parameter MUST be a string which uniquely identifies the ent
7393

7494
If a snap is asked to create an account via `keyring.createAccount`, and the `entropySource` parameter is provided, and the snap requires entropy to create an account,the snap SHOULD request the entropy from the specified source.
7595

76-
### RPC Methods
96+
### New RPC Methods
97+
98+
#### `snap_listAvailableEntropySources`
99+
100+
The method returns an array of `EntropySource` objects, each representing an available entropy source. It is intended that the snap will display this list to the user.
101+
102+
```typescript
103+
const entropySources = await snap.request({
104+
method: "snap_listAvailableEntropySources",
105+
});
106+
// [
107+
// { name: "Phrase 1", id: "phrase-1" },
108+
// { name: "Phrase 2", id: "phrase-2" },
109+
// ]
110+
```
111+
112+
### Existing RPC Methods
77113

78114
#### `snap_getEntropy`
79115

0 commit comments

Comments
 (0)