lumina-node-wasm 0.11.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.
@@ -384,10 +384,14 @@ export enum TxStatus {
384
384
  * The transaction was evicted from the mempool.
385
385
  */
386
386
  Evicted = 2,
387
+ /**
388
+ * The transaction was rejected
389
+ */
390
+ Rejected = 3,
387
391
  /**
388
392
  * The transaction was committed into the block.
389
393
  */
390
- Committed = 3,
394
+ Committed = 4,
391
395
  }
392
396
  /**
393
397
  * Types of votes
@@ -474,6 +478,24 @@ type ReadableStreamType = "bytes";
474
478
  height: bigint;
475
479
  }
476
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
+
477
499
  /**
478
500
  * Transaction config.
479
501
  */
@@ -536,6 +558,13 @@ export class AbciMessageLog {
536
558
  export class AbciQueryResponse {
537
559
  private constructor();
538
560
  free(): void;
561
+ /**
562
+ * The block height from which data was derived.
563
+ *
564
+ * Note that this is the height of the block containing the application's Merkle root hash,
565
+ * which represents the state as it was after committing the block at height - 1.
566
+ */
567
+ readonly height: bigint;
539
568
  /**
540
569
  * Response code.
541
570
  */
@@ -579,13 +608,6 @@ export class AbciQueryResponse {
579
608
  * Additional information. May be non-deterministic.
580
609
  */
581
610
  info: string;
582
- /**
583
- * The block height from which data was derived.
584
- *
585
- * Note that this is the height of the block containing the application's Merkle root hash,
586
- * which represents the state as it was after committing the block at height - 1.
587
- */
588
- readonly height: bigint;
589
611
  }
590
612
  /**
591
613
  * Address of an account.
@@ -751,6 +773,29 @@ export class BlobParams {
751
773
  */
752
774
  gov_max_square_size: bigint;
753
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
+ }
754
799
  /**
755
800
  * Blocks consist of a header, transactions, votes (the commit), and a list of
756
801
  * evidence of malfeasance (i.e. signing conflicting votes).
@@ -840,16 +885,16 @@ export class BroadcastMode {
840
885
  * zero-value for mode ordering
841
886
  */
842
887
  static readonly Unspecified: BroadcastMode;
843
- /**
844
- * DEPRECATED: use `BroadcastMode` `Sync` instead,
845
- * `BroadcastMode` `Block` is not supported by the SDK from v0.47.x onwards.
846
- */
847
- static readonly Block: BroadcastMode;
848
888
  /**
849
889
  * `BroadcastMode` `Sync` defines a tx broadcasting mode where the client waits for
850
890
  * a CheckTx execution response only.
851
891
  */
852
892
  static readonly Sync: BroadcastMode;
893
+ /**
894
+ * DEPRECATED: use `BroadcastMode` `Sync` instead,
895
+ * `BroadcastMode` `Block` is not supported by the SDK from v0.47.x onwards.
896
+ */
897
+ static readonly Block: BroadcastMode;
853
898
  /**
854
899
  * `BroadcastMode` `Async` defines a tx broadcasting mode where the client returns
855
900
  * immediately.
@@ -1026,6 +1071,9 @@ export class ConflictingBlock {
1026
1071
  */
1027
1072
  validator_set: ValidatorSet;
1028
1073
  }
1074
+ /**
1075
+ * Network connection information
1076
+ */
1029
1077
  export class ConnectionCountersSnapshot {
1030
1078
  private constructor();
1031
1079
  /**
@@ -1122,7 +1170,7 @@ export class Data {
1122
1170
  * # fn extended_header() -> ExtendedHeader {
1123
1171
  * # unimplemented!();
1124
1172
  * # }
1125
- * # fn shares_with_proof(_: Height, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1173
+ * # fn shares_with_proof(_: u64, _: &Namespace) -> (Vec<Share>, NamespaceProof) {
1126
1174
  * # unimplemented!();
1127
1175
  * # }
1128
1176
  * // fetch the block header and data for your namespace
@@ -1151,32 +1199,32 @@ export class DataAvailabilityHeader {
1151
1199
  */
1152
1200
  toString(): string;
1153
1201
  free(): void;
1202
+ /**
1203
+ * Get a root of the row with the given index.
1204
+ */
1205
+ rowRoot(row: number): any;
1154
1206
  /**
1155
1207
  * Merkle roots of the [`ExtendedDataSquare`] rows.
1156
1208
  */
1157
1209
  rowRoots(): Array<any>;
1158
1210
  /**
1159
- * Merkle roots of the [`ExtendedDataSquare`] columns.
1211
+ * Get the a root of the column with the given index.
1160
1212
  */
1161
- columnRoots(): Array<any>;
1213
+ columnRoot(column: number): any;
1162
1214
  /**
1163
- * Get a root of the row with the given index.
1215
+ * Merkle roots of the [`ExtendedDataSquare`] columns.
1164
1216
  */
1165
- rowRoot(row: number): any;
1217
+ columnRoots(): Array<any>;
1166
1218
  /**
1167
- * Get the a root of the column with the given index.
1219
+ * Get the size of the [`ExtendedDataSquare`] for which this header was built.
1168
1220
  */
1169
- columnRoot(column: number): any;
1221
+ squareWidth(): number;
1170
1222
  /**
1171
1223
  * Compute the combined hash of all rows and columns.
1172
1224
  *
1173
1225
  * This is the data commitment for the block.
1174
1226
  */
1175
1227
  hash(): any;
1176
- /**
1177
- * Get the size of the [`ExtendedDataSquare`] for which this header was built.
1178
- */
1179
- squareWidth(): number;
1180
1228
  }
