parsing events output

This commit is contained in:
Marek Kotewicz
2015-02-03 16:16:38 +01:00
parent 1860b3dff9
commit a5909d82eb
6 changed files with 71 additions and 15 deletions

View File

@ -90,14 +90,18 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
}, {});
};
var outputParser = function (event) {
return function (output) {
var result = {
event: utils.extractDisplayName(event.name),
number: output.number
number: output.number,
args: {}
};
if (!output.topic) {
return result;
}
var indexedOutputs = filterInputs(event.inputs, true);
var indexedData = "0x" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join("");
@ -112,8 +116,20 @@ var outputParser = function (event) {
};
};
module.exports = {
inputParser: inputParser,
outputParser: outputParser
var getMatchingEvent = function (events, payload) {
for (var i = 0; i < events.length; i++) {
var signature = abi.eventSignatureFromAscii(events[i].name);
if (signature === payload.topic[0]) {
return events[i];
}
}
return undefined;
};
module.exports = {
inputParser: inputParser,
outputParser: outputParser,
getMatchingEvent: getMatchingEvent
};