Skip to content

feat(zcash): add AI analysis for blocks, transactions and addresses - #413

Open
MatiasOS wants to merge 4 commits into
issue-398-zcash-addressfrom
issue-398-zcash-ai-analysis
Open

MatiasOS wants to merge 4 commits into
issue-398-zcash-addressfrom
issue-398-zcash-ai-analysis

Conversation

@MatiasOS

@MatiasOS MatiasOS commented Sep 14, 2026

Copy link
Copy Markdown
Member

Description

Adds AI analysis to the Zcash block, transaction and address pages. It's the last PR in the Zcash stack. The panel is the same AIAnalysisPanel the Bitcoin pages use, placed in the same spot.

Prompt rules, for both the power-user and regular-user configs:

  • Amounts are in ZEC.
  • Value balances are explained with their sign: positive means value left a shielded pool, negative means it entered one.
  • Shielded amounts, senders and recipients are never guessed.
  • Empty transparent inputs and outputs are not treated as errors.
  • No EVM terminology.
  • For addresses, a blocked address index is reported as data that couldn't be loaded, not as a zero balance.

Context sent to the model. Each page builds a compact context in aiContext.ts:

  • Amounts are converted from zatoshis, and every field name carries its unit (feeZEC, valueBalanceZEC, …).
  • Proofs, signatures, ciphertexts and the Equihash solution are left out.
  • A fee is only included when every transparent input value is known. Before input lookup, the model sees no fee instead of a wrong one.

Related Issue

Part of #398. Stacked on #412.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

  • AIAnalysisType gains zcash_transaction, zcash_block and zcash_address.
  • The worker's VALID_ANALYSIS_TYPES allowlist gains the same three types.
  • AIPromptTemplates.ts: Zcash configs in the power and regular maps, plus the buildPrompt cases.
  • src/components/pages/zcash/aiContext.ts builds the three contexts; unit tests are in aiContext.test.ts.
  • zatToZec added to zcashUtils.
  • AIAnalysisPanel added to ZcashBlockDisplay, ZcashTransactionDisplay and ZcashAddressDisplay, each wrapped in page-with-analysis. Cache keys follow the Bitcoin pattern, e.g. openscan_ai_zcash_block_${networkId}_${hash}.

Screenshots (if applicable)

Checked locally against mocked RPC data:

  • the block page
  • the Ironwood-only transaction, at desktop width and at 400px
  • a transparent address with the address index available

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors
  • I have run tests with npm run test:run
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

  • Most of the diff in the three display components is re-indentation from the new wrapper; git diff -w shows the real change.
  • The panel sends nothing until the user clicks Analyze, so it adds no RPC calls against the 5 req/min budget.
  • The worker allowlist also lacks the solana_* types. That's a pre-existing gap and out of scope here.
  • Metadata bump. METADATA_VERSION moves to 1.3.0-alpha.0, which is now published.
    • Compared with 1.2.1-alpha.0, it only adds three files: rpcs/zec/mainnet.json, rpcs/zec/testnet.json and the Zcash logo.
    • Zcash RPCs now also come from metadata. The Tatum URLs in BUILTIN_RPC_DEFAULTS stay as a first-load fallback and are de-duplicated.
    • The RPC cache is keyed by metadata version, so it refreshes on its own.
  • CI lockfile fix. bun.lock is regenerated with Bun 1.4.2, which fixes the "Build PR Preview" failure: lockfile had changes, but lockfile is frozen.
    • Cause: CI's setup-bun installs latest, now Bun 1.4. Bun 1.4 honours the nested overrides.vitest.vite rule, but the lockfile had been written by Bun 1.3, which ignored it.
    • Diff: lockfileVersion goes from 1 to 3 and the rule is added to the lockfile. No resolved versions change.
    • Bun requirement: Bun 1.3 can't read a v3 lockfile, so packageManager is now bun@1.4.2 and engines.bun is >=1.4.0. Run bun upgrade before installing locally.
  • Tests:
    • npm run test:run: 156 passing.
    • Hermetic Zcash e2e specs (dashboard, blocks, transactions, mempool, search, address): 20 passed.

@MatiasOS
MatiasOS added this pull request to stack #414 September 15, 2026 00:17
Bun 1.4 honours nested overrides and fails --frozen-lockfile when
bun.lock does not record them. The lockfile was written by Bun 1.3,
which ignored overrides.vitest.vite, so CI (setup-bun latest) broke.

Bun now writes lockfileVersion 3, which older Bun cannot read, so
packageManager and engines move to Bun 1.4. No resolved versions change.
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

🚀 Preview: https://pr-413--openscan.netlify.app
📝 Commit: 6c67dde62c9e06fa53e46f440d79f756c7fddfee

1.3.0-alpha.0 publishes the Zcash RPC lists (rpcs/zec/mainnet.json,
rpcs/zec/testnet.json) and the Zcash network logo, so the explorer now
loads both from metadata instead of falling back. It adds no other
files. The metadata RPC cache is keyed by version and refreshes itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant