lumina-node-wasm 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -478,6 +478,24 @@ type ReadableStreamType = "bytes";
478
478
  height: bigint;
479
479
  }
480
480
 
481
+ /**
482
+ * A transaction that was broadcasted
483
+ */
484
+ export interface BroadcastedTx {
485
+ /**
486
+ * Broadcasted bytes
487
+ */
488
+ tx: Uint8Array;
489
+ /**
490
+ * Transaction hash
491
+ */
492
+ hash: string;
493
+ /**
494
+ * Transaction sequence
495
+ */
496
+ sequence: bigint;
497
+ }
498
+
481
499
  /**
482
500
  * Transaction config.
483
501
  */
@@ -500,6 +518,10 @@ type ReadableStreamType = "bytes";
500
518
  * Priority of the transaction, used with gas estimation service
501
519
  */
502
520
  priority?: TxPriority;
521
+ /**
522
+ * Interval between confirmation polling attempts, in milliseconds.
523
+ */
524
+ confirmationIntervalMs?: bigint;
503
525
  }
504
526
 
505
527
 
@@ -755,6 +777,29 @@ export class BlobParams {
755
777
  */
756
778
  gov_max_square_size: bigint;
757
779
  }
780
+ /**
781
+ * List of blobs together with height they were published at
782
+ */
783
+ export class BlobsAtHeight {
784
+ private constructor();
785
+ /**
786
+ ** Return copy of self without private attributes.
787
+ */
788
+ toJSON(): Object;
789
+ /**
790
+ * Return stringified version of self.
791
+ */
792
+ toString(): string;
793
+ free(): void;
794
+ /**
795
+ * Height the blobs were published at
796
+ */
797
+ height: bigint;
798
+ /**
799
+ * Published blobs
800
+ */
801
+ blobs: Blob[];
802
+ }
758
803
  /**
759
804
  * Blocks consist of a header, transactions, votes (the commit), and a list of
760
805
  * evidence of malfeasance (i.e. signing conflicting votes).
@@ -1129,7 +1174,7 @@ export class Data {
1129
1174
  * # fn extended_header() -> ExtendedHeader {
1130
1175
  * # unimplemented!();
1131
1176
  * # }
1132
- * # fn shares_with_proof(_: Height, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1177
+ * # fn shares_with_proof(_: u64, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1133
1178
  * # unimplemented!();
1134
1179
  * # }
1135
1180
  * // fetch the block header and data for your namespace
@@ -1439,6 +1484,22 @@ export class GrpcClient {
1439
1484
  * Issue a direct ABCI query to the application
1440
1485
  */
1441
1486
  abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1487
+ /**
1488
+ * Confirm transaction broadcasted with [`broadcast_blobs`] or [`broadcast_message`].
1489
+ *
1490
+ * # Example
1491
+ * ```js
1492
+ * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
1493
+ * const data = new Uint8Array([100, 97, 116, 97]);
1494
+ * const blob = new Blob(ns, data, AppVersion.latest());
1495
+ *
1496
+ * const broadcastedTx = await txClient.broadcastBlobs([blob]);
1497
+ * console.log("Tx hash:", broadcastedTx.hash);
1498
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1499
+ * console.log("Confirmed at height:", txInfo.height);
1500
+ * ```
1501
+ */
1502
+ confirmTx(broadcasted_tx: BroadcastedTx, tx_config?: TxConfig | null): Promise<TxInfo>;
1442
1503
  /**
1443
1504
  * Get account
1444
1505
  */
