lumina-node-wasm
A compatibility layer for the Lumina
node to
work within a browser environment and be operable with javascript.
You can find about the latest changes here.
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();
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();
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
.
lumina-node-wasm / AppVersion
Version of the App
readonly
static
V1:AppVersion
App v1
lumina_node_wasm.d.ts:154
readonly
static
V2:AppVersion
App v2
lumina_node_wasm.d.ts:158
readonly
static
V3:AppVersion
App v3
lumina_node_wasm.d.ts:162
free():
void
void
lumina_node_wasm.d.ts:146
static
latest():AppVersion
Latest App version variant.
lumina_node_wasm.d.ts:150
lumina-node-wasm / Blob
Arbitrary data that can be stored in the network within certain [Namespace
].
new Blob(
namespace
,data
,app_version
):Blob
Create a new blob with the given data within the [Namespace
].
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:180
commitment:
Commitment
A [Commitment
] computed from the Blob
s data.
lumina_node_wasm.d.ts:202
data:
Uint8Array
<ArrayBuffer
>
Data stored within the Blob
.
lumina_node_wasm.d.ts:192
namespace:
Namespace
A [Namespace
] the Blob
belongs to.
lumina_node_wasm.d.ts:188
share_version:
number
Version indicating the format in which Share
s should be created from this Blob
.
lumina_node_wasm.d.ts:198
get index():
bigint
Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.
bigint
set index(
value
):void
Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.
####### value
bigint
void
lumina_node_wasm.d.ts:206
clone():
Blob
Clone a blob creating a new deep copy of it.
lumina_node_wasm.d.ts:184
free():
void
void
lumina_node_wasm.d.ts:176
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:171
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:175
lumina-node-wasm / BlockRange
A range of blocks between start
and end
height, inclusive
end:
bigint
Last block height in range
lumina_node_wasm.d.ts:233
start:
bigint
First block height in range
lumina_node_wasm.d.ts:229
free():
void
void
lumina_node_wasm.d.ts:225
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:220
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:224
lumina-node-wasm / Commitment
A merkle hash used to identify the Blob
s 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 Share
s is
designed in a way to allow easy and cheap proving of the Share
s 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 Share
s would be used directly, but it imposes some
constraints on how the Blob
s can be placed in the ExtendedDataSquare
. You can
read more about that in the share commitment rules
.
free():
void
void
lumina_node_wasm.d.ts:283
hash():
Uint8Array
<ArrayBuffer
>
Hash of the commitment
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:287
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:278
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:282
lumina-node-wasm / ConnectionCountersSnapshot
num_connections:
number
The total number of connections, both pending and established.
lumina_node_wasm.d.ts:303
num_established:
number
The number of outgoing connections being established.
lumina_node_wasm.d.ts:319
num_established_incoming:
number
The number of established incoming connections.
lumina_node_wasm.d.ts:323
num_established_outgoing:
number
The number of established outgoing connections.
lumina_node_wasm.d.ts:327
num_pending:
number
The total number of pending connections, both incoming and outgoing.
lumina_node_wasm.d.ts:307
num_pending_incoming:
number
The total number of pending connections, both incoming and outgoing.
lumina_node_wasm.d.ts:311
num_pending_outgoing:
number
The number of outgoing connections being established.
lumina_node_wasm.d.ts:315
free():
void
void
lumina_node_wasm.d.ts:299
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:294
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:298
lumina-node-wasm / 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.
## 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());
columnRoot(
column
):any
Get the a root of the column with the given index.
number
any
lumina_node_wasm.d.ts:391
columnRoots():
any
[]
Merkle roots of the ExtendedDataSquare
columns.
any
[]
lumina_node_wasm.d.ts:383
free():
void
void
lumina_node_wasm.d.ts:375
hash():
any
Compute the combined hash of all rows and columns.
This is the data commitment for the block.
any
lumina_node_wasm.d.ts:397
rowRoot(
row
):any
Get a root of the row with the given index.
number
any
lumina_node_wasm.d.ts:387
rowRoots():
any
[]
Merkle roots of the ExtendedDataSquare
rows.
any
[]
lumina_node_wasm.d.ts:379
squareWidth():
number
Get the size of the ExtendedDataSquare
for which this header was built.
number
lumina_node_wasm.d.ts:401
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:370
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:374
lumina-node-wasm / 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.
## 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");
readonly
commit:any
Commit metadata and signatures from validators committing the block.
lumina_node_wasm.d.ts:532
Header of the block data availability.
lumina_node_wasm.d.ts:524
readonly
header:any
Tendermint block header.
lumina_node_wasm.d.ts:528
readonly
validatorSet:any
Information about the set of validators commiting the block.
lumina_node_wasm.d.ts:536
clone():
ExtendedHeader
Clone a header producing a deep copy of it.
lumina_node_wasm.d.ts:446
free():
void
void
lumina_node_wasm.d.ts:442
hash():
string
Get the block hash.
string
lumina_node_wasm.d.ts:458
height():
bigint
Get the block height.
bigint
lumina_node_wasm.d.ts:450
previousHeaderHash():
string
Get the hash of the previous header.
string
lumina_node_wasm.d.ts:462
time():
number
Get the block time.
number
lumina_node_wasm.d.ts:454
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:437
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:441
validate():
void
Decode protobuf encoded header and then validate it.
void
lumina_node_wasm.d.ts:466
verify(
untrusted
):void
Verify a chain of adjacent untrusted headers and make sure
they are adjacent to self
.
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
void
lumina_node_wasm.d.ts:476
verifyAdjacentRange(
untrusted
):void
Verify a chain of adjacent untrusted headers and make sure
they are adjacent to self
.
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()));
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
void
lumina_node_wasm.d.ts:520
verifyRange(
untrusted
):void
Verify a chain of adjacent untrusted headers.
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()));
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.
void
lumina_node_wasm.d.ts:498
lumina-node-wasm / IntoUnderlyingByteSource
readonly
autoAllocateChunkSize:number
lumina_node_wasm.d.ts:545
readonly
type:"bytes"
lumina_node_wasm.d.ts:544
cancel():
void
void
lumina_node_wasm.d.ts:543
free():
void
void
lumina_node_wasm.d.ts:540
pull(
controller
):Promise
<any
>
ReadableByteStreamController
Promise
<any
>
lumina_node_wasm.d.ts:542
start(
controller
):void
ReadableByteStreamController
void
lumina_node_wasm.d.ts:541
lumina-node-wasm / IntoUnderlyingSink
abort(
reason
):Promise
<any
>
any
Promise
<any
>
lumina_node_wasm.d.ts:552
close():
Promise
<any
>
Promise
<any
>
lumina_node_wasm.d.ts:551
free():
void
void
lumina_node_wasm.d.ts:549
write(
chunk
):Promise
<any
>
any
Promise
<any
>
lumina_node_wasm.d.ts:550
lumina-node-wasm / IntoUnderlyingSource
cancel():
void
void
lumina_node_wasm.d.ts:558
free():
void
void
lumina_node_wasm.d.ts:556
pull(
controller
):Promise
<any
>
ReadableStreamDefaultController
<any
>
Promise
<any
>
lumina_node_wasm.d.ts:557
lumina-node-wasm / 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 180x00
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 270xff
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 to0xff
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.
readonly
id:Uint8Array
<ArrayBuffer
>
Returns the trailing 28 bytes indicating the id of the [Namespace
].
lumina_node_wasm.d.ts:667
readonly
version:number
Returns the first byte indicating the version of the [Namespace
].
lumina_node_wasm.d.ts:663
readonly
static
MAX_PRIMARY_RESERVED:Namespace
Maximal primary reserved [Namespace
].
Used to indicate the end of the primary reserved group.
lumina_node_wasm.d.ts:638
readonly
static
MIN_SECONDARY_RESERVED:Namespace
Minimal secondary reserved [Namespace
].
Used to indicate the beginning of the secondary reserved group.
lumina_node_wasm.d.ts:644
readonly
static
NS_SIZE:number
Namespace size in bytes.
lumina_node_wasm.d.ts:617
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.
lumina_node_wasm.d.ts:659
readonly
static
PAY_FOR_BLOB:Namespace
Primary reserved [Namespace
] for the compact Shares with MsgPayForBlobs transactions.
lumina_node_wasm.d.ts:625
readonly
static
PRIMARY_RESERVED_PADDING:Namespace
Primary reserved [Namespace
] for the Share
s used for padding.
Share
s with this namespace are inserted after other shares from primary reserved namespace
so that user-defined namespaces are correctly aligned in ExtendedDataSquare
lumina_node_wasm.d.ts:632
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
.
lumina_node_wasm.d.ts:651
readonly
static
TRANSACTION:Namespace
Primary reserved [Namespace
] for the compact Share
s with cosmos SDK
transactions.
lumina_node_wasm.d.ts:621
asBytes():
Uint8Array
<ArrayBuffer
>
Converts the [Namespace
] to a byte slice.
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:613
free():
void
void
lumina_node_wasm.d.ts:591
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:586
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:590
static
fromRaw(raw
):Namespace
Create a new [Namespace
] from the raw bytes.
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
].
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:609
static
newV0(id
):Namespace
Create a new [Namespace
] version 0
with given id.
Check Namespace::new_v0
for more details.
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:599
lumina-node-wasm / NetworkInfoSnapshot
Information about the connections
connection_counters:
ConnectionCountersSnapshot
Gets counters for ongoing network connections.
lumina_node_wasm.d.ts:690
num_peers:
number
The number of connected peers, i.e. peers with whom at least one established connection exists.
lumina_node_wasm.d.ts:686
free():
void
void
lumina_node_wasm.d.ts:682
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:677
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:681
lumina-node-wasm / NodeClient
NodeClient
is responsible for steering NodeWorker
by sending it commands and receiving
responses over the provided port.
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.
any
lumina_node_wasm.d.ts:704
addConnectionToWorker(
port
):Promise
<void
>
Establish a new connection to the existing worker over provided port
any
Promise
<void
>
lumina_node_wasm.d.ts:708
connectedPeers():
Promise
<any
[]>
Get all the peers that node is connected to.
Promise
<any
[]>
lumina_node_wasm.d.ts:745
eventsChannel():
Promise
<BroadcastChannel
>
Returns a [BroadcastChannel
] for events generated by [Node
].
Promise
<BroadcastChannel
>
lumina_node_wasm.d.ts:812
free():
void
void
lumina_node_wasm.d.ts:699
getHeaderByHash(
hash
):Promise
<ExtendedHeader
>
Get a synced header for the block with a given hash.
string
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:788
getHeaderByHeight(
height
):Promise
<ExtendedHeader
>
Get a synced header for the block with a given height.
bigint
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:792
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.
If range contains a height of a header that is not found in the store.
bigint
bigint
Promise
<ExtendedHeader
[]>
lumina_node_wasm.d.ts:804
getLocalHeadHeader():
Promise
<ExtendedHeader
>
Get the latest locally synced header.
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:784
getNetworkHeadHeader():
Promise
<ExtendedHeader
>
Get the latest header announced in the network.
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:780
getSamplingMetadata(
height
):Promise
<SamplingMetadata
>
Get data sampling metadata of an already sampled height.
bigint
Promise
<SamplingMetadata
>
lumina_node_wasm.d.ts:808
isRunning():
Promise
<boolean
>
Check whether Lumina is currently running
Promise
<boolean
>
lumina_node_wasm.d.ts:712
listeners():
Promise
<any
[]>
Get all the multiaddresses on which the node listens.
Promise
<any
[]>
lumina_node_wasm.d.ts:741
localPeerId():
Promise
<string
>
Get node's local peer ID.
Promise
<string
>
lumina_node_wasm.d.ts:721
networkInfo():
Promise
<NetworkInfoSnapshot
>
Get current network info.
Promise
<NetworkInfoSnapshot
>
lumina_node_wasm.d.ts:737
peerTrackerInfo():
Promise
<PeerTrackerInfoSnapshot
>
Get current [PeerTracker
] info.
Promise
<PeerTrackerInfoSnapshot
>
lumina_node_wasm.d.ts:725
requestAllBlobs(
header
,namespace
,timeout_secs
?):Promise
<Blob
[]>
Request all blobs with provided namespace in the block corresponding to this header using bitswap protocol.
number
Promise
<Blob
[]>
lumina_node_wasm.d.ts:772
requestHeaderByHash(
hash
):Promise
<ExtendedHeader
>
Request a header for the block with a given hash from the network.
string
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:757
requestHeaderByHeight(
height
):Promise
<ExtendedHeader
>
Request a header for the block with a given height from the network.
bigint
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:761
requestHeadHeader():
Promise
<ExtendedHeader
>
Request the head header from the network.
Promise
<ExtendedHeader
>
lumina_node_wasm.d.ts:753
requestVerifiedHeaders(
from
,amount
):Promise
<ExtendedHeader
[]>
Request headers in range (from, from + amount] from the network.
The headers will be verified with the from
header.
bigint
Promise
<ExtendedHeader
[]>
lumina_node_wasm.d.ts:767
setPeerTrust(
peer_id
,is_trusted
):Promise
<void
>
Trust or untrust the peer with a given ID.
string
boolean
Promise
<void
>
lumina_node_wasm.d.ts:749
start(
config
):Promise
<void
>
Start a node with the provided config, if it's not running
Promise
<void
>
lumina_node_wasm.d.ts:716
stop():
Promise
<void
>
Promise
<void
>
lumina_node_wasm.d.ts:717
syncerInfo():
Promise
<SyncingInfoSnapshot
>
Get current header syncing info.
Promise
<SyncingInfoSnapshot
>
lumina_node_wasm.d.ts:776
waitConnected():
Promise
<void
>
Wait until the node is connected to at least 1 peer.
Promise
<void
>
lumina_node_wasm.d.ts:729
waitConnectedTrusted():
Promise
<void
>
Wait until the node is connected to at least 1 trusted peer.
Promise
<void
>
lumina_node_wasm.d.ts:733
lumina-node-wasm / NodeConfig
Config for the lumina wasm node.
bootnodes:
string
[]
A list of bootstrap peers to connect to.
lumina_node_wasm.d.ts:839
network:
Network
A network to connect to.
lumina_node_wasm.d.ts:835
usePersistentMemory:
boolean
Whether to store data in persistent memory or not.
Default value: true
lumina_node_wasm.d.ts:845
get customPruningDelaySecs():
number
Pruning delay defines how much time the pruner should wait after sampling window in order to prune the block.
If this is not set, then default value will apply:
- If
use_persistent_memory == true
, default value is 1 hour. - If
use_persistent_memory == false
, default value is 60 seconds.
The minimum value that can be set is 60 seconds.
number
set customPruningDelaySecs(
value
):void
Pruning delay defines how much time the pruner should wait after sampling window in order to prune the block.
If this is not set, then default value will apply:
- If
use_persistent_memory == true
, default value is 1 hour. - If
use_persistent_memory == false
, default value is 60 seconds.
The minimum value that can be set is 60 seconds.
####### value
number
void
lumina_node_wasm.d.ts:879
get customSamplingWindowSecs():
number
Sampling window defines maximum age of a block considered for syncing and sampling.
If this is not set, then default value will apply:
- If
use_persistent_memory == true
, default value is 30 days. - If
use_persistent_memory == false
, default value is 60 seconds.
The minimum value that can be set is 60 seconds.
number
set customSamplingWindowSecs(
value
):void
Sampling window defines maximum age of a block considered for syncing and sampling.
If this is not set, then default value will apply:
- If
use_persistent_memory == true
, default value is 30 days. - If
use_persistent_memory == false
, default value is 60 seconds.
The minimum value that can be set is 60 seconds.
####### value
number
void
lumina_node_wasm.d.ts:856
free():
void
void
lumina_node_wasm.d.ts:827
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:822
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:826
static
default(network
):NodeConfig
Get the configuration with default bootnodes for provided network
lumina_node_wasm.d.ts:831
lumina-node-wasm / NodeWorker
NodeWorker
is responsible for receiving commands from connected NodeClient
s, executing
them and sending a response back, as well as accepting new NodeClient
connections.
new NodeWorker(
port_like_object
):NodeWorker
any
lumina_node_wasm.d.ts:901
free():
void
void
lumina_node_wasm.d.ts:900
run():
Promise
<void
>
Promise
<void
>
lumina_node_wasm.d.ts:902
lumina-node-wasm / PeerTrackerInfoSnapshot
Statistics of the connected peers
num_connected_peers:
bigint
Number of the connected peers.
lumina_node_wasm.d.ts:921
num_connected_trusted_peers:
bigint
Number of the connected trusted peers.
lumina_node_wasm.d.ts:925
free():
void
void
lumina_node_wasm.d.ts:917
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:912
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:916
lumina-node-wasm / SamplingMetadata
Sampling metadata for a block.
This struct persists DAS-ing information in a header store for future reference.
readonly
cids:Uint8Array
<ArrayBuffer
>[]
Return Array of cids
lumina_node_wasm.d.ts:942
status:
SamplingStatus
Indicates whether this node was able to successfuly sample the block
lumina_node_wasm.d.ts:938
free():
void
void
lumina_node_wasm.d.ts:934
lumina-node-wasm / SyncingInfoSnapshot
Status of the synchronization.
stored_headers:
BlockRange
[]
Ranges of headers that are already synchronised
lumina_node_wasm.d.ts:961
subjective_head:
bigint
Syncing target. The latest height seen in the network that was successfully verified.
lumina_node_wasm.d.ts:965
free():
void
void
lumina_node_wasm.d.ts:957
toJSON():
Object
- Return copy of self without private attributes.
Object
lumina_node_wasm.d.ts:952
toString():
string
Return stringified version of self.
string
lumina_node_wasm.d.ts:956
lumina-node-wasm / TxClient
Celestia grpc transaction client.
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.
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);
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)
string
string
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:1007
readonly
appVersion:AppVersion
AppVersion of the client
lumina_node_wasm.d.ts:1102
readonly
chainId:string
Chain id of the client
lumina_node_wasm.d.ts:1098
free():
void
void
lumina_node_wasm.d.ts:971
getAccount(
account
):Promise
<BaseAccount
>
Get account
string
Promise
<BaseAccount
>
lumina_node_wasm.d.ts:1074
getAccounts():
Promise
<BaseAccount
[]>
Get accounts
Promise
<BaseAccount
[]>
lumina_node_wasm.d.ts:1078
getAllBalances(
address
):Promise
<Coin
[]>
Get balance of all coins
string
Promise
<Coin
[]>
lumina_node_wasm.d.ts:1086
getAuthParams():
Promise
<AuthParams
>
Get auth params
Promise
<AuthParams
>
lumina_node_wasm.d.ts:1070
getBalance(
address
,denom
):Promise
<Coin
>
Get balance of coins with given denom
string
string
Promise
<Coin
>
lumina_node_wasm.d.ts:1082
getSpendableBalances(
address
):Promise
<Coin
[]>
Get balance of all spendable coins
string
Promise
<Coin
[]>
lumina_node_wasm.d.ts:1090
getTotalSupply():
Promise
<Coin
[]>
Get total supply
Promise
<Coin
[]>
lumina_node_wasm.d.ts:1094
lastSeenGasPrice():
number
Last gas price fetched by the client
number
lumina_node_wasm.d.ts:1011
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
.
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 });
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()));
Blob
[]
Promise
<TxInfo
>
lumina_node_wasm.d.ts:1040
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
.
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);
Promise
<TxInfo
>
lumina_node_wasm.d.ts:1066
lumina-node-wasm / Network
Supported Celestia networks.
Arabica:
1
Arabica testnet.
lumina_node_wasm.d.ts:22
Mainnet:
0
Celestia mainnet.
lumina_node_wasm.d.ts:18
Mocha:
2
Mocha testnet.
lumina_node_wasm.d.ts:26
Private:
3
Private local network.
lumina_node_wasm.d.ts:30
lumina-node-wasm / SamplingStatus
Sampling status for a block.
Accepted:
1
Sampling is done and block is accepted.
lumina_node_wasm.d.ts:43
Rejected:
2
Sampling is done and block is rejected.
lumina_node_wasm.d.ts:47
Unknown:
0
Sampling is not done.
lumina_node_wasm.d.ts:39
lumina-node-wasm / protoEncodeSignDoc
protoEncodeSignDoc(
sign_doc
):Uint8Array
A helper to encode the SignDoc with protobuf to get bytes to sign directly.
Uint8Array
lumina_node_wasm.d.ts:10
lumina-node-wasm / setup_logging
setup_logging():
void
Set up a logging layer that direct logs to the browser's console.
void
lumina_node_wasm.d.ts:6
- AppVersion
- Blob
- BlockRange
- Commitment
- ConnectionCountersSnapshot
- DataAvailabilityHeader
- ExtendedHeader
- IntoUnderlyingByteSource
- IntoUnderlyingSink
- IntoUnderlyingSource
- Namespace
- NetworkInfoSnapshot
- NodeClient
- NodeConfig
- NodeWorker
- PeerTrackerInfoSnapshot
- SamplingMetadata
- SyncingInfoSnapshot
- TxClient
lumina-node-wasm / AuthParams
Auth module parameters
maxMemoCharacters:
bigint
lumina_node_wasm.d.ts:88
sigVerifyCostEd25519:
bigint
lumina_node_wasm.d.ts:91
sigVerifyCostSecp256k1:
bigint
lumina_node_wasm.d.ts:92
txSigLimit:
bigint
lumina_node_wasm.d.ts:89
txSizeCostPerByte:
bigint
lumina_node_wasm.d.ts:90
lumina-node-wasm / BaseAccount
Common data of all account types
accountNumber:
bigint
lumina_node_wasm.d.ts:80
address:
string
lumina_node_wasm.d.ts:78
optional
pubkey:PublicKey
lumina_node_wasm.d.ts:79
sequence:
bigint
lumina_node_wasm.d.ts:81
lumina-node-wasm / Coin
Coin
amount:
bigint
lumina_node_wasm.d.ts:61
denom:
string
lumina_node_wasm.d.ts:60
lumina-node-wasm / ProtoAny
Protobuf Any type
typeUrl:
string
lumina_node_wasm.d.ts:118
value:
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:119
lumina-node-wasm / PublicKey
Public key
type:
"ed25519"
|"secp256k1"
lumina_node_wasm.d.ts:70
value:
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:71
lumina-node-wasm / SignDoc
A payload to be signed
accountNumber:
bigint
lumina_node_wasm.d.ts:104
authInfoBytes:
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:102
bodyBytes:
Uint8Array
<ArrayBuffer
>
lumina_node_wasm.d.ts:101
chainId:
string
lumina_node_wasm.d.ts:103
lumina-node-wasm / TxConfig
Transaction config.
optional
gasLimit:bigint
lumina_node_wasm.d.ts:136
optional
gasPrice:number
lumina_node_wasm.d.ts:137
lumina-node-wasm / TxInfo
Transaction info
hash:
string
lumina_node_wasm.d.ts:128
height:
bigint
lumina_node_wasm.d.ts:129
lumina-node-wasm / ReadableStreamType
ReadableStreamType:
"bytes"
The ReadableStreamType
enum.
This API requires the following crate features to be activated: ReadableStreamType
lumina_node_wasm.d.ts:54
lumina-node-wasm / SignerFn
SignerFn: (
arg
) =>Uint8Array
| (arg
) =>Promise
<Uint8Array
>
A function that produces a signature of a payload
lumina_node_wasm.d.ts:110