-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix truffle migration async scripts (#366)
- Loading branch information
Showing
3 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
const namehash = require('eth-ens-namehash').hash | ||
const keccak256 = require('js-sha3').keccak_256 | ||
|
||
module.exports = async (deployer, network, accounts, arts = null) => { | ||
if (arts != null) artifacts = arts // allow running outside | ||
module.exports = function (deployer, network, accounts, arts = null) { | ||
return deployer.then(async () => { | ||
if (arts != null) artifacts = arts // allow running outside | ||
|
||
const getContract = name => artifacts.require(name) | ||
const getContract = name => artifacts.require(name) | ||
|
||
const bases = ['APMRegistry', 'Repo', 'ENSSubdomainRegistrar'] | ||
const baseContracts = bases.map(getContract) | ||
const bases = ['APMRegistry', 'Repo', 'ENSSubdomainRegistrar'] | ||
const baseContracts = bases.map(getContract) | ||
|
||
await deployer.deploy(baseContracts) | ||
await deployer.deploy(baseContracts) | ||
|
||
const baseDeployed = baseContracts.map(c => c.address) | ||
const baseDeployed = baseContracts.map(c => c.address) | ||
|
||
// TODO: Take into account networks with ENS deployed | ||
const ENSFactory = getContract('ENSFactory') | ||
await deployer.deploy(ENSFactory) | ||
// TODO: Take into account networks with ENS deployed | ||
const ENSFactory = getContract('ENSFactory') | ||
await deployer.deploy(ENSFactory) | ||
|
||
const APMRegistryFactory = getContract('APMRegistryFactory') | ||
const ensAddr = '0x0' // so ensfactory creates one | ||
const APMRegistryFactory = getContract('APMRegistryFactory') | ||
const ensAddr = '0x0' // so ensfactory creates one | ||
|
||
const kernelBase = await getContract('Kernel').new() | ||
const aclBase = await getContract('ACL').new() | ||
const daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, '0x00') | ||
const kernelBase = await getContract('Kernel').new() | ||
const aclBase = await getContract('ACL').new() | ||
const daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, '0x00') | ||
|
||
await deployer.deploy(APMRegistryFactory, daoFactory.address, ...baseDeployed, ensAddr, ENSFactory.address) | ||
const factory = await APMRegistryFactory.deployed() | ||
await deployer.deploy(APMRegistryFactory, daoFactory.address, ...baseDeployed, ensAddr, ENSFactory.address) | ||
const factory = await APMRegistryFactory.deployed() | ||
|
||
|
||
console.log('Deploying APM...') | ||
const root = '0xffffffffffffffffffffffffffffffffffffffff' // public | ||
const receipt = await factory.newAPM(namehash('eth'), '0x'+keccak256('aragonpm'), root) | ||
const apmAddr = receipt.logs.filter(l => l.event == 'DeployAPM')[0].args.apm | ||
console.log('Deployed APM at:', apmAddr) | ||
console.log('Deploying APM...') | ||
const root = '0xffffffffffffffffffffffffffffffffffffffff' // public | ||
const receipt = await factory.newAPM(namehash('eth'), '0x'+keccak256('aragonpm'), root) | ||
const apmAddr = receipt.logs.filter(l => l.event == 'DeployAPM')[0].args.apm | ||
console.log('Deployed APM at:', apmAddr) | ||
|
||
const apm = getContract('APMRegistry').at(apmAddr) | ||
console.log('Kernel:', await apm.kernel()) | ||
const apm = getContract('APMRegistry').at(apmAddr) | ||
console.log('Kernel:', await apm.kernel()) | ||
|
||
const ensSub = getContract('ENSSubdomainRegistrar').at(await apm.registrar()) | ||
console.log('ENS:', await ensSub.ens()) | ||
const ensSub = getContract('ENSSubdomainRegistrar').at(await apm.registrar()) | ||
console.log('ENS:', await ensSub.ens()) | ||
|
||
return { apm, ensAddr: await ensSub.ens() } | ||
return { apm, ensAddr: await ensSub.ens() } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
const getContract = name => artifacts.require(name) | ||
|
||
module.exports = async (deployer, network, accounts, arts = null) => { | ||
if (arts != null) artifacts = arts // allow running outside | ||
module.exports = function (deployer, network, accounts, arts = null) { | ||
return deployer.then(async () => { | ||
if (arts != null) artifacts = arts // allow running outside | ||
|
||
const DAOFactory = artifacts.require('DAOFactory') | ||
const EVMScriptRegistryFactory = artifacts.require('EVMScriptRegistryFactory') | ||
const DAOFactory = artifacts.require('DAOFactory') | ||
const EVMScriptRegistryFactory = artifacts.require('EVMScriptRegistryFactory') | ||
|
||
const kernelBase = await getContract('Kernel').new() | ||
const aclBase = await getContract('ACL').new() | ||
const kernelBase = await getContract('Kernel').new() | ||
const aclBase = await getContract('ACL').new() | ||
|
||
const regFact = await EVMScriptRegistryFactory.new() | ||
const daoFact = await DAOFactory.new(kernelBase.address, aclBase.address, regFact.address) | ||
const regFact = await EVMScriptRegistryFactory.new() | ||
const daoFact = await DAOFactory.new(kernelBase.address, aclBase.address, regFact.address) | ||
|
||
if (!arts) { // Running standalone in aOS repo | ||
const receipt = await daoFact.newDAO(accounts[0]) | ||
daoAddr = receipt.logs.filter(l => l.event == 'DeployDAO')[0].args.dao | ||
console.log('deployed DAO at', daoAddr) | ||
} | ||
if (!arts) { // Running standalone in aOS repo | ||
const receipt = await daoFact.newDAO(accounts[0]) | ||
daoAddr = receipt.logs.filter(l => l.event == 'DeployDAO')[0].args.dao | ||
console.log('deployed DAO at', daoAddr) | ||
} | ||
|
||
return { daoFact } | ||
return { daoFact } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
const ScriptHelpers = artifacts.require('ScriptHelpers') | ||
const EVMScriptRegistryFactory = artifacts.require('EVMScriptRegistryFactory') | ||
|
||
module.exports = async (deployer, network) => { | ||
deployer.deploy(ScriptHelpers) | ||
deployer.link(ScriptHelpers, EVMScriptRegistryFactory) | ||
module.exports = function (deployer, network) { | ||
return deployer.then(async () => { | ||
await deployer.deploy(ScriptHelpers) | ||
await deployer.link(ScriptHelpers, EVMScriptRegistryFactory) | ||
}) | ||
} |