1181
1229
  /**
1182
1230
  * Duplicate vote evidence
@@ -1252,40 +1300,10 @@ export class ExtendedHeader {
1252
1300
  */
1253
1301
  toString(): string;
1254
1302
  free(): void;
1255
- /**
1256
- * Clone a header producing a deep copy of it.
1257
- */
1258
- clone(): ExtendedHeader;
1259
- /**
1260
- * Get the block height.
1261
- */
1262
- height(): bigint;
1263
- /**
1264
- * Get the block time.
1265
- */
1266
- time(): number;
1267
- /**
1268
- * Get the block hash.
1269
- */
1270
- hash(): string;
1271
- /**
1272
- * Get the hash of the previous header.
1273
- */
1274
- previousHeaderHash(): string;
1275
1303
  /**
1276
1304
  * Decode protobuf encoded header and then validate it.
1277
1305
  */
1278
1306
  validate(): void;
1279
- /**
1280
- * Verify a chain of adjacent untrusted headers and make sure
1281
- * they are adjacent to `self`.
1282
- *
1283
- * # Errors
1284
- *
1285
- * If verification fails, this function will return an error with a reason of failure.
1286
- * This function will also return an error if untrusted headers and `self` don't form contiguous range
1287
- */
1288
- verify(untrusted: ExtendedHeader): void;
1289
1307
  /**
1290
1308
  * Verify a chain of adjacent untrusted headers.
1291
1309
  *
@@ -1308,6 +1326,10 @@ export class ExtendedHeader {
1308
1326
  * to each other.
1309
1327
  */
1310
1328
  verifyRange(untrusted: ExtendedHeader[]): void;
1329
+ /**
1330
+ * Get the hash of the previous header.
1331
+ */
1332
+ previousHeaderHash(): string;
1311
1333
  /**
1312
1334
  * Verify a chain of adjacent untrusted headers and make sure
1313
1335
  * they are adjacent to `self`.
@@ -1331,21 +1353,47 @@ export class ExtendedHeader {
1331
1353
  */
1332
1354
  verifyAdjacentRange(untrusted: ExtendedHeader[]): void;
1333
1355
  /**
1334
- * Header of the block data availability.
1356
+ * Get the block hash.
1335
1357
  */
1336
- dah: DataAvailabilityHeader;
1358
+ hash(): string;
1337
1359
  /**
1338
- * Tendermint block header.
1360
+ * Get the block time.
1339
1361
  */
1340
- readonly header: any;
1362
+ time(): number;
1341
1363
  /**
1342
- * Commit metadata and signatures from validators committing the block.
1364
+ * Clone a header producing a deep copy of it.
1343
1365
  */
1344
- readonly commit: any;
1366
+ clone(): ExtendedHeader;
1367
+ /**
1368
+ * Get the block height.
1369
+ */
1370
+ height(): bigint;
1371
+ /**
1372
+ * Verify a chain of adjacent untrusted headers and make sure
1373
+ * they are adjacent to `self`.
1374
+ *
1375
+ * # Errors
1376
+ *
1377
+ * If verification fails, this function will return an error with a reason of failure.
1378
+ * This function will also return an error if untrusted headers and `self` don't form contiguous range
1379
+ */
1380
+ verify(untrusted: ExtendedHeader): void;
1345
1381
  /**
1346
1382
  * Information about the set of validators commiting the block.
1347
1383
  */
1348
1384
  readonly validatorSet: any;
1385
+ /**
1386
+ * Commit metadata and signatures from validators committing the block.
1387
+ */
1388
+ readonly commit: any;
1389
+ /**
1390
+ * Tendermint block header.
1391
+ */
1392
+ readonly header: any;
1393
+ /**
1394
+ * Header of the block data availability.
1395
+ */
1396
+ dah: DataAvailabilityHeader;
1349
1397
  }
1350
1398
  /**
1351
1399
  * Fee includes the amount of coins paid in fees and the maximum
@@ -1429,92 +1477,41 @@ export class GrpcClient {
1429
1477
  private constructor();
1430
1478
  free(): void;
1431
1479
  /**
1432
- * Create a builder for [`GrpcClient`] connected to `url`
1480
+ * Issue a direct ABCI query to the application
1433
1481
  */
1434
- static withUrl(url: string): GrpcClientBuilder;
1482
+ abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1435
1483
  /**
1436
- * Get auth params
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
+ * ```
1437
1497
  */
1438
- getAuthParams(): Promise<AuthParams>;
1498
+ confirmTx(broadcasted_tx: BroadcastedTx, tx_config?: TxConfig | null): Promise<TxInfo>;
1439
1499
  /**
1440
1500
  * Get account
1441
1501
  */
