Skip to content

Commit

Permalink
Merge pull request #79 from gnosisguild/local-node-fix
Browse files Browse the repository at this point in the history
Fix local hardhat node
  • Loading branch information
samepant authored Sep 16, 2024
2 parents 9e7d734 + 4a3458f commit ab4a26a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
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

0 comments on commit ab4a26a

Please sign in to comment.