reload config; create a config so it doens't damage original

This commit is contained in:
Iuri Matias 2018-06-14 09:21:51 -04:00
parent be6ada2909
commit 5a2cf62ee5
3 changed files with 29 additions and 3 deletions

View File

@ -216,10 +216,13 @@ class ContractDeployer {
},
function estimateCorrectGas(next) {
if (contract.gas === 'auto') {
return deployObject.estimateGas().then((gasValue) => {
return self.blockchain.estimateDeployContractGas(deployObject, (err, gasValue) => {
if (err) {
return next(err);
}
contract.gas = gasValue;
next();
}).catch(next);
});
}
next();
},

View File

@ -1,5 +1,6 @@
let toposort = require('toposort');
let async = require('async');
const cloneDeep = require('clone-deep');
let utils = require('../utils/utils.js');
const constants = require('../constants');
@ -10,7 +11,7 @@ class ContractsManager {
constructor(options) {
const self = this;
this.contractFiles = options.contractFiles;
this.contractsConfig = options.contractsConfig;
this.contractsConfig = cloneDeep(options.contractsConfig || {});
this.contracts = {};
this.logger = options.logger;
this.plugins = options.plugins;
@ -58,7 +59,20 @@ class ContractsManager {
build(done) {
let self = this;
self.contracts = {};
async.waterfall([
function loadContractFiles(callback) {
self.events.request("config:contractsFiles", (contractsFiles) => {
self.contractsFiles = contractsFiles;
callback();
});
},
function loadContractConfigs(callback) {
self.events.request("config:contractsConfig", (contractsConfig) => {
self.contractsConfig = cloneDeep(contractsConfig);
callback();
});
},
function compileContracts(callback) {
self.events.emit("status", __("Compiling..."));
if (process.env.isTest && self.compiledContracts && Object.keys(self.compiledContracts).length) {

View File

@ -7,6 +7,7 @@ const deepEqual = require('deep-equal');
const constants = require('../constants');
var Config = function(options) {
const self = this;
this.env = options.env;
this.blockchainConfig = {};
this.contractsConfig = {};
@ -22,6 +23,14 @@ var Config = function(options) {
this.events = options.events;
this.embarkConfig = {};
this.context = options.context || [constants.contexts.any];
self.events.setCommandHandler("config:contractsConfig", (cb) => {
cb(self.contractsConfig);
});
self.events.setCommandHandler("config:contractsFiles", (cb) => {
cb(self.contractsFiles);
});
};
Config.prototype.loadConfigFiles = function(options) {