Add EIP-7702 authorization signing to JsonRpcSigner (fixes #5056)#5153
Open
sawirricardo wants to merge 1 commit into
Open
Add EIP-7702 authorization signing to JsonRpcSigner (fixes #5056)#5153sawirricardo wants to merge 1 commit into
sawirricardo wants to merge 1 commit into
Conversation
…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).
Author
|
if anyone able to test this will be really helpful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
JsonRpcSigner(and thereforeBrowserProvider/injected-wallet signers) inherits the throwing defaultauthorize()fromAbstractSigner, so callingsigner.authorize(...)fails withauthorization not implemented for this signer. There is currently no way to sign an EIP-7702 authorization over JSON-RPC.Fixes #5056.
Changes
authorize()onJsonRpcSigner. It populates any missingnonce/chainId, resolves the delegateaddress(ENS/Addressable), sendseth_signAuthorizationto the backing node/injected provider, and normalizes the returned signature into anAuthorization.eth_signAuthorizationand asserts the returnedAuthorizationpopulatesnonce/chainId, preserves the delegate address, and verifies back to the signing account viaverifyAuthorization.Notes
addressin theAuthorizationRequestis the contract code to delegate to; the account that signs is theJsonRpcSigneraddress. This matchesAbstractSigner.populateAuthorizationandBaseWallet.authorize.eth_signAuthorizationis the de-facto method name used by geth/reth and matches etherseth_*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.