diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 14fc8f35..ae291124 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -15,6 +15,7 @@ class ContractsManager { this.plugins = options.plugins; this.contractDependencies = {}; this.gasLimit = options.gasLimit; + this.deployOnlyOnConfig = false; } build(done) { @@ -71,6 +72,10 @@ class ContractsManager { for (className in self.contracts) { contract = self.contracts[className]; contract.deploy = (contract.deploy === undefined) || contract.deploy; + if (self.deployOnlyOnConfig && !self.contractsConfig.contracts[className]) { + contract.deploy = false; + } + if (contract.code === "") { self.logger.info("assuming " + className + " to be an interface"); contract.deploy = false; diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 72502bbc..0562574e 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -16,6 +16,7 @@ class DeployManager { this.contractsManager = options.contractsManager; this.gasLimit = false; this.fatalErrors = false; + this.deployOnlyOnConfig = false; } deployContracts(done) { @@ -29,6 +30,7 @@ class DeployManager { async.waterfall([ function buildContracts(callback) { + self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor self.contractsManager.build(callback); }, function checkWeb3IsConnected(contractsManager, callback) { diff --git a/lib/tests/test.js b/lib/tests/test.js index 9831900c..0534bd28 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -79,6 +79,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) { self.engine.deployManager.gasLimit = 6000000; self.engine.contractsManager.gasLimit = 6000000; self.engine.deployManager.fatalErrors = true; + self.engine.deployManager.deployOnlyOnConfig = true; self.engine.deployManager.deployContracts(function(err, _result) { if (err) { callback(err); diff --git a/test_app/test/another_storage_spec.js b/test_app/test/another_storage_spec.js index ec19e7c3..d34c3e72 100644 --- a/test_app/test/another_storage_spec.js +++ b/test_app/test/another_storage_spec.js @@ -8,29 +8,6 @@ contract("AnotherStorage", function() { }, "AnotherStorage": { args: ["$SimpleStorage"] - }, - "Token": { - deploy: false, - args: [1000] - }, - "MyToken": { - instanceOf: "Token" - }, - "MyToken2": { - instanceOf: "Token", - args: [2000] - }, - "ContractArgs": { - "args": { - "initialValue": 123, - "_addresses": ["$MyToken2", "$SimpleStorage"] - } - }, - "SomeContract": { - "args": [ - ["$MyToken2", "$SimpleStorage"], - 100 - ] } }; EmbarkSpec.deployAll(contractsConfig, () => { done() }); diff --git a/test_app/test/lib_test_spec.js b/test_app/test/lib_test_spec.js index cac9c61c..ceab0cfc 100644 --- a/test_app/test/lib_test_spec.js +++ b/test_app/test/lib_test_spec.js @@ -2,9 +2,13 @@ contract("Test", function() { before(function(done) { this.timeout(0); var contractsConfig = { + "Test2": { + }, "Test": { "gas": 2000000 }, + "ZAMyLib": { + }, "ZAMyLib2": { "deploy": true }, diff --git a/test_app/test/token_spec.js b/test_app/test/token_spec.js index 21f74c11..a8184ac2 100644 --- a/test_app/test/token_spec.js +++ b/test_app/test/token_spec.js @@ -10,6 +10,10 @@ describe("Token", function() { //}); var contractsConfig = { + "ZAMyLib": { + }, + "Token": { + }, "SimpleStorage": { args: [100] },