lumina-node-wasm

Crates.iolumina-node-wasm
lib.rslumina-node-wasm
version
sourcesrc
created_at2024-01-17 14:53:42.37413
updated_at2024-12-03 10:28:19.716295
descriptionBrowser compatibility layer for the Lumina node
homepagehttps://www.eiger.co
repositoryhttps://github.com/eigerco/lumina
max_upload_size
id1103061
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Eiger (eiger-releases)

documentation

README

Lumina node wasm

A compatibility layer for the Lumina node to work within a browser environment and be operable with javascript.

Example

Starting lumina inside a dedicated worker

import { spawnNode, NodeConfig, Network } from "lumina-node";

const node = await spawnNode();
const mainnetConfig = NodeConfig.default(Network.Mainnet);

await node.start(mainnetConfig);

await node.waitConnected();
await node.requestHeadHeader();

Manual setup

Note that spawnNode implicitly calls wasm initialisation code. If you want to set things up manually, make sure to call the default export before using any of the wasm functionality.

import init, { NodeConfig, Network } from "lumina-node";

await init();
const config = NodeConfig.default(Network.Mainnet);

// client and worker accept any object with MessagePort like interface e.g. Worker
const channel = new MessageChannel();
const worker = new NodeWorker(channel.port1);

// 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.run();

// client port can be used locally or transferred like any plain MessagePort
const client = await new NodeClient(channel.port2);
await client.waitConnected();
await client.requestHeadHeader();

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.

Commit count: 285

cargo fmt