-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIP-27: Accounts Metadata Request #148
base: main
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
sip: 27 | ||
title: Accounts Metadata Request | ||
status: Draft | ||
author: Olaf Tomalka (@ritave) | ||
created: 2024-09-17 | ||
--- | ||
|
||
## Abstract | ||
|
||
This SIP allows Snaps to retrieve metadata related to accounts that exist in the extension. | ||
|
||
## Motivation | ||
|
||
The intention of this SIP is to allow Snaps providing new accounts for new chains to be able to list all accounts when selecting one during transfers. Currently the Snap can only access their own accounts, and can't do more complex UI flows. | ||
|
||
The specific need for this SIP is to allow a Snap to create a send flow with an account picker, with an example design as follows. | ||
|
||
<img src="../assets/sip-27/snap-account-list.png" alt="Account picker flow" width="600"/> | ||
|
||
## Specification | ||
|
||
> Indented sections like this are considered non-normative. | ||
|
||
> Usage of `CAIP-N` specifications, where `N` is a number, are references to [Chain Agnostic Improvement Proposals](https://github.com/ChainAgnostic/CAIPs). | ||
|
||
### Language | ||
|
||
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", | ||
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and | ||
"OPTIONAL" written in uppercase in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) | ||
|
||
### Snap Manifest | ||
|
||
This SIP specifies a permission named `keyring_listAccountsAll`. This permission grants a Snap the ability to retrieve account metadata through an RPC call. | ||
|
||
The permission is specified in `snap.manifest.json` as follows: | ||
|
||
```json | ||
{ | ||
"initialPermissions": { | ||
"keyring_listAccountsAll": {} | ||
} | ||
} | ||
``` | ||
|
||
### RPC Method | ||
|
||
This SIP exposes a new RPC method called `keyring_listAccountsAll` with no additional parameters. | ||
|
||
The RPC call returns with the following data: | ||
|
||
```typescript | ||
type KeyringAccount = { | ||
id: string; // An extension-specific unique ID | ||
address: string; // A blockchain specific public address for the account. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a CAIP-10 address? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This address can exist on multiple chains at the same time. Keyrings initially had a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then how would you identify which network the address is tied to? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only data available in MetaMask currently is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess my question is, should we combine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Accounts team envisioned the following types: type AccountType =
| 'eip155:eoa'
| 'eip155:sca:erc4337'
| 'bip122:p2pk'
| 'bip122:p2pkh'
| 'bip122:p2sh'
| 'bip122:p2wpkh'
| 'bip122:p2tr'; Notice they are all on mainnet while still differing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main goal of For multichain, we are still working on a solution that addresses two key issues:
We are considering approaches like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ritave, I need to double-check, but the reason we dropped the chains field was that CAIP-2 doesn't support wildcards. We considered using I'm not super happy with the decision and think we can reconsided the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, we were also considering using just the CAIP namespace as an alternative to wildcard. This way we can regroup "things" on the same namespace, so instead of We started using this pattern in the extension/core IIRC. But this is still not 100% compliant with a true CAIP-2 identifier... |
||
name: string; // User-given nickname for the account in the extension | ||
type: string; // Blockchain specific type of the account. For example "eip155:erc4337" | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we wish to have a similar UI than the native one to list the accounts, we might needs some more information coming from the In case of HW, the {
"id": "651e5769-86b1-4717-ae7b-63a00d7b3872",
"address": "0x9f753769a4b45e8e2ed61108f1174b5a0939e08e",
"options": {},
"methods": [
...
],
"type": "eip155:eoa",
"metadata": {
"name": "Ledger 1",
"importTime": 1727081928281,
"keyring": {
"type": "Ledger Hardware"
},
"lastSelected": 1727081928285,
"nameLastUpdatedAt": 1727081928286
}
} And I believe, if we implement a similar But I think @danroc had a different ideas regarding rendering a I just wanted to be explicit here that |
||
|
||
type Keyring_ListAccountsAllResult = KeyringAccount[]; | ||
``` | ||
|
||
> Notice that multiple `Account`s can have the same `address`, for example when there are two hardware wallets using the same seed. | ||
|
||
The call returns data concerning all accounts available in the client, both built-in Ethereum accounts as well as accounts managed by this, and other Snaps. | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](../LICENSE). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to expose this? What do you envision we use it for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you have two accounts with the same address (eg 2 different hardware wallets with the same seed), you need to differentiate them somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this just complicates things. The Snap has no information about how the address was created, right? Is it even relevant for the Snap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This provides a stable identity for an account.
For example, you could want to map accounts to a user editable notes about those accounts.
You can't use the name since it's user editable and can change, and you can't use address because there are multiple accounts with the same address.
By providing a stable identity (similar to React's key property) you can easily manipulate those accounts.