mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-19 11:50:56 +00:00
cleanup
This commit is contained in:
parent
a38428f762
commit
55c001deda
@ -21,8 +21,6 @@ class Blockchain {
|
|||||||
this.web3StartedInProcess = false;
|
this.web3StartedInProcess = false;
|
||||||
|
|
||||||
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
||||||
console.dir("geting state of web3");
|
|
||||||
console.dir(self.isWeb3Ready.toString());
|
|
||||||
cb(self.isWeb3Ready);
|
cb(self.isWeb3Ready);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,7 +43,6 @@ class Blockchain {
|
|||||||
if (this.contractsConfig.deployment.type !== "rpc" && this.contractsConfig.deployment.type !== "ws") {
|
if (this.contractsConfig.deployment.type !== "rpc" && this.contractsConfig.deployment.type !== "ws") {
|
||||||
const message = __("contracts config error: unknown deployment type %s", this.contractsConfig.deployment.type);
|
const message = __("contracts config error: unknown deployment type %s", this.contractsConfig.deployment.type);
|
||||||
this.logger.error(message);
|
this.logger.error(message);
|
||||||
//return cb(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const protocol = (this.contractsConfig.deployment.type === "rpc") ? this.contractsConfig.deployment.protocol : 'ws';
|
const protocol = (this.contractsConfig.deployment.type === "rpc") ? this.contractsConfig.deployment.protocol : 'ws';
|
||||||
@ -64,17 +61,11 @@ class Blockchain {
|
|||||||
this.provider = new Provider(providerOptions);
|
this.provider = new Provider(providerOptions);
|
||||||
|
|
||||||
self.events.request("processes:launch", "blockchain", () => {
|
self.events.request("processes:launch", "blockchain", () => {
|
||||||
console.dir("======> blockchain launched!");
|
|
||||||
console.dir("starting web3 provider");
|
|
||||||
self.provider.startWeb3Provider(() => {
|
self.provider.startWeb3Provider(() => {
|
||||||
console.dir("funding accounts");
|
|
||||||
self.provider.fundAccounts(() => {
|
self.provider.fundAccounts(() => {
|
||||||
console.dir("registering web3 object");
|
|
||||||
self.isWeb3Ready = true;
|
self.isWeb3Ready = true;
|
||||||
self.events.emit(WEB3_READY);
|
self.events.emit(WEB3_READY);
|
||||||
self.registerWeb3Object();
|
self.registerWeb3Object();
|
||||||
|
|
||||||
//self.events.emit("check:backOnline:Ethereum");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -97,14 +88,11 @@ class Blockchain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onReady(callback) {
|
onReady(callback) {
|
||||||
console.dir("======> onReady!!");
|
|
||||||
console.dir("this.isWeb3Ready: " + this.isWeb3Ready.toString());
|
|
||||||
if (this.isWeb3Ready) {
|
if (this.isWeb3Ready) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.events.once(WEB3_READY, () => {
|
this.events.once(WEB3_READY, () => {
|
||||||
console.dir("got event triggered");
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -146,7 +134,6 @@ class Blockchain {
|
|||||||
if (err && err !== NO_NODE) {
|
if (err && err !== NO_NODE) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
console.dir(statusObj);
|
|
||||||
cb(statusObj);
|
cb(statusObj);
|
||||||
});
|
});
|
||||||
}, 5000, 'off');
|
}, 5000, 'off');
|
||||||
@ -198,10 +185,8 @@ class Blockchain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getGasPrice(cb) {
|
getGasPrice(cb) {
|
||||||
console.dir("geting gas price");
|
|
||||||
const self = this;
|
const self = this;
|
||||||
this.onReady(() => {
|
this.onReady(() => {
|
||||||
console.dir("it's ready, getting gas price");
|
|
||||||
self.web3.eth.getGasPrice(cb);
|
self.web3.eth.getGasPrice(cb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,15 +85,15 @@ class DeployManager {
|
|||||||
return callback();
|
return callback();
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: could be implemented as an event (beforeDeployAll)
|
//// TODO: could be implemented as an event (beforeDeployAll)
|
||||||
function checkIsConnectedToBlockchain(callback) {
|
//function checkIsConnectedToBlockchain(callback) {
|
||||||
callback();
|
// callback();
|
||||||
//self.blockchain.onReady(() => {
|
// //self.blockchain.onReady(() => {
|
||||||
// self.blockchain.assertNodeConnection((err) => {
|
// // self.blockchain.assertNodeConnection((err) => {
|
||||||
// callback(err);
|
// // callback(err);
|
||||||
// });
|
// // });
|
||||||
//});
|
// //});
|
||||||
},
|
//},
|
||||||
|
|
||||||
// TODO: this can be done on the fly or as part of the initialization
|
// TODO: this can be done on the fly or as part of the initialization
|
||||||
function determineDefaultAccount(callback) {
|
function determineDefaultAccount(callback) {
|
||||||
|
@ -11,6 +11,7 @@ function log(eventType, eventName) {
|
|||||||
if (['end', 'prefinish', 'error', 'new', 'demo', 'block', 'version'].indexOf(eventName) >= 0) {
|
if (['end', 'prefinish', 'error', 'new', 'demo', 'block', 'version'].indexOf(eventName) >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// prevents infinite loop when printing events
|
||||||
if (eventType.indexOf("log") >= 0) {
|
if (eventType.indexOf("log") >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,7 @@ class BlockchainModule {
|
|||||||
this.events.request('processes:register', 'blockchain', (cb) => {
|
this.events.request('processes:register', 'blockchain', (cb) => {
|
||||||
console.dir("gonna check node connection");
|
console.dir("gonna check node connection");
|
||||||
self.assertNodeConnection(true, (connected) => {
|
self.assertNodeConnection(true, (connected) => {
|
||||||
if (connected === undefined) {
|
|
||||||
console.dir("result is undefined");
|
|
||||||
} else {
|
|
||||||
console.dir("result is " + connected.toString());
|
|
||||||
}
|
|
||||||
//if (!err) return cb();
|
|
||||||
if (connected) return cb();
|
if (connected) return cb();
|
||||||
console.dir("blockchain not started, so gonna start one");
|
|
||||||
self.startBlockchainNode(cb);
|
self.startBlockchainNode(cb);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -43,12 +36,8 @@ class BlockchainModule {
|
|||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
// check if web3 is set
|
|
||||||
//
|
|
||||||
function checkWeb3State(next) {
|
function checkWeb3State(next) {
|
||||||
self.events.request("blockchain:web3:isReady", (connected) => {
|
self.events.request("blockchain:web3:isReady", (connected) => {
|
||||||
console.dir("---> checking web3 state");
|
|
||||||
console.dir(connected.toString());
|
|
||||||
if (connected) {
|
if (connected) {
|
||||||
return next(connected);
|
return next(connected);
|
||||||
}
|
}
|
||||||
@ -71,7 +60,6 @@ class BlockchainModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startBlockchainNode(callback) {
|
startBlockchainNode(callback) {
|
||||||
console.dir("||==> startBlockchainNode");
|
|
||||||
const self = this;
|
const self = this;
|
||||||
let blockchainProcess = new BlockchainProcessLauncher({
|
let blockchainProcess = new BlockchainProcessLauncher({
|
||||||
events: self.events,
|
events: self.events,
|
||||||
@ -84,11 +72,9 @@ class BlockchainModule {
|
|||||||
|
|
||||||
blockchainProcess.startBlockchainNode();
|
blockchainProcess.startBlockchainNode();
|
||||||
self.events.once(constants.blockchain.blockchainReady, () => {
|
self.events.once(constants.blockchain.blockchainReady, () => {
|
||||||
console.dir("||==> blockchainReady");
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
self.events.once(constants.blockchain.blockchainExit, () => {
|
self.events.once(constants.blockchain.blockchainExit, () => {
|
||||||
console.dir("||==> blockchainExit");
|
|
||||||
self.provider.stop();
|
self.provider.stop();
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const Viz = require('viz.js');
|
const Viz = require('viz.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// TODO: refactor this class to use the plugin api and not refeneences directly
|
||||||
class GraphGenerator {
|
class GraphGenerator {
|
||||||
constructor(embark, options) {
|
constructor(embark, options) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -39,9 +39,6 @@ describe('embark.Contracts', function() {
|
|||||||
|
|
||||||
let events = new Events();
|
let events = new Events();
|
||||||
let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins});
|
let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins});
|
||||||
//events.setCommandHandler("compiler:contracts", function(contractFiles, cb) {
|
|
||||||
// compiler.compile_contracts(contractFiles, cb);
|
|
||||||
//});
|
|
||||||
|
|
||||||
events.setCommandHandler("config:contractsConfig", function(cb) {
|
events.setCommandHandler("config:contractsConfig", function(cb) {
|
||||||
cb(contractsConfig);
|
cb(contractsConfig);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user