@@ -12,12 +12,13 @@ const Api3Token = artifacts.require("Api3Token");
1212const Convenience = artifacts . require ( "Convenience" ) ;
1313const TimelockManager = artifacts . require ( "TimelockManager" ) ;
1414
15- const daoId = `api3-template-${ Math . random ( ) . toString ( 36 ) . substring ( 7 ) } ` ;
1615const supportRequiredPct1 = 50e16 ;
1716const minAcceptQuorumPct1 = 50e16 ;
1817const supportRequiredPct2 = 50e16 ;
1918const 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 () => {
4445module . 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