lumina-node-wasm 0.10.3 → 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,16 +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
463
  /**
464
464
  * Transaction info
465
465
  */
@@ -500,21 +500,21 @@ type ReadableStreamType = "bytes";
500
500
 
501
501
 
502
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>);
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
+ }
517
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
518
 
519
519
  /**
520
520
  * ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
@@ -1423,52 +1423,54 @@ export class GetTxResponse {
1423
1423
  tx_response: TxResponse;
1424
1424
  }
1425
1425
  /**
1426
- * Celestia GRPC client
1426
+ * Celestia gRPC client, for builder see [`GrpcClientBuilder`]
1427
1427
  */
1428
1428
  export class GrpcClient {
1429
1429
  private constructor();
1430
1430
  free(): void;
1431
1431
  /**
1432
- * Create a new client connected with the given `url`
1432
+ * Create a builder for [`GrpcClient`] connected to `url`
1433
1433
  */
1434
- static new(url: string): Promise<GrpcClient>;
1434
+ static withUrl(url: string): GrpcClientBuilder;
1435
1435
  /**
1436
1436
  * Get auth params
1437
1437
  */
1438
- get_auth_params(): Promise<AuthParams>;
1438
+ getAuthParams(): Promise<AuthParams>;
1439
1439
  /**
1440
1440
  * Get account
1441
1441
  */
1442
- get_account(account: string): Promise<BaseAccount>;
1442
+ getAccount(account: string): Promise<BaseAccount>;
1443
1443
  /**
1444
1444
  * Get accounts
1445
1445
  */
1446
- get_accounts(): Promise<BaseAccount[]>;
1446
+ getAccounts(): Promise<BaseAccount[]>;
1447
1447
  /**
1448
- * Get balance of coins with bond denom for the given address, together with a proof,
1449
- * and verify the returned balance against the corresponding block's app hash.
1448
+ * Retrieves the verified Celestia coin balance for the address.
1450
1449
  *
1451
- * NOTE: the balance returned is the balance reported by the parent block of
1452
- * the provided header. This is due to the fact that for block N, the block's
1453
- * 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`].
1454
1456
  */
1455
- get_verified_balance(address: string, header: ExtendedHeader): Promise<Coin>;
1457
+ getVerifiedBalance(address: string, header: ExtendedHeader): Promise<Coin>;
1456
1458
  /**
1457
- * Get balance of coins with given denom
1459
+ * Retrieves the Celestia coin balance for the given address.
1458
1460
  */
1459
- get_balance(address: string, denom: string): Promise<Coin>;
1461
+ getBalance(address: string, denom: string): Promise<Coin>;
1460
1462
  /**
1461
1463
  * Get balance of all coins
1462
1464
  */
1463
- get_all_balances(address: string): Promise<Coin[]>;
1465
+ getAllBalances(address: string): Promise<Coin[]>;
1464
1466
  /**
1465
1467
  * Get balance of all spendable coins
1466
1468
  */
1467
- get_spendable_balances(address: string): Promise<Coin[]>;
1469
+ getSpendableBalances(address: string): Promise<Coin[]>;
1468
1470
  /**
1469
1471
  * Get total supply
1470
1472
  */
1471
- get_total_supply(): Promise<Coin[]>;
1473
+ getTotalSupply(): Promise<Coin[]>;
1472
1474
  /**
1473
1475
  * Get node configuration
1474
1476
  */
@@ -1476,23 +1478,23 @@ export class GrpcClient {
1476
1478
  /**
1477
1479
  * Get latest block
1478
1480
  */
1479
- get_latest_block(): Promise<Block>;
1481
+ getLatestBlock(): Promise<Block>;
1480
1482
  /**
1481
1483
  * Get block by height
1482
1484
  */
1483
- get_block_by_height(height: bigint): Promise<Block>;
1485
+ getBlockByHeight(height: bigint): Promise<Block>;
1484
1486
  /**
1485
1487
  * Issue a direct ABCI query to the application
1486
1488
  */
1487
- abci_query(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1489
+ abciQuery(data: Uint8Array, path: string, height: bigint, prove: boolean): Promise<AbciQueryResponse>;
1488
1490
  /**
1489
1491
  * Broadcast prepared and serialised transaction
1490
1492
  */
1491
- broadcast_tx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
1493
+ broadcastTx(tx_bytes: Uint8Array, mode: BroadcastMode): Promise<TxResponse>;
1492
1494
  /**
1493
1495
  * Get Tx
1494
1496
  */
1495
- get_tx(hash: string): Promise<GetTxResponse>;
1497
+ getTx(hash: string): Promise<GetTxResponse>;
1496
1498
  /**
1497
1499
  * Simulate prepared and serialised transaction, returning simulated gas usage
1498
1500
  */
@@ -1500,11 +1502,162 @@ export class GrpcClient {
1500
1502
  /**
1501
1503
  * Get blob params
1502
1504
  */
1503
- get_blob_params(): Promise<BlobParams>;
1505
+ getBlobParams(): Promise<BlobParams>;
1504
1506
  /**
1505
1507
  * Get status of the transaction
1506
1508
  */
1507
- 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;
1508
1661
  }
1509
1662
  /**
1510
1663
  * Block Header values contain metadata about the block and about the consensus,
@@ -2005,6 +2158,16 @@ export class NodeConfig {
2005
2158
  * A list of bootstrap peers to connect to.
2006
2159
  */
2007
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);
2008
2171
  /**
2009
2172
  * Whether to store data in persistent memory or not.
2010
2173
  *
@@ -2280,146 +2443,6 @@ export class TxBody {
2280
2443
  */
2281
2444
  readonly timeout_height: bigint;
2282
2445
  }
2283
- /**
2284
- * Celestia grpc transaction client.
2285
- */
2286
- export class TxClient {
2287
- free(): void;
2288
- /**
2289
- * Create a new transaction client with the specified account.
2290
- *
2291
- * Url must point to a [grpc-web proxy](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
2292
- *
2293
- * # Example with noble/curves
2294
- * ```js
2295
- * import { secp256k1 } from "@noble/curves/secp256k1";
2296
- *
2297
- * const privKey = "fdc8ac75dfa1c142dbcba77938a14dd03078052ce0b49a529dcf72a9885a3abb";
2298
- * const pubKey = secp256k1.getPublicKey(privKey);
2299
- *
2300
- * const signer = (signDoc) => {
2301
- * const bytes = protoEncodeSignDoc(signDoc);
2302
- * const sig = secp256k1.sign(bytes, privKey, { prehash: true });
2303
- * return sig.toCompactRawBytes();
2304
- * };
2305
- *
2306
- * const txClient = await new TxClient("http://127.0.0.1:18080", pubKey, signer);
2307
- * ```
2308
- *
2309
- * # Example with leap wallet
2310
- * ```js
2311
- * await window.leap.enable("mocha-4")
2312
- * const keys = await window.leap.getKey("mocha-4")
2313
- *
2314
- * const signer = (signDoc) => {
2315
- * return window.leap.signDirect("mocha-4", keys.bech32Address, signDoc, { preferNoSetFee: true })
2316
- * .then(sig => Uint8Array.from(atob(sig.signature.signature), c => c.charCodeAt(0)))
2317
- * }
2318
- *
2319
- * const tx_client = await new TxClient("http://127.0.0.1:18080", keys.pubKey, signer)
2320
- * ```
2321
- */
2322
- constructor(url: string, pubkey: Uint8Array, signer_fn: SignerFn);
2323
- /**
2324
- * estimate_gas_price takes a transaction priority and estimates the gas price based
2325
- * on the gas prices of the transactions in the last five blocks.
2326
- *
2327
- * If no transaction is found in the last five blocks, return the network
2328
- * min gas price.
2329
- */
2330
- getEstimateGasPrice(priority: TxPriority): Promise<number>;
2331
- /**
2332
- * Submit blobs to the celestia network.
2333
- *
2334
- * When no `TxConfig` is provided, client will automatically calculate needed
2335
- * gas and update the `gasPrice`, if network agreed on a new minimal value.
2336
- * To enforce specific values use a `TxConfig`.
2337
- *
2338
- * # Example
2339
- * ```js
2340
- * const ns = Namespace.newV0(new Uint8Array([97, 98, 99]));
2341
- * const data = new Uint8Array([100, 97, 116, 97]);
2342
- * const blob = new Blob(ns, data, AppVersion.latest());
2343
- *
2344
- * const txInfo = await txClient.submitBlobs([blob]);
2345
- * await txClient.submitBlobs([blob], { gasLimit: 100000n, gasPrice: 0.02, memo: "foo" });
2346
- * ```
2347
- *
2348
- * # Note
2349
- *
2350
- * Provided blobs will be consumed by this method, meaning
2351
- * they will no longer be accessible. If this behavior is not desired,
2352
- * consider using `Blob.clone()`.
2353
- *
2354
- * ```js
2355
- * const blobs = [blob1, blob2, blob3];
2356
- * await txClient.submitBlobs(blobs.map(b => b.clone()));
2357
- * ```
2358
- */
2359
- submitBlobs(blobs: Blob[], tx_config?: TxConfig | null): Promise<TxInfo>;
2360
- /**
2361
- * Submit message to the celestia network.
2362
- *
2363
- * When no `TxConfig` is provided, client will automatically calculate needed
2364
- * gas and update the `gasPrice`, if network agreed on a new minimal value.
2365
- * To enforce specific values use a `TxConfig`.
2366
- *
2367
- * # Example
2368
- * ```js
2369
- * import { Registry } from "@cosmjs/proto-signing";
2370
- *
2371
- * const registry = new Registry();
2372
- * const sendMsg = {
2373
- * typeUrl: "/cosmos.bank.v1beta1.MsgSend",
2374
- * value: {
2375
- * fromAddress: "celestia169s50psyj2f4la9a2235329xz7rk6c53zhw9mm",
2376
- * toAddress: "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9",
2377
- * amount: [{ denom: "utia", amount: "10000" }],
2378
- * },
2379
- * };
2380
- * const sendMsgAny = registry.encodeAsAny(sendMsg);
2381
- *
2382
- * const txInfo = await txClient.submitMessage(sendMsgAny);
2383
- * ```
2384
- */
2385
- submitMessage(message: ProtoAny, tx_config?: TxConfig | null): Promise<TxInfo>;
2386
- /**
2387
- * Get auth params
2388
- */
2389
- getAuthParams(): Promise<AuthParams>;
2390
- /**
2391
- * Get account
2392
- */
2393
- getAccount(account: string): Promise<BaseAccount>;
2394
- /**
2395
- * Get accounts
2396
- */
2397
- getAccounts(): Promise<BaseAccount[]>;
2398
- /**
2399
- * Get balance of coins with given denom
2400
- */
2401
- getBalance(address: string, denom: string): Promise<Coin>;
2402
- /**
2403
- * Get balance of all coins
2404
- */
2405
- getAllBalances(address: string): Promise<Coin[]>;
2406
- /**
2407
- * Get balance of all spendable coins
2408
- */
2409
- getSpendableBalances(address: string): Promise<Coin[]>;
2410
- /**
2411
- * Get total supply
2412
- */
2413
- getTotalSupply(): Promise<Coin[]>;
2414
- /**
2415
- * Chain id of the client
2416
- */
2417
- readonly chainId: string;
2418
- /**
2419
- * AppVersion of the client
2420
- */
2421
- readonly appVersion: AppVersion;
2422
- }
2423
2446
  /**
2424
2447
  * Response to a tx query
2425
2448
  */