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.
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?
SIP-27: Accounts Metadata Request #148
Changes from 2 commits
3a8ac41
8a2bd5e
38d345f
0c4bf40
18dff37
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What do you think of this?
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 specifically don't want it to be mistaken with existing
keyring_listAccounts
, which only lists accounts managed by the Snap. IMHO, by appending it at the end it's more visible,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 wonder if it makes sense to prefix this with
keyring_
in the first place. So far these APIs are only used by account Snaps.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 want to display all accounts, we have to support how keyring manages and stores them in the extension, so this API mimics keyring internals almost 1:1.
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.
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.
Should this be a CAIP-10 address?
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 address can exist on multiple chains at the same time. Keyrings initially had a
chains
property, but it's not implementedThere 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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The only data available in MetaMask currently is the
type
property.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 guess my question is, should we combine
type
andaddress
into one field with a CAIP-10 address.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.
type
exposes more information than just the network the address is on.Accounts team envisioned the following types:
Notice they are all on mainnet while still differing
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.
The main goal of
type
is to differentiate between accounts that may behave differently, such as EOAs and Smart Contract Accounts.For multichain, we are still working on a solution that addresses two key issues:
We are considering approaches like
addresses: Map<Caip2ChainId, Address[]>
oraddresses: Caip10Address[]
(PR draft). Which is aligned with what you said above.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.
@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
eip155:*
, even though it wouldn’t be compliant, but ultimately decided to replace it with afilterAccountChains
method. This method can be called with a list of CAIP-2 chain IDs, and the Snap will return the list of supported chains from the input where the account can be used.I'm not super happy with the decision and think we can reconsided the
chains
field.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.
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
eip155:*
, we would useeip155
.We started using this pattern in the extension/core IIRC. But this is still not 100% compliant with a true CAIP-2 identifier...
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.