1442
1502
  getAccount(account: string): Promise<BaseAccount>;
1443
- /**
1444
- * Get accounts
1445
- */
1446
- getAccounts(): Promise<BaseAccount[]>;
1447
- /**
1448
- * Retrieves the verified Celestia coin balance for the address.
1449
- *
1450
- * # Notes
1451
- *
1452
- * This returns the verified balance which is the one that was reported by
1453
- * the previous network block. In other words, if you transfer some coins,
1454
- * you need to wait 1 more block in order to see the new balance. If you want
1455
- * something more immediate then use [`GrpcClient::get_balance`].
1456
- */
1457
- getVerifiedBalance(address: string, header: ExtendedHeader): Promise<Coin>;
1458
1503
  /**
1459
1504
  * Retrieves the Celestia coin balance for the given address.
1460
1505
  */
1461
1506
  getBalance(address: string, denom: string): Promise<Coin>;
1462
- /**
1463
- * Get balance of all coins
1464
- */
1465
- getAllBalances(address: string): Promise<Coin[]>;
1466
- /**
1467
- * Get balance of all spendable coins
1468
- */
1469
- getSpendableBalances(address: string): Promise<Coin[]>;
1470
- /**
1471
- * Get total supply
1472
- */
1473
- getTotalSupply(): Promise<Coin[]>;
1474
- /**
1475
- * Get node configuration
1476
- */
1477
- get_node_config(): Promise<ConfigResponse>;
1478
- /**
1479
- * Get latest block
1480
- */
1481
- getLatestBlock(): Promise<Block>;
1482
- /**
1483
- * Get block by height
1484
- */
1485
- getBlockByHeight(height: bigint): Promise<Block>;
1486
- /**
1487
- * Issue a direct ABCI query to the application
1488
- */
1489
- abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1490
1507
  /**
1491
1508
  * Broadcast prepared and serialised transaction
1492
1509
  */
1493
1510
  broadcastTx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
1494
1511
  /**
1495
- * Get Tx
1496
- */
1497
- getTx(hash: string): Promise<GetTxResponse>;
1498
- /**
1499
- * Simulate prepared and serialised transaction, returning simulated gas usage
1500
- */
1501
- simulate(tx_bytes: Uint8Array): Promise<GasInfo>;
1502
- /**
1503
- * Get blob params
1504
- */
1505
- getBlobParams(): Promise<BlobParams>;
1506
- /**
1507
- * Get status of the transaction
1508
- */
1509
- txStatus(hash: string): Promise<TxStatusResponse>;
1510
- /**
1511
- * Estimate gas price for given transaction priority based
1512
- * on the gas prices of the transactions in the last five blocks.
1513
- *
1514
- * If no transaction is found in the last five blocks, return the network
1515
- * min gas price.
1512
+ * Get accounts
1516
1513
  */
1517
- estimateGasPrice(priority: TxPriority): Promise<number>;
1514
+ getAccounts(): Promise<BaseAccount[]>;
1518
1515
  /**
1519
1516
  * Submit blobs to the celestia network.
1520
1517
  *
@@ -1563,16 +1560,140 @@ export class GrpcClient {
1563
1560
  */
1564
1561
  submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
1565
1562
  /**
1566
- * Chain id of the client
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
+ * ```
1567
1586
  */
1568
- readonly chainId: Promise<string>;
1587
+ broadcastBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<BroadcastedTx>;
1569
1588
  /**
1570
- * AppVersion of the client
1589
+ * Get auth params
1571
1590
  */
