rebase fixes
This commit is contained in:
parent
0d3dd56a86
commit
2843303d8c
|
@ -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;
|
|
@ -1,17 +1,16 @@
|
|||
let async = require('async');
|
||||
|
||||
const ContractDeployer = require('./contract_deployer.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
//require("../utils/debug_util.js")(__filename, async);
|
||||
const cloneDeep = require('clone-deep');
|
||||
|
||||
class DeployManager {
|
||||
constructor(options) {
|
||||
constructor(embark, options) {
|
||||
const self = this;
|
||||
this.config = options.config;
|
||||
this.logger = options.logger;
|
||||
this.config = embark.config;
|
||||
this.logger = embark.logger;
|
||||
this.blockchainConfig = this.config.blockchainConfig;
|
||||
|
||||
this.events = options.events;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
this.blockchain = options.blockchain;
|
||||
this.gasLimit = false;
|
||||
|
@ -19,9 +18,25 @@ class DeployManager {
|
|||
this.deployOnlyOnConfig = 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) => {
|
||||
self.deployContracts(cb);
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('deploy:contracts:test', (cb) => {
|
||||
self.fatalErrors = true;
|
||||
self.deployOnlyOnConfig = true;
|
||||
self.deployContracts(cb);
|
||||
});
|
||||
}
|
||||
|
||||
deployAll(done) {
|
||||
|
@ -101,6 +116,13 @@ class DeployManager {
|
|||
}
|
||||
|
||||
async.waterfall([
|
||||
function requestBlockchainConnector(callback) {
|
||||
self.events.request("blockchain:object", (blockchain) => {
|
||||
self.blockchain = blockchain;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
function buildContracts(callback) {
|
||||
self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => {
|
||||
callback(err);
|
||||
|
@ -118,12 +140,9 @@ class DeployManager {
|
|||
|
||||
// TODO: could be implemented as an event (beforeDeployAll)
|
||||
function checkIsConnectedToBlockchain(callback) {
|
||||
callback();
|
||||
//self.blockchain.onReady(() => {
|
||||
// self.blockchain.assertNodeConnection((err) => {
|
||||
// callback(err);
|
||||
// });
|
||||
//});
|
||||
self.blockchain.onReady((err) => {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
||||
// TODO: this can be done on the fly or as part of the initialization
|
||||
|
|
|
@ -104,14 +104,6 @@ class IPFS {
|
|||
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() {
|
||||
let ipfs = IpfsApi(this.host, this.port);
|
||||
this.events.emit("runcode:register", "ipfs", ipfs);
|
||||
|
@ -124,15 +116,9 @@ class IPFS {
|
|||
events: self.events,
|
||||
storageConfig: self.storageConfig,
|
||||
webServerConfig: self.webServerConfig,
|
||||
<<<<<<< HEAD
|
||||
blockchainConfig: self.blockchainConfig,
|
||||
corsParts: self.embark.config.corsParts
|
||||
||||||| merged common ancestors
|
||||
blockchainConfig: self.blockchainConfig
|
||||
=======
|
||||
blockchainConfig: self.blockchainConfig,
|
||||
embark: self.embark
|
||||
>>>>>>> small conflicts
|
||||
});
|
||||
self.logger.trace(`Storage module: Launching ipfs process...`);
|
||||
return storageProcessesLauncher.launchProcess('ipfs', callback);
|
||||
|
|
|
@ -73,7 +73,7 @@ class ScaffoldingReact {
|
|||
});
|
||||
}
|
||||
|
||||
build(contract){
|
||||
async build(contract){
|
||||
this._buildHTML(contract);
|
||||
|
||||
const filename = contract.className.toLowerCase();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue