From ca1e9e6dd81cf8a40671498fee5e8afca5318d5f Mon Sep 17 00:00:00 2001 From: Dean Brown Date: Thu, 11 Oct 2018 13:19:38 +0100 Subject: [PATCH] Fix bug where crowdsale is not being deployed to the blockchain during migrations. This resolves: https://github.com/dappuniversity/ico_irl/issues/3 This bug was caused by the way in which the migrations steps are added to the promise chain. More can be read about this issue here: https://github.com/trufflesuite/truffle/issues/501 --- migrations/2_deploy_crowdsale.js | 40 +++++++++++++++++--------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/migrations/2_deploy_crowdsale.js b/migrations/2_deploy_crowdsale.js index ee91fb1..253f162 100644 --- a/migrations/2_deploy_crowdsale.js +++ b/migrations/2_deploy_crowdsale.js @@ -12,19 +12,15 @@ const duration = { years: function (val) { return val * this.days(365); }, }; -module.exports = async function(deployer, network, accounts) { +module.exports = function(deployer, network, accounts) { const _name = "Dapp Token"; const _symbol = "DAPP"; const _decimals = 18; - await deployer.deploy(DappToken, _name, _symbol, _decimals); - const deployedToken = await DappToken.deployed(); - const latestTime = (new Date).getTime(); const _rate = 500; const _wallet = accounts[0]; // TODO: Replace me - const _token = deployedToken.address; const _openingTime = latestTime + duration.minutes(1); const _closingTime = _openingTime + duration.weeks(1); const _cap = ether(100); @@ -34,20 +30,26 @@ module.exports = async function(deployer, network, accounts) { const _partnersFund = accounts[0]; // TODO: Replace me const _releaseTime = _closingTime + duration.days(1); - await deployer.deploy( - DappTokenCrowdsale, - _rate, - _wallet, - _token, - _cap, - _openingTime, - _closingTime, - _goal, - _foundersFund, - _foundationFund, - _partnersFund, - _releaseTime - ); + deployer.then(async() => { + await deployer.deploy(DappToken, _name, _symbol, _decimals); + + const _deployedToken = await DappToken.deployed(); + + await deployer.deploy( + DappTokenCrowdsale, + _rate, + _wallet, + _deployedToken.address, + _cap, + _openingTime, + _closingTime, + _goal, + _foundersFund, + _foundationFund, + _partnersFund, + _releaseTime + ); + }); return true; };