rebase fixes

This commit is contained in:
Iuri Matias 2018-09-30 12:48:44 -04:00 committed by Pascal Precht
parent 0d3dd56a86
commit 2843303d8c
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
5 changed files with 5685 additions and 252 deletions

View File

@ -1,132 +0,0 @@
const async = require('async');
const AccountParser = require('./accountParser');
const fundAccount = require('./fundAccount');
class Provider {
constructor(options) {
this.web3 = options.web3;
this.accountsConfig = options.accountsConfig;
this.blockchainConfig = options.blockchainConfig;
this.type = options.type;
this.web3Endpoint = options.web3Endpoint;
this.logger = options.logger;
this.isDev = options.isDev;
this.engine = new ProviderEngine();
this.asyncMethods = {};
}
startWeb3Provider(callback) {
const self = this;
if (this.type === 'rpc') {
self.engine.addProvider(new RpcSubprovider({
rpcUrl: self.web3Endpoint
}));
} else if (this.type === 'ws') {
//self.engine.addProvider(new WsSubprovider({
console.log('USing ws');
self.addProvider(new SubscriptionSubprovider());
self.addProvider(new WsSubprovider({
rpcUrl: self.web3Endpoint,
origin: this.blockchainConfig.wsOrigins.split(',')[0]
}));
//self.provider = new this.web3.providers.WebsocketProvider(self.web3Endpoint, {headers: {Origin: "embark"}});
} else {
return callback(__("contracts config error: unknown deployment type %s", this.type));
}
// network connectivity error
self.engine.on('error', (err) => {
// report connectivity errors
self.logger.error(err);
});
self.engine.start();
//self.on('error', (err) => {
// console.log('ERR', JSON.stringify(err));
// // report connectivity errors as trace due to polling
// self.logger.trace('web3 provider error: ', err);
// self.logger.trace('stopping web3 provider due to error');
// // prevent continuous polling errors
// self.stop();
//});
//self.web3.setProvider(self);
//self.start();
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger);
self.addresses = [];
if (!self.accounts.length) {
return callback();
}
self.accounts.forEach(account => {
self.addresses.push(account.address);
self.web3.eth.accounts.wallet.add(account);
});
self.realAccountFunction = self.web3.eth.getAccounts;
self.web3.eth.getAccounts = function (cb) {
if (!cb) {
cb = function () {
};
}
return new Promise((resolve, reject) => {
self.realAccountFunction((err, accounts) => {
if (err) {
cb(err);
return reject(err);
}
accounts = accounts.concat(self.addresses);
// accounts = self.addresses.concat(accounts);
cb(null, accounts);
resolve(accounts);
});
});
};
callback();
}
fundAccounts(callback) {
const self = this;
if (!self.accounts.length) {
return callback();
}
if (!self.isDev) {
return callback();
}
async.each(self.accounts, (account, eachCb) => {
fundAccount(self.web3, account.address, account.hexBalance, eachCb);
}, callback);
}
stop() {
this.engine.stop();
}
eth_accounts(payload, cb) {
return cb(null, this.addresses);
}
sendAsync(payload, callback) {
let method = this.asyncMethods[payload.method];
if (method) {
return method.call(method, payload, (err, result) => {
if (err) {
return callback(err);
}
let response = {'id': payload.id, 'jsonrpc': '2.0', 'result': result};
callback(null, response);
});
}
this.engine.sendAsync.apply(this.engine, arguments);
}
send() {
return this.engine.send.apply(this.engine, arguments);
}
}
module.exports = Provider;

View File

