Skip to content

Commit

Permalink
Fix bug where crowdsale is not being deployed to the blockchain durin…
Browse files Browse the repository at this point in the history
…g migrations.

This resolves: dappuniversity#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: trufflesuite/truffle#501
  • Loading branch information
dbrowne24 committed Oct 11, 2018
1 parent e211bea commit ca1e9e6
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions migrations/2_deploy_crowdsale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
};

0 comments on commit ca1e9e6

Please sign in to comment.