Skip to content

fix(sdk): use signed permit chain for decrypt requests - #307

Open
Lesnak1 wants to merge 1 commit into
FhenixProtocol:masterfrom
Lesnak1:fix/decrypt-permit-chain
Open

fix(sdk): use signed permit chain for decrypt requests#307
Lesnak1 wants to merge 1 commit into
FhenixProtocol:masterfrom
Lesnak1:fix/decrypt-permit-chain

Conversation

@Lesnak1

@Lesnak1 Lesnak1 commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • derive permit-based decrypt requests from the permit's EIP-712 signed chain ID
  • use that chain consistently for threshold-network URL selection and the request payload
  • cover both decryptForView and decryptForTx with regression tests
  • leave the no-permit/global-allowance path unchanged

Problem

withPermit(permit) is documented to use the supplied permit regardless of the builder's chain ID or account. Both decrypt builders already extracted permit._signedDomain.chainId to choose between mock and production execution, but the production methods still resolved the threshold-network URL and populated the request chainId from the builder state.

As a result, a directly supplied permit could:

  • throw ChainIdUninitialized when the builder chain was unset, or
  • route the request using a stale/different builder chain.

Fix

Pass the signed permit chain ID into the production decrypt methods and use it for both configuration lookup and the threshold-network request. The global-allowance path continues to use the resolved builder/public-client chain.

A patch changeset is included.

Verification

  • pnpm --filter @cofhe/sdk exec vitest run --project node core/test/decryptBuilders.test.ts — 34 passed
  • pnpm --filter @cofhe/sdk check:types
  • pnpm --filter @cofhe/sdk build
  • pnpm --filter @cofhe/sdk lint — 0 errors
  • Prettier and git diff --check

The regression fixtures create a real local EIP-712 permit signature; only the external threshold-network boundary is isolated.

@changeset-bot

changeset-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e162a8c

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

This PR includes changesets to release 9 packages
Name Type
@cofhe/sdk Patch
@cofhe/abi Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/react Patch
@cofhe/site Patch
@cofhe/example-react Patch
@cofhe/foundry-plugin 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

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@Lesnak1 is attempting to deploy a commit to the Fhenix Team on Vercel.

A member of the Team first needs to authorize it.

@Lesnak1
Lesnak1 marked this pull request as ready for review August 9, 2026 21:02

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@Lesnak1

Lesnak1 commented Aug 26, 2026

Copy link
Copy Markdown
Author

Hi team, same situation as #323 - the Permit to ACP migration on master has structurally diverged from this PR's signed permit chain logic.

Happy to rewrite against the new ACP API, or close this if it's been superseded. Let me know!

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.

1 participant