Skip to content

Commit

Permalink
Merge pull request #492 from sudoblockio/bugs
Browse files Browse the repository at this point in the history
chore: event log input parsing bug
  • Loading branch information
athoifss authored Sep 17, 2024
2 parents 79067f1 + 7c9fcbd commit d9934e4
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/libs/event-log-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,40 @@ function getEventsByName(ABI) {


function getParsedLog(log, eventsByName) {
const indexed = JSON.parse(log.indexed);
const data = JSON.parse(log.data); // values for non indexed field
const indexed = JSON.parse(log.indexed); // values for indexed field

const eventName = indexed[0].split("(")[0];
const paramValues = indexed.splice(1);
const paramValues = indexed.splice(1); //indexed


const logSignature = eventsByName[eventName.toLowerCase()];
const inputs = logSignature.inputs;


const params = [];
const parsed = {};

const params = logSignature?.inputs?.map((input, index) => ({ ...input, value: paramValues[index] })) || []
let isFinishedIndexed = false;
let i = 0;
while (!isFinishedIndexed) {
const input = inputs[i];
const value = paramValues[i];
params.push({ ...input, value })
if (!value) {
isFinishedIndexed = true;
} else {
i++;
}
}

let counter = 0;
for (let x = i; x < inputs.length; x++) {
const input = inputs[x];
const value = data[counter++]
params.push({ ...input, value })
}

params.forEach(item => {
if (item.value) {
let value = item.value;
Expand All @@ -38,6 +62,7 @@ function getParsedLog(log, eventsByName) {
}
})


return parsed;
}

Expand Down

0 comments on commit d9934e4

Please sign in to comment.