Displaying status, gas and block number
This commit is contained in:
parent
66353bb8d5
commit
744ec4428e
|
@ -3,6 +3,8 @@ const http = require('http');
|
|||
|
||||
exports.serve = function(ipc, host, port, ws){
|
||||
let commList = {};
|
||||
let transactions = {};
|
||||
let receipts = {};
|
||||
|
||||
let proxy = httpProxy.createProxyServer({
|
||||
target: {
|
||||
|
@ -21,14 +23,23 @@ exports.serve = function(ipc, host, port, ws){
|
|||
let jsonO = JSON.parse(resBody);
|
||||
if(commList[jsonO.id]){
|
||||
commList[jsonO.id].transactionHash = jsonO.result;
|
||||
transactions[jsonO.result] = {commListId: jsonO.id};
|
||||
} else if(receipts[jsonO.id]){
|
||||
commList[receipts[jsonO.id]].blockNumber = jsonO.result.blockNumber;
|
||||
commList[receipts[jsonO.id]].gasUsed = jsonO.result.gasUsed;
|
||||
commList[receipts[jsonO.id]].status = jsonO.result.status;
|
||||
|
||||
if(ipc.connected && !ipc.connecting){
|
||||
ipc.request('log', commList[jsonO.id]);
|
||||
ipc.request('log', commList[receipts[jsonO.id]]);
|
||||
} else {
|
||||
ipc.connecting = true;
|
||||
ipc.connect((err) => {
|
||||
ipc.connecting = false;
|
||||
});
|
||||
}
|
||||
|
||||
delete transactions[commList[receipts[jsonO.id]].transactionHash];
|
||||
delete receipts[jsonO.id];
|
||||
delete commList[jsonO.id];
|
||||
}
|
||||
} catch(e){
|
||||
|
@ -50,6 +61,11 @@ exports.serve = function(ipc, host, port, ws){
|
|||
address: jsonO.params[0].to,
|
||||
data: jsonO.params[0].data
|
||||
};
|
||||
} else if(jsonO.method == "eth_getTransactionReceipt"){
|
||||
if(transactions[jsonO.params[0]]){
|
||||
transactions[jsonO.params[0]].receiptId = jsonO.id;
|
||||
receipts[jsonO.id] = transactions[jsonO.params[0]].commListId;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -38,15 +38,18 @@ class ConsoleListener {
|
|||
this.ipc.on('log', (request) => {
|
||||
if(request.type == 'contract-log'){
|
||||
|
||||
let {address, data, transactionHash} = request;
|
||||
let {address, data, transactionHash, blockNumber, gasUsed, status} = request;
|
||||
if(!this.addressToContract[address]){
|
||||
this._updateContractList();
|
||||
}
|
||||
|
||||
let name = this.addressToContract[address].name;
|
||||
let funcHash = this.addressToContract[address].functions[data.substring(0, 10)];
|
||||
|
||||
this.logger.debug(`${name}.${funcHash} : ${transactionHash}`);
|
||||
|
||||
gasUsed = utils.hexToNumber(gasUsed);
|
||||
blockNumber = utils.hexToNumber(blockNumber);
|
||||
|
||||
this.logger.debug(`${name}.${funcHash} : ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`);
|
||||
} else {
|
||||
this.logger.debug(request);
|
||||
}
|
||||
|
|
|
@ -185,6 +185,10 @@ function getExternalContractUrl(file) {
|
|||
};
|
||||
}
|
||||
|
||||
function hexToNumber(hex){
|
||||
return Web3.utils.hexToNumber(hex);
|
||||
}
|
||||
|
||||
function toChecksumAddress(address) {
|
||||
return Web3.utils.toChecksumAddress(address);
|
||||
}
|
||||
|
@ -253,6 +257,7 @@ module.exports = {
|
|||
httpsGet: httpsGet,
|
||||
httpGetJson: httpGetJson,
|
||||
httpsGetJson: httpsGetJson,
|
||||
hexToNumber: hexToNumber,
|
||||
runCmd: runCmd,
|
||||
cd: cd,
|
||||
sed: sed,
|
||||
|
|
Loading…
Reference in New Issue