diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js index 677fe900..930465b0 100644 --- a/lib/contracts/blockchain.js +++ b/lib/contracts/blockchain.js @@ -13,7 +13,7 @@ class Blockchain { this.initWeb3(); } this.registerServiceCheck(); - this.registerAccountRequests(); + this.registerRequests(); } initWeb3() { @@ -57,7 +57,7 @@ class Blockchain { }); } - registerAccountRequests() { + registerRequests() { const self = this; this.events.setCommandHandler("blockchain:defaultAccount:get", function(cb) { @@ -68,6 +68,11 @@ class Blockchain { self.setDefaultAccount(account); cb(); }); + + this.events.setCommandHandler("blockchain:block:byNumber", function(blockNumber, cb) { + self.getBlock(blockNumber, cb); + }); + } defaultAccount() { diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 16d6b33a..a8ee3462 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -26,7 +26,7 @@ class Deploy { initTracker(cb) { this.deployTracker = new DeployTracker({ - logger: this.logger, chainConfig: this.chainConfig, blockchain: this.blockchain, env: this.env + logger: this.logger, chainConfig: this.chainConfig, env: this.env, events: this.events }, cb); } diff --git a/lib/contracts/deploy_tracker.js b/lib/contracts/deploy_tracker.js index 64d33b3a..994e1b54 100644 --- a/lib/contracts/deploy_tracker.js +++ b/lib/contracts/deploy_tracker.js @@ -5,16 +5,16 @@ class DeployTracker { constructor(options, cb) { const self = this; this.logger = options.logger; + this.events = options.events; this.env = options.env; this.chainConfig = options.chainConfig; - this.blockchain = options.blockchain; if (this.chainConfig === false) { this.currentChain = {contracts: []}; return cb(); } - this.blockchain.getBlock(0, function(err, block) { + this.events.request("blockchain:block:byNumber", 0, function(_err, block) { let chainId = block.hash; if (self.chainConfig[chainId] === undefined) { @@ -26,10 +26,6 @@ class DeployTracker { self.currentChain.name = self.env; cb(); }); - - // TODO: add other params - //this.currentChain.networkId = ""; - //this.currentChain.networkType = "custom" } loadConfig(config) {