Skip to content
Merged
5 changes: 5 additions & 0 deletions .changeset/beige-fans-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-confidential-contracts': minor
---

Migrate `@fhevm/solidity` from v0.7.0 to 0.8.0
5 changes: 3 additions & 2 deletions contracts/mocks/docs/SwapERC7984ToERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ contract VestingWalletCliffExecutorConfidential is VestingWalletCliffConfidentia
__ERC7821WithExecutor_init(executor);

FHE.setCoprocessor(ZamaConfig.getSepoliaConfig());
FHE.setDecryptionOracle(ZamaConfig.getSepoliaOracleAddress());
}
}
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/token/ERC7984/ERC7984.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 7 additions & 2 deletions contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
70 changes: 46 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions test/helpers/accounts.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion test/token/ERC7984/ERC7984.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC7984/extensions/ERC7984Freezable.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 };
}

Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC7984/extensions/ERC7984Omnibus.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC7984/extensions/ERC7984Wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

Expand Down