@ -1,17 +1,16 @@
let async = require('async'); let async = require('async');
const ContractDeployer = require('./contract_deployer.js'); const ContractDeployer = require('./contract_deployer.js');
const utils = require('../../utils/utils.js'); const cloneDeep = require('clone-deep');
//require("../utils/debug_util.js")(__filename, async);
class DeployManager { class DeployManager {
constructor(options) { constructor(embark, options) {
const self = this; const self = this;
this.config = options.config; this.config = embark.config;
this.logger = options.logger; this.logger = embark.logger;
this.blockchainConfig = this.config.blockchainConfig; this.blockchainConfig = this.config.blockchainConfig;
this.events = options.events; this.events = embark.events;
this.plugins = options.plugins; this.plugins = options.plugins;
this.blockchain = options.blockchain; this.blockchain = options.blockchain;
this.gasLimit = false; this.gasLimit = false;
@ -19,9 +18,25 @@ class DeployManager {
this.deployOnlyOnConfig = false; this.deployOnlyOnConfig = false;
this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false; this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false;
this.contractDeployer = new ContractDeployer({
logger: this.logger,
events: this.events,
plugins: this.plugins
});
this.events.setCommandHandler('deploy:setGasLimit', (gasLimit) => {
self.gasLimit = gasLimit;
});
this.events.setCommandHandler('deploy:contracts', (cb) => { this.events.setCommandHandler('deploy:contracts', (cb) => {
self.deployContracts(cb); self.deployContracts(cb);
}); });
this.events.setCommandHandler('deploy:contracts:test', (cb) => {
self.fatalErrors = true;
self.deployOnlyOnConfig = true;
self.deployContracts(cb);
});
} }
deployAll(done) { deployAll(done) {
@ -101,6 +116,13 @@ class DeployManager {
} }
async.waterfall([ async.waterfall([
function requestBlockchainConnector(callback) {
self.events.request("blockchain:object", (blockchain) => {
self.blockchain = blockchain;
callback();
});
},
function buildContracts(callback) { function buildContracts(callback) {
self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => { self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => {
callback(err); callback(err);
@ -108,8 +130,8 @@ class DeployManager {
}, },
// TODO: shouldn't be necessary // TODO: shouldn't be necessary
function checkCompileOnly(callback){ function checkCompileOnly(callback) {
if(self.onlyCompile){ if (self.onlyCompile) {
self.events.emit('contractsDeployed'); self.events.emit('contractsDeployed');
return done(); return done();
} }
@ -118,12 +140,9 @@ class DeployManager {
// TODO: could be implemented as an event (beforeDeployAll) // TODO: could be implemented as an event (beforeDeployAll)
function checkIsConnectedToBlockchain(callback) { function checkIsConnectedToBlockchain(callback) {
callback(); self.blockchain.onReady((err) => {
//self.blockchain.onReady(() => { callback(err);
// self.blockchain.assertNodeConnection((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

View File

@ -104,14 +104,6 @@ class IPFS {
this.embark.addCodeToEmbarkJS(code); this.embark.addCodeToEmbarkJS(code);
} }
addNamesystemProviderToEmbarkJS() {
let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs', 'name.js')).toString();
code += "\nEmbarkJS.Names.registerProvider('ipns', __embarkIPFS);";
this.embark.addCodeToEmbarkJS(code);
}
addObjectToConsole() { addObjectToConsole() {
let ipfs = IpfsApi(this.host, this.port); let ipfs = IpfsApi(this.host, this.port);
this.events.emit("runcode:register", "ipfs", ipfs); this.events.emit("runcode:register", "ipfs", ipfs);
@ -124,15 +116,9 @@ class IPFS {
events: self.events, events: self.events,
storageConfig: self.storageConfig, storageConfig: self.storageConfig,
webServerConfig: self.webServerConfig, webServerConfig: self.webServerConfig,
<<<<<<< HEAD
blockchainConfig: self.blockchainConfig, blockchainConfig: self.blockchainConfig,
corsParts: self.embark.config.corsParts corsParts: self.embark.config.corsParts
||||||| merged common ancestors
blockchainConfig: self.blockchainConfig
=======
blockchainConfig: self.blockchainConfig,
embark: self.embark embark: self.embark
>>>>>>> small conflicts
}); });
self.logger.trace(`Storage module: Launching ipfs process...`); self.logger.trace(`Storage module: Launching ipfs process...`);
return storageProcessesLauncher.launchProcess('ipfs', callback); return storageProcessesLauncher.launchProcess('ipfs', callback);

View File

@ -73,7 +73,7 @@ class ScaffoldingReact {
}); });
} }
build(contract){ async build(contract){
this._buildHTML(contract); this._buildHTML(contract);
const filename = contract.className.toLowerCase(); const filename = contract.className.toLowerCase();

5742
package-lock.json generated

File diff suppressed because it is too large Load Diff