From 6a575747332be6a824264bc8ae09395266ca851b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 28 Jun 2025 22:37:49 -0700 Subject: [PATCH] Distinguish ZKsync blocks using "l1Batch" headers Based on a search, only ZKsync-based chains use this "l1Batch" terminology. --- index.html | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 9c6a79e..f69ac2e 100644 --- a/index.html +++ b/index.html @@ -78,19 +78,10 @@ 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'}`; -- 2.47.3