lumina-node
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

lumina-node-wasm


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 { spawnNode, Network, NodeConfig } 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

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 { Network, NodeClient, NodeConfig, NodeWorker } from "lumina-node";

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.

Classes

lumina-node-wasm


lumina-node-wasm / AccAddress

Class: AccAddress

Address of an account.

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:138


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:133


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:137

lumina-node-wasm


lumina-node-wasm / AppVersion

Class: AppVersion

Version of the App

Properties

V1

readonly static V1: AppVersion

App v1

Defined in

lumina_node_wasm.d.ts:153


V2

readonly static V2: AppVersion

App v2

Defined in

lumina_node_wasm.d.ts:157


V3

readonly static V3: AppVersion

App v3

Defined in

lumina_node_wasm.d.ts:161


V4

readonly static V4: AppVersion

App v4

Defined in

lumina_node_wasm.d.ts:165

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:145


latest()

static latest(): AppVersion

Latest App version variant.

Returns

AppVersion

Defined in

lumina_node_wasm.d.ts:149

lumina-node-wasm


lumina-node-wasm / Blob

Class: Blob

Arbitrary data that can be stored in the network within certain [Namespace].

Constructors

new Blob()

new Blob(namespace, data, app_version): Blob

Create a new blob with the given data within the [Namespace].

Parameters
namespace

Namespace

data

Uint8Array<ArrayBuffer>

app_version

AppVersion

Returns

Blob

Defined in

lumina_node_wasm.d.ts:183

Properties

commitment

commitment: Commitment

A [Commitment] computed from the Blobs data.

Defined in

lumina_node_wasm.d.ts:203


data

data: Uint8Array<ArrayBuffer>

Data stored within the Blob.

Defined in

lumina_node_wasm.d.ts:195


namespace

namespace: Namespace

A [Namespace] the Blob belongs to.

Defined in

lumina_node_wasm.d.ts:191


share_version

share_version: number

Version indicating the format in which Shares should be created from this Blob.

Defined in

lumina_node_wasm.d.ts:199

Accessors

index

Get Signature

get index(): bigint

Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.

Returns

bigint

Set Signature

set index(value): void

Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.

Parameters

####### value

bigint

Returns

void

Defined in

lumina_node_wasm.d.ts:207


signer

Get Signature

get signer(): AccAddress

A signer of the blob, i.e. address of the account which submitted the blob.

Must be present in share_version 1 and absent otherwise.

Returns

AccAddress

Set Signature

set signer(value): void

A signer of the blob, i.e. address of the account which submitted the blob.

Must be present in share_version 1 and absent otherwise.

Parameters

####### value

AccAddress

Returns

void

Defined in

lumina_node_wasm.d.ts:217

Methods

clone()

clone(): Blob

Clone a blob creating a new deep copy of it.

Returns

Blob

Defined in

lumina_node_wasm.d.ts:187


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:179


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:174


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:178

lumina-node-wasm


lumina-node-wasm / BlockRange

Class: BlockRange

A range of blocks between start and end height, inclusive

Properties

end

end: bigint

Last block height in range

Defined in

lumina_node_wasm.d.ts:246


start

start: bigint

First block height in range

Defined in

lumina_node_wasm.d.ts:242

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:238


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:233


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:237

lumina-node-wasm


lumina-node-wasm / Commitment

Class: Commitment

A merkle hash used to identify the Blobs data.

In Celestia network, the transaction which pays for the blob's inclusion is separated from the data itself. The reason for that is to allow verifying the blockchain's state without the need to pull the actual data which got stored. To achieve that, the MsgPayForBlobs transaction only includes the [Commitment]s of the blobs it is paying for, not the data itself.

The algorithm of computing the [Commitment] of the Blob's Shares is designed in a way to allow easy and cheap proving of the Shares inclusion in the block. It is computed as a merkle hash of all the Nmt subtree roots created from the blob shares included in the ExtendedDataSquare rows. Assuming the s1 and s2 are the only shares of some blob posted to the celestia, they'll result in a single subtree root as shown below:

NMT:           row root
               /     \
             o   subtree root
            / \      / \
          _________________
EDS row: | s | s | s1 | s2 |

Using subtree roots as a base for [Commitment] computation allows for much smaller inclusion proofs than when the Shares would be used directly, but it imposes some constraints on how the Blobs can be placed in the ExtendedDataSquare. You can read more about that in the share commitment rules.

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:296


hash()

hash(): Uint8Array<ArrayBuffer>

Hash of the commitment

Returns

Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:300


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:291


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:295

lumina-node-wasm


lumina-node-wasm / ConnectionCountersSnapshot

Class: ConnectionCountersSnapshot

Properties

num_connections

num_connections: number

The total number of connections, both pending and established.

Defined in

lumina_node_wasm.d.ts:316


num_established

num_established: number

The number of outgoing connections being established.

Defined in

