Lumina node wasm
A compatibility layer for the Lumina
node to
work within a browser environment and be operable with javascript.
Changelog
You can find about the latest changes here.
Example
Starting lumina inside a dedicated worker
import from "lumina-node";
const node = await ;
const mainnetConfig = ;
await node.;
await node.;
await node.;
Manual setup
spawnNode
sets up a DedicatedWorker
instance and runs NodeWorker
there. If you want to set things up manually
you need to connect client and worker using objects that have MessagePort
interface.
import from "lumina-node";
const config = ;
// client and worker accept any object with MessagePort like interface e.g. Worker
const channel = ;
const worker = ;
// note that this runs lumina in the current context (and doesn't create a new web-worker). Promise created with `.run()` never completes.
const worker_promise = worker.;
// client port can be used locally or transferred like any plain MessagePort
const client = await ;
await client.;
await client.;
Rust API
For comprehensive and fully typed interface documentation, see lumina-node
and celestia-types documentation on docs.rs.
You can see there the exact structure of more complex types, such as ExtendedHeader
.
JavaScript API's goal is to provide similar interface to Rust when possible, e.g. NodeClient
mirrors Node
.