move blockchain connection code to its own module

This commit is contained in:
Iuri Matias 2018-07-27 16:54:33 -04:00
parent 567b0c75b8
commit 4919114f36
5 changed files with 11 additions and 16 deletions

View File

@ -251,16 +251,10 @@ class Engine {
isDev: this.isDev
});
const Blockchain = require('../contracts/blockchain.js');
(new Blockchain({
contractsConfig: this.config.contractsConfig,
blockchainConfig: this.config.blockchainConfig,
events: this.events,
logger: this.logger,
this.registerModule('blockchain_connector', {
isDev: this.isDev,
locale: this.locale,
web3: options.web3
})); /*eslint no-new: "off"*/
});
this.registerModule('whisper');
}

View File

@ -1,19 +1,19 @@
const Web3 = require('web3');
const async = require('async');
const Provider = require('./provider.js');
const utils = require('../utils/utils');
const utils = require('../../utils/utils');
const WEB3_READY = 'web3Ready';
// TODO: consider another name, this is the blockchain connector
class BlockchainConnector {
constructor(options) {
constructor(embark, options) {
const self = this;
this.plugins = options.plugins;
this.logger = options.logger;
this.events = options.events;
this.contractsConfig = options.contractsConfig;
this.blockchainConfig = options.blockchainConfig;
this.logger = embark.logger;
this.events = embark.events;
this.contractsConfig = embark.config.contractsConfig;
this.blockchainConfig = embark.config.blockchainConfig;
this.web3 = options.web3;
this.isDev = options.isDev;
this.web3Endpoint = '';

View File

@ -1,5 +1,5 @@
const async = require('async');
const AccountParser = require('../utils/accountParser');
const AccountParser = require('../../utils/accountParser');
const fundAccount = require('./fundAccount');
class Provider {

View File

@ -6,7 +6,8 @@ const constants = require('../constants');
const Events = require('../core/events');
const cloneDeep = require('clone-deep');
const AccountParser = require('../utils/accountParser');
const Provider = require('../contracts/provider');
// TODO: breaks module isolation; tests need to be refactored to use the engine and avoid this
const Provider = require('../modules/blockchain_connector/provider.js');
const utils = require('../utils/utils');
const EmbarkJS = require('embarkjs');