remove web3 dependency from deploy tracker; use request instead to get block

This commit is contained in:
Iuri Matias 2018-05-18 21:08:32 -04:00 committed by Jonathan Rainville
parent 68c277cad1
commit 78f64945ab
3 changed files with 10 additions and 9 deletions

View File

@ -13,7 +13,7 @@ class Blockchain {
this.initWeb3(); this.initWeb3();
} }
this.registerServiceCheck(); this.registerServiceCheck();
this.registerAccountRequests(); this.registerRequests();
} }
initWeb3() { initWeb3() {
@ -57,7 +57,7 @@ class Blockchain {
}); });
} }
registerAccountRequests() { registerRequests() {
const self = this; const self = this;
this.events.setCommandHandler("blockchain:defaultAccount:get", function(cb) { this.events.setCommandHandler("blockchain:defaultAccount:get", function(cb) {
@ -68,6 +68,11 @@ class Blockchain {
self.setDefaultAccount(account); self.setDefaultAccount(account);
cb(); cb();
}); });
this.events.setCommandHandler("blockchain:block:byNumber", function(blockNumber, cb) {
self.getBlock(blockNumber, cb);
});
} }
defaultAccount() { defaultAccount() {

View File

@ -26,7 +26,7 @@ class Deploy {
initTracker(cb) { initTracker(cb) {
this.deployTracker = new DeployTracker({ 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); }, cb);
} }

View File

@ -5,16 +5,16 @@ class DeployTracker {
constructor(options, cb) { constructor(options, cb) {
const self = this; const self = this;
this.logger = options.logger; this.logger = options.logger;
this.events = options.events;
this.env = options.env; this.env = options.env;
this.chainConfig = options.chainConfig; this.chainConfig = options.chainConfig;
this.blockchain = options.blockchain;
if (this.chainConfig === false) { if (this.chainConfig === false) {
this.currentChain = {contracts: []}; this.currentChain = {contracts: []};
return cb(); return cb();
} }
this.blockchain.getBlock(0, function(err, block) { this.events.request("blockchain:block:byNumber", 0, function(_err, block) {
let chainId = block.hash; let chainId = block.hash;
if (self.chainConfig[chainId] === undefined) { if (self.chainConfig[chainId] === undefined) {
@ -26,10 +26,6 @@ class DeployTracker {
self.currentChain.name = self.env; self.currentChain.name = self.env;
cb(); cb();
}); });
// TODO: add other params
//this.currentChain.networkId = "";
//this.currentChain.networkType = "custom"
} }
loadConfig(config) { loadConfig(config) {