-
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
Open
ritave
wants to merge
5
commits into
main
Choose a base branch
from
ritave/sip-27
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
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 = { | ||
/** | ||
* An extension-specific unique ID providing stable identity. | ||
*/ | ||
id: string; | ||
/** | ||
* Account addresses mapped by CAIP-2 namespace or chain ID. | ||
* | ||
* If the address is the same for all CAIP-2 chains, it's mapped only by namespace. | ||
* @example | ||
* ```typescript | ||
* address: { | ||
* 'eip155': ['0x1234...'] | ||
* } | ||
* ``` | ||
* | ||
* Otherwise, if the address differs between chains, it's mapped by chain IDs. | ||
* @example | ||
* ```typescript | ||
* address: { | ||
* 'eip155:1': ['0x1234...'], | ||
* 'eip155:137': ['0x6789...'] | ||
* } | ||
* ``` | ||
*/ | ||
address: Record<string, string[]>; | ||
/** | ||
* User-given nickname for the account in the extension. | ||
*/ | ||
name: string; | ||
}; | ||
|
||
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). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
metadata
field fromInternalAccount
(maybe not everything, but I was thinking about hardware-wallet accounts).In case of HW, the
account.type
will beeip155:eoa
, but we don't encode any other information regarding which HW if comes from. We do have this information in theaccount.metadata.keyring.type
field like:And I believe, if we implement a similar
AccountList
component to display the list of accounts, we will need thiskeyring.type
information to be able to display the small pillLedger
alongside the account entry.But I think @danroc had a different ideas regarding rendering a
AccountList
component, so maybe we won't even need to expose any of thosemetadata
:).I just wanted to be explicit here that
type
lacks some context/information.