Skip to content

Conversation

@turnekybc
Copy link
Contributor

@turnekybc turnekybc commented Jun 20, 2025

Summary & Motivation

In order to support EIP-7702 transactions via @turnkey/ethers we need to expose signer.authorize()

Linear Ref

How I Tested These Changes

  • implemented unit tests

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 changeset will 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.

@socket-security
Copy link

socket-security bot commented Jun 20, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​nomicfoundation/​hardhat-network-helpers@​1.0.8 ⏵ 1.0.1210010081 +198 +1100
Updatedhardhat@​2.19.4 ⏵ 2.24.394 +110090 +2100 +180
Updated@​nomicfoundation/​hardhat-ethers@​3.0.5 ⏵ 3.0.9100 +110010099100

View full report

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 20, 2025

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:

Sandbox Source
@turnkey/example-react-components Configuration

Copy link
Contributor

Copilot AI left a 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 signAuthorization on TurnkeySigner and refine serializeSignature
  • Expand index-test.ts with 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 signAuthorization but the Ethers standard and PR title refer to authorize; consider renaming (or aliasing) this method to authorize for 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 signAuthorization describing its parameters (address, chainId, nonce, code) and return type (Authorization) so consumers know how to use it.
  async signAuthorization(

Comment on lines +425 to +431
ethers.hashAuthorization({
address: normalizedAddress,
chainId: normalizedChainId,
nonce: normalizedNonce,
code,
} as ethers.AuthorizationRequest);

Copy link

Copilot AI Jun 20, 2025

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.

Suggested change
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}`);

Copilot uses AI. Check for mistakes.
Comment on lines +356 to +373
// 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
Copy link

Copilot AI Jun 20, 2025

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.

Suggested change
// 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 uses AI. Check for mistakes.
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