@@ -86,6 +86,108 @@ async function migrateDAO ({ arcVersion, web3, spinner, confirm, opts, migration
86
86
deploymentState . StandAloneContracts = [ ]
87
87
}
88
88
89
+ let runFunctions = async function ( object , contract ) {
90
+ if ( object . runFunctions !== undefined ) {
91
+ for ( let i in object . runFunctions ) {
92
+ let functionParams = [ ]
93
+ for ( let j in object . runFunctions [ i ] . params ) {
94
+ if ( object . runFunctions [ i ] . params [ j ] . StandAloneContract !== undefined ) {
95
+ functionParams . push ( deploymentState . StandAloneContracts [ object . runFunctions [ i ] . params [ j ] . StandAloneContract ] . address )
96
+ } else {
97
+ functionParams . push ( object . runFunctions [ i ] . params [ j ] )
98
+ }
99
+ }
100
+ const functionCall = contract . methods [ object . runFunctions [ i ] . functionName ] ( ...functionParams )
101
+
102
+ tx = ( await sendTx ( functionCall , `Calling ${ object . name } - ${ object . runFunctions [ i ] . functionName } ...` ) ) . receipt
103
+ await logTx ( tx , `${ object . name } called function ${ object . runFunctions [ i ] . functionName } .` )
104
+ }
105
+ }
106
+ }
107
+
108
+ if ( migrationParams . StandAloneContracts ) {
109
+ let len = migrationParams . StandAloneContracts . length
110
+ if ( deploymentState . standAloneContractsCounter === undefined ) {
111
+ deploymentState . standAloneContractsCounter = 0
112
+ }
113
+ for ( deploymentState . standAloneContractsCounter ;
114
+ deploymentState . standAloneContractsCounter < len ;
115
+ deploymentState . standAloneContractsCounter ++ ) {
116
+ setState ( deploymentState , network )
117
+ let standAlone = migrationParams . StandAloneContracts [ deploymentState . standAloneContractsCounter ]
118
+
119
+ const path = require ( 'path' )
120
+ let contractJson
121
+ if ( standAlone . fromArc ) {
122
+ contractJson = utils . importAbi ( `./${ contractsDir } /${ standAlone . arcVersion ? standAlone . arcVersion : arcVersion } /${ standAlone . name } .json` )
123
+ } else {
124
+ contractJson = require ( path . resolve ( `${ customAbisLocation } /${ standAlone . name } .json` ) )
125
+ }
126
+ let abi = contractJson . abi
127
+ let bytecode = contractJson . bytecode
128
+ let contractParams = [ ]
129
+
130
+ const StandAloneContract = new web3 . eth . Contract ( abi , undefined , opts )
131
+
132
+ if ( standAlone . params !== undefined ) {
133
+ for ( let i in standAlone . params ) {
134
+ if ( standAlone . params [ i ] . StandAloneContract !== undefined ) {
135
+ contractParams . push ( deploymentState . StandAloneContracts [ standAlone . params [ i ] . StandAloneContract ] . address )
136
+ } else if ( standAlone . params [ i ] === 'DefaultAccount' ) {
137
+ contractParams . push ( web3 . eth . defaultAccount )
138
+ } else {
139
+ contractParams . push ( standAlone . params [ i ] )
140
+ }
141
+ }
142
+ }
143
+
144
+ // Allow create as proxy
145
+ let standAloneContract
146
+ if ( standAlone . fromArc && standAlone . noProxy !== true ) {
147
+ const contractInitParams = ( standAlone . params !== undefined && standAlone . params . length > 0 )
148
+ ? StandAloneContract . methods . initialize ( ...contractParams ) . encodeABI ( )
149
+ : '0x'
150
+ let createStandAloneProxyInstance = daoFactory . methods . createInstance (
151
+ [ 0 , 1 , getArcVersionNumber ( standAlone . arcVersion ? standAlone . arcVersion : arcVersion ) ] ,
152
+ standAlone . name ,
153
+ web3 . eth . accounts . wallet [ 0 ] . address ,
154
+ contractInitParams
155
+ )
156
+ tx = ( await sendTx ( createStandAloneProxyInstance , `Creating ${ standAlone . name } Proxy Instance...` ) ) . receipt
157
+ standAloneContract = new web3 . eth . Contract ( abi , tx . events . ProxyCreated . returnValues . _proxy , opts )
158
+ await logTx ( tx , `${ standAloneContract . options . address } => ${ standAlone . name } ` )
159
+ } else {
160
+ const { receipt, result : standAloneContractRes } = await sendTx ( StandAloneContract . deploy ( {
161
+ data : bytecode ,
162
+ arguments : standAlone . constructor ? contractParams : null
163
+ } ) , `Migrating ${ standAlone . name } ...` )
164
+ standAloneContract = standAloneContractRes
165
+ await logTx ( receipt , `${ standAloneContract . options . address } => ${ standAlone . name } ` )
166
+
167
+ if ( standAlone . constructor !== true && standAlone . params !== undefined ) {
168
+ const contractSetParams = standAloneContract . methods . initialize ( ...contractParams )
169
+
170
+ tx = ( await sendTx ( contractSetParams , `Initializing ${ standAlone . name } ...` ) ) . receipt
171
+ await logTx ( tx , `${ standAlone . name } initialized.` )
172
+ }
173
+ }
174
+
175
+ await runFunctions ( standAlone , standAloneContract )
176
+
177
+ deploymentState . StandAloneContracts . push (
178
+ {
179
+ name : standAlone . name ,
180
+ alias : standAlone . alias ,
181
+ address : standAloneContract . options . address ,
182
+ arcVersion : ( standAlone . arcVersion ? standAlone . arcVersion : arcVersion )
183
+ }
184
+ )
185
+ setState ( deploymentState , network )
186
+ }
187
+ deploymentState . standAloneContractsCounter ++
188
+ setState ( deploymentState , network )
189
+ }
190
+
89
191
const [ founderAddresses , tokenDist , repDist ] = [
90
192
founders . map ( ( { address } ) => address ) ,
91
193
founders . map ( ( { tokens } ) => web3 . utils . toWei ( tokens !== undefined ? tokens . toString ( ) : '0' ) ) ,
@@ -253,140 +355,16 @@ async function migrateDAO ({ arcVersion, web3, spinner, confirm, opts, migration
253
355
)
254
356
deploymentState . Controller = controller . options . address
255
357
256
- // if (deploymentState.schemesSet !== true) {
257
- // var encodedSetSchemesParams = web3.eth.abi.encodeParameters(
258
- // ['bytes32[]', 'bytes', 'uint256[]', 'bytes4[]', 'string'],
259
- // [
260
- // deploymentState.schemeNames,
261
- // deploymentState.schemesData,
262
- // deploymentState.schemesInitializeDataLens,
263
- // deploymentState.permissions,
264
- // migrationParams.metaData !== undefined ? migrationParams.metaData : 'metaData'
265
- // ]
266
- // )
267
- // tx = (await sendTx(
268
- // daoFactory.methods.setSchemes(
269
- // avatar.options.address,
270
- // encodedSetSchemesParams
271
- // ), 'Setting DAO schemes...')).receipt
272
- // await logTx(tx, 'DAO schemes set.')
273
-
274
- // let schemesEvents = tx.events.SchemeInstance
275
- // for (let i in schemesEvents) {
276
- // deploymentState.Schemes.push(
277
- // {
278
- // name: web3.utils.toAscii(deploymentState.schemeNames[i]),
279
- // alias: migrationParams.Schemes[i].alias,
280
- // address: schemesEvents[i].returnValues._scheme
281
- // })
282
- // }
283
-
284
- // deploymentState.schemesSet = true
285
- // setState(deploymentState, network)
286
- // }
287
-
288
- let runFunctions = async function ( object , contract ) {
289
- if ( object . runFunctions !== undefined ) {
290
- for ( let i in object . runFunctions ) {
291
- let functionParams = [ ]
292
- for ( let j in object . runFunctions [ i ] . params ) {
293
- if ( object . runFunctions [ i ] . params [ j ] . StandAloneContract !== undefined ) {
294
- functionParams . push ( deploymentState . StandAloneContracts [ object . runFunctions [ i ] . params [ j ] . StandAloneContract ] . address )
295
- } else if ( object . runFunctions [ i ] . params [ j ] === 'AvatarAddress' ) {
296
- functionParams . push ( avatar . options . address )
297
- } else {
298
- functionParams . push ( object . runFunctions [ i ] . params [ j ] )
299
- }
300
- }
301
- const functionCall = contract . methods [ object . runFunctions [ i ] . functionName ] ( ...functionParams )
302
-
303
- tx = ( await sendTx ( functionCall , `Calling ${ object . name } - ${ object . runFunctions [ i ] . functionName } ...` ) ) . receipt
304
- await logTx ( tx , `${ object . name } called function ${ object . runFunctions [ i ] . functionName } .` )
305
- }
306
- }
307
- }
308
-
309
- if ( migrationParams . StandAloneContracts ) {
310
- let len = migrationParams . StandAloneContracts . length
311
- if ( deploymentState . standAloneContractsCounter === undefined ) {
312
- deploymentState . standAloneContractsCounter = 0
313
- }
314
- for ( deploymentState . standAloneContractsCounter ;
315
- deploymentState . standAloneContractsCounter < len ;
316
- deploymentState . standAloneContractsCounter ++ ) {
317
- setState ( deploymentState , network )
318
- let standAlone = migrationParams . StandAloneContracts [ deploymentState . standAloneContractsCounter ]
319
-
320
- const path = require ( 'path' )
321
- let contractJson
322
- if ( standAlone . fromArc ) {
323
- contractJson = utils . importAbi ( `./${ contractsDir } /${ standAlone . arcVersion ? standAlone . arcVersion : arcVersion } /${ standAlone . name } .json` )
324
- } else {
325
- contractJson = require ( path . resolve ( `${ customAbisLocation } /${ standAlone . name } .json` ) )
326
- }
327
- let abi = contractJson . abi
328
- let bytecode = contractJson . bytecode
329
- let contractParams = [ ]
330
-
331
- const StandAloneContract = new web3 . eth . Contract ( abi , undefined , opts )
332
-
333
- if ( standAlone . params !== undefined ) {
334
- for ( let i in standAlone . params ) {
335
- if ( standAlone . params [ i ] . StandAloneContract !== undefined ) {
336
- contractParams . push ( deploymentState . StandAloneContracts [ standAlone . params [ i ] . StandAloneContract ] . address )
337
- } else if ( standAlone . params [ i ] === 'DefaultAccount' ) {
338
- contractParams . push ( web3 . eth . defaultAccount )
339
- } else {
340
- contractParams . push ( standAlone . params [ i ] )
341
- }
342
- }
343
- }
344
-
345
- // Allow create as proxy
346
- let standAloneContract
347
- if ( standAlone . fromArc && standAlone . noProxy !== true ) {
348
- const contractInitParams = ( standAlone . params !== undefined && standAlone . params . length > 0 )
349
- ? StandAloneContract . methods . initialize ( ...contractParams ) . encodeABI ( )
350
- : '0x'
351
- let createStandAloneProxyInstance = daoFactory . methods . createInstance (
352
- [ 0 , 1 , getArcVersionNumber ( standAlone . arcVersion ? standAlone . arcVersion : arcVersion ) ] ,
353
- standAlone . name ,
354
- avatar . options . address ,
355
- contractInitParams
356
- )
357
- tx = ( await sendTx ( createStandAloneProxyInstance , `Creating ${ standAlone . name } Proxy Instance...` ) ) . receipt
358
- standAloneContract = new web3 . eth . Contract ( abi , tx . events . ProxyCreated . returnValues . _proxy , opts )
359
- await logTx ( tx , `${ standAloneContract . options . address } => ${ standAlone . name } ` )
360
- } else {
361
- const { receipt, result : standAloneContractRes } = await sendTx ( StandAloneContract . deploy ( {
362
- data : bytecode ,
363
- arguments : standAlone . constructor ? contractParams : null
364
- } ) , `Migrating ${ standAlone . name } ...` )
365
- standAloneContract = standAloneContractRes
366
- await logTx ( receipt , `${ standAloneContract . options . address } => ${ standAlone . name } ` )
367
-
368
- if ( standAlone . constructor !== true && standAlone . params !== undefined ) {
369
- const contractSetParams = standAloneContract . methods . initialize ( ...contractParams )
370
-
371
- tx = ( await sendTx ( contractSetParams , `Initializing ${ standAlone . name } ...` ) ) . receipt
372
- await logTx ( tx , `${ standAlone . name } initialized.` )
373
- }
374
- }
375
-
376
- await runFunctions ( standAlone , standAloneContract )
377
-
378
- deploymentState . StandAloneContracts . push (
379
- {
380
- name : standAlone . name ,
381
- alias : standAlone . alias ,
382
- address : standAloneContract . options . address ,
383
- arcVersion : ( standAlone . arcVersion ? standAlone . arcVersion : arcVersion )
384
- }
358
+ for ( let standaloneContract in deploymentState . StandAloneContracts ) {
359
+ if ( standaloneContract . fromArc && standaloneContract . noProxy !== true ) {
360
+ let standaloneContractProxy = new web3 . eth . Contract (
361
+ utils . importAbi ( `./${ contractsDir } /${ arcVersion } /AdminUpgradeabilityProxy.json` ) . abi ,
362
+ standaloneContract . address ,
363
+ opts
385
364
)
386
- setState ( deploymentState , network )
365
+ tx = ( await sendTx ( standaloneContractProxy . methods . changeAdmin ( deploymentState . Avatar ) , 'Transferring Standalone Proxy Ownership...' ) ) . receipt
366
+ await logTx ( tx , 'Transferred Standalone Proxy Ownership.' )
387
367
}
388
- deploymentState . standAloneContractsCounter ++
389
- setState ( deploymentState , network )
390
368
}
391
369
392
370
let dao = {
0 commit comments