MetaMask / metamask-snaps-beta

Fork of MetaMask that supports plugins! Read the Wiki!
https://github.com/MetaMask/metamask-snaps-beta/wiki
MIT License
144 stars 57 forks source link

Add account types #167

Closed danfinlay closed 4 years ago

danfinlay commented 4 years ago

Introduces a concept of "account types" to the AccountsController.

The permission to wallet_manageIdentities is now known as wallet_manageAccounts_*, where * is an account type identifier string.

Currently this string is Ether for Ethereum accounts, per Ethereum's SLIP44 name.

Also introduces wallet_accounts_*, where * is again that same account type identifier. This method is meant to so that eth_accounts can be an alias for wallet_accounts_Ether, as a strict superset of that method.

If any parameters are present in a call to wallet_accounts_*, then those parameters will be passed to the handler for the account defined by the from value on its AccountMessageHandler function, allowing account type snaps to define their own interfaces, and the accounts permission to allow passing through messages related to the permitted accounts.

Will benefit from a number of improvements:

danfinlay commented 4 years ago

Alright got the tests passing.

I separated the two types of identifiers:

We are using the former in Aaron's PR above to ensure that the key derivation permission is bound very explicitly to the input of the key derivation function.

The account type identifier is a "softer" guarantee: The two permissions that use this are for:

To allow keyless account types, it's important that the account-service registry is not bound to a key derivation strategy (or key derivation at all, as in the case of contract accounts).