]> git.ardis.lu - event-hashes/commitdiff
Parse multi-line event definitions
authorArdis Lu <ardisglu@gmail.com>
Sun, 11 Feb 2024 01:20:02 +0000 (17:20 -0800)
committerArdis Lu <ardisglu@gmail.com>
Sun, 11 Feb 2024 01:20:02 +0000 (17:20 -0800)
README.md
index.html

index 1bbca9ed952a96c596e9c59f4953501dc82482d0..2a872b79bd0a506fecfb2ab42626b065e837387c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,7 +5,6 @@ This is a minimal web utility to calculate the `keccak256` hashes of the normali
 > [!WARNING]<br>
 > **Known issues:**
 > - This tool won't work with [user-defined value types](https://docs.soliditylang.org/en/latest/types.html#user-defined-value-types). For events that include these types, you must manually convert the user-defined value type into its equivalent primitive type.
-> - This tool won't work with multi-line event definitions. For events that span multiple lines, you must manually collapse the definition into one line.
 
 ## Example
 
index 0197bf8633228fafa5d4829e7a8a0d4e51d50999..2707025ba069774dbf03e3757e6ed8ecaaa808de 100644 (file)
           strict = true;
           continue;
         }
+        // Basic lookahead for event definitions that span multiple lines
+        if ((line.match(/\(/g)?.length ?? 0) > (line.match(/\)/g)?.length ?? 0)) {
+          const start = code.indexOf(line);
+          const end = code.indexOf(')', start);
+          const lookaheadLine = code.substring(start, end + 1).replaceAll('\n', '');
+          try {
+            const normalizedEvent = normalizeEvent(lookaheadLine, strict);
+            events.add(normalizedEvent);
+          }
+          catch { }
+          continue;
+        }
         try {
           const normalizedEvent = normalizeEvent(line, strict);
           events.add(normalizedEvent);
This page took 0.043131 seconds and 4 git commands to generate.