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

feat: add optional signEip7702Authorization method to Keyring type #231

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ export type Keyring<State extends Json> = {
options?: Record<string, unknown>,
): Promise<string>;

/**
* Sign an EIP-7702 authorization. This is a signing method for authorizing a
* specific contract on a specific chain.
*
* @param address - The address of the account to use for signing.
* @param authorization - An array containing the chain ID, contract address,
* and nonce.
* @param options - Signing options; differs between keyrings.
* @returns The signed authorization as a hex string.
*/
signEip7702Authorization?(
address: Hex,
authorization: [chainId: number, contractAddress: Hex, nonce: number],
Copy link
Contributor

@ccharly ccharly Feb 11, 2025

Choose a reason for hiding this comment

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

We could have used @metamask/eth-sig-util here too, but that would pull a new dep and since we plan to move this type (Keyring) to accounts/keyring-utils, I think that's fine that we keep it as is.

options?: Record<string, unknown>,
): Promise<string>;

/**
* Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC
* method, which is exposed by MetaMask as the method `personal_sign`. See
Expand Down
Loading