Skip to content

Add EIP-7702 authorization signing to JsonRpcSigner (fixes #5056)#5153

Open
sawirricardo wants to merge 1 commit into
ethers-io:mainfrom
sawirricardo:fix/5056-eip7702-jsonrpc-authorize
Open

Add EIP-7702 authorization signing to JsonRpcSigner (fixes #5056)#5153
sawirricardo wants to merge 1 commit into
ethers-io:mainfrom
sawirricardo:fix/5056-eip7702-jsonrpc-authorize

Conversation

@sawirricardo

Copy link
Copy Markdown

Summary

JsonRpcSigner (and therefore BrowserProvider/injected-wallet signers) inherits the throwing default authorize() from AbstractSigner, so calling signer.authorize(...) fails with authorization not implemented for this signer. There is currently no way to sign an EIP-7702 authorization over JSON-RPC.

Fixes #5056.

Changes

  • Implement authorize() on JsonRpcSigner. It populates any missing nonce/chainId, resolves the delegate address (ENS/Addressable), sends eth_signAuthorization to the backing node/injected provider, and normalizes the returned signature into an Authorization.
  • Add a JSON-RPC test that mocks eth_signAuthorization and asserts the returned Authorization populates nonce/chainId, preserves the delegate address, and verifies back to the signing account via verifyAuthorization.

Notes

  • The address in the AuthorizationRequest is the contract code to delegate to; the account that signs is the JsonRpcSigner address. This matches AbstractSigner.populateAuthorization and BaseWallet.authorize.
  • eth_signAuthorization is the de-facto method name used by geth/reth and matches ethers eth_* JSON-RPC convention. MetaMask stable does not yet expose it; this PR unblocks every provider/node that does and gives injected wallets a concrete method to implement.
const signer = await browserProvider.getSigner();
const authorization = await signer.authorize({ address: delegateContract });
const tx = await signer.sendTransaction({
    to: target, authorizationList: [authorization ]
});

…5056)

JsonRpcSigner (and therefore BrowserProvider signers) threw
"authorization not implemented for this signer" when authorize() was
called, leaving no way to sign an EIP-7702 authorization over JSON-RPC.

Implement authorize() on JsonRpcSigner by sending eth_signAuthorization
to the backing node/injected provider. Missing nonce and chainId are
populated, the delegate address is resolved (ENS/Addressable), and the
returned signature is normalized into an Authorization.

This unblocks EIP-7702 delegation flows for any JSON-RPC provider that
implements eth_signAuthorization (e.g. geth, reth, and EIP-1193 wallets
that expose it).
@sawirricardo

Copy link
Copy Markdown
Author

if anyone able to test this will be really helpful

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.

EIP-7702 from MetaMask

1 participant