lumina-node-wasm 0.12.0 → 0.13.0

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
  */
@@ -755,6 +773,29 @@ export class BlobParams {
755
773
  */
756
774
  gov_max_square_size: bigint;
757
775
  }
776
+ /**
777
+ * List of blobs together with height they were published at
778
+ */
779
+ export class BlobsAtHeight {
780
+ private constructor();
781
+ /**
782
+ ** Return copy of self without private attributes.
783
+ */
784
+ toJSON(): Object;
785
+ /**
786
+ * Return stringified version of self.
787
+ */
788
+ toString(): string;
789
+ free(): void;
790
+ /**
791
+ * Height the blobs were published at
792
+ */
793
+ height: bigint;
794
+ /**
795
+ * Published blobs
796
+ */
797
+ blobs: Blob[];
798
+ }
758
799
  /**
759
800
  * Blocks consist of a header, transactions, votes (the commit), and a list of
760
801
  * evidence of malfeasance (i.e. signing conflicting votes).
@@ -1129,7 +1170,7 @@ export class Data {
1129
1170
  * # fn extended_header() -> ExtendedHeader {
1130
1171
  * # unimplemented!();
1131
1172
  * # }
1132
- * # fn shares_with_proof(_: Height, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1173
+ * # fn shares_with_proof(_: u64, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1133
1174
  * # unimplemented!();
1134
1175
  * # }
1135
1176
  * // fetch the block header and data for your namespace
@@ -1439,6 +1480,22 @@ export class GrpcClient {
1439
1480
  * Issue a direct ABCI query to the application
1440
1481
  */
1441
1482
  abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1483
+ /**
1484
+ * Confirm transaction broadcasted with [`broadcast_blobs`] or [`broadcast_message`].
1485
+ *
1486
+ * # Example
1487
+ * ```js
1488
+ * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
1489
+ * const data = new Uint8Array([100, 97, 116, 97]);
1490
+ * const blob = new Blob(ns, data, AppVersion.latest());
1491
+ *
1492
+ * const broadcastedTx = await txClient.broadcastBlobs([blob]);
1493
+ * console.log("Tx hash:", broadcastedTx.hash);
1494
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1495
+ * console.log("Confirmed at height:", txInfo.height);
1496
+ * ```
1497
+ */
1498
+ confirmTx(broadcasted_tx: BroadcastedTx, tx_config?: TxConfig | null): Promise<TxInfo>;
1442
1499
  /**
1443
1500
  * Get account
1444
1501
  */
