don't redeploy if an asset has been changed and not a contract

This commit is contained in:
Iuri Matias 2018-02-21 18:43:34 -05:00
parent ed530e8511
commit 41baca4b51
3 changed files with 26 additions and 23 deletions

View File

@ -1,7 +1,6 @@
let async = require('async'); let async = require('async');
//require("../utils/debug_util.js")(__filename, async); //require("../utils/debug_util.js")(__filename, async);
let Deploy = require('./deploy.js'); let Deploy = require('./deploy.js');
let ContractsManager = require('./contracts.js');
let RunCode = require('../core/runCode.js'); let RunCode = require('../core/runCode.js');
class DeployManager { class DeployManager {
@ -14,6 +13,7 @@ class DeployManager {
this.plugins = options.plugins; this.plugins = options.plugins;
this.web3 = options.web3; this.web3 = options.web3;
this.chainConfig = (options.trackContracts !== false) ? this.config.chainTracker : false; this.chainConfig = (options.trackContracts !== false) ? this.config.chainTracker : false;
this.contractsManager = options.contractsManager;
this.gasLimit = false; this.gasLimit = false;
this.fatalErrors = false; this.fatalErrors = false;
} }
@ -29,14 +29,7 @@ class DeployManager {
async.waterfall([ async.waterfall([
function buildContracts(callback) { function buildContracts(callback) {
let contractsManager = new ContractsManager({ self.contractsManager.build(callback);
contractFiles: self.config.contractsFiles,
contractsConfig: self.config.contractsConfig,
logger: self.logger,
plugins: self.plugins,
gasLimit: self.gasLimit
});
contractsManager.build(callback);
}, },
function checkWeb3IsConnected(contractsManager, callback) { function checkWeb3IsConnected(contractsManager, callback) {
if (!self.web3) { if (!self.web3) {

View File

@ -2,6 +2,7 @@ let Web3 = require('web3');
let Events = require('./events.js'); let Events = require('./events.js');
let Logger = require('./logger.js'); let Logger = require('./logger.js');
let Config = require('./config.js'); let Config = require('./config.js');
let ContractsManager = require('../contracts/contracts.js');
let DeployManager = require('../contracts/deploy_manager.js'); let DeployManager = require('../contracts/deploy_manager.js');
let CodeGenerator = require('../contracts/code_generator.js'); let CodeGenerator = require('../contracts/code_generator.js');
let ServicesMonitor = require('./services_monitor.js'); let ServicesMonitor = require('./services_monitor.js');
@ -99,13 +100,11 @@ class Engine {
}); });
// TODO: still need to redeploy contracts because the original contracts // TODO: still need to redeploy contracts because the original contracts
// config is being corrupted // config is being corrupted
//this.events.on('file-event', function(fileType, path) { this.events.on('file-event', function(fileType, _path) {
// if (fileType === 'asset') { if (fileType === 'asset') {
// self.config.reloadConfig(); self.events.emit('asset-changed', self.contractsManager);
// pipeline.build(self.abi, self.contractsJSON, path); }
// self.events.emit('outputDone'); });
// }
//});
} }
codeGeneratorService(_options) { codeGeneratorService(_options) {
@ -128,6 +127,7 @@ class Engine {
}; };
this.events.on('contractsDeployed', generateCode); this.events.on('contractsDeployed', generateCode);
this.events.on('blockchainDisabled', generateCode); this.events.on('blockchainDisabled', generateCode);
this.events.on('asset-changed', generateCode);
} }
deploymentService(options) { deploymentService(options) {
@ -137,23 +137,32 @@ class Engine {
contractDirectories: self.config.contractDirectories contractDirectories: self.config.contractDirectories
}); });
this.contractsManager = new ContractsManager({
contractFiles: this.config.contractsFiles,
contractsConfig: this.config.contractsConfig,
logger: this.logger,
plugins: this.plugins,
gasLimit: false
});
this.deployManager = new DeployManager({ this.deployManager = new DeployManager({
web3: options.web3 || self.web3, web3: options.web3 || self.web3,
trackContracts: options.trackContracts, trackContracts: options.trackContracts,
config: this.config, config: this.config,
logger: this.logger, logger: this.logger,
plugins: this.plugins, plugins: this.plugins,
events: this.events events: this.events,
contractsManager: this.contractsManager
}); });
this.events.on('file-event', function (_fileType, _path) { this.events.on('file-event', function (fileType, _path) {
// TODO: for now need to deploy on asset chanes as well // TODO: for now need to deploy on asset chanes as well
// because the contractsManager config is corrupted after a deploy // because the contractsManager config is corrupted after a deploy
//if (fileType === 'contract' || fileType === 'config') { if (fileType === 'contract' || fileType === 'config') {
self.config.reloadConfig(); self.config.reloadConfig();
self.deployManager.deployContracts(function () { self.deployManager.deployContracts(function () {
}); });
//} }
}); });
} }

View File

@ -77,6 +77,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
}); });
self.engine.deployManager.gasLimit = 6000000; self.engine.deployManager.gasLimit = 6000000;
self.engine.contractsManager.gasLimit = 6000000;
self.engine.deployManager.fatalErrors = true; self.engine.deployManager.fatalErrors = true;
self.engine.deployManager.deployContracts(function(err, _result) { self.engine.deployManager.deployContracts(function(err, _result) {
if (err) { if (err) {