mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-08 21:34:55 +00:00
Fixing conflicts
This commit is contained in:
parent
e46f6aa5b7
commit
48a3f2afdc
@ -3,6 +3,7 @@ const child_process = require('child_process');
|
|||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
const fs = require('../../core/fs.js');
|
const fs = require('../../core/fs.js');
|
||||||
|
const constants = require('../../constants.json');
|
||||||
|
|
||||||
const GethCommands = require('./geth_commands.js');
|
const GethCommands = require('./geth_commands.js');
|
||||||
|
|
||||||
@ -83,10 +84,18 @@ Blockchain.prototype.setupProxy = function() {
|
|||||||
|
|
||||||
let ipcObject = new Ipc({ipcRole: 'client'});
|
let ipcObject = new Ipc({ipcRole: 'client'});
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false);
|
proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false);
|
||||||
proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true);
|
proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true);
|
||||||
this.config.rpcPort += 10;
|
this.config.rpcPort += 10;
|
||||||
this.config.wsPort += 10;
|
this.config.wsPort += 10;
|
||||||
|
=======
|
||||||
|
proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false);
|
||||||
|
proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true);
|
||||||
|
this.config.rpcPort += constants.blockchain.servicePortOnProxy;
|
||||||
|
this.config.wsPort += constants.blockchain.servicePortOnProxy;
|
||||||
|
}
|
||||||
|
>>>>>>> Changes based on code review
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.prototype.runCommand = function(cmd, options, callback) {
|
Blockchain.prototype.runCommand = function(cmd, options, callback) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
let shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
let proxy = require('../core/proxy');
|
let proxy = require('../core/proxy');
|
||||||
const Ipc = require('../core/ipc');
|
const Ipc = require('../core/ipc');
|
||||||
|
const constants = require('../constants.json');
|
||||||
|
|
||||||
class Simulator {
|
class Simulator {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
@ -23,7 +24,7 @@ class Simulator {
|
|||||||
let host = (options.host || this.blockchainConfig.rpcHost || 'localhost');
|
let host = (options.host || this.blockchainConfig.rpcHost || 'localhost');
|
||||||
let port = (options.port || this.blockchainConfig.rpcPort || 8545);
|
let port = (options.port || this.blockchainConfig.rpcPort || 8545);
|
||||||
|
|
||||||
cmds.push("-p " + (port + (useProxy ? 10 : 0)));
|
cmds.push("-p " + (port + (useProxy ? constants.blockchain.servicePortOnProxy : 0)));
|
||||||
cmds.push("-h " + host);
|
cmds.push("-h " + host);
|
||||||
cmds.push("-a " + (options.numAccounts || 10));
|
cmds.push("-a " + (options.numAccounts || 10));
|
||||||
cmds.push("-e " + (options.defaultBalance || 100));
|
cmds.push("-e " + (options.defaultBalance || 100));
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
"blockchain": {
|
"blockchain": {
|
||||||
"blockchainReady": "blockchainReady",
|
"blockchainReady": "blockchainReady",
|
||||||
"init": "init",
|
"init": "init",
|
||||||
"initiated": "initiated"
|
"initiated": "initiated",
|
||||||
|
"servicePortOnProxy": 10
|
||||||
},
|
},
|
||||||
"storage": {
|
"storage": {
|
||||||
"init": "init",
|
"init": "init",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const httpProxy = require('http-proxy');
|
const httpProxy = require('http-proxy');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const constants = require('../constants.json');
|
||||||
|
|
||||||
exports.serve = function(ipc, host, port, ws){
|
exports.serve = function(ipc, host, port, ws){
|
||||||
let commList = {};
|
let commList = {};
|
||||||
@ -8,14 +9,15 @@ exports.serve = function(ipc, host, port, ws){
|
|||||||
|
|
||||||
let proxy = httpProxy.createProxyServer({
|
let proxy = httpProxy.createProxyServer({
|
||||||
target: {
|
target: {
|
||||||
host: host,
|
host,
|
||||||
port: port + 10
|
port: port + constants.blockchain.servicePortOnProxy
|
||||||
},
|
},
|
||||||
ws: ws
|
ws: ws
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.on('error', function () {
|
proxy.on('error', function () {
|
||||||
proxy.close();
|
console.log(__("Error forwarding requests to blockchain/simulator"));
|
||||||
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.on('proxyRes', (proxyRes) => {
|
proxy.on('proxyRes', (proxyRes) => {
|
||||||
@ -23,8 +25,14 @@ exports.serve = function(ipc, host, port, ws){
|
|||||||
proxyRes.on('data', (b) => resBody.push(b));
|
proxyRes.on('data', (b) => resBody.push(b));
|
||||||
proxyRes.on('end', function () {
|
proxyRes.on('end', function () {
|
||||||
resBody = Buffer.concat(resBody).toString();
|
resBody = Buffer.concat(resBody).toString();
|
||||||
|
|
||||||
|
let jsonO;
|
||||||
try {
|
try {
|
||||||
let jsonO = JSON.parse(resBody);
|
jsonO = JSON.parse(resBody);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(commList[jsonO.id]){
|
if(commList[jsonO.id]){
|
||||||
commList[jsonO.id].transactionHash = jsonO.result;
|
commList[jsonO.id].transactionHash = jsonO.result;
|
||||||
transactions[jsonO.result] = {commListId: jsonO.id};
|
transactions[jsonO.result] = {commListId: jsonO.id};
|
||||||
@ -46,9 +54,6 @@ exports.serve = function(ipc, host, port, ws){
|
|||||||
delete receipts[jsonO.id];
|
delete receipts[jsonO.id];
|
||||||
delete commList[jsonO.id];
|
delete commList[jsonO.id];
|
||||||
}
|
}
|
||||||
} catch(e){
|
|
||||||
//
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,13 +64,13 @@ exports.serve = function(ipc, host, port, ws){
|
|||||||
reqBody = Buffer.concat(reqBody).toString();
|
reqBody = Buffer.concat(reqBody).toString();
|
||||||
if(reqBody){
|
if(reqBody){
|
||||||
let jsonO = JSON.parse(reqBody);
|
let jsonO = JSON.parse(reqBody);
|
||||||
if(jsonO.method == "eth_sendTransaction"){
|
if(jsonO.method === "eth_sendTransaction"){
|
||||||
commList[jsonO.id] = {
|
commList[jsonO.id] = {
|
||||||
type: 'contract-log',
|
type: 'contract-log',
|
||||||
address: jsonO.params[0].to,
|
address: jsonO.params[0].to,
|
||||||
data: jsonO.params[0].data
|
data: jsonO.params[0].data
|
||||||
};
|
};
|
||||||
} else if(jsonO.method == "eth_getTransactionReceipt"){
|
} else if(jsonO.method === "eth_getTransactionReceipt"){
|
||||||
if(transactions[jsonO.params[0]]){
|
if(transactions[jsonO.params[0]]){
|
||||||
transactions[jsonO.params[0]].receiptId = jsonO.id;
|
transactions[jsonO.params[0]].receiptId = jsonO.id;
|
||||||
receipts[jsonO.id] = transactions[jsonO.params[0]].commListId;
|
receipts[jsonO.id] = transactions[jsonO.params[0]].commListId;
|
||||||
|
@ -4,57 +4,66 @@ class ConsoleListener {
|
|||||||
constructor(embark, options) {
|
constructor(embark, options) {
|
||||||
this.logger = embark.logger;
|
this.logger = embark.logger;
|
||||||
this.ipc = options.ipc;
|
this.ipc = options.ipc;
|
||||||
|
this.events = embark.events;
|
||||||
this.addressToContract = [];
|
this.addressToContract = [];
|
||||||
this.contractsConfig = embark.config.contractsConfig;
|
this.contractsConfig = embark.config.contractsConfig;
|
||||||
this.listenForLogRequests();
|
this.contractsDeployed = false;
|
||||||
|
|
||||||
|
this._listenForLogRequests();
|
||||||
|
|
||||||
|
this.events.on("contractsDeployed", () => {
|
||||||
|
this.contractsDeployed = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateContractList(){
|
_updateContractList(){
|
||||||
Object.keys(this.contractsConfig.contracts).forEach(contractName => {
|
this.events.request("contracts:list", (_err, contractsList) => {
|
||||||
let contract = this.contractsConfig.contracts[contractName];
|
if(_err) return;
|
||||||
|
contractsList.forEach(contract => {
|
||||||
let address = contract.deployedAddress.toLowerCase();
|
let address = contract.deployedAddress.toLowerCase();
|
||||||
|
|
||||||
if(!this.addressToContract[address]){
|
if(!this.addressToContract[address]){
|
||||||
let funcSignatures = {};
|
let funcSignatures = {};
|
||||||
contract.abiDefinition
|
contract.abiDefinition
|
||||||
.filter(func => func.type == "function")
|
.filter(func => func.type == "function")
|
||||||
.map(func => {
|
.map(func => {
|
||||||
return {
|
const name = func.name +
|
||||||
name: func.name +
|
|
||||||
'(' +
|
'(' +
|
||||||
(func.inputs ? func.inputs.map(input => input.type).join(',') : '') +
|
(func.inputs ? func.inputs.map(input => input.type).join(',') : '') +
|
||||||
')',
|
')';
|
||||||
|
funcSignatures[utils.sha3(name).substring(0, 10)] = {
|
||||||
|
name,
|
||||||
abi: func,
|
abi: func,
|
||||||
functionName: func.name
|
functionName: func.name
|
||||||
};
|
};
|
||||||
})
|
|
||||||
.forEach(func => {
|
|
||||||
funcSignatures[utils.sha3(func.name).substring(0, 10)] = func;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addressToContract[address] = {
|
this.addressToContract[address] = {
|
||||||
name: contractName,
|
name: contract.className,
|
||||||
functions: funcSignatures
|
functions: funcSignatures
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
listenForLogRequests(){
|
_listenForLogRequests(){
|
||||||
if(this.ipc.ipcRole === 'server'){
|
if(this.ipc.ipcRole !== 'server') return;
|
||||||
this.ipc.on('log', (request) => {
|
this.ipc.on('log', (request) => {
|
||||||
if(request.type == 'contract-log'){
|
if(request.type == 'contract-log'){
|
||||||
|
if(!this.contractsDeployed) return;
|
||||||
|
|
||||||
let {address, data, transactionHash, blockNumber, gasUsed, status} = request;
|
let {address, data, transactionHash, blockNumber, gasUsed, status} = request;
|
||||||
if(!this.addressToContract[address]){
|
if(!this.addressToContract[address]){
|
||||||
this._updateContractList();
|
this._updateContractList();
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = this.addressToContract[address].name;
|
if(!this.addressToContract[address]) return;
|
||||||
let func = this.addressToContract[address].functions[data.substring(0, 10)];
|
|
||||||
let functionName = func.functionName;
|
|
||||||
|
|
||||||
let decodedParameters = utils.decodeParams(func.abi.inputs, data.substring(10));
|
const name = this.addressToContract[address].name;
|
||||||
|
const func = this.addressToContract[address].functions[data.substring(0, 10)];
|
||||||
|
const functionName = func.functionName;
|
||||||
|
|
||||||
|
const decodedParameters = utils.decodeParams(func.abi.inputs, data.substring(10));
|
||||||
let paramString = "";
|
let paramString = "";
|
||||||
if(func.abi.inputs){
|
if(func.abi.inputs){
|
||||||
func.abi.inputs.forEach((input) => {
|
func.abi.inputs.forEach((input) => {
|
||||||
@ -73,7 +82,6 @@ class ConsoleListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ConsoleListener;
|
module.exports = ConsoleListener;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user