fix(@embark/embark-deployment): Undeployed contract artifacts (#1815)

Contract artifacts were not being generated nor run through the VM if the contracts/interfaces were not deployed. These features were executed as actions on the `deployment:contract:deployed` event.

This PR runs executes the same actions for `deployment:contract:undeployed` event as the `deployment:contract:deployed` event, which occurs when a contract is not deployed.
This commit is contained in:
Eric Mastro 2019-08-30 05:27:01 +10:00 committed by Iuri Matias
parent 0455c550ce
commit 0c7c3e83fe
5 changed files with 16 additions and 5 deletions

View File

@ -32,8 +32,9 @@ class ContractDeployer {
(params, next) => {
if (!params.shouldDeploy) {
this.events.emit("deployment:contract:undeployed", contract);
return next(null, null);
return this.plugins.emitAndRunActionsForEvent('deployment:contract:undeployed', {contract}, (err, _params) => {
next(err, null);
});
}
// TODO: implement `blockchainType` a la `this.deployer[contract.blockchainType].apply(this.deployer, [contract, next])`

View File

@ -25,9 +25,11 @@ class EmbarkWeb3 {
this.events.on("blockchain:started", this.registerWeb3Object.bind(this));
embark.registerActionForEvent("pipeline:generateAll:before", this.addWeb3Artifact.bind(this));
embark.registerActionForEvent("deployment:contract:deployed", this.registerInVm.bind(this));
embark.registerActionForEvent("deployment:contract:undeployed", this.registerInVm.bind(this));
embark.registerActionForEvent("deployment:contract:deployed", this.registerArtifact.bind(this));
embark.registerActionForEvent("deployment:contract:undeployed", this.registerArtifact.bind(this));
this.registerWeb3Help()
this.registerWeb3Help();
}
async registerWeb3Object() {

View File

@ -69,7 +69,14 @@ class Dashboard {
this.events.on("deployment:contract:deployed", (_contract) => {
// self.events.emit('contractsState', self.contractsState());
this.events.request("contracts:state", (err, contracts) => {
monitor.setContracts(contracts)
monitor.setContracts(contracts);
});
});
this.events.on("deployment:contract:undeployed", (_contract) => {
// self.events.emit('contractsState', self.contractsState());
this.events.request("contracts:state", (err, contracts) => {
monitor.setContracts(contracts);
});
});

View File

@ -13,6 +13,7 @@ class EthereumBlockchainClient {
this.events = embark.events;
this.logger = embark.logger;
this.embark.registerActionForEvent("deployment:contract:undeployed", this.addContractJSONToPipeline.bind(this));
this.embark.registerActionForEvent("deployment:contract:deployed", this.addContractJSONToPipeline.bind(this));
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', this.determineArguments.bind(this));
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', this.doLinking.bind(this));