1572
- readonly appVersion: Promise<AppVersion>;
1573
- }
1574
- /**
1575
- * Builder for [`GrpcClient`] and [`TxClient`].
1591
+ getAuthParams(): Promise<AuthParams>;
1592
+ /**
1593
+ * Get blob params
1594
+ */
1595
+ getBlobParams(): Promise<BlobParams>;
1596
+ /**
1597
+ * Get node configuration
1598
+ */
1599
+ get_node_config(): Promise<ConfigResponse>;
1600
+ /**
1601
+ * Get balance of all coins
1602
+ */
1603
+ getAllBalances(address: string): Promise<Coin[]>;
1604
+ /**
1605
+ * Get latest block
1606
+ */
1607
+ getLatestBlock(): Promise<Block>;
1608
+ /**
1609
+ * Get total supply
1610
+ */
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>;
1636
+ /**
1637
+ * Estimate gas price for given transaction priority based
1638
+ * on the gas prices of the transactions in the last five blocks.
1639
+ *
1640
+ * If no transaction is found in the last five blocks, return the network
1641
+ * min gas price.
1642
+ */
1643
+ estimateGasPrice(priority: TxPriority): Promise<number>;
1644
+ /**
1645
+ * Get block by height
1646
+ */
1647
+ getBlockByHeight(height: bigint): Promise<Block>;
1648
+ /**
1649
+ * Retrieves the verified Celestia coin balance for the address.
1650
+ *
1651
+ * # Notes
1652
+ *
1653
+ * This returns the verified balance which is the one that was reported by
1654
+ * the previous network block. In other words, if you transfer some coins,
1655
+ * you need to wait 1 more block in order to see the new balance. If you want
1656
+ * something more immediate then use [`GrpcClient::get_balance`].
1657
+ */
1658
+ getVerifiedBalance(address: string, header: ExtendedHeader): Promise<Coin>;
1659
+ /**
1660
+ * Get balance of all spendable coins
1661
+ */
1662
+ getSpendableBalances(address: string): Promise<Coin[]>;
1663
+ /**
1664
+ * Get Tx
1665
+ */
1666
+ getTx(hash: string): Promise<GetTxResponse>;
1667
+ /**
1668
+ * Simulate prepared and serialised transaction, returning simulated gas usage
1669
+ */
1670
+ simulate(tx_bytes: Uint8Array): Promise<GasInfo>;
1671
+ /**
1672
+ * Create a builder for [`GrpcClient`] connected to `url`
1673
+ */
1674
+ static withUrl(url: string): GrpcClientBuilder;
1675
+ /**
1676
+ * Get status of the transaction
1677
+ */
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;
1686
+ /**
1687
+ * AppVersion of the client
1688
+ */
1689
+ readonly appVersion: Promise<AppVersion>;
1690
+ /**
1691
+ * Chain id of the client
1692
+ */
1693
+ readonly chainId: Promise<string>;
1694
+ }
1695
+ /**
1696
+ * Builder for [`GrpcClient`] and [`TxClient`].
1576
1697
  *
1577
1698
  * Url must point to a [grpc-web proxy](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
1578
1699
  *
@@ -1581,6 +1702,7 @@ export class GrpcClient {
1581
1702
  * ```js
1582
1703
  * const client = await GrpcClient
1583
1704
  * .withUrl("http://127.0.0.1:18080")
1705
+ * .withTimeout(5000) // Optional: 5 second timeout
1584
1706
  * .build()
1585
1707
  * ```
1586
1708
  *
@@ -1625,19 +1747,12 @@ export class GrpcClientBuilder {
1625
1747
  private constructor();
1626
1748
  free(): void;
1627
1749
  /**
1628
- * Set the `url` of the grpc-web server to connect to
1750
+ * Sets the request timeout in milliseconds, overriding default one from the transport.
1629
1751
  *
1630
1752
  * Note that this method **consumes** builder and returns updated instance of it.
1631
1753
  * Make sure to re-assign it if you keep builder in a variable.
1632
1754
  */
1633
- withUrl(url: string): GrpcClientBuilder;
1634
- /**
1635
- * Add public key and signer to the client being built
1636
- *
1637
- * Note that this method **consumes** builder and returns updated instance of it.
1638
- * Make sure to re-assign it if you keep builder in a variable.
1639
- */
1640
- withPubkeyAndSigner(account_pubkey: Uint8Array, signer_fn: SignerFn): GrpcClientBuilder;
1755
+ withTimeout(timeout_ms: bigint): GrpcClientBuilder;
1641
1756
  /**
1642
1757
  * Appends ascii metadata to all requests made by the client.
1643
1758
  *
@@ -1654,10 +1769,34 @@ export class GrpcClientBuilder {
1654
1769
  * Make sure to re-assign it if you keep builder in a variable.
1655
1770
  */
1656
1771
  withMetadataBin(key: string, value: Uint8Array): GrpcClientBuilder;
1772
+ /**
1773
+ * Add public key and signer to the client being built
1774
+ *
1775
+ * Note that this method **consumes** builder and returns updated instance of it.
1776
+ * Make sure to re-assign it if you keep builder in a variable.
1777
+ */
1778
+ withPubkeyAndSigner(account_pubkey: Uint8Array, signer_fn: SignerFn): GrpcClientBuilder;
1657
1779
  /**
1658
1780
  * build gRPC client
1659
1781
  */
1660
1782
  build(): GrpcClient;
1783
+ /**
1784
+ * Set the `url` of the grpc-web server to connect to
1785
+ *
1786
+ * Note that this method **consumes** builder and returns updated instance of it.
1787
+ * Make sure to re-assign it if you keep builder in a variable.
1788
+ */
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;
1661
1800
  }
1662
1801
  /**
1663
1802
  * Block Header values contain metadata about the block and about the consensus,
@@ -1747,18 +1886,18 @@ export class Header {
1747
1886
  export class IntoUnderlyingByteSource {
1748
1887
  private constructor();
1749
1888
  free(): void;
1750
- start(controller: ReadableByteStreamController): void;
1751
1889
  pull(controller: ReadableByteStreamController): Promise<any>;
1890
+ start(controller: ReadableByteStreamController): void;
1752
1891
  cancel(): void;
1753
- readonly type: ReadableStreamType;
1754
1892
  readonly autoAllocateChunkSize: number;
1893
+ readonly type: ReadableStreamType;
1755
1894
  }
1756
1895
  export class IntoUnderlyingSink {
1757
1896
  private constructor();
1758
1897
  free(): void;
1759
- write(chunk: any): Promise<any>;
1760
- close(): Promise<any>;
1761
1898
  abort(reason: any): Promise<any>;
1899
+ close(): Promise<any>;
1900
+ write(chunk: any): Promise<any>;
1762
1901
  }
1763
1902
  export class IntoUnderlyingSource {
1764
1903
  private constructor();
@@ -1766,6 +1905,21 @@ export class IntoUnderlyingSource {
1766
1905
  pull(controller: ReadableStreamDefaultController): Promise<any>;
1767
1906
  cancel(): void;
1768
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
+ }
1769
1923
  /**
1770
1924
  * Array of bits
1771
1925
  */
