diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 6b12bc67..36ee2d9c 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -1,7 +1,6 @@ let toposort = require('toposort'); let async = require('async'); -let Compiler = require('./compiler.js'); let utils = require('../utils/utils.js'); const constants = require('../constants'); @@ -36,8 +35,7 @@ class ContractsManager { let self = this; async.waterfall([ function compileContracts(callback) { - let compiler = new Compiler({plugins: self.plugins, logger: self.logger}); - compiler.compile_contracts(self.contractFiles, function (err, compiledObject) { + self.events.request("compiler:contracts", self.contractFiles, function (err, compiledObject) { self.compiledContracts = compiledObject; callback(err); }); diff --git a/lib/core/engine.js b/lib/core/engine.js index e6709a23..67661fb7 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -4,6 +4,7 @@ const Events = require('./events.js'); const Logger = require('./logger.js'); const Config = require('./config.js'); const Blockchain = require('../contracts/blockchain.js'); +const Compiler = require('../contracts/compiler.js'); const ContractsManager = require('../contracts/contracts.js'); const DeployManager = require('../contracts/deploy_manager.js'); const CodeGenerator = require('../contracts/code_generator.js'); @@ -192,6 +193,11 @@ class Engine { deploymentService(options) { let self = this; + let compiler = new Compiler({plugins: self.plugins, logger: self.logger}); + this.events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { + compiler.compile_contracts(contractFiles, cb); + }); + this.registerModule('solidity', { contractDirectories: self.config.contractDirectories });