diff --git a/.changeset/beige-fans-call.md b/.changeset/beige-fans-call.md new file mode 100644 index 00000000..a1ca054c --- /dev/null +++ b/.changeset/beige-fans-call.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-confidential-contracts': minor +--- + +Migrate `@fhevm/solidity` from v0.7.0 to 0.8.0 diff --git a/contracts/mocks/docs/SwapERC7984ToERC20.sol b/contracts/mocks/docs/SwapERC7984ToERC20.sol index 16b8e7d5..7231e571 100644 --- a/contracts/mocks/docs/SwapERC7984ToERC20.sol +++ b/contracts/mocks/docs/SwapERC7984ToERC20.sol @@ -31,8 +31,9 @@ contract SwapConfidentialToERC20 { _receivers[requestID] = msg.sender; } - function finalizeSwap(uint256 requestID, uint64 amount, bytes[] memory signatures) public virtual { - FHE.checkSignatures(requestID, signatures); + function finalizeSwap(uint256 requestID, bytes calldata cleartexts, bytes calldata decryptionProof) public virtual { + FHE.checkSignatures(requestID, cleartexts, decryptionProof); + uint64 amount = abi.decode(cleartexts, (uint64)); address to = _receivers[requestID]; require(to != address(0), SwapConfidentialToERC20InvalidGatewayRequest(requestID)); delete _receivers[requestID]; diff --git a/contracts/mocks/finance/VestingWalletConfidentialFactoryMock.sol b/contracts/mocks/finance/VestingWalletConfidentialFactoryMock.sol index 71bd97f8..f19b7994 100644 --- a/contracts/mocks/finance/VestingWalletConfidentialFactoryMock.sol +++ b/contracts/mocks/finance/VestingWalletConfidentialFactoryMock.sol @@ -62,6 +62,5 @@ contract VestingWalletCliffExecutorConfidential is VestingWalletCliffConfidentia __ERC7821WithExecutor_init(executor); FHE.setCoprocessor(ZamaConfig.getSepoliaConfig()); - FHE.setDecryptionOracle(ZamaConfig.getSepoliaOracleAddress()); } } diff --git a/contracts/package.json b/contracts/package.json index e16e9917..8aeeffa4 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -32,7 +32,7 @@ }, "homepage": "https://openzeppelin.com/contracts/", "peerDependencies": { - "@fhevm/solidity": "0.7.0", + "@fhevm/solidity": "0.8.0", "@openzeppelin/contracts": "^5.4.0", "@openzeppelin/contracts-upgradeable": "^5.4.0" } diff --git a/contracts/token/ERC7984/ERC7984.sol b/contracts/token/ERC7984/ERC7984.sol index 1d93756f..76e74438 100644 --- a/contracts/token/ERC7984/ERC7984.sol +++ b/contracts/token/ERC7984/ERC7984.sol @@ -219,11 +219,11 @@ abstract contract ERC7984 is IERC7984 { */ function finalizeDiscloseEncryptedAmount( uint256 requestId, - uint64 amount, - bytes[] memory signatures + bytes calldata cleartexts, + bytes calldata decryptionProof ) public virtual { - FHE.checkSignatures(requestId, signatures); - + FHE.checkSignatures(requestId, cleartexts, decryptionProof); + uint64 amount = abi.decode(cleartexts, (uint64)); euint64 requestHandle = euint64.wrap(FHE.loadRequestedHandles(requestId)[0]); emit AmountDisclosed(requestHandle, amount); } diff --git a/contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol b/contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol index 3d7609c7..9af25aa7 100644 --- a/contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol +++ b/contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol @@ -127,8 +127,13 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver { /** * @dev Fills an unwrap request for a given request id related to a decrypted unwrap amount. */ - function finalizeUnwrap(uint256 requestID, uint64 amount, bytes[] memory signatures) public virtual { - FHE.checkSignatures(requestID, signatures); + function finalizeUnwrap( + uint256 requestID, + bytes calldata cleartexts, + bytes calldata decryptionProof + ) public virtual { + FHE.checkSignatures(requestID, cleartexts, decryptionProof); + uint64 amount = abi.decode(cleartexts, (uint64)); address to = _receivers[requestID]; require(to != address(0), ERC7984InvalidGatewayRequest(requestID)); delete _receivers[requestID]; diff --git a/package-lock.json b/package-lock.json index ed7daf15..aa513fe6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,8 @@ "@changesets/read": "^0.6.0", "@eslint/compat": "^1.2.8", "@eslint/js": "^9.9.0", - "@fhevm/core-contracts": "0.7.0-12", - "@fhevm/hardhat-plugin": "0.0.1-3", - "@fhevm/solidity": "0.7.0", + "@fhevm/hardhat-plugin": "^0.1.0", + "@fhevm/solidity": "0.8.0", "@nomicfoundation/hardhat-chai-matchers": "^2.0.6", "@nomicfoundation/hardhat-ethers": "^3.0.4", "@nomicfoundation/hardhat-network-helpers": "^1.0.3", @@ -34,7 +33,7 @@ "@types/node": "^18.19.59", "@typescript-eslint/eslint-plugin": "^8.0.1", "@typescript-eslint/parser": "^8.0.1", - "@zama-fhe/relayer-sdk": "^0.1.0-5", + "@zama-fhe/relayer-sdk": "^0.2.0", "chai": "^4.3.7", "cross-env": "^7.0.3", "dotenv": "^16.0.3", @@ -1976,7 +1975,9 @@ } }, "node_modules/@fhevm/core-contracts": { - "version": "0.7.0-12", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@fhevm/core-contracts/-/core-contracts-0.8.0.tgz", + "integrity": "sha512-jQ2gyoTH0DZfOyOCQKLfV11agOVqrwZ7YfpLKdHDVjjXSO9gWIrXrvmUS6eV6zhED+PDHAcX0vfGGfLmsEBMTA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -1988,11 +1989,13 @@ } }, "node_modules/@fhevm/hardhat-plugin": { - "version": "0.0.1-3", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@fhevm/hardhat-plugin/-/hardhat-plugin-0.1.0.tgz", + "integrity": "sha512-u8gNJt/K+ggxgaESM7pbUpxu3wbiwtDOF+ONb8XJIlDmqnv/O4zkhide/+TTlF8X831tBd8cLwvJlWOzhgfZnQ==", "dev": true, "license": "BSD-3-Clause-Clear", "dependencies": { - "@fhevm/core-contracts": "0.7.0-12", + "@fhevm/core-contracts": "0.8.0", "debug": "^4.1.1", "dotenv": "^16.5.0", "picocolors": "^1.1.1", @@ -2003,22 +2006,25 @@ "npm": ">=7.0.0" }, "peerDependencies": { - "@fhevm/mock-utils": "0.0.1-3", - "@fhevm/solidity": "^0.7.0", + "@fhevm/mock-utils": "0.1.0", + "@fhevm/solidity": "^0.8.0", "@nomicfoundation/hardhat-ethers": "^3.0.8", "@zama-fhe/oracle-solidity": "^0.1.0", - "@zama-fhe/relayer-sdk": "^0.1.0-5", + "@zama-fhe/relayer-sdk": "^0.2.0", + "encrypted-types": "^0.0.4", "ethers": "^6.1.0", "hardhat": "^2.0.0" } }, "node_modules/@fhevm/mock-utils": { - "version": "0.0.1-3", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@fhevm/mock-utils/-/mock-utils-0.1.0.tgz", + "integrity": "sha512-MZk+hXNrO4t0kIgoO9nLln9lKCefCe6gCAKeBhwAMmndIdYGIGkNJHVTbqAAMWS7wPTsA5pkR47BWvX0N6XaZQ==", "dev": true, "license": "BSD-3-Clause-Clear", "peer": true, "peerDependencies": { - "@zama-fhe/relayer-sdk": "^0.1.0-5", + "@zama-fhe/relayer-sdk": "^0.2.0", "ethers": "^6.1.0", "typescript": ">=5.0.4" }, @@ -2029,7 +2035,9 @@ } }, "node_modules/@fhevm/solidity": { - "version": "0.7.0", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@fhevm/solidity/-/solidity-0.8.0.tgz", + "integrity": "sha512-+jpjPcJbwE+eNRhCn4IwQ2mcH11W9TW0GepwJh0aWm/oN1pmvmapHkj3WiLtG+PorQ8LDMgaq7+LO8hyVYKEzA==", "dev": true, "license": "BSD-3-Clause-Clear", "dependencies": { @@ -3662,6 +3670,8 @@ }, "node_modules/@zama-fhe/oracle-solidity": { "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@zama-fhe/oracle-solidity/-/oracle-solidity-0.1.0.tgz", + "integrity": "sha512-phRego2FW7SWgneQOES/iQ99c97ZCb+KZk5m+lT474dSNrsgEDh96W9T1+Owhc9C6VKtCpMLM43dHXwKHDIw6g==", "dev": true, "license": "BSD-3-Clause", "peer": true, @@ -3670,18 +3680,20 @@ } }, "node_modules/@zama-fhe/relayer-sdk": { - "version": "0.1.0-9", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@zama-fhe/relayer-sdk/-/relayer-sdk-0.2.0.tgz", + "integrity": "sha512-phgpQgqdpIDYKihNdBt3JQtvkKjZpG5a2l+bwh5JJvvUuLG1jkoHbd1LGWvtxd7rF54TIAyupIEIMM0C1Qj1xw==", "dev": true, "license": "BSD-3-Clause-Clear", "dependencies": { "commander": "^14.0.0", - "ethers": "^6.13.4", + "ethers": "^6.15.0", "fetch-retry": "^6.0.0", "keccak": "^3.0.4", - "node-tfhe": "^1.1.3", - "node-tkms": "0.11.0-rc17", - "tfhe": "^1.1.3", - "tkms": "0.11.0-rc17", + "node-tfhe": "1.3.0", + "node-tkms": "^0.11.0", + "tfhe": "1.3.0", + "tkms": "^0.11.0", "wasm-feature-detect": "^1.8.0" }, "bin": { @@ -5836,7 +5848,9 @@ } }, "node_modules/ethers": { - "version": "6.14.4", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.15.0.tgz", + "integrity": "sha512-Kf/3ZW54L4UT0pZtsY/rf+EkBU7Qi5nnhonjUb8yTXcxH3cdcWrV2cRyk0Xk/4jK6OoHhxxZHriyhje20If2hQ==", "dev": true, "funding": [ { @@ -9180,12 +9194,16 @@ } }, "node_modules/node-tfhe": { - "version": "1.2.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/node-tfhe/-/node-tfhe-1.3.0.tgz", + "integrity": "sha512-BhqHFH1sFp9bziPfar2MqtZI1NT+fsqt6w+q6l1bUFn7ENTwGbjZqZIPGuPKxgnWF6iqMhwVG5IYpKpAwil6oA==", "dev": true, "license": "BSD-3-Clause-Clear" }, "node_modules/node-tkms": { - "version": "0.11.0-rc17", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/node-tkms/-/node-tkms-0.11.1.tgz", + "integrity": "sha512-AWciFzfvjEYECHiAJXv1KLz6K28fX/0DDlaktAbslF2XpaIGsc9sCKjYPJHubrJfNrtUWUI5qfqhJOP3BD/mcw==", "dev": true, "license": "BSD-3-Clause-Clear" }, @@ -11756,7 +11774,9 @@ "license": "MIT" }, "node_modules/tfhe": { - "version": "1.2.0", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tfhe/-/tfhe-1.3.0.tgz", + "integrity": "sha512-SYySiMB/hCPJmy3K8RliVYCN4mV/p5+EJozaYfXTS0UEl3aS+1b71XqGfI1KDucYHelVS1iWgF7+uO2wNqQQ/g==", "dev": true, "license": "BSD-3-Clause-Clear" }, @@ -11800,7 +11820,9 @@ } }, "node_modules/tkms": { - "version": "0.11.0-rc17", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/tkms/-/tkms-0.11.1.tgz", + "integrity": "sha512-FNpnwZKsUUMs0q4aAwZatpw7fz1UBG9cdh3LZYgWYN3rvouS+v4zysB642dG8J35KgNF6WCFAzTyRKagdL8x7g==", "dev": true, "license": "BSD-3-Clause-Clear" }, diff --git a/package.json b/package.json index 1687b67e..2b2d5609 100644 --- a/package.json +++ b/package.json @@ -44,9 +44,8 @@ "@changesets/read": "^0.6.0", "@eslint/compat": "^1.2.8", "@eslint/js": "^9.9.0", - "@fhevm/core-contracts": "0.7.0-12", - "@fhevm/hardhat-plugin": "0.0.1-3", - "@fhevm/solidity": "0.7.0", + "@fhevm/hardhat-plugin": "^0.1.0", + "@fhevm/solidity": "0.8.0", "@nomicfoundation/hardhat-chai-matchers": "^2.0.6", "@nomicfoundation/hardhat-ethers": "^3.0.4", "@nomicfoundation/hardhat-network-helpers": "^1.0.3", @@ -63,7 +62,7 @@ "@types/node": "^18.19.59", "@typescript-eslint/eslint-plugin": "^8.0.1", "@typescript-eslint/parser": "^8.0.1", - "@zama-fhe/relayer-sdk": "^0.1.0-5", + "@zama-fhe/relayer-sdk": "^0.2.0", "chai": "^4.3.7", "cross-env": "^7.0.3", "dotenv": "^16.0.3", diff --git a/test/helpers/accounts.ts b/test/helpers/accounts.ts index f63fc36e..f4e2a90f 100644 --- a/test/helpers/accounts.ts +++ b/test/helpers/accounts.ts @@ -1,11 +1,9 @@ -import constants from '../../node_modules/@fhevm/hardhat-plugin/src/constants'; import { impersonateAccount, setBalance } from '@nomicfoundation/hardhat-network-helpers'; import { Addressable, Signer, ethers } from 'ethers'; import fs from 'fs'; +import { fhevm } from 'hardhat'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; -export const ACL_ADDRESS = constants.ACL_CONTRACT_ADDRESS; - const DEFAULT_BALANCE: bigint = 10000n * ethers.WeiPerEther; export async function impersonate(hre: HardhatRuntimeEnvironment, account: string, balance: bigint = DEFAULT_BALANCE) { @@ -14,11 +12,15 @@ export async function impersonate(hre: HardhatRuntimeEnvironment, account: strin .then(() => hre.ethers.getSigner(account)); } +export async function getAclAddress() { + return (await fhevm.getRelayerMetadata()).ACLAddress; +} + export async function allowHandle(hre: HardhatRuntimeEnvironment, from: Signer, to: Addressable, handle: string) { const acl_abi = JSON.parse( fs.readFileSync('node_modules/@fhevm/core-contracts/artifacts/contracts/ACL.sol/ACL.json', 'utf8'), ).abi; - const aclContract = await hre.ethers.getContractAt(acl_abi, ACL_ADDRESS); + const aclContract = await hre.ethers.getContractAt(acl_abi, await getAclAddress()); await aclContract.connect(from).allow(handle, to); } diff --git a/test/token/ERC7984/ERC7984.test.ts b/test/token/ERC7984/ERC7984.test.ts index d28fcbb7..a6f7a810 100644 --- a/test/token/ERC7984/ERC7984.test.ts +++ b/test/token/ERC7984/ERC7984.test.ts @@ -567,7 +567,7 @@ describe('ERC7984', function () { const holderBalanceHandle = await this.token.confidentialBalanceOf(this.holder); await this.token.connect(this.holder).discloseEncryptedAmount(holderBalanceHandle); - await expect(this.token.connect(this.holder).finalizeDiscloseEncryptedAmount(0, 0, [])).to.be.reverted; + await expect(this.token.connect(this.holder).finalizeDiscloseEncryptedAmount(0, '0x', '0x')).to.be.reverted; }); afterEach(async function () { diff --git a/test/token/ERC7984/extensions/ERC7984Freezable.test.ts b/test/token/ERC7984/extensions/ERC7984Freezable.test.ts index 995d44ae..48e3f825 100644 --- a/test/token/ERC7984/extensions/ERC7984Freezable.test.ts +++ b/test/token/ERC7984/extensions/ERC7984Freezable.test.ts @@ -1,6 +1,6 @@ import { IACL__factory } from '../../../../types'; import { $ERC7984FreezableMock } from '../../../../types/contracts-exposed/mocks/token/ERC7984FreezableMock.sol/$ERC7984FreezableMock'; -import { ACL_ADDRESS } from '../../../helpers/accounts'; +import { getAclAddress } from '../../../helpers/accounts'; import { FhevmType } from '@fhevm/hardhat-plugin'; import { expect } from 'chai'; import { AddressLike, BytesLike, EventLog } from 'ethers'; @@ -19,7 +19,7 @@ describe('ERC7984Freezable', function () { uri, freezer.address, ])) as any as $ERC7984FreezableMock; - const acl = IACL__factory.connect(ACL_ADDRESS, ethers.provider); + const acl = IACL__factory.connect(await getAclAddress(), ethers.provider); return { token, acl, holder, recipient, freezer, operator, anyone }; } diff --git a/test/token/ERC7984/extensions/ERC7984Omnibus.test.ts b/test/token/ERC7984/extensions/ERC7984Omnibus.test.ts index 3c805550..70863203 100644 --- a/test/token/ERC7984/extensions/ERC7984Omnibus.test.ts +++ b/test/token/ERC7984/extensions/ERC7984Omnibus.test.ts @@ -1,6 +1,6 @@ import { IACL__factory } from '../../../../types'; import { $ERC7984OmnibusMock } from '../../../../types/contracts-exposed/mocks/token/ERC7984OmnibusMock.sol/$ERC7984OmnibusMock'; -import { ACL_ADDRESS } from '../../../helpers/accounts'; +import { getAclAddress } from '../../../helpers/accounts'; import { FhevmType } from '@fhevm/hardhat-plugin'; import { expect } from 'chai'; import { ethers, fhevm } from 'hardhat'; @@ -17,7 +17,7 @@ describe('ERC7984Omnibus', function () { symbol, uri, ])) as any as $ERC7984OmnibusMock; - const acl = IACL__factory.connect(ACL_ADDRESS, ethers.provider); + const acl = IACL__factory.connect(await getAclAddress(), ethers.provider); Object.assign(this, { token, acl, holder, recipient, operator, subaccount }); await this.token['$_mint(address,uint64)'](this.holder.address, 1000); diff --git a/test/token/ERC7984/extensions/ERC7984Wrapper.test.ts b/test/token/ERC7984/extensions/ERC7984Wrapper.test.ts index 1c3014de..37b0ccac 100644 --- a/test/token/ERC7984/extensions/ERC7984Wrapper.test.ts +++ b/test/token/ERC7984/extensions/ERC7984Wrapper.test.ts @@ -240,7 +240,7 @@ describe('ERC7984Wrapper', function () { }); it('finalized with invalid signature', async function () { - await expect(this.wrapper.connect(this.holder).finalizeUnwrap(0, 0, [])).to.be.reverted; + await expect(this.wrapper.connect(this.holder).finalizeUnwrap(0, '0x', '0x')).to.be.reverted; }); });