@@ -1860,6 +2014,12 @@ export class ModeInfo {
1860
2014
  * Return signature mode for the stored signature(s)
1861
2015
  */
1862
2016
  signature_mode(): SignatureMode;
2017
+ /**
2018
+ * Multi is the mode info for a multisig public key
2019
+ * mode_infos is the corresponding modes of the signers of the multisig
2020
+ * which could include nested multisig public keys
2021
+ */
2022
+ readonly mode_infos: ModeInfo[] | undefined;
1863
2023
  /**
1864
2024
  * Single is the mode info for a single signer. It is structured as a message
1865
2025
  * to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the
@@ -1871,12 +2031,6 @@ export class ModeInfo {
1871
2031
  * bitarray specifies which keys within the multisig are signing
1872
2032
  */
1873
2033
  readonly bitarray: JsBitVector | undefined;
1874
- /**
1875
- * Multi is the mode info for a multisig public key
1876
- * mode_infos is the corresponding modes of the signers of the multisig
1877
- * which could include nested multisig public keys
1878
- */
1879
- readonly mode_infos: ModeInfo[] | undefined;
1880
2034
  }
1881
2035
  /**
1882
2036
  * Namespace of the data published to the celestia network.
@@ -1911,13 +2065,9 @@ export class Namespace {
1911
2065
  toString(): string;
1912
2066
  free(): void;
1913
2067
  /**
1914
- * Create a new [`Namespace`] version `0` with given id.
1915
- *
1916
- * Check [`Namespace::new_v0`] for more details.
1917
- *
1918
- * [`Namespace::new_v0`]: https://docs.rs/celestia-types/latest/celestia_types/nmt/struct.Namespace.html#method.new_v0
2068
+ * Converts the [`Namespace`] to a byte slice.
1919
2069
  */
1920
- static newV0(id: Uint8Array): Namespace;
2070
+ asBytes(): Uint8Array;
1921
2071
  /**
1922
2072
  * Create a new [`Namespace`] from the raw bytes.
1923
2073
  *
@@ -1929,28 +2079,44 @@ export class Namespace {
1929
2079
  */
1930
2080
  static fromRaw(raw: Uint8Array): Namespace;
1931
2081
  /**
1932
- * Converts the [`Namespace`] to a byte slice.
2082
+ * Create a new [`Namespace`] version `0` with given id.
2083
+ *
2084
+ * Check [`Namespace::new_v0`] for more details.
2085
+ *
2086
+ * [`Namespace::new_v0`]: https://docs.rs/celestia-types/latest/celestia_types/nmt/struct.Namespace.html#method.new_v0
1933
2087
  */
1934
- asBytes(): Uint8Array;
2088
+ static newV0(id: Uint8Array): Namespace;
1935
2089
  /**
1936
2090
  * Namespace size in bytes.
1937
2091
  */
1938
2092
  static readonly NS_SIZE: number;
2093
+ /**
2094
+ * Returns the first byte indicating the version of the [`Namespace`].
2095
+ */
2096
+ readonly version: number;
1939
2097
  /**
1940
2098
  * Primary reserved [`Namespace`] for the compact `Share`s with `cosmos SDK` transactions.
1941
2099
  */
1942
2100
  static readonly TRANSACTION: Namespace;
2101
+ /**
2102
+ * The [`Namespace`] for `parity shares`.
2103
+ *
2104
+ * It is the namespace with which all the `parity shares` from
2105
+ * `ExtendedDataSquare` are inserted to the `Nmt` when computing
2106
+ * merkle roots.
2107
+ */
2108
+ static readonly PARITY_SHARE: Namespace;
1943
2109
  /**
1944
2110
  * Primary reserved [`Namespace`] for the compact Shares with MsgPayForBlobs transactions.
1945
2111
  */
1946
2112
  static readonly PAY_FOR_BLOB: Namespace;
1947
2113
  /**
1948
- * Primary reserved [`Namespace`] for the `Share`s used for padding.
2114
+ * Secondary reserved [`Namespace`] used for padding after the blobs.
1949
2115
  *
1950
- * `Share`s with this namespace are inserted after other shares from primary reserved namespace
1951
- * so that user-defined namespaces are correctly aligned in `ExtendedDataSquare`
2116
+ * It is used to fill up the `original data square` after all user-submitted
2117
+ * blobs before the parity data is generated for the `ExtendedDataSquare`.
1952
2118
  */
1953
- static readonly PRIMARY_RESERVED_PADDING: Namespace;
2119
+ static readonly TAIL_PADDING: Namespace;
1954
2120
  /**
1955
2121
  * Maximal primary reserved [`Namespace`].
1956
2122
  *
@@ -1964,24 +2130,12 @@ export class Namespace {
1964
2130
  */
