const eventRegex = strict ?
/^(event )(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) *\((?<topics>.*?)(?!.+\))/ :
/^(event )?(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) *\((?<topics>.*?)(?!.+\))/;
- const { name, topics } = eventRegex.exec(event).groups;
+ const regexResult = eventRegex.exec(event);
+ if (regexResult === null) { return null; }
+ const { name, topics } = regexResult.groups;
// Drop parameter names and extraneous whitespace, if there are any. Preserves tuple parentheses.
// E.g. "(uint abc, uint256, bool test)[]" --> ['(uint', 'uint256', 'bool)[]']
continue;
}
const lookaheadLine = code.substring(start, end + 1).replaceAll('\n', '');
- try {
- const normalizedEvent = normalizeEvent(lookaheadLine, strict);
+ const normalizedEvent = normalizeEvent(lookaheadLine, strict);
+ if (normalizedEvent !== null) {
originalEvents.push(lookaheadLine);
events.push(normalizedEvent);
}
- catch { }
continue;
}
- try {
- const normalizedEvent = normalizeEvent(line, strict);
+ const normalizedEvent = normalizeEvent(line, strict);
+ if (normalizedEvent !== null) {
originalEvents.push(line);
events.push(normalizedEvent);
}
- catch {
- continue;
- }
}
return events;
}