@@ -1502,6 +1559,32 @@ export class GrpcClient {
1502
1559
  * ```
1503
1560
  */
1504
1561
  submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
1562
+ /**
1563
+ * Broadcast blobs to the celestia network, and return without confirming.
1564
+ *
1565
+ * # Example
1566
+ * ```js
1567
+ * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
1568
+ * const data = new Uint8Array([100, 97, 116, 97]);
1569
+ * const blob = new Blob(ns, data, AppVersion.latest());
1570
+ *
1571
+ * const broadcastedTx = await txClient.broadcastBlobs([blob]);
1572
+ * console.log("Tx hash:", broadcastedTx.hash);
1573
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1574
+ * ```
1575
+ *
1576
+ * # Note
1577
+ *
1578
+ * Provided blobs will be consumed by this method, meaning
1579
+ * they will no longer be accessible. If this behavior is not desired,
1580
+ * consider using `Blob.clone()`.
1581
+ *
1582
+ * ```js
1583
+ * const blobs = [blob1, blob2, blob3];
1584
+ * await txClient.broadcastBlobs(blobs.map(b => b.clone()));
1585
+ * ```
1586
+ */
1587
+ broadcastBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<BroadcastedTx>;
1505
1588
  /**
1506
1589
  * Get auth params
1507
1590
  */
@@ -1526,6 +1609,30 @@ export class GrpcClient {
1526
1609
  * Get total supply
1527
1610
  */
1528
1611
  getTotalSupply(): Promise<Coin[]>;
1612
+ /**
1613
+ * Broadcast message to the celestia network, and return without confirming.
1614
+ *
1615
+ * # Example
1616
+ * ```js
1617
+ * import { Registry } from "@cosmjs/proto-signing";
1618
+ *
1619
+ * const registry = new Registry();
1620
+ * const sendMsg = {
1621
+ * typeUrl: "/cosmos.bank.v1beta1.MsgSend",
1622
+ * value: {
1623
+ * fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
1624
+ * toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
1625
+ * amount: [{ denom: "utia", amount: "10000" }],
1626
+ * },
1627
+ * };
1628
+ * const sendMsgAny = registry.encodeAsAny(sendMsg);
1629
+ *
1630
+ * const broadcastedTx = await txClient.broadcastMessage(sendMsgAny);
1631
+ * console.log("Tx hash:", broadcastedTx.hash);
1632
+ * const txInfo = await txClient.confirmTx(broadcastedTx);
1633
+ * ```
1634
+ */
1635
+ broadcastMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<BroadcastedTx>;
1529
1636
  /**
1530
1637
  * Estimate gas price for given transaction priority based
1531
1638
  * on the gas prices of the transactions in the last five blocks.
@@ -1569,6 +1676,13 @@ export class GrpcClient {
1569
1676
  * Get status of the transaction
1570
1677
  */
1571
1678
  txStatus(hash: string): Promise<TxStatusResponse>;
1679
+ /**
1680
+ * Create a builder for [`GrpcClient`] with multiple URL endpoints for fallback support.
1681
+ *
1682
+ * When multiple endpoints are configured, the client will automatically
1683
+ * fall back to the next endpoint if a network-related error occurs.
1684
+ */
1685
+ static withUrls(urls: string[]): GrpcClientBuilder;
1572
1686
  /**
1573
1687
  * AppVersion of the client
1574
1688
  */
@@ -1588,6 +1702,7 @@ export class GrpcClient {
1588
1702
  * ```js
1589
1703
  * const client = await GrpcClient
1590
1704
  * .withUrl("http://127.0.0.1:18080")
1705
+ * .withTimeout(5000) // Optional: 5 second timeout
1591
1706
  * .build()
1592
1707
  * ```
1593
1708
  *
@@ -1631,6 +1746,13 @@ export class GrpcClient {
1631
1746
  export class GrpcClientBuilder {
1632
1747
  private constructor();
1633
1748
  free(): void;
1749
+ /**
1750
+ * Sets the request timeout in milliseconds, overriding default one from the transport.
1751
+ *
1752
+ * Note that this method **consumes** builder and returns updated instance of it.
1753
+ * Make sure to re-assign it if you keep builder in a variable.
1754
+ */
1755
+ withTimeout(timeout_ms: bigint): GrpcClientBuilder;
1634
1756
  /**
1635
1757
  * Appends ascii metadata to all requests made by the client.
1636
1758
  *
@@ -1665,6 +1787,16 @@ export class GrpcClientBuilder {
1665
1787
  * Make sure to re-assign it if you keep builder in a variable.
1666
1788
  */
1667
1789
  withUrl(url: string): GrpcClientBuilder;
1790
+ /**
1791
+ * Add multiple URL endpoints at once for fallback support.
1792
+ *
1793
+ * When multiple endpoints are configured, the client will automatically
1794
+ * fall back to the next endpoint if a network-related error occurs.
1795
+ *
1796
+ * Note that this method **consumes** builder and returns updated instance of it.
1797
+ * Make sure to re-assign it if you keep builder in a variable.
1798
+ */
1799
+ withUrls(urls: string[]): GrpcClientBuilder;
1668
1800
  }
1669
1801
  /**
1670
1802
  * Block Header values contain metadata about the block and about the consensus,
@@ -1773,6 +1905,21 @@ export class IntoUnderlyingSource {
1773
1905
  pull(controller: ReadableStreamDefaultController): Promise<any>;
1774
1906
  cancel(): void;
1775
1907
  }
1908
+ export class IteratorResultObject {
1909
+ private constructor();
1910
+ free(): void;
1911
+ /**
1912
+ * Has the value true if the iterator is past the end of the
1913
+ * iterated sequence. In this case value optionally specifies
1914
+ * the return value of the iterator.
1915
+ */
1916
+ done: boolean;
1917
+ /**
1918
+ * Any JavaScript value returned by the iterator.
1919
+ * Can be omitted when done is true.
1920
+ */
1921
+ value: any;
1922
+ }
1776
1923
  /**
1777
1924
  * Array of bits
1778
1925
  */
@@ -2053,6 +2200,13 @@ export class NodeClient {
2053
2200
  * Get node's local peer ID.
2054
2201
  */
2055
2202
  localPeerId(): Promise<string>;
2203
+ /**
2204
+ * Subscribe to the shares from the namespace, as new headers are received by the node
2205
+ *
2206
+ * Return an async iterator which will yield all the blobs from the namespace, as the new headers
2207
+ * are being received by the node, starting from the first header received after the call.
2208
+ */
2209
+ blobSubscribe(namespace: Namespace): Promise<AsyncIterable<BlobsAtHeight | SubscriptionError>>;
2056
2210
  /**
2057
2211
  * Returns a [`BroadcastChannel`] for events generated by [`Node`].
2058
2212
  */
@@ -2069,6 +2223,13 @@ export class NodeClient {
2069
2223
  * Get all the peers that node is connected to.
2070
2224
  */
2071
2225
  connectedPeers(): Promise<Array<any>>;
2226
+ /**
2227
+ * Subscribe to new headers received by the node from the network.
2228
+ *
2229
+ * Return an async iterator which will yield all the headers, as they are being received by the
2230
+ * node, starting from the first header received after the call.
2231
+ */
2232
+ headerSubscribe(): Promise<AsyncIterable<ExtendedHeader | SubscriptionError>>;
2072
2233
  /**
2073
2234
  * Get current [`PeerTracker`] info.
2074
2235
  */
@@ -2082,6 +2243,13 @@ export class NodeClient {
2082
2243
  * Get a synced header for the block with a given hash.
2083
2244
  */
2084
2245
  getHeaderByHash(hash: string): Promise<ExtendedHeader>;
2246
+ /**
2247
+ * Subscribe to the blobs from the namespace, as new headers are received by the node
2248
+ *
2249
+ * Return an async iterator which will yield all the shares from the namespace, as the new headers
2250
+ * are being received by the node, starting from the first header received after the call.
2251
+ */
2252
+ namespaceSubscribe(namespace: Namespace): Promise<AsyncIterable<SharesAtHeight | SubscriptionError>>;
2085
2253
  /**
2086
2254
  * Request the head header from the network.
2087
2255
  */
@@ -2318,6 +2486,58 @@ export class SamplingMetadata {
2318
2486
  */
2319
2487
  readonly cids: Uint8Array[];
2320
2488
  }
2489
+ /**
2490
+ * A single fixed-size chunk of data which is used to form an [`ExtendedDataSquare`].
2491
+ *
2492
+ * All data in Celestia is split into [`Share`]s before being put into a
2493
+ * block's data square. See [`Blob::to_shares`].
2494
+ *
2495
+ * All shares have the fixed size of 512 bytes and the following structure:
2496
+ *
2497
+ * ```text
2498
+ * | Namespace | InfoByte | (optional) sequence length | data |
2499
+ * ```
2500
+ *
2501
+ * `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.
2502
+ *
2503
+ * [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
2504
+ * [`Blob::to_shares`]: crate::Blob::to_shares
2505
+ */
2506
+ export class Share {
2507
+ private constructor();
2508
+ /**
2509
+ ** Return copy of self without private attributes.
2510
+ */
2511
+ toJSON(): Object;
2512
+ /**
2513
+ * Return stringified version of self.
2514
+ */
2515
+ toString(): string;
2516
+ free(): void;
2517
+ }
2518
+ /**
2519
+ * A list of shares that were published at particular height.
2520
+ */
2521
+ export class SharesAtHeight {
2522
+ private constructor();
2523
+ /**
2524
+ ** Return copy of self without private attributes.
2525
+ */
2526
+ toJSON(): Object;
2527
+ /**
2528
+ * Return stringified version of self.
2529
+ */
2530
+ toString(): string;
2531
+ free(): void;
2532
+ /**
2533
+ * height the shares were published at
2534
+ */
2535
+ height: bigint;
2536
+ /**
2537
+ * shares published
2538
+ */
2539
+ shares: Share[];
2540
+ }
2321
2541
  /**
2322
2542
  * Signature
2323
2543
  */
@@ -2376,6 +2596,25 @@ export class StringEvent {
2376
2596
  type: string;
2377
2597
  attributes: Attribute[];
2378
2598
  }
2599
+ /**
2600
+ * Error thrown while processing subscription
2601
+ */
2602
+ export class SubscriptionError {
2603
+ private constructor();
2604
+ free(): void;
2605
+ /**
2606
+ * Height at which the error occurred, if applicable
2607
+ */
2608
+ get height(): bigint | undefined;
2609
+ /**
2610
+ * Height at which the error occurred, if applicable
2611
+ */
2612
+ set height(value: bigint | null | undefined);
2613
+ /**
2614
+ * error message
2615
+ */
2616
+ error: string;
2617
+ }
2379
2618
  /**
2380
2619
  * Status of the synchronization.
2381
2620
  */