1965
2131
  static readonly MIN_SECONDARY_RESERVED: Namespace;
1966
2132
  /**
1967
- * Secondary reserved [`Namespace`] used for padding after the blobs.
1968
- *
1969
- * It is used to fill up the `original data square` after all user-submitted
1970
- * blobs before the parity data is generated for the `ExtendedDataSquare`.
1971
- */
1972
- static readonly TAIL_PADDING: Namespace;
1973
- /**
1974
- * The [`Namespace`] for `parity shares`.
2133
+ * Primary reserved [`Namespace`] for the `Share`s used for padding.
1975
2134
  *
1976
- * It is the namespace with which all the `parity shares` from
1977
- * `ExtendedDataSquare` are inserted to the `Nmt` when computing
1978
- * merkle roots.
1979
- */
1980
- static readonly PARITY_SHARE: Namespace;
1981
- /**
1982
- * Returns the first byte indicating the version of the [`Namespace`].
2135
+ * `Share`s with this namespace are inserted after other shares from primary reserved namespace
2136
+ * so that user-defined namespaces are correctly aligned in `ExtendedDataSquare`
1983
2137
  */
1984
- readonly version: number;
2138
+ static readonly PRIMARY_RESERVED_PADDING: Namespace;
1985
2139
  /**
1986
2140
  * Returns the trailing 28 bytes indicating the id of the [`Namespace`].
1987
2141
  */
@@ -2019,118 +2173,142 @@ export class NetworkInfoSnapshot {
2019
2173
  export class NodeClient {
2020
2174
  free(): void;
2021
2175
  /**
2022
- * Create a new connection to a Lumina node running in [`NodeWorker`]. Provided `port` is
2023
- * expected to have `MessagePort`-like interface for sending and receiving messages.
2176
+ * Check whether Lumina is currently running
2024
2177
  */
2025
- constructor(port: any);
2178
+ isRunning(): Promise<boolean>;
2026
2179
  /**
2027
- * Establish a new connection to the existing worker over provided port
2180
+ * Get synced headers from the given heights range.
2181
+ *
2182
+ * If start of the range is undefined (None), the first returned header will be of height 1.
2183
+ * If end of the range is undefined (None), the last returned header will be the last header in the
2184
+ * store.
2185
+ *
2186
+ * # Errors
2187
+ *
2188
+ * If range contains a height of a header that is not found in the store.
2028
2189
  */
2029
- addConnectionToWorker(port: any): Promise<void>;
2190
+ getHeaders(start_height?: bigint | null, end_height?: bigint | null): Promise<ExtendedHeader[]>;
2030
2191
  /**
2031
- * Check whether Lumina is currently running
2192
+ * Get current header syncing info.
2032
2193
  */
2033
- isRunning(): Promise<boolean>;
2194
+ syncerInfo(): Promise<SyncingInfoSnapshot>;
2034
2195
  /**
2035
- * Start a node with the provided config, if it's not running
2196
+ * Get current network info.
2036
2197
  */
2037
- start(config: NodeConfig): Promise<void>;
2038
- stop(): Promise<void>;
2198
+ networkInfo(): Promise<NetworkInfoSnapshot>;
2039
2199
  /**
2040
2200
  * Get node's local peer ID.
2041
2201
  */
2042
2202
  localPeerId(): Promise<string>;
2043
2203
  /**
2044
- * Get current [`PeerTracker`] info.
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.
2045
2208
  */
2046
- peerTrackerInfo(): Promise<PeerTrackerInfoSnapshot>;
2209
+ blobSubscribe(namespace: Namespace): Promise<AsyncIterable<BlobsAtHeight | SubscriptionError>>;
2210
+ /**
2211
+ * Returns a [`BroadcastChannel`] for events generated by [`Node`].
2212
+ */
2213
+ eventsChannel(): Promise<BroadcastChannel>;
2214
+ /**
2215
+ * Trust or untrust the peer with a given ID.
2216
+ */
2217
+ setPeerTrust(peer_id: string, is_trusted: boolean): Promise<void>;
2047
2218
  /**
2048
2219
  * Wait until the node is connected to at least 1 peer.
2049
2220
  */
2050
2221
  waitConnected(): Promise<void>;
2051
2222
  /**
2052
- * Wait until the node is connected to at least 1 trusted peer.
2223
+ * Get all the peers that node is connected to.
2053
2224
  */
2054
- waitConnectedTrusted(): Promise<void>;
2225
+ connectedPeers(): Promise<Array<any>>;
2055
2226
  /**
2056
- * Get current network info.
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.
2057
2231
  */
2058
- networkInfo(): Promise<NetworkInfoSnapshot>;
2232
+ headerSubscribe(): Promise<AsyncIterable<ExtendedHeader | SubscriptionError>>;
2059
2233
  /**
2060
- * Get all the multiaddresses on which the node listens.
2234
+ * Get current [`PeerTracker`] info.
2061
2235
  */
2062
- listeners(): Promise<Array<any>>;
2236
+ peerTrackerInfo(): Promise<PeerTrackerInfoSnapshot>;
2063
2237
  /**
2064
- * Get all the peers that node is connected to.
2238
+ * Request all blobs with provided namespace in the block corresponding to this header
2239
+ * using bitswap protocol.
2065
2240
  */
2066
- connectedPeers(): Promise<Array<any>>;
2241
+ requestAllBlobs(namespace: Namespace, block_height: bigint, timeout_secs?: number | null): Promise<Blob[]>;
2067
2242
  /**
2068
- * Trust or untrust the peer with a given ID.
2243
+ * Get a synced header for the block with a given hash.
2069
2244
  */
2070
- setPeerTrust(peer_id: string, is_trusted: boolean): Promise<void>;
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>>;
2071
2253
  /**
2072
2254
  * Request the head header from the network.
2073
2255
  */
2074
2256
  requestHeadHeader(): Promise<ExtendedHeader>;
2075
2257
  /**
2076
- * Request a header for the block with a given hash from the network.
2258
+ * Get a synced header for the block with a given height.
2077
2259
  */
2078
- requestHeaderByHash(hash: string): Promise<ExtendedHeader>;
2260
+ getHeaderByHeight(height: bigint): Promise<ExtendedHeader>;
2079
2261
  /**
2080
- * Request a header for the block with a given height from the network.
2262
+ * Get the latest locally synced header.
2081
2263
  */
2082
- requestHeaderByHeight(height: bigint): Promise<ExtendedHeader>;
2264
+ getLocalHeadHeader(): Promise<ExtendedHeader>;
2083
2265
  /**
2084
- * Request headers in range (from, from + amount] from the network.
2085
- *
2086
- * The headers will be verified with the `from` header.
2266
+ * Get data sampling metadata of an already sampled height.
2087
2267
  */
2088
- requestVerifiedHeaders(from: ExtendedHeader, amount: bigint): Promise<ExtendedHeader[]>;
2268
+ getSamplingMetadata(height: bigint): Promise<SamplingMetadata | undefined>;
2089
2269
  /**
2090
- * Request all blobs with provided namespace in the block corresponding to this header
2091
- * using bitswap protocol.
2270
+ * Request a header for the block with a given hash from the network.
2092
2271
  */
2093
- requestAllBlobs(namespace: Namespace, block_height: bigint, timeout_secs?: number | null): Promise<Blob[]>;
2272
+ requestHeaderByHash(hash: string): Promise<ExtendedHeader>;
2094
2273
  /**
2095
- * Get current header syncing info.
2274
+ * Wait until the node is connected to at least 1 trusted peer.
2096
2275
  */
2097
- syncerInfo(): Promise<SyncingInfoSnapshot>;
2276
+ waitConnectedTrusted(): Promise<void>;
2098
2277
  /**
2099
2278
  * Get the latest header announced in the network.
2100
2279
  */
2101
2280
  getNetworkHeadHeader(): Promise<ExtendedHeader | undefined>;
2102
2281
  /**
2103
- * Get the latest locally synced header.
2282
+ * Establish a new connection to the existing worker over provided port
2104
2283
  */
2105
- getLocalHeadHeader(): Promise<ExtendedHeader>;
2284
+ addConnectionToWorker(port: any): Promise<void>;
2106
2285
  /**
2107
- * Get a synced header for the block with a given hash.
2286
+ * Request a header for the block with a given height from the network.
2108
2287
  */
2109
- getHeaderByHash(hash: string): Promise<ExtendedHeader>;
2288
+ requestHeaderByHeight(height: bigint): Promise<ExtendedHeader>;
2110
2289
  /**
2111
- * Get a synced header for the block with a given height.
2290
+ * Request headers in range (from, from + amount] from the network.
2291
+ *
2292
+ * The headers will be verified with the `from` header.
2112
2293
  */
2113
- getHeaderByHeight(height: bigint): Promise<ExtendedHeader>;
2294
+ requestVerifiedHeaders(from: ExtendedHeader, amount: bigint): Promise<ExtendedHeader[]>;
2114
2295
  /**
2115
- * Get synced headers from the given heights range.
2116
- *
2117
- * If start of the range is undefined (None), the first returned header will be of height 1.
2118
- * If end of the range is undefined (None), the last returned header will be the last header in the
2119
- * store.
2120
- *
2121
- * # Errors
2122
- *
2123
- * If range contains a height of a header that is not found in the store.
2296
+ * Create a new connection to a Lumina node running in [`NodeWorker`]. Provided `port` is
2297
+ * expected to have `MessagePort`-like interface for sending and receiving messages.
2124
2298
  */
2125
- getHeaders(start_height?: bigint | null, end_height?: bigint | null): Promise<ExtendedHeader[]>;
2299
+ constructor(port: any);
2126
2300
  /**
2127
- * Get data sampling metadata of an already sampled height.
2301
+ * Stop the node.
2128
2302
  */
2129
- getSamplingMetadata(height: bigint): Promise<SamplingMetadata | undefined>;
2303
+ stop(): Promise<void>;
2130
2304
  /**
2131
- * Returns a [`BroadcastChannel`] for events generated by [`Node`].
2305
+ * Start the node with the provided config, if it's not running
2132
2306
  */
2133
- eventsChannel(): Promise<BroadcastChannel>;
2307
+ start(config: NodeConfig): Promise<void>;
2308
+ /**
2309
+ * Get all the multiaddresses on which the node listens.
2310
+ */
2311
+ listeners(): Promise<Array<any>>;
2134
2312
  }
2135
2313
  /**
2136
2314
  * Config for the lumina wasm node.
@@ -2209,7 +2387,13 @@ export class NodeConfig {
2209
2387
  */
2210
2388
  export class NodeWorker {
2211
2389
  free(): void;
2390
+ /**
2391
+ * Create a new `NodeWorker` with a port-like JS object.
2392
+ */
2212
2393
  constructor(port_like_object: any);
2394
+ /**
2395
+ * Run `NodeWorker` main loop.
2396
+ */
2213
2397
  run(): Promise<void>;
2214
2398
  }
2215
2399
  /**
@@ -2302,6 +2486,58 @@ export class SamplingMetadata {
2302
2486
  */
2303
2487
  readonly cids: Uint8Array[];
2304
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
+ }
2305
2541
  /**
2306
2542
  * Signature
2307
2543
  */
