Skip to content

Commit

Permalink
Merge pull request #52 from gnosisguild/deploy-cleanup
Browse files Browse the repository at this point in the history
Better deploy script
  • Loading branch information
samepant authored Sep 13, 2024
2 parents 5a27c0e + 2c5f314 commit fb0fe39
Show file tree
Hide file tree
Showing 16 changed files with 3,131 additions and 64 deletions.
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

0 comments on commit fb0fe39

Please sign in to comment.