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

Deploy staging #130

Merged
merged 3 commits into from
Nov 10, 2023
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
1,548 changes: 1,548 additions & 0 deletions .openzeppelin/polygon-mumbai.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions deployments/80001.DAORoles.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions deployments/80001.DIAOracleV2Mock.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions deployments/80001.GovernanceToken.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608","NEOKingdom DAO Governance","NEOKGOV"]
1 change: 1 addition & 0 deletions deployments/80001.InternalMarket.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608","0xf4537D936a31abb933acdBF288a274eC732B15aF"]
1 change: 1 addition & 0 deletions deployments/80001.NeokingdomToken.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["NEOKingdom DAO","NEOK"]
1 change: 1 addition & 0 deletions deployments/80001.ProxyAdmin.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions deployments/80001.RedemptionController.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608"]
1 change: 1 addition & 0 deletions deployments/80001.ResolutionManager.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608","0x5b8f86C4010e58347afCEB7820A1c410b845D5d1","0xf4537D936a31abb933acdBF288a274eC732B15aF","0x74FdD2b10cF71B9b7AEB402F90aDE1a67D9C2258"]
1 change: 1 addition & 0 deletions deployments/80001.ShareholderRegistry.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608","NeokingdomDAO Share","NEOKSHARE"]
1 change: 1 addition & 0 deletions deployments/80001.TokenMock.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions deployments/80001.Voting.arguments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608"]
57 changes: 57 additions & 0 deletions deployments/80001.network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"DAORoles": {
"address": "0x7c5303cD3375711ff47CDEe2CB2AD2cF2e415608",
"blockNumber": 41716417,
"blockHash": "0x22e4050701fc9b3f840bccc7ac4a435f91da91d8d313f7c17b0b3b2d26f51653"
},
"TokenMock": {
"address": "0x32cac81e324F5eca265DfEcf0eDCcc277e1B4DE6",
"blockNumber": 41716430,
"blockHash": "0xafd5e2fd7f21556162a960c1cf61d919174d5eb59c17875c01168ccc7ae02c8d"
},
"DIAOracleV2Mock": {
"address": "0x0F7755e7B1cf0f8015180E67C97271471808d150",
"blockNumber": 41716448,
"blockHash": "0xc689bf80159aac4f28568bb580b75924d138d4055be50129d316e0b62a733b93"
},
"Voting": {
"address": "0x74FdD2b10cF71B9b7AEB402F90aDE1a67D9C2258",
"blockNumber": 41716462,
"blockHash": "0x6f251f3ad964601e4906d4966a98f9abfe85df3b530e764b6d05b2f71e4ba265"
},
"GovernanceToken": {
"address": "0xf4537D936a31abb933acdBF288a274eC732B15aF",
"blockNumber": 41716500,
"blockHash": "0x03652b4a41e53f8d614e6af957b670b92df43a30404e33b9a38a1931467324ea"
},
"NeokingdomToken": {
"address": "0xdC6dc5c5524A77633EF1b3eFb08fe0950A155E44",
"blockNumber": 41716528,
"blockHash": "0xbc5935a875c8b4283b9e1b7f2867cb9c65b9c5e0d76600cd2492b9006209b71f"
},
"RedemptionController": {
"address": "0xF610a6EB92023DCb716E218Bf8225d862F8e4A0e",
"blockNumber": 41716550,
"blockHash": "0x44a5d8b3b4065446cebf4af1abb8ed05b2439939e4611cc5e6bcc4e01e5f54d2"
},
"InternalMarket": {
"address": "0xd345D53144E237C69F08B543553FAFc78d14Ab24",
"blockNumber": 41716575,
"blockHash": "0x6e496da76dfde9f860abbf95aba5c51be0f779e3c7be5999a2a18bb0b66b4175"
},
"ShareholderRegistry": {
"address": "0x5b8f86C4010e58347afCEB7820A1c410b845D5d1",
"blockNumber": 41716600,
"blockHash": "0x2e41d94bedaa5dce30d553e37837256f533c0eb258d5e6a59f2974a92fbc93c0"
},
"ResolutionManager": {
"address": "0x62279b0624da9Ade912273C9F88287596c66e1F1",
"blockNumber": 41716626,
"blockHash": "0x098660d6b4fcc1faab2a517c78cf6b25e55c2c290b03ddf3ee1f6bbfe5d465a7"
},
"ProxyAdmin": {
"address": "0x5928Ffd33a8a57D1e82d5D5fCa6D1C9c6fe3150d",
"blockNumber": 41716645,
"blockHash": "0x405695bff1ae47693a5ddc7b25ec2c0a1c0e5e55d511c2698ba067b6598ef965"
}
}
1 change: 1 addition & 0 deletions deployments/80001.setup.nextstep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
6 changes: 3 additions & 3 deletions dev-wallets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
"name": "albi",
"address": "0x197970E48082CD46f277ABDb8afe492bCCd78300",
"status": "contributor",
"status": "board",
"tokens": "20000000000000000000000"
},
{
"name": "gian",
"address": "0x8e2e09eb2a0a8e6e1d8de3e5fb09ec1e05b0cdbf",
"status": "contributor",
"status": "board",
"tokens": "12000000000000000000000"
},
{
Expand All @@ -20,7 +20,7 @@
{
"name": "nicola",
"address": "0x2e1aF63Cd595A6D715E5e2D92151801F0d406a6b",
"status": "contributor",
"status": "board",
"tokens": "22000000000000000000000"
}
]
5 changes: 3 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import("./tasks").catch((e) => console.log("Cannot load tasks", e.toString()));

