Skip to content
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-26: Non-EVM protocol support #147

Merged
merged 26 commits into from
Nov 14, 2024
Merged

SIP-26: Non-EVM protocol support #147

merged 26 commits into from
Nov 14, 2024

Conversation

danroc
Copy link
Contributor

@danroc danroc commented Aug 30, 2024

Abstract

This SIP presents an architecture to enable Snaps to expose blockchain-specific methods to dapps, extending MetaMask's functionality to support a multichain ecosystem.

Motivation

Currently, MetaMask is limited to EVM-compatible networks. This proposal aims to empower developers, both first- and third-party, to use Snaps to add native support for non-EVM-compatible chains within MetaMask.

Fixes: https://github.com/MetaMask/accounts-planning/issues/542

@danroc danroc self-assigned this Sep 2, 2024
@danroc danroc marked this pull request as ready for review September 12, 2024 08:43
@danroc danroc requested review from Montoya, ziad-saab and a team as code owners September 12, 2024 08:43
Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of small comments, overall this looks like a good improvement to handle multichain requests and scale the wallet beyond EVM chains

SIPS/sip-26.md Outdated Show resolved Hide resolved
SIPS/sip-26.md Outdated
Comment on lines 49 to 50
- **Account Router**: Native component that forwards signing requests to the
appropriate Account Snap or native implementation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the Account Router is the one that registers signing methods to the RPC Router, but how are the signing methods registered into the Account Router?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are listed in the account object in the methods field.

But it made me think of another problem: the account doesn't list the supported chains (there is a method to get this information, but we should probably move it into the account object).

Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com>
SIPS/sip-26.md Outdated Show resolved Hide resolved
Co-authored-by: Charly Chevalier <charlyy.chevalier@gmail.com>
SIPS/sip-26.md Outdated
Comment on lines 52 to 54
- **Account Address Resolution Snaps**: Snaps that implement the
`resolveAccountAddress` method to extract the account address from the
request object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these Snaps be the same as Account and Protocol Snaps, or do they have to be separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking with @Mrtenz, I believe the Snaps should remain separate. Our goal is for these Snaps to operate without special permissions. Additionally, we should have only one Account Address Resolution Snap per blockchain. This will help simplify the Account (CAIP-2) Snap and prevent any confusion about which Account Address Resolution Snap to use.

SIPS/sip-26.md Outdated
Comment on lines 40 to 44
- **Account Snaps**: Snaps that implement the Keyring API and are responsible
for signing requests and managing accounts.

- **Protocol Snaps**: Snaps that implement protocol methods that do not require
an account to be executed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought per our discussions with @rekmarks we'd determined that we can't enforce separation of Account + Protocol Snaps?
Accounts SIP (1)

Copy link
Contributor

@adonesky1 adonesky1 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I now see the language in your diagram saying that these can be combined. I think its more confusing to represent them as (sortof) separate in the diagram.

As I believe I said in our meeting I don't think we're really getting anything by having these non signing protocol snaps that implement non signing methods if the signing snaps can trivially handle those requests too.

In that case I feel like its clearer to call them something more general than "Account Snaps" since they are not just handling accounts. Maybe "Protocol Snaps" or "CAIP-2 Snaps" (though I'd prefer something that clearly states its purpose without external reference).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To restate what I said in a meeting: As I read it, they are just two separate permissions that a Snap may or may not put together, and some Snaps (e.g. hardware wallet or SCAs) may want to only ship the account part.

SIPS/sip-26.md Outdated
account: {
id: '74bb3393-f267-48ee-855a-2ba575291ab0',
type: 'eip155:eoa',
address: '0x1234567890123456789012345678901234567890',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a caip-10 address to include the chainid which is missing context here when creating an account:

eip155:1:0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea agreed. We will need some way to associate this account with the appropriate CAIP-2 identifier for routing purposes, whether its making these CAIP-10 addresses or adding a CAIP-2 property on the object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a 1:1 mapping to the blockchain account, and for EVM chains the address is the same accross all networks, so I think CAIP-2 addresses are not suitable here.

We have thought about using CAIP-2 namespaces, but it's not in the scope of this SIP, this snippet is an example of the existing API.

Copy link
Contributor

@adonesky1 adonesky1 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Do we have a plan for how to handle types that are not eip155:eoa (EVM SCAs and other non-evm chains where the account type might not provide enough to be sure that the account can be used on all subchains) then? Seems like we should include a CAIP-2 scope(s) property here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there documentation we could link to where this type property is defined/scoped?

SIPS/sip-26.md Outdated
type: 'eip155:eoa',
address: '0x1234567890123456789012345678901234567890',
methods: ['eth_signTypedData_v4'],
options: {},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would go in options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the Keyring API and is used by Snap devs to store implementation-dependent information about the account. An example would be to use it to store the tresholds, index, and other metadata used by MPC accounts.

@danroc danroc changed the title SIP-26: Account Router Snap SIP-26: RPC Router and support for non-EVM chains Nov 12, 2024
SIPS/sip-26.md Outdated Show resolved Hide resolved
SIPS/sip-26.md Outdated Show resolved Hide resolved
* SIP-26: Update Snaps-specific parts of the specification

* Minor updates

* Reword slightly

* Update SIPS/sip-26.md

Co-authored-by: Alex Donesky <alex.donesky@consensys.net>

---------

Co-authored-by: Alex Donesky <alex.donesky@consensys.net>
SIPS/sip-26.md Outdated Show resolved Hide resolved
@danroc danroc changed the title SIP-26: RPC Router and support for non-EVM chains SIP-26: Non-EVM protocol support Nov 14, 2024
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
Mrtenz
Mrtenz previously approved these changes Nov 14, 2024
@FrederikBolding
Copy link
Member

Awaiting sign off from @adonesky1 before merging

SIPS/sip-26.md Outdated Show resolved Hide resolved
SIPS/sip-26.md Outdated Show resolved Hide resolved
#### RPC Router

The RPC Router will be a new native component responsible for routing JSON-RPC
requests to the appropriate Snap or keyring.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it confusing to separate keyring from Snap here since all the keyrings we route to are Snap keyrings?

Suggested change
requests to the appropriate Snap or keyring.
requests to the appropriate Snap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I dunno this isn't a big deal and maybe its better as is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think this is fine as-is since we don't wanna route directly to keyring Snaps, but to the native keyring controlling them. It is a minor detail though

SIPS/sip-26.md Outdated Show resolved Hide resolved
SIPS/sip-26.md Outdated Show resolved Hide resolved
Comment on lines +97 to +99
type: "eip155:eoa",
address: "0x1234567890123456789012345678901234567890",
methods: ["eth_signTypedData_v4"],
Copy link
Contributor

@adonesky1 adonesky1 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] since this SIP is for non-evm snaps should we provide a non-evm example here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'm still wondering how we plan to standardize non-evm account types. Currently our documentation only appears to describe eip155:eoa or eip155:erc4337

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been requesting this as well, we need a more generic type that allows any protocol. IIRC @danroc and team are thinking about how to do that.

Co-authored-by: Alex Donesky <alex.donesky@consensys.net>
@FrederikBolding FrederikBolding dismissed stale reviews from Mrtenz and themself via 7b35ebc November 14, 2024 15:46
@FrederikBolding FrederikBolding merged commit d2a8c29 into main Nov 14, 2024
3 checks passed
@FrederikBolding FrederikBolding deleted the dr/accounts branch November 14, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants