remove direct reference to contracts manager, use a request instead
This commit is contained in:
parent
98c5b2dd06
commit
3fb2b6fa60
|
@ -8,6 +8,7 @@ const constants = require('../constants');
|
|||
|
||||
class ContractsManager {
|
||||
constructor(options) {
|
||||
const self = this;
|
||||
this.contractFiles = options.contractFiles;
|
||||
this.contractsConfig = options.contractsConfig;
|
||||
this.contracts = {};
|
||||
|
@ -18,14 +19,13 @@ class ContractsManager {
|
|||
this.deployOnlyOnConfig = false;
|
||||
this.events = options.events;
|
||||
|
||||
this.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
||||
this.contractFiles = newContractFiles;
|
||||
self.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
||||
self.contractFiles = newContractFiles;
|
||||
});
|
||||
this.events.on(constants.events.contractConfigChanged, (newContracts) => {
|
||||
this.contractsConfig = newContracts;
|
||||
self.events.on(constants.events.contractConfigChanged, (newContracts) => {
|
||||
self.contractsConfig = newContracts;
|
||||
});
|
||||
|
||||
const self = this;
|
||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||
cb(self.listContracts());
|
||||
});
|
||||
|
|
|
@ -181,9 +181,8 @@ class Deploy {
|
|||
});
|
||||
},
|
||||
function doLinking(next) {
|
||||
// Applying linked contracts
|
||||
let contractsList = self.contractsManager.listContracts();
|
||||
for (let contractObj of contractsList) {
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
for (let contractObj of contracts) {
|
||||
let filename = contractObj.filename;
|
||||
let deployedAddress = contractObj.deployedAddress;
|
||||
if (deployedAddress) {
|
||||
|
@ -206,6 +205,7 @@ class Deploy {
|
|||
// saving code changes back to contract object
|
||||
contract.code = contractCode;
|
||||
next();
|
||||
});
|
||||
},
|
||||
function applyBeforeDeploy(next) {
|
||||
let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy');
|
||||
|
@ -284,9 +284,9 @@ class Deploy {
|
|||
deployAll(done) {
|
||||
let self = this;
|
||||
this.logger.info(__("deploying contracts"));
|
||||
let contracts = this.contractsManager.listContracts();
|
||||
this.events.emit("deploy:beforeAll");
|
||||
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
async.eachOfSeries(contracts,
|
||||
function (contract, key, callback) {
|
||||
self.logger.trace(arguments);
|
||||
|
@ -307,6 +307,7 @@ class Deploy {
|
|||
done(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue