diff --git a/lib/constants.json b/lib/constants.json index 8971600ec..344a5128e 100644 --- a/lib/constants.json +++ b/lib/constants.json @@ -56,5 +56,9 @@ "logs": { "logPath": ".embark/logs/", "maxLogLength": 1500 + }, + "deploymentStrategy": { + "implicit": "implicit", + "explicit": "explicit" } } diff --git a/lib/core/config.js b/lib/core/config.js index b653812d6..c74ad16f6 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -276,6 +276,7 @@ Config.prototype.loadContractsConfigFile = function() { "$WEB3", "localhost:8545" ], + "strategy": constants.deploymentStrategy.implicit, "gas": "auto", "contracts": { } diff --git a/lib/modules/contracts_manager/index.js b/lib/modules/contracts_manager/index.js index d2f29ac99..49be163cb 100644 --- a/lib/modules/contracts_manager/index.js +++ b/lib/modules/contracts_manager/index.js @@ -4,6 +4,7 @@ const cloneDeep = require('clone-deep'); const utils = require('../../utils/utils.js'); const fs = require('../../core/fs'); +const constants = require('../../constants'); // TODO: create a contract object @@ -307,6 +308,10 @@ class ContractsManager { contract.deploy = false; } + if (!self.contractsConfig.contracts[className] && self.contractsConfig.strategy === constants.deploymentStrategy.explicit) { + contract.deploy = false; + } + if (contract.code === "") { const message = __("assuming %s to be an interface", className); if (contract.silent) { diff --git a/templates/boilerplate/config/contracts.js b/templates/boilerplate/config/contracts.js index 29828c2ba..ad42e14e3 100644 --- a/templates/boilerplate/config/contracts.js +++ b/templates/boilerplate/config/contracts.js @@ -31,7 +31,17 @@ module.exports = { "ws://localhost:8546", "http://localhost:8545" ], + gas: "auto", + + // Strategy for the deployment of the contracts: + // - implicit will try to deploy all the contracts located inside the contracts directory + // or the directory configured for the location of the contracts. This is default one + // when not specified + // - explicit will only attempt to deploy the contracts that are explicity specified inside the + // contracts section. + //strategy: 'implicit', + contracts: { // example: //SimpleStorage: { diff --git a/templates/demo/config/contracts.js b/templates/demo/config/contracts.js index 4fdd08f7d..9e4cb3c2d 100644 --- a/templates/demo/config/contracts.js +++ b/templates/demo/config/contracts.js @@ -31,7 +31,17 @@ module.exports = { "ws://localhost:8546", "http://localhost:8545" ], + gas: "auto", + + // Strategy for the deployment of the contracts: + // - implicit will try to deploy all the contracts located inside the contracts directory + // or the directory configured for the location of the contracts. This is default one + // when not specified + // - explicit will only attempt to deploy the contracts that are explicity specified inside the + // contracts section. + //strategy: 'implicit', + contracts: { SimpleStorage: { fromIndex: 0, diff --git a/templates/simple/contracts.js b/templates/simple/contracts.js index 29828c2ba..ad42e14e3 100644 --- a/templates/simple/contracts.js +++ b/templates/simple/contracts.js @@ -31,7 +31,17 @@ module.exports = { "ws://localhost:8546", "http://localhost:8545" ], + gas: "auto", + + // Strategy for the deployment of the contracts: + // - implicit will try to deploy all the contracts located inside the contracts directory + // or the directory configured for the location of the contracts. This is default one + // when not specified + // - explicit will only attempt to deploy the contracts that are explicity specified inside the + // contracts section. + //strategy: 'implicit', + contracts: { // example: //SimpleStorage: { diff --git a/test/config.js b/test/config.js index ca7202aeb..04d1ffa92 100644 --- a/test/config.js +++ b/test/config.js @@ -112,6 +112,7 @@ describe('embark.Config', function () { deployment: {host: 'localhost', port: 8545, type: 'rpc', "accounts": [{"mnemonic": "12 word mnemonic", "balance": "5000000000"}]}, dappConnection: ['$WEB3', 'localhost:8545'], "gas": "400000", + "strategy": "implicit", "contracts": { "SimpleStorage": { "args": [100],