Formatting input parameters
This commit is contained in:
parent
610b6de008
commit
87a49900b4
|
@ -18,12 +18,18 @@ class ConsoleListener {
|
||||||
let funcSignatures = {};
|
let funcSignatures = {};
|
||||||
contract.abiDefinition
|
contract.abiDefinition
|
||||||
.filter(func => func.type == "function")
|
.filter(func => func.type == "function")
|
||||||
.map(func => func.name +
|
.map(func => {
|
||||||
'(' +
|
return {
|
||||||
(func.inputs ? func.inputs.map(input => input.type).join(',') : '') +
|
name: func.name +
|
||||||
')')
|
'(' +
|
||||||
|
(func.inputs ? func.inputs.map(input => input.type).join(',') : '') +
|
||||||
|
')',
|
||||||
|
abi: func,
|
||||||
|
functionName: func.name
|
||||||
|
};
|
||||||
|
})
|
||||||
.forEach(func => {
|
.forEach(func => {
|
||||||
funcSignatures[utils.sha3(func).substring(0, 10)] = func;
|
funcSignatures[utils.sha3(func.name).substring(0, 10)] = func;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addressToContract[address] = {
|
this.addressToContract[address] = {
|
||||||
|
@ -44,12 +50,23 @@ class ConsoleListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = this.addressToContract[address].name;
|
let name = this.addressToContract[address].name;
|
||||||
let funcHash = this.addressToContract[address].functions[data.substring(0, 10)];
|
let func = this.addressToContract[address].functions[data.substring(0, 10)];
|
||||||
|
let functionName = func.functionName;
|
||||||
|
|
||||||
|
let decodedParameters = utils.decodeParams(func.abi.inputs, data.substring(10));
|
||||||
|
let paramString = "";
|
||||||
|
if(func.abi.inputs){
|
||||||
|
func.abi.inputs.forEach((input) => {
|
||||||
|
let quote = input.type.indexOf("int") == -1 ? '"' : '';
|
||||||
|
paramString += quote + decodedParameters[input.name] + quote + ", ";
|
||||||
|
});
|
||||||
|
paramString = paramString.substring(0, paramString.length - 2);
|
||||||
|
}
|
||||||
|
|
||||||
gasUsed = utils.hexToNumber(gasUsed);
|
gasUsed = utils.hexToNumber(gasUsed);
|
||||||
blockNumber = utils.hexToNumber(blockNumber);
|
blockNumber = utils.hexToNumber(blockNumber);
|
||||||
|
|
||||||
this.logger.debug(`${name}.${funcHash} : ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`);
|
this.logger.debug(`${name}.${functionName}(${paramString}) : ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`);
|
||||||
} else {
|
} else {
|
||||||
this.logger.debug(request);
|
this.logger.debug(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ let shelljs = require('shelljs');
|
||||||
var tar = require('tar');
|
var tar = require('tar');
|
||||||
var propose = require('propose');
|
var propose = require('propose');
|
||||||
var Web3 = require('web3');
|
var Web3 = require('web3');
|
||||||
|
var Web3EthAbi = require('web3-eth-abi');
|
||||||
const constants = require('../constants');
|
const constants = require('../constants');
|
||||||
|
|
||||||
//let fs = require('../core/fs.js');
|
//let fs = require('../core/fs.js');
|
||||||
|
@ -189,6 +190,10 @@ function hexToNumber(hex){
|
||||||
return Web3.utils.hexToNumber(hex);
|
return Web3.utils.hexToNumber(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeParams(typesArray, hexString){
|
||||||
|
return Web3EthAbi.decodeParameters(typesArray, hexString);
|
||||||
|
}
|
||||||
|
|
||||||
function toChecksumAddress(address) {
|
function toChecksumAddress(address) {
|
||||||
return Web3.utils.toChecksumAddress(address);
|
return Web3.utils.toChecksumAddress(address);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +263,7 @@ module.exports = {
|
||||||
httpGetJson: httpGetJson,
|
httpGetJson: httpGetJson,
|
||||||
httpsGetJson: httpsGetJson,
|
httpsGetJson: httpsGetJson,
|
||||||
hexToNumber: hexToNumber,
|
hexToNumber: hexToNumber,
|
||||||
|
decodeParams: decodeParams,
|
||||||
runCmd: runCmd,
|
runCmd: runCmd,
|
||||||
cd: cd,
|
cd: cd,
|
||||||
sed: sed,
|
sed: sed,
|
||||||
|
|
Loading…
Reference in New Issue