@@ -1502,6 +1563,32 @@ export class GrpcClient {
1502
1563
  * ```
1503
1564
  */
1504
1565
  submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
1566
+ /**
1567
+ * Broadcast blobs to the celestia network, and return without confirming.
1568
+ *
1569
+ * # Example
1570
+ * ```js
1571
+ * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
1572
+ * const data = new Uint8Array([100, 97, 116, 97]);
1573
+ * const blob = new Blob(ns, data, AppVersion.latest());
1574
+ *
1575
+ * const broadcastedTx = await txClient.broadcastBlobs([blob]);
1576
+ * console.log("Tx hash:", broadcastedTx.hash);
1577
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1578
+ * ```
1579
+ *
1580
+ * # Note
1581
+ *
1582
+ * Provided blobs will be consumed by this method, meaning
1583
+ * they will no longer be accessible. If this behavior is not desired,
1584
+ * consider using `Blob.clone()`.
1585
+ *
1586
+ * ```js
1587
+ * const blobs = [blob1, blob2, blob3];
1588
+ * await txClient.broadcastBlobs(blobs.map(b => b.clone()));
1589
+ * ```
1590
+ */
1591
+ broadcastBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<BroadcastedTx>;
1505
1592
  /**
1506
1593
  * Get auth params
1507
1594
  */
@@ -1526,6 +1613,30 @@ export class GrpcClient {
1526
1613
  * Get total supply
1527
1614
  */
1528
1615
  getTotalSupply(): Promise<Coin[]>;
1616
+ /**
1617
+ * Broadcast message to the celestia network, and return without confirming.
1618
+ *
1619
+ * # Example
1620
+ * ```js
1621
+ * import { Registry } from "@cosmjs/proto-signing";
1622
+ *
1623
+ * const registry = new Registry();
1624
+ * const sendMsg = {
1625
+ * typeUrl: "/cosmos.bank.v1beta1.MsgSend",
1626
+ * value: {
1627
+ * fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
1628
+ * toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
1629
+ * amount: [{ denom: "utia", amount: "10000" }],
1630
+ * },
1631
+ * };
1632
+ * const sendMsgAny = registry.encodeAsAny(sendMsg);
1633
+ *
1634
+ * const broadcastedTx = await txClient.broadcastMessage(sendMsgAny);
1635
+ * console.log("Tx hash:", broadcastedTx.hash);
1636
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1637
+ * ```
1638
+ */
1639
+ broadcastMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<BroadcastedTx>;
1529
1640
  /**
1530
1641
  * Estimate gas price for given transaction priority based
1531
1642
  * on the gas prices of the transactions in the last five blocks.
@@ -1569,6 +1680,13 @@ export class GrpcClient {
1569
1680
  * Get status of the transaction
1570
1681
  */
1571
1682
  txStatus(hash: string): Promise<TxStatusResponse>;
1683
+ /**
1684
+ * Create a builder for [`GrpcClient`] with multiple URL endpoints for fallback support.
1685
+ *
1686
+ * When multiple endpoints are configured, the client will automatically
1687
+ * fall back to the next endpoint if a network-related error occurs.
1688
+ */
1689
+ static withUrls(urls: string[]): GrpcClientBuilder;
1572
1690
  /**
1573
1691
  * AppVersion of the client
1574
1692
  */
@@ -1588,6 +1706,7 @@ export class GrpcClient {
1588
1706
  * ```js
1589
1707
  * const client = await GrpcClient
1590
1708
  * .withUrl("http://127.0.0.1:18080")
1709
+ * .withTimeout(5000) // Optional: 5 second timeout
1591
1710
  * .build()
1592
1711
  * ```
1593
1712
  *
@@ -1631,6 +1750,13 @@ export class GrpcClient {
1631
1750
  export class GrpcClientBuilder {
1632
1751
  private constructor();
1633
1752
  free(): void;
1753
+ /**
1754
+ * Sets the request timeout in milliseconds, overriding default one from the transport.
1755
+ *
1756
+ * Note that this method **consumes** builder and returns updated instance of it.
1757
+ * Make sure to re-assign it if you keep builder in a variable.
1758
+ */
1759
+ withTimeout(timeout_ms: bigint): GrpcClientBuilder;
1634
1760
  /**
1635
1761
  * Appends ascii metadata to all requests made by the client.
1636
1762
  *
@@ -1665,6 +1791,16 @@ export class GrpcClientBuilder {
1665
1791
  * Make sure to re-assign it if you keep builder in a variable.
1666
1792
  */
1667
1793
  withUrl(url: string): GrpcClientBuilder;
1794
+ /**
1795
+ * Add multiple URL endpoints at once for fallback support.
1796
+ *
1797
+ * When multiple endpoints are configured, the client will automatically
1798
+ * fall back to the next endpoint if a network-related error occurs.
1799
+ *
1800
+ * Note that this method **consumes** builder and returns updated instance of it.
1801
+ * Make sure to re-assign it if you keep builder in a variable.
1802
+ */
1803
+ withUrls(urls: string[]): GrpcClientBuilder;
1668
1804
  }
1669
1805
  /**
1670
1806
  * Block Header values contain metadata about the block and about the consensus,
@@ -1773,6 +1909,21 @@ export class IntoUnderlyingSource {
1773
1909
  pull(controller: ReadableStreamDefaultController): Promise<any>;
1774
1910
  cancel(): void;
1775
1911
  }
1912
+ export class IteratorResultObject {
1913
+ private constructor();
1914
+ free(): void;
1915
+ /**
1916
+ * Has the value true if the iterator is past the end of the
1917
+ * iterated sequence. In this case value optionally specifies
1918
+ * the return value of the iterator.
1919
+ */
1920
+ done: boolean;
1921
+ /**
1922
+ * Any JavaScript value returned by the iterator.
1923
+ * Can be omitted when done is true.
1924
+ */
1925
+ value: any;
1926
+ }
1776
1927
  /**
1777
1928
  * Array of bits
1778
1929
  */
@@ -2053,6 +2204,13 @@ export class NodeClient {
2053
2204
  * Get node's local peer ID.
2054
2205
  */
2055
2206
  localPeerId(): Promise<string>;
2207
+ /**
2208
+ * Subscribe to the shares from the namespace, as new headers are received by the node
2209
+ *
2210
+ * Return an async iterator which will yield all the blobs from the namespace, as the new headers
2211
+ * are being received by the node, starting from the first header received after the call.
2212
+ */
2213
+ blobSubscribe(namespace: Namespace): Promise<AsyncIterable<BlobsAtHeight | SubscriptionError>>;
2056
2214
  /**
2057
2215
  * Returns a [`BroadcastChannel`] for events generated by [`Node`].
2058
2216
  */
@@ -2069,6 +2227,13 @@ export class NodeClient {
2069
2227
  * Get all the peers that node is connected to.
2070
2228
  */
2071
2229
  connectedPeers(): Promise<Array<any>>;
2230
+ /**
2231
+ * Subscribe to new headers received by the node from the network.
2232
+ *
2233
+ * Return an async iterator which will yield all the headers, as they are being received by the
2234
+ * node, starting from the first header received after the call.
2235
+ */
2236
+ headerSubscribe(): Promise<AsyncIterable<ExtendedHeader | SubscriptionError>>;
2072
2237
  /**
2073
2238
  * Get current [`PeerTracker`] info.
2074
2239
  */
@@ -2082,6 +2247,13 @@ export class NodeClient {
2082
2247
  * Get a synced header for the block with a given hash.
2083
2248
  */
2084
2249
  getHeaderByHash(hash: string): Promise<ExtendedHeader>;
2250
+ /**
2251
+ * Subscribe to the blobs from the namespace, as new headers are received by the node
2252
+ *
2253
+ * Return an async iterator which will yield all the shares from the namespace, as the new headers
2254
+ * are being received by the node, starting from the first header received after the call.
2255
+ */
2256
+ namespaceSubscribe(namespace: Namespace): Promise<AsyncIterable<SharesAtHeight | SubscriptionError>>;
2085
2257
  /**
2086
2258
  * Request the head header from the network.
2087
2259
  */
@@ -2318,6 +2490,58 @@ export class SamplingMetadata {
2318
2490
  */
2319
2491
  readonly cids: Uint8Array[];
2320
2492
  }
2493
+ /**
2494
+ * A single fixed-size chunk of data which is used to form an [`ExtendedDataSquare`].
2495
+ *
2496
+ * All data in Celestia is split into [`Share`]s before being put into a
2497
+ * block's data square. See [`Blob::to_shares`].
2498
+ *
2499
+ * All shares have the fixed size of 512 bytes and the following structure:
2500
+ *
2501
+ * ```text
2502
+ * | Namespace | InfoByte | (optional) sequence length | data |
2503
+ * ```
2504
+ *
2505
+ * `sequence length` is the length of the original data in bytes and is present only in the first of the shares the data was split into.
2506
+ *
2507
+ * [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
2508
+ * [`Blob::to_shares`]: crate::Blob::to_shares
2509
+ */
2510
+ export class Share {
2511
+ private constructor();
2512
+ /**
2513
+ ** Return copy of self without private attributes.
2514
+ */
2515
+ toJSON(): Object;
2516
+ /**
2517
+ * Return stringified version of self.
2518
+ */
2519
+ toString(): string;
2520
+ free(): void;
2521
+ }
2522
+ /**
2523
+ * A list of shares that were published at particular height.
2524
+ */
2525
+ export class SharesAtHeight {
2526
+ private constructor();
2527
+ /**
2528
+ ** Return copy of self without private attributes.
2529
+ */
2530
+ toJSON(): Object;
2531
+ /**
2532
+ * Return stringified version of self.
2533
+ */
2534
+ toString(): string;
2535
+ free(): void;
2536
+ /**
2537
+ * height the shares were published at
2538
+ */
2539
+ height: bigint;
2540
+ /**
2541
+ * shares published
2542
+ */
2543
+ shares: Share[];
2544
+ }
2321
2545
  /**
2322
2546
  * Signature
2323
2547
  */
@@ -2376,6 +2600,25 @@ export class StringEvent {
2376
2600
  type: string;
2377
2601
  attributes: Attribute[];
2378
2602
  }
2603
+ /**
2604
+ * Error thrown while processing subscription
2605
+ */
2606
+ export class SubscriptionError {
2607
+ private constructor();
2608
+ free(): void;
2609
+ /**
2610
+ * Height at which the error occurred, if applicable
2611
+ */
2612
+ get height(): bigint | undefined;
2613
+ /**
2614
+ * Height at which the error occurred, if applicable
2615
+ */
2616
+ set height(value: bigint | null | undefined);
2617
+ /**
2618
+ * error message
2619
+ */
2620
+ error: string;
2621
+ }
2379
2622
  /**
2380
2623
  * Status of the synchronization.
2381
2624
  */