lumina_node_wasm.d.ts:332


num_established_incoming

num_established_incoming: number

The number of established incoming connections.

Defined in

lumina_node_wasm.d.ts:336


num_established_outgoing

num_established_outgoing: number

The number of established outgoing connections.

Defined in

lumina_node_wasm.d.ts:340


num_pending

num_pending: number

The total number of pending connections, both incoming and outgoing.

Defined in

lumina_node_wasm.d.ts:320


num_pending_incoming

num_pending_incoming: number

The total number of pending connections, both incoming and outgoing.

Defined in

lumina_node_wasm.d.ts:324


num_pending_outgoing

num_pending_outgoing: number

The number of outgoing connections being established.

Defined in

lumina_node_wasm.d.ts:328

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:312


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:307


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:311

lumina-node-wasm


lumina-node-wasm / ConsAddress

Class: ConsAddress

Address of a consensus node.

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:355


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:350


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:354

lumina-node-wasm


lumina-node-wasm / DataAvailabilityHeader

Class: DataAvailabilityHeader

Header with commitments of the data availability.

It consists of the root hashes of the merkle trees created from each row and column of the ExtendedDataSquare. Those are used to prove the inclusion of the data in a block.

The hash of this header is a hash of all rows and columns and thus a data commitment of the block.

Example

## use celestia_types::{ExtendedHeader, Height, Share};
## use celestia_types::nmt::{Namespace, NamespaceProof};
## fn extended_header() -> ExtendedHeader {
##     unimplemented!();
## }
## fn shares_with_proof(_: Height, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
##     unimplemented!();
## }
// fetch the block header and data for your namespace
let namespace = Namespace::new_v0(&[1, 2, 3, 4]).unwrap();
let eh = extended_header();
let (shares, proof) = shares_with_proof(eh.height(), &namespace);

// get the data commitment for a given row
let dah = eh.dah;
let root = dah.row_root(0).unwrap();

// verify a proof of the inclusion of the shares
assert!(proof.verify_complete_namespace(&root, &shares, *namespace).is_ok());

Methods

columnRoot()

columnRoot(column): any

Get the a root of the column with the given index.

Parameters
column

number

Returns

any

Defined in

lumina_node_wasm.d.ts:419


columnRoots()

columnRoots(): any[]

Merkle roots of the ExtendedDataSquare columns.

Returns

any[]

Defined in

lumina_node_wasm.d.ts:411


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:403


hash()

hash(): any

Compute the combined hash of all rows and columns.

This is the data commitment for the block.

Returns

any

Defined in

lumina_node_wasm.d.ts:425


rowRoot()

rowRoot(row): any

Get a root of the row with the given index.

Parameters
row

number

Returns

any

Defined in

lumina_node_wasm.d.ts:415


rowRoots()

rowRoots(): any[]

Merkle roots of the ExtendedDataSquare rows.

Returns

any[]

Defined in

lumina_node_wasm.d.ts:407


squareWidth()

squareWidth(): number

Get the size of the ExtendedDataSquare for which this header was built.

Returns

number

Defined in

lumina_node_wasm.d.ts:429


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:398


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:402

lumina-node-wasm


lumina-node-wasm / ExtendedHeader

Class: ExtendedHeader

Block header together with the relevant Data Availability metadata.

[ExtendedHeader]s are used to announce and describe the blocks in the Celestia network.

Before being used, each header should be validated and verified with a header you trust.

Example

## use celestia_types::ExtendedHeader;
## fn trusted_genesis_header() -> ExtendedHeader {
##     let s = include_str!("../test_data/chain1/extended_header_block_1.json");
##     serde_json::from_str(s).unwrap()
## }
## fn some_untrusted_header() -> ExtendedHeader {
##     let s = include_str!("../test_data/chain1/extended_header_block_27.json");
##     serde_json::from_str(s).unwrap()
## }
let genesis_header = trusted_genesis_header();

// fetch new header
let fetched_header = some_untrusted_header();

fetched_header.validate().expect("Invalid block header");
genesis_header.verify(&fetched_header).expect("Malicious header received");

Properties

commit

readonly commit: any

Commit metadata and signatures from validators committing the block.

Defined in

lumina_node_wasm.d.ts:560


dah

dah: DataAvailabilityHeader

Header of the block data availability.

Defined in

lumina_node_wasm.d.ts:552


header

readonly header: any

Tendermint block header.

Defined in

lumina_node_wasm.d.ts:556


validatorSet

readonly validatorSet: any

Information about the set of validators commiting the block.

Defined in

lumina_node_wasm.d.ts:564

Methods

clone()

clone(): ExtendedHeader

Clone a header producing a deep copy of it.

Returns

ExtendedHeader

Defined in

lumina_node_wasm.d.ts:474


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:470


hash()

hash(): string

Get the block hash.

Returns

string

Defined in

lumina_node_wasm.d.ts:486


height()