const BLAST_API_KEY = process.env.BLAST_API_KEY || "";
const MUMBAI_PRIVATE_KEY =
process.env.RINKEBY_PRIVATE_KEY! ||
process.env.MUMBAI_PRIVATE_KEY! ||
"0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"; // well known private key
const POLYGON_PRIVATE_KEY =
process.env.POLYGON_PRIVATE_KEY! ||
Expand Down Expand Up @@ -65,7 +65,8 @@ const config: HardhatUserConfig = {
url: "http://127.0.0.1:8545",
},
mumbai: {
url: `https://polygon-testnet.blastapi.io/${BLAST_API_KEY}`,
//url: `https://polygon-testnet.blastapi.io/${BLAST_API_KEY}`,
url: "https://polygon-mumbai-bor.publicnode.com",
accounts: [MUMBAI_PRIVATE_KEY],
},
polygon: {
Expand Down
28 changes: 19 additions & 9 deletions lib/internal/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ export abstract class NeokingdomDAO {
} as Config;
}

public getNextStepFilename() {
return `./deployments/${this.config.chainId}.nextstep`;
public getNextStepFilename(sequenceName: string) {
return `./deployments/${this.config.chainId}.${sequenceName}.nextstep`;
}

public async setNextStep(n: number) {
await writeFile(this.getNextStepFilename(), n.toString());
public async setNextStep(n: number, sequenceName: string) {
await writeFile(this.getNextStepFilename(sequenceName), n.toString());
}

public async getNextStep() {
public async getNextStep(sequenceName: string) {
try {
return parseInt(await readFile(this.getNextStepFilename(), "utf8"));
return parseInt(
await readFile(this.getNextStepFilename(sequenceName), "utf8")
);
} catch (e) {
if ((e as any).code !== "ENOENT") {
throw e;
Expand All @@ -66,12 +68,13 @@ export abstract class NeokingdomDAO {
async run<T extends Context>(
c: ContextGenerator<T>,
s: Sequence<T>,
sequenceName: string,
config: { force?: boolean; restart?: boolean } = {}
) {
const { force, restart } = config;
const sequence = await this._preprocessSequence(c, s);
const nextStep = restart ? 0 : await this.getNextStep();
await this._executeSequence(c, sequence, nextStep, force);
const nextStep = restart ? 0 : await this.getNextStep(sequenceName);
await this._executeSequence(c, sequence, sequenceName, nextStep, force);
}

// There are situations where you don't have all contracts available, and a
Expand Down Expand Up @@ -117,9 +120,16 @@ export abstract class NeokingdomDAO {
private async _executeSequence<T extends Context>(
c: ContextGenerator<T>,
s: ProcessedSequence<T>,
sequenceName: string,
nextStep = 0,
force = false
) {
if (nextStep >= s.length) {
throw new Error(
`Sequence already executed, to run it use the "--restart" flag or ` +
`remove the file ${this.getNextStepFilename(sequenceName)}.`
);
}
for (let i = nextStep; i < s.length; i++) {
const context = await c(this);
const step = s[i];
Expand All @@ -143,7 +153,7 @@ export abstract class NeokingdomDAO {
if (tx) {
await tx.wait(1);
}
await this.setNextStep(i + 1);
await this.setNextStep(i + 1, sequenceName);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function isContractName(name: string): name is ContractNames {
}
const WAIT_BLOCKS = process.env.WAIT_BLOCKS
? parseInt(process.env.WAIT_BLOCKS)
: 1;
: 5;

function getConfigPath(chainId: number) {
return `./deployments/${chainId}.network.json`;
Expand Down Expand Up @@ -128,8 +128,8 @@ export async function _deployContract(
);

if (verify) {
console.log("Wait 2 blocks");
await contract.deployTransaction.wait(2);
console.log(`Wait ${WAIT_BLOCKS} blocks`);
await contract.deployTransaction.wait(WAIT_BLOCKS);
console.log("Verify contract");
try {
await hre.run("verify", {
Expand Down Expand Up @@ -224,6 +224,7 @@ const CHAINID_TO_NAME = {
666666: "localhost",
9000: "tevmos",
9001: "evmos",
80001: "mumbai",
} as const;

const CHAINIDS = Object.keys(CHAINID_TO_NAME).map((c) => parseInt(c));
Expand Down
22 changes: 18 additions & 4 deletions tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ task("deploy:dao", "Deploy DAO")
verifyContracts: verify,
verbose: true,
});
await neokingdom.run(generateDeployContext, DEPLOY_SEQUENCE, { restart });
await neokingdom.run(generateDeployContext, DEPLOY_SEQUENCE, "deploy", {
restart,
});
}
);

Expand All @@ -43,7 +45,11 @@ task("setup:dao", "Set up the DAO")
const neokingdom = await NeokingdomDAOHardhat.initialize(hre, {
verbose: true,
});
await neokingdom.run(generateSetupContext(contributors, hre), sequence);
await neokingdom.run(
generateSetupContext(contributors, hre),
sequence,
"setup"
);
});

task("setup:vigodarzere", "Set up the DAO").setAction(async (_, hre) => {
Expand All @@ -52,7 +58,11 @@ task("setup:vigodarzere", "Set up the DAO").setAction(async (_, hre) => {
const neokingdom = await NeokingdomDAOHardhat.initialize(hre, {
verbose: true,
});
await neokingdom.run(generateSetupContext([], hre), sequence);
await neokingdom.run(
generateSetupContext([], hre),
sequence,
"setup-vigodarzere"
);
});

task("setup:acl", "Set up ACL")
Expand All @@ -78,6 +88,10 @@ task("setup:acl", "Set up ACL")
const neokingdom = await NeokingdomDAOHardhat.initialize(hre, {
verbose: true,
});
await neokingdom.run(generateSetupContext([], hre), sequence);
await neokingdom.run(
generateSetupContext([], hre),
sequence,
"setup-acl"
);
}
});