Skip to content

Commit

Permalink
fix: update deploy for mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlacci committed Oct 26, 2021
1 parent 5fb57c0 commit 521c6f0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 21 deletions.
24 changes: 21 additions & 3 deletions deploy/01_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ module.exports = async ({ deployments, getChainId, getNamedAccounts, ethers }) =

const ens = {
reverseRegistrar: {
1: "0x084b1c3C81545d370f3634392De611CaaBFf8148",
4: "0x6F628b68b30Dc3c17f345c9dbBb1E483c2b7aE5c",
},
publicResolver: {
1: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
4: "0xf6305c19e814d2a75429Fd637d01F7ee0E77d615",
},
};

const TLD = {
1: "pod.xyz",
4: "pod.eth",
31337: "pod.eth",
};

const proxyFactoryAddress =
network === "31337"
? (await deployments.get("GnosisSafeProxyFactory")).address
Expand All @@ -40,16 +48,20 @@ module.exports = async ({ deployments, getChainId, getNamedAccounts, ethers }) =
const ensResolver =
network === "31337" ? (await deployments.get("PublicResolver")).address : ens.publicResolver[network];

const { address: inviteTokenAddress } = await deploy("InviteToken", {
const { address: controllerRegistryAddress } = await deploy("ControllerRegistry", {
from: deployer,
gasLimit: 8000000,
args: [],
log: true,
skipIfAlreadyDeployed: true,
});

const { address: controllerRegistryAddress } = await deploy("ControllerRegistry", {
const { address: inviteTokenAddress } = await deploy("InviteToken", {
from: deployer,
gasLimit: 8000000,
args: [],
log: true,
skipIfAlreadyDeployed: true,
});

const { address: podEnsRegistrarAddress } = await deploy("PodEnsRegistrar", {
Expand All @@ -60,15 +72,19 @@ module.exports = async ({ deployments, getChainId, getNamedAccounts, ethers }) =
ensResolver,
ensReverseRegistrar,
controllerRegistryAddress,
ethers.utils.namehash("pod.eth"),
ethers.utils.namehash(TLD[network]),
inviteTokenAddress,
],
log: true,
skipIfAlreadyDeployed: true,
});

const { address: memberTokenAddress } = await deploy("MemberToken", {
from: deployer,
gasLimit: 8000000,
args: [controllerRegistryAddress, "https://orcaprotocol-nft.vercel.app/assets/{id}.json"],
log: true,
skipIfAlreadyDeployed: true,
});

const { address: controllerAddress } = await deploy("Controller", {
Expand All @@ -81,6 +97,8 @@ module.exports = async ({ deployments, getChainId, getNamedAccounts, ethers }) =
gnosisSafeAddress,
podEnsRegistrarAddress,
],
log: true,
skipIfAlreadyDeployed: true,
});

const controllerRegistry = await ethers.getContractAt("ControllerRegistry", controllerRegistryAddress, signer);
Expand Down
76 changes: 58 additions & 18 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */

const { ENSRegistry } = require("@ensdomains/ens-contracts");
const { getEnsAddress } = require("@ensdomains/ensjs");
const { task } = require("hardhat/config");

/* eslint-disable import/no-extraneous-dependencies */
Expand All @@ -25,6 +25,13 @@ const networks = {
rinkeby: {
url: `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts,
gasPrice: 100000000000,
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts,
gasPrice: 100000000000,
timeout: 1200000, // 20 minute timeout in ms
},
};

Expand All @@ -44,21 +51,23 @@ const namedAccounts = {
},
};

task("tenderly-verify", "verifies current deployment on tenderly").setAction(async () => {
const contracts = [
{ name: "Controller", address: (await deployments.get("Controller")).address },
{ name: "MemberToken", address: (await deployments.get("MemberToken")).address },
{ name: "ControllerRegistry", address: (await deployments.get("ControllerRegistry")).address },
{ name: "PodEnsRegistrar", address: (await deployments.get("PodEnsRegistrar")).address },
];
await tenderly.verify(...contracts);
});
task("tenderly-verify", "verifies current deployment on tenderly").setAction(
async (args, { tenderly, deployments }) => {
const contracts = [
{ name: "Controller", address: (await deployments.get("Controller")).address },
{ name: "MemberToken", address: (await deployments.get("MemberToken")).address },
{ name: "ControllerRegistry", address: (await deployments.get("ControllerRegistry")).address },
{ name: "PodEnsRegistrar", address: (await deployments.get("PodEnsRegistrar")).address },
];
await tenderly.verify(...contracts);
},
);

task("set-ship-state", "sets restrictions to closed, open, onlyShip or onlySafeWithShip")
.addPositionalParam("state")
.setAction(async args => {
.setAction(async (args, { getNamedAccounts, ethers }) => {
const { deployer } = await getNamedAccounts();
PodEnsRegistrar = await ethers.getContract("PodEnsRegistrar", deployer);
const podEnsRegistrar = await ethers.getContract("PodEnsRegistrar", deployer);

const stateEnum = {
onlySafeWithShip: 0,
Expand All @@ -69,27 +78,58 @@ task("set-ship-state", "sets restrictions to closed, open, onlyShip or onlySafeW

const { state } = args;

const currentState = await PodEnsRegistrar.state();
const currentState = await podEnsRegistrar.state();
if (currentState === stateEnum[state]) {
console.log("Contract was already set to that state");
return;
}
await PodEnsRegistrar.setRestrictionState(stateEnum[state]);
await podEnsRegistrar.setRestrictionState(stateEnum[state]);
console.log(`Successfully changed state to ${state}`);
});

task("mint", "mints tokens to an address, with an optional amount")
.addPositionalParam("recipient")
.addOptionalPositionalParam("amount")
.setAction(async args => {
.setAction(async (args, { getNamedAccounts, ethers }) => {
const { deployer } = await getNamedAccounts();
InviteToken = await ethers.getContract("InviteToken", deployer);
const inviteToken = await ethers.getContract("InviteToken", deployer);

const { recipient, amount } = args;
await InviteToken.mint(recipient, amount || 1);
await inviteToken.mint(recipient, amount || 1);
console.log(`Minted ${amount || 1} tokens to ${recipient}`);
});

task("register-controller", "registers controller with controller registry")
.addOptionalPositionalParam("controller")
.setAction(async (args, { getNamedAccounts, ethers, deployments }) => {
const { deployer } = await getNamedAccounts();
const controllerRegistry = await ethers.getContract("ControllerRegistry", deployer);

const controller = args.controller || (await deployments.get("Controller", deployer)).address;

await controllerRegistry.registerController(controller);
console.log(`Registered ${controller} with controller Registry`);
});

task("ens-setApproval", "sets ens approval for podEnsRegistrar with ensHolder account")
.addOptionalPositionalParam("controller")
.setAction(async (args, { getNamedAccounts, getChainId, ethers, deployments }) => {
const { ensHolder } = await getNamedAccounts();
const ensHolderSigner = ethers.provider.getSigner(ensHolder);

const network = await getChainId();
const ensRegistryAddress =
network === "31337" ? (await deployments.get("ENSRegistry")).address : getEnsAddress(network);

const { address: podEnsRegistrarAddress } = await deployments.get("PodEnsRegistrar");

const ensRegistry = new ethers.Contract(ensRegistryAddress, ENSRegistry, ensHolderSigner);
// approve podENSRegistry to make pod.eth changes on behalf of ensHolder
await ensRegistry.setApprovalForAll(podEnsRegistrarAddress, true);

console.log(`Set ${ensHolder} approvalForAll for ${podEnsRegistrarAddress} with ens ${ensRegistryAddress}`);
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

Expand Down

0 comments on commit 521c6f0

Please sign in to comment.