Skip to content

Commit 6716afd

Browse files
authored
Merge pull request #307 from api3dao/update-deployment-script
Update deployment script
2 parents 0b8bb17 + 56e26c1 commit 6716afd

3 files changed

Lines changed: 100 additions & 26 deletions

File tree

packages/api3-voting/arapp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
"appName": "api3voting.aragonpm.eth",
77
"registry": "0xdA71454D2a71D63116cd67099e4a0fdd3a8Dfb47"
88
},
9+
"mainnet": {
10+
"apm": {
11+
"ipfs": {
12+
"gateway": "https://ipfs.eth.aragon.network/ipfs"
13+
}
14+
},
15+
"network": "mainnet",
16+
"appName": "api3voting.open.aragonpm.eth",
17+
"wsRPC": "wss://mainnet.infura.io/ws/v3/4c9049736af84c46ad0972910df0476a",
18+
"rpc": "https://mainnet.infura.io/v3/4c9049736af84c46ad0972910df0476a",
19+
"registry": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
20+
},
921
"rinkeby": {
1022
"apm": {
1123
"ipfs": {

packages/api3-voting/buidler.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
url: "https://mainnet.infura.io/v3/4c9049736af84c46ad0972910df0476a",
3535
chainId: 1,
3636
accounts: [process.env.MAINNET_PRIVATE_KEY || ""],
37+
gasPrice: 50000000000,
3738
},
3839
ropsten: {
3940
url: "https://ropsten.infura.io/v3/4c9049736af84c46ad0972910df0476a",

packages/dao/scripts/deploy.js

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ const Api3Token = artifacts.require("Api3Token");
1212
const Convenience = artifacts.require("Convenience");
1313
const TimelockManager = artifacts.require("TimelockManager");
1414

15-
const daoId = `api3-template-${Math.random().toString(36).substring(7)}`;
1615
const supportRequiredPct1 = 50e16;
1716
const minAcceptQuorumPct1 = 50e16;
1817
const supportRequiredPct2 = 50e16;
1918
const minAcceptQuorumPct2 = 15e16;
2019

20+
const gasPrice = "55" + "000" + "000" + "000";
21+
2122
/**
2223
* Returns the address of the deployer
2324
*/
@@ -44,29 +45,75 @@ const getDeployer = async () => {
4445
module.exports = async (callback) => {
4546
try {
4647
const network = await getNetworkName();
48+
const deployer = await getDeployer();
49+
50+
let api3Token, api3Pool;
51+
let api3TokenAddress, timelockManagerAddress;
4752
if (network === "mainnet") {
48-
// TODO: We should use specific daoId and do NOT create new token and pool instance
49-
throw new Error("This script is not yet ready for mainnet deployment!");
53+
// TODO: replace below with 0x0b38210ea11411557c13457D4dA7dC6ea731B88a
54+
api3TokenAddress = "0x0000000000000000000000000000000000000001";
55+
timelockManagerAddress = "0xFaef86994a37F1c8b2A5c73648F07dd4eFF02baA";
56+
api3Pool = await Api3Pool.new(api3TokenAddress, timelockManagerAddress, {
57+
gasPrice: gasPrice,
58+
});
59+
// Pass an API3DAOv1 proposal to call the token contract to authorize the pool contract as a minter
60+
// Pass an API3DAOv1 proposal to call the timelock manager contract to set the pool contract
61+
} else {
62+
api3Token = await Api3Token.new(deployer, deployer, {
63+
gasPrice: gasPrice,
64+
});
65+
api3TokenAddress = api3Token.address;
66+
const timelockManager = await TimelockManager.new(
67+
api3Token.address,
68+
deployer,
69+
{ gasPrice: gasPrice }
70+
);
71+
timelockManagerAddress = timelockManager.address;
72+
api3Pool = await Api3Pool.new(
73+
api3Token.address,
74+
timelockManager.address,
75+
{ gasPrice: gasPrice }
76+
);
77+
await api3Token.updateMinterStatus(api3Pool.address, true, {
78+
gasPrice: gasPrice,
79+
});
80+
await timelockManager.updateApi3Pool(api3Pool.address, {
81+
gasPrice: gasPrice,
82+
});
5083
}
5184

52-
const deployer = await getDeployer();
85+
const convenience = await Convenience.new(api3Pool.address, {
86+
gasPrice: gasPrice,
87+
});
88+
if (network === "mainnet") {
89+
await convenience.setErc20Addresses(
90+
[
91+
api3TokenAddress,
92+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
93+
],
94+
{ gasPrice: gasPrice }
95+
);
96+
} else {
97+
await convenience.setErc20Addresses([api3TokenAddress], {
98+
gasPrice: gasPrice,
99+
});
100+
}
53101

54-
const api3Token = await Api3Token.new(deployer, deployer);
55-
const timelockManager = await TimelockManager.new(
56-
api3Token.address,
57-
deployer
58-
);
59-
const api3Pool = await Api3Pool.new(
60-
api3Token.address,
61-
timelockManager.address
62-
);
63-
await api3Token.updateMinterStatus(api3Pool.address, true);
64-
const convenience = await Convenience.new(api3Pool.address);
65-
await convenience.setErc20Addresses([api3Token.address]);
102+
let templateId;
103+
if (network === "mainnet") {
104+
// TODO: replace below with the final name
105+
templateId = "api3-template-test.open";
106+
} else if (network === "rinkeby" || network === "ropsten") {
107+
templateId = `api3-template-${Math.random()
108+
.toString(36)
109+
.substring(7)}.open`;
110+
} else {
111+
templateId = `api3-template-${Math.random().toString(36).substring(7)}`;
112+
}
66113
const template = await deployTemplate(
67114
web3,
68115
artifacts,
69-
network === "rinkeby" || network === "ropsten" ? daoId + ".open" : daoId,
116+
templateId,
70117
"Api3Template",
71118
[
72119
{ name: "agent", contractName: "Agent" },
@@ -76,19 +123,28 @@ module.exports = async (callback) => {
76123
{ name: "payroll", contractName: "Payroll" },
77124
{ name: "finance", contractName: "Finance" },
78125
{ name: "token-manager", contractName: "TokenManager" },
79-
]
126+
],
127+
{ gasPrice: gasPrice }
80128
);
129+
130+
let daoId;
131+
if (network === "mainnet") {
132+
// TODO: replace below with the final name
133+
daoId = "api3-test";
134+
} else {
135+
daoId = `api3-${Math.random().toString(36).substring(7)}`;
136+
}
81137
const api3VotingAppId =
82-
network === "rinkeby" || network === "mainnet" || network === "ropsten"
138+
network === "mainnet" || network === "ropsten" || network === "rinkeby"
83139
? namehash("api3voting.open.aragonpm.eth")
84140
: namehash("api3voting.aragonpm.eth");
85-
86141
const tx = await template.newInstance(
87142
daoId,
88143
api3Pool.address,
89144
[supportRequiredPct1, minAcceptQuorumPct1],
90145
[supportRequiredPct2, minAcceptQuorumPct2],
91-
api3VotingAppId
146+
api3VotingAppId,
147+
{ gasPrice: gasPrice }
92148
);
93149
const dao = getEventArgument(tx, "Api3DaoDeployed", "dao");
94150
const acl = getEventArgument(tx, "Api3DaoDeployed", "acl");
@@ -120,12 +176,18 @@ module.exports = async (callback) => {
120176
{ from: deployer }
121177
);
122178

123-
await api3Token.transfer(primaryAgent, "100000000000000000000000");
124-
await api3Token.transfer(secondaryAgent, "50000000000000000000000");
179+
if (network !== "mainnet") {
180+
await api3Token.transfer(primaryAgent, "100000000000000000000000", {
181+
gasPrice: gasPrice,
182+
});
183+
await api3Token.transfer(secondaryAgent, "50000000000000000000000", {
184+
gasPrice: gasPrice,
185+
});
186+
}
125187

126188
const deployedAddresses = {
127-
api3Token: api3Token.address,
128-
timelockManager: timelockManager.address,
189+
api3Token: api3TokenAddress,
190+
timelockManager: timelockManagerAddress,
129191
api3Pool: api3Pool.address,
130192
convenience: convenience.address,
131193
dao: dao,
@@ -161,6 +223,5 @@ module.exports = async (callback) => {
161223
} catch (error) {
162224
callback(error);
163225
}
164-
165226
callback();
166227
};

0 commit comments

Comments
 (0)