What problem does it solve?
Anarchy’s frontend needs reliable, repeatable patterns for connecting a Next.js App Router UI to the PAPI-based smoldot light client, dispatching chain extrinsics, running Wasm cryptography in Web Workers, and implementing stealth address/DM scanning without breaking SSR rules or leaking secrets.
Core Features & Use Cases
- PAPI + smoldot integration patterns: Use a single PAPI client singleton via
getUnsafeApi() to avoid @polkadot/api metadata/signature issues during the metadata v16 transition.
- Safe extrinsic + storage access: Handle runtime storage reads, runtime API calls (e.g., DM scan), and extrinsic submission with correct type conversions (notably
BigInt for u64/u128).
- Wasm-in-Workers cryptography workflow: Initialize
anarchy-wasm-engine in the main thread only when appropriate, then offload heavy crypto (KZG/SSS/DM encrypt-decrypt scanning) to a WorkerPool to keep the UI responsive.
- Stealth & DM scanning + state orchestration: Implement scanner flows with bounded block ranges, progress updates into Zustand stores, and session-only key management rules.
- i18n, SSR guards, and validation/state machine conventions: Standardize error mapping to i18n keys, prevent
window is not defined SSR crashes, and use explicit UI state machines for pending/confirmed flows.
Quick Start
Use frontend-patterns to implement a new Next.js page that initializes the PAPI smoldot client on the client side, calls the runtime DM scanner API, and runs Wasm cryptographic steps through the shared WorkerPool while streaming progress into the zustand store.