height(): bigint

Get the block height.

Returns

bigint

Defined in

lumina_node_wasm.d.ts:478


previousHeaderHash()

previousHeaderHash(): string

Get the hash of the previous header.

Returns

string

Defined in

lumina_node_wasm.d.ts:490


time()

time(): number

Get the block time.

Returns

number

Defined in

lumina_node_wasm.d.ts:482


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:465


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:469


validate()

validate(): void

Decode protobuf encoded header and then validate it.

Returns

void

Defined in

lumina_node_wasm.d.ts:494


verify()

verify(untrusted): void

Verify a chain of adjacent untrusted headers and make sure they are adjacent to self.

Errors

If verification fails, this function will return an error with a reason of failure. This function will also return an error if untrusted headers and self don't form contiguous range

Parameters
untrusted

ExtendedHeader

Returns

void

Defined in

lumina_node_wasm.d.ts:504


verifyAdjacentRange()

verifyAdjacentRange(untrusted): void

Verify a chain of adjacent untrusted headers and make sure they are adjacent to self.

Note

Provided headers will be consumed by this method, meaning they will no longer be accessible. If this behavior is not desired, consider using ExtendedHeader.clone().

const genesis = hdr0;
const headers = [hrd1, hdr2, hdr3];
genesis.verifyAdjacentRange(headers.map(h => h.clone()));

Errors

If verification fails, this function will return an error with a reason of failure. This function will also return an error if untrusted headers and self don't form contiguous range

Parameters
untrusted

ExtendedHeader[]

Returns

void

Defined in

lumina_node_wasm.d.ts:548


verifyRange()

verifyRange(untrusted): void

Verify a chain of adjacent untrusted headers.

Note

Provided headers will be consumed by this method, meaning they will no longer be accessible. If this behavior is not desired, consider using ExtendedHeader.clone().

const genesis = hdr0;
const headers = [hrd1, hdr2, hdr3];
genesis.verifyRange(headers.map(h => h.clone()));

Errors

If verification fails, this function will return an error with a reason of failure. This function will also return an error if untrusted headers are not adjacent to each other.

Parameters
untrusted

ExtendedHeader[]

Returns

void

Defined in

lumina_node_wasm.d.ts:526

lumina-node-wasm


lumina-node-wasm / IntoUnderlyingByteSource

Class: IntoUnderlyingByteSource

Properties

autoAllocateChunkSize

readonly autoAllocateChunkSize: number

Defined in

lumina_node_wasm.d.ts:573


type

readonly type: "bytes"

Defined in

lumina_node_wasm.d.ts:572

Methods

cancel()

