lumina-node-wasm 0.10.2 → 0.11.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.
@@ -419,6 +419,16 @@ type ReadableStreamType = "bytes";
419
419
 
420
420
 
421
421
 
422
+ /**
423
+ * Coin
424
+ */
425
+ export interface Coin {
426
+ denom: string,
427
+ amount: bigint
428
+ }
429
+
430
+
431
+
422
432
  /**
423
433
  * Public key
424
434
  */
@@ -450,33 +460,6 @@ type ReadableStreamType = "bytes";
450
460
 
451
461
 
452
462
 
453
- /**
454
- * Coin
455
- */
456
- export interface Coin {
457
- denom: string,
458
- amount: bigint
459
- }
460
-
461
-
462
-
463
- /**
464
- * A payload to be signed
465
- */
466
- export interface SignDoc {
467
- bodyBytes: Uint8Array;
468
- authInfoBytes: Uint8Array;
469
- chainId: string;
470
- accountNumber: bigint;
471
- }
472
-
473
- /**
474
- * A function that produces a signature of a payload
475
- */
476
- export type SignerFn = ((arg: SignDoc) => Uint8Array) | ((arg: SignDoc) => Promise<Uint8Array>);
477
-
478
-
479
-
480
463
  /**
481
464
  * Transaction info
482
465
  */
@@ -516,6 +499,23 @@ export type SignerFn = ((arg: SignDoc) => Uint8Array) | ((arg: SignDoc) => Promi
516
499
  }
517
500
 
518
501
 
502
+
503
+ /**
504
+ * A payload to be signed
505
+ */
506
+ export interface SignDoc {
507
+ bodyBytes: Uint8Array;
508
+ authInfoBytes: Uint8Array;
509
+ chainId: string;
510
+ accountNumber: bigint;
511
+ }
512
+
513
+ /**
514
+ * A function that produces a signature of a payload
515
+ */
516
+ export type SignerFn = ((arg: SignDoc) => Uint8Array) | ((arg: SignDoc) => Promise<Uint8Array>);
517
+
518
+
519
519
  /**
520
520
  * ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
521
521
  */
@@ -632,6 +632,10 @@ export class AppVersion {
632
632
  * App v5
633
633
  */
634
634
  static readonly V5: AppVersion;
635
+ /**
636
+ * App v6
637
+ */
638
+ static readonly V6: AppVersion;
635
639
  }
636
640
  /**
637
641
  * Attribute defines an attribute wrapper where the key and value are
@@ -980,6 +984,33 @@ export class Commitment {
980
984
  */
981
985
  hash(): Uint8Array;
982
986
  }
987
+ /**
988
+ * Response holding consensus node configuration.
989
+ */
990
+ export class ConfigResponse {
991
+ private constructor();
992
+ free(): void;
993
+ /**
994
+ * Minimum gas price for the node to accept tx. Value is in `utia` denom.
995
+ */
996
+ get minimum_gas_price(): number | undefined;
997
+ /**
998
+ * Minimum gas price for the node to accept tx. Value is in `utia` denom.
999
+ */
1000
+ set minimum_gas_price(value: number | null | undefined);
1001
+ /**
1002
+ * How many recent blocks are stored by the node.
1003
+ */
1004
+ pruning_keep_recent: bigint;
1005
+ /**
1006
+ * Amount of blocks used as an interval to trigger prunning.
1007
+ */
1008
+ pruning_interval: bigint;
1009
+ /**
1010
+ * A height at which the node should stop advancing state.
1011
+ */
1012
+ halt_height: bigint;
1013
+ }
983
1014
  /**
984
1015
  * Conflicting block detected in light client attack
985
1016
  */
@@ -1392,76 +1423,78 @@ export class GetTxResponse {
1392
1423
  tx_response: TxResponse;
1393
1424
  }
1394
1425
  /**
1395
- * Celestia GRPC client
1426
+ * Celestia gRPC client, for builder see [`GrpcClientBuilder`]
1396
1427
  */
