Skip to content

fix: derive yParity from v in serializeErc8010Signature - #5645

Merged
jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/erc8010-authorization-legacy-v
Nov 23, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/erc8010-authorization-legacy-v

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

Summary

serializeErc8010Signature throws recovery id invalid for an authorization that has a v but no yParity:

serializeErc8010Signature({
  authorization: { address, chainId: 1, nonce: 0, r, s, v: 27n },
  data: '0xdeadbeef',
  signature,
})
// Error: recovery id invalid

SignedAuthorization allows this shape (Signature accepts v with an optional yParity). Other authorization helpers already handle it: formatTransactionRequest sends v when yParity is missing, and both serializeAuthorizationList and recoverAuthorizationAddress derive the parity from v.

Root cause

The function passes yParity: parameters.authorization.yParity! to SignatureErc8010.wrap. wrap always recovers the authority from the authorization, so an undefined yParity throws, even when address is given.

Fix

Fall back to Signature.vToYParity(v) when yParity is not set. An existing yParity is passed through unchanged. This matches how #5279 derives the parity from a legacy v in signatureToCompactSignature. vToYParity is already bundled through SignatureErc8010.wrap.

Test

Extended the default case. The same authorization with v: 27n instead of yParity must serialize to the same signature. On main it fails with recovery id invalid; with this fix it passes.

Ran:

  • SKIP_GLOBAL_SETUP=true pnpm test --run --project core src/utils/signature/serializeErc8010Signature.test.ts src/utils/signature/parseErc8010Signature.test.ts src/utils/signature/isErc8010Signature.test.ts
  • biome check on the changed files
  • tsc on the changed files with a targeted config extending test/tsconfig.json

@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 21e74dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jxom
jxom merged commit 1c54cdc into wevm:main Nov 23, 2026
26 of 35 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
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