From 1e4adf6c1ca263513bb48f94a6fb415620408071 Mon Sep 17 00:00:00 2001 From: Mati OS Date: Mon, 14 Sep 2026 20:11:37 -0300 Subject: [PATCH 1/6] feat(i18n): add zcash block page strings and tooltips --- src/locales/en/tooltips.json | 21 ++++++++++++ src/locales/en/zcash.json | 58 +++++++++++++++++++++++++++++++++ src/locales/es/tooltips.json | 21 ++++++++++++ src/locales/es/zcash.json | 58 +++++++++++++++++++++++++++++++++ src/locales/ja/tooltips.json | 21 ++++++++++++ src/locales/ja/zcash.json | 58 +++++++++++++++++++++++++++++++++ src/locales/pt-BR/tooltips.json | 21 ++++++++++++ src/locales/pt-BR/zcash.json | 58 +++++++++++++++++++++++++++++++++ src/locales/zh/tooltips.json | 21 ++++++++++++ src/locales/zh/zcash.json | 58 +++++++++++++++++++++++++++++++++ 10 files changed, 395 insertions(+) diff --git a/src/locales/en/tooltips.json b/src/locales/en/tooltips.json index 55f6273f..ad226cba 100644 --- a/src/locales/en/tooltips.json +++ b/src/locales/en/tooltips.json @@ -161,6 +161,27 @@ "orchard": "Shielded pool introduced with NU5 in 2022, using Halo 2 proofs that need no trusted setup.", "lockbox": "Deferred development fund: part of every block reward since NU6, held by the protocol until its use is decided.", "ironwood": "Shielded pool introduced with the NU6.3 (Ironwood) network upgrade." + }, + "block": { + "hash": "The unique identifier of this block, derived from its header.", + "confirmations": "Blocks mined on top of this one. More confirmations means the block is harder to reverse.", + "reward": "Total value of the coinbase outputs: the miner's subsidy plus fees, and funding streams paid to transparent addresses.", + "coinbaseOutputs": "Transparent outputs created by the coinbase transaction, such as the miner reward and development fund payments.", + "transactions": "Transactions in this block. Chips count the transactions that use each shielded pool.", + "transparentOutput": "Sum of all transparent outputs in this block. Shielded amounts are not publicly visible.", + "difficulty": "How hard it was to find a valid Equihash solution for this block.", + "size": "Size of the serialized block, including shielded proofs.", + "previousBlock": "The block this one builds on.", + "nextBlock": "The block built on top of this one, if any.", + "merkleRoot": "Root of the Merkle tree of all transaction IDs in this block.", + "blockCommitments": "Commitment to the chain history and authorizing data, required since NU5.", + "finalSaplingRoot": "Root of the Sapling note commitment tree after this block.", + "finalOrchardRoot": "Root of the Orchard note commitment tree after this block. Present on blocks after NU5.", + "version": "Block format version.", + "bits": "Compact encoding of the proof-of-work target.", + "nonce": "32-byte value miners vary while searching for a valid Equihash solution.", + "solution": "The Equihash proof-of-work solution for this block.", + "trees": "Number of notes committed to each shielded pool's note commitment tree as of this block." } }, "network": { diff --git a/src/locales/en/zcash.json b/src/locales/en/zcash.json index 24e194b4..4e6b2f2b 100644 --- a/src/locales/en/zcash.json +++ b/src/locales/en/zcash.json @@ -43,5 +43,63 @@ "shielded": "Fully shielded", "mixed": "Mixed" } + }, + "breadcrumb": { + "home": "Home", + "blocks": "Blocks", + "block": "Block #{{height}}" + }, + "blocksPage": { + "title": "{{network}} Blocks", + "showingLatest": "Showing the {{count}} most recent blocks", + "showingRange": "Showing blocks {{from}} – {{to}}", + "height": "Height", + "hash": "Hash", + "time": "Time", + "txns": "Txns", + "size": "Size", + "latest": "Latest", + "latestTitle": "Go to the latest blocks", + "newer": "← Newer", + "newerTitle": "View newer blocks", + "older": "Older →", + "olderTitle": "View older blocks", + "loadError": "Couldn't load blocks: {{message}}" + }, + "block": { + "title": "Block", + "loading": "Loading block data...", + "loadError": "Couldn't load this block: {{message}}", + "notFound": "Block not found", + "previousBlock": "Previous block", + "nextBlock": "Next block", + "confirmations": "{{count}} Confirmations", + "hash": "Block Hash:", + "reward": "Block Reward:", + "coinbaseOutputs": "Coinbase Outputs:", + "noAddress": "Non-standard script", + "transactions": "Transactions:", + "txCount": "{{count}} transactions", + "poolTxCount": "{{count}} {{pool}}", + "transparentOutput": "Transparent Output:", + "difficulty": "Difficulty:", + "size": "Size:", + "previousBlockLabel": "Previous Block:", + "nextBlockLabel": "Next Block:", + "showDetails": "+ Show More Details", + "hideDetails": "− Hide More Details", + "merkleRoot": "Merkle Root:", + "blockCommitments": "Block Commitments:", + "finalSaplingRoot": "Final Sapling Root:", + "finalOrchardRoot": "Final Orchard Root:", + "version": "Version:", + "bits": "Bits:", + "nonce": "Nonce:", + "solution": "Equihash Solution:", + "trees": "Note Commitment Trees:", + "treeSize": "{{pool}} {{size}}", + "valuePoolsTitle": "Value Pools After This Block", + "showTransactions": "+ Show Transactions ({{count}})", + "hideTransactions": "− Hide Transactions ({{count}})" } } diff --git a/src/locales/es/tooltips.json b/src/locales/es/tooltips.json index 081bfe0b..4097de05 100644 --- a/src/locales/es/tooltips.json +++ b/src/locales/es/tooltips.json @@ -161,6 +161,27 @@ "orchard": "Pool blindado introducido con NU5 en 2022, con pruebas Halo 2 que no requieren configuración de confianza.", "lockbox": "Fondo de desarrollo diferido: parte de cada recompensa de bloque desde NU6, retenida por el protocolo hasta que se decida su uso.", "ironwood": "Pool blindado introducido con la actualización de red NU6.3 (Ironwood)." + }, + "block": { + "hash": "Identificador único de este bloque, derivado de su encabezado.", + "confirmations": "Bloques minados sobre este. Más confirmaciones significa que el bloque es más difícil de revertir.", + "reward": "Valor total de las salidas coinbase: el subsidio del minero más las comisiones y los flujos de financiamiento pagados a direcciones transparentes.", + "coinbaseOutputs": "Salidas transparentes creadas por la transacción coinbase, como la recompensa del minero y los pagos al fondo de desarrollo.", + "transactions": "Transacciones en este bloque. Las etiquetas cuentan las transacciones que usan cada pool blindado.", + "transparentOutput": "Suma de todas las salidas transparentes de este bloque. Los montos blindados no son públicos.", + "difficulty": "Qué tan difícil fue encontrar una solución Equihash válida para este bloque.", + "size": "Tamaño del bloque serializado, incluidas las pruebas blindadas.", + "previousBlock": "El bloque sobre el que se construye este.", + "nextBlock": "El bloque construido sobre este, si existe.", + "merkleRoot": "Raíz del árbol Merkle de todos los IDs de transacción de este bloque.", + "blockCommitments": "Compromiso con el historial de la cadena y los datos de autorización, requerido desde NU5.", + "finalSaplingRoot": "Raíz del árbol de compromisos de notas de Sapling después de este bloque.", + "finalOrchardRoot": "Raíz del árbol de compromisos de notas de Orchard después de este bloque. Presente en bloques posteriores a NU5.", + "version": "Versión del formato del bloque.", + "bits": "Codificación compacta del objetivo de prueba de trabajo.", + "nonce": "Valor de 32 bytes que los mineros varían al buscar una solución Equihash válida.", + "solution": "La solución de prueba de trabajo Equihash de este bloque.", + "trees": "Cantidad de notas comprometidas en el árbol de compromisos de cada pool blindado hasta este bloque." } }, "network": { diff --git a/src/locales/es/zcash.json b/src/locales/es/zcash.json index da27380e..f14ffcd7 100644 --- a/src/locales/es/zcash.json +++ b/src/locales/es/zcash.json @@ -43,5 +43,63 @@ "shielded": "Totalmente blindada", "mixed": "Mixta" } + }, + "breadcrumb": { + "home": "Inicio", + "blocks": "Bloques", + "block": "Bloque #{{height}}" + }, + "blocksPage": { + "title": "Bloques de {{network}}", + "showingLatest": "Mostrando los {{count}} bloques más recientes", + "showingRange": "Mostrando bloques {{from}} – {{to}}", + "height": "Altura", + "hash": "Hash", + "time": "Tiempo", + "txns": "Txs", + "size": "Tamaño", + "latest": "Últimos", + "latestTitle": "Ir a los últimos bloques", + "newer": "← Más recientes", + "newerTitle": "Ver bloques más recientes", + "older": "Más antiguos →", + "olderTitle": "Ver bloques más antiguos", + "loadError": "No se pudieron cargar los bloques: {{message}}" + }, + "block": { + "title": "Bloque", + "loading": "Cargando datos del bloque...", + "loadError": "No se pudo cargar este bloque: {{message}}", + "notFound": "Bloque no encontrado", + "previousBlock": "Bloque anterior", + "nextBlock": "Bloque siguiente", + "confirmations": "{{count}} confirmaciones", + "hash": "Hash del bloque:", + "reward": "Recompensa del bloque:", + "coinbaseOutputs": "Salidas coinbase:", + "noAddress": "Script no estándar", + "transactions": "Transacciones:", + "txCount": "{{count}} transacciones", + "poolTxCount": "{{count}} {{pool}}", + "transparentOutput": "Salida transparente:", + "difficulty": "Dificultad:", + "size": "Tamaño:", + "previousBlockLabel": "Bloque anterior:", + "nextBlockLabel": "Bloque siguiente:", + "showDetails": "+ Mostrar más detalles", + "hideDetails": "− Ocultar detalles", + "merkleRoot": "Raíz Merkle:", + "blockCommitments": "Compromisos del bloque:", + "finalSaplingRoot": "Raíz final de Sapling:", + "finalOrchardRoot": "Raíz final de Orchard:", + "version": "Versión:", + "bits": "Bits:", + "nonce": "Nonce:", + "solution": "Solución Equihash:", + "trees": "Árboles de compromisos de notas:", + "treeSize": "{{pool}} {{size}}", + "valuePoolsTitle": "Pools de valor después de este bloque", + "showTransactions": "+ Mostrar transacciones ({{count}})", + "hideTransactions": "− Ocultar transacciones ({{count}})" } } diff --git a/src/locales/ja/tooltips.json b/src/locales/ja/tooltips.json index 37f51cd2..5875807d 100644 --- a/src/locales/ja/tooltips.json +++ b/src/locales/ja/tooltips.json @@ -161,6 +161,27 @@ "orchard": "2022年のNU5で導入されたシールドプール。信頼されたセットアップが不要なHalo 2証明を使用します。", "lockbox": "繰り延べ開発資金:NU6以降、各ブロック報酬の一部が使途決定までプロトコルによって保管されます。", "ironwood": "NU6.3(Ironwood)ネットワークアップグレードで導入されたシールドプール。" + }, + "block": { + "hash": "ヘッダーから導出される、このブロックの一意の識別子。", + "confirmations": "このブロックの上にマイニングされたブロック数。承認数が多いほど、ブロックは覆りにくくなります。", + "reward": "コインベース出力の合計額:マイナーの補助金と手数料、およびトランスペアレントアドレスに支払われる資金ストリーム。", + "coinbaseOutputs": "コインベーストランザクションが作成したトランスペアレント出力(マイナー報酬や開発資金への支払いなど)。", + "transactions": "このブロック内のトランザクション。チップは各シールドプールを使用するトランザクション数を示します。", + "transparentOutput": "このブロック内のすべてのトランスペアレント出力の合計。シールドされた金額は公開されません。", + "difficulty": "このブロックの有効なEquihashソリューションを見つける難しさ。", + "size": "シールド証明を含む、シリアライズされたブロックのサイズ。", + "previousBlock": "このブロックが基づいているブロック。", + "nextBlock": "このブロックの上に構築されたブロック(存在する場合)。", + "merkleRoot": "このブロック内のすべてのトランザクションIDのマークルツリーのルート。", + "blockCommitments": "NU5以降に必要な、チェーン履歴と承認データへのコミットメント。", + "finalSaplingRoot": "このブロック後のSaplingノートコミットメントツリーのルート。", + "finalOrchardRoot": "このブロック後のOrchardノートコミットメントツリーのルート。NU5以降のブロックに存在します。", + "version": "ブロックフォーマットのバージョン。", + "bits": "プルーフ・オブ・ワークのターゲットのコンパクトな表現。", + "nonce": "マイナーが有効なEquihashソリューションを探す際に変化させる32バイトの値。", + "solution": "このブロックのEquihashプルーフ・オブ・ワークのソリューション。", + "trees": "このブロック時点で各シールドプールのノートコミットメントツリーにコミットされたノート数。" } }, "network": { diff --git a/src/locales/ja/zcash.json b/src/locales/ja/zcash.json index e9b18d88..94d64c0e 100644 --- a/src/locales/ja/zcash.json +++ b/src/locales/ja/zcash.json @@ -43,5 +43,63 @@ "shielded": "完全シールド", "mixed": "混合" } + }, + "breadcrumb": { + "home": "ホーム", + "blocks": "ブロック", + "block": "ブロック #{{height}}" + }, + "blocksPage": { + "title": "{{network}} のブロック", + "showingLatest": "最新 {{count}} 件のブロックを表示", + "showingRange": "ブロック {{from}} – {{to}} を表示", + "height": "高さ", + "hash": "ハッシュ", + "time": "時間", + "txns": "Tx数", + "size": "サイズ", + "latest": "最新", + "latestTitle": "最新のブロックへ移動", + "newer": "← 新しい", + "newerTitle": "新しいブロックを表示", + "older": "古い →", + "olderTitle": "古いブロックを表示", + "loadError": "ブロックを読み込めませんでした: {{message}}" + }, + "block": { + "title": "ブロック", + "loading": "ブロックデータを読み込み中...", + "loadError": "このブロックを読み込めませんでした: {{message}}", + "notFound": "ブロックが見つかりません", + "previousBlock": "前のブロック", + "nextBlock": "次のブロック", + "confirmations": "{{count}} 承認", + "hash": "ブロックハッシュ:", + "reward": "ブロック報酬:", + "coinbaseOutputs": "コインベース出力:", + "noAddress": "非標準スクリプト", + "transactions": "トランザクション:", + "txCount": "{{count}} 件のトランザクション", + "poolTxCount": "{{pool}} {{count}} 件", + "transparentOutput": "トランスペアレント出力:", + "difficulty": "難易度:", + "size": "サイズ:", + "previousBlockLabel": "前のブロック:", + "nextBlockLabel": "次のブロック:", + "showDetails": "+ 詳細を表示", + "hideDetails": "− 詳細を隠す", + "merkleRoot": "マークルルート:", + "blockCommitments": "ブロックコミットメント:", + "finalSaplingRoot": "最終 Sapling ルート:", + "finalOrchardRoot": "最終 Orchard ルート:", + "version": "バージョン:", + "bits": "Bits:", + "nonce": "ノンス:", + "solution": "Equihash ソリューション:", + "trees": "ノートコミットメントツリー:", + "treeSize": "{{pool}} {{size}}", + "valuePoolsTitle": "このブロック時点のバリュープール", + "showTransactions": "+ トランザクションを表示 ({{count}})", + "hideTransactions": "− トランザクションを隠す ({{count}})" } } diff --git a/src/locales/pt-BR/tooltips.json b/src/locales/pt-BR/tooltips.json index 68242f78..5fbfa73e 100644 --- a/src/locales/pt-BR/tooltips.json +++ b/src/locales/pt-BR/tooltips.json @@ -161,6 +161,27 @@ "orchard": "Pool blindado introduzido com o NU5 em 2022, usando provas Halo 2 que dispensam configuração confiável.", "lockbox": "Fundo de desenvolvimento diferido: parte de cada recompensa de bloco desde o NU6, retida pelo protocolo até que seu uso seja decidido.", "ironwood": "Pool blindado introduzido com a atualização de rede NU6.3 (Ironwood)." + }, + "block": { + "hash": "Identificador único deste bloco, derivado do seu cabeçalho.", + "confirmations": "Blocos minerados sobre este. Mais confirmações significa que o bloco é mais difícil de reverter.", + "reward": "Valor total das saídas coinbase: o subsídio do minerador mais as taxas e os fluxos de financiamento pagos a endereços transparentes.", + "coinbaseOutputs": "Saídas transparentes criadas pela transação coinbase, como a recompensa do minerador e os pagamentos ao fundo de desenvolvimento.", + "transactions": "Transações neste bloco. As etiquetas contam as transações que usam cada pool blindado.", + "transparentOutput": "Soma de todas as saídas transparentes deste bloco. Valores blindados não são públicos.", + "difficulty": "Quão difícil foi encontrar uma solução Equihash válida para este bloco.", + "size": "Tamanho do bloco serializado, incluindo as provas blindadas.", + "previousBlock": "O bloco sobre o qual este é construído.", + "nextBlock": "O bloco construído sobre este, se houver.", + "merkleRoot": "Raiz da árvore Merkle de todos os IDs de transação deste bloco.", + "blockCommitments": "Compromisso com o histórico da cadeia e os dados de autorização, exigido desde o NU5.", + "finalSaplingRoot": "Raiz da árvore de compromissos de notas do Sapling após este bloco.", + "finalOrchardRoot": "Raiz da árvore de compromissos de notas do Orchard após este bloco. Presente em blocos posteriores ao NU5.", + "version": "Versão do formato do bloco.", + "bits": "Codificação compacta do alvo da prova de trabalho.", + "nonce": "Valor de 32 bytes que os mineradores variam ao buscar uma solução Equihash válida.", + "solution": "A solução de prova de trabalho Equihash deste bloco.", + "trees": "Número de notas comprometidas na árvore de compromissos de cada pool blindado até este bloco." } }, "network": { diff --git a/src/locales/pt-BR/zcash.json b/src/locales/pt-BR/zcash.json index f89d893c..52b0f298 100644 --- a/src/locales/pt-BR/zcash.json +++ b/src/locales/pt-BR/zcash.json @@ -43,5 +43,63 @@ "shielded": "Totalmente blindada", "mixed": "Mista" } + }, + "breadcrumb": { + "home": "Início", + "blocks": "Blocos", + "block": "Bloco #{{height}}" + }, + "blocksPage": { + "title": "Blocos de {{network}}", + "showingLatest": "Mostrando os {{count}} blocos mais recentes", + "showingRange": "Mostrando blocos {{from}} – {{to}}", + "height": "Altura", + "hash": "Hash", + "time": "Tempo", + "txns": "Txs", + "size": "Tamanho", + "latest": "Mais recentes", + "latestTitle": "Ir para os blocos mais recentes", + "newer": "← Mais novos", + "newerTitle": "Ver blocos mais novos", + "older": "Mais antigos →", + "olderTitle": "Ver blocos mais antigos", + "loadError": "Não foi possível carregar os blocos: {{message}}" + }, + "block": { + "title": "Bloco", + "loading": "Carregando dados do bloco...", + "loadError": "Não foi possível carregar este bloco: {{message}}", + "notFound": "Bloco não encontrado", + "previousBlock": "Bloco anterior", + "nextBlock": "Próximo bloco", + "confirmations": "{{count}} confirmações", + "hash": "Hash do bloco:", + "reward": "Recompensa do bloco:", + "coinbaseOutputs": "Saídas coinbase:", + "noAddress": "Script não padrão", + "transactions": "Transações:", + "txCount": "{{count}} transações", + "poolTxCount": "{{count}} {{pool}}", + "transparentOutput": "Saída transparente:", + "difficulty": "Dificuldade:", + "size": "Tamanho:", + "previousBlockLabel": "Bloco anterior:", + "nextBlockLabel": "Próximo bloco:", + "showDetails": "+ Mostrar mais detalhes", + "hideDetails": "− Ocultar detalhes", + "merkleRoot": "Raiz Merkle:", + "blockCommitments": "Compromissos do bloco:", + "finalSaplingRoot": "Raiz final do Sapling:", + "finalOrchardRoot": "Raiz final do Orchard:", + "version": "Versão:", + "bits": "Bits:", + "nonce": "Nonce:", + "solution": "Solução Equihash:", + "trees": "Árvores de compromissos de notas:", + "treeSize": "{{pool}} {{size}}", + "valuePoolsTitle": "Pools de valor após este bloco", + "showTransactions": "+ Mostrar transações ({{count}})", + "hideTransactions": "− Ocultar transações ({{count}})" } } diff --git a/src/locales/zh/tooltips.json b/src/locales/zh/tooltips.json index 239836c8..5c62967c 100644 --- a/src/locales/zh/tooltips.json +++ b/src/locales/zh/tooltips.json @@ -161,6 +161,27 @@ "orchard": "随 2022 年 NU5 升级引入的屏蔽池,使用无需可信设置的 Halo 2 证明。", "lockbox": "递延开发基金:自 NU6 起每个区块奖励的一部分,由协议保管,直至决定其用途。", "ironwood": "随 NU6.3(Ironwood)网络升级引入的屏蔽池。" + }, + "block": { + "hash": "由区块头派生的该区块唯一标识符。", + "confirmations": "在此区块之上挖出的区块数。确认越多,区块越难被撤销。", + "reward": "Coinbase 输出总额:矿工补贴加手续费,以及支付给透明地址的资金流。", + "coinbaseOutputs": "Coinbase 交易创建的透明输出,例如矿工奖励和开发基金付款。", + "transactions": "此区块中的交易。标签统计使用各屏蔽池的交易数量。", + "transparentOutput": "此区块中所有透明输出的总和。屏蔽金额不公开。", + "difficulty": "为此区块找到有效 Equihash 解的难度。", + "size": "序列化区块的大小,包括屏蔽证明。", + "previousBlock": "此区块所基于的区块。", + "nextBlock": "构建在此区块之上的区块(如有)。", + "merkleRoot": "此区块中所有交易 ID 的默克尔树根。", + "blockCommitments": "对链历史和授权数据的承诺,自 NU5 起必需。", + "finalSaplingRoot": "此区块之后 Sapling 票据承诺树的根。", + "finalOrchardRoot": "此区块之后 Orchard 票据承诺树的根。仅存在于 NU5 之后的区块。", + "version": "区块格式版本。", + "bits": "工作量证明目标的紧凑编码。", + "nonce": "矿工在寻找有效 Equihash 解时改变的 32 字节值。", + "solution": "此区块的 Equihash 工作量证明解。", + "trees": "截至此区块,各屏蔽池票据承诺树中已提交的票据数量。" } }, "network": { diff --git a/src/locales/zh/zcash.json b/src/locales/zh/zcash.json index 48cef60e..d007fdc5 100644 --- a/src/locales/zh/zcash.json +++ b/src/locales/zh/zcash.json @@ -43,5 +43,63 @@ "shielded": "完全屏蔽", "mixed": "混合" } + }, + "breadcrumb": { + "home": "首页", + "blocks": "区块", + "block": "区块 #{{height}}" + }, + "blocksPage": { + "title": "{{network}} 区块", + "showingLatest": "显示最近 {{count}} 个区块", + "showingRange": "显示区块 {{from}} – {{to}}", + "height": "高度", + "hash": "哈希", + "time": "时间", + "txns": "交易数", + "size": "大小", + "latest": "最新", + "latestTitle": "前往最新区块", + "newer": "← 较新", + "newerTitle": "查看较新的区块", + "older": "较旧 →", + "olderTitle": "查看较旧的区块", + "loadError": "无法加载区块: {{message}}" + }, + "block": { + "title": "区块", + "loading": "正在加载区块数据...", + "loadError": "无法加载此区块: {{message}}", + "notFound": "未找到区块", + "previousBlock": "上一个区块", + "nextBlock": "下一个区块", + "confirmations": "{{count}} 个确认", + "hash": "区块哈希:", + "reward": "区块奖励:", + "coinbaseOutputs": "Coinbase 输出:", + "noAddress": "非标准脚本", + "transactions": "交易:", + "txCount": "{{count}} 笔交易", + "poolTxCount": "{{pool}} {{count}} 笔", + "transparentOutput": "透明输出:", + "difficulty": "难度:", + "size": "大小:", + "previousBlockLabel": "上一个区块:", + "nextBlockLabel": "下一个区块:", + "showDetails": "+ 显示更多详情", + "hideDetails": "− 隐藏详情", + "merkleRoot": "默克尔根:", + "blockCommitments": "区块承诺:", + "finalSaplingRoot": "最终 Sapling 根:", + "finalOrchardRoot": "最终 Orchard 根:", + "version": "版本:", + "bits": "Bits:", + "nonce": "Nonce:", + "solution": "Equihash 解:", + "trees": "票据承诺树:", + "treeSize": "{{pool}} {{size}}", + "valuePoolsTitle": "此区块后的价值池", + "showTransactions": "+ 显示交易 ({{count}})", + "hideTransactions": "− 隐藏交易 ({{count}})" } } From b603bc3b963ef1a4c312c1041e8d25895b3f4efa Mon Sep 17 00:00:00 2001 From: Mati OS Date: Mon, 14 Sep 2026 20:11:38 -0300 Subject: [PATCH 2/6] feat(zcash): add blocks list and block detail pages Block details come from a single getblock call and surface Zcash header fields (hex nonce, Equihash solution, commitment roots, note commitment tree sizes), coinbase outputs, per-pool shielded transaction counts and value pools after the block. --- src/App.tsx | 6 + src/components/LazyComponents.tsx | 6 + .../pages/zcash/ZcashBlockDisplay.tsx | 399 ++++++++++++++++++ src/components/pages/zcash/ZcashBlockPage.tsx | 125 ++++++ .../pages/zcash/ZcashBlocksPage.tsx | 227 ++++++++++ .../pages/zcash/ZcashValuePools.tsx | 25 +- src/components/pages/zcash/index.tsx | 6 +- src/config/zcashConstants.ts | 3 + src/styles/components.css | 59 +++ 9 files changed, 845 insertions(+), 11 deletions(-) create mode 100644 src/components/pages/zcash/ZcashBlockDisplay.tsx create mode 100644 src/components/pages/zcash/ZcashBlockPage.tsx create mode 100644 src/components/pages/zcash/ZcashBlocksPage.tsx diff --git a/src/App.tsx b/src/App.tsx index b6294f31..018d08e9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,6 +56,8 @@ import { LazyTokenDetails, LazyTx, LazyTxs, + LazyZcashBlock, + LazyZcashBlocks, LazyZcashNetwork, preloadAllRoutes, } from "./components/LazyComponents"; @@ -162,8 +164,12 @@ function AppContent() { } /> {/* Zcash Mainnet routes (must come before :networkId catch-all) */} } /> + } /> + } /> {/* Zcash Testnet routes */} } /> + } /> + } /> {/* Solana Mainnet routes (must come before :networkId catch-all) */} } /> } /> diff --git a/src/components/LazyComponents.tsx b/src/components/LazyComponents.tsx index 80b70255..0a5bf25a 100644 --- a/src/components/LazyComponents.tsx +++ b/src/components/LazyComponents.tsx @@ -22,6 +22,8 @@ const BitcoinMempoolPage = lazy(() => import("./pages/bitcoin/BitcoinMempoolPage // Lazy load page components - Zcash const ZcashNetwork = lazy(() => import("./pages/zcash")); +const ZcashBlocksPage = lazy(() => import("./pages/zcash/ZcashBlocksPage")); +const ZcashBlockPage = lazy(() => import("./pages/zcash/ZcashBlockPage")); // Lazy load page components - Solana const SolanaNetwork = lazy(() => import("./pages/solana")); @@ -68,6 +70,8 @@ export const LazyBitcoinTxs = withSuspense(BitcoinTransactionsPage); export const LazyBitcoinAddress = withSuspense(BitcoinAddressPage); export const LazyBitcoinMempool = withSuspense(BitcoinMempoolPage); export const LazyZcashNetwork = withSuspense(ZcashNetwork); +export const LazyZcashBlocks = withSuspense(ZcashBlocksPage); +export const LazyZcashBlock = withSuspense(ZcashBlockPage); export const LazySolanaNetwork = withSuspense(SolanaNetwork); export const LazySolanaSlots = withSuspense(SolanaSlotsPage); export const LazySolanaSlot = withSuspense(SolanaSlotPage); @@ -115,6 +119,8 @@ export function preloadAllRoutes() { import("./pages/bitcoin/BitcoinMempoolPage"); // Zcash pages import("./pages/zcash"); + import("./pages/zcash/ZcashBlocksPage"); + import("./pages/zcash/ZcashBlockPage"); // Solana pages import("./pages/solana"); import("./pages/solana/SolanaSlotsPage"); diff --git a/src/components/pages/zcash/ZcashBlockDisplay.tsx b/src/components/pages/zcash/ZcashBlockDisplay.tsx new file mode 100644 index 00000000..a68bd7e7 --- /dev/null +++ b/src/components/pages/zcash/ZcashBlockDisplay.tsx @@ -0,0 +1,399 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; +import { useSettings } from "../../../context/SettingsContext"; +import { useZcashTimeAgo } from "../../../hooks/useZcashTimeAgo"; +import type { ZcashBlock, ZcashShieldedPool } from "../../../types"; +import { + formatDifficulty, + formatNumber, + formatSize, + formatTimestamp, + formatZEC, + truncateBlockHash, +} from "../../../utils/zcashFormatters"; +import CopyButton from "../../common/CopyButton"; +import FieldLabel from "../../common/FieldLabel"; +import HelperTooltip from "../../common/HelperTooltip"; +import ZcashValuePools from "./ZcashValuePools"; + +const SHIELDED_POOLS: ZcashShieldedPool[] = ["sprout", "sapling", "orchard", "ironwood"]; +const TREE_POOLS = ["sapling", "orchard", "ironwood"] as const; + +const POOL_NAME_KEYS = { + sprout: "valuePools.pools.sprout", + sapling: "valuePools.pools.sapling", + orchard: "valuePools.pools.orchard", + ironwood: "valuePools.pools.ironwood", +} as const satisfies Record; + +interface DetailRowProps { + label: string; + tooltip?: string; + mono?: boolean; + children: React.ReactNode; +} + +const DetailRow: React.FC = ({ label, tooltip, mono, children }) => ( +
+ + {label} + {tooltip && } + + {children} +
+); + +interface ZcashBlockDisplayProps { + block: ZcashBlock; + networkId: string; + currency: string; +} + +const ZcashBlockDisplay: React.FC = React.memo( + ({ block, networkId, currency }) => { + const { t } = useTranslation("zcash"); + const { t: tTooltips } = useTranslation("tooltips"); + const { settings } = useSettings(); + const timeAgo = useZcashTimeAgo(); + const [showMoreDetails, setShowMoreDetails] = useState(false); + const [showTransactions, setShowTransactions] = useState(false); + const showTooltips = settings.showHelperTooltips !== false; + + const coinbaseOutputs = block.coinbaseOutputs ?? []; + const rewardZat = coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0); + const txids = block.txids ?? []; + const poolCounts = SHIELDED_POOLS.flatMap((pool) => { + const count = block.shieldedTxCounts?.[pool]; + return count ? [{ pool, count }] : []; + }); + const treeSizes = TREE_POOLS.flatMap((pool) => { + const size = block.trees?.[pool]; + return size === undefined + ? [] + : [t("block.treeSize", { pool: t(POOL_NAME_KEYS[pool]), size: formatNumber(size) })]; + }); + + return ( +
+
+
+ {block.height > 0 && ( + + ← + + )} +
+ {t("block.title")} + #{block.height.toLocaleString()} +
+ {block.nextBlockHash && ( + + → + + )} + • + + {timeAgo(block.time)} + ({formatTimestamp(block.time)}) + +
+ {block.confirmations !== undefined && ( + + {t("block.confirmations", { count: block.confirmations })} + {showTooltips && ( + + )} + + )} +
+ +
+
+ + + {block.hash} + + +
+ +
+
+ {coinbaseOutputs.length > 0 && ( +
+ + + {formatZEC(rewardZat, currency)} + +
+ )} + +
+ + + {t("block.txCount", { count: block.nTx })} + {poolCounts.length > 0 && ( + + {poolCounts.map(({ pool, count }) => ( + + {t("block.poolTxCount", { count, pool: t(POOL_NAME_KEYS[pool]) })} + + ))} + + )} + +
+ + {block.transparentOutputZat !== undefined && ( +
+ + + {formatZEC(block.transparentOutputZat, currency)} + +
+ )} +
+ +
+
+ + {formatDifficulty(block.difficulty)} +
+ +
+ + {formatSize(block.size)} +
+ + {block.previousBlockHash && ( +
+ + + + {truncateBlockHash(block.previousBlockHash)} + + +
+ )} + + {block.nextBlockHash && ( +
+ + + + {truncateBlockHash(block.nextBlockHash)} + + +
+ )} +
+
+ + {coinbaseOutputs.length > 0 && ( +
+ +
    + {coinbaseOutputs.map((output, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: outputs keep their on-chain order +
  • + {output.address ? ( + + {output.address} + + ) : ( + {t("block.noAddress")} + )} + + {formatZEC(output.valueZat, currency)} + +
  • + ))} +
+
+ )} + +
+ + + {showMoreDetails && ( +
+ + {block.merkleRoot} + + {block.blockCommitments && ( + + {block.blockCommitments} + + )} + {block.finalSaplingRoot && ( + + {block.finalSaplingRoot} + + )} + {block.finalOrchardRoot && ( + + {block.finalOrchardRoot} + + )} + + {block.version} + + + {block.bits} + + + {block.nonce} + + {block.solution && ( + + + {block.solution.length > 64 + ? `${block.solution.slice(0, 32)}…${block.solution.slice(-32)}` + : block.solution} + + + + )} + {treeSizes.length > 0 && ( + + {treeSizes.join(" · ")} + + )} +
+ )} +
+ + {txids.length > 0 && ( +
+ + + {showTransactions && ( +
+
+ {txids.map((txid, index) => ( +
+ {index} + + + {txid} + + +
+ ))} +
+
+ )} +
+ )} +
+ + {block.valuePools && block.valuePools.length > 0 && ( + + )} +
+ ); + }, +); + +ZcashBlockDisplay.displayName = "ZcashBlockDisplay"; +export default ZcashBlockDisplay; diff --git a/src/components/pages/zcash/ZcashBlockPage.tsx b/src/components/pages/zcash/ZcashBlockPage.tsx new file mode 100644 index 00000000..e0021f4c --- /dev/null +++ b/src/components/pages/zcash/ZcashBlockPage.tsx @@ -0,0 +1,125 @@ +import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useLocation, useParams } from "react-router-dom"; +import { getNetworkBySlug } from "../../../config/networks"; +import { useDataService } from "../../../hooks/useDataService"; +import { usePersistentCache } from "../../../hooks/usePersistentCache"; +import type { ZcashBlock } from "../../../types"; +import Breadcrumb from "../../common/Breadcrumb"; +import LoaderWithTimeout from "../../common/LoaderWithTimeout"; +import ZcashBlockDisplay from "./ZcashBlockDisplay"; + +export default function ZcashBlockPage() { + const { t } = useTranslation("zcash"); + const { filter } = useParams<{ filter?: string }>(); + const location = useLocation(); + + // Extract network slug from path (e.g., "/tzec/block/123" → "tzec") + const networkSlug = location.pathname.split("/")[1] || "zec"; + const dataService = useDataService(networkSlug); + const network = getNetworkBySlug(networkSlug); + const networkLabel = network?.shortName || networkSlug.toUpperCase(); + const cacheNetworkId = network?.networkId ?? networkSlug; + const { getCached, setCached } = usePersistentCache(); + + const [block, setBlock] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if (!dataService || !dataService.isZcash() || !filter) return; + + let cancelled = false; + const adapter = dataService.getZcashAdapter(); + + const fetchBlock = async () => { + setLoading(true); + setError(null); + + try { + let blockId: string | number = filter; + if (filter === "latest") { + blockId = await adapter.getLatestBlockNumber(); + } else if (/^\d+$/.test(filter)) { + const cached = getCached(cacheNetworkId, "block", filter); + if (cached) { + if (!cancelled) setBlock(cached); + return; + } + } + + // A single getblock call returns the header, transactions and value pools + const { data } = await adapter.getBlock(blockId); + if (cancelled) return; + setBlock(data.block); + setCached(cacheNetworkId, "block", String(data.block.height), data.block); + } catch (err) { + if (!cancelled) setError(err instanceof Error ? err.message : String(err)); + } finally { + if (!cancelled) setLoading(false); + } + }; + + fetchBlock(); + return () => { + cancelled = true; + }; + }, [dataService, filter, getCached, setCached, cacheNetworkId]); + + if (loading) { + return ( +
+
+
+ {t("block.title")} + {filter} +
+
+ window.location.reload()} /> +
+
+
+ ); + } + + if (error) { + return ( +
+
+
+ {t("block.title")} +
+
+

{t("block.loadError", { message: error })}

+
+
+
+ ); + } + + return ( +
+ + {block ? ( + + ) : ( +
+
+

{t("block.notFound")}

+
+
+ )} +
+ ); +} diff --git a/src/components/pages/zcash/ZcashBlocksPage.tsx b/src/components/pages/zcash/ZcashBlocksPage.tsx new file mode 100644 index 00000000..c47ad496 --- /dev/null +++ b/src/components/pages/zcash/ZcashBlocksPage.tsx @@ -0,0 +1,227 @@ +import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { Link, useLocation, useNavigate, useSearchParams } from "react-router-dom"; +import { getNetworkBySlug } from "../../../config/networks"; +import { BLOCKS_PER_PAGE } from "../../../config/zcashConstants"; +import { useDataService } from "../../../hooks/useDataService"; +import { useZcashTimeAgo } from "../../../hooks/useZcashTimeAgo"; +import type { ZcashBlock } from "../../../types"; +import { logger } from "../../../utils/logger"; +import { + formatNumber, + formatSize, + formatTimestamp, + truncateBlockHash, +} from "../../../utils/zcashFormatters"; +import Breadcrumb from "../../common/Breadcrumb"; + +const skeletonCell = (width: string) => ( + +); + +export default function ZcashBlocksPage() { + const { t } = useTranslation("zcash"); + const timeAgo = useZcashTimeAgo(); + const location = useLocation(); + const navigate = useNavigate(); + const [searchParams] = useSearchParams(); + + // Extract network slug from path (e.g., "/tzec/blocks" → "tzec") + const networkSlug = location.pathname.split("/")[1] || "zec"; + const dataService = useDataService(networkSlug); + const network = getNetworkBySlug(networkSlug); + const networkName = network?.name ?? networkSlug; + const networkLabel = network?.shortName || networkSlug.toUpperCase(); + + const fromBlockParam = searchParams.get("fromBlock"); + const fromBlock = + fromBlockParam !== null && /^\d+$/.test(fromBlockParam) ? Number(fromBlockParam) : null; + + const [blocks, setBlocks] = useState([]); + const [latestHeight, setLatestHeight] = useState(null); + const [fetching, setFetching] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if (!dataService || !dataService.isZcash()) return; + + let cancelled = false; + const adapter = dataService.getZcashAdapter(); + + const fetchBlocks = async () => { + setFetching(true); + setError(null); + setBlocks([]); + + try { + const tipHeight = await adapter.getLatestBlockNumber(); + if (cancelled) return; + setLatestHeight(tipHeight); + + const start = Math.min(fromBlock ?? tipHeight, tipHeight); + for (let height = start; height > start - BLOCKS_PER_PAGE && height >= 0; height--) { + // One block per call, so rows appear as they arrive on rate-limited endpoints + const [block] = await adapter.getBlockSummaries([height]); + if (cancelled) return; + if (block) setBlocks((prev) => [...prev, block]); + } + } catch (err) { + logger.error("Error fetching Zcash blocks:", err); + if (!cancelled) setError(err instanceof Error ? err.message : String(err)); + } finally { + if (!cancelled) setFetching(false); + } + }; + + fetchBlocks(); + return () => { + cancelled = true; + }; + }, [dataService, fromBlock]); + + const startHeight = + latestHeight === null ? null : Math.min(fromBlock ?? latestHeight, latestHeight); + const oldestHeight = startHeight === null ? null : Math.max(startHeight - BLOCKS_PER_PAGE + 1, 0); + const isAtLatest = fromBlock === null || (latestHeight !== null && fromBlock >= latestHeight); + const canGoNewer = !isAtLatest && startHeight !== null; + const canGoOlder = startHeight !== null && startHeight - BLOCKS_PER_PAGE >= 0; + + const expectedRows = + startHeight === null ? BLOCKS_PER_PAGE : Math.min(BLOCKS_PER_PAGE, startHeight + 1); + const skeletonRows = fetching ? Math.max(expectedRows - blocks.length, 0) : 0; + + const goToLatest = () => navigate(`/${networkSlug}/blocks`); + + const goToNewer = () => { + if (startHeight === null || latestHeight === null) return; + const next = startHeight + BLOCKS_PER_PAGE; + navigate( + next >= latestHeight ? `/${networkSlug}/blocks` : `/${networkSlug}/blocks?fromBlock=${next}`, + ); + }; + + const goToOlder = () => { + if (startHeight === null) return; + navigate(`/${networkSlug}/blocks?fromBlock=${startHeight - BLOCKS_PER_PAGE}`); + }; + + return ( +
+ +
+
+
+ {t("blocksPage.title", { network: networkName })} + {startHeight !== null && oldestHeight !== null && ( + <> + • + + {isAtLatest + ? t("blocksPage.showingLatest", { count: BLOCKS_PER_PAGE }) + : t("blocksPage.showingRange", { + from: formatNumber(oldestHeight), + to: formatNumber(startHeight), + })} + + + )} +
+
+ + {error ? ( +
+

{t("blocksPage.loadError", { message: error })}

+
+ ) : ( +
+ + + + + + + + + + + + {blocks.map((block) => ( + + + + + + + + ))} + {Array.from({ length: skeletonRows }).map((_, i) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: skeleton placeholder + + + + + + + + ))} + +
{t("blocksPage.height")}{t("blocksPage.hash")}{t("blocksPage.time")}{t("blocksPage.txns")}{t("blocksPage.size")}
+ + {block.height.toLocaleString()} + + + + {truncateBlockHash(block.hash)} + + + {timeAgo(block.time)} + {block.nTx.toLocaleString()}{formatSize(block.size)}
{skeletonCell("70px")}{skeletonCell("120px")}{skeletonCell("60px")}{skeletonCell("40px")}{skeletonCell("80px")}
+
+ )} + +
+ + + +
+
+
+ ); +} diff --git a/src/components/pages/zcash/ZcashValuePools.tsx b/src/components/pages/zcash/ZcashValuePools.tsx index 65f6bd92..62abdc3a 100644 --- a/src/components/pages/zcash/ZcashValuePools.tsx +++ b/src/components/pages/zcash/ZcashValuePools.tsx @@ -1,7 +1,7 @@ import type React from "react"; import { useTranslation } from "react-i18next"; import { useSettings } from "../../../context/SettingsContext"; -import type { ZcashNetworkStats, ZcashValuePoolId } from "../../../types"; +import type { ZcashValuePool, ZcashValuePoolId } from "../../../types"; import { formatPercent, formatZECCompact } from "../../../utils/zcashFormatters"; import HelperTooltip from "../../common/HelperTooltip"; import { VALUE_POOL_LABEL_KEYS } from "./labels"; @@ -16,32 +16,37 @@ const POOL_TOOLTIP_KEYS = { } as const satisfies Record; interface ZcashValuePoolsProps { - stats: ZcashNetworkStats | null; + valuePools: ZcashValuePool[]; + chainSupplyZat?: number; currency: string; + title?: string; } -const ZcashValuePools: React.FC = ({ stats, currency }) => { +const ZcashValuePools: React.FC = ({ + valuePools, + chainSupplyZat, + currency, + title, +}) => { const { t } = useTranslation("zcash"); const { t: tTooltips } = useTranslation("tooltips"); const { settings } = useSettings(); const showTooltips = settings.showHelperTooltips !== false; - const pools = stats?.valuePools ?? []; - const totalZat = - stats?.chainSupplyZat || pools.reduce((sum, pool) => sum + pool.valueZat, 0) || 0; - if (pools.length === 0 || totalZat <= 0) return null; + const totalZat = chainSupplyZat || valuePools.reduce((sum, pool) => sum + pool.valueZat, 0); + if (valuePools.length === 0 || totalZat <= 0) return null; const sharePercent = (valueZat: number) => (valueZat / totalZat) * 100; return (
-

{t("valuePools.title")}

+

{title ?? t("valuePools.title")}

{showTooltips && }
- {pools.map((pool) => ( + {valuePools.map((pool) => ( = ({ stats, currency }) =>
    - {pools.map((pool) => ( + {valuePools.map((pool) => (
  • {t(VALUE_POOL_LABEL_KEYS[pool.id])} diff --git a/src/components/pages/zcash/index.tsx b/src/components/pages/zcash/index.tsx index 0ccafabe..5a8156a2 100644 --- a/src/components/pages/zcash/index.tsx +++ b/src/components/pages/zcash/index.tsx @@ -58,7 +58,11 @@ export default function ZcashNetwork() { loading={dashboard.loading} /> - +
    Date: Mon, 14 Sep 2026 20:11:39 -0300 Subject: [PATCH 3/6] test(e2e): add hermetic Zcash blocks spec --- e2e/tests/shared/mocked/zcash-blocks.spec.ts | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 e2e/tests/shared/mocked/zcash-blocks.spec.ts diff --git a/e2e/tests/shared/mocked/zcash-blocks.spec.ts b/e2e/tests/shared/mocked/zcash-blocks.spec.ts new file mode 100644 index 00000000..41962735 --- /dev/null +++ b/e2e/tests/shared/mocked/zcash-blocks.spec.ts @@ -0,0 +1,56 @@ +import { BLOCK_3483400 } from "../../../../src/services/adapters/ZcashAdapter/fixtures"; +import { expect, test } from "../../../fixtures/test"; +import { mockZcashRpc, ZCASH } from "../../../fixtures/zcash"; + +/** + * Hermetic Zcash blocks list and block detail pages, served from mainnet block 3,483,400. + */ +test.describe("Zcash blocks", () => { + test("lists the latest blocks one call per block and pages to older blocks", async ({ + page, + }) => { + const calls = await mockZcashRpc(page); + + await page.goto(`/#/${ZCASH.networkSlug}/blocks`); + + const table = page.locator("table.blocks-table"); + await expect(table).toContainText("3,483,400"); + await expect(table).toContainText("3,483,391"); + await expect(table.locator("tbody tr")).toHaveCount(10); + + const summaryHeights = calls + .filter((call) => call.method === "getblock" && call.params[1] === 1) + .map((call) => call.params[0]); + expect(summaryHeights).toContain("3483391"); + expect(calls.map((call) => call.method)).not.toContain("getblockhash"); + + await page.getByRole("button", { name: "Older →" }).click(); + await expect(page).toHaveURL(/fromBlock=3483390/); + await expect(table).toContainText("3,483,381"); + }); + + test("shows Zcash-specific block details", async ({ page }) => { + const calls = await mockZcashRpc(page); + + await page.goto(`/#/${ZCASH.networkSlug}/block/${ZCASH.tipHeight}`); + + await expect(page.locator(".block-number")).toHaveText("#3,483,400"); + await expect(page.getByText(BLOCK_3483400.hash)).toBeVisible(); + await expect(page.getByText("t1SqwRAAdSig6dE4EBPLonAait219VmkUjP")).toBeVisible(); + await expect(page.getByText("2 Sapling")).toBeVisible(); + await expect(page.getByText("2 Ironwood")).toBeVisible(); + await expect(page.getByTestId("zcash-value-pools")).toContainText("Value Pools After This Block"); + + await page.getByRole("button", { name: "+ Show More Details" }).click(); + await expect(page.getByText(BLOCK_3483400.nonce)).toBeVisible(); + await expect(page.getByText("Equihash Solution:")).toBeVisible(); + await expect(page.getByText("Ironwood 318,976")).toBeVisible(); + + // Only the requested block is fetched with full transactions, by height string. The dev + // server runs React StrictMode, which can issue the same request twice. + const verboseBlockCalls = calls.filter( + (call) => call.method === "getblock" && call.params[1] === 2, + ); + expect(new Set(verboseBlockCalls.map((call) => call.params[0]))).toEqual(new Set(["3483400"])); + }); +}); From 048ffdea1c74b59601dca0c0122def2bc36fb286 Mon Sep 17 00:00:00 2001 From: Mati OS Date: Fri, 20 Nov 2026 20:12:54 -0300 Subject: [PATCH 4/6] feat(adapter): stream zcash block summaries as they arrive --- src/services/adapters/ZcashAdapter/ZcashAdapter.test.ts | 7 ++++++- src/services/adapters/ZcashAdapter/ZcashAdapter.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/services/adapters/ZcashAdapter/ZcashAdapter.test.ts b/src/services/adapters/ZcashAdapter/ZcashAdapter.test.ts index dc2e53b9..4486f4b8 100644 --- a/src/services/adapters/ZcashAdapter/ZcashAdapter.test.ts +++ b/src/services/adapters/ZcashAdapter/ZcashAdapter.test.ts @@ -162,7 +162,10 @@ describe("ZcashAdapter blocks", () => { .mockResolvedValueOnce(fail("RPC error: Block not found")) .mockResolvedValueOnce(ok(summary(3483400))); - const { blocks, failedHeights } = await adapter.getBlockSummaries([3483399, 3483398, 3483400]); + const onBlock = vi.fn(); + const { blocks, failedHeights } = await adapter.getBlockSummaries([3483399, 3483398, 3483400], { + onBlock, + }); expect(client.getBlock.mock.calls).toEqual([ ["3483399", 1], @@ -172,6 +175,8 @@ describe("ZcashAdapter blocks", () => { expect(blocks.map((block) => block.height)).toEqual([3483400, 3483399]); expect(blocks[0]?.txids).toEqual(["a".repeat(64)]); expect(failedHeights).toEqual([3483398]); + // Rows can render in request order as each block arrives + expect(onBlock.mock.calls.map(([block]) => block.height)).toEqual([3483399, 3483400]); }); it("stops fetching summaries once a block stays rate limited", async () => { diff --git a/src/services/adapters/ZcashAdapter/ZcashAdapter.ts b/src/services/adapters/ZcashAdapter/ZcashAdapter.ts index 8921e32c..39fba262 100644 --- a/src/services/adapters/ZcashAdapter/ZcashAdapter.ts +++ b/src/services/adapters/ZcashAdapter/ZcashAdapter.ts @@ -333,7 +333,10 @@ export class ZcashAdapter { */ async getBlockSummaries( heights: number[], - options: ZcashCallOptions = {}, + options: ZcashCallOptions & { + /** Called as each block arrives, so pages can render rows progressively */ + onBlock?: (block: ZcashBlock) => void; + } = {}, ): Promise { const blocks: ZcashBlock[] = []; const failedHeights: number[] = []; @@ -345,7 +348,9 @@ export class ZcashAdapter { () => this.client.getBlock(String(height), 1), options.signal, ); - blocks.push(transformBlockSummary(data)); + const block = transformBlockSummary(data); + blocks.push(block); + options.onBlock?.(block); } catch (error) { if (options.signal?.aborted) throw error; logger.warn(`Failed to fetch Zcash block ${height}:`, error); From 0f4bf0bba68a832f859be5992b46d18168324240 Mon Sep 17 00:00:00 2001 From: Mati OS Date: Fri, 20 Nov 2026 20:12:55 -0300 Subject: [PATCH 5/6] fix(i18n): localize the loader timeout message and actions --- src/components/common/LoaderWithTimeout.tsx | 10 ++++++---- src/locales/en/common.json | 4 ++++ src/locales/es/common.json | 4 ++++ src/locales/ja/common.json | 4 ++++ src/locales/pt-BR/common.json | 4 ++++ src/locales/zh/common.json | 4 ++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/common/LoaderWithTimeout.tsx b/src/components/common/LoaderWithTimeout.tsx index 4e455ce3..fd987367 100644 --- a/src/components/common/LoaderWithTimeout.tsx +++ b/src/components/common/LoaderWithTimeout.tsx @@ -1,5 +1,6 @@ import type React from "react"; import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import OpenScanCubeLoader from "../LoadingLogo"; @@ -16,8 +17,9 @@ const LoaderWithTimeout: React.FC = ({ size = 60, timeoutMs = 15000, onRetry, - timeoutText = "Data is taking longer than expected.", + timeoutText, }) => { + const { t } = useTranslation("common"); const [timedOut, setTimedOut] = useState(false); useEffect(() => { @@ -40,15 +42,15 @@ const LoaderWithTimeout: React.FC = ({ -

    {timeoutText}

    +

    {timeoutText ?? t("loaderTimeout.message")}

    {onRetry && ( )} - Go Home + {t("errors.goHome")}
    diff --git a/src/locales/en/common.json b/src/locales/en/common.json index 42ee1dd9..35338d05 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -318,5 +318,9 @@ "badgeUnknown": "Unknown", "noQueryHelp": "Search for an address, transaction hash, block number, or ENS name.", "goHome": "Go Home" + }, + "loaderTimeout": { + "message": "Data is taking longer than expected.", + "retry": "Retry" } } diff --git a/src/locales/es/common.json b/src/locales/es/common.json index 4067115f..6a20c079 100644 --- a/src/locales/es/common.json +++ b/src/locales/es/common.json @@ -333,5 +333,9 @@ "connectWallet": "Conectar wallet", "wrongNetwork": "Red incorrecta", "chainIcon": "Ícono de red" + }, + "loaderTimeout": { + "message": "Los datos están tardando más de lo esperado.", + "retry": "Reintentar" } } diff --git a/src/locales/ja/common.json b/src/locales/ja/common.json index 843ccf18..4d1fb263 100644 --- a/src/locales/ja/common.json +++ b/src/locales/ja/common.json @@ -306,5 +306,9 @@ "badgeBlock": "ブロック", "badgeEns": "ENS", "badgeUnknown": "不明" + }, + "loaderTimeout": { + "message": "データの取得に予想以上に時間がかかっています。", + "retry": "再試行" } } diff --git a/src/locales/pt-BR/common.json b/src/locales/pt-BR/common.json index c441c67f..f0410739 100644 --- a/src/locales/pt-BR/common.json +++ b/src/locales/pt-BR/common.json @@ -309,5 +309,9 @@ "badgeBlock": "Bloco", "badgeEns": "ENS", "badgeUnknown": "Desconhecido" + }, + "loaderTimeout": { + "message": "Os dados estão demorando mais do que o esperado.", + "retry": "Tentar novamente" } } diff --git a/src/locales/zh/common.json b/src/locales/zh/common.json index 47e84319..22ec8dba 100644 --- a/src/locales/zh/common.json +++ b/src/locales/zh/common.json @@ -291,5 +291,9 @@ "badgeBlock": "区块", "badgeEns": "ENS", "badgeUnknown": "未知" + }, + "loaderTimeout": { + "message": "数据加载时间超出预期。", + "retry": "重试" } } From 074300ac4ef2a15c345a4b6b88c145c7f9399b8f Mon Sep 17 00:00:00 2001 From: Mati OS Date: Fri, 20 Nov 2026 20:12:56 -0300 Subject: [PATCH 6/6] fix(zcash): show shielded rewards and failed blocks on block pages - Block Reward adds the shielded coinbase value, so blocks mined to a Sapling or Orchard address no longer show only funding streams. - The blocks list makes one streamed summaries call, aborts on page or network change, and lists blocks that fail as rows with a retry. - Block details reuse FieldLabel (honouring the knowledge level), LongString for the Equihash solution, the shared pool chip and the typed pool label keys. - The tip block is no longer cached; cached blocks show their confirmations as a lower bound ("N+"). - The loader waits out the rate-limit retry window and its Retry re-runs the fetch instead of reloading the page. - Plural forms for confirmations, transaction counts and the page summary. - E2E: a pre-NU5 block, paging to genesis, and a failed block retried. --- e2e/tests/shared/mocked/zcash-blocks.spec.ts | 97 +++++++- .../pages/zcash/ZcashBlockDisplay.tsx | 123 +++++------ src/components/pages/zcash/ZcashBlockPage.tsx | 60 +++-- .../pages/zcash/ZcashBlocksPage.tsx | 208 ++++++++++++------ src/components/pages/zcash/ZcashCells.tsx | 26 ++- src/config/zcashConstants.ts | 3 + src/locales/en/zcash.json | 16 +- src/locales/es/zcash.json | 16 +- src/locales/ja/zcash.json | 10 +- src/locales/pt-BR/zcash.json | 16 +- src/locales/zh/zcash.json | 10 +- src/styles/components.css | 14 ++ 12 files changed, 422 insertions(+), 177 deletions(-) diff --git a/e2e/tests/shared/mocked/zcash-blocks.spec.ts b/e2e/tests/shared/mocked/zcash-blocks.spec.ts index 41962735..7b9012ce 100644 --- a/e2e/tests/shared/mocked/zcash-blocks.spec.ts +++ b/e2e/tests/shared/mocked/zcash-blocks.spec.ts @@ -1,6 +1,47 @@ -import { BLOCK_3483400 } from "../../../../src/services/adapters/ZcashAdapter/fixtures"; +import type { Page } from "@playwright/test"; +import { + BLOCK_3483400, + COINBASE_TX, +} from "../../../../src/services/adapters/ZcashAdapter/fixtures"; import { expect, test } from "../../../fixtures/test"; -import { mockZcashRpc, ZCASH } from "../../../fixtures/zcash"; +import { mockZcashRpc, ZCASH, ZCASH_RPC_PATTERN } from "../../../fixtures/zcash"; + +// Before NU5 (mainnet height 1,687,104) blocks have no Orchard root, tree or block commitments +const PRE_NU5_HEIGHT = 1_000_000; +const PRE_NU5_BLOCK = { + ...BLOCK_3483400, + height: PRE_NU5_HEIGHT, + hash: PRE_NU5_HEIGHT.toString(16).padStart(64, "0"), + finalorchardroot: undefined, + blockcommitments: undefined, + trees: { sapling: { size: 123_456 } }, + tx: [COINBASE_TX], +}; + +/** + * Answer one getblock request from the test instead of the shared mock + */ +async function overrideGetBlock( + page: Page, + respond: (params: unknown[]) => { result: unknown } | { error: string } | null, +) { + await page.route(ZCASH_RPC_PATTERN, async (route) => { + const body = JSON.parse(route.request().postData() ?? "{}"); + const response = body.method === "getblock" ? respond(body.params ?? []) : null; + if (!response) { + await route.fallback(); + return; + } + await route.fulfill({ + contentType: "application/json", + body: JSON.stringify( + "error" in response + ? { jsonrpc: "2.0", id: body.id, error: { code: -8, message: response.error } } + : { jsonrpc: "2.0", id: body.id, result: response.result }, + ), + }); + }); +} /** * Hermetic Zcash blocks list and block detail pages, served from mainnet block 3,483,400. @@ -53,4 +94,56 @@ test.describe("Zcash blocks", () => { ); expect(new Set(verboseBlockCalls.map((call) => call.params[0]))).toEqual(new Set(["3483400"])); }); + + test("renders a pre-NU5 block without Orchard fields", async ({ page }) => { + await mockZcashRpc(page); + await overrideGetBlock(page, ([height]) => + height === String(PRE_NU5_HEIGHT) ? { result: PRE_NU5_BLOCK } : null, + ); + + await page.goto(`/#/${ZCASH.networkSlug}/block/${PRE_NU5_HEIGHT}`); + await expect(page.locator(".block-number")).toHaveText("#1,000,000"); + + await page.getByRole("button", { name: "+ Show More Details" }).click(); + await expect(page.getByText("Final Sapling Root:")).toBeVisible(); + await expect(page.getByText("Sapling 123,456")).toBeVisible(); + await expect(page.getByText("Final Orchard Root:")).toHaveCount(0); + await expect(page.getByText("Block Commitments:")).toHaveCount(0); + await expect(page.getByText(/Orchard \d/)).toHaveCount(0); + }); + + test("pages down to the genesis block", async ({ page }) => { + await mockZcashRpc(page); + + await page.goto(`/#/${ZCASH.networkSlug}/blocks?fromBlock=3`); + + const table = page.locator("table.blocks-table"); + await expect(table.locator("tbody tr")).toHaveCount(4); + await expect(table.locator("tbody tr").last()).toContainText("0"); + await expect(page.getByRole("button", { name: "Older →" })).toBeDisabled(); + await expect(page.getByRole("button", { name: "← Newer" })).toBeEnabled(); + }); + + test("lists a block that failed to load and retries it", async ({ page }) => { + await mockZcashRpc(page); + const failingHeight = String(ZCASH.tipHeight - 5); + // Fails until the retry (React StrictMode may fetch the page twice in development) + let recovered = false; + await overrideGetBlock(page, ([height]) => + height === failingHeight && !recovered ? { error: "Block not found" } : null, + ); + + await page.goto(`/#/${ZCASH.networkSlug}/blocks`); + + const table = page.locator("table.blocks-table"); + const unavailable = table.getByTestId("zcash-block-unavailable"); + // Rows arrive one block at a time, so allow for a slow dev server + await expect(unavailable).toContainText("3,483,395", { timeout: 15_000 }); + await expect(table.locator("tbody tr")).toHaveCount(10); + + recovered = true; + await unavailable.getByRole("button", { name: "Retry" }).click(); + await expect(unavailable).toHaveCount(0); + await expect(table).toContainText("3,483,395"); + }); }); diff --git a/src/components/pages/zcash/ZcashBlockDisplay.tsx b/src/components/pages/zcash/ZcashBlockDisplay.tsx index a68bd7e7..f6f8d1b4 100644 --- a/src/components/pages/zcash/ZcashBlockDisplay.tsx +++ b/src/components/pages/zcash/ZcashBlockDisplay.tsx @@ -1,9 +1,10 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; +import { ZCASH_SHIELDED_POOLS, ZCASH_TREE_POOLS } from "../../../config/zcashConstants"; import { useSettings } from "../../../context/SettingsContext"; -import { useZcashTimeAgo } from "../../../hooks/useZcashTimeAgo"; -import type { ZcashBlock, ZcashShieldedPool } from "../../../types"; +import { useTimeAgo } from "../../../hooks/useTimeAgo"; +import type { KnowledgeLevel, ZcashBlock } from "../../../types"; import { formatDifficulty, formatNumber, @@ -15,31 +16,30 @@ import { import CopyButton from "../../common/CopyButton"; import FieldLabel from "../../common/FieldLabel"; import HelperTooltip from "../../common/HelperTooltip"; +import LongString from "../../common/LongString"; +import { VALUE_POOL_LABEL_KEYS } from "./labels"; +import { ZcashPoolChip } from "./ZcashCells"; import ZcashValuePools from "./ZcashValuePools"; -const SHIELDED_POOLS: ZcashShieldedPool[] = ["sprout", "sapling", "orchard", "ironwood"]; -const TREE_POOLS = ["sapling", "orchard", "ironwood"] as const; - -const POOL_NAME_KEYS = { - sprout: "valuePools.pools.sprout", - sapling: "valuePools.pools.sapling", - orchard: "valuePools.pools.orchard", - ironwood: "valuePools.pools.ironwood", -} as const satisfies Record; +// Header internals are self-explanatory to advanced users +const DETAIL_TOOLTIP_LEVELS: KnowledgeLevel[] = ["beginner", "intermediate"]; interface DetailRowProps { label: string; - tooltip?: string; + tooltipKey: string; mono?: boolean; children: React.ReactNode; } -const DetailRow: React.FC = ({ label, tooltip, mono, children }) => ( +/** A row of the "more details" section; FieldLabel decides whether the tooltip shows */ +const DetailRow: React.FC = ({ label, tooltipKey, mono, children }) => (
    - - {label} - {tooltip && } - + {children}
    ); @@ -48,30 +48,40 @@ interface ZcashBlockDisplayProps { block: ZcashBlock; networkId: string; currency: string; + /** The block came from the cache: its confirmation count is a lower bound */ + confirmationsAtLeast?: boolean; } const ZcashBlockDisplay: React.FC = React.memo( - ({ block, networkId, currency }) => { + ({ block, networkId, currency, confirmationsAtLeast = false }) => { const { t } = useTranslation("zcash"); const { t: tTooltips } = useTranslation("tooltips"); const { settings } = useSettings(); - const timeAgo = useZcashTimeAgo(); + const timeAgo = useTimeAgo(); const [showMoreDetails, setShowMoreDetails] = useState(false); const [showTransactions, setShowTransactions] = useState(false); const showTooltips = settings.showHelperTooltips !== false; const coinbaseOutputs = block.coinbaseOutputs ?? []; - const rewardZat = coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0); + const coinbaseShieldedZat = block.coinbaseShieldedZat ?? 0; + // A shielded coinbase pays (part of) the reward into Sapling or Orchard + const rewardZat = + coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0) + coinbaseShieldedZat; const txids = block.txids ?? []; - const poolCounts = SHIELDED_POOLS.flatMap((pool) => { + const poolCounts = ZCASH_SHIELDED_POOLS.flatMap((pool) => { const count = block.shieldedTxCounts?.[pool]; return count ? [{ pool, count }] : []; }); - const treeSizes = TREE_POOLS.flatMap((pool) => { + const treeSizes = ZCASH_TREE_POOLS.flatMap((pool) => { const size = block.trees?.[pool]; return size === undefined ? [] - : [t("block.treeSize", { pool: t(POOL_NAME_KEYS[pool]), size: formatNumber(size) })]; + : [ + t("block.treeSize", { + pool: t(VALUE_POOL_LABEL_KEYS[pool]), + size: formatNumber(size), + }), + ]; }); return ( @@ -108,7 +118,9 @@ const ZcashBlockDisplay: React.FC = React.memo( {block.confirmations !== undefined && ( - {t("block.confirmations", { count: block.confirmations })} + {confirmationsAtLeast + ? t("block.confirmationsAtLeast", { count: block.confirmations }) + : t("block.confirmations", { count: block.confirmations })} {showTooltips && ( )} @@ -131,7 +143,7 @@ const ZcashBlockDisplay: React.FC = React.memo(
    - {coinbaseOutputs.length > 0 && ( + {rewardZat > 0 && (
    = React.memo( /> {formatZEC(rewardZat, currency)} + {coinbaseShieldedZat > 0 && ( + + {" "} + {t("block.shieldedReward", { + amount: formatZEC(coinbaseShieldedZat, currency), + })} + + )}
    )} @@ -155,9 +175,9 @@ const ZcashBlockDisplay: React.FC = React.memo( {poolCounts.length > 0 && ( {poolCounts.map(({ pool, count }) => ( - - {t("block.poolTxCount", { count, pool: t(POOL_NAME_KEYS[pool]) })} - + + {t("block.poolTxCount", { count, pool: t(VALUE_POOL_LABEL_KEYS[pool]) })} + ))} )} @@ -270,17 +290,13 @@ const ZcashBlockDisplay: React.FC = React.memo( {showMoreDetails && (
    - + {block.merkleRoot} {block.blockCommitments && ( {block.blockCommitments} @@ -289,7 +305,7 @@ const ZcashBlockDisplay: React.FC = React.memo( {block.finalSaplingRoot && ( {block.finalSaplingRoot} @@ -298,51 +314,28 @@ const ZcashBlockDisplay: React.FC = React.memo( {block.finalOrchardRoot && ( {block.finalOrchardRoot} )} - + {block.version} - + {block.bits} - + {block.nonce} {block.solution && ( - - - {block.solution.length > 64 - ? `${block.solution.slice(0, 32)}…${block.solution.slice(-32)}` - : block.solution} - - + + )} {treeSizes.length > 0 && ( - + {treeSizes.join(" · ")} )} diff --git a/src/components/pages/zcash/ZcashBlockPage.tsx b/src/components/pages/zcash/ZcashBlockPage.tsx index e0021f4c..963f109a 100644 --- a/src/components/pages/zcash/ZcashBlockPage.tsx +++ b/src/components/pages/zcash/ZcashBlockPage.tsx @@ -1,9 +1,10 @@ import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { useLocation, useParams } from "react-router-dom"; -import { getNetworkBySlug } from "../../../config/networks"; +import { useParams } from "react-router-dom"; +import { LOADER_TIMEOUT_MS } from "../../../config/zcashConstants"; import { useDataService } from "../../../hooks/useDataService"; import { usePersistentCache } from "../../../hooks/usePersistentCache"; +import { useZcashNetworkFromPath } from "../../../hooks/useZcashNetworkFromPath"; import type { ZcashBlock } from "../../../types"; import Breadcrumb from "../../common/Breadcrumb"; import LoaderWithTimeout from "../../common/LoaderWithTimeout"; @@ -12,59 +13,66 @@ import ZcashBlockDisplay from "./ZcashBlockDisplay"; export default function ZcashBlockPage() { const { t } = useTranslation("zcash"); const { filter } = useParams<{ filter?: string }>(); - const location = useLocation(); - - // Extract network slug from path (e.g., "/tzec/block/123" → "tzec") - const networkSlug = location.pathname.split("/")[1] || "zec"; + const { + slug: networkSlug, + label: networkLabel, + currency, + cacheNetworkId, + } = useZcashNetworkFromPath(); const dataService = useDataService(networkSlug); - const network = getNetworkBySlug(networkSlug); - const networkLabel = network?.shortName || networkSlug.toUpperCase(); - const cacheNetworkId = network?.networkId ?? networkSlug; const { getCached, setCached } = usePersistentCache(); const [block, setBlock] = useState(null); + const [fromCache, setFromCache] = useState(false); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [attempt, setAttempt] = useState(0); + // biome-ignore lint/correctness/useExhaustiveDependencies: attempt re-runs the fetch on retry useEffect(() => { if (!dataService || !dataService.isZcash() || !filter) return; - let cancelled = false; + const controller = new AbortController(); + const { signal } = controller; const adapter = dataService.getZcashAdapter(); const fetchBlock = async () => { setLoading(true); setError(null); + setFromCache(false); try { let blockId: string | number = filter; if (filter === "latest") { - blockId = await adapter.getLatestBlockNumber(); + blockId = await adapter.getLatestBlockNumber({ signal }); } else if (/^\d+$/.test(filter)) { const cached = getCached(cacheNetworkId, "block", filter); if (cached) { - if (!cancelled) setBlock(cached); + setBlock(cached); + setFromCache(true); return; } } // A single getblock call returns the header, transactions and value pools - const { data } = await adapter.getBlock(blockId); - if (cancelled) return; + const { data } = await adapter.getBlock(blockId, { signal }); + if (signal.aborted) return; setBlock(data.block); - setCached(cacheNetworkId, "block", String(data.block.height), data.block); + // The tip still changes (next block link, confirmations), so only cache blocks that + // already have a successor + if (data.block.nextBlockHash) { + setCached(cacheNetworkId, "block", String(data.block.height), data.block); + } } catch (err) { - if (!cancelled) setError(err instanceof Error ? err.message : String(err)); + if (!signal.aborted) setError(err instanceof Error ? err.message : String(err)); } finally { - if (!cancelled) setLoading(false); + if (!signal.aborted) setLoading(false); } }; fetchBlock(); - return () => { - cancelled = true; - }; - }, [dataService, filter, getCached, setCached, cacheNetworkId]); + return () => controller.abort(); + }, [dataService, filter, getCached, setCached, cacheNetworkId, attempt]); if (loading) { return ( @@ -75,7 +83,12 @@ export default function ZcashBlockPage() { {filter}
    - window.location.reload()} /> + setAttempt((count) => count + 1)} + />
    @@ -111,7 +124,8 @@ export default function ZcashBlockPage() { ) : (
    diff --git a/src/components/pages/zcash/ZcashBlocksPage.tsx b/src/components/pages/zcash/ZcashBlocksPage.tsx index c47ad496..d04eade3 100644 --- a/src/components/pages/zcash/ZcashBlocksPage.tsx +++ b/src/components/pages/zcash/ZcashBlocksPage.tsx @@ -1,10 +1,10 @@ -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; -import { Link, useLocation, useNavigate, useSearchParams } from "react-router-dom"; -import { getNetworkBySlug } from "../../../config/networks"; +import { Link, useNavigate, useSearchParams } from "react-router-dom"; import { BLOCKS_PER_PAGE } from "../../../config/zcashConstants"; import { useDataService } from "../../../hooks/useDataService"; -import { useZcashTimeAgo } from "../../../hooks/useZcashTimeAgo"; +import { useTimeAgo } from "../../../hooks/useTimeAgo"; +import { useZcashNetworkFromPath } from "../../../hooks/useZcashNetworkFromPath"; import type { ZcashBlock } from "../../../types"; import { logger } from "../../../utils/logger"; import { @@ -14,70 +14,94 @@ import { truncateBlockHash, } from "../../../utils/zcashFormatters"; import Breadcrumb from "../../common/Breadcrumb"; - -const skeletonCell = (width: string) => ( - -); +import { ZcashSkeleton } from "./ZcashCells"; export default function ZcashBlocksPage() { const { t } = useTranslation("zcash"); - const timeAgo = useZcashTimeAgo(); - const location = useLocation(); + const timeAgo = useTimeAgo(); const navigate = useNavigate(); const [searchParams] = useSearchParams(); - - // Extract network slug from path (e.g., "/tzec/blocks" → "tzec") - const networkSlug = location.pathname.split("/")[1] || "zec"; + const { slug: networkSlug, name: networkName, label: networkLabel } = useZcashNetworkFromPath(); const dataService = useDataService(networkSlug); - const network = getNetworkBySlug(networkSlug); - const networkName = network?.name ?? networkSlug; - const networkLabel = network?.shortName || networkSlug.toUpperCase(); const fromBlockParam = searchParams.get("fromBlock"); const fromBlock = fromBlockParam !== null && /^\d+$/.test(fromBlockParam) ? Number(fromBlockParam) : null; - const [blocks, setBlocks] = useState([]); + const [blocks, setBlocks] = useState>(new Map()); + const [failedHeights, setFailedHeights] = useState([]); const [latestHeight, setLatestHeight] = useState(null); const [fetching, setFetching] = useState(true); const [error, setError] = useState(null); + // Aborted when the page or network changes, so retries of an old page can't land here + const pageSignalRef = useRef(null); + + const addBlock = useCallback((block: ZcashBlock) => { + setBlocks((prev) => new Map(prev).set(block.height, block)); + }, []); useEffect(() => { if (!dataService || !dataService.isZcash()) return; - let cancelled = false; + const controller = new AbortController(); + const { signal } = controller; + pageSignalRef.current = signal; const adapter = dataService.getZcashAdapter(); const fetchBlocks = async () => { setFetching(true); setError(null); - setBlocks([]); + setBlocks(new Map()); + setFailedHeights([]); try { - const tipHeight = await adapter.getLatestBlockNumber(); - if (cancelled) return; + const tipHeight = await adapter.getLatestBlockNumber({ signal }); + if (signal.aborted) return; setLatestHeight(tipHeight); const start = Math.min(fromBlock ?? tipHeight, tipHeight); - for (let height = start; height > start - BLOCKS_PER_PAGE && height >= 0; height--) { - // One block per call, so rows appear as they arrive on rate-limited endpoints - const [block] = await adapter.getBlockSummaries([height]); - if (cancelled) return; - if (block) setBlocks((prev) => [...prev, block]); - } + const heights = Array.from({ length: BLOCKS_PER_PAGE }, (_, i) => start - i).filter( + (height) => height >= 0, + ); + // One block per call; rows appear as they arrive on rate-limited endpoints + const result = await adapter.getBlockSummaries(heights, { + signal, + onBlock: (block) => { + if (!signal.aborted) addBlock(block); + }, + }); + if (signal.aborted) return; + setFailedHeights(result.failedHeights); } catch (err) { + if (signal.aborted) return; logger.error("Error fetching Zcash blocks:", err); - if (!cancelled) setError(err instanceof Error ? err.message : String(err)); + setError(err instanceof Error ? err.message : String(err)); } finally { - if (!cancelled) setFetching(false); + if (!signal.aborted) setFetching(false); } }; fetchBlocks(); - return () => { - cancelled = true; - }; - }, [dataService, fromBlock]); + return () => controller.abort(); + }, [dataService, fromBlock, addBlock]); + + const retryBlock = async (height: number) => { + const signal = pageSignalRef.current; + if (!dataService?.isZcash() || !signal) return; + setFailedHeights((prev) => prev.filter((failed) => failed !== height)); + try { + const result = await dataService.getZcashAdapter().getBlockSummaries([height], { + signal, + onBlock: (block) => { + if (!signal.aborted) addBlock(block); + }, + }); + if (signal.aborted) return; + setFailedHeights((prev) => [...prev, ...result.failedHeights]); + } catch { + // Aborted: the page moved on + } + }; const startHeight = latestHeight === null ? null : Math.min(fromBlock ?? latestHeight, latestHeight); @@ -86,9 +110,11 @@ export default function ZcashBlocksPage() { const canGoNewer = !isAtLatest && startHeight !== null; const canGoOlder = startHeight !== null && startHeight - BLOCKS_PER_PAGE >= 0; - const expectedRows = - startHeight === null ? BLOCKS_PER_PAGE : Math.min(BLOCKS_PER_PAGE, startHeight + 1); - const skeletonRows = fetching ? Math.max(expectedRows - blocks.length, 0) : 0; + const pageHeights = + startHeight === null || oldestHeight === null + ? [] + : Array.from({ length: startHeight - oldestHeight + 1 }, (_, i) => startHeight - i); + const skeletonRows = startHeight === null && fetching ? BLOCKS_PER_PAGE : 0; const goToLatest = () => navigate(`/${networkSlug}/blocks`); @@ -151,41 +177,65 @@ export default function ZcashBlocksPage() { - {blocks.map((block) => ( - - - - {block.height.toLocaleString()} - - - - - {truncateBlockHash(block.hash)} - - - - {timeAgo(block.time)} - - {block.nTx.toLocaleString()} - {formatSize(block.size)} - - ))} + {pageHeights.map((height) => { + const block = blocks.get(height); + if (block) { + return ( + + + + {block.height.toLocaleString()} + + + + + {truncateBlockHash(block.hash)} + + + + {timeAgo(block.time)} + + {block.nTx.toLocaleString()} + {formatSize(block.size)} + + ); + } + if (failedHeights.includes(height)) { + return ( + + + + {height.toLocaleString()} + + + + {t("blocksPage.unavailable")} + + + + ); + } + return ; + })} {Array.from({ length: skeletonRows }).map((_, i) => ( // biome-ignore lint/suspicious/noArrayIndexKey: skeleton placeholder - - {skeletonCell("70px")} - {skeletonCell("120px")} - {skeletonCell("60px")} - {skeletonCell("40px")} - {skeletonCell("80px")} - + ))} @@ -225,3 +275,23 @@ export default function ZcashBlocksPage() {
    ); } + +const SkeletonRow = () => ( + + + + + + + + + + + + + + + + + +); diff --git a/src/components/pages/zcash/ZcashCells.tsx b/src/components/pages/zcash/ZcashCells.tsx index 546a2789..9f1b9c55 100644 --- a/src/components/pages/zcash/ZcashCells.tsx +++ b/src/components/pages/zcash/ZcashCells.tsx @@ -1,16 +1,16 @@ import type React from "react"; import { useTranslation } from "react-i18next"; -import type { ZcashTransaction, ZcashTxKind } from "../../../types"; +import type { ZcashShieldedPool, ZcashTransaction, ZcashTxKind } from "../../../types"; import { formatZEC } from "../../../utils/zcashFormatters"; import { getTransparentOutputZat } from "../../../utils/zcashUtils"; -import { TX_KIND_LABEL_KEYS } from "./labels"; +import { TX_KIND_LABEL_KEYS, VALUE_POOL_LABEL_KEYS } from "./labels"; -type SkeletonWidth = 50 | 60 | 70 | 80 | 90 | 100 | 120 | 140; +type SkeletonWidth = 40 | 50 | 60 | 70 | 80 | 90 | 100 | 120 | 140; interface ZcashSkeletonProps { width: SkeletonWidth; /** Line height of the text the placeholder stands in for */ - size?: "small" | "text" | "stat"; + size?: "small" | "text" | "row" | "stat"; } /** @@ -46,3 +46,21 @@ export const ZcashOutputValue: React.FC = ({ transaction, {t("transactions.shieldedValue")} ); }; + +interface ZcashPoolChipProps { + pool: ZcashShieldedPool; + /** Chip text; the pool name by default */ + children?: React.ReactNode; +} + +/** + * A shielded pool tag, colored per pool + */ +export const ZcashPoolChip: React.FC = ({ pool, children }) => { + const { t } = useTranslation("zcash"); + return ( + + {children ?? t(VALUE_POOL_LABEL_KEYS[pool])} + + ); +}; diff --git a/src/config/zcashConstants.ts b/src/config/zcashConstants.ts index fef58065..79a8c958 100644 --- a/src/config/zcashConstants.ts +++ b/src/config/zcashConstants.ts @@ -37,6 +37,9 @@ export const MAX_INPUT_LOOKUPS = 10; // Backoff before retrying a rate-limited call (hosted gateways allow ~5 requests/min per IP) export const RATE_LIMIT_RETRY_DELAYS_MS = [15_000, 30_000]; +// Loaders wait out the whole retry window (15s + 30s plus request time) before offering a retry +export const LOADER_TIMEOUT_MS = 50_000; + // Dashboard sizing, kept small so a refresh fits within hosted rate limits export const DASHBOARD_BLOCKS = 5; export const DASHBOARD_TXS = 10; diff --git a/src/locales/en/zcash.json b/src/locales/en/zcash.json index 4e6b2f2b..c04e3052 100644 --- a/src/locales/en/zcash.json +++ b/src/locales/en/zcash.json @@ -51,7 +51,8 @@ }, "blocksPage": { "title": "{{network}} Blocks", - "showingLatest": "Showing the {{count}} most recent blocks", + "showingLatest": "Showing the most recent block", + "showingLatest_other": "Showing the {{count}} most recent blocks", "showingRange": "Showing blocks {{from}} – {{to}}", "height": "Height", "hash": "Hash", @@ -64,7 +65,9 @@ "newerTitle": "View newer blocks", "older": "Older →", "olderTitle": "View older blocks", - "loadError": "Couldn't load blocks: {{message}}" + "loadError": "Couldn't load blocks: {{message}}", + "unavailable": "Couldn't load this block", + "retryBlock": "Retry" }, "block": { "title": "Block", @@ -73,13 +76,18 @@ "notFound": "Block not found", "previousBlock": "Previous block", "nextBlock": "Next block", - "confirmations": "{{count}} Confirmations", + "confirmations": "{{count}} Confirmation", + "confirmations_other": "{{count}} Confirmations", + "confirmationsAtLeast": "{{count}}+ Confirmations", + "confirmationsAtLeast_other": "{{count}}+ Confirmations", "hash": "Block Hash:", "reward": "Block Reward:", + "shieldedReward": "({{amount}} paid into shielded pools)", "coinbaseOutputs": "Coinbase Outputs:", "noAddress": "Non-standard script", "transactions": "Transactions:", - "txCount": "{{count}} transactions", + "txCount": "{{count}} transaction", + "txCount_other": "{{count}} transactions", "poolTxCount": "{{count}} {{pool}}", "transparentOutput": "Transparent Output:", "difficulty": "Difficulty:", diff --git a/src/locales/es/zcash.json b/src/locales/es/zcash.json index f14ffcd7..391282f1 100644 --- a/src/locales/es/zcash.json +++ b/src/locales/es/zcash.json @@ -51,7 +51,8 @@ }, "blocksPage": { "title": "Bloques de {{network}}", - "showingLatest": "Mostrando los {{count}} bloques más recientes", + "showingLatest": "Mostrando el bloque más reciente", + "showingLatest_other": "Mostrando los {{count}} bloques más recientes", "showingRange": "Mostrando bloques {{from}} – {{to}}", "height": "Altura", "hash": "Hash", @@ -64,7 +65,9 @@ "newerTitle": "Ver bloques más recientes", "older": "Más antiguos →", "olderTitle": "Ver bloques más antiguos", - "loadError": "No se pudieron cargar los bloques: {{message}}" + "loadError": "No se pudieron cargar los bloques: {{message}}", + "unavailable": "No se pudo cargar este bloque", + "retryBlock": "Reintentar" }, "block": { "title": "Bloque", @@ -73,13 +76,18 @@ "notFound": "Bloque no encontrado", "previousBlock": "Bloque anterior", "nextBlock": "Bloque siguiente", - "confirmations": "{{count}} confirmaciones", + "confirmations": "{{count}} confirmación", + "confirmations_other": "{{count}} confirmaciones", + "confirmationsAtLeast": "{{count}}+ confirmaciones", + "confirmationsAtLeast_other": "{{count}}+ confirmaciones", "hash": "Hash del bloque:", "reward": "Recompensa del bloque:", + "shieldedReward": "({{amount}} pagados a pools blindados)", "coinbaseOutputs": "Salidas coinbase:", "noAddress": "Script no estándar", "transactions": "Transacciones:", - "txCount": "{{count}} transacciones", + "txCount": "{{count}} transacción", + "txCount_other": "{{count}} transacciones", "poolTxCount": "{{count}} {{pool}}", "transparentOutput": "Salida transparente:", "difficulty": "Dificultad:", diff --git a/src/locales/ja/zcash.json b/src/locales/ja/zcash.json index 94d64c0e..4617b4cf 100644 --- a/src/locales/ja/zcash.json +++ b/src/locales/ja/zcash.json @@ -52,6 +52,7 @@ "blocksPage": { "title": "{{network}} のブロック", "showingLatest": "最新 {{count}} 件のブロックを表示", + "showingLatest_other": "最新 {{count}} 件のブロックを表示", "showingRange": "ブロック {{from}} – {{to}} を表示", "height": "高さ", "hash": "ハッシュ", @@ -64,7 +65,9 @@ "newerTitle": "新しいブロックを表示", "older": "古い →", "olderTitle": "古いブロックを表示", - "loadError": "ブロックを読み込めませんでした: {{message}}" + "loadError": "ブロックを読み込めませんでした: {{message}}", + "unavailable": "このブロックを読み込めませんでした", + "retryBlock": "再試行" }, "block": { "title": "ブロック", @@ -74,12 +77,17 @@ "previousBlock": "前のブロック", "nextBlock": "次のブロック", "confirmations": "{{count}} 承認", + "confirmations_other": "{{count}} 承認", + "confirmationsAtLeast": "{{count}}+ 承認", + "confirmationsAtLeast_other": "{{count}}+ 承認", "hash": "ブロックハッシュ:", "reward": "ブロック報酬:", + "shieldedReward": "(うち {{amount}} はシールドプールへ)", "coinbaseOutputs": "コインベース出力:", "noAddress": "非標準スクリプト", "transactions": "トランザクション:", "txCount": "{{count}} 件のトランザクション", + "txCount_other": "{{count}} 件のトランザクション", "poolTxCount": "{{pool}} {{count}} 件", "transparentOutput": "トランスペアレント出力:", "difficulty": "難易度:", diff --git a/src/locales/pt-BR/zcash.json b/src/locales/pt-BR/zcash.json index 52b0f298..909f5b7f 100644 --- a/src/locales/pt-BR/zcash.json +++ b/src/locales/pt-BR/zcash.json @@ -51,7 +51,8 @@ }, "blocksPage": { "title": "Blocos de {{network}}", - "showingLatest": "Mostrando os {{count}} blocos mais recentes", + "showingLatest": "Mostrando o bloco mais recente", + "showingLatest_other": "Mostrando os {{count}} blocos mais recentes", "showingRange": "Mostrando blocos {{from}} – {{to}}", "height": "Altura", "hash": "Hash", @@ -64,7 +65,9 @@ "newerTitle": "Ver blocos mais novos", "older": "Mais antigos →", "olderTitle": "Ver blocos mais antigos", - "loadError": "Não foi possível carregar os blocos: {{message}}" + "loadError": "Não foi possível carregar os blocos: {{message}}", + "unavailable": "Não foi possível carregar este bloco", + "retryBlock": "Tentar novamente" }, "block": { "title": "Bloco", @@ -73,13 +76,18 @@ "notFound": "Bloco não encontrado", "previousBlock": "Bloco anterior", "nextBlock": "Próximo bloco", - "confirmations": "{{count}} confirmações", + "confirmations": "{{count}} confirmação", + "confirmations_other": "{{count}} confirmações", + "confirmationsAtLeast": "{{count}}+ confirmações", + "confirmationsAtLeast_other": "{{count}}+ confirmações", "hash": "Hash do bloco:", "reward": "Recompensa do bloco:", + "shieldedReward": "({{amount}} pagos a pools blindados)", "coinbaseOutputs": "Saídas coinbase:", "noAddress": "Script não padrão", "transactions": "Transações:", - "txCount": "{{count}} transações", + "txCount": "{{count}} transação", + "txCount_other": "{{count}} transações", "poolTxCount": "{{count}} {{pool}}", "transparentOutput": "Saída transparente:", "difficulty": "Dificuldade:", diff --git a/src/locales/zh/zcash.json b/src/locales/zh/zcash.json index d007fdc5..50f6f58a 100644 --- a/src/locales/zh/zcash.json +++ b/src/locales/zh/zcash.json @@ -52,6 +52,7 @@ "blocksPage": { "title": "{{network}} 区块", "showingLatest": "显示最近 {{count}} 个区块", + "showingLatest_other": "显示最近 {{count}} 个区块", "showingRange": "显示区块 {{from}} – {{to}}", "height": "高度", "hash": "哈希", @@ -64,7 +65,9 @@ "newerTitle": "查看较新的区块", "older": "较旧 →", "olderTitle": "查看较旧的区块", - "loadError": "无法加载区块: {{message}}" + "loadError": "无法加载区块: {{message}}", + "unavailable": "无法加载此区块", + "retryBlock": "重试" }, "block": { "title": "区块", @@ -74,12 +77,17 @@ "previousBlock": "上一个区块", "nextBlock": "下一个区块", "confirmations": "{{count}} 个确认", + "confirmations_other": "{{count}} 个确认", + "confirmationsAtLeast": "{{count}}+ 个确认", + "confirmationsAtLeast_other": "{{count}}+ 个确认", "hash": "区块哈希:", "reward": "区块奖励:", + "shieldedReward": "(其中 {{amount}} 进入屏蔽池)", "coinbaseOutputs": "Coinbase 输出:", "noAddress": "非标准脚本", "transactions": "交易:", "txCount": "{{count}} 笔交易", + "txCount_other": "{{count}} 笔交易", "poolTxCount": "{{pool}} {{count}} 笔", "transparentOutput": "透明输出:", "difficulty": "难度:", diff --git a/src/styles/components.css b/src/styles/components.css index cbe548ac..4f2bc696 100644 --- a/src/styles/components.css +++ b/src/styles/components.css @@ -6366,10 +6366,15 @@ button.tx-section-header-toggle { height: 14px; } +.zec-skeleton-row { + height: 18px; +} + .zec-skeleton-stat { height: 20px; } +.zec-skeleton-w40 { width: 40px; } .zec-skeleton-w50 { width: 50px; } .zec-skeleton-w60 { width: 60px; } .zec-skeleton-w70 { width: 70px; } @@ -6379,6 +6384,15 @@ button.tx-section-header-toggle { .zec-skeleton-w120 { width: 120px; } .zec-skeleton-w140 { width: 140px; } +.zec-retry-button { + background: none; + border: none; + padding: 0; + margin-left: 8px; + font: inherit; + cursor: pointer; +} + /* Zcash value pools */ .zec-value-pools { background: var(--bg-secondary);