FHERC20Upgradeable (ERC7984 compliant) contracts#50
Open
architect-dev wants to merge 3 commits intomasterfrom
Open
FHERC20Upgradeable (ERC7984 compliant) contracts#50architect-dev wants to merge 3 commits intomasterfrom
architect-dev wants to merge 3 commits intomasterfrom
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This PR replaces the project-local FHE token implementation (
FHERC20.sol,FHERC20Upgradeable.sol,ConfidentialClaim.sol,FHEContract.sol,FUSD.sol, and all associated interfaces/mocks) with the upstreamfhenix-confidential-contracts@0.3.1package and its ERC-7984-compliant upgradeable base contracts.ConfidentialERC20andConfidentialETHare now thin, focused wrappers overFHERC20ERC20WrapperUpgradeableandFHERC20NativeWrapperUpgradeablerespectively.RedactCorehas been refactored into a factory, registry, and upgrade manager — it deploysConfidentialERC20proxies on demand, tracks the shared implementation address for future deployments, and is the sole entity authorized to upgrade any registered wrapper.Contract changes
Deleted (superseded by upstream package):
FHERC20.sol,FHERC20Upgradeable.solConfidentialClaim.sol,FHEContract.sol,FUSD.solinterfaces/IFHERC20.sol,interfaces/IFHERC20Errors.sol,interfaces/IWETH.soltest/FHERC20_Harness.sol,test/MockFherc20Vault.sol,test/ERC20_Harness.solRewritten:
ConfidentialERC20— now extendsFHERC20ERC20WrapperUpgradeable + OwnableUpgradeable + UUPSUpgradeable. Deployed behind an ERC-1967 proxy. Guards against wrapping another FHERC20 token and caps decimals at 6.ConfidentialETH— now extendsFHERC20NativeWrapperUpgradeable + OwnableUpgradeable + UUPSUpgradeable. Deployed behind an ERC-1967 proxy.RedactCore— stores aconfidentialERC20Implementationaddress used as the logic contract for every newdeployConfidentialERC20()call. ExposessetConfidentialERC20Implementation(owner only) to point future deployments at a new impl, andupgradeWrapper(owner only) to upgrade any already-deployed proxy.Added (test harnesses only):
hardhat/ConfidentialERC20V2_Harness.sol— extendsConfidentialERC20and exposes aversion()getter to verify UUPS upgrades work end-to-end in tests.hardhat/ConfidentialETHV2_Harness.sol— same forConfidentialETH.Dependency changes
fhenix-confidential-contracts0.3.1✨@cofhe/hardhat-plugin0.4.0✨@cofhe/sdk0.4.0✨@fhenixprotocol/cofhe-contracts0.0.130.1.3@fhenixprotocol/cofhe-mock-contracts^0.2.1-alpha.0Deployment process (fresh deploy)
WETH(or use the chain's canonical WETH address).ConfidentialETHimplementation contract.ERC1967Proxypointing at theConfidentialETHimpl, passinginitialize(wethAddress)as init data.ConfidentialERC20implementation contract.RedactCore(wethAddress, eETHProxyAddress, erc20ImplAddress).ConfidentialETHproxy toRedactCoreso it can authorize future upgrades.Any user can then call
RedactCore.deployConfidentialERC20(erc20Address)to permissionlessly spin up a confidential wrapper for a supported ERC-20.Upgrade process (existing deployment)
To upgrade all future
deployConfidentialERC20calls to a new implementation:ConfidentialERC20implementation contract.RedactCore.setConfidentialERC20Implementation(newImplAddress). This only affects proxies deployed after this call.To upgrade an already-deployed wrapper proxy:
RedactCore.upgradeWrapper(proxyAddress, newImplAddress, data). This callsupgradeToAndCallon the UUPS proxy directly. Passdata = "0x"if no post-upgrade initializer is needed.Both
ConfidentialETHandConfidentialERC20proxies are upgradeable viaupgradeWrappersinceRedactCoreis their owner.