From 58ad62f32bb98829f191e9b14d6d9ced406d3ba3 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 3 Sep 2019 14:03:29 -0400 Subject: [PATCH] refactor(@embark/cmd-controller): re add cargo for file watcher (#1857) --- packages/embark-deploy-tracker/src/deploymentChecks.js | 2 +- .../embark-deploy-tracker/src/test/deploymentChecksSpec.js | 4 ++++ packages/embark-solidity/src/index.js | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/embark-deploy-tracker/src/deploymentChecks.js b/packages/embark-deploy-tracker/src/deploymentChecks.js index 07b76dec2..8eec52718 100644 --- a/packages/embark-deploy-tracker/src/deploymentChecks.js +++ b/packages/embark-deploy-tracker/src/deploymentChecks.js @@ -80,7 +80,7 @@ export default class DeploymentChecks { catch (err) { return cb(err); } - if (codeInChain.length > 3) { // it is "0x" or "0x0" for empty code, depending on web3 version + if (codeInChain.length > 3 && codeInChain.substring(2) === contract.runtimeBytecode) { // it is "0x" or "0x0" for empty code, depending on web3 version contract.deployedAddress = trackedContract.address; contract.log(contract.className.bold.cyan + __(" already deployed at ").green + contract.deployedAddress.bold.cyan); params.shouldDeploy = false; diff --git a/packages/embark-deploy-tracker/src/test/deploymentChecksSpec.js b/packages/embark-deploy-tracker/src/test/deploymentChecksSpec.js index 57fb9e6e0..b50286251 100644 --- a/packages/embark-deploy-tracker/src/test/deploymentChecksSpec.js +++ b/packages/embark-deploy-tracker/src/test/deploymentChecksSpec.js @@ -164,6 +164,8 @@ describe('embark.deploymentChecks', function () { }); }); it("should not deploy if contract is tracked, but bytecode exists on chain", async function () { + trackingFunctions._web3.eth.getCode = () => "0x0123"; + params.contract.runtimeBytecode = '0123'; return deploymentChecks.checkIfAlreadyDeployed(params, (err, params) => { expect(err).to.be(null); expect(params.shouldDeploy).to.be(false); @@ -180,6 +182,8 @@ describe('embark.deploymentChecks', function () { it("should update tracked contract in chains.json when contract.track !== false", async function () { const trackAndSaveContract = sinon.stub(trackingFunctions, "trackAndSaveContract"); const {contract} = params; + trackingFunctions._web3.eth.getCode = () => "0x0123"; + params.contract.runtimeBytecode = '0123'; return deploymentChecks.checkIfAlreadyDeployed(params, (err, params) => { expect(err).to.be(null); expect(params.shouldDeploy).to.be(false); diff --git a/packages/embark-solidity/src/index.js b/packages/embark-solidity/src/index.js index 65521c5df..ed7e019d7 100644 --- a/packages/embark-solidity/src/index.js +++ b/packages/embark-solidity/src/index.js @@ -3,6 +3,7 @@ let SolcW = require('./solcW.js'); const path = require('path'); import { __ } from 'embark-i18n'; import {normalizePath} from 'embark-utils'; +const cloneDeep = require('lodash.clonedeep'); class Solidity { @@ -197,6 +198,8 @@ class Solidity { let input = {}; let originalFilepath = {}; + contractFiles = cloneDeep(contractFiles); + async.waterfall([ function prepareInput(callback) { async.each(contractFiles,