Skip to content

Feat/migrate to cofhesdk - #4

Merged
alexshchur merged 51 commits into
FhenixProtocol:mainfrom
alexshchur:feat/migrate-to-cofhesdk
Nov 4, 2025
Merged

alexshchur merged 51 commits into
FhenixProtocol:mainfrom
alexshchur:feat/migrate-to-cofhesdk

Conversation

@alexshchur

@alexshchur alexshchur commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor
  • migrate from cofhejs to new @cofhe/* packages (@cofhe/sdk, @cofhe/hardhat-plugin etc)
  • small adjustments in the code caused by SDK interface changes

@alexshchur
alexshchur marked this pull request as ready for review November 3, 2025 08:34

Copilot AI 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.

Pull Request Overview

This PR migrates the CoFHE SDK integration from the deprecated cofhejs package to the new @cofhe/sdk package (version 0.0.0-beta-20251028130353). The migration includes updated APIs, naming conventions, and architectural improvements to the SDK initialization and usage patterns.

Key changes:

  • Package migration from cofhejs and related packages to @cofhe/sdk, @cofhe/hardhat-plugin, and @cofhe/mock-contracts
  • Updated initialization pattern with synchronous client construction and asynchronous connection
  • Renamed hooks and components from "Cofhejs" to "Cofhe" throughout the codebase
  • Updated API calls to use new SDK methods (encryptInputs().encrypt(), decryptHandle().decrypt())

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
yarn.lock Updates dependencies to use new @cofhe scoped packages and removes old cofhejs packages
packages/nextjs/package.json Replaces cofhejs with @cofhe/sdk dependency
packages/hardhat/package.json Replaces cofhe-hardhat-plugin and cofhejs with @cofhe scoped equivalents
packages/nextjs/app/useCofhe.ts Complete rewrite using new SDK with updated initialization and permit handling logic
packages/nextjs/app/useEncryptInput.ts Updates encryption API calls and removes FheTypes.Uint256 support
packages/nextjs/app/useDecrypt.ts Updates decryption API calls and error messages
packages/nextjs/components/cofhe/*.tsx Renames components and updates import paths and API usage
packages/hardhat/test/FHECounter.test.ts Updates test utilities from hre.cofhe to hre.cofhesdk
README.md Updates documentation to reflect new package names and API patterns
Comments suppressed due to low confidence (1)

packages/nextjs/components/cofhe/CofhePortal.tsx:139

  • Corrected spelling of 'nethier' to 'neither'.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/nextjs/app/useCofhe.ts Outdated

@architect-dev architect-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great! I've requested a few small changes and have a few questions but other than that nice migration 👍

Comment thread packages/hardhat/test/FHECounter.test.ts Outdated
Comment thread packages/hardhat/test/FHECounter.test.ts Outdated
Comment thread packages/nextjs/app/useCofhe.ts Outdated
Comment thread packages/nextjs/app/useCofhe.ts Outdated
Comment thread packages/nextjs/app/useCofhe.ts Outdated
Comment thread packages/nextjs/app/useCofhe.ts
Comment thread packages/nextjs/app/useCofhe.ts Outdated

Copilot AI 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.

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

packages/nextjs/components/cofhe/CofhePortal.tsx:138

  • Corrected spelling of 'nethier' to 'neither'.
    packages/nextjs/components/cofhe/CofhePermitModal.tsx:52
  • The type annotation on line 50 is redundant since TypeScript can infer the type from the conditional expression. Additionally, the check on line 52 occurs after determining the type, which could lead to throwing an error with an already-computed but unused type variable. Consider checking account first before computing type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/nextjs/app/useCofhe.ts Outdated

@architect-dev architect-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great, I'm happy with it as is, but I think there might be more places we're still using initialized when we shouldn't. Not too big a deal either way though. LGTM!

Comment thread packages/nextjs/app/useCofhe.ts Outdated
* FHE based interactions (encrypt / decrypt) should be disabled until this is true
* @returns boolean indicating if FHE keys, provider, and signer are all initialized
*/
export const useCofheInitialized = () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe worth switching this up too, useCofheConnected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fair enough, I've changed

@alexshchur
alexshchur merged commit 14dc74f into FhenixProtocol:main Nov 4, 2025
1 check passed
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.

3 participants