fix(sdk): canonicalize Permit2 signature v-byte in MocIntegration route - #1150
Open
tjcloa wants to merge 1 commit into
Open
fix(sdk): canonicalize Permit2 signature v-byte in MocIntegration route#1150tjcloa wants to merge 1 commit into
tjcloa wants to merge 1 commit into
Conversation
SDK counterpart of the frontend fix in PR #1147. The MocIntegration route ABI-encoded options.typedDataSignature verbatim into the getDocFromDllrAndRedeemRbtcWithPermit2 call; wallets that return v as a raw recovery id (0/1 — Frame, onboard-ledger, some MPC wallets) or an EIP-2098 compact form produced calldata Permit2's ecrecover rejects on-chain. Add normalizeSignature (joinSignature∘splitSignature) to internal/utils and apply it at the encoding site; canonical signatures pass through byte-identical, malformed ones throw at build time. The ZeroRedemption path already canonicalizes via its existing splitSignature call and needs no change. Tests: raw v=1 in -> canonical v=28 encoded; canonical passthrough pinned. The slippage-invariant moc fixture switched to the shared valid FAKE_SIGNATURE (its 0xab..ab placeholder has s's top bit set, which ethers rejects as inconsistent in the 65-byte form). Full sdk suite 88/88 green, eslint clean.
🦋 Changeset detectedLatest commit: cb8b432 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for sovryn-dapp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SDK-side counterpart of #1147, so the Permit2 signature fix ships inside
@sovryn/sdk2.0.11 rather than only in the frontend.The MocIntegration route ABI-encodes
options.typedDataSignatureverbatim into thegetDocFromDllrAndRedeemRbtcWithPermit2call. Wallets that expose raw signer output (Frame, onboard-ledger, some WalletConnect/MPC wallets) return the ECDSA v byte as the recovery id (0/1), and EIP-2098 signers return a 64-byte compact form — both produce calldata that Permit2'sSignatureVerification(rawecrecover) rejects on-chain. #1147 normalizes at the frontend boundary; this PR applies the same canonicalization where the SDK itself consumes the signature, covering direct SDK integrators.normalizeSignaturehelper ininternal/utils(joinSignature(splitSignature(x))— same idiom as fix: canonicalize typed-data signature v-byte before forwarding on-chain (Permit2 flows failing for Frame/Ledger wallets) #1147): canonical signatures pass through byte-for-byte, raw/compact forms are normalized to 65-byter||s||vwith v ∈ {27, 28}, malformed signatures throw at build time instead of reverting on-chain.splitSignaturecall and is unchanged.@sovryn/sdkpatch (joins the pending 2.0.11 release train).Tests (TDD, red→green watched)
v=1signature in → canonicalv=28encoded in calldata0xab…abplaceholder to the shared validFAKE_SIGNATURE(the placeholder'sshas its top bit set, which ethers rejects as inconsistent in the 65-byte form — the route now correctly refuses it at build time)Verification
Full sdk jest suite 88/88 green (fresh worktree, deps built from source); eslint clean.
Release note
Intended to merge before the Version Packages PR #1149 so it rides the 2.0.11 release together with #1147's frontend half.