Skip to content

fix(Secp256k1): resolve yParity type mismatch in verify#189

Open
Aboudjem wants to merge 1 commit intowevm:mainfrom
Aboudjem:fix/secp256k1-verify-yparity-type
Open

fix(Secp256k1): resolve yParity type mismatch in verify#189
Aboudjem wants to merge 1 commit intowevm:mainfrom
Aboudjem:fix/secp256k1-verify-yparity-type

Conversation

@Aboudjem
Copy link

@Aboudjem Aboudjem commented Mar 8, 2026

Destructuring the OneOf union in verify() causes TypeScript to lose the correlation between address and the correct Signature type. After destructuring, signature becomes Signature<true> | Signature<false>, but recoverAddress expects Signature<true> (with required yParity).

This surfaces as a build error in downstream projects that type-check node_modules source files (e.g. next build), since ox ships raw .ts files.

The fix avoids destructuring branch-dependent properties upfront and instead accesses them from the options object after narrowing, so the type checker can resolve the correct union member.

Fixes wevm/viem#4379

Destructuring the OneOf union in verify() lost TypeScript's ability
to correlate address with the correct Signature type. Access
branch-dependent properties from the options object instead so the
type checker can narrow correctly.

Fixes wevm/viem#4379
@vercel
Copy link

vercel bot commented Mar 8, 2026

@Aboudjem is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@Aboudjem
Copy link
Author

The only CI failure is the Vercel deployment which needs team authorization — the code changes and Socket Security checks pass. Could a maintainer approve the Vercel bot when you get a chance? Happy to address any feedback on the code itself. Thanks!

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.

Type error in Secp256k1.ts: yParity optional/required mismatch

1 participant