mirror of https://github.com/embarklabs/embark.git
move contractsState emit to contracts
This commit is contained in:
parent
250e0b8798
commit
98c5b2dd06
|
@ -33,6 +33,18 @@ class ContractsManager {
|
|||
self.events.setCommandHandler("contracts:contract", (contractName, cb) => {
|
||||
cb(self.getContract(contractName));
|
||||
});
|
||||
|
||||
self.events.on("deploy:contract:error", (_contract) => {
|
||||
self.events.emit('contractsState', self.contractsState());
|
||||
});
|
||||
|
||||
self.events.on("deploy:contract:deployed", (_contract) => {
|
||||
self.events.emit('contractsState', self.contractsState());
|
||||
});
|
||||
|
||||
self.events.on("deploy:contract:undeployed", (_contract) => {
|
||||
self.events.emit('contractsState', self.contractsState());
|
||||
});
|
||||
}
|
||||
|
||||
build(done) {
|
||||
|
|
|
@ -13,8 +13,6 @@ class Deploy {
|
|||
this.contractsManager = options.contractsManager;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.env = options.env;
|
||||
this.chainConfig = options.chainConfig;
|
||||
this.plugins = options.plugins;
|
||||
this.gasLimit = options.gasLimit;
|
||||
}
|
||||
|
@ -68,7 +66,7 @@ class Deploy {
|
|||
contract.error = false;
|
||||
|
||||
if (contract.deploy === false) {
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
self.events.emit("deploy:contract:undeployed", contract);
|
||||
return callback();
|
||||
}
|
||||
|
||||
|
@ -82,13 +80,11 @@ class Deploy {
|
|||
self.logger.error(e.message);
|
||||
contract.error = e.message;
|
||||
self.events.emit("deploy:contract:error", contract);
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
return callback(e.message);
|
||||
}
|
||||
contract.deployedAddress = contract.address;
|
||||
self.logger.info(contract.className.bold.cyan + __(" already deployed at ").green + contract.address.bold.cyan);
|
||||
self.events.emit("deploy:contract:deployed", contract);
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
return callback();
|
||||
}
|
||||
|
||||
|
@ -113,7 +109,6 @@ class Deploy {
|
|||
self.logger.info(contract.className.bold.cyan + __(" already deployed at ").green + trackedContract.address.bold.cyan);
|
||||
contract.deployedAddress = trackedContract.address;
|
||||
self.events.emit("deploy:contract:deployed", contract);
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
|
||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
|
@ -130,12 +125,10 @@ class Deploy {
|
|||
this.deployContract(contract, contract.realArgs, function (err, address) {
|
||||
if (err) {
|
||||
self.events.emit("deploy:contract:error", contract);
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
return callback(new Error(err));
|
||||
}
|
||||
contract.address = address;
|
||||
self.events.emit("deploy:contract:deployed", contract);
|
||||
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||
|
||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
|
|
Loading…
Reference in New Issue