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 isDev: this.isDev
}); });
const Blockchain = require('../contracts/blockchain.js'); this.registerModule('blockchain_connector', {
(new Blockchain({
contractsConfig: this.config.contractsConfig,
blockchainConfig: this.config.blockchainConfig,
events: this.events,
logger: this.logger,
isDev: this.isDev, isDev: this.isDev,
locale: this.locale,
web3: options.web3 web3: options.web3
})); /*eslint no-new: "off"*/ });
this.registerModule('whisper'); this.registerModule('whisper');
} }

View File

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

View File

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

View File

@ -6,7 +6,8 @@ const constants = require('../constants');
const Events = require('../core/events'); const Events = require('../core/events');
const cloneDeep = require('clone-deep'); const cloneDeep = require('clone-deep');
const AccountParser = require('../utils/accountParser'); 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 utils = require('../utils/utils');
const EmbarkJS = require('embarkjs'); const EmbarkJS = require('embarkjs');