cancel(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:571


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:568


pull()

pull(controller): Promise<any>

Parameters
controller

ReadableByteStreamController

Returns

Promise<any>

Defined in

lumina_node_wasm.d.ts:570


start()

start(controller): void

Parameters
controller

ReadableByteStreamController

Returns

void

Defined in

lumina_node_wasm.d.ts:569

lumina-node-wasm


lumina-node-wasm / IntoUnderlyingSink

Class: IntoUnderlyingSink

Methods

abort()

abort(reason): Promise<any>

Parameters
reason

any

Returns

Promise<any>

Defined in

lumina_node_wasm.d.ts:580


close()

close(): Promise<any>

Returns

Promise<any>

Defined in

lumina_node_wasm.d.ts:579


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:577


write()

write(chunk): Promise<any>

Parameters
chunk

any

Returns

Promise<any>

Defined in

lumina_node_wasm.d.ts:578

lumina-node-wasm


lumina-node-wasm / IntoUnderlyingSource

Class: IntoUnderlyingSource

Methods

cancel()

cancel(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:586


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:584


pull()

pull(controller): Promise<any>

Parameters
controller

ReadableStreamDefaultController<any>

Returns

Promise<any>

Defined in

lumina_node_wasm.d.ts:585

lumina-node-wasm


lumina-node-wasm / Namespace

Class: Namespace

Namespace of the data published to the celestia network.

The [Namespace] is a single byte defining the version followed by 28 bytes specifying concrete ID of the namespace.

Currently there are two versions of namespaces:

  • version 0 - the one allowing for the custom namespace ids. It requires an id to start with 18 0x00 bytes followed by a user specified suffix (except reserved ones, see below).
  • version 255 - for secondary reserved namespaces. It requires an id to start with 27 0xff bytes followed by a single byte indicating the id.

Some namespaces are reserved for the block creation purposes and cannot be used when submitting the blobs to celestia. Those fall into one of the two categories:

  • primary reserved namespaces - those use version 0 and have id lower or equal to 0xff so they are always placed in blocks before user-submitted data.
  • secondary reserved namespaces - those use version 0xff so they are always placed after user-submitted data.

Properties

id

readonly id: Uint8Array<ArrayBuffer>

Returns the trailing 28 bytes indicating the id of the [Namespace].

Defined in

lumina_node_wasm.d.ts:695


version

readonly version: number

Returns the first byte indicating the version of the [Namespace].

Defined in

lumina_node_wasm.d.ts:691


MAX_PRIMARY_RESERVED

readonly static MAX_PRIMARY_RESERVED: Namespace

Maximal primary reserved [Namespace].

Used to indicate the end of the primary reserved group.

Defined in

lumina_node_wasm.d.ts:666


MIN_SECONDARY_RESERVED

readonly static MIN_SECONDARY_RESERVED: Namespace

Minimal secondary reserved [Namespace].

Used to indicate the beginning of the secondary reserved group.

Defined in

lumina_node_wasm.d.ts:672


NS_SIZE

readonly static NS_SIZE: number

Namespace size in bytes.

Defined in

lumina_node_wasm.d.ts:645


PARITY_SHARE

readonly static PARITY_SHARE: Namespace

The [Namespace] for parity shares.

It is the namespace with which all the parity shares from ExtendedDataSquare are inserted to the Nmt when computing merkle roots.

Defined in

lumina_node_wasm.d.ts:687


PAY_FOR_BLOB

readonly static PAY_FOR_BLOB: Namespace

Primary reserved [Namespace] for the compact Shares with MsgPayForBlobs transactions.

Defined in

lumina_node_wasm.d.ts:653


PRIMARY_RESERVED_PADDING

readonly static PRIMARY_RESERVED_PADDING: Namespace

Primary reserved [Namespace] for the Shares used for padding.

Shares with this namespace are inserted after other shares from primary reserved namespace so that user-defined namespaces are correctly aligned in ExtendedDataSquare

Defined in

lumina_node_wasm.d.ts:660


TAIL_PADDING

readonly static TAIL_PADDING: Namespace

Secondary reserved [Namespace] used for padding after the blobs.

It is used to fill up the original data square after all user-submitted blobs before the parity data is generated for the ExtendedDataSquare.

Defined in

lumina_node_wasm.d.ts:679


TRANSACTION

readonly static TRANSACTION: Namespace

Primary reserved [Namespace] for the compact Shares with cosmos SDK transactions.

Defined in

lumina_node_wasm.d.ts:649

Methods

asBytes()

asBytes(): Uint8Array<ArrayBuffer>

Converts the [Namespace] to a byte slice.

Returns

Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:641


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:619


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:614


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:618


fromRaw()

static fromRaw(raw): Namespace

Create a new [Namespace] from the raw bytes.

Errors

This function will return an error if the slice length is different than [NS_SIZE] or if the namespace is invalid. If you are constructing the version 0 namespace, check [newV0].

Parameters
raw

Uint8Array<ArrayBuffer>

Returns

Namespace

Defined in

lumina_node_wasm.d.ts:637


newV0()

static newV0(id): Namespace

Create a new [Namespace] version 0 with given id.

Check Namespace::new_v0 for more details.

Parameters
id

Uint8Array<ArrayBuffer>

Returns

Namespace

Defined in

lumina_node_wasm.d.ts:627

lumina-node-wasm


lumina-node-wasm / NetworkInfoSnapshot

Class: NetworkInfoSnapshot

Information about the connections

Properties

connection_counters

connection_counters: ConnectionCountersSnapshot

Gets counters for ongoing network connections.

Defined in

lumina_node_wasm.d.ts:718


num_peers

num_peers: number

The number of connected peers, i.e. peers with whom at least one established connection exists.

Defined in

lumina_node_wasm.d.ts:714

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:710


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:705


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:709

lumina-node-wasm


lumina-node-wasm / NodeClient

Class: NodeClient

NodeClient is responsible for steering NodeWorker by sending it commands and receiving responses over the provided port.

Constructors

new NodeClient()

new NodeClient(port): NodeClient

Create a new connection to a Lumina node running in NodeWorker. Provided port is expected to have MessagePort-like interface for sending and receiving messages.

Parameters
port

any

Returns

NodeClient

Defined in

lumina_node_wasm.d.ts:732

Methods

addConnectionToWorker()

addConnectionToWorker(port): Promise<void>

Establish a new connection to the existing worker over provided port

Parameters
port

any

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:736


connectedPeers()

connectedPeers(): Promise<any[]>

Get all the peers that node is connected to.

Returns

Promise<any[]>

Defined in

lumina_node_wasm.d.ts:773


eventsChannel()

eventsChannel(): Promise<BroadcastChannel>

Returns a [BroadcastChannel] for events generated by [Node].

Returns

Promise<BroadcastChannel>

Defined in

lumina_node_wasm.d.ts:840


free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:727


getHeaderByHash()

getHeaderByHash(hash): Promise<ExtendedHeader>

Get a synced header for the block with a given hash.

Parameters
hash

string

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:816


getHeaderByHeight()

getHeaderByHeight(height): Promise<ExtendedHeader>

Get a synced header for the block with a given height.

Parameters
height

bigint

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:820


getHeaders()

getHeaders(start_height?, end_height?): Promise<ExtendedHeader[]>

Get synced headers from the given heights range.

If start of the range is undefined (None), the first returned header will be of height 1. If end of the range is undefined (None), the last returned header will be the last header in the store.

Errors

If range contains a height of a header that is not found in the store.

Parameters
start_height?

bigint

end_height?

bigint

Returns

Promise<ExtendedHeader[]>

Defined in

lumina_node_wasm.d.ts:832


getLocalHeadHeader()

getLocalHeadHeader(): Promise<ExtendedHeader>

Get the latest locally synced header.

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:812


getNetworkHeadHeader()

getNetworkHeadHeader(): Promise<ExtendedHeader>

Get the latest header announced in the network.

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:808


getSamplingMetadata()

getSamplingMetadata(height): Promise<SamplingMetadata>

Get data sampling metadata of an already sampled height.

Parameters
height

bigint

Returns

Promise<SamplingMetadata>

Defined in

lumina_node_wasm.d.ts:836


isRunning()

isRunning(): Promise<boolean>

Check whether Lumina is currently running

Returns

Promise<boolean>

Defined in

lumina_node_wasm.d.ts:740


listeners()

listeners(): Promise<any[]>

Get all the multiaddresses on which the node listens.

Returns

Promise<any[]>

Defined in

lumina_node_wasm.d.ts:769


localPeerId()

localPeerId(): Promise<string>

Get node's local peer ID.

Returns

Promise<string>

Defined in

lumina_node_wasm.d.ts:749


networkInfo()

networkInfo(): Promise<NetworkInfoSnapshot>

Get current network info.

Returns

Promise<NetworkInfoSnapshot>

Defined in

lumina_node_wasm.d.ts:765


peerTrackerInfo()

peerTrackerInfo(): Promise<PeerTrackerInfoSnapshot>

Get current [PeerTracker] info.

Returns

Promise<PeerTrackerInfoSnapshot>

Defined in

lumina_node_wasm.d.ts:753


requestAllBlobs()

requestAllBlobs(namespace, block_height, timeout_secs?): Promise<Blob[]>

Request all blobs with provided namespace in the block corresponding to this header using bitswap protocol.

Parameters
namespace

Namespace

block_height

bigint

timeout_secs?

number

Returns

Promise<Blob[]>

Defined in

lumina_node_wasm.d.ts:800


requestHeaderByHash()

requestHeaderByHash(hash): Promise<ExtendedHeader>

Request a header for the block with a given hash from the network.

Parameters
hash

string

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:785


requestHeaderByHeight()

requestHeaderByHeight(height): Promise<ExtendedHeader>

Request a header for the block with a given height from the network.

Parameters
height

bigint

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:789


requestHeadHeader()

requestHeadHeader(): Promise<ExtendedHeader>

Request the head header from the network.

Returns

Promise<ExtendedHeader>

Defined in

lumina_node_wasm.d.ts:781


requestVerifiedHeaders()

requestVerifiedHeaders(from, amount): Promise<ExtendedHeader[]>

Request headers in range (from, from + amount] from the network.

The headers will be verified with the from header.

Parameters
from

ExtendedHeader

amount

bigint

Returns

Promise<ExtendedHeader[]>

Defined in

lumina_node_wasm.d.ts:795


setPeerTrust()

setPeerTrust(peer_id, is_trusted): Promise<void>

Trust or untrust the peer with a given ID.

Parameters
peer_id

string

is_trusted

boolean

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:777


start()

start(config): Promise<void>

Start a node with the provided config, if it's not running

Parameters
config

NodeConfig

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:744


stop()

stop(): Promise<void>

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:745


syncerInfo()

syncerInfo(): Promise<SyncingInfoSnapshot>

Get current header syncing info.

Returns

Promise<SyncingInfoSnapshot>

Defined in

lumina_node_wasm.d.ts:804


waitConnected()

waitConnected(): Promise<void>

Wait until the node is connected to at least 1 peer.

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:757


waitConnectedTrusted()

waitConnectedTrusted(): Promise<void>

Wait until the node is connected to at least 1 trusted peer.

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:761

lumina-node-wasm


lumina-node-wasm / NodeConfig

Class: NodeConfig

Config for the lumina wasm node.

Properties

bootnodes

bootnodes: string[]

A list of bootstrap peers to connect to.

Defined in

lumina_node_wasm.d.ts:867


network

network: Network

A network to connect to.

Defined in

lumina_node_wasm.d.ts:863


usePersistentMemory

usePersistentMemory: boolean

Whether to store data in persistent memory or not.

Default value: true

Defined in

lumina_node_wasm.d.ts:873

Accessors

customPruningWindowSecs

Get Signature

get customPruningWindowSecs(): number

Pruning window defines maximum age of a block for it to be retained in store.

If pruning window is smaller than sampling window, then blocks will be pruned right after they are sampled. This is useful when you want to keep low memory footprint but still validate the blockchain.

If this is not set, then default value will apply:

  • If use_persistent_memory == true, default value is 30 days plus 1 hour.
  • If use_persistent_memory == false, default value is 0 seconds.
Returns

number

Set Signature

set customPruningWindowSecs(value): void

Pruning window defines maximum age of a block for it to be retained in store.

If pruning window is smaller than sampling window, then blocks will be pruned right after they are sampled. This is useful when you want to keep low memory footprint but still validate the blockchain.

If this is not set, then default value will apply:

  • If use_persistent_memory == true, default value is 30 days plus 1 hour.
  • If use_persistent_memory == false, default value is 0 seconds.
Parameters

####### value

number

Returns

void

Defined in

lumina_node_wasm.d.ts:900


customSamplingWindowSecs

Get Signature

get customSamplingWindowSecs(): number

Sampling window defines maximum age of a block considered for syncing and sampling.

Default value: 2592000 seconds (30 days)
Minimum: 60 seconds

Returns

number

Set Signature

set customSamplingWindowSecs(value): void

Sampling window defines maximum age of a block considered for syncing and sampling.

Default value: 2592000 seconds (30 days)
Minimum: 60 seconds

Parameters

####### value

number

Returns

void

Defined in

lumina_node_wasm.d.ts:880

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:855


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:850


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:854


default()

static default(network): NodeConfig

Get the configuration with default bootnodes for provided network

Parameters
network

Network

Returns

NodeConfig

Defined in

lumina_node_wasm.d.ts:859

lumina-node-wasm


lumina-node-wasm / NodeWorker

Class: NodeWorker

NodeWorker is responsible for receiving commands from connected NodeClients, executing them and sending a response back, as well as accepting new NodeClient connections.

Constructors

new NodeWorker()

new NodeWorker(port_like_object): NodeWorker

Parameters
port_like_object

any

Returns

NodeWorker

Defined in

lumina_node_wasm.d.ts:923

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:922


run()

run(): Promise<void>

Returns

Promise<void>

Defined in

lumina_node_wasm.d.ts:924

lumina-node-wasm


lumina-node-wasm / PeerTrackerInfoSnapshot

Class: PeerTrackerInfoSnapshot

Statistics of the connected peers

Properties

num_connected_peers

num_connected_peers: bigint

Number of the connected peers.

Defined in

lumina_node_wasm.d.ts:943


num_connected_trusted_peers

num_connected_trusted_peers: bigint

Number of the connected trusted peers.

Defined in

lumina_node_wasm.d.ts:947

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:939


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:934


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:938

lumina-node-wasm


lumina-node-wasm / SamplingMetadata

Class: SamplingMetadata

Sampling metadata for a block.

This struct persists DAS-ing information in a header store for future reference.

Properties

cids

readonly cids: Uint8Array<ArrayBuffer>[]

Return Array of cids

Defined in

lumina_node_wasm.d.ts:960

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:956

lumina-node-wasm


lumina-node-wasm / SyncingInfoSnapshot

Class: SyncingInfoSnapshot

Status of the synchronization.

Properties

stored_headers

stored_headers: BlockRange[]

Ranges of headers that are already synchronised

Defined in

lumina_node_wasm.d.ts:979


subjective_head

subjective_head: bigint

Syncing target. The latest height seen in the network that was successfully verified.

Defined in

lumina_node_wasm.d.ts:983

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:975


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:970


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:974

lumina-node-wasm


lumina-node-wasm / TxClient

Class: TxClient

Celestia grpc transaction client.

Constructors

new TxClient()

new TxClient(url, bech32_address, pubkey, signer_fn): TxClient

Create a new transaction client with the specified account.

Url must point to a grpc-web proxy.

Example with noble/curves

import { secp256k1 } from "@noble/curves/secp256k1";

const address = "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm";
const privKey = "fdc8ac75dfa1c142dbcba77938a14dd03078052ce0b49a529dcf72a9885a3abb";
const pubKey = secp256k1.getPublicKey(privKey);

const signer = (signDoc) => {
  const bytes = protoEncodeSignDoc(signDoc);
  const sig = secp256k1.sign(bytes, privKey, { prehash: true });
  return sig.toCompactRawBytes();
};

const txClient = await new TxClient("http://127.0.0.1:18080", address, pubKey, signer);

Example with leap wallet

await window.leap.enable("mocha-4")
const keys = await window.leap.getKey("mocha-4")

const signer = (signDoc) => {
  return window.leap.signDirect("mocha-4", keys.bech32Address, signDoc, { preferNoSetFee: true })
    .then(sig => Uint8Array.from(atob(sig.signature.signature), c => c.charCodeAt(0)))
}

const tx_client = await new TxClient("http://127.0.0.1:18080", keys.bech32Address, keys.pubKey, signer)
Parameters
url

string

bech32_address

string

pubkey

Uint8Array<ArrayBuffer>

signer_fn

SignerFn

Returns

TxClient

Defined in

lumina_node_wasm.d.ts:1025

Properties

appVersion

readonly appVersion: AppVersion

AppVersion of the client

Defined in

lumina_node_wasm.d.ts:1120


chainId

readonly chainId: string

Chain id of the client

Defined in

lumina_node_wasm.d.ts:1116

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:989


getAccount()

getAccount(account): Promise<BaseAccount>

Get account

Parameters
account

string

Returns

Promise<BaseAccount>

Defined in

lumina_node_wasm.d.ts:1092


getAccounts()

getAccounts(): Promise<BaseAccount[]>

Get accounts

Returns

Promise<BaseAccount[]>

Defined in

lumina_node_wasm.d.ts:1096


getAllBalances()

getAllBalances(address): Promise<Coin[]>

Get balance of all coins

Parameters
address

string

Returns

Promise<Coin[]>

Defined in

lumina_node_wasm.d.ts:1104


getAuthParams()

getAuthParams(): Promise<AuthParams>

Get auth params

Returns

Promise<AuthParams>

Defined in

lumina_node_wasm.d.ts:1088


getBalance()

getBalance(address, denom): Promise<Coin>

Get balance of coins with given denom

Parameters
address

string

denom

string

Returns

Promise<Coin>

Defined in

lumina_node_wasm.d.ts:1100


getSpendableBalances()

getSpendableBalances(address): Promise<Coin[]>

Get balance of all spendable coins

Parameters
address

string

Returns

Promise<Coin[]>

Defined in

lumina_node_wasm.d.ts:1108


getTotalSupply()

getTotalSupply(): Promise<Coin[]>

Get total supply

Returns

Promise<Coin[]>

Defined in

lumina_node_wasm.d.ts:1112


lastSeenGasPrice()

lastSeenGasPrice(): number

Last gas price fetched by the client

Returns

number

Defined in

lumina_node_wasm.d.ts:1029


submitBlobs()

submitBlobs(blobs, tx_config?): Promise<TxInfo>

Submit blobs to the celestia network.

When no TxConfig is provided, client will automatically calculate needed gas and update the gasPrice, if network agreed on a new minimal value. To enforce specific values use a TxConfig.

Example

const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
const data = new Uint8Array([100, 97, 116, 97]);
const blob = new Blob(ns, data, AppVersion.latest());

const txInfo = await txClient.submitBlobs([blob]);
await txClient.submitBlobs([blob], { gasLimit: 100000n, gasPrice: 0.02, memo: "foo" });

Note

Provided blobs will be consumed by this method, meaning they will no longer be accessible. If this behavior is not desired, consider using Blob.clone().

const blobs = [blob1, blob2, blob3];
await txClient.submitBlobs(blobs.map(b => b.clone()));
Parameters
blobs

Blob[]

tx_config?

TxConfig

Returns

Promise<TxInfo>

Defined in

lumina_node_wasm.d.ts:1058


submitMessage()

submitMessage(message, tx_config?): Promise<TxInfo>

Submit message to the celestia network.

When no TxConfig is provided, client will automatically calculate needed gas and update the gasPrice, if network agreed on a new minimal value. To enforce specific values use a TxConfig.

Example

import { Registry } from "@cosmjs/proto-signing";

const registry = new Registry();
const sendMsg = {
  typeUrl: "/cosmos.bank.v1beta1.MsgSend",
  value: {
    fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
    toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
    amount: [{ denom: "utia", amount: "10000" }],
  },
};
const sendMsgAny = registry.encodeAsAny(sendMsg);

const txInfo = await txClient.submitMessage(sendMsgAny);
Parameters
message

ProtoAny

tx_config?

TxConfig

Returns

Promise<TxInfo>

Defined in

lumina_node_wasm.d.ts:1084

lumina-node-wasm


lumina-node-wasm / ValAddress

Class: ValAddress

Address of a validator.

Methods

free()

free(): void

Returns

void

Defined in

lumina_node_wasm.d.ts:1135


toJSON()

toJSON(): Object

  • Return copy of self without private attributes.
Returns

Object

Defined in

lumina_node_wasm.d.ts:1130


toString()

toString(): string

Return stringified version of self.

Returns

string

Defined in

lumina_node_wasm.d.ts:1134

Enumerations

lumina-node-wasm


lumina-node-wasm / Network

Enumeration: Network

Supported Celestia networks.

Enumeration Members

Arabica

Arabica: 1

Arabica testnet.

Defined in

lumina_node_wasm.d.ts:22


Mainnet

Mainnet: 0

Celestia mainnet.

Defined in

lumina_node_wasm.d.ts:18


Mocha

Mocha: 2

Mocha testnet.

Defined in

lumina_node_wasm.d.ts:26


Private

Private: 3

Private local network.

Defined in

lumina_node_wasm.d.ts:30

Functions

lumina-node-wasm


lumina-node-wasm / protoEncodeSignDoc

Function: protoEncodeSignDoc()

protoEncodeSignDoc(sign_doc): Uint8Array

A helper to encode the SignDoc with protobuf to get bytes to sign directly.

Parameters

sign_doc

SignDoc

Returns

Uint8Array

Defined in

lumina_node_wasm.d.ts:10

lumina-node-wasm


lumina-node-wasm / setup_logging

Function: setup_logging()

setup_logging(): void

Set up a logging layer that direct logs to the browser's console.

Returns

void

Defined in

lumina_node_wasm.d.ts:6

lumina-node-wasm


lumina-node-wasm

Enumerations

Classes

Interfaces

Type Aliases

Functions

Interfaces

lumina-node-wasm


lumina-node-wasm / AuthParams

Interface: AuthParams

Auth module parameters

Properties

maxMemoCharacters

maxMemoCharacters: bigint

Defined in

lumina_node_wasm.d.ts:80


sigVerifyCostEd25519

sigVerifyCostEd25519: bigint

Defined in

lumina_node_wasm.d.ts:83


sigVerifyCostSecp256k1

sigVerifyCostSecp256k1: bigint

Defined in

lumina_node_wasm.d.ts:84


txSigLimit

txSigLimit: bigint

Defined in

lumina_node_wasm.d.ts:81


txSizeCostPerByte

txSizeCostPerByte: bigint

Defined in

lumina_node_wasm.d.ts:82

lumina-node-wasm


lumina-node-wasm / BaseAccount

Interface: BaseAccount

Common data of all account types

Properties

accountNumber

accountNumber: bigint

Defined in

lumina_node_wasm.d.ts:72


address

address: string

Defined in

lumina_node_wasm.d.ts:70


pubkey?

optional pubkey: PublicKey

Defined in

lumina_node_wasm.d.ts:71


sequence

sequence: bigint

Defined in

lumina_node_wasm.d.ts:73

lumina-node-wasm


lumina-node-wasm / Coin

Interface: Coin

Coin

Properties

amount

amount: bigint

Defined in

lumina_node_wasm.d.ts:94


denom

denom: string

Defined in

lumina_node_wasm.d.ts:93

lumina-node-wasm


lumina-node-wasm / ProtoAny

Interface: ProtoAny

Protobuf Any type

Properties

typeUrl

typeUrl: string

Defined in

lumina_node_wasm.d.ts:120


value

value: Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:121

lumina-node-wasm


lumina-node-wasm / PublicKey

Interface: PublicKey

Public key

Properties

type

type: "ed25519" | "secp256k1"

Defined in

lumina_node_wasm.d.ts:62


value

value: Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:63

lumina-node-wasm


lumina-node-wasm / SignDoc

Interface: SignDoc

A payload to be signed

Properties

accountNumber

accountNumber: bigint

Defined in

lumina_node_wasm.d.ts:106


authInfoBytes

authInfoBytes: Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:104


bodyBytes

bodyBytes: Uint8Array<ArrayBuffer>

Defined in

lumina_node_wasm.d.ts:103


chainId

chainId: string

Defined in

lumina_node_wasm.d.ts:105

lumina-node-wasm


lumina-node-wasm / TxConfig

Interface: TxConfig

Transaction config.

Properties

gasLimit?

optional gasLimit: bigint

Defined in

lumina_node_wasm.d.ts:51


gasPrice?

optional gasPrice: number

Defined in

lumina_node_wasm.d.ts:52


memo?

optional memo: string

Defined in

lumina_node_wasm.d.ts:53

lumina-node-wasm


lumina-node-wasm / TxInfo

Interface: TxInfo

Transaction info

Properties

hash

hash: string

Defined in

lumina_node_wasm.d.ts:43


height

height: bigint

Defined in

lumina_node_wasm.d.ts:44

Type Aliases

lumina-node-wasm


lumina-node-wasm / ReadableStreamType

Type Alias: ReadableStreamType

ReadableStreamType: "bytes"

The ReadableStreamType enum.

This API requires the following crate features to be activated: ReadableStreamType

Defined in

lumina_node_wasm.d.ts:37

lumina-node-wasm


lumina-node-wasm / SignerFn

Type Alias: SignerFn

SignerFn: (arg) => Uint8Array | (arg) => Promise<Uint8Array>

A function that produces a signature of a payload

Defined in

lumina_node_wasm.d.ts:112

Package Sidebar

Install

npm i lumina-node

Homepage

www.eiger.co

Weekly Downloads

19

Version

0.9.0

License

Apache-2.0

Unpacked Size

61.9 kB

Total Files

5

Last publish

Collaborators

  • eigerco