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

Adds signAuthorization method for EIP-7702 #407

Merged
merged 5 commits into from
Jan 26, 2025
Merged

Conversation

jeffsmale90
Copy link
Contributor

EIP-7702 defines a new struct Authorization which represents authority to set a pointer to a contract address at an EOA - effectively making the EOA perform as a smart contract.

This change adds methods to hash and sign authorizations, and to recover signer address.

Although the EIP defines the signed authorization as [chain_id, address, nonce, y_parity, r, s], the utility method returns the signature as a standard r|s|v signature for consistency with other signing methods.

See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md for details

@jeffsmale90 jeffsmale90 force-pushed the feat/sign-authorization branch from 5c46e25 to bb5e268 Compare December 19, 2024 04:13
@jeffsmale90 jeffsmale90 force-pushed the feat/sign-authorization branch from bb5e268 to b50bc64 Compare December 19, 2024 04:14
@jeffsmale90 jeffsmale90 requested a review from a team December 19, 2024 19:41
src/sign-authorization.ts Outdated Show resolved Hide resolved
src/sign-authorization.ts Outdated Show resolved Hide resolved
src/sign-authorization.ts Outdated Show resolved Hide resolved
src/sign-authorization.ts Outdated Show resolved Hide resolved
src/sign-authorization.test.ts Outdated Show resolved Hide resolved
src/sign-authorization.test.ts Outdated Show resolved Hide resolved
src/sign-authorization.test.ts Outdated Show resolved Hide resolved
…shuffled non-exported members to the bottom of the file, and renamed a few test constants to aid readability. Also used it.each for multiple test cases.
@jeffsmale90
Copy link
Contributor Author

jeffsmale90 commented Jan 13, 2025

@matthewwalsh0 thanks for the review! I made all of the changes you recommended, except for validating chainId !== 0, as I think this should be an API concern, rather than a utility concern, and the redundant "should" in the test names 👀

@jeffsmale90 jeffsmale90 merged commit 0f3013b into main Jan 26, 2025
16 checks passed
@jeffsmale90 jeffsmale90 deleted the feat/sign-authorization branch January 26, 2025 22:22
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.

2 participants