2
0
mirror of synced 2025-02-25 04:25:16 +00:00

Added parseTransaction to interface to detect and parse relevant function and args.

This commit is contained in:
Richard Moore 2018-06-03 17:10:48 -04:00
parent 48c07f6ef6
commit 6c6e031254
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

View File

@ -391,4 +391,23 @@ function Interface(abi) {
utils.defineProperty(this, 'deployFunction', deploy); utils.defineProperty(this, 'deployFunction', deploy);
} }
utils.defineProperty(Interface.prototype, 'parseTransaction', function(tx) {
var sighash = tx.data.substring(0, 10).toLowerCase();
for (var name in this.functions) {
if (name.indexOf('(') === -1) { continue; }
var func = this.functions[name];
if (func.sighash === sighash) {
var result = utils.coder.decode(func.inputs.types, '0x' + tx.data.substring(10));
return {
args: result,
signature: func.signature,
sighash: func.sighash,
parse: func.parseResult,
value: tx.value,
};
}
}
return null;
});
module.exports = Interface; module.exports = Interface;