diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js index ae6567fa..347c5e5c 100644 --- a/lib/contracts/blockchain.js +++ b/lib/contracts/blockchain.js @@ -24,6 +24,10 @@ class BlockchainConnector { cb(self.isWeb3Ready); }); + self.events.setCommandHandler("blockchain:object", (cb) => { + cb(self); + }); + if (!this.web3) { this.initWeb3(); } else { diff --git a/lib/core/engine.js b/lib/core/engine.js index a073373f..6465411b 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -206,7 +206,7 @@ class Engine { events: this.events }); - this.registerModule('deployment', {blockchain: this.blockchain, plugins: this.plugins, onlyCompile: options.onlyCompile}); + this.registerModule('deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile}); this.events.on('file-event', function (fileType) { clearTimeout(self.fileTimeout); @@ -252,7 +252,7 @@ class Engine { }); const Blockchain = require('../contracts/blockchain.js'); - this.blockchain = new Blockchain({ + (new Blockchain({ contractsConfig: this.config.contractsConfig, blockchainConfig: this.config.blockchainConfig, events: this.events, @@ -260,7 +260,7 @@ class Engine { isDev: this.isDev, locale: this.locale, web3: options.web3 - }); + })); /*eslint no-new: "off"*/ this.registerModule('whisper'); } diff --git a/lib/modules/deployment/contract_deployer.js b/lib/modules/deployment/contract_deployer.js index cb150d7c..a0582974 100644 --- a/lib/modules/deployment/contract_deployer.js +++ b/lib/modules/deployment/contract_deployer.js @@ -6,7 +6,6 @@ class ContractDeployer { constructor(options) { const self = this; - this.blockchain = options.blockchain; this.logger = options.logger; this.events = options.events; this.plugins = options.plugins; @@ -71,6 +70,13 @@ class ContractDeployer { } async.waterfall([ + function requestBlockchainConnector(callback) { + self.events.request("blockchain:object", (blockchain) => { + self.blockchain = blockchain; + callback(); + }); + }, + function _determineArguments(next) { self.determineArguments(params || contract.args, contract, (err, realArgs) => { if (err) { diff --git a/lib/modules/deployment/index.js b/lib/modules/deployment/index.js index ce303bc8..c32ca242 100644 --- a/lib/modules/deployment/index.js +++ b/lib/modules/deployment/index.js @@ -20,7 +20,6 @@ class DeployManager { this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false; this.contractDeployer = new ContractDeployer({ - blockchain: this.blockchain, logger: this.logger, events: this.events, plugins: this.plugins @@ -89,6 +88,13 @@ class DeployManager { } async.waterfall([ + function requestBlockchainConnector(callback) { + self.events.request("blockchain:object", (blockchain) => { + self.blockchain = blockchain; + callback(); + }); + }, + function buildContracts(callback) { self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => { callback(err);