@@ -2360,6 +2596,25 @@ export class StringEvent {
2360
2596
  type: string;
2361
2597
  attributes: Attribute[];
2362
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
+ }
2363
2618
  /**
2364
2619
  * Status of the synchronization.
2365
2620
  */
@@ -2410,17 +2665,6 @@ export class Tx {
2410
2665
  export class TxBody {
2411
2666
  private constructor();
2412
2667
  free(): void;
2413
- /**
2414
- * `messages` is a list of messages to be executed. The required signers of
2415
- * those messages define the number and order of elements in `AuthInfo`'s
2416
- * signer_infos and Tx's signatures. Each required signer address is added to
2417
- * the list only the first time it occurs.
2418
- *
2419
- * By convention, the first required signer (usually from the first message)
2420
- * is referred to as the primary signer and pays the fee for the whole
2421
- * transaction.
2422
- */
2423
- messages(): ProtoAny[];
2424
2668
  /**
2425
2669
  * `extension_options` are arbitrary options that can be added by chains
2426
2670
  * when the default options are not sufficient. If any of these are present
@@ -2433,6 +2677,17 @@ export class TxBody {
2433
2677
  * and can't be handled, they will be ignored
2434
2678
  */
2435
2679
  non_critical_extension_options(): ProtoAny[];
2680
+ /**
2681
+ * `messages` is a list of messages to be executed. The required signers of
2682
+ * those messages define the number and order of elements in `AuthInfo`'s
2683
+ * signer_infos and Tx's signatures. Each required signer address is added to
2684
+ * the list only the first time it occurs.
2685
+ *
2686
+ * By convention, the first required signer (usually from the first message)
2687
+ * is referred to as the primary signer and pays the fee for the whole
2688
+ * transaction.
2689
+ */
2690
+ messages(): ProtoAny[];
2436
2691
  /**
2437
2692
  * `memo` is any arbitrary memo to be added to the transaction.
2438
2693
  */
@@ -2449,6 +2704,17 @@ export class TxBody {
2449
2704
  export class TxResponse {
2450
2705
  private constructor();
2451
2706
  free(): void;
2707
+ /**
2708
+ * Events defines all the events emitted by processing a transaction. Note,
2709
+ * these events include those emitted by processing all the messages and those
2710
+ * emitted from the ante. Whereas Logs contains the events, with
2711
+ * additional metadata, emitted only by processing the messages.
2712
+ */
2713
+ readonly events: JsEvent[];
2714
+ /**
2715
+ * The block height
2716
+ */
2717
+ readonly height: bigint;
2452
2718
  /**
2453
2719
  * Namespace for the Code
2454
2720
  */
@@ -2488,17 +2754,6 @@ export class TxResponse {
2488
2754
  * it's genesis time.
2489
2755
  */
2490
2756
  timestamp: string;
2491
- /**
2492
- * The block height
2493
- */
2494
- readonly height: bigint;
2495
- /**
2496
- * Events defines all the events emitted by processing a transaction. Note,
2497
- * these events include those emitted by processing all the messages and those
2498
- * emitted from the ante. Whereas Logs contains the events, with
2499
- * additional metadata, emitted only by processing the messages.
2500
- */
2501
- readonly events: JsEvent[];
2502
2757
  }
2503
2758
  /**
2504
2759
  * Response to a tx status query
@@ -2506,6 +2761,10 @@ export class TxResponse {
2506
2761
  export class TxStatusResponse {
2507
2762
  private constructor();
2508
2763
  free(): void;
2764
+ /**
2765
+ * Height of the block in which the transaction was committed.
2766
+ */
2767
+ readonly height: bigint;
2509
2768
  /**
2510
2769
  * Index of the transaction in block.
2511
2770
  */
@@ -2524,10 +2783,6 @@ export class TxStatusResponse {
2524
2783
  * Status of the transaction.
2525
2784
  */
2526
2785
  status: TxStatus;
2527
- /**
2528
- * Height of the block in which the transaction was committed.
2529
- */
2530
- readonly height: bigint;
2531
2786
  }
2532
2787
  /**
2533
2788
  * Address of a validator.