]> git.ardis.lu - block-hash-calculator/commitdiff
Distinguish ZKsync blocks using "l1Batch" headers
authorArdis Lu <ardisglu@gmail.com>
Sun, 29 Jun 2025 05:37:49 +0000 (22:37 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 29 Jun 2025 05:37:49 +0000 (22:37 -0700)
Based on a search, only ZKsync-based chains use this "l1Batch" terminology.

index.html

index 9c6a79e0e6c058e7c1fcd26e4c9c1f6592d86028..f69ac2e8290dc8573d51a8357f6a15b4160efb48 100644 (file)
 
       const block = response?.result;
       if (block !== undefined) {
-        const { header, encoded, hash } = calculate(block);
-
-        if (hash !== block.hash) { // TODO: use a better heuristic to determine if it's ZKsync Era
-          const { header, encoded, hash } = calculateZkSync(block);
-          document.querySelector('#out-header').textContent = `[\n  ${header.join(',\n  ')}\n]`;
-          document.querySelector('#out-encoded').textContent = encoded;
-          document.querySelector('#out-hash').textContent = hash;
-        }
-        else {
-          document.querySelector('#out-header').textContent = `[\n  ${header.join(',\n  ')}\n]`;
-          document.querySelector('#out-encoded').textContent = encoded;
-          document.querySelector('#out-hash').textContent = hash;
-        }
+        const { header, encoded, hash } = block?.l1BatchTimestamp && block?.l1BatchNumber ? calculateZkSync(block) : calculate(block);
+        document.querySelector('#out-header').textContent = `[\n  ${header.join(',\n  ')}\n]`;
+        document.querySelector('#out-encoded').textContent = encoded;
+        document.querySelector('#out-hash').textContent = hash;
       }
       else {
         document.querySelector('#out-header').textContent = `Unable to retrieve block header. Error: ${response?.message ?? 'Other'}`;
This page took 0.042908 seconds and 4 git commands to generate.