Skip to content

Commit

Permalink
Merge pull request #590 from zama-ai/fhevm-core-contracts
Browse files Browse the repository at this point in the history
feat: refactor importing fhevm-core-contracts
  • Loading branch information
jatZama authored Oct 25, 2024
2 parents 662abe1 + 552fa63 commit b9a0860
Show file tree
Hide file tree
Showing 44 changed files with 156 additions and 3,581 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ typechain
typechain-types
.openzeppelin/unknown*
.openzeppelin/sepolia.json
fhevmTemp/
4 changes: 3 additions & 1 deletion CustomProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class CustomProvider extends ProviderWrapper {
const blockNumberHex = await this._wrappedProvider.request({ method: 'eth_blockNumber' });
this.lastBlockSnapshot = parseInt(blockNumberHex);
this.lastBlockSnapshotForDecrypt = parseInt(blockNumberHex);
const parsedEnvCoprocessor = dotenv.parse(fs.readFileSync('lib/.env.exec'));
const parsedEnvCoprocessor = dotenv.parse(
fs.readFileSync('node_modules/fhevm-core-contracts/addresses/.env.exec'),
);
const coprocAdd = parsedEnvCoprocessor.TFHE_EXECUTOR_CONTRACT_ADDRESS;
this.lastCounterRand = await this._wrappedProvider.request({
method: 'eth_getStorageAt',
Expand Down
2 changes: 1 addition & 1 deletion examples/ACLUpgradedExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import "../lib/ACL.sol";
import "fhevm-core-contracts/contracts/ACL.sol";

contract ACLUpgradedExample is ACL {
/// @notice Name of the contract
Expand Down
2 changes: 1 addition & 1 deletion examples/ACLUpgradedExample2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import "../lib/ACL.sol";
import "fhevm-core-contracts/contracts/ACL.sol";

contract ACLUpgradedExample2 is ACL {
/// @notice Name of the contract
Expand Down
2 changes: 1 addition & 1 deletion examples/FHEPaymentUpgradedExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import "../lib/FHEPayment.sol";
import "fhevm-core-contracts/contracts/FHEPayment.sol";

contract FHEPaymentUpgradedExample is FHEPayment {
/// @notice Name of the contract
Expand Down
2 changes: 1 addition & 1 deletion examples/KMSUpgradedExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import "../lib/KMSVerifier.sol";
import "fhevm-core-contracts/contracts/KMSVerifier.sol";

contract KMSVerifierUpgradedExample is KMSVerifier {
/// @notice Name of the contract
Expand Down
2 changes: 1 addition & 1 deletion examples/TFHEExecutorUpgradedExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import "../lib/TFHEExecutor.sol";
import "fhevm-core-contracts/contracts/TFHEExecutor.sol";

/// @title TFHEExecutorUpgradedExample
/// @dev Contract that extends TFHEExecutor with version information
Expand Down
4 changes: 2 additions & 2 deletions gateway/GatewayContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "../lib/TFHE.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "../lib/KMSVerifierAddress.sol";
import "../lib/ACLAddress.sol";
import "fhevm-core-contracts/addresses/KMSVerifierAddress.sol";
import "fhevm-core-contracts/addresses/ACLAddress.sol";
import "./IKMSVerifier.sol";

contract GatewayContract is UUPSUpgradeable, Ownable2StepUpgradeable {
Expand Down
2 changes: 1 addition & 1 deletion gateway/lib/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.24;
import "./GatewayContractAddress.sol";
import "../IKMSVerifier.sol";
import "../../lib/Impl.sol";
import "../../lib/ACLAddress.sol";
import "fhevm-core-contracts/addresses/ACLAddress.sol";

interface IGatewayContract {
function requestDecryption(
Expand Down
6 changes: 6 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import dotenv from 'dotenv';
import * as fs from 'fs-extra';
import 'hardhat-deploy';
import 'hardhat-ignore-warnings';
import type { HardhatUserConfig, extendProvider } from 'hardhat/config';
import { task } from 'hardhat/config';
import type { NetworkUserConfig } from 'hardhat/types';
import { resolve } from 'path';
import * as path from 'path';

import CustomProvider from './CustomProvider';
// Adjust the import path as needed
Expand Down Expand Up @@ -102,6 +104,10 @@ task('test', async (taskArgs, hre, runSuper) => {
await hre.run('task:computeKMSVerifierAddress', { privateKey: privKeyFhevmDeployer });
await hre.run('task:computeInputVerifierAddress', { privateKey: privKeyFhevmDeployer, useAddress: false });
await hre.run('task:computeFHEPaymentAddress', { privateKey: privKeyFhevmDeployer });
const sourceDir = path.resolve(__dirname, 'node_modules/fhevm-core-contracts/');
const destinationDir = path.resolve(__dirname, 'fhevmTemp/');
fs.copySync(sourceDir, destinationDir, { dereference: true });
await hre.run('compile:specific', { contract: 'fhevmTemp' });
await hre.run('compile:specific', { contract: 'lib' });
await hre.run('compile:specific', { contract: 'gateway' });
await hre.run('compile:specific', { contract: 'payment' });
Expand Down
3 changes: 3 additions & 0 deletions launch-fhevm-sepolia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ npx hardhat clean
PRIVATE_KEY_FHEVM_DEPLOYER=$(grep PRIVATE_KEY_FHEVM_DEPLOYER .env | cut -d '"' -f 2)
NUM_KMS_SIGNERS=$(grep NUM_KMS_SIGNERS .env | cut -d '"' -f 2)

mkdir -p fhevmTemp
cp -L -r node_modules/fhevm-core-contracts fhevmTemp/
npx hardhat compile:specific --contract fhevmTemp
npx hardhat compile:specific --contract lib
npx hardhat compile:specific --contract gateway

Expand Down
1 change: 0 additions & 1 deletion lib/.env.acl

This file was deleted.

1 change: 0 additions & 1 deletion lib/.env.coprocessor

This file was deleted.

1 change: 0 additions & 1 deletion lib/.env.exec

This file was deleted.

1 change: 0 additions & 1 deletion lib/.env.fhepayment

This file was deleted.

1 change: 0 additions & 1 deletion lib/.env.inputverifier

This file was deleted.

1 change: 0 additions & 1 deletion lib/.env.kmsverifier

This file was deleted.

173 changes: 0 additions & 173 deletions lib/ACL.sol

This file was deleted.

5 changes: 0 additions & 5 deletions lib/ACLAddress.sol

This file was deleted.

5 changes: 0 additions & 5 deletions lib/CoprocessorAddress.sol

This file was deleted.

Loading

0 comments on commit b9a0860

Please sign in to comment.