1397
1428
  export class GrpcClient {
1398
1429
  private constructor();
1399
1430
  free(): void;
1400
1431
  /**
1401
- * Create a new client connected with the given `url`
1432
+ * Create a builder for [`GrpcClient`] connected to `url`
1402
1433
  */
1403
- static new(url: string): Promise<GrpcClient>;
1434
+ static withUrl(url: string): GrpcClientBuilder;
1404
1435
  /**
1405
1436
  * Get auth params
1406
1437
  */
1407
- get_auth_params(): Promise<AuthParams>;
1438
+ getAuthParams(): Promise<AuthParams>;
1408
1439
  /**
1409
1440
  * Get account
1410
1441
  */
1411
- get_account(account: string): Promise<BaseAccount>;
1442
+ getAccount(account: string): Promise<BaseAccount>;
1412
1443
  /**
1413
1444
  * Get accounts
1414
1445
  */
1415
- get_accounts(): Promise<BaseAccount[]>;
1446
+ getAccounts(): Promise<BaseAccount[]>;
1416
1447
  /**
1417
- * Get balance of coins with bond denom for the given address, together with a proof,
1418
- * and verify the returned balance against the corresponding block's app hash.
1448
+ * Retrieves the verified Celestia coin balance for the address.
1419
1449
  *
1420
- * NOTE: the balance returned is the balance reported by the parent block of
1421
- * the provided header. This is due to the fact that for block N, the block's
1422
- * app hash is the result of applying the previous block's transaction list.
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`].
1423
1456
  */
1424
- get_verified_balance(address: string, header: ExtendedHeader): Promise<Coin>;
1457
+ getVerifiedBalance(address: string, header: ExtendedHeader): Promise<Coin>;
1425
1458
  /**
1426
- * Get balance of coins with given denom
1459
+ * Retrieves the Celestia coin balance for the given address.
1427
1460
  */
1428
- get_balance(address: string, denom: string): Promise<Coin>;
1461
+ getBalance(address: string, denom: string): Promise<Coin>;
1429
1462
  /**
1430
1463
  * Get balance of all coins
1431
1464
  */
1432
- get_all_balances(address: string): Promise<Coin[]>;
1465
+ getAllBalances(address: string): Promise<Coin[]>;
1433
1466
  /**
1434
1467
  * Get balance of all spendable coins
1435
1468
  */
1436
- get_spendable_balances(address: string): Promise<Coin[]>;
1469
+ getSpendableBalances(address: string): Promise<Coin[]>;
1437
1470
  /**
1438
1471
  * Get total supply
1439
1472
  */
1440
- get_total_supply(): Promise<Coin[]>;
1473
+ getTotalSupply(): Promise<Coin[]>;
1441
1474
  /**
1442
- * Get Minimum Gas price
1475
+ * Get node configuration
1443
1476
  */
1444
- get_min_gas_price(): Promise<number>;
1477
+ get_node_config(): Promise<ConfigResponse>;
1445
1478
  /**
1446
1479
  * Get latest block
1447
1480
  */
1448
- get_latest_block(): Promise<Block>;
1481
+ getLatestBlock(): Promise<Block>;
1449
1482
  /**
1450
1483
  * Get block by height
1451
1484
  */
1452
- get_block_by_height(height: bigint): Promise<Block>;
1485
+ getBlockByHeight(height: bigint): Promise<Block>;
1453
1486
  /**
1454
1487
  * Issue a direct ABCI query to the application
1455
1488
  */
1456
- abci_query(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1489
+ abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1457
1490
  /**
1458
1491
  * Broadcast prepared and serialised transaction
1459
1492
  */
1460
- broadcast_tx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
1493
+ broadcastTx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
1461
1494
  /**
1462
1495
  * Get Tx
1463
1496
  */
1464
- get_tx(hash: string): Promise<GetTxResponse>;
1497
+ getTx(hash: string): Promise<GetTxResponse>;
1465
1498
  /**
1466
1499
  * Simulate prepared and serialised transaction, returning simulated gas usage
1467
1500
  */
@@ -1469,11 +1502,162 @@ export class GrpcClient {
1469
1502
  /**
1470
1503
  * Get blob params
1471
1504
  */
1472
- get_blob_params(): Promise<BlobParams>;
1505
+ getBlobParams(): Promise<BlobParams>;
1473
1506
  /**
1474
1507
  * Get status of the transaction
1475
1508
  */
1476
- tx_status(hash: string): Promise<TxStatusResponse>;
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.
1516
+ */
1517
+ estimateGasPrice(priority: TxPriority): Promise<number>;
1518
+ /**
1519
+ * Submit blobs to the celestia network.
1520
+ *
1521
+ * # Example
1522
+ * ```js
1523
+ * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
1524
+ * const data = new Uint8Array([100, 97, 116, 97]);
1525
+ * const blob = new Blob(ns, data, AppVersion.latest());
1526
+ *
1527
+ * const txInfo = await txClient.submitBlobs([blob]);
1528
+ * await txClient.submitBlobs([blob], { gasLimit: 100000n, gasPrice: 0.02, memo: "foo" });
1529
+ * ```
1530
+ *
1531
+ * # Note
1532
+ *
1533
+ * Provided blobs will be consumed by this method, meaning
1534
+ * they will no longer be accessible. If this behavior is not desired,
1535
+ * consider using `Blob.clone()`.
1536
+ *
1537
+ * ```js
1538
+ * const blobs = [blob1, blob2, blob3];
1539
+ * await txClient.submitBlobs(blobs.map(b => b.clone()));
1540
+ * ```
1541
+ */
1542
+ submitBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<TxInfo>;
1543
+ /**
1544
+ * Submit message to the celestia network.
1545
+ *
1546
+ * # Example
1547
+ * ```js
1548
+ * import { Registry } from "@cosmjs/proto-signing";
1549
+ *
1550
+ * const registry = new Registry();
1551
+ * const sendMsg = {
1552
+ * typeUrl: "/cosmos.bank.v1beta1.MsgSend",
1553
+ * value: {
1554
+ * fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
1555
+ * toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
1556
+ * amount: [{ denom: "utia", amount: "10000" }],
1557
+ * },
1558
+ * };
1559
+ * const sendMsgAny = registry.encodeAsAny(sendMsg);
1560
+ *
1561
+ * const txInfo = await txClient.submitMessage(sendMsgAny);
1562
+ * ```
1563
+ */
1564
+ submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
1565
+ /**
1566
+ * Chain id of the client
1567
+ */
1568
+ readonly chainId: Promise<string>;
1569
+ /**
1570
+ * AppVersion of the client
1571
+ */
1572
+ readonly appVersion: Promise<AppVersion>;
1573
+ }
1574
+ /**
1575
+ * Builder for [`GrpcClient`] and [`TxClient`].
1576
+ *
1577
+ * Url must point to a [grpc-web proxy](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
1578
+ *
1579
+ * # Keyless client example
1580
+ *
1581
+ * ```js
1582
+ * const client = await GrpcClient
1583
+ * .withUrl("http://127.0.0.1:18080")
1584
+ * .build()
1585
+ * ```
1586
+ *
1587
+ * # Transaction client examples
1588
+ *
1589
+ * ## Example with noble/curves
1590
+ * ```js
1591
+ * import { secp256k1 } from "@noble/curves/secp256k1";
1592
+ *
1593
+ * const privKey = "fdc8ac75dfa1c142dbcba77938a14dd03078052ce0b49a529dcf72a9885a3abb";
1594
+ * const pubKey = secp256k1.getPublicKey(privKey);
1595
+ *
1596
+ * const signer = (signDoc) => {
1597
+ * const bytes = protoEncodeSignDoc(signDoc);
1598
+ * const sig = secp256k1.sign(bytes, privKey, { prehash: true });
1599
+ * return sig.toCompactRawBytes();
1600
+ * };
1601
+ *
1602
+ * const client = await GrpcClient
1603
+ * .withUrl("http://127.0.0.1:18080")
1604
+ * .withPubkeyAndSigner(pubKey, signer)
1605
+ * .build();
1606
+ * ```
1607
+ *
1608
+ * ## Example with leap wallet
1609
+ * ```js
1610
+ * await window.leap.enable("mocha-4")
1611
+ * const keys = await window.leap.getKey("mocha-4")
1612
+ *
1613
+ * const signer = (signDoc) => {
1614
+ * return window.leap.signDirect("mocha-4", keys.bech32Address, signDoc, { preferNoSetFee: true })
1615
+ * .then(sig => Uint8Array.from(atob(sig.signature.signature), c => c.charCodeAt(0)))
1616
+ * }
1617
+ *
1618
+ * const client = await GrpcClient
1619
+ * .withUrl("http://127.0.0.1:18080")
1620
+ * .withPubkeyAndSigner(keys.pubKey, signer)
1621
+ * .build()
1622
+ * ```
1623
+ */
1624
+ export class GrpcClientBuilder {
1625
+ private constructor();
1626
+ free(): void;
1627
+ /**
1628
+ * Set the `url` of the grpc-web server to connect to
1629
+ *
1630
+ * Note that this method **consumes** builder and returns updated instance of it.
1631
+ * Make sure to re-assign it if you keep builder in a variable.
1632
+ */
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;
1641
+ /**
1642
+ * Appends ascii metadata to all requests made by the client.
1643
+ *
1644
+ * Note that this method **consumes** builder and returns updated instance of it.
1645
+ * Make sure to re-assign it if you keep builder in a variable.
1646
+ */
1647
+ withMetadata(key: string, value: string): GrpcClientBuilder;
1648
+ /**
1649
+ * Appends binary metadata to all requests made by the client.
1650
+ *
1651
+ * Keys for binary metadata must have `-bin` suffix.
1652
+ *
1653
+ * Note that this method **consumes** builder and returns updated instance of it.
1654
+ * Make sure to re-assign it if you keep builder in a variable.
1655
+ */
1656
+ withMetadataBin(key: string, value: Uint8Array): GrpcClientBuilder;
1657
+ /**
1658
+ * build gRPC client
1659
+ */
1660
+ build(): GrpcClient;
1477
1661
  }
1478
1662
  /**
1479
1663
  * Block Header values contain metadata about the block and about the consensus,
@@ -1974,6 +2158,16 @@ export class NodeConfig {
1974
2158
  * A list of bootstrap peers to connect to.
1975
2159
  */
1976
2160
  bootnodes: string[];
2161
+ /**
2162
+ * Optionally start with a provided private key used as libp2p identity. Expects 32 bytes
2163
+ * containing ed25519 secret key.
2164
+ */
2165
+ get identity_key(): Uint8Array | undefined;
2166
+ /**
2167
+ * Optionally start with a provided private key used as libp2p identity. Expects 32 bytes
2168
+ * containing ed25519 secret key.
2169
+ */
2170
+ set identity_key(value: Uint8Array | null | undefined);
1977
2171
  /**
1978
2172
  * Whether to store data in persistent memory or not.
1979
2173
  *
@@ -2249,150 +2443,6 @@ export class TxBody {
2249
2443
  */
2250
2444
  readonly timeout_height: bigint;
2251
2445
  }
2252
- /**
2253
- * Celestia grpc transaction client.
2254
- */
2255
- export class TxClient {
2256
- free(): void;
2257
- /**
2258
- * Create a new transaction client with the specified account.
2259
- *
2260
- * Url must point to a [grpc-web proxy](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
2261
- *
2262
- * # Example with noble/curves
2263
- * ```js
2264
- * import { secp256k1 } from "@noble/curves/secp256k1";
2265
- *
2266
- * const privKey = "fdc8ac75dfa1c142dbcba77938a14dd03078052ce0b49a529dcf72a9885a3abb";
2267
- * const pubKey = secp256k1.getPublicKey(privKey);
2268
- *
2269
- * const signer = (signDoc) => {
2270
- * const bytes = protoEncodeSignDoc(signDoc);
2271
- * const sig = secp256k1.sign(bytes, privKey, { prehash: true });
2272
- * return sig.toCompactRawBytes();
2273
- * };
2274
- *
2275
- * const txClient = await new TxClient("http://127.0.0.1:18080", pubKey, signer);
2276
- * ```
2277
- *
2278
- * # Example with leap wallet
2279
- * ```js
2280
- * await window.leap.enable("mocha-4")
2281
- * const keys = await window.leap.getKey("mocha-4")
2282
- *
2283
- * const signer = (signDoc) => {
2284
- * return window.leap.signDirect("mocha-4", keys.bech32Address, signDoc, { preferNoSetFee: true })
2285
- * .then(sig => Uint8Array.from(atob(sig.signature.signature), c => c.charCodeAt(0)))
2286
- * }
2287
- *
2288
- * const tx_client = await new TxClient("http://127.0.0.1:18080", keys.pubKey, signer)
2289
- * ```
2290
- */
2291
- constructor(url: string, pubkey: Uint8Array, signer_fn: SignerFn);
2292
- /**
2293
- * Query for the current minimum gas price
2294
- */
2295
- minGasPrice(): Promise<number>;
2296
- /**
2297
- * estimate_gas_price takes a transaction priority and estimates the gas price based
2298
- * on the gas prices of the transactions in the last five blocks.
2299
- *
2300
- * If no transaction is found in the last five blocks, return the network
2301
- * min gas price.
2302
- */
2303
- getEstimateGasPrice(priority: TxPriority): Promise<number>;
2304
- /**
2305
- * Submit blobs to the celestia network.
2306
- *
2307
- * When no `TxConfig` is provided, client will automatically calculate needed
2308
- * gas and update the `gasPrice`, if network agreed on a new minimal value.
2309
- * To enforce specific values use a `TxConfig`.
2310
- *
2311
- * # Example
2312
- * ```js
2313
- * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
2314
- * const data = new Uint8Array([100, 97, 116, 97]);
2315
- * const blob = new Blob(ns, data, AppVersion.latest());
2316
- *
2317
- * const txInfo = await txClient.submitBlobs([blob]);
2318
- * await txClient.submitBlobs([blob], { gasLimit: 100000n, gasPrice: 0.02, memo: "foo" });
2319
- * ```
2320
- *
2321
- * # Note
2322
- *
2323
- * Provided blobs will be consumed by this method, meaning
2324
- * they will no longer be accessible. If this behavior is not desired,
2325
- * consider using `Blob.clone()`.
2326
- *
2327
- * ```js
2328
- * const blobs = [blob1, blob2, blob3];
2329
- * await txClient.submitBlobs(blobs.map(b => b.clone()));
2330
- * ```
2331
- */
2332
- submitBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<TxInfo>;
2333
- /**
2334
- * Submit message to the celestia network.
2335
- *
2336
- * When no `TxConfig` is provided, client will automatically calculate needed
2337
- * gas and update the `gasPrice`, if network agreed on a new minimal value.
2338
- * To enforce specific values use a `TxConfig`.
2339
- *
2340
- * # Example
2341
- * ```js
2342
- * import { Registry } from "@cosmjs/proto-signing";
2343
- *
2344
- * const registry = new Registry();
2345
- * const sendMsg = {
2346
- * typeUrl: "/cosmos.bank.v1beta1.MsgSend",
2347
- * value: {
2348
- * fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
2349
- * toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
2350
- * amount: [{ denom: "utia", amount: "10000" }],
2351
- * },
2352
- * };
2353
- * const sendMsgAny = registry.encodeAsAny(sendMsg);
2354
- *
2355
- * const txInfo = await txClient.submitMessage(sendMsgAny);
2356
- * ```
2357
- */
2358
- submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
2359
- /**
2360
- * Get auth params
2361
- */
2362
- getAuthParams(): Promise<AuthParams>;
2363
- /**
2364
- * Get account
2365
- */
2366
- getAccount(account: string): Promise<BaseAccount>;
2367
- /**
2368
- * Get accounts
2369
- */
2370
- getAccounts(): Promise<BaseAccount[]>;
2371
- /**
2372
- * Get balance of coins with given denom
2373
- */
2374
- getBalance(address: string, denom: string): Promise<Coin>;
2375
- /**
2376
- * Get balance of all coins
2377
- */
2378
- getAllBalances(address: string): Promise<Coin[]>;
2379
- /**
2380
- * Get balance of all spendable coins
2381
- */
2382
- getSpendableBalances(address: string): Promise<Coin[]>;
2383
- /**
2384
- * Get total supply
2385
- */
2386
- getTotalSupply(): Promise<Coin[]>;
2387
- /**
2388
- * Chain id of the client
2389
- */
2390
- readonly chainId: string;
2391
- /**
2392
- * AppVersion of the client
2393
- */
2394
- readonly appVersion: AppVersion;
2395
- }
2396
2446
  /**
2397
2447
  * Response to a tx query
2398
2448
  */