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

Fix local hardhat node #79

Merged
merged 2 commits into from
Sep 16, 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
43 changes: 38 additions & 5 deletions packages/evm/deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { PoseidonT3, proxy } from "poseidon-solidity";

const THIRTY_DAYS_IN_SECONDS = 60 * 60 * 24 * 30;
const addressOne = "0x0000000000000000000000000000000000000001";
Expand All @@ -8,26 +9,58 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;

// First check if the proxy exists
if ((await hre.ethers.provider.getCode(proxy.address)) === "0x") {
// probably on the hardhat network
// fund the keyless account
const [sender] = await hre.ethers.getSigners();
await sender.sendTransaction({
to: proxy.from,
value: proxy.gas,
});

// then send the presigned transaction deploying the proxy
await hre.ethers.provider.broadcastTransaction(proxy.tx);
console.log(`Proxy deployed to: ${proxy.address}`);
}

// Then deploy the hasher, if needed
if ((await hre.ethers.provider.getCode(PoseidonT3.address)) === "0x") {
const [sender] = await hre.ethers.getSigners();
await sender.sendTransaction({
to: proxy.address,
data: PoseidonT3.data,
});

console.log(`PoseidonT3 deployed to: ${PoseidonT3.address}`);
}

// Deploy Enclave contract

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

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

// Deploy CyphernodeRegistryOwnable contract
// Deploy CiphernodeRegistryOwnable contract

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

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

Expand All @@ -47,14 +80,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
enclave.address,
);

const registryAddress = await enclaveContract.cyphernodeRegistry();
const registryAddress = await enclaveContract.ciphernodeRegistry();

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

const result = await enclaveContract.setCyphernodeRegistry(
const result = await enclaveContract.setCiphernodeRegistry(
cypherNodeRegistry.address,
);
await result.wait();
Expand Down
6 changes: 3 additions & 3 deletions packages/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ const config: HardhatUserConfig = {
arbitrumOne: vars.get("ARBISCAN_API_KEY", ""),
avalanche: vars.get("SNOWTRACE_API_KEY", ""),
bsc: vars.get("BSCSCAN_API_KEY", ""),
mainnet: ETHERSCAN_API_KEY,
mainnet: ETHERSCAN_API_KEY || "",
optimisticEthereum: vars.get("OPTIMISM_API_KEY", ""),
polygon: vars.get("POLYGONSCAN_API_KEY", ""),
polygonMumbai: vars.get("POLYGONSCAN_API_KEY", ""),
sepolia: ETHERSCAN_API_KEY,
sepolia: ETHERSCAN_API_KEY || "",
},
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS ? true : false,
excludeContracts: [],
src: "./contracts",
},
networks: {
hardhat: {
Expand Down Expand Up @@ -130,6 +129,7 @@ const config: HardhatUserConfig = {
},
overrides: {
"node_modules/poseidon-solidity/PoseidonT3.sol": {
version: "0.7.0",
settings: {
optimizer: {
enabled: true,
Expand Down
Loading