Repository navigation
Feat/migrate to cofhesdk - #4
Conversation
There was a problem hiding this comment.
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
cofhejsand 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.
architect-dev
left a comment
There was a problem hiding this comment.
Looks great! I've requested a few small changes and have a few questions but other than that nice migration 👍
There was a problem hiding this comment.
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
typevariable. Consider checkingaccountfirst before computingtype.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
architect-dev
left a comment
There was a problem hiding this comment.
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!
| * 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 = () => { |
There was a problem hiding this comment.
Maybe worth switching this up too, useCofheConnected?
@cofhe/*packages (@cofhe/sdk,@cofhe/hardhat-pluginetc)