From 7c228c750cf58dedbc743b0e9546ae4810b92c60 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 19 Aug 2019 17:35:50 -0400 Subject: [PATCH 1/3] add TODO --- packages/embark-deployment/src/contract_deployer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/embark-deployment/src/contract_deployer.js b/packages/embark-deployment/src/contract_deployer.js index f9c9d9d6a..aff60dfe7 100644 --- a/packages/embark-deployment/src/contract_deployer.js +++ b/packages/embark-deployment/src/contract_deployer.js @@ -23,6 +23,7 @@ class ContractDeployer { async.waterfall([ (next) => { this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (err, _params) => { + // TODO: confirm this really works and shouldn't be next(err, params) next(err); }); }, From 10a7833838660b19aae90c082fd3eea7282f10de Mon Sep 17 00:00:00 2001 From: emizzle Date: Fri, 2 Aug 2019 15:00:15 +1000 Subject: [PATCH 2/3] refactor(@embark/embark-deploy-tracker): Add back contract tracking Add back contract tracking to the refactored code. Deployment checks are added as plugins to the `embark-deployment` module. Adds ability to track if a contract has already been deployed, and skips deployment if so. Updates error handling flow for deployment process. Adds a contract class to the `embark-contracts-manager`, to add a `log` function for the contract. This `log` function can be called from any module that has the contract instance. Adds TS interfaces for contracts configuration. Handles the following cases: 1. Contract already deployed 2. Contract not deployed 3. Contract is configured with `{track: false}` (deploy if not deployed, and don't track) 5. Contract is configured with an `address` in the config 6. `trackContracts` set to `false` from `engine` (always deploy but don't track contracts). Currently used for the tests. 7. Contract deployment produces an error 8. Interface deployment shows warning. PR with unit tests and documenation to follow. # Conflicts: # packages/embark/src/lib/modules/ethereum-blockchain-client/index.js --- packages/embark-deploy-tracker/src/trackingFunctions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/embark-deploy-tracker/src/trackingFunctions.js b/packages/embark-deploy-tracker/src/trackingFunctions.js index 3c81a65bb..f4fc45b32 100644 --- a/packages/embark-deploy-tracker/src/trackingFunctions.js +++ b/packages/embark-deploy-tracker/src/trackingFunctions.js @@ -58,6 +58,7 @@ export default class TrackingFunctions { } setCurrentChain(_params, callback) { + if (!this.chainFile) return callback(); if (this.chainFile === false) return callback(); if (this.chainConfig === false) { this.currentChain = {contracts: []}; From 29ee9edf83264f12f69ab3ec571e1d634179147a Mon Sep 17 00:00:00 2001 From: emizzle Date: Wed, 7 Aug 2019 16:17:48 +1000 Subject: [PATCH 3/3] =?UTF-8?q?feat(@embark/embark-deployment):=20Don?= =?UTF-8?q?=E2=80=99t=20hang=20on=20contract=20deploy=20fail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this PR (including with v4), Embark would hang on a deployment error. After this PR, Embark continues it’s run routine despite a contract deployment error, and reports the error to the user in the console appropriately. NOTE: this branch is based on `refactor/add-contract-tracking` (which would land in https://github.com/embark-framework/embark/pull/1743). If #1743 lands (will be merged in to `refactor_5_0_0`), I will rebase this branch on top of `refactor_5_0_0`. --- packages/embark-deployment/src/index.js | 37 ++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/embark-deployment/src/index.js b/packages/embark-deployment/src/index.js index 7b059c222..033307689 100644 --- a/packages/embark-deployment/src/index.js +++ b/packages/embark-deployment/src/index.js @@ -15,8 +15,7 @@ class Deployment { this.contractDeployer = new ContractDeployer({ events: this.events, - plugins: this.plugins, - logger: this.logger + plugins: this.plugins }); this.events.setCommandHandler('deployment:contracts:deploy', (contractsList, contractDependencies, cb) => { @@ -28,17 +27,23 @@ class Deployment { this.logger.info(__("deploying contracts")); async.waterfall([ // TODO used to be called this.plugins.emitAndRunActionsForEvent("deploy:beforeAll", (err) => { - (next) => {this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:beforeAll', {}, () => {next()});}, - (next) => {this.deployAll(contracts, contractDependencies, next);}, (next) => { - this.events.emit('contractsDeployed'); - this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:afterAll', {}, () => {next()}); - console.dir("==== finished deploying"); + this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:beforeAll', {}, (err) => { + next(err); + }); + }, + (next) => {this.deployAll(contracts, contractDependencies, next);}, + ], (err) => { + if (err) { + this.events.emit("outputError", err.message || err); + this.logger.error(err.message || err); } - ], done); + this.events.emit('contractsDeployed'); + this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:afterAll', {}, done); + }); } - deployContract(contract, errors, callback) { + deployContract(contract, callback) { console.dir("requesting to deploy contract") this.events.request('deployment:contract:deploy', contract, (err) => { if (err) { @@ -48,7 +53,7 @@ class Deployment { } else { this.logger.error(`[${contract.className}]: ${err.message || err}`); } - errors.push(err); + return callback(err); } callback(); }); @@ -64,7 +69,12 @@ class Deployment { function deploy(result, callback) { console.dir("== deploy") if (typeof result === 'function') callback = result; - self.deployContract(contract, errors, callback); + self.deployContract(contract, (err) => { + if (err) { + errors.push(err); + } + callback(); + }); } const className = contract.className; @@ -77,13 +87,8 @@ class Deployment { }) async.auto(contractDeploys, (err, _results) => { - if (err) { - console.dir("error deploying contracts") - console.dir(err) - } if (errors.length) { err = __("Error deploying contracts. Please fix errors to continue."); - this.events.emit("outputError", __("Error deploying contracts, please check console")); return done(err); } if (contracts.length === 0) {