From: Ardis Lu Date: Sun, 29 Jun 2025 05:37:49 +0000 (-0700) Subject: Distinguish ZKsync blocks using "l1Batch" headers X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=6a575747332be6a824264bc8ae09395266ca851b;p=block-hash-calculator Distinguish ZKsync blocks using "l1Batch" headers Based on a search, only ZKsync-based chains use this "l1Batch" terminology. --- 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'}`;