lumina-node-wasm
Version:
Browser compatibility layer for the Lumina node
2,023 lines (2,003 loc) • 65.9 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/**
* Set up a logging layer that direct logs to the browser's console.
*/
export function setup_logging(): void;
/**
* A helper to encode the SignDoc with protobuf to get bytes to sign directly.
*/
export function protoEncodeSignDoc(sign_doc: SignDoc): Uint8Array;
/**
* Attack type for the associated evidence
*/
export enum AttackType {
/**
* Duplicate vote
*/
DuplicateVote = 0,
/**
* LightClient attack
*/
LightClient = 1,
}
export enum CommitVoteType {
/**
* no vote was received from a validator.
*/
BlockIdFlagAbsent = 0,
/**
* voted for the Commit.BlockID.
*/
BlockIdFlagCommit = 1,
/**
* voted for nil
*/
BlockIdFlagNil = 2,
}
/**
* Error codes associated with transaction responses.
*/
export enum ErrorCode {
/**
* No error
*/
Success = 0,
/**
* Cannot parse a transaction
*/
TxDecode = 2,
/**
* Sequence number (nonce) is incorrect for the signature
*/
InvalidSequence = 3,
/**
* Request without sufficient authorization is handled
*/
Unauthorized = 4,
/**
* Account cannot pay requested amount
*/
InsufficientFunds = 5,
/**
* Request is unknown
*/
UnknownRequest = 6,
/**
* Address is invalid
*/
InvalidAddress = 7,
/**
* Pubkey is invalid
*/
InvalidPubKey = 8,
/**
* Address is unknown
*/
UnknownAddress = 9,
/**
* Coin is invalid
*/
InvalidCoins = 10,
/**
* Gas exceeded
*/
OutOfGas = 11,
/**
* Memo too large
*/
MemoTooLarge = 12,
/**
* Fee is insufficient
*/
InsufficientFee = 13,
/**
* Too many signatures
*/
TooManySignatures = 14,
/**
* No signatures in transaction
*/
NoSignatures = 15,
/**
* Error converting to json
*/
JSONMarshal = 16,
/**
* Error converting from json
*/
JSONUnmarshal = 17,
/**
* Request contains invalid data
*/
InvalidRequest = 18,
/**
* Tx already exists in the mempool
*/
TxInMempoolCache = 19,
/**
* Mempool is full
*/
MempoolIsFull = 20,
/**
* Tx is too large
*/
TxTooLarge = 21,
/**
* Key doesn't exist
*/
KeyNotFound = 22,
/**
* Key password is invalid
*/
WrongPassword = 23,
/**
* Tx intended signer does not match the given signer
*/
InvalidSigner = 24,
/**
* Invalid gas adjustment
*/
InvalidGasAdjustment = 25,
/**
* Invalid height
*/
InvalidHeight = 26,
/**
* Invalid version
*/
InvalidVersion = 27,
/**
* Chain-id is invalid
*/
InvalidChainID = 28,
/**
* Invalid type
*/
InvalidType = 29,
/**
* Tx rejected due to an explicitly set timeout height
*/
TxTimeoutHeight = 30,
/**
* Unknown extension options.
*/
UnknownExtensionOptions = 31,
/**
* Account sequence defined in the signer info doesn't match the account's actual sequence
*/
WrongSequence = 32,
/**
* Packing a protobuf message to Any failed
*/
PackAny = 33,
/**
* Unpacking a protobuf message from Any failed
*/
UnpackAny = 34,
/**
* Internal logic error, e.g. an invariant or assertion that is violated
*/
Logic = 35,
/**
* Conflict error, e.g. when two goroutines try to access the same resource and one of them fails
*/
Conflict = 36,
/**
* Called a branch of a code which is currently not supported
*/
NotSupported = 37,
/**
* Requested entity doesn't exist in the state
*/
NotFound = 38,
/**
* Internal errors caused by external operation
*/
IO = 39,
/**
* Min-gas-prices field in BaseConfig is empty
*/
AppConfig = 40,
/**
* Invalid GasWanted value is supplied
*/
InvalidGasLimit = 41,
/**
* Node recovered from panic
*/
Panic = 111222,
/**
* cannot use reserved namespace IDs
*/
ReservedNamespace = 11110,
/**
* invalid namespace length
*/
InvalidNamespaceLen = 11111,
/**
* data must be multiple of shareSize
*/
InvalidDataSize = 11112,
/**
* actual blob size differs from that specified in the MsgPayForBlob
*/
BlobSizeMismatch = 11113,
/**
* committed to invalid square size: must be power of two
*/
CommittedSquareSizeNotPowOf2 = 11114,
/**
* unexpected error calculating commitment for share
*/
CalculateCommitment = 11115,
/**
* invalid commitment for share
*/
InvalidShareCommitment = 11116,
/**
* cannot use parity shares namespace ID
*/
ParitySharesNamespace = 11117,
/**
* cannot use tail padding namespace ID
*/
TailPaddingNamespace = 11118,
/**
* cannot use transaction namespace ID
*/
TxNamespace = 11119,
/**
* invalid share commitments: all relevant square sizes must be committed to
*/
InvalidShareCommitments = 11122,
/**
* unsupported share version
*/
UnsupportedShareVersion = 11123,
/**
* cannot use zero blob size
*/
ZeroBlobSize = 11124,
/**
* mismatched number of blobs per MsgPayForBlob
*/
MismatchedNumberOfPFBorBlob = 11125,
/**
* no MsgPayForBlobs found in blob transaction
*/
NoPFB = 11126,
/**
* namespace of blob and its respective MsgPayForBlobs differ
*/
NamespaceMismatch = 11127,
/**
* failure to parse a transaction from its protobuf representation
*/
ProtoParsing = 11128,
/**
* not yet supported: multiple sdk.Msgs found in BlobTx
*/
MultipleMsgsInBlobTx = 11129,
/**
* number of each component in a MsgPayForBlobs must be identical
*/
MismatchedNumberOfPFBComponent = 11130,
/**
* no blobs provided
*/
NoBlobs = 11131,
/**
* no namespaces provided
*/
NoNamespaces = 11132,
/**
* no share versions provided
*/
NoShareVersions = 11133,
/**
* no blob sizes provided
*/
NoBlobSizes = 11134,
/**
* no share commitments provided
*/
NoShareCommitments = 11135,
/**
* invalid namespace
*/
InvalidNamespace = 11136,
/**
* invalid namespace version
*/
InvalidNamespaceVersion = 11137,
/**
* total blob size too large
*
* TotalBlobSize is deprecated, use BlobsTooLarge instead.
*/
TotalBlobSizeTooLarge = 11138,
/**
* blob(s) too large
*/
BlobsTooLarge = 11139,
/**
* invalid blob signer
*/
InvalidBlobSigner = 11140,
}
/**
* Supported Celestia networks.
*/
export enum Network {
/**
* Celestia mainnet.
*/
Mainnet = 0,
/**
* Arabica testnet.
*/
Arabica = 1,
/**
* Mocha testnet.
*/
Mocha = 2,
/**
* Private local network.
*/
Private = 3,
}
export enum SignatureMode {
Single = 0,
Multi = 1,
}
/**
* TxPriority is the priority level of the requested gas price.
*/
export enum TxPriority {
/**
* Estimated gas price is the value at the end of the lowest 10% of gas prices from the last 5 blocks.
*/
Low = 1,
/**
* Estimated gas price is the mean of all gas prices from the last 5 blocks.
*/
Medium = 2,
/**
* Estimated gas price is the price at the start of the top 10% of transactions’ gas prices from the last 5 blocks.
*/
High = 3,
}
/**
* Represents state of the transaction in the mempool
*/
export enum TxStatus {
/**
* The transaction is not known to the node, it could be never sent.
*/
Unknown = 0,
/**
* The transaction is still pending.
*/
Pending = 1,
/**
* The transaction was evicted from the mempool.
*/
Evicted = 2,
/**
* The transaction was committed into the block.
*/
Committed = 3,
}
/**
* Types of votes
*/
export enum VoteType {
/**
* Prevote
*/
Prevote = 0,
/**
* Precommit
*/
Precommit = 1,
}
/**
* The `ReadableStreamType` enum.
*
* *This API requires the following crate features to be activated: `ReadableStreamType`*
*/
type ReadableStreamType = "bytes";
/**
* Protobuf Any type
*/
export interface ProtoAny {
typeUrl: string;
value: Uint8Array;
}
/**
* Coin
*/
export interface Coin {
denom: string,
amount: bigint
}
/**
* Public key
*/
export interface PublicKey {
type: "ed25519" | "secp256k1",
value: Uint8Array
}
/**
* Common data of all account types
*/
export interface BaseAccount {
address: string,
pubkey?: PublicKey,
accountNumber: bigint,
sequence: bigint
}
/**
* Auth module parameters
*/
export interface AuthParams {
maxMemoCharacters: bigint,
txSigLimit: bigint,
txSizeCostPerByte: bigint,
sigVerifyCostEd25519: bigint,
sigVerifyCostSecp256k1: bigint
}
/**
* Transaction info
*/
export interface TxInfo {
/**
* Hash of the transaction.
*/
hash: string;
/**
* Height at which transaction was submitted.
*/
height: bigint;
}
/**
* Transaction config.
*/
export interface TxConfig {
/**
* Custom gas limit for the transaction (in `utia`). By default, client will
* query gas estimation service to get estimate gas limit.
*/
gasLimit?: bigint; // utia
/**
* Custom gas price for fee calculation. By default, client will query gas
* estimation service to get gas price estimate.
*/
gasPrice?: number;
/**
* Memo for the transaction
*/
memo?: string;
/**
* Priority of the transaction, used with gas estimation service
*/
priority?: TxPriority;
}
/**
* A payload to be signed
*/
export interface SignDoc {
bodyBytes: Uint8Array;
authInfoBytes: Uint8Array;
chainId: string;
accountNumber: bigint;
}
/**
* A function that produces a signature of a payload
*/
export type SignerFn = ((arg: SignDoc) => Uint8Array) | ((arg: SignDoc) => Promise<Uint8Array>);
/**
* ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
*/
export class AbciMessageLog {
private constructor();
free(): void;
msg_index: number;
log: string;
/**
* Events contains a slice of Event objects that were emitted during some
* execution.
*/
events: StringEvent[];
}
/**
* Response to a tx query
*/
export class AbciQueryResponse {
private constructor();
free(): void;
/**
* Response code.
*/
code: ErrorCode;
/**
* Namespace for the Code.
*/
codespace: string;
/**
* The index of the key in the tree.
*/
index: bigint;
/**
* The key of the matching data.
*/
key: Uint8Array;
/**
* The value of the matching data.
*/
value: Uint8Array;
/**
* Serialized proof for the value data, if requested,
* to be verified against the [`AppHash`] for the given [`Height`].
*
* [`AppHash`]: tendermint::hash::AppHash
*/
get proof_ops(): ProofOps | undefined;
/**
* Serialized proof for the value data, if requested,
* to be verified against the [`AppHash`] for the given [`Height`].
*
* [`AppHash`]: tendermint::hash::AppHash
*/
set proof_ops(value: ProofOps | null | undefined);
/**
* The output of the application's logger (raw string). May be
* non-deterministic.
*/
log: string;
/**
* Additional information. May be non-deterministic.
*/
info: string;
/**
* The block height from which data was derived.
*
* Note that this is the height of the block containing the application's Merkle root hash,
* which represents the state as it was after committing the block at height - 1.
*/
readonly height: bigint;
}
/**
* Address of an account.
*/
export class AccAddress {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
}
/**
* Version of the App
*/
export class AppVersion {
private constructor();
free(): void;
/**
* Latest App version variant.
*/
static latest(): AppVersion;
/**
* App v1
*/
static readonly V1: AppVersion;
/**
* App v2
*/
static readonly V2: AppVersion;
/**
* App v3
*/
static readonly V3: AppVersion;
/**
* App v4
*/
static readonly V4: AppVersion;
/**
* App v5
*/
static readonly V5: AppVersion;
/**
* App v6
*/
static readonly V6: AppVersion;
}
/**
* Attribute defines an attribute wrapper where the key and value are
* strings instead of raw bytes.
*/
export class Attribute {
private constructor();
free(): void;
key: string;
value: string;
}
/**
* [`AuthInfo`] describes the fee and signer modes that are used to sign a transaction.
*/
export class AuthInfo {
private constructor();
free(): void;
/**
* Defines the signing modes for the required signers.
*
* The number and order of elements must match the required signers from transaction
* [`TxBody`]’s messages. The first element is the primary signer and the one
* which pays the [`Fee`].
*/
signer_infos: SignerInfo[];
/**
* [`Fee`] and gas limit for the transaction.
*
* The first signer is the primary signer and the one which pays the fee.
* The fee can be calculated based on the cost of evaluating the body and doing signature
* verification of the signers. This can be estimated via simulation.
*/
fee: Fee;
}
/**
* Arbitrary data that can be stored in the network within certain [`Namespace`].
*/
export class Blob {
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Create a new blob with the given data within the [`Namespace`].
*/
constructor(namespace: Namespace, data: Uint8Array, app_version: AppVersion);
/**
* Clone a blob creating a new deep copy of it.
*/
clone(): Blob;
/**
* A [`Namespace`] the [`Blob`] belongs to.
*/
namespace: Namespace;
/**
* Data stored within the [`Blob`].
*/
data: Uint8Array;
/**
* Version indicating the format in which [`Share`]s should be created from this [`Blob`].
*/
share_version: number;
/**
* A [`Commitment`] computed from the [`Blob`]s data.
*/
commitment: Commitment;
/**
* Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.
*/
get index(): bigint | undefined;
/**
* Index of the blob's first share in the EDS. Only set for blobs retrieved from chain.
*/
set index(value: bigint | null | undefined);
/**
* 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.
*/
get signer(): AccAddress | undefined;
/**
* 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.
*/
set signer(value: AccAddress | null | undefined);
}
/**
* Params defines the parameters for the blob module.
*/
export class BlobParams {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Gas cost per blob byte
*/
gas_per_blob_byte: number;
/**
* Max square size
*/
gov_max_square_size: bigint;
}
/**
* Blocks consist of a header, transactions, votes (the commit), and a list of
* evidence of malfeasance (i.e. signing conflicting votes).
*
* This is a modified version of [`tendermint::block::Block`] which contains
* [modifications](data-mod) that Celestia introduced.
*
* [data-mod]: https://github.com/celestiaorg/celestia-core/blob/a1268f7ae3e688144a613c8a439dd31818aae07d/proto/tendermint/types/types.proto#L84-L104
*/
export class Block {
private constructor();
free(): void;
/**
* Transaction data
*/
data: Data;
/**
* Block header
*/
readonly header: Header;
/**
* Evidence of malfeasance
*/
readonly evidence: Evidence[];
/**
* Last commit, should be `None` for the initial block.
*/
readonly lastCommit: Commit | undefined;
}
/**
* Block identifiers which contain two distinct Merkle roots of the block, as well as the number of parts in the block.
*/
export class BlockId {
private constructor();
free(): void;
/**
* The block’s main hash is the Merkle root of all the fields in the block header.
*/
hash: string;
/**
* Parts header (if available) is used for secure gossipping of the block during
* consensus. It is the Merkle root of the complete serialized block cut into parts.
*
* PartSet is used to split a byteslice of data into parts (pieces) for transmission.
* By splitting data into smaller parts and computing a Merkle root hash on the list,
* you can verify that a part is legitimately part of the complete data, and the part
* can be forwarded to other peers before all the parts are known. In short, it’s
* a fast way to propagate a large file over a gossip network.
*
* <https://github.com/tendermint/tendermint/wiki/Block-Structure#partset>
*
* PartSetHeader in protobuf is defined as never nil using the gogoproto annotations.
* This does not translate to Rust, but we can indicate this in the domain type.
*/
part_set_header: PartsHeader;
}
/**
* A range of blocks between `start` and `end` height, inclusive
*/
export class BlockRange {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* First block height in range
*/
start: bigint;
/**
* Last block height in range
*/
end: bigint;
}
/**
* BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method.
*/
export class BroadcastMode {
private constructor();
free(): void;
/**
* zero-value for mode ordering
*/
static readonly Unspecified: BroadcastMode;
/**
* DEPRECATED: use `BroadcastMode` `Sync` instead,
* `BroadcastMode` `Block` is not supported by the SDK from v0.47.x onwards.
*/
static readonly Block: BroadcastMode;
/**
* `BroadcastMode` `Sync` defines a tx broadcasting mode where the client waits for
* a CheckTx execution response only.
*/
static readonly Sync: BroadcastMode;
/**
* `BroadcastMode` `Async` defines a tx broadcasting mode where the client returns
* immediately.
*/
static readonly Async: BroadcastMode;
}
/**
* Coin defines a token with a denomination and an amount.
*/
export class Coin {
private constructor();
free(): void;
}
/**
* Commit contains the justification (ie. a set of signatures) that a block was
* committed by a set of validators.
*/
export class Commit {
private constructor();
free(): void;
/**
* Block height
*/
height: bigint;
/**
* Round
*/
round: number;
/**
* Block ID
*/
block_id: BlockId;
/**
* Signatures
*/
signatures: CommitSig[];
}
/**
* CommitSig represents a signature of a validator. It’s a part of the Commit and can
* be used to reconstruct the vote set given the validator set.
*/
export class CommitSig {
private constructor();
free(): void;
/**
* vote type of a validator
*/
vote_type: CommitVoteType;
/**
* vote, if received
*/
get vote(): CommitVote | undefined;
/**
* vote, if received
*/
set vote(value: CommitVote | null | undefined);
}
/**
* Value of the validator vote
*/
export class CommitVote {
private constructor();
free(): void;
/**
* Address of the voting validator
*/
validator_address: string;
/**
* Timestamp
*/
timestamp: string;
/**
* Signature
*/
get signature(): Signature | undefined;
/**
* Signature
*/
set signature(value: Signature | null | undefined);
}
/**
* 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:
*
* ```text
* 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`].
*
* [`Blob`]: crate::Blob
* [`Share`]: crate::share::Share
* [`MsgPayForBlobs`]: celestia_proto::celestia::blob::v1::MsgPayForBlobs
* [`merkle hash`]: tendermint::merkle::simple_hash_from_byte_vectors
* [`Nmt`]: crate::nmt::Nmt
* [`ExtendedDataSquare`]: crate::ExtendedDataSquare
* [`share commitment rules`]: https://github.com/celestiaorg/celestia-app/blob/main/specs/src/specs/data_square_layout.md#blob-share-commitment-rules
*/
export class Commitment {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Hash of the commitment
*/
hash(): Uint8Array;
}
/**
* Response holding consensus node configuration.
*/
export class ConfigResponse {
private constructor();
free(): void;
/**
* Minimum gas price for the node to accept tx. Value is in `utia` denom.
*/
get minimum_gas_price(): number | undefined;
/**
* Minimum gas price for the node to accept tx. Value is in `utia` denom.
*/
set minimum_gas_price(value: number | null | undefined);
/**
* How many recent blocks are stored by the node.
*/
pruning_keep_recent: bigint;
/**
* Amount of blocks used as an interval to trigger prunning.
*/
pruning_interval: bigint;
/**
* A height at which the node should stop advancing state.
*/
halt_height: bigint;
}
/**
* Conflicting block detected in light client attack
*/
export class ConflictingBlock {
private constructor();
free(): void;
/**
* Signed header
*/
signed_header: SignedHeader;
/**
* Validator set
*/
validator_set: ValidatorSet;
}
export class ConnectionCountersSnapshot {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* The total number of connections, both pending and established.
*/
num_connections: number;
/**
* The total number of pending connections, both incoming and outgoing.
*/
num_pending: number;
/**
* The total number of pending connections, both incoming and outgoing.
*/
num_pending_incoming: number;
/**
* The number of outgoing connections being established.
*/
num_pending_outgoing: number;
/**
* The number of outgoing connections being established.
*/
num_established: number;
/**
* The number of established incoming connections.
*/
num_established_incoming: number;
/**
* The number of established outgoing connections.
*/
num_established_outgoing: number;
}
/**
* Address of a consensus node.
*/
export class ConsAddress {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
}
/**
* Data contained in a [`Block`].
*
* [`Block`]: crate::block::Block
*/
export class Data {
private constructor();
free(): void;
/**
* Square width of original data square.
*/
square_size: bigint;
/**
* Hash is the root of a binary Merkle tree where the leaves of the tree are
* the row and column roots of an extended data square. Hash is often referred
* to as the "data root".
*/
hash: Uint8Array;
/**
* Transactions
*/
readonly transactions: Uint8Array[];
}
/**
* 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
*
* ```no_run
* # 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());
* ```
*
* [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
*/
export class DataAvailabilityHeader {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Merkle roots of the [`ExtendedDataSquare`] rows.
*/
rowRoots(): Array<any>;
/**
* Merkle roots of the [`ExtendedDataSquare`] columns.
*/
columnRoots(): Array<any>;
/**
* Get a root of the row with the given index.
*/
rowRoot(row: number): any;
/**
* Get the a root of the column with the given index.
*/
columnRoot(column: number): any;
/**
* Compute the combined hash of all rows and columns.
*
* This is the data commitment for the block.
*/
hash(): any;
/**
* Get the size of the [`ExtendedDataSquare`] for which this header was built.
*/
squareWidth(): number;
}
/**
* Duplicate vote evidence
*/
export class DuplicateVoteEvidence {
private constructor();
free(): void;
/**
* Vote A
*/
vote_a: Vote;
/**
* Vote B
*/
vote_b: Vote;
/**
* Total voting power
*/
total_voting_power: bigint;
/**
* Validator power
*/
validator_power: bigint;
/**
* Timestamp
*/
timestamp: string;
}
/**
* Evidence of malfeasance by validators (i.e. signing conflicting votes or light client attack).
*/
export class Evidence {
private constructor();
free(): void;
}
/**
* 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");
* ```
*/
export class ExtendedHeader {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Clone a header producing a deep copy of it.
*/
clone(): ExtendedHeader;
/**
* Get the block height.
*/
height(): bigint;
/**
* Get the block time.
*/
time(): number;
/**
* Get the block hash.
*/
hash(): string;
/**
* Get the hash of the previous header.
*/
previousHeaderHash(): string;
/**
* Decode protobuf encoded header and then validate it.
*/
validate(): 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
*/
verify(untrusted: ExtendedHeader): 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()`.
*
* ```js
* 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.
*/
verifyRange(untrusted: ExtendedHeader[]): 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()`.
*
* ```js
* 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
*/
verifyAdjacentRange(untrusted: ExtendedHeader[]): void;
/**
* Header of the block data availability.
*/
dah: DataAvailabilityHeader;
/**
* Tendermint block header.
*/
readonly header: any;
/**
* Commit metadata and signatures from validators committing the block.
*/
readonly commit: any;
/**
* Information about the set of validators commiting the block.
*/
readonly validatorSet: any;
}
/**
* Fee includes the amount of coins paid in fees and the maximum
* gas to be used by the transaction. The ratio yields an effective "gasprice",
* which must be above some miminum to be accepted into the mempool.
*/
export class Fee {
private constructor();
free(): void;
/**
* amount is the amount of coins to be paid as a fee
*/
amount: Coin[];
/**
* gas_limit is the maximum gas that can be used in transaction processing
* before an out of gas error occurs
*/
gas_limit: bigint;
/**
* if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees.
* the payer must be a tx signer (and thus have signed this field in AuthInfo).
* setting this field does *not* change the ordering of required signers for the transaction.
*/
readonly payer: string | undefined;
/**
* if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used
* to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does
* not support fee grants, this will fail
*/
readonly granter: string | undefined;
}
/**
* Result of gas price and usage estimation
*/
export class GasEstimate {
private constructor();
free(): void;
/**
* Gas price estimated based on last 5 blocks
*/
price: number;
/**
* Simulated transaction gas usage
*/
usage: bigint;
}
/**
* GasInfo defines tx execution gas context.
*/
export class GasInfo {
private constructor();
free(): void;
/**
* GasWanted is the maximum units of work we allow this tx to perform.
*/
gas_wanted: bigint;
/**
* GasUsed is the amount of gas actually consumed.
*/
gas_used: bigint;
}
/**
* Response to GetTx
*/
export class GetTxResponse {
private constructor();
free(): void;
/**
* Response Transaction
*/
tx: Tx;
/**
* TxResponse to a Query
*/
tx_response: TxResponse;
}
/**
* Celestia gRPC client, for builder see [`GrpcClientBuilder`]
*/
export class GrpcClient {
private constructor();
free(): void;
/**
* Create a builder for [`GrpcClient`] connected to `url`
*/
static withUrl(url: string): GrpcClientBuilder;
/**
* Get auth params
*/
getAuthParams(): Promise<AuthParams>;
/**
* Get account
*/
getAccount(account: string): Promise<BaseAccount>;
/**
* Get accounts
*/
getAccounts(): Promise<BaseAccount[]>;
/**
* Retrieves the verified Celestia coin balance for the address.
*
* # Notes
*
* This returns the verified balance which is the one that was reported by
* the previous network block. In other words, if you transfer some coins,
* you need to wait 1 more block in order to see the new balance. If you want
* something more immediate then use [`GrpcClient::get_balance`].
*/
getVerifiedBalance(address: string, header: ExtendedHeader): Promise<Coin>;
/**
* Retrieves the Celestia coin balance for the given address.
*/
getBalance(address: string, denom: string): Promise<Coin>;
/**
* Get balance of all coins
*/
getAllBalances(address: string): Promise<Coin[]>;
/**
* Get balance of all spendable coins
*/
getSpendableBalances(address: string): Promise<Coin[]>;
/**
* Get total supply
*/
getTotalSupply(): Promise<Coin[]>;
/**
* Get node configuration
*/
get_node_config(): Promise<ConfigResponse>;
/**
* Get latest block
*/
getLatestBlock(): Promise<Block>;
/**
* Get block by height
*/
getBlockByHeight(height: bigint): Promise<Block>;
/**
* Issue a direct ABCI query to the application
*/
abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
/**
* Broadcast prepared and serialised transaction
*/
broadcastTx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
/**
* Get Tx
*/
getTx(hash: string): Promise<GetTxResponse>;
/**
* Simulate prepared and serialised transaction, returning simulated gas usage
*/
simulate(tx_bytes: Uint8Array): Promise<GasInfo>;
/**
* Get blob params
*/
getBlobParams(): Promise<BlobParams>;
/**
* Get status of the transaction
*/
txStatus(hash: string): Promise<TxStatusResponse>;
/**
* Estimate gas price for given transaction priority based
* on the gas prices of the transactions in the last five blocks.
*
* If no transaction is found in the last five blocks, return the network
* min gas price.
*/
estimateGasPrice(priority: TxPriority): Promise<number>;
/**
* Submit blobs to the celestia network.
*
* # Example
* ```js
* 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()`.
*
* ```js
* const blobs = [blob1, blob2, blob3];
* await txClient.submitBlobs(blobs.map(b => b.clone()));
* ```
*/
submitBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<TxInfo>;
/**
* Submit message to the celestia network.
*
* # Example
* ```js
* 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);
* ```
*/
submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
/**
* Chain id of the client
*/
readonly chainId: Promise<string>;
/**
* AppVersion of the client
*/
readonly appVersion: Promise<AppVersion>;
}
/**
* Builder for [`GrpcClient`] and [`TxClient`].
*
* Url must point to a [grpc-web proxy](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
*
* # Keyless client example
*
* ```js
* const client = await GrpcClient
* .withUrl("http://127.0.0.1:18080")
* .build()
* ```
*
* # Transaction client examples
*
* ## Example with noble/curves
* ```js
* import { secp256k1 } from "@noble/curves/secp256k1";
*
* 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 client = await GrpcClient
* .withUrl("http://127.0.0.1:18080")
* .withPubkeyAndSigner(pubKey, signer)
* .build();
* ```
*
* ## Example with leap wallet
* ```js
* 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 client = await GrpcClient
* .withUrl("http://127.0.0.1:18080")
* .withPubkeyAndSigner(keys.pubKey, signer)
* .build()
* ```
*/
export class GrpcClientBuilder {
private constructor();
free(): void;
/**
* Set the `url` of the grpc-web server to connect to
*
* Note that this method **consumes** builder and returns updated instance of it.
* Make sure to re-assign it if you keep builder in a variable.
*/
withUrl(url: string): GrpcClientBuilder;
/**
* Add public key and signer to the client being built
*
* Note that this method **consumes** builder and returns updated instance of it.
* Make sure to re-assign it if you keep builder in a variable.
*/
withPubkeyAndSigner(account_pubkey: Uint8Array, signer_fn: SignerFn): GrpcClientBuilder;
/**
* Appends ascii metadata to all requests made by the client.
*
* Note that this method **consumes** builder and returns updated instance of it.
* Make sure to re-assign it if you keep builder in a variable.
*/
withMetadata(key: string, value: string): GrpcClientBuilder;
/**
* Appends binary metadata to all requests made by the client.
*
* Keys for binary metadata must have `-bin` suffix.
*
* Note that this method **consumes** builder and returns updated instance of it.
* Make sure to re-assign it if you keep builder in a variable.
*/
withMetadataBin(key: string, value: Uint8Array): GrpcClientBuilder;
/**
* build gRPC client
*/
build(): GrpcClient;
}
/**
* Block Header values contain metadata about the block and about the consensus,
* as well as commitments to the data in the current block, the previous block,
* and the results returned by the application.
*/
export class Header {
private constructor();
free(): void;
/**
* Header version
*/
version: ProtocolVersion;
/**
* Chain ID
*/
chain_id: string;
/**
* Current block height
*/
height: bigint;
/**
* Current timestamp encoded as rfc3339
*/
time: string;
/**
* Previous block info
*/
get last_block_id(): BlockId | undefined;
/**
* Previous block info
*/
set last_block_id(value: BlockId | null | undefined);
/**
* Commit from validators from the last block
*/
get last_commit_hash(): string | undefined;
/**
* Commit from validators from the last block
*/
set last_commit_hash(value: string | null | undefined);
/**
* Merkle root of transaction hashes
*/
get data_hash(): string | undefined;
/**
* Merkle root of transaction hashes
*/
set data_hash(value: string | null | undefined);
/**
* Validators for the current block
*/
validators_hash: string;
/**
* Validators for the next block
*/
next_validators_hash: string;
/**
* Consensus params for the current block
*/
consensus_hash: string;
/**
* State after txs from the previous block
*/
app_hash: string;
/**
* Root hash of all results from the txs from the previous block
*/
get last_results_hash(): string | undefined;
/**
* Root hash of all results from the txs from the previous block
*/
set last_results_hash(value: string | null | undefined);
/**
* Hash of evidence included in the block
*/
get evidence_hash(): string | undefined;
/**
* Hash of evidence included in the block
*/
set evidence_hash(value: string | null | undefined);
/**
* Original proposer of the block
*/
proposer_address: string;
}
export class IntoUnderlyingByteSource {
private constructor();
free(): void;
start(controller: ReadableByteStreamController): void;
pull(controller: ReadableByteStreamController): Promise<any>;
cancel(): void;
readonly type: ReadableStreamType;
readonly autoAllocateChunkSize: number;
}
export class IntoUnderlyingSink {
private constructor();
free(): void;
write(chunk: any): Promise<any>;
close(): Promise<any>;
abort(reason: any): Promise<any>;
}
export class IntoUnderlyingSource {
private constructor();
free(): void;
pull(controller: ReadableStreamDefaultController): Promise<any>;
cancel(): void;
}
/**
* Array of bits
*/
export class JsBitVector {
private constructor();
free(): void;
0: Uint8Array;
}
/**
* Event allows application developers to attach additional information to
* ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx.
* Later, transactions may be queried using these events.
*/
export class JsEvent {
private constructor();
free(): void;
type: string;
attributes: JsEventAttribute[];
}
export class JsEventAttribute {
private constructor();
free(): void;
key: string;
value: string;
index: boolean;
}
/**
* Validator information
*/
export class JsValidatorInfo {
private constructor();
free(): void;
/**
* Validator account address
*/
address: string;
/**
* Validator public key
*/
pub_key: PublicKey;
/**
* Validator voting power
*/
power: bigint;
/**
* Validator name
*/
get name(): string | undefined;
/**
* Validator name
*/
set name(value: string | null | undefined);
/**
* Validator proposer priority
*/
proposer_priority: bigint;
}
/**
* LightClient attack evidence
*/
export class LightClientAttackEvidence {
private constructor();
free(): void;
/**
* Conflicting block
*/
conflicting_block: ConflictingBlock;
/**
* Common height
*/
common_height: bigint;
/**
* Byzantine validators
*/
byzantine_validators: JsValidatorInfo[];
/**
* Total voting power
*/
total_voting_power: bigint;
/**
* Timestamp
*/
timestamp: string;
}
/**
* ModeInfo describes the signing mode of a single or nested multisig signer.
*/
export class ModeInfo {
private constructor();
free(): void;
/**
* Return signature mode for the stored signature(s)
*/
signature_mode(): SignatureMode;
/**
* Single is the mode info for a single signer. It is structured as a message
* to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the
* future
*/
readonly mode: number | undefined;
/**
* Multi is the mode info for a multisig public key
* bitarray specifies which keys within the multisig are signing
*/
readonly bitarray: JsBitVector | undefined;
/**
* Multi is the mode info for a multisig public key
* mode_infos is the corresponding modes of the signers of the multisig
* which could include nested multisig public keys
*/
readonly mode_infos: ModeInfo[] | undefined;
}
/**
* 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.
*/
export class Namespace {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* Create a new [`Namespace`] version `0` with given id.
*
* Check [`Namespace::new_v0`] for more details.
*
* [`Namespace::new_v0`]: https://docs.rs/celestia-types/latest/celestia_types/nmt/struct.Namespace.html#method.new_v0
*/
static newV0(id: Uint8Array): 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`].
*/
static fromRaw(raw: Uint8Array): Namespace;
/**
* Converts the [`Namespace`] to a byte slice.
*/
asBytes(): Uint8Array;
/**
* Namespace size in bytes.
*/
static readonly NS_SIZE: number;
/**
* Primary reserved [`Namespace`] for the compact `Share`s with `cosmos SDK` transactions.
*/
static readonly TRANSACTION: Namespace;
/**
* Primary reserved [`Namespace`] for the compact Shares with MsgPayForBlobs transactions.
*/
static readonly PAY_FOR_BLOB: 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`
*/
static readonly PRIMARY_RESERVED_PADDING: Namespace;
/**
* Maximal primary reserved [`Namespace`].
*
* Used to indicate the end of the primary reserved group.
*/
static readonly MAX_PRIMARY_RESERVED: Namespace;
/**
* Minimal secondary reserved [`Namespace`].
*
* Used to indicate the beginning of the secondary reserved group.
*/
static readonly MIN_SECONDARY_RESERVED: 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`.
*/
static readonly TAIL_PADDING: 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.
*/
static readonly PARITY_SHARE: Namespace;
/**
* Returns the first byte indicating the version of the [`Namespace`].
*/
readonly version: number;
/**
* Returns the trailing 28 bytes indicating the id of the [`Namespace`].
*/
readonly id: Uint8Array;
}
/**
* Information about the connections
*/
export class NetworkInfoSnapshot {
private constructor();
/**
** Return copy of self without private attributes.
*/
toJSON(): Object;
/**
* Return stringified version of self.
*/
toString(): string;
free(): void;
/**
* The number of connected peers, i.e. peers with whom at least one established connection exists.
*/
num_peers: number;
/**
* Gets counters for ongoing network connections.
*/
connection_counters: ConnectionCountersSnapshot;
}
/**
* `NodeClient` is responsible for steering [`NodeWorker`] by sending it commands and receiving
* responses over the provided port.
*
* [`NodeWorker`]: crate::worker::NodeWorker
*/
export class NodeClient {
free(): void;
/**
* Create a new connection to a Lumina node running in [`NodeWorker`]. Provided `port` is