Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better deploy script #52

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules


# ciphernode
target
target

*.DS_Store
4 changes: 4 additions & 0 deletions packages/evm/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MNEMONIC=
INFURA_KEY=

ETHERSCAN_API_KEY=
1 change: 0 additions & 1 deletion packages/evm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ coverage
dist
node_modules
types
deployments

# files
*.env
Expand Down
12 changes: 12 additions & 0 deletions packages/evm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Enclave EVM

## To deploy

```
yarn deploy --network [network]
```

This will add the deployment information to the `./deployments` directory.

Be sure to configure your desired network in `hardhat.config.ts` before
deploying.
4 changes: 2 additions & 2 deletions packages/evm/contracts/registry/NaiveRegistryFilter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable {
// //
////////////////////////////////////////////////////////////

constructor(address _owner, address _enclave) {
initialize(_owner, _enclave);
constructor(address _owner, address _registry) {
initialize(_owner, _registry);
}

function initialize(address _owner, address _registry) public initializer {
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/contracts/test/MockRegistryFilter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IRegistry {
) external;
}

contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable {
contract MockNaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable {
struct Committee {
address[] nodes;
uint32[2] threshold;
Expand Down
47 changes: 46 additions & 1 deletion packages/evm/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,63 @@ import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const THIRTY_DAYS_IN_SECONDS = 60 * 60 * 24 * 30;
const addressOne = "0x0000000000000000000000000000000000000001";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;

// Deploy Enclave contract

const enclave = await deploy("Enclave", {
from: deployer,
args: [THIRTY_DAYS_IN_SECONDS],
args: [deployer, addressOne, THIRTY_DAYS_IN_SECONDS],
log: true,
});

console.log(`Enclave contract: `, enclave.address);

// Deploy CyphernodeRegistryOwnable contract

const cypherNodeRegistry = await deploy("CyphernodeRegistryOwnable", {
from: deployer,
args: [deployer, enclave.address],
log: true,
});

console.log(
`CyphernodeRegistryOwnable contract: `,
cypherNodeRegistry.address,
);

// Deploy NaiveRegistryFilter contract

const naiveRegistryFilter = await deploy("NaiveRegistryFilter", {
from: deployer,
args: [deployer, cypherNodeRegistry.address],
log: true,
});

console.log(`NaiveRegistryFilter contract: `, naiveRegistryFilter.address);

// set registry in enclave
const enclaveContract = await hre.ethers.getContractAt(
"Enclave",
enclave.address,
);

const registryAddress = await enclaveContract.cyphernodeRegistry();

if (registryAddress === cypherNodeRegistry.address) {
console.log(`Enclave contract already has registry`);
return;
}

const result = await enclaveContract.setCyphernodeRegistry(
cypherNodeRegistry.address,
);
await result.wait();
console.log(`Enclave contract updated with registry`);
};
export default func;
func.id = "deploy_enclave"; // id required to prevent reexecution
Expand Down
1 change: 1 addition & 0 deletions packages/evm/deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading
Loading