-
Notifications
You must be signed in to change notification settings - Fork 43
Implement signer.authorize for EIP-7702 transactions #696
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
base: main
Are you sure you want to change the base?
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a44cbea:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for EIP-7702 authorization signing by exposing a new signAuthorization method on TurnkeySigner, upgrades ethers to v6.14.4 (and related dev deps), and updates unit tests to cover the new flow.
- Bump
ethers, Hardhat, and network helper versions - Implement
signAuthorizationonTurnkeySignerand refineserializeSignature - Expand
index-test.tswith EIP-7702 authorization tests
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/ethers/src/index.ts | Added signAuthorization method, error wrapping, and signature serialization checks |
| packages/ethers/src/tests/index-test.ts | Updated imports and added an EIP-7702 authorization test |
| packages/ethers/package.json | Upgraded ethers, Hardhat, and helper versions |
| .changeset/gold-glasses-reflect.md | New changeset for the minor feature release |
Comments suppressed due to low confidence (3)
packages/ethers/src/index.ts:324
- The method is named
signAuthorizationbut the Ethers standard and PR title refer toauthorize; consider renaming (or aliasing) this method toauthorizefor consistency with Ethers.Signer.
async signAuthorization(
packages/ethers/src/tests/index-test.ts:462
- The new positive test covers the happy path, but there are no negative tests for invalid inputs (bad address, bad chainId, bad code, chainId mismatch). Consider adding tests that assert your error branches.
testCase("it signs EIP-7702 authorization", async () => {
packages/ethers/src/index.ts:324
- [nitpick] Add a JSDoc comment for
signAuthorizationdescribing its parameters (address,chainId,nonce,code) and return type (Authorization) so consumers know how to use it.
async signAuthorization(
| ethers.hashAuthorization({ | ||
| address: normalizedAddress, | ||
| chainId: normalizedChainId, | ||
| nonce: normalizedNonce, | ||
| code, | ||
| } as ethers.AuthorizationRequest); | ||
|
|
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of ethers.hashAuthorization(...) is not used; remove this call or capture its result if it’s intended for verification or logging.
| ethers.hashAuthorization({ | |
| address: normalizedAddress, | |
| chainId: normalizedChainId, | |
| nonce: normalizedNonce, | |
| code, | |
| } as ethers.AuthorizationRequest); | |
| const authorizationHash = ethers.hashAuthorization({ | |
| address: normalizedAddress, | |
| chainId: normalizedChainId, | |
| nonce: normalizedNonce, | |
| code, | |
| } as ethers.AuthorizationRequest); | |
| console.debug(`Authorization hash computed: ${authorizationHash}`); |
| // testCase("it signs authorization (EIP-712 permit style)", async () => { | ||
| // // Define the EIP-712 domain for EIP-7702 | ||
| // const domain = { | ||
| // name: "EIP7702Authorization", | ||
| // version: "1", | ||
| // chainId: chainId, | ||
| // verifyingContract: "0x0000000000000000000000000000000000000000", | ||
| // }; | ||
|
|
||
| // // Define the EIP-7702 AuthorizationRequest | ||
| // const authRequest: ethers.AuthorizationRequest = { | ||
| // address: signingConfig.expectedEthAddress, | ||
| // chainId: chainId, | ||
| // nonce: 0, | ||
| // }; | ||
|
|
||
| // try { | ||
| // // Sign the authorization |
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There’s a large block of commented-out test code above the real EIP-7702 test; remove it to keep the test file clean and focused.
| // testCase("it signs authorization (EIP-712 permit style)", async () => { | |
| // // Define the EIP-712 domain for EIP-7702 | |
| // const domain = { | |
| // name: "EIP7702Authorization", | |
| // version: "1", | |
| // chainId: chainId, | |
| // verifyingContract: "0x0000000000000000000000000000000000000000", | |
| // }; | |
| // // Define the EIP-7702 AuthorizationRequest | |
| // const authRequest: ethers.AuthorizationRequest = { | |
| // address: signingConfig.expectedEthAddress, | |
| // chainId: chainId, | |
| // nonce: 0, | |
| // }; | |
| // try { | |
| // // Sign the authorization |
Summary & Motivation
In order to support EIP-7702 transactions via
@turnkey/etherswe need to exposesigner.authorize()v6.14.4to ensure latest support for EIP-7702signAuthorization()function from@turnkey/etherspackageLinear Ref
How I Tested These Changes
Did you add a changeset?
If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run
pnpm changeset.pnpm changesetwill generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.