@ckb-ccc/core 1.19.1 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/advanced.d.mts +2 -2
  3. package/dist/advanced.mjs +1 -1
  4. package/{dist.commonjs/advancedBarrel-CSQ2SmeJ.d.ts → dist/advancedBarrel-Di0YBlWc.d.mts} +2029 -1639
  5. package/dist/advancedBarrel-Di0YBlWc.d.mts.map +1 -0
  6. package/dist/advancedBarrel.d.mts +2 -2
  7. package/dist/advancedBarrel.mjs +1 -1
  8. package/dist/advancedBarrel.mjs.map +1 -1
  9. package/dist/barrel-G6e8gZrB.mjs +7 -0
  10. package/dist/barrel-G6e8gZrB.mjs.map +1 -0
  11. package/dist/barrel.d.mts +2 -2
  12. package/dist/barrel.mjs +1 -1
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.mjs +1 -1
  15. package/dist/transformers-DxPrDQko.mjs +2 -0
  16. package/dist/transformers-DxPrDQko.mjs.map +1 -0
  17. package/dist.commonjs/advanced.d.ts +2 -2
  18. package/dist.commonjs/advanced.js +1 -1
  19. package/{dist/advancedBarrel-BwJIDnvL.d.mts → dist.commonjs/advancedBarrel-B57gAzdK.d.ts} +2030 -1638
  20. package/dist.commonjs/advancedBarrel-B57gAzdK.d.ts.map +1 -0
  21. package/dist.commonjs/advancedBarrel.d.ts +2 -2
  22. package/dist.commonjs/advancedBarrel.js +1 -1
  23. package/dist.commonjs/advancedBarrel.js.map +1 -1
  24. package/dist.commonjs/barrel-BOCFtFjq.js +23 -0
  25. package/dist.commonjs/barrel-BOCFtFjq.js.map +1 -0
  26. package/dist.commonjs/barrel.d.ts +2 -2
  27. package/dist.commonjs/barrel.js +1 -1
  28. package/dist.commonjs/index.d.ts +2 -2
  29. package/dist.commonjs/index.js +1 -1
  30. package/dist.commonjs/{rolldown-runtime-DWNI8pZO.js → rolldown-runtime-Chgba0Kb.js} +1 -1
  31. package/dist.commonjs/transformers-0FqvcPy2.js +2 -0
  32. package/dist.commonjs/transformers-0FqvcPy2.js.map +1 -0
  33. package/package.json +8 -7
  34. package/src/advancedBarrel.ts +1 -0
  35. package/src/bytes/advanced.ts +1 -6
  36. package/src/bytes/index.ts +37 -10
  37. package/src/ckb/transaction.ts +7 -5
  38. package/src/client/client.ts +75 -19
  39. package/src/client/clientPublicMainnet.ts +75 -36
  40. package/src/client/clientPublicTestnet.ts +75 -36
  41. package/src/client/jsonRpc/client.ts +77 -30
  42. package/src/client/jsonRpc/transformers.ts +4 -4
  43. package/src/jsonRpc/index.ts +1 -0
  44. package/src/jsonRpc/requestor.ts +74 -21
  45. package/src/jsonRpc/transports/advanced.ts +0 -4
  46. package/src/jsonRpc/transports/factory.ts +12 -5
  47. package/src/jsonRpc/transports/fallback.ts +9 -5
  48. package/src/jsonRpc/transports/http.ts +21 -17
  49. package/src/jsonRpc/transports/index.ts +4 -0
  50. package/src/jsonRpc/transports/transport.ts +32 -6
  51. package/src/jsonRpc/transports/webSocket.ts +67 -20
  52. package/src/keystore/index.ts +3 -3
  53. package/src/molecule/codec.ts +20 -17
  54. package/src/signer/advanced.ts +1 -0
  55. package/src/signer/btc/verify.ts +2 -2
  56. package/src/signer/ckb/secp256k1Signing.ts +3 -3
  57. package/src/signer/doge/signerDoge.ts +1 -1
  58. package/src/signer/doge/signerDogePrivateKey.ts +1 -1
  59. package/src/signer/index.ts +1 -0
  60. package/src/signer/jsonRpc/handler.ts +217 -0
  61. package/src/signer/jsonRpc/index.ts +2 -0
  62. package/src/signer/jsonRpc/network.ts +15 -0
  63. package/src/signer/jsonRpc/signer.ts +234 -0
  64. package/src/signer/jsonRpc/transformers.ts +67 -0
  65. package/src/utils/abortSignal.ts +42 -0
  66. package/src/utils/index.ts +2 -0
  67. package/src/utils/owner/aggregated.ts +56 -0
  68. package/src/utils/owner/index.ts +4 -0
  69. package/src/utils/owner/owner.ts +141 -0
  70. package/src/utils/owner/refCount.ts +78 -0
  71. package/src/utils/owner/unique.ts +30 -0
  72. package/tsdown.config.mts +1 -0
  73. package/dist/address.advanced-Cka_9tcR.mjs +0 -2
  74. package/dist/address.advanced-Cka_9tcR.mjs.map +0 -1
  75. package/dist/advancedBarrel-BwJIDnvL.d.mts.map +0 -1
  76. package/dist/barrel-DsK2p-Rh.mjs +0 -7
  77. package/dist/barrel-DsK2p-Rh.mjs.map +0 -1
  78. package/dist.commonjs/address.advanced-BTrmYDic.js +0 -2
  79. package/dist.commonjs/address.advanced-BTrmYDic.js.map +0 -1
  80. package/dist.commonjs/advancedBarrel-CSQ2SmeJ.d.ts.map +0 -1
  81. package/dist.commonjs/barrel-D8_wJLfr.js +0 -23
  82. package/dist.commonjs/barrel-D8_wJLfr.js.map +0 -1
@@ -1,9 +1,10 @@
1
+ //#endregion
1
2
  //#region src/bytes/advanced.d.ts
2
3
  /**
3
4
  * Represents the possible encoding formats for converting bytes.
4
5
  * @public
5
6
  */
6
- type BytesFromEncoding = "utf8" | "utf16le" | "latin1" | "base64" | "base64url" | "hex" | "ascii" | "binary" | "ucs2";
7
+ type BytesFromEncoding = "utf8" | "base64" | "base64url" | "hex";
7
8
  //#endregion
8
9
  //#region src/bytes/index.d.ts
9
10
  /**
@@ -525,10 +526,192 @@ declare function numLeFromBytes(val: BytesLike): Num;
525
526
  */
526
527
  declare function numBeFromBytes(val: BytesLike): Num;
527
528
  //#endregion
529
+ //#region src/utils/abortSignal.d.ts
530
+ /**
531
+ * Creates a signal that aborts when any of the input signals aborts.
532
+ *
533
+ * Uses the native `AbortSignal.any` when available and falls back to an
534
+ * `AbortController` implementation for older runtimes.
535
+ *
536
+ * @public
537
+ */
538
+ declare function abortSignalAny(signals: readonly AbortSignal[]): AbortSignal;
539
+ //#endregion
528
540
  //#region src/utils/constructor.d.ts
529
541
  type Constructor<T, Args extends any[] = any[]> = new (...args: Args) => T;
530
542
  type AbstractConstructor<T, Args extends any[] = any[]> = abstract new (...args: Args) => T;
531
543
  //#endregion
544
+ //#region src/utils/owner/owner.d.ts
545
+ /**
546
+ * An ownership claim moved out of an {@link Owner}.
547
+ *
548
+ * @public
549
+ */
550
+ declare class OwnerMoved<T> {
551
+ /** The owned value. */
552
+ readonly value: T;
553
+ private readonly disposer;
554
+ private disposing?;
555
+ constructor(
556
+ /** The owned value. */
557
+ value: T, disposer: (value: T) => PromiseLike<void> | void);
558
+ /** Disposes this ownership claim. */
559
+ dispose(): Promise<void>;
560
+ }
561
+ declare const ownerId: unique symbol;
562
+ /**
563
+ * Owns the lifecycle of a value.
564
+ *
565
+ * @example
566
+ * ```ts
567
+ * class ConnectionOwner extends Owner<Connection> {
568
+ * constructor(protected readonly value_: Connection) {
569
+ * super();
570
+ * }
571
+ *
572
+ * protected release(connection: Connection): Promise<void> {
573
+ * return connection.close();
574
+ * }
575
+ * }
576
+ * ```
577
+ *
578
+ * @public
579
+ */
580
+ declare abstract class Owner<T> {
581
+ protected abstract readonly value_: T;
582
+ private readonly [ownerId];
583
+ private disposing?;
584
+ /** Whether this ownership claim has not been moved or disposed. */
585
+ get isValid(): boolean;
586
+ /** Returns whether a value implements CCC Owner semantics. */
587
+ static is(value: unknown): value is Owner<unknown>;
588
+ /**
589
+ * The owned value.
590
+ *
591
+ * @throws If this ownership has been moved or disposed.
592
+ */
593
+ get value(): T;
594
+ /**
595
+ * Releases this ownership claim.
596
+ *
597
+ * Implementations decide whether this disposes the value immediately or,
598
+ * for example, only decrements a reference count.
599
+ */
600
+ protected abstract release(value: T): PromiseLike<void> | void;
601
+ /**
602
+ * Disposes this ownership claim. Repeated calls are safe.
603
+ */
604
+ dispose(): Promise<void>;
605
+ /**
606
+ * Maps the owned value while transferring this ownership claim.
607
+ *
608
+ * The mapper runs before the claim is moved, so a mapper failure leaves this
609
+ * Owner active. After a successful mapping, this Owner is invalidated and the
610
+ * returned Owner retains its release semantics.
611
+ */
612
+ map<U>(mapper: (value: T) => U): Owner<U>;
613
+ /**
614
+ * Moves the ownership claim out of this owner without disposing it.
615
+ *
616
+ * Access is invalidated synchronously and the moved claim retains this
617
+ * Owner's release semantics.
618
+ *
619
+ * @throws If this owner no longer has an ownership claim.
620
+ */
621
+ protected move(): OwnerMoved<T>;
622
+ /**
623
+ * Moves an ownership claim between Owner implementations.
624
+ *
625
+ * @throws If the source owner has already been moved or disposed.
626
+ */
627
+ protected static moveFrom<T>(owner: Owner<T>): OwnerMoved<T>;
628
+ }
629
+ //#endregion
630
+ //#region src/utils/owner/aggregated.d.ts
631
+ type Owners = readonly Owner<any>[];
632
+ type OwnerValues<T extends Owners> = { [K in keyof T]: T[K] extends Owner<infer U> ? U : never; };
633
+ /**
634
+ * An Owner that aggregates multiple ownership claims.
635
+ *
636
+ * Disposing it attempts to release every claim and aggregates any failures.
637
+ *
638
+ * @public
639
+ */
640
+ declare class OwnerAggregated<T extends readonly unknown[]> extends Owner<T> {
641
+ protected readonly value_: T;
642
+ private readonly owners;
643
+ private constructor();
644
+ /** Moves multiple ownership claims into one Owner. */
645
+ static from<const TOwners extends Owners>(owners: TOwners): OwnerAggregated<OwnerValues<TOwners>>;
646
+ protected release(): Promise<void>;
647
+ }
648
+ //#endregion
649
+ //#region src/utils/owner/refCount.d.ts
650
+ /**
651
+ * A reference-counted Owner for a shared value.
652
+ *
653
+ * The source ownership is disposed after the final OwnerRefCount is disposed.
654
+ * Each clone owns one reference and can be disposed independently.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * const controller = new AbortController();
659
+ * const first = OwnerRefCount.new(
660
+ * controller,
661
+ * (controller) => controller.abort(),
662
+ * );
663
+ * const second = first.clone();
664
+ *
665
+ * await first.dispose();
666
+ * console.log(controller.signal.aborted); // false
667
+ *
668
+ * await second.dispose();
669
+ * console.log(controller.signal.aborted); // true
670
+ * ```
671
+ *
672
+ * @public
673
+ */
674
+ declare class OwnerRefCount<T> extends Owner<T> {
675
+ private readonly state;
676
+ private constructor();
677
+ protected get value_(): T;
678
+ /** Creates the first reference-counted Owner for a value. */
679
+ static new<T>(value: T, disposer: (value: T) => PromiseLike<void> | void): OwnerRefCount<T>;
680
+ /**
681
+ * Moves an ownership claim into a new reference-counted Owner.
682
+ *
683
+ * @throws If the source Owner has already been moved or disposed.
684
+ */
685
+ static from<T>(owner: Owner<T>): OwnerRefCount<T>;
686
+ /** Creates another Owner for the same shared value. */
687
+ clone(): OwnerRefCount<T>;
688
+ protected release(): Promise<void> | void;
689
+ }
690
+ //#endregion
691
+ //#region src/utils/owner/unique.d.ts
692
+ /**
693
+ * An Owner with a single, transferable ownership claim.
694
+ *
695
+ * @example
696
+ * ```ts
697
+ * const owner = new OwnerUnique(
698
+ * new AbortController(),
699
+ * (controller) => controller.abort(),
700
+ * );
701
+ *
702
+ * const signal = owner.value.signal;
703
+ * await owner.dispose();
704
+ * ```
705
+ *
706
+ * @public
707
+ */
708
+ declare class OwnerUnique<T> extends Owner<T> {
709
+ protected readonly value_: T;
710
+ private readonly disposer;
711
+ constructor(value_: T, disposer: (value: T) => PromiseLike<void> | void);
712
+ protected release(value: T): void | PromiseLike<void>;
713
+ }
714
+ //#endregion
532
715
  //#region src/utils/proxy.d.ts
533
716
  /**
534
717
  * Utilities for creating composition wrappers.
@@ -1349,62 +1532,89 @@ declare class HasherKeecak256 implements Hasher {
1349
1532
  }
1350
1533
  //#endregion
1351
1534
  //#region src/jsonRpc/transports/transport.d.ts
1535
+ type JsonRpcId = string | number;
1352
1536
  type JsonRpcPayload = {
1353
- id: number;
1537
+ id: JsonRpcId;
1354
1538
  jsonrpc: "2.0";
1355
1539
  method: string;
1356
1540
  params: unknown[] | Record<string, unknown>;
1357
1541
  };
1358
- interface Transport {
1542
+ type JsonRpcErrorLike<Data = unknown> = {
1543
+ code: number;
1544
+ message: string;
1545
+ data?: Data;
1546
+ };
1547
+ declare class JsonRpcError<Data = unknown> extends Error {
1548
+ readonly code: number;
1549
+ readonly data?: Data;
1550
+ constructor(error: JsonRpcErrorLike<Data>);
1551
+ }
1552
+ type JsonRpcResponse<Result = unknown, ErrorData = unknown> = {
1553
+ id: JsonRpcId;
1554
+ jsonrpc: "2.0";
1555
+ } & ({
1556
+ result: Result;
1557
+ error?: never;
1558
+ } | {
1559
+ result?: never;
1560
+ error: JsonRpcErrorLike<ErrorData>;
1561
+ });
1562
+ interface JsonRpcTransport {
1359
1563
  /**
1360
1564
  * Sends a JSON-RPC request to the server.
1361
1565
  *
1362
1566
  * @param payload - The JSON-RPC payload to send.
1363
- * @returns The result of the JSON-RPC request.
1364
- *
1365
- * @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
1567
+ * @returns The JSON-RPC response.
1366
1568
  */
1367
- request(data: JsonRpcPayload): Promise<unknown>;
1569
+ request(payload: JsonRpcPayload): Promise<JsonRpcResponse>;
1570
+ }
1571
+ //#endregion
1572
+ //#region src/jsonRpc/transports/fallback.d.ts
1573
+ declare class JsonRpcTransportFallback implements JsonRpcTransport {
1574
+ private readonly transports;
1575
+ private i;
1576
+ constructor(transports: JsonRpcTransport[]);
1577
+ request(data: JsonRpcPayload): Promise<JsonRpcResponse>;
1368
1578
  }
1369
1579
  //#endregion
1370
1580
  //#region src/jsonRpc/transports/http.d.ts
1371
- declare class TransportHttp implements Transport {
1581
+ declare class JsonRpcTransportHttp implements JsonRpcTransport {
1372
1582
  private readonly url;
1373
1583
  private readonly timeout;
1374
1584
  constructor(url: string, timeout?: number);
1375
- request(payload: JsonRpcPayload): Promise<any>;
1585
+ request(payload: JsonRpcPayload): Promise<JsonRpcResponse>;
1376
1586
  }
1377
1587
  //#endregion
1378
1588
  //#region src/jsonRpc/transports/webSocket.d.ts
1379
- declare class TransportWebSocket implements Transport {
1589
+ declare class JsonRpcTransportWebSocket implements JsonRpcTransport {
1380
1590
  private readonly url;
1381
1591
  private readonly timeout;
1382
1592
  private ongoing;
1593
+ private disposed;
1383
1594
  private socket?;
1384
1595
  private openSocket?;
1596
+ /**
1597
+ * @deprecated Use {@link JsonRpcTransportWebSocket.open} to make lifecycle
1598
+ * ownership explicit. This constructor will become private in a future
1599
+ * release.
1600
+ */
1385
1601
  constructor(url: string, timeout?: number);
1386
- request(data: JsonRpcPayload): Promise<unknown>;
1387
- }
1388
- //#endregion
1389
- //#region src/jsonRpc/transports/factory.d.ts
1390
- declare function transportFromUri(uri: string, config?: {
1391
- timeout?: number;
1392
- }): TransportWebSocket | TransportHttp;
1393
- //#endregion
1394
- //#region src/jsonRpc/transports/fallback.d.ts
1395
- declare class TransportFallback implements Transport {
1396
- private readonly transports;
1397
- private i;
1398
- constructor(transports: Transport[]);
1399
- request(data: JsonRpcPayload): Promise<unknown>;
1602
+ /** Opens an owned WebSocket transport. */
1603
+ static open(url: string, timeout?: number): OwnerUnique<JsonRpcTransportWebSocket>;
1604
+ request(data: JsonRpcPayload): Promise<JsonRpcResponse>;
1605
+ private dispose;
1400
1606
  }
1401
1607
  //#endregion
1402
1608
  //#region src/jsonRpc/requestor.d.ts
1609
+ /**
1610
+ * @deprecated Used only by the legacy positional constructor. Use the static
1611
+ * {@link RequestorJsonRpc.new} or {@link RequestorJsonRpc.open} methods.
1612
+ */
1403
1613
  type RequestorJsonRpcConfig = {
1404
1614
  fallbacks?: string[];
1405
1615
  timeout?: number;
1406
1616
  maxConcurrent?: number;
1407
- transport?: Transport;
1617
+ transport?: JsonRpcTransport;
1408
1618
  };
1409
1619
  declare class RequestorJsonRpc {
1410
1620
  private readonly url_;
@@ -1412,19 +1622,36 @@ declare class RequestorJsonRpc {
1412
1622
  readonly maxConcurrent?: number;
1413
1623
  private concurrent;
1414
1624
  private readonly pending;
1415
- readonly transport: Transport;
1625
+ readonly transport: JsonRpcTransport;
1416
1626
  private id;
1417
1627
  /**
1418
- * Creates an instance of ClientJsonRpc.
1628
+ * Creates a Requestor using legacy positional arguments.
1419
1629
  *
1420
1630
  * @param url_ - The URL of the JSON-RPC server.
1421
1631
  * @param timeout - The timeout for requests in milliseconds
1632
+ * @deprecated Use {@link RequestorJsonRpc.new} with a borrowed Transport or
1633
+ * {@link RequestorJsonRpc.open} when creating Transports.
1422
1634
  */
1423
1635
  constructor(url_: string, config?: RequestorJsonRpcConfig, onError?: ((err: unknown) => Promise<void> | void) | undefined);
1636
+ /** Creates a Requestor that borrows an existing Transport. */
1637
+ static new({ transport, maxConcurrent, onError }: {
1638
+ transport: JsonRpcTransport;
1639
+ maxConcurrent?: number;
1640
+ onError?: (err: unknown) => Promise<void> | void;
1641
+ }): RequestorJsonRpc;
1642
+ /** Opens a Requestor with ownership of its default transports. */
1643
+ static open({ urls: [url, ...fallbacks], onError, ...config }: {
1644
+ urls: readonly [string, ...string[]];
1645
+ timeout?: number;
1646
+ maxConcurrent?: number;
1647
+ onError?: (err: unknown) => Promise<void> | void;
1648
+ }): Owner<RequestorJsonRpc>;
1424
1649
  /**
1425
1650
  * Returns the URL of the JSON-RPC server.
1426
1651
  *
1427
1652
  * @returns The URL of the JSON-RPC server.
1653
+ * @deprecated URL belongs to Transport construction and is unavailable for
1654
+ * Requestors created with {@link RequestorJsonRpc.new}.
1428
1655
  */
1429
1656
  get url(): string;
1430
1657
  /**
@@ -2874,6 +3101,94 @@ declare class SignerEvmAddressReadonly extends SignerEvm {
2874
3101
  */
2875
3102
  declare function verifyMessageEvmPersonal(message: string | BytesLike, signature: string, address: string): boolean;
2876
3103
  //#endregion
3104
+ //#region src/signer/jsonRpc/transformers.d.ts
3105
+ type SignerJsonRpcInfo = {
3106
+ type: SignerType;
3107
+ signType: SignerSignType;
3108
+ name?: string;
3109
+ icon?: string;
3110
+ };
3111
+ type SignerJsonRpcInfoPayload = {
3112
+ type: SignerType;
3113
+ sign_type: SignerSignType;
3114
+ name?: string;
3115
+ icon?: string;
3116
+ };
3117
+ type SignerJsonRpcMessageToSign = {
3118
+ type: "string";
3119
+ value: string;
3120
+ } | {
3121
+ type: "bytes";
3122
+ value: Hex;
3123
+ };
3124
+ declare class SignerJsonRpcTransformers {
3125
+ static infoFrom(info: SignerJsonRpcInfo): SignerJsonRpcInfoPayload;
3126
+ static infoTo(info: SignerJsonRpcInfoPayload): SignerJsonRpcInfo;
3127
+ static messageFrom(message: string | BytesLike): SignerJsonRpcMessageToSign;
3128
+ static messageTo(message: unknown): string | Uint8Array;
3129
+ }
3130
+ //#endregion
3131
+ //#region src/signer/jsonRpc/handler.d.ts
3132
+ type SignerJsonRpcConfirmation = {
3133
+ method: "connect";
3134
+ networkId: string;
3135
+ } | {
3136
+ method: "sign_message";
3137
+ message: SignerJsonRpcMessageToSign;
3138
+ } | {
3139
+ method: "sign_transaction";
3140
+ transaction: Transaction;
3141
+ };
3142
+ type SignerJsonRpcHandlerConfig = {
3143
+ getSigner: () => Signer | undefined;
3144
+ getSignerMetadata?: () => Pick<SignerJsonRpcInfo, "name" | "icon">;
3145
+ /** Connects the requested network and returns its connected Signer. */
3146
+ connect: (networkId: string) => Promise<Signer>;
3147
+ confirmRequest: (request: SignerJsonRpcConfirmation) => Promise<boolean>;
3148
+ };
3149
+ type SignerJsonRpcHandler = (payload: JsonRpcPayload) => unknown;
3150
+ declare function buildSignerJsonRpcHandler({ connect, confirmRequest, getSigner, getSignerMetadata }: SignerJsonRpcHandlerConfig): SignerJsonRpcHandler;
3151
+ //#endregion
3152
+ //#region src/signer/jsonRpc/signer.d.ts
3153
+ type SignerJsonRpcConfig = Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError"> & {
3154
+ /** Cleans up integration-owned resources before replacement is announced. */
3155
+ disconnectHandler?: () => PromiseLike<void> | void;
3156
+ };
3157
+ declare class SignerJsonRpc extends Signer {
3158
+ readonly requestor: RequestorJsonRpc;
3159
+ private info;
3160
+ private readonly disconnectHandler?;
3161
+ private connecting?;
3162
+ private disconnecting?;
3163
+ private scriptsPromise?;
3164
+ private internalAddressPromise?;
3165
+ private identityPromise?;
3166
+ private readonly replacedListeners;
3167
+ private constructor();
3168
+ /** Creates a Signer that borrows an existing Transport. */
3169
+ static new(client: Client, config: SignerJsonRpcConfig): Promise<SignerJsonRpc>;
3170
+ get type(): SignerType;
3171
+ get signType(): SignerSignType;
3172
+ get url(): string;
3173
+ get name(): string | undefined;
3174
+ get icon(): string | undefined;
3175
+ connect(): Promise<void>;
3176
+ disconnect(): Promise<void>;
3177
+ onReplaced(listener: () => void): () => boolean;
3178
+ replace(): void;
3179
+ isConnected(): Promise<boolean>;
3180
+ getScripts(): Promise<Script[]>;
3181
+ getAddressObjs(): Promise<Address[]>;
3182
+ getInternalAddress(): Promise<string>;
3183
+ getIdentity(): Promise<string>;
3184
+ signMessageRaw: Signer["signMessageRaw"];
3185
+ prepareTransaction: Signer["prepareTransaction"];
3186
+ signOnlyTransaction: Signer["signOnlyTransaction"];
3187
+ buildSender(rpcMethod: Parameters<RequestorJsonRpc["request"]>[0], inTransformers?: Parameters<RequestorJsonRpc["request"]>[2], outTransformer?: Parameters<RequestorJsonRpc["request"]>[3]): (...request: unknown[]) => Promise<unknown>;
3188
+ private clearReadCache;
3189
+ private requestConnect;
3190
+ }
3191
+ //#endregion
2877
3192
  //#region src/signer/nostr/signerNostr.d.ts
2878
3193
  /**
2879
3194
  * @public
@@ -2974,7 +3289,7 @@ declare function buildNostrEventFromMessage(message: string | BytesLike): NostrE
2974
3289
  declare function nostrEventHash(event: NostrEvent): Bytes$1;
2975
3290
  declare function verifyMessageNostrEvent(message: string | BytesLike, signature: string, address: string): boolean;
2976
3291
  declare namespace barrel_d_exports {
2977
- export { AbstractConstructor, Address, AddressLike, Bytes$1 as Bytes, BytesLike, Cell, CellAny, CellAnyLike, CellDep, CellDepInfo, CellDepInfoLike, CellDepLike, CellDepVec, CellInput, CellInputLike, CellInputVec, CellLike, CellOutput, CellOutputLike, CellOutputVec, Client, ClientBlock, ClientBlockHeader, ClientBlockHeaderLike, ClientBlockLike, ClientBlockUncle, ClientBlockUncleLike, ClientCache, ClientCacheMemory, ClientFindCellsResponse, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKey, ClientIndexerSearchKeyFilter, ClientIndexerSearchKeyFilterLike, ClientIndexerSearchKeyLike, ClientIndexerSearchKeyTransaction, ClientIndexerSearchKeyTransactionLike, ClientJsonRpc, ClientJsonRpcConfig, ClientPublicMainnet, ClientPublicTestnet, ClientTransactionResponse, ClientTransactionResponseLike, Codec, CodecBool, CodecByte, CodecByte16, CodecByte32, CodecByte4, CodecByte8, CodecBytes, CodecLike, CodecRaw, CodecUint128, CodecUint128BE, CodecUint128LE, CodecUint16, CodecUint16BE, CodecUint16LE, CodecUint256, CodecUint256BE, CodecUint256LE, CodecUint32, CodecUint32BE, CodecUint32LE, CodecUint512, CodecUint512BE, CodecUint512LE, CodecUint64, CodecUint64BE, CodecUint64LE, CodecUint8, Constructor, DecodedType, DepType, DepTypeCodec, DepTypeLike, EncodableType, Entity, Epoch, EpochLike, ErrorClientBase, ErrorClientBaseLike, ErrorClientDuplicatedTransaction, ErrorClientMaxFeeRateExceeded, ErrorClientRBFRejected, ErrorClientResolveUnknown, ErrorClientVerification, ErrorClientWaitTransactionTimeout, ErrorTransactionInsufficientCapacity, ErrorTransactionInsufficientCoin, FixedPoint, FixedPointLike, HASH_CKB_LENGTH, HASH_CKB_SHORT_LENGTH, HashType, HashTypeCodec, HashTypeLike, Hasher, HasherCkb, HasherKeecak256, Hex, HexLike, InputToSign, InputToSignLike, KnownScript, LumosTransactionSkeletonType, MultisigCkbWitness, MultisigCkbWitnessLike, NetworkPreference, NostrEvent, Num, NumLike, One, OutPoint, OutPointLike, OutputsValidator, Proxy, RawTransaction, RequestorJsonRpc, RequestorJsonRpcConfig, SECP256K1_SIGNATURE_LENGTH, Script, ScriptInfo, ScriptInfoLike, ScriptLike, ScriptOpt, ScriptVec, SignPsbtOptions, SignPsbtOptionsLike, Signature, Signer, SignerAlwaysError, SignerBtc, SignerBtcPublicKeyReadonly, SignerCkbAlwaysSuccess, SignerCkbPrivateKey, SignerCkbPublicKey, SignerCkbScriptReadonly, SignerDoge, SignerDogeAddressReadonly, SignerDogePrivateKey, SignerDummy, SignerEvm, SignerEvmAddressReadonly, SignerInfo, SignerMultisig, SignerMultisigCkbPrivateKey, SignerMultisigCkbReadonly, SignerMultisigNotEnoughSignaturesError, SignerNostr, SignerNostrPrivateKey, SignerNostrPublicKeyReadonly, SignerOpenLink, SignerSignType, SignerType, Since, SinceLike, Transaction, TransactionLike, TransactionStatus, Wallet, WitnessArgs, WitnessArgsLike, Zero, apply, btcEcdsaPublicKeyHash, btcP2pkhAddressFromPublicKey, btcPublicKeyFromP2pkhAddress, btcVarLengthBytesFrom, buildNostrEventFromMessage, bytesConcat, bytesConcatTo, bytesEq, bytesFrom, bytesLen, bytesLenUnsafe, bytesTo, calcDaoClaimEpoch, calcDaoProfit, codec, codecPadding, codecUint, codecUintNumber, depTypeFrom, depTypeFromBytes, depTypeToBytes, epochFrom, epochFromHex, epochToHex, fixedPointFrom, fixedPointToString, gcd, hashCkb, hashCkbShort, hashTypeFrom, hashTypeFromBytes, hashTypeId, hashTypeToBytes, hexFrom, isDaoOutputLimitExceeded, isWebview, keystoreDecrypt, keystoreEncrypt, messageHashBtcEcdsa, messageHashCkbSecp256k1, messageHashDogeEcdsa, barrel_d_exports$1 as mol, nostrEventHash, numBeFromBytes, numBeToBytes, numFrom, numFromBytes, numLeFromBytes, numLeToBytes, numMax, numMin, numToBytes, numToHex, recoverMessageSecp256k1, reduceAsync, signMessageSecp256k1, sleep, stringify, udtBalanceFrom, verifyMessageBtcEcdsa, verifyMessageCkbSecp256k1, verifyMessageDogeEcdsa, verifyMessageEvmPersonal, verifyMessageJoyId, verifyMessageNostrEvent, verifyMessageSecp256k1 };
3292
+ export { AbstractConstructor, Address, AddressLike, Bytes$1 as Bytes, BytesLike, Cell, CellAny, CellAnyLike, CellDep, CellDepInfo, CellDepInfoLike, CellDepLike, CellDepVec, CellInput, CellInputLike, CellInputVec, CellLike, CellOutput, CellOutputLike, CellOutputVec, Client, ClientBlock, ClientBlockHeader, ClientBlockHeaderLike, ClientBlockLike, ClientBlockUncle, ClientBlockUncleLike, ClientCache, ClientCacheMemory, ClientConfig, ClientFindCellsResponse, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKey, ClientIndexerSearchKeyFilter, ClientIndexerSearchKeyFilterLike, ClientIndexerSearchKeyLike, ClientIndexerSearchKeyTransaction, ClientIndexerSearchKeyTransactionLike, ClientJsonRpc, ClientJsonRpcConfig, ClientPublicMainnet, ClientPublicTestnet, ClientTransactionResponse, ClientTransactionResponseLike, Codec, CodecBool, CodecByte, CodecByte16, CodecByte32, CodecByte4, CodecByte8, CodecBytes, CodecLike, CodecRaw, CodecUint128, CodecUint128BE, CodecUint128LE, CodecUint16, CodecUint16BE, CodecUint16LE, CodecUint256, CodecUint256BE, CodecUint256LE, CodecUint32, CodecUint32BE, CodecUint32LE, CodecUint512, CodecUint512BE, CodecUint512LE, CodecUint64, CodecUint64BE, CodecUint64LE, CodecUint8, Constructor, DecodedType, DepType, DepTypeCodec, DepTypeLike, EncodableType, Entity, Epoch, EpochLike, ErrorClientBase, ErrorClientBaseLike, ErrorClientDuplicatedTransaction, ErrorClientMaxFeeRateExceeded, ErrorClientRBFRejected, ErrorClientResolveUnknown, ErrorClientVerification, ErrorClientWaitTransactionTimeout, ErrorTransactionInsufficientCapacity, ErrorTransactionInsufficientCoin, FixedPoint, FixedPointLike, HASH_CKB_LENGTH, HASH_CKB_SHORT_LENGTH, HashType, HashTypeCodec, HashTypeLike, Hasher, HasherCkb, HasherKeecak256, Hex, HexLike, InputToSign, InputToSignLike, JsonRpcError, JsonRpcErrorLike, JsonRpcId, JsonRpcPayload, JsonRpcResponse, JsonRpcTransport, JsonRpcTransportFallback, JsonRpcTransportHttp, JsonRpcTransportWebSocket, KnownScript, LumosTransactionSkeletonType, MultisigCkbWitness, MultisigCkbWitnessLike, NetworkPreference, NostrEvent, Num, NumLike, One, OutPoint, OutPointLike, OutputsValidator, Owner, OwnerAggregated, OwnerMoved, OwnerRefCount, OwnerUnique, Proxy, RawTransaction, RequestorJsonRpc, RequestorJsonRpcConfig, SECP256K1_SIGNATURE_LENGTH, Script, ScriptInfo, ScriptInfoLike, ScriptLike, ScriptOpt, ScriptVec, SignPsbtOptions, SignPsbtOptionsLike, Signature, Signer, SignerAlwaysError, SignerBtc, SignerBtcPublicKeyReadonly, SignerCkbAlwaysSuccess, SignerCkbPrivateKey, SignerCkbPublicKey, SignerCkbScriptReadonly, SignerDoge, SignerDogeAddressReadonly, SignerDogePrivateKey, SignerDummy, SignerEvm, SignerEvmAddressReadonly, SignerInfo, SignerJsonRpc, SignerJsonRpcConfig, SignerJsonRpcConfirmation, SignerJsonRpcHandler, SignerJsonRpcHandlerConfig, SignerMultisig, SignerMultisigCkbPrivateKey, SignerMultisigCkbReadonly, SignerMultisigNotEnoughSignaturesError, SignerNostr, SignerNostrPrivateKey, SignerNostrPublicKeyReadonly, SignerOpenLink, SignerSignType, SignerType, Since, SinceLike, Transaction, TransactionLike, TransactionStatus, Wallet, WitnessArgs, WitnessArgsLike, Zero, abortSignalAny, apply, btcEcdsaPublicKeyHash, btcP2pkhAddressFromPublicKey, btcPublicKeyFromP2pkhAddress, btcVarLengthBytesFrom, buildNostrEventFromMessage, buildSignerJsonRpcHandler, bytesConcat, bytesConcatTo, bytesEq, bytesFrom, bytesLen, bytesLenUnsafe, bytesTo, calcDaoClaimEpoch, calcDaoProfit, codec, codecPadding, codecUint, codecUintNumber, depTypeFrom, depTypeFromBytes, depTypeToBytes, epochFrom, epochFromHex, epochToHex, fixedPointFrom, fixedPointToString, gcd, hashCkb, hashCkbShort, hashTypeFrom, hashTypeFromBytes, hashTypeId, hashTypeToBytes, hexFrom, isDaoOutputLimitExceeded, isWebview, keystoreDecrypt, keystoreEncrypt, messageHashBtcEcdsa, messageHashCkbSecp256k1, messageHashDogeEcdsa, barrel_d_exports$1 as mol, nostrEventHash, numBeFromBytes, numBeToBytes, numFrom, numFromBytes, numLeFromBytes, numLeToBytes, numMax, numMin, numToBytes, numToHex, recoverMessageSecp256k1, reduceAsync, signMessageSecp256k1, sleep, stringify, udtBalanceFrom, verifyMessageBtcEcdsa, verifyMessageCkbSecp256k1, verifyMessageDogeEcdsa, verifyMessageEvmPersonal, verifyMessageJoyId, verifyMessageNostrEvent, verifyMessageSecp256k1 };
2978
3293
  }
2979
3294
  //#endregion
2980
3295
  //#region src/client/clientTypes.advanced.d.ts
@@ -3727,830 +4042,599 @@ declare enum KnownScript {
3727
4042
  TimeLock = "TimeLock"
3728
4043
  }
3729
4044
  //#endregion
3730
- //#region src/ckb/script.d.ts
3731
- declare const HashTypeCodec: Codec<HashTypeLike, HashType>;
3732
- /**
3733
- * @public
3734
- */
3735
- type HashTypeLike = string | number | bigint;
3736
- /**
3737
- * @public
3738
- */
3739
- type HashType = "type" | "data" | "data1" | "data2";
3740
- /**
3741
- * Converts a HashTypeLike value to a HashType.
3742
- * @public
3743
- *
3744
- * @param val - The value to convert, which can be a string, number, or bigint.
3745
- * @returns The corresponding HashType.
3746
- *
3747
- * @throws Will throw an error if the input value is not a valid hash type.
3748
- *
3749
- * @example
3750
- * ```typescript
3751
- * const hashType = hashTypeFrom(1); // Outputs "data"
3752
- * const hashType = hashTypeFrom("type"); // Outputs "type"
3753
- * ```
3754
- */
3755
- declare function hashTypeFrom(val: HashTypeLike): HashType;
3756
- /**
3757
- * Converts a HashTypeLike value to its corresponding byte representation.
3758
- * @public
3759
- *
3760
- * @param hashType - The hash type value to convert.
3761
- * @returns A Uint8Array containing the byte representation of the hash type.
3762
- *
3763
- * @example
3764
- * ```typescript
3765
- * const hashTypeBytes = hashTypeToBytes("type"); // Outputs Uint8Array [0]
3766
- * ```
3767
- */
3768
- declare function hashTypeToBytes(hashType: HashTypeLike): Bytes$1;
3769
- /**
3770
- * Converts a byte-like value to a HashType.
3771
- * @public
3772
- *
3773
- * @param bytes - The byte-like value to convert.
3774
- * @returns The corresponding HashType.
3775
- *
3776
- * @throws Will throw an error if the input bytes do not correspond to a valid hash type.
3777
- *
3778
- * @example
3779
- * ```typescript
3780
- * const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs "type"
3781
- * ```
3782
- */
3783
- declare function hashTypeFromBytes(bytes: BytesLike): HashType;
4045
+ //#region src/client/client.d.ts
4046
+ type ClientConfig = {
4047
+ cache?: ClientCache;
4048
+ scripts?: Partial<Record<KnownScript, ScriptInfoLike>>;
4049
+ };
3784
4050
  /**
3785
4051
  * @public
3786
4052
  */
3787
- type ScriptLike = {
3788
- codeHash: BytesLike;
3789
- hashType: HashTypeLike;
3790
- args: BytesLike;
3791
- };
3792
- declare const Script_base: (abstract new () => {
3793
- toBytes(): Bytes$1;
3794
- clone(): Script;
3795
- eq(other: ScriptLike): boolean;
3796
- hash(): Hex;
3797
- toHex(): Hex;
3798
- }) & {
3799
- byteLength?: number;
3800
- encode(_: ScriptLike): Bytes$1;
3801
- decode(_: BytesLike): Script;
3802
- fromBytes(_bytes: BytesLike): Script;
3803
- from(_: ScriptLike): Script;
3804
- Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
3805
- toBytes(): Bytes$1;
3806
- clone(): SubType;
3807
- eq(other: SubTypeLike): boolean;
3808
- hash(): Hex;
3809
- toHex(): Hex;
3810
- }) & {
3811
- byteLength?: number;
3812
- encode(_: SubTypeLike): Bytes$1;
3813
- decode(_: BytesLike): SubType;
3814
- fromBytes(_bytes: BytesLike): SubType;
3815
- from(_: SubTypeLike): SubType;
3816
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
3817
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
3818
- readonly inner: DecodedType<CodecType>;
3819
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
3820
- _?: undefined | null;
3821
- }): Result;
3822
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
3823
- _: (inner: DecodedType<CodecType>) => Result;
3824
- }): Result;
3825
- toBytes(): Bytes$1;
3826
- clone(): SubType_1;
3827
- eq(other: SubTypeLike_1): boolean;
3828
- hash(): Hex;
3829
- toHex(): Hex;
3830
- }) & {
3831
- byteLength?: number;
3832
- encode(_: SubTypeLike_1): Bytes$1;
3833
- decode(_: BytesLike): SubType_1;
3834
- fromBytes(_bytes: BytesLike): SubType_1;
3835
- from(_: SubTypeLike_1): SubType_1;
3836
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
3837
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
3838
- };
3839
- };
3840
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
3841
- readonly inner: DecodedType<CodecType>;
3842
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
3843
- _?: undefined | null;
3844
- }): Result;
3845
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
3846
- _: (inner: DecodedType<CodecType>) => Result;
3847
- }): Result;
3848
- toBytes(): Bytes$1;
3849
- clone(): SubType;
3850
- eq(other: SubTypeLike): boolean;
3851
- hash(): Hex;
3852
- toHex(): Hex;
3853
- }) & {
3854
- byteLength?: number;
3855
- encode(_: SubTypeLike): Bytes$1;
3856
- decode(_: BytesLike): SubType;
3857
- fromBytes(_bytes: BytesLike): SubType;
3858
- from(_: SubTypeLike): SubType;
3859
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
3860
- toBytes(): Bytes$1;
3861
- clone(): SubType_1;
3862
- eq(other: SubTypeLike_1): boolean;
3863
- hash(): Hex;
3864
- toHex(): Hex;
3865
- }) & {
3866
- byteLength?: number;
3867
- encode(_: SubTypeLike_1): Bytes$1;
3868
- decode(_: BytesLike): SubType_1;
3869
- fromBytes(_bytes: BytesLike): SubType_1;
3870
- from(_: SubTypeLike_1): SubType_1;
3871
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
3872
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
3873
- };
3874
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
3875
- };
3876
- };
3877
- /**
3878
- * @public
3879
- */
3880
- declare class Script extends Script_base {
3881
- codeHash: Hex;
3882
- hashType: HashType;
3883
- args: Hex;
4053
+ declare abstract class Client {
4054
+ cache: ClientCache;
4055
+ private readonly scripts;
4056
+ constructor(config?: ClientConfig);
3884
4057
  /**
3885
- * Creates an instance of Script.
4058
+ * The legacy primary URL associated with this Client.
3886
4059
  *
3887
- * @param codeHash - The code hash of the script.
3888
- * @param hashType - The hash type of the script.
3889
- * @param args - The arguments for the script.
4060
+ * @deprecated A Client may use multiple endpoints or a Transport without a
4061
+ * URL, so this value does not reliably identify its connection.
3890
4062
  */
3891
- constructor(codeHash: Hex, hashType: HashType, args: Hex);
3892
- get occupiedSize(): number;
4063
+ abstract get url(): string;
4064
+ abstract get addressPrefix(): string;
3893
4065
  /**
3894
- * Clone a script.
4066
+ * Get the deployment info for a well-known CKB script.
4067
+ * Returns the cell deps and type script info needed to use the script.
3895
4068
  *
3896
- * @returns A cloned Script instance.
4069
+ * @param script - The KnownScript enum value.
4070
+ * @returns Script info including cellDeps and type hash.
3897
4071
  *
3898
4072
  * @example
3899
4073
  * ```typescript
3900
- * const script1 = script0.clone();
4074
+ * import { ccc } from "@ckb-ccc/core";
4075
+ *
4076
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4077
+ * const client = clientOwner.value;
4078
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4079
+ *
4080
+ * // Get xUDT script deployment info
4081
+ * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
4082
+ * console.log(`xUDT cellDeps:`, xudtInfo.cellDeps);
4083
+ *
4084
+ * // Build an xUDT type script
4085
+ * const xudtType = await ccc.Script.fromKnownScript(
4086
+ * client,
4087
+ * ccc.KnownScript.XUdt,
4088
+ * "0xOWNER_LOCK_HASH...",
4089
+ * );
3901
4090
  * ```
3902
4091
  */
3903
- clone(): Script;
4092
+ getKnownScript(script: KnownScript): Promise<ScriptInfo>;
4093
+ abstract getFeeRateStatistics(blockRange?: NumLike): Promise<{
4094
+ mean: Num;
4095
+ median: Num;
4096
+ }>;
3904
4097
  /**
3905
- * Check if the script is equal to another script.
3906
- * @public
3907
- * @param other - The other script to compare with
3908
- * @returns True if the scripts are equal, false otherwise
4098
+ * Get the recommended transaction fee rate based on recent blocks.
4099
+ * Returns the median fee rate, clamped between min and max fee rates.
4100
+ *
4101
+ * @param blockRange - Number of recent blocks to analyze.
4102
+ * @param options - Optional max fee rate cap.
4103
+ * @returns The recommended fee rate in Shannons per KB.
3909
4104
  *
3910
4105
  * @example
3911
4106
  * ```typescript
3912
- * const isEqual = script0.eq(script1);
4107
+ * import { ccc } from "@ckb-ccc/core";
4108
+ *
4109
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4110
+ * const client = clientOwner.value;
4111
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4112
+ * const feeRate = await client.getFeeRate();
4113
+ * console.log(`Current fee rate: ${feeRate} Shannons/KB`);
3913
4114
  * ```
3914
4115
  */
3915
- eq(other: ScriptLike): boolean;
4116
+ getFeeRate(blockRange?: NumLike, options?: {
4117
+ maxFeeRate?: NumLike;
4118
+ }): Promise<Num>;
3916
4119
  /**
3917
- * Creates a Script instance from a ScriptLike object.
4120
+ * Get the latest block number (tip) of the chain.
3918
4121
  *
3919
- * @param script - A ScriptLike object or an instance of Script.
3920
- * @returns A Script instance.
4122
+ * @returns The current tip block number.
3921
4123
  *
3922
4124
  * @example
3923
4125
  * ```typescript
3924
- * const script = Script.from({
3925
- * codeHash: "0x1234...",
3926
- * hashType: "type",
3927
- * args: "0xabcd..."
4126
+ * import { ccc } from "@ckb-ccc/core";
4127
+ *
4128
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4129
+ * const client = clientOwner.value;
4130
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4131
+ * const tipBlockNumber = await client.getTip();
4132
+ * console.log(`Current block height: ${tipBlockNumber}`);
4133
+ * ```
4134
+ */
4135
+ abstract getTip(): Promise<Num>;
4136
+ /**
4137
+ * Get the header of the latest block.
4138
+ *
4139
+ * @param verbosity - Verbosity level (0 for hex, 1 for object).
4140
+ * @returns The tip block header.
4141
+ *
4142
+ * @example
4143
+ * ```typescript
4144
+ * import { ccc } from "@ckb-ccc/core";
4145
+ *
4146
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4147
+ * const client = clientOwner.value;
4148
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4149
+ * const header = await client.getTipHeader();
4150
+ * console.log(`Block #${header.number}, hash: ${header.hash}`);
4151
+ * ```
4152
+ */
4153
+ abstract getTipHeader(verbosity?: number | null): Promise<ClientBlockHeader>;
4154
+ abstract getBlockByNumberNoCache(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4155
+ abstract getBlockByHashNoCache(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4156
+ abstract getHeaderByNumberNoCache(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4157
+ abstract getHeaderByHashNoCache(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4158
+ getBlockByNumber(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4159
+ getBlockByHash(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4160
+ getHeaderByNumber(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4161
+ getHeaderByHash(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4162
+ abstract estimateCycles(transaction: TransactionLike): Promise<Num>;
4163
+ abstract sendTransactionDry(transaction: TransactionLike, validator?: OutputsValidator): Promise<Num>;
4164
+ abstract sendTransactionNoCache(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
4165
+ abstract getTransactionNoCache(txHash: HexLike): Promise<ClientTransactionResponse | undefined>;
4166
+ /**
4167
+ * Get a cell by its out point.
4168
+ * The cell will be cached if it is found.
4169
+ *
4170
+ * @param outPointLike - The out point of the cell to get.
4171
+ * @returns The cell if it exists, otherwise undefined.
4172
+ *
4173
+ * @example
4174
+ * ```typescript
4175
+ * import { ccc } from "@ckb-ccc/core";
4176
+ *
4177
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4178
+ * const client = clientOwner.value;
4179
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4180
+ * const cell = await client.getCell({
4181
+ * txHash: "0xTX_HASH...",
4182
+ * index: 0,
3928
4183
  * });
4184
+ * if (cell) {
4185
+ * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4186
+ * console.log(`Lock: ${cell.cellOutput.lock.codeHash}`);
4187
+ * console.log(`Data: ${cell.outputData}`);
4188
+ * }
3929
4189
  * ```
3930
4190
  */
3931
- static from(script: ScriptLike): Script;
4191
+ getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
4192
+ getCellWithHeader(outPointLike: OutPointLike): Promise<{
4193
+ cell: Cell;
4194
+ header?: ClientBlockHeader;
4195
+ } | undefined>;
4196
+ abstract getCellLiveNoCache(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
3932
4197
  /**
3933
- * Creates a Script instance from client and known script.
4198
+ * Get a live (unspent) cell by its out point.
4199
+ * Unlike getCell(), this verifies the cell is still live on-chain.
3934
4200
  *
3935
- * @param knownScript - A KnownScript enum.
3936
- * @param args - Args for the script.
3937
- * @param client - A ScriptLike object or an instance of Script.
3938
- * @returns A promise that resolves to the script instance.
4201
+ * @param outPointLike - The out point of the cell.
4202
+ * @param withData - Whether to include cell data.
4203
+ * @param includeTxPool - Whether to include cells in the transaction pool.
4204
+ * @returns The live cell, or undefined if spent or not found.
3939
4205
  *
3940
4206
  * @example
3941
4207
  * ```typescript
3942
- * const script = await Script.fromKnownScript(
3943
- * client,
3944
- * KnownScript.XUdt,
3945
- * args: "0xabcd..."
4208
+ * import { ccc } from "@ckb-ccc/core";
4209
+ *
4210
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4211
+ * const client = clientOwner.value;
4212
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4213
+ * const cell = await client.getCellLive(
4214
+ * { txHash: "0xTX_HASH...", index: 0 },
4215
+ * true, // include data
4216
+ * true, // include tx pool
3946
4217
  * );
4218
+ * if (cell) {
4219
+ * console.log("Cell is still live!");
4220
+ * } else {
4221
+ * console.log("Cell has been spent or does not exist.");
4222
+ * }
3947
4223
  * ```
3948
4224
  */
3949
- static fromKnownScript(client: Client, knownScript: KnownScript, args: HexLike): Promise<Script>;
3950
- }
3951
- declare const ScriptOpt: Codec<ScriptLike | null | undefined, Script | undefined>;
3952
- declare const ScriptVec: Codec<ScriptLike[], Script[]>;
3953
- //#endregion
3954
- //#region src/ckb/transactionLumos.d.ts
3955
- interface LumosTransactionSkeletonType {
3956
- cellDeps: {
3957
- toArray(): CellDepLike[];
3958
- };
3959
- headerDeps: {
3960
- toArray(): HexLike[];
3961
- };
3962
- inputs: {
3963
- toArray(): {
3964
- outPoint?: OutPointLike;
3965
- cellOutput: CellOutputLike;
3966
- data: HexLike;
3967
- }[];
3968
- };
3969
- inputSinces: {
3970
- get(i: number, defaultVal: string): HexLike;
3971
- };
3972
- outputs: {
3973
- toArray(): {
3974
- cellOutput: CellOutputLike;
3975
- data: HexLike;
3976
- }[];
3977
- };
3978
- witnesses: {
3979
- toArray(): HexLike[];
3980
- };
3981
- }
3982
- //#endregion
3983
- //#region src/ckb/transaction.d.ts
3984
- declare const DepTypeCodec: Codec<DepTypeLike, DepType>;
3985
- /**
3986
- * @public
3987
- */
3988
- type DepTypeLike = string | number | bigint;
3989
- /**
3990
- * @public
3991
- */
3992
- type DepType = "depGroup" | "code";
3993
- /**
3994
- * Converts a DepTypeLike value to a DepType.
3995
- * @public
3996
- *
3997
- * @param val - The value to convert, which can be a string, number, or bigint.
3998
- * @returns The corresponding DepType.
3999
- *
4000
- * @throws Will throw an error if the input value is not a valid dep type.
4001
- *
4002
- * @example
4003
- * ```typescript
4004
- * const depType = depTypeFrom(1); // Outputs "code"
4005
- * const depType = depTypeFrom("depGroup"); // Outputs "depGroup"
4006
- * ```
4007
- */
4008
- declare function depTypeFrom(val: DepTypeLike): DepType;
4009
- /**
4010
- * Converts a DepTypeLike value to its corresponding byte representation.
4011
- * @public
4012
- *
4013
- * @param depType - The dep type value to convert.
4014
- * @returns A Uint8Array containing the byte representation of the dep type.
4015
- *
4016
- * @example
4017
- * ```typescript
4018
- * const depTypeBytes = depTypeToBytes("code"); // Outputs Uint8Array [1]
4019
- * ```
4020
- */
4021
- declare function depTypeToBytes(depType: DepTypeLike): Bytes$1;
4022
- /**
4023
- * Converts a byte-like value to a DepType.
4024
- * @public
4025
- *
4026
- * @param bytes - The byte-like value to convert.
4027
- * @returns The corresponding DepType.
4028
- *
4029
- * @throws Will throw an error if the input bytes do not correspond to a valid dep type.
4030
- *
4031
- * @example
4032
- * ```typescript
4033
- * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs "code"
4034
- * ```
4035
- */
4036
- declare function depTypeFromBytes(bytes: BytesLike): DepType;
4037
- /**
4038
- * @public
4039
- */
4040
- type OutPointLike = {
4041
- txHash: HexLike;
4042
- index: NumLike;
4043
- };
4044
- declare const OutPoint_base: (abstract new () => {
4045
- toBytes(): Bytes$1;
4046
- clone(): OutPoint;
4047
- eq(other: OutPointLike): boolean;
4048
- hash(): Hex;
4049
- toHex(): Hex;
4050
- }) & {
4051
- byteLength?: number;
4052
- encode(_: OutPointLike): Bytes$1;
4053
- decode(_: BytesLike): OutPoint;
4054
- fromBytes(_bytes: BytesLike): OutPoint;
4055
- from(_: OutPointLike): OutPoint;
4056
- Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4057
- toBytes(): Bytes$1;
4058
- clone(): SubType;
4059
- eq(other: SubTypeLike): boolean;
4060
- hash(): Hex;
4061
- toHex(): Hex;
4062
- }) & {
4063
- byteLength?: number;
4064
- encode(_: SubTypeLike): Bytes$1;
4065
- decode(_: BytesLike): SubType;
4066
- fromBytes(_bytes: BytesLike): SubType;
4067
- from(_: SubTypeLike): SubType;
4068
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4069
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
4070
- readonly inner: DecodedType<CodecType>;
4071
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
4072
- _?: undefined | null;
4073
- }): Result;
4074
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
4075
- _: (inner: DecodedType<CodecType>) => Result;
4076
- }): Result;
4077
- toBytes(): Bytes$1;
4078
- clone(): SubType_1;
4079
- eq(other: SubTypeLike_1): boolean;
4080
- hash(): Hex;
4081
- toHex(): Hex;
4082
- }) & {
4083
- byteLength?: number;
4084
- encode(_: SubTypeLike_1): Bytes$1;
4085
- decode(_: BytesLike): SubType_1;
4086
- fromBytes(_bytes: BytesLike): SubType_1;
4087
- from(_: SubTypeLike_1): SubType_1;
4088
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4089
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
4090
- };
4091
- };
4092
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
4093
- readonly inner: DecodedType<CodecType>;
4094
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
4095
- _?: undefined | null;
4096
- }): Result;
4097
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
4098
- _: (inner: DecodedType<CodecType>) => Result;
4099
- }): Result;
4100
- toBytes(): Bytes$1;
4101
- clone(): SubType;
4102
- eq(other: SubTypeLike): boolean;
4103
- hash(): Hex;
4104
- toHex(): Hex;
4105
- }) & {
4106
- byteLength?: number;
4107
- encode(_: SubTypeLike): Bytes$1;
4108
- decode(_: BytesLike): SubType;
4109
- fromBytes(_bytes: BytesLike): SubType;
4110
- from(_: SubTypeLike): SubType;
4111
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
4112
- toBytes(): Bytes$1;
4113
- clone(): SubType_1;
4114
- eq(other: SubTypeLike_1): boolean;
4115
- hash(): Hex;
4116
- toHex(): Hex;
4117
- }) & {
4118
- byteLength?: number;
4119
- encode(_: SubTypeLike_1): Bytes$1;
4120
- decode(_: BytesLike): SubType_1;
4121
- fromBytes(_bytes: BytesLike): SubType_1;
4122
- from(_: SubTypeLike_1): SubType_1;
4123
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
4124
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4125
- };
4126
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4127
- };
4128
- };
4129
- /**
4130
- * @public
4131
- */
4132
- declare class OutPoint extends OutPoint_base {
4133
- txHash: Hex;
4134
- index: Num;
4225
+ getCellLive(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
4226
+ abstract findCellsPagedNoCache(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
4135
4227
  /**
4136
- * Creates an instance of OutPoint.
4228
+ * Find cells with pagination support.
4229
+ * Returns one page of results at a time with a cursor for the next page.
4137
4230
  *
4138
- * @param txHash - The transaction hash.
4139
- * @param index - The index of the output in the transaction.
4231
+ * @param key - The indexer search key.
4232
+ * @param order - Sort order ("asc" or "desc").
4233
+ * @param limit - Maximum cells per page.
4234
+ * @param after - Cursor from previous page for pagination.
4235
+ * @returns A page of cells with a cursor for the next page.
4236
+ *
4237
+ * @example
4238
+ * ```typescript
4239
+ * import { ccc } from "@ckb-ccc/core";
4240
+ *
4241
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4242
+ * const client = clientOwner.value;
4243
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4244
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4245
+ *
4246
+ * // Get first page of cells
4247
+ * const page1 = await client.findCellsPaged({
4248
+ * script: lock,
4249
+ * scriptType: "lock",
4250
+ * }, "asc", 20);
4251
+ * console.log(`Found ${page1.cells.length} cells`);
4252
+ *
4253
+ * // Get next page
4254
+ * if (page1.cells.length === 20) {
4255
+ * const page2 = await client.findCellsPaged(
4256
+ * { script: lock, scriptType: "lock" },
4257
+ * "asc", 20, page1.lastCursor,
4258
+ * );
4259
+ * }
4260
+ * ```
4140
4261
  */
4141
- constructor(txHash: Hex, index: Num);
4262
+ findCellsPaged(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
4263
+ findCellsOnChain(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4142
4264
  /**
4143
- * Creates an OutPoint instance from an OutPointLike object.
4265
+ * Find cells by search key designed for collectable cells.
4266
+ * The result also includes cached cells, the order param only works for cells fetched from RPC.
4144
4267
  *
4145
- * @param outPoint - An OutPointLike object or an instance of OutPoint.
4146
- * @returns An OutPoint instance.
4268
+ * @param keyLike - The search key.
4269
+ * @returns A async generator for yielding cells.
4147
4270
  *
4148
4271
  * @example
4149
4272
  * ```typescript
4150
- * const outPoint = OutPoint.from({ txHash: "0x...", index: 0 });
4273
+ * import { ccc } from "@ckb-ccc/core";
4274
+ *
4275
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4276
+ * const client = clientOwner.value;
4277
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4278
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4279
+ *
4280
+ * // Find all cells owned by a lock script
4281
+ * for await (const cell of client.findCells({
4282
+ * script: lock,
4283
+ * scriptType: "lock",
4284
+ * scriptSearchMode: "exact",
4285
+ * withData: true,
4286
+ * })) {
4287
+ * console.log(`Cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
4288
+ * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4289
+ * }
4151
4290
  * ```
4152
4291
  */
4153
- static from(outPoint: OutPointLike): OutPoint;
4292
+ findCells(keyLike: ClientCollectableSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4154
4293
  /**
4155
- * Clone a OutPoint.
4294
+ * Find cells by lock script, optionally filtered by type script.
4156
4295
  *
4157
- * @returns A cloned OutPoint instance.
4296
+ * @param lock - The lock script to search by.
4297
+ * @param type - Optional type script filter.
4298
+ * @param withData - Whether to include cell data (default: true).
4299
+ * @param order - Sort order by block number ("asc" or "desc").
4300
+ * @param limit - Page size for each RPC call (default: 10).
4301
+ * @returns An async generator yielding matching cells.
4158
4302
  *
4159
4303
  * @example
4160
4304
  * ```typescript
4161
- * const outPoint1 = outPoint0.clone();
4305
+ * import { ccc } from "@ckb-ccc/core";
4306
+ *
4307
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4308
+ * const client = clientOwner.value;
4309
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4310
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4311
+ *
4312
+ * // Find all cells belonging to this address
4313
+ * for await (const cell of client.findCellsByLock(lock)) {
4314
+ * console.log(`${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4315
+ * }
4316
+ *
4317
+ * // Find only xUDT cells belonging to this address
4318
+ * const xudtType = await ccc.Script.fromKnownScript(
4319
+ * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
4320
+ * );
4321
+ * for await (const cell of client.findCellsByLock(lock, xudtType)) {
4322
+ * console.log(`UDT cell found`);
4323
+ * }
4162
4324
  * ```
4163
4325
  */
4164
- clone(): OutPoint;
4326
+ findCellsByLock(lock: ScriptLike, type?: ScriptLike | null, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4165
4327
  /**
4166
- * Check if the OutPoint is equal to another OutPoint.
4167
- * @public
4168
- * @param other - The other OutPoint to compare with
4169
- * @returns True if the OutPoints are equal, false otherwise
4328
+ * Find cells by type script.
4329
+ *
4330
+ * @param type - The type script to search by.
4331
+ * @param withData - Whether to include cell data (default: true).
4332
+ * @param order - Sort order by block number.
4333
+ * @param limit - Page size for each RPC call (default: 10).
4334
+ * @returns An async generator yielding matching cells.
4170
4335
  *
4171
4336
  * @example
4172
4337
  * ```typescript
4173
- * const isEqual = outPoint0.eq(outPoint1);
4338
+ * import { ccc } from "@ckb-ccc/core";
4339
+ *
4340
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4341
+ * const client = clientOwner.value;
4342
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4343
+ * // Find all xUDT cells of a specific token
4344
+ * const xudtType = await ccc.Script.fromKnownScript(
4345
+ * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
4346
+ * );
4347
+ * for await (const cell of client.findCellsByType(xudtType)) {
4348
+ * console.log(`Token cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
4349
+ * }
4174
4350
  * ```
4175
4351
  */
4176
- eq(other: OutPointLike): boolean;
4177
- }
4178
- /**
4179
- * @public
4180
- */
4181
- type CellOutputLike = {
4182
- capacity?: NumLike | null;
4183
- lock: ScriptLike;
4184
- type?: ScriptLike | null;
4185
- };
4186
- declare const CellOutput_base: (abstract new () => {
4187
- toBytes(): Bytes$1;
4188
- clone(): CellOutput;
4189
- eq(other: CellOutputLike): boolean;
4190
- hash(): Hex;
4191
- toHex(): Hex;
4192
- }) & {
4193
- byteLength?: number;
4194
- encode(_: CellOutputLike): Bytes$1;
4195
- decode(_: BytesLike): CellOutput;
4196
- fromBytes(_bytes: BytesLike): CellOutput;
4197
- from(_: CellOutputLike): CellOutput;
4198
- Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4199
- toBytes(): Bytes$1;
4200
- clone(): SubType;
4201
- eq(other: SubTypeLike): boolean;
4202
- hash(): Hex;
4203
- toHex(): Hex;
4204
- }) & {
4205
- byteLength?: number;
4206
- encode(_: SubTypeLike): Bytes$1;
4207
- decode(_: BytesLike): SubType;
4208
- fromBytes(_bytes: BytesLike): SubType;
4209
- from(_: SubTypeLike): SubType;
4210
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4211
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
4212
- readonly inner: DecodedType<CodecType>;
4213
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
4214
- _?: undefined | null;
4215
- }): Result;
4216
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
4217
- _: (inner: DecodedType<CodecType>) => Result;
4218
- }): Result;
4219
- toBytes(): Bytes$1;
4220
- clone(): SubType_1;
4221
- eq(other: SubTypeLike_1): boolean;
4222
- hash(): Hex;
4223
- toHex(): Hex;
4224
- }) & {
4225
- byteLength?: number;
4226
- encode(_: SubTypeLike_1): Bytes$1;
4227
- decode(_: BytesLike): SubType_1;
4228
- fromBytes(_bytes: BytesLike): SubType_1;
4229
- from(_: SubTypeLike_1): SubType_1;
4230
- Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4231
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
4232
- };
4233
- };
4234
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
4235
- readonly inner: DecodedType<CodecType>;
4236
- match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
4237
- _?: undefined | null;
4238
- }): Result;
4239
- match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
4240
- _: (inner: DecodedType<CodecType>) => Result;
4241
- }): Result;
4242
- toBytes(): Bytes$1;
4243
- clone(): SubType;
4244
- eq(other: SubTypeLike): boolean;
4245
- hash(): Hex;
4246
- toHex(): Hex;
4247
- }) & {
4248
- byteLength?: number;
4249
- encode(_: SubTypeLike): Bytes$1;
4250
- decode(_: BytesLike): SubType;
4251
- fromBytes(_bytes: BytesLike): SubType;
4252
- from(_: SubTypeLike): SubType;
4253
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
4254
- toBytes(): Bytes$1;
4255
- clone(): SubType_1;
4256
- eq(other: SubTypeLike_1): boolean;
4257
- hash(): Hex;
4258
- toHex(): Hex;
4259
- }) & {
4260
- byteLength?: number;
4261
- encode(_: SubTypeLike_1): Bytes$1;
4262
- decode(_: BytesLike): SubType_1;
4263
- fromBytes(_bytes: BytesLike): SubType_1;
4264
- from(_: SubTypeLike_1): SubType_1;
4265
- Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
4266
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4267
- };
4268
- BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
4269
- };
4270
- };
4271
- /**
4272
- * @public
4273
- */
4274
- declare class CellOutput extends CellOutput_base {
4275
- capacity: Num;
4276
- lock: Script;
4277
- type?: Script | undefined;
4278
- /**
4279
- * Creates an instance of CellOutput.
4280
- *
4281
- * @param capacity - The capacity of the cell.
4282
- * @param lock - The lock script of the cell.
4283
- * @param type - The optional type script of the cell.
4284
- */
4285
- constructor(capacity: Num, lock: Script, type?: Script | undefined);
4286
- get occupiedSize(): number;
4352
+ findCellsByType(type: ScriptLike, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4353
+ findSingletonCellByType(type: ScriptLike, withData?: boolean): Promise<Cell | undefined>;
4287
4354
  /**
4288
- * Creates a CellOutput instance from a CellOutputLike object.
4289
- * This method supports automatic capacity calculation when outputData is provided and capacity is 0 or omitted.
4355
+ * Resolve cell dependency info into concrete CellDep objects.
4356
+ * If a CellDepInfo specifies a type script, the actual deployed cell is located on-chain.
4290
4357
  *
4291
- * @param cellOutput - A CellOutputLike object or an instance of CellOutput.
4292
- * @param outputData - Optional output data used for automatic capacity calculation.
4293
- * When provided and capacity is 0, the capacity will be calculated
4294
- * as occupiedSize + outputData.length.
4295
- * @returns A CellOutput instance.
4358
+ * @param cellDepsInfoLike - One or more CellDepInfo or arrays of CellDepInfo.
4359
+ * @returns Resolved CellDep array ready to be added to a transaction.
4296
4360
  *
4297
4361
  * @example
4298
4362
  * ```typescript
4299
- * // Basic usage with explicit capacity
4300
- * const cellOutput1 = CellOutput.from({
4301
- * capacity: 1000n,
4302
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." },
4303
- * type: { codeHash: "0x...", hashType: "type", args: "0x..." }
4304
- * });
4363
+ * import { ccc } from "@ckb-ccc/core";
4305
4364
  *
4306
- * // Automatic capacity calculation
4307
- * const cellOutput2 = CellOutput.from({
4308
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
4309
- * }, "0x1234"); // Capacity will be calculated automatically
4365
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4366
+ * const client = clientOwner.value;
4367
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4368
+ * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
4369
+ * const cellDeps = await client.getCellDeps(xudtInfo.cellDeps);
4370
+ * // cellDeps can be added to a transaction:
4371
+ * // tx.cellDeps.push(...cellDeps);
4310
4372
  * ```
4311
4373
  */
4312
- static from(cellOutput: CellOutputLike, outputData?: HexLike | null): CellOutput;
4374
+ getCellDeps(...cellDepsInfoLike: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<CellDep[]>;
4375
+ abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4376
+ groupByTransaction: true;
4377
+ }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsGroupedResponse>;
4378
+ abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4379
+ groupByTransaction?: false | null;
4380
+ }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse>;
4381
+ abstract findTransactionsPaged(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse | ClientFindTransactionsGroupedResponse>;
4382
+ findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4383
+ groupByTransaction: true;
4384
+ }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4385
+ findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4386
+ groupByTransaction?: false | null;
4387
+ }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4388
+ findTransactions(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4313
4389
  /**
4314
- * Clone a CellOutput.
4390
+ * Find transactions related to a lock script, optionally filtered by type script.
4315
4391
  *
4316
- * @returns A cloned CellOutput instance.
4392
+ * @param lock - The lock script to search by.
4393
+ * @param type - Optional type script filter.
4394
+ * @param groupByTransaction - If true, group results by transaction.
4395
+ * @param order - Sort order by block number.
4396
+ * @param limit - Page size per RPC call.
4397
+ * @returns An async generator yielding transaction records.
4317
4398
  *
4318
4399
  * @example
4319
4400
  * ```typescript
4320
- * const cellOutput1 = cellOutput0.clone();
4321
- * ```
4322
- */
4323
- clone(): CellOutput;
4324
- }
4325
- declare const CellOutputVec: Codec<CellOutputLike[], CellOutput[]>;
4326
- /**
4327
- * @public
4328
- * Represents a cell-like object that may or may not be on-chain.
4329
- * It can optionally have an `outPoint` (or `previousOutput`).
4330
- * This is used as a flexible input for creating `CellAny` instances.
4331
- * @see CellAny
4332
- */
4333
- type CellAnyLike = {
4334
- outPoint?: OutPointLike | null;
4335
- previousOutput?: OutPointLike | null;
4336
- cellOutput: CellOutputLike;
4337
- outputData?: HexLike | null;
4338
- };
4339
- /**
4340
- * Represents a CKB cell that can be either on-chain (with an `outPoint`) or off-chain (without an `outPoint`).
4341
- * This class provides a unified interface for handling cells before they are included in a transaction,
4342
- * or for cells that are already part of the blockchain state.
4343
- *
4344
- * @public
4345
- */
4346
- declare class CellAny {
4347
- cellOutput: CellOutput;
4348
- outputData: Hex;
4349
- outPoint: OutPoint | undefined;
4350
- /**
4351
- * Creates an instance of CellAny.
4401
+ * import { ccc } from "@ckb-ccc/core";
4352
4402
  *
4353
- * @param cellOutput - The cell output of the cell.
4354
- * @param outputData - The output data of the cell.
4355
- * @param outPoint - The optional output point of the cell. If provided, the cell is considered on-chain.
4403
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4404
+ * const client = clientOwner.value;
4405
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4406
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4407
+ *
4408
+ * // List all transactions related to an address (grouped)
4409
+ * for await (const txRecord of client.findTransactionsByLock(lock, null, true)) {
4410
+ * console.log(`TX: ${txRecord.txHash}, Block: ${txRecord.blockNumber}`);
4411
+ * }
4412
+ * ```
4356
4413
  */
4357
- constructor(cellOutput: CellOutput, outputData: Hex, outPoint?: OutPoint);
4414
+ findTransactionsByLock(lock: ScriptLike, type: ScriptLike | undefined | null, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4415
+ findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4416
+ findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4417
+ findTransactionsByType(type: ScriptLike, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4418
+ findTransactionsByType(type: ScriptLike, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4419
+ findTransactionsByType(type: ScriptLike, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4420
+ abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
4358
4421
  /**
4359
- * Creates a `CellAny` instance from a `CellAnyLike` object.
4360
- * This factory method provides a convenient way to create `CellAny` instances
4361
- * from plain objects, automatically handling the optional `outPoint` or `previousOutput`.
4422
+ * Get the total CKB balance of a single lock script.
4423
+ * Only counts cells with no type script and no data (pure CKB capacity cells).
4362
4424
  *
4363
- * @param cell - A `CellAnyLike` object.
4364
- * @returns A new `CellAny` instance.
4425
+ * @param lock - The lock script to query balance for.
4426
+ * @returns The total capacity in Shannons as a bigint.
4365
4427
  *
4366
4428
  * @example
4367
4429
  * ```typescript
4368
- * // Create an off-chain cell (e.g., a new output)
4369
- * const offChainCell = CellAny.from({
4370
- * cellOutput: { capacity: 1000n, lock: lockScript },
4371
- * outputData: "0x"
4372
- * });
4430
+ * import { ccc } from "@ckb-ccc/core";
4373
4431
  *
4374
- * // Create an on-chain cell from an input
4375
- * const onChainCell = CellAny.from({
4376
- * outPoint: { txHash: "0x...", index: 0 },
4377
- * cellOutput: { capacity: 2000n, lock: lockScript },
4378
- * outputData: "0x1234"
4379
- * });
4432
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4433
+ * const client = clientOwner.value;
4434
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4435
+ * const { script: lock } = await ccc.Address.fromString(
4436
+ * "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq...",
4437
+ * client,
4438
+ * );
4439
+ * const balance = await client.getBalanceSingle(lock);
4440
+ * console.log(`Balance: ${ccc.fixedPointToString(balance)} CKB`);
4380
4441
  * ```
4381
4442
  */
4382
- static from(cell: CellAnyLike): CellAny;
4443
+ getBalanceSingle(lock: ScriptLike): Promise<Num>;
4383
4444
  /**
4384
- * Calculates the total occupied size of the cell in bytes.
4385
- * This includes the size of the `CellOutput` structure plus the size of the `outputData`.
4445
+ * Get the total CKB balance across multiple lock scripts.
4446
+ * Sums the balance from each lock script.
4386
4447
  *
4387
- * @returns The total occupied size in bytes.
4388
- */
4389
- get occupiedSize(): number;
4390
- /**
4391
- * Calculates the free capacity of the cell.
4392
- * Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.
4448
+ * @param locks - An array of lock scripts to query.
4449
+ * @returns The combined total capacity in Shannons as a bigint.
4393
4450
  *
4394
- * @returns The free capacity in shannons as a `Num`.
4395
- */
4396
- get capacityFree(): bigint;
4397
- /**
4398
- * Checks if the cell is a Nervos DAO cell and optionally checks its phase.
4451
+ * @example
4452
+ * ```typescript
4453
+ * import { ccc } from "@ckb-ccc/core";
4399
4454
  *
4400
- * @param client - A CKB client instance to fetch known script information.
4401
- * @param phase - Optional phase to check: "deposited" or "withdrew".
4402
- * If omitted, it checks if the cell is a DAO cell regardless of phase.
4403
- * @returns A promise that resolves to `true` if the cell is a matching Nervos DAO cell, `false` otherwise.
4455
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4456
+ * const client = clientOwner.value;
4457
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4458
+ * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
4459
+ * await signer.connect();
4460
+ *
4461
+ * const locks = await signer.getRecommendedAddressObj()
4462
+ * .then(({ script }) => [script]);
4463
+ * const totalBalance = await client.getBalance(locks);
4464
+ * console.log(`Total: ${ccc.fixedPointToString(totalBalance)} CKB`);
4465
+ * ```
4404
4466
  */
4405
- isNervosDao(client: Client, phase?: "deposited" | "withdrew"): Promise<boolean>;
4467
+ getBalance(locks: ScriptLike[]): Promise<Num>;
4406
4468
  /**
4407
- * Clones the `CellAny` instance.
4469
+ * Send a signed transaction to the CKB network.
4470
+ * Validates the fee rate against the maximum before sending.
4408
4471
  *
4409
- * @returns A new `CellAny` instance that is a deep copy of the current one.
4472
+ * @param transaction - The transaction to send.
4473
+ * @param validator - Optional outputs validator ("passthrough" or "well_known_scripts_only").
4474
+ * @param options - Optional configuration including maxFeeRate.
4475
+ * @returns The transaction hash.
4410
4476
  *
4411
4477
  * @example
4412
4478
  * ```typescript
4413
- * const clonedCell = cellAny.clone();
4414
- * ```
4415
- */
4416
- clone(): CellAny;
4417
- }
4418
- /**
4419
- * Represents a cell-like object that is guaranteed to be on-chain.
4420
- * It must have an `outPoint` (or its alias `previousOutput`).
4421
- * This is used as a type constraint for creating `Cell` instances.
4422
- * @see Cell
4423
- * @public
4424
- */
4425
- type CellLike = CellAnyLike & ({
4426
- outPoint: OutPointLike;
4427
- previousOutput?: undefined | null;
4428
- } | {
4429
- outPoint?: undefined | null;
4430
- previousOutput: OutPointLike;
4431
- });
4432
- /**
4433
- * Represents an on-chain CKB cell, which is a `CellAny` that is guaranteed to have an `outPoint`.
4434
- * This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.
4435
- * @public
4436
- */
4437
- declare class Cell extends CellAny {
4438
- outPoint: OutPoint;
4439
- /**
4440
- * Creates an instance of an on-chain Cell.
4441
- *
4442
- * @param outPoint - The output point of the cell.
4443
- * @param cellOutput - The cell output of the cell.
4444
- * @param outputData - The output data of the cell.
4445
- */
4446
- constructor(outPoint: OutPoint, cellOutput: CellOutput, outputData: Hex);
4447
- /**
4448
- * Creates a Cell instance from a CellLike object.
4449
- * This method accepts either `outPoint` or `previousOutput` to specify the cell's location,
4450
- * and supports automatic capacity calculation for the cell output.
4479
+ * import { ccc } from "@ckb-ccc/core";
4451
4480
  *
4452
- * @param cell - A CellLike object or an instance of Cell. The object can use either:
4453
- * - `outPoint`: For referencing a cell output
4454
- * - `previousOutput`: For referencing a cell input (alternative name for outPoint)
4455
- * The cellOutput can omit capacity for automatic calculation.
4456
- * @returns A Cell instance.
4481
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4482
+ * const client = clientOwner.value;
4483
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4484
+ * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
4485
+ * await signer.connect();
4457
4486
  *
4458
- * @example
4459
- * ```typescript
4460
- * // Using outPoint with explicit capacity
4461
- * const cell1 = Cell.from({
4462
- * outPoint: { txHash: "0x...", index: 0 },
4463
- * cellOutput: {
4464
- * capacity: 1000n,
4465
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
4466
- * },
4467
- * outputData: "0x"
4487
+ * const tx = ccc.Transaction.from({
4488
+ * outputs: [{ capacity: ccc.fixedPointFrom(100), lock: receiverLock }],
4468
4489
  * });
4490
+ * await tx.completeInputsByCapacity(signer);
4491
+ * await tx.completeFeeBy(signer);
4469
4492
  *
4470
- * // Using previousOutput with automatic capacity calculation
4471
- * const cell2 = Cell.from({
4472
- * previousOutput: { txHash: "0x...", index: 0 },
4473
- * cellOutput: {
4474
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
4475
- * // capacity will be calculated automatically
4476
- * },
4477
- * outputData: "0x1234"
4478
- * });
4493
+ * // Usually you call signer.sendTransaction(tx) which signs then sends.
4494
+ * // client.sendTransaction expects an already-signed transaction.
4495
+ * const txHash = await client.sendTransaction(tx);
4479
4496
  * ```
4480
4497
  */
4481
- static from(cell: CellLike): Cell;
4498
+ sendTransaction(transaction: TransactionLike, validator?: OutputsValidator, options?: {
4499
+ maxFeeRate?: NumLike;
4500
+ }): Promise<Hex>;
4482
4501
  /**
4483
- * Gets confirmed Nervos DAO profit of a Cell
4484
- * It returns non-zero value only when the cell is in withdrawal phase 2
4485
- * See https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md
4502
+ * Get a transaction by its hash, including its status and block info.
4486
4503
  *
4487
- * @param client - A client for searching DAO related headers
4488
- * @returns Profit
4504
+ * @param txHashLike - The transaction hash to look up.
4505
+ * @returns The transaction response with status, or undefined if not found.
4489
4506
  *
4490
4507
  * @example
4491
4508
  * ```typescript
4492
- * const profit = await cell.getDaoProfit(client);
4509
+ * import { ccc } from "@ckb-ccc/core";
4510
+ *
4511
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4512
+ * const client = clientOwner.value;
4513
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4514
+ * const txResponse = await client.getTransaction("0xTX_HASH...");
4515
+ * if (txResponse) {
4516
+ * console.log(`Status: ${txResponse.status}`);
4517
+ * console.log(`Block: ${txResponse.blockNumber}`);
4518
+ * console.log(`Outputs: ${txResponse.transaction.outputs.length}`);
4519
+ * }
4493
4520
  * ```
4494
4521
  */
4495
- getDaoProfit(client: Client): Promise<Num>;
4522
+ getTransaction(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
4496
4523
  /**
4497
- * Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.
4498
- *
4499
- * @param client - A CKB client instance to fetch cell and header data.
4500
- * @returns A promise that resolves to an object containing header information.
4501
- * - If not a DAO cell, returns `{}`.
4502
- * - If a deposited DAO cell, returns `{ depositHeader }`.
4503
- * - If a withdrawn DAO cell, returns `{ depositHeader, withdrawHeader }`.
4504
- *
4505
- * @throws If the cell is a DAO cell but its corresponding headers cannot be fetched.
4506
- *
4507
- * @example
4508
- * ```typescript
4509
- * const daoInfo = await cell.getNervosDaoInfo(client);
4510
- * ```
4524
+ * This method gets specified transaction with its block header (if existed).
4525
+ * This is mainly for caching because we need the header to test if we can safely trust the cached tx status.
4526
+ * @param txHashLike
4511
4527
  */
4512
- getNervosDaoInfo(client: Client): Promise<{
4513
- depositHeader?: undefined;
4514
- withdrawHeader?: undefined;
4515
- } | {
4516
- depositHeader: ClientBlockHeader;
4517
- withdrawHeader?: undefined;
4518
- } | {
4519
- depositHeader: ClientBlockHeader;
4520
- withdrawHeader: ClientBlockHeader;
4521
- }>;
4528
+ getTransactionWithHeader(txHashLike: HexLike): Promise<{
4529
+ transaction: ClientTransactionResponse;
4530
+ header?: ClientBlockHeader;
4531
+ } | undefined>;
4522
4532
  /**
4523
- * Clone a Cell
4533
+ * Wait for a transaction to be confirmed on-chain.
4534
+ * Polls the node until the transaction reaches the specified confirmation depth.
4524
4535
  *
4525
- * @returns A cloned Cell instance.
4536
+ * @param txHash - The transaction hash to wait for.
4537
+ * @param confirmations - Number of block confirmations to wait for (default: 0 = committed).
4538
+ * @param timeout - Maximum wait time in milliseconds (default: 60000).
4539
+ * @param interval - Polling interval in milliseconds (default: 2000).
4540
+ * @returns The transaction response once confirmed, or throws on timeout.
4526
4541
  *
4527
4542
  * @example
4528
4543
  * ```typescript
4529
- * const cell1 = cell0.clone();
4544
+ * import { ccc } from "@ckb-ccc/core";
4545
+ *
4546
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4547
+ * const client = clientOwner.value;
4548
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4549
+ * // Wait for transaction to be committed (0 confirmations)
4550
+ * const tx = await client.waitTransaction("0xTX_HASH...");
4551
+ * console.log(`Confirmed in block: ${tx?.blockNumber}`);
4552
+ *
4553
+ * // Wait for 4 confirmations with 2 minute timeout
4554
+ * const confirmedTx = await client.waitTransaction(
4555
+ * "0xTX_HASH...",
4556
+ * 4, // confirmations
4557
+ * 120000, // timeout: 2 minutes
4558
+ * );
4530
4559
  * ```
4531
4560
  */
4532
- clone(): Cell;
4561
+ waitTransaction(txHash: HexLike, confirmations?: number, timeout?: number, interval?: number): Promise<ClientTransactionResponse | undefined>;
4533
4562
  }
4563
+ //#endregion
4564
+ //#region src/ckb/script.d.ts
4565
+ declare const HashTypeCodec: Codec<HashTypeLike, HashType>;
4534
4566
  /**
4535
4567
  * @public
4536
4568
  */
4537
- type SinceLike = {
4538
- relative: "absolute" | "relative";
4539
- metric: "blockNumber" | "epoch" | "timestamp";
4540
- value: NumLike;
4541
- } | NumLike;
4542
- declare const Since_base: (abstract new () => {
4569
+ type HashTypeLike = string | number | bigint;
4570
+ /**
4571
+ * @public
4572
+ */
4573
+ type HashType = "type" | "data" | "data1" | "data2";
4574
+ /**
4575
+ * Converts a HashTypeLike value to a HashType.
4576
+ * @public
4577
+ *
4578
+ * @param val - The value to convert, which can be a string, number, or bigint.
4579
+ * @returns The corresponding HashType.
4580
+ *
4581
+ * @throws Will throw an error if the input value is not a valid hash type.
4582
+ *
4583
+ * @example
4584
+ * ```typescript
4585
+ * const hashType = hashTypeFrom(1); // Outputs "data"
4586
+ * const hashType = hashTypeFrom("type"); // Outputs "type"
4587
+ * ```
4588
+ */
4589
+ declare function hashTypeFrom(val: HashTypeLike): HashType;
4590
+ /**
4591
+ * Converts a HashTypeLike value to its corresponding byte representation.
4592
+ * @public
4593
+ *
4594
+ * @param hashType - The hash type value to convert.
4595
+ * @returns A Uint8Array containing the byte representation of the hash type.
4596
+ *
4597
+ * @example
4598
+ * ```typescript
4599
+ * const hashTypeBytes = hashTypeToBytes("type"); // Outputs Uint8Array [0]
4600
+ * ```
4601
+ */
4602
+ declare function hashTypeToBytes(hashType: HashTypeLike): Bytes$1;
4603
+ /**
4604
+ * Converts a byte-like value to a HashType.
4605
+ * @public
4606
+ *
4607
+ * @param bytes - The byte-like value to convert.
4608
+ * @returns The corresponding HashType.
4609
+ *
4610
+ * @throws Will throw an error if the input bytes do not correspond to a valid hash type.
4611
+ *
4612
+ * @example
4613
+ * ```typescript
4614
+ * const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs "type"
4615
+ * ```
4616
+ */
4617
+ declare function hashTypeFromBytes(bytes: BytesLike): HashType;
4618
+ /**
4619
+ * @public
4620
+ */
4621
+ type ScriptLike = {
4622
+ codeHash: BytesLike;
4623
+ hashType: HashTypeLike;
4624
+ args: BytesLike;
4625
+ };
4626
+ declare const Script_base: (abstract new () => {
4543
4627
  toBytes(): Bytes$1;
4544
- clone(): Since;
4545
- eq(other: SinceLike): boolean;
4628
+ clone(): Script;
4629
+ eq(other: ScriptLike): boolean;
4546
4630
  hash(): Hex;
4547
4631
  toHex(): Hex;
4548
4632
  }) & {
4549
4633
  byteLength?: number;
4550
- encode(_: SinceLike): Bytes$1;
4551
- decode(_: BytesLike): Since;
4552
- fromBytes(_bytes: BytesLike): Since;
4553
- from(_: SinceLike): Since;
4634
+ encode(_: ScriptLike): Bytes$1;
4635
+ decode(_: BytesLike): Script;
4636
+ fromBytes(_bytes: BytesLike): Script;
4637
+ from(_: ScriptLike): Script;
4554
4638
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4555
4639
  toBytes(): Bytes$1;
4556
4640
  clone(): SubType;
@@ -4627,89 +4711,182 @@ declare const Since_base: (abstract new () => {
4627
4711
  /**
4628
4712
  * @public
4629
4713
  */
4630
- declare class Since extends Since_base {
4631
- relative: "absolute" | "relative";
4632
- metric: "blockNumber" | "epoch" | "timestamp";
4633
- value: Num;
4714
+ declare class Script extends Script_base {
4715
+ codeHash: Hex;
4716
+ hashType: HashType;
4717
+ args: Hex;
4634
4718
  /**
4635
- * Creates an instance of Since.
4719
+ * Creates an instance of Script.
4636
4720
  *
4637
- * @param relative - Absolute or relative
4638
- * @param metric - The metric of since
4639
- * @param value - The value of since
4721
+ * @param codeHash - The code hash of the script.
4722
+ * @param hashType - The hash type of the script.
4723
+ * @param args - The arguments for the script.
4640
4724
  */
4641
- constructor(relative: "absolute" | "relative", metric: "blockNumber" | "epoch" | "timestamp", value: Num);
4725
+ constructor(codeHash: Hex, hashType: HashType, args: Hex);
4726
+ get occupiedSize(): number;
4642
4727
  /**
4643
- * Clone a Since.
4728
+ * Clone a script.
4644
4729
  *
4645
- * @returns A cloned Since instance.
4730
+ * @returns A cloned Script instance.
4646
4731
  *
4647
4732
  * @example
4648
4733
  * ```typescript
4649
- * const since1 = since0.clone();
4734
+ * const script1 = script0.clone();
4650
4735
  * ```
4651
4736
  */
4652
- clone(): Since;
4737
+ clone(): Script;
4653
4738
  /**
4654
- * Creates a Since instance from a SinceLike object.
4655
- *
4656
- * @param since - A SinceLike object or an instance of Since.
4657
- * @returns A Since instance.
4739
+ * Check if the script is equal to another script.
4740
+ * @public
4741
+ * @param other - The other script to compare with
4742
+ * @returns True if the scripts are equal, false otherwise
4658
4743
  *
4659
4744
  * @example
4660
4745
  * ```typescript
4661
- * const since = Since.from("0x1234567812345678");
4746
+ * const isEqual = script0.eq(script1);
4662
4747
  * ```
4663
4748
  */
4664
- static from(since: SinceLike): Since;
4749
+ eq(other: ScriptLike): boolean;
4665
4750
  /**
4666
- * Converts the Since instance to num.
4751
+ * Creates a Script instance from a ScriptLike object.
4667
4752
  *
4668
- * @returns A num
4753
+ * @param script - A ScriptLike object or an instance of Script.
4754
+ * @returns A Script instance.
4669
4755
  *
4670
4756
  * @example
4671
4757
  * ```typescript
4672
- * const num = since.toNum();
4758
+ * const script = Script.from({
4759
+ * codeHash: "0x1234...",
4760
+ * hashType: "type",
4761
+ * args: "0xabcd..."
4762
+ * });
4673
4763
  * ```
4674
4764
  */
4675
- toNum(): Num;
4765
+ static from(script: ScriptLike): Script;
4676
4766
  /**
4677
- * Creates a Since instance from a num-like value.
4767
+ * Creates a Script instance from client and known script.
4678
4768
  *
4679
- * @param numLike - The num-like value to convert.
4680
- * @returns A Since instance.
4769
+ * @param knownScript - A KnownScript enum.
4770
+ * @param args - Args for the script.
4771
+ * @param client - A ScriptLike object or an instance of Script.
4772
+ * @returns A promise that resolves to the script instance.
4681
4773
  *
4682
4774
  * @example
4683
4775
  * ```typescript
4684
- * const since = Since.fromNum("0x0");
4776
+ * const script = await Script.fromKnownScript(
4777
+ * client,
4778
+ * KnownScript.XUdt,
4779
+ * args: "0xabcd..."
4780
+ * );
4685
4781
  * ```
4686
4782
  */
4687
- static fromNum(numLike: NumLike): Since;
4783
+ static fromKnownScript(client: Client, knownScript: KnownScript, args: HexLike): Promise<Script>;
4784
+ }
4785
+ declare const ScriptOpt: Codec<ScriptLike | null | undefined, Script | undefined>;
4786
+ declare const ScriptVec: Codec<ScriptLike[], Script[]>;
4787
+ //#endregion
4788
+ //#region src/ckb/transactionLumos.d.ts
4789
+ interface LumosTransactionSkeletonType {
4790
+ cellDeps: {
4791
+ toArray(): CellDepLike[];
4792
+ };
4793
+ headerDeps: {
4794
+ toArray(): HexLike[];
4795
+ };
4796
+ inputs: {
4797
+ toArray(): {
4798
+ outPoint?: OutPointLike;
4799
+ cellOutput: CellOutputLike;
4800
+ data: HexLike;
4801
+ }[];
4802
+ };
4803
+ inputSinces: {
4804
+ get(i: number, defaultVal: string): HexLike;
4805
+ };
4806
+ outputs: {
4807
+ toArray(): {
4808
+ cellOutput: CellOutputLike;
4809
+ data: HexLike;
4810
+ }[];
4811
+ };
4812
+ witnesses: {
4813
+ toArray(): HexLike[];
4814
+ };
4688
4815
  }
4816
+ //#endregion
4817
+ //#region src/ckb/transaction.d.ts
4818
+ declare const DepTypeCodec: Codec<DepTypeLike, DepType>;
4689
4819
  /**
4690
4820
  * @public
4691
4821
  */
4692
- type CellInputLike = ({
4693
- previousOutput: OutPointLike;
4694
- } | {
4695
- outPoint: OutPointLike;
4696
- }) & {
4697
- since?: SinceLike | NumLike | null;
4698
- cellOutput?: CellOutputLike | null;
4699
- outputData?: HexLike | null;
4822
+ type DepTypeLike = string | number | bigint;
4823
+ /**
4824
+ * @public
4825
+ */
4826
+ type DepType = "depGroup" | "code";
4827
+ /**
4828
+ * Converts a DepTypeLike value to a DepType.
4829
+ * @public
4830
+ *
4831
+ * @param val - The value to convert, which can be a string, number, or bigint.
4832
+ * @returns The corresponding DepType.
4833
+ *
4834
+ * @throws Will throw an error if the input value is not a valid dep type.
4835
+ *
4836
+ * @example
4837
+ * ```typescript
4838
+ * const depType = depTypeFrom(1); // Outputs "code"
4839
+ * const depType = depTypeFrom("depGroup"); // Outputs "depGroup"
4840
+ * ```
4841
+ */
4842
+ declare function depTypeFrom(val: DepTypeLike): DepType;
4843
+ /**
4844
+ * Converts a DepTypeLike value to its corresponding byte representation.
4845
+ * @public
4846
+ *
4847
+ * @param depType - The dep type value to convert.
4848
+ * @returns A Uint8Array containing the byte representation of the dep type.
4849
+ *
4850
+ * @example
4851
+ * ```typescript
4852
+ * const depTypeBytes = depTypeToBytes("code"); // Outputs Uint8Array [1]
4853
+ * ```
4854
+ */
4855
+ declare function depTypeToBytes(depType: DepTypeLike): Bytes$1;
4856
+ /**
4857
+ * Converts a byte-like value to a DepType.
4858
+ * @public
4859
+ *
4860
+ * @param bytes - The byte-like value to convert.
4861
+ * @returns The corresponding DepType.
4862
+ *
4863
+ * @throws Will throw an error if the input bytes do not correspond to a valid dep type.
4864
+ *
4865
+ * @example
4866
+ * ```typescript
4867
+ * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs "code"
4868
+ * ```
4869
+ */
4870
+ declare function depTypeFromBytes(bytes: BytesLike): DepType;
4871
+ /**
4872
+ * @public
4873
+ */
4874
+ type OutPointLike = {
4875
+ txHash: HexLike;
4876
+ index: NumLike;
4700
4877
  };
4701
- declare const CellInput_base: (abstract new () => {
4878
+ declare const OutPoint_base: (abstract new () => {
4702
4879
  toBytes(): Bytes$1;
4703
- clone(): CellInput;
4704
- eq(other: CellInputLike): boolean;
4880
+ clone(): OutPoint;
4881
+ eq(other: OutPointLike): boolean;
4705
4882
  hash(): Hex;
4706
4883
  toHex(): Hex;
4707
4884
  }) & {
4708
4885
  byteLength?: number;
4709
- encode(_: CellInputLike): Bytes$1;
4710
- decode(_: BytesLike): CellInput;
4711
- fromBytes(_bytes: BytesLike): CellInput;
4712
- from(_: CellInputLike): CellInput;
4886
+ encode(_: OutPointLike): Bytes$1;
4887
+ decode(_: BytesLike): OutPoint;
4888
+ fromBytes(_bytes: BytesLike): OutPoint;
4889
+ from(_: OutPointLike): OutPoint;
4713
4890
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4714
4891
  toBytes(): Bytes$1;
4715
4892
  clone(): SubType;
@@ -4786,87 +4963,72 @@ declare const CellInput_base: (abstract new () => {
4786
4963
  /**
4787
4964
  * @public
4788
4965
  */
4789
- declare class CellInput extends CellInput_base {
4790
- previousOutput: OutPoint;
4791
- since: Num;
4792
- cellOutput?: CellOutput | undefined;
4793
- outputData?: Hex | undefined;
4966
+ declare class OutPoint extends OutPoint_base {
4967
+ txHash: Hex;
4968
+ index: Num;
4794
4969
  /**
4795
- * Creates an instance of CellInput.
4970
+ * Creates an instance of OutPoint.
4796
4971
  *
4797
- * @param previousOutput - The previous outpoint of the cell.
4798
- * @param since - The since value of the cell input.
4799
- * @param cellOutput - The optional cell output associated with the cell input.
4800
- * @param outputData - The optional output data associated with the cell input.
4972
+ * @param txHash - The transaction hash.
4973
+ * @param index - The index of the output in the transaction.
4801
4974
  */
4802
- constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: Hex | undefined);
4975
+ constructor(txHash: Hex, index: Num);
4803
4976
  /**
4804
- * Creates a CellInput instance from a CellInputLike object.
4977
+ * Creates an OutPoint instance from an OutPointLike object.
4805
4978
  *
4806
- * @param cellInput - A CellInputLike object or an instance of CellInput.
4807
- * @returns A CellInput instance.
4979
+ * @param outPoint - An OutPointLike object or an instance of OutPoint.
4980
+ * @returns An OutPoint instance.
4808
4981
  *
4809
4982
  * @example
4810
4983
  * ```typescript
4811
- * const cellInput = CellInput.from({
4812
- * previousOutput: { txHash: "0x...", index: 0 },
4813
- * since: 0n
4814
- * });
4984
+ * const outPoint = OutPoint.from({ txHash: "0x...", index: 0 });
4815
4985
  * ```
4816
4986
  */
4817
- static from(cellInput: CellInputLike): CellInput;
4818
- getCell(client: Client): Promise<Cell>;
4987
+ static from(outPoint: OutPointLike): OutPoint;
4819
4988
  /**
4820
- * Complete extra infos in the input. Including
4821
- * - Previous cell output
4822
- * - Previous cell data
4823
- * The instance will be modified.
4989
+ * Clone a OutPoint.
4990
+ *
4991
+ * @returns A cloned OutPoint instance.
4824
4992
  *
4825
- * @returns true if succeed.
4826
4993
  * @example
4827
4994
  * ```typescript
4828
- * await cellInput.completeExtraInfos(client);
4995
+ * const outPoint1 = outPoint0.clone();
4829
4996
  * ```
4830
4997
  */
4831
- completeExtraInfos(client: Client): Promise<void>;
4832
- /**
4833
- * The extra capacity created when consume this input.
4834
- * This is usually NervosDAO interest, see https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md.
4835
- * And it can also be miners' income. (But this is not implemented yet)
4836
- */
4837
- getExtraCapacity(client: Client): Promise<Num>;
4998
+ clone(): OutPoint;
4838
4999
  /**
4839
- * Clone a CellInput.
4840
- *
4841
- * @returns A cloned CellInput instance.
5000
+ * Check if the OutPoint is equal to another OutPoint.
5001
+ * @public
5002
+ * @param other - The other OutPoint to compare with
5003
+ * @returns True if the OutPoints are equal, false otherwise
4842
5004
  *
4843
5005
  * @example
4844
5006
  * ```typescript
4845
- * const cellInput1 = cellInput0.clone();
5007
+ * const isEqual = outPoint0.eq(outPoint1);
4846
5008
  * ```
4847
5009
  */
4848
- clone(): CellInput;
5010
+ eq(other: OutPointLike): boolean;
4849
5011
  }
4850
- declare const CellInputVec: Codec<CellInputLike[], CellInput[]>;
4851
5012
  /**
4852
5013
  * @public
4853
5014
  */
4854
- type CellDepLike = {
4855
- outPoint: OutPointLike;
4856
- depType: DepTypeLike;
5015
+ type CellOutputLike = {
5016
+ capacity?: NumLike | null;
5017
+ lock: ScriptLike;
5018
+ type?: ScriptLike | null;
4857
5019
  };
4858
- declare const CellDep_base: (abstract new () => {
5020
+ declare const CellOutput_base: (abstract new () => {
4859
5021
  toBytes(): Bytes$1;
4860
- clone(): CellDep;
4861
- eq(other: CellDepLike): boolean;
5022
+ clone(): CellOutput;
5023
+ eq(other: CellOutputLike): boolean;
4862
5024
  hash(): Hex;
4863
5025
  toHex(): Hex;
4864
5026
  }) & {
4865
5027
  byteLength?: number;
4866
- encode(_: CellDepLike): Bytes$1;
4867
- decode(_: BytesLike): CellDep;
4868
- fromBytes(_bytes: BytesLike): CellDep;
4869
- from(_: CellDepLike): CellDep;
5028
+ encode(_: CellOutputLike): Bytes$1;
5029
+ decode(_: BytesLike): CellOutput;
5030
+ fromBytes(_bytes: BytesLike): CellOutput;
5031
+ from(_: CellOutputLike): CellOutput;
4870
5032
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4871
5033
  toBytes(): Bytes$1;
4872
5034
  clone(): SubType;
@@ -4943,64 +5105,286 @@ declare const CellDep_base: (abstract new () => {
4943
5105
  /**
4944
5106
  * @public
4945
5107
  */
4946
- declare class CellDep extends CellDep_base {
4947
- outPoint: OutPoint;
4948
- depType: DepType;
5108
+ declare class CellOutput extends CellOutput_base {
5109
+ capacity: Num;
5110
+ lock: Script;
5111
+ type?: Script | undefined;
4949
5112
  /**
4950
- * Creates an instance of CellDep.
5113
+ * Creates an instance of CellOutput.
4951
5114
  *
4952
- * @param outPoint - The outpoint of the cell dependency.
4953
- * @param depType - The dependency type.
5115
+ * @param capacity - The capacity of the cell.
5116
+ * @param lock - The lock script of the cell.
5117
+ * @param type - The optional type script of the cell.
4954
5118
  */
4955
- constructor(outPoint: OutPoint, depType: DepType);
5119
+ constructor(capacity: Num, lock: Script, type?: Script | undefined);
5120
+ get occupiedSize(): number;
4956
5121
  /**
4957
- * Creates a CellDep instance from a CellDepLike object.
5122
+ * Creates a CellOutput instance from a CellOutputLike object.
5123
+ * This method supports automatic capacity calculation when outputData is provided and capacity is 0 or omitted.
4958
5124
  *
4959
- * @param cellDep - A CellDepLike object or an instance of CellDep.
4960
- * @returns A CellDep instance.
5125
+ * @param cellOutput - A CellOutputLike object or an instance of CellOutput.
5126
+ * @param outputData - Optional output data used for automatic capacity calculation.
5127
+ * When provided and capacity is 0, the capacity will be calculated
5128
+ * as occupiedSize + outputData.length.
5129
+ * @returns A CellOutput instance.
4961
5130
  *
4962
5131
  * @example
4963
5132
  * ```typescript
4964
- * const cellDep = CellDep.from({
4965
- * outPoint: { txHash: "0x...", index: 0 },
4966
- * depType: "depGroup"
5133
+ * // Basic usage with explicit capacity
5134
+ * const cellOutput1 = CellOutput.from({
5135
+ * capacity: 1000n,
5136
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." },
5137
+ * type: { codeHash: "0x...", hashType: "type", args: "0x..." }
4967
5138
  * });
5139
+ *
5140
+ * // Automatic capacity calculation
5141
+ * const cellOutput2 = CellOutput.from({
5142
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5143
+ * }, "0x1234"); // Capacity will be calculated automatically
4968
5144
  * ```
4969
5145
  */
4970
- static from(cellDep: CellDepLike): CellDep;
5146
+ static from(cellOutput: CellOutputLike, outputData?: HexLike | null): CellOutput;
4971
5147
  /**
4972
- * Clone a CellDep.
5148
+ * Clone a CellOutput.
4973
5149
  *
4974
- * @returns A cloned CellDep instance.
5150
+ * @returns A cloned CellOutput instance.
4975
5151
  *
4976
5152
  * @example
4977
5153
  * ```typescript
4978
- * const cellDep1 = cellDep0.clone();
5154
+ * const cellOutput1 = cellOutput0.clone();
4979
5155
  * ```
4980
5156
  */
4981
- clone(): CellDep;
5157
+ clone(): CellOutput;
4982
5158
  }
4983
- declare const CellDepVec: Codec<CellDepLike[], CellDep[]>;
5159
+ declare const CellOutputVec: Codec<CellOutputLike[], CellOutput[]>;
4984
5160
  /**
4985
5161
  * @public
5162
+ * Represents a cell-like object that may or may not be on-chain.
5163
+ * It can optionally have an `outPoint` (or `previousOutput`).
5164
+ * This is used as a flexible input for creating `CellAny` instances.
5165
+ * @see CellAny
4986
5166
  */
4987
- type WitnessArgsLike = {
4988
- lock?: HexLike | null;
4989
- inputType?: HexLike | null;
4990
- outputType?: HexLike | null;
5167
+ type CellAnyLike = {
5168
+ outPoint?: OutPointLike | null;
5169
+ previousOutput?: OutPointLike | null;
5170
+ cellOutput: CellOutputLike;
5171
+ outputData?: HexLike | null;
4991
5172
  };
4992
- declare const WitnessArgs_base: (abstract new () => {
5173
+ /**
5174
+ * Represents a CKB cell that can be either on-chain (with an `outPoint`) or off-chain (without an `outPoint`).
5175
+ * This class provides a unified interface for handling cells before they are included in a transaction,
5176
+ * or for cells that are already part of the blockchain state.
5177
+ *
5178
+ * @public
5179
+ */
5180
+ declare class CellAny {
5181
+ cellOutput: CellOutput;
5182
+ outputData: Hex;
5183
+ outPoint: OutPoint | undefined;
5184
+ /**
5185
+ * Creates an instance of CellAny.
5186
+ *
5187
+ * @param cellOutput - The cell output of the cell.
5188
+ * @param outputData - The output data of the cell.
5189
+ * @param outPoint - The optional output point of the cell. If provided, the cell is considered on-chain.
5190
+ */
5191
+ constructor(cellOutput: CellOutput, outputData: Hex, outPoint?: OutPoint);
5192
+ /**
5193
+ * Creates a `CellAny` instance from a `CellAnyLike` object.
5194
+ * This factory method provides a convenient way to create `CellAny` instances
5195
+ * from plain objects, automatically handling the optional `outPoint` or `previousOutput`.
5196
+ *
5197
+ * @param cell - A `CellAnyLike` object.
5198
+ * @returns A new `CellAny` instance.
5199
+ *
5200
+ * @example
5201
+ * ```typescript
5202
+ * // Create an off-chain cell (e.g., a new output)
5203
+ * const offChainCell = CellAny.from({
5204
+ * cellOutput: { capacity: 1000n, lock: lockScript },
5205
+ * outputData: "0x"
5206
+ * });
5207
+ *
5208
+ * // Create an on-chain cell from an input
5209
+ * const onChainCell = CellAny.from({
5210
+ * outPoint: { txHash: "0x...", index: 0 },
5211
+ * cellOutput: { capacity: 2000n, lock: lockScript },
5212
+ * outputData: "0x1234"
5213
+ * });
5214
+ * ```
5215
+ */
5216
+ static from(cell: CellAnyLike): CellAny;
5217
+ /**
5218
+ * Calculates the total occupied size of the cell in bytes.
5219
+ * This includes the size of the `CellOutput` structure plus the size of the `outputData`.
5220
+ *
5221
+ * @returns The total occupied size in bytes.
5222
+ */
5223
+ get occupiedSize(): number;
5224
+ /**
5225
+ * Calculates the free capacity of the cell.
5226
+ * Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.
5227
+ *
5228
+ * @returns The free capacity in shannons as a `Num`.
5229
+ */
5230
+ get capacityFree(): bigint;
5231
+ /**
5232
+ * Checks if the cell is a Nervos DAO cell and optionally checks its phase.
5233
+ *
5234
+ * @param client - A CKB client instance to fetch known script information.
5235
+ * @param phase - Optional phase to check: "deposited" or "withdrew".
5236
+ * If omitted, it checks if the cell is a DAO cell regardless of phase.
5237
+ * @returns A promise that resolves to `true` if the cell is a matching Nervos DAO cell, `false` otherwise.
5238
+ */
5239
+ isNervosDao(client: Client, phase?: "deposited" | "withdrew"): Promise<boolean>;
5240
+ /**
5241
+ * Clones the `CellAny` instance.
5242
+ *
5243
+ * @returns A new `CellAny` instance that is a deep copy of the current one.
5244
+ *
5245
+ * @example
5246
+ * ```typescript
5247
+ * const clonedCell = cellAny.clone();
5248
+ * ```
5249
+ */
5250
+ clone(): CellAny;
5251
+ }
5252
+ /**
5253
+ * Represents a cell-like object that is guaranteed to be on-chain.
5254
+ * It must have an `outPoint` (or its alias `previousOutput`).
5255
+ * This is used as a type constraint for creating `Cell` instances.
5256
+ * @see Cell
5257
+ * @public
5258
+ */
5259
+ type CellLike = CellAnyLike & ({
5260
+ outPoint: OutPointLike;
5261
+ previousOutput?: undefined | null;
5262
+ } | {
5263
+ outPoint?: undefined | null;
5264
+ previousOutput: OutPointLike;
5265
+ });
5266
+ /**
5267
+ * Represents an on-chain CKB cell, which is a `CellAny` that is guaranteed to have an `outPoint`.
5268
+ * This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.
5269
+ * @public
5270
+ */
5271
+ declare class Cell extends CellAny {
5272
+ outPoint: OutPoint;
5273
+ /**
5274
+ * Creates an instance of an on-chain Cell.
5275
+ *
5276
+ * @param outPoint - The output point of the cell.
5277
+ * @param cellOutput - The cell output of the cell.
5278
+ * @param outputData - The output data of the cell.
5279
+ */
5280
+ constructor(outPoint: OutPoint, cellOutput: CellOutput, outputData: Hex);
5281
+ /**
5282
+ * Creates a Cell instance from a CellLike object.
5283
+ * This method accepts either `outPoint` or `previousOutput` to specify the cell's location,
5284
+ * and supports automatic capacity calculation for the cell output.
5285
+ *
5286
+ * @param cell - A CellLike object or an instance of Cell. The object can use either:
5287
+ * - `outPoint`: For referencing a cell output
5288
+ * - `previousOutput`: For referencing a cell input (alternative name for outPoint)
5289
+ * The cellOutput can omit capacity for automatic calculation.
5290
+ * @returns A Cell instance.
5291
+ *
5292
+ * @example
5293
+ * ```typescript
5294
+ * // Using outPoint with explicit capacity
5295
+ * const cell1 = Cell.from({
5296
+ * outPoint: { txHash: "0x...", index: 0 },
5297
+ * cellOutput: {
5298
+ * capacity: 1000n,
5299
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5300
+ * },
5301
+ * outputData: "0x"
5302
+ * });
5303
+ *
5304
+ * // Using previousOutput with automatic capacity calculation
5305
+ * const cell2 = Cell.from({
5306
+ * previousOutput: { txHash: "0x...", index: 0 },
5307
+ * cellOutput: {
5308
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5309
+ * // capacity will be calculated automatically
5310
+ * },
5311
+ * outputData: "0x1234"
5312
+ * });
5313
+ * ```
5314
+ */
5315
+ static from(cell: CellLike): Cell;
5316
+ /**
5317
+ * Gets confirmed Nervos DAO profit of a Cell
5318
+ * It returns non-zero value only when the cell is in withdrawal phase 2
5319
+ * See https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md
5320
+ *
5321
+ * @param client - A client for searching DAO related headers
5322
+ * @returns Profit
5323
+ *
5324
+ * @example
5325
+ * ```typescript
5326
+ * const profit = await cell.getDaoProfit(client);
5327
+ * ```
5328
+ */
5329
+ getDaoProfit(client: Client): Promise<Num>;
5330
+ /**
5331
+ * Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.
5332
+ *
5333
+ * @param client - A CKB client instance to fetch cell and header data.
5334
+ * @returns A promise that resolves to an object containing header information.
5335
+ * - If not a DAO cell, returns `{}`.
5336
+ * - If a deposited DAO cell, returns `{ depositHeader }`.
5337
+ * - If a withdrawn DAO cell, returns `{ depositHeader, withdrawHeader }`.
5338
+ *
5339
+ * @throws If the cell is a DAO cell but its corresponding headers cannot be fetched.
5340
+ *
5341
+ * @example
5342
+ * ```typescript
5343
+ * const daoInfo = await cell.getNervosDaoInfo(client);
5344
+ * ```
5345
+ */
5346
+ getNervosDaoInfo(client: Client): Promise<{
5347
+ depositHeader?: undefined;
5348
+ withdrawHeader?: undefined;
5349
+ } | {
5350
+ depositHeader: ClientBlockHeader;
5351
+ withdrawHeader?: undefined;
5352
+ } | {
5353
+ depositHeader: ClientBlockHeader;
5354
+ withdrawHeader: ClientBlockHeader;
5355
+ }>;
5356
+ /**
5357
+ * Clone a Cell
5358
+ *
5359
+ * @returns A cloned Cell instance.
5360
+ *
5361
+ * @example
5362
+ * ```typescript
5363
+ * const cell1 = cell0.clone();
5364
+ * ```
5365
+ */
5366
+ clone(): Cell;
5367
+ }
5368
+ /**
5369
+ * @public
5370
+ */
5371
+ type SinceLike = {
5372
+ relative: "absolute" | "relative";
5373
+ metric: "blockNumber" | "epoch" | "timestamp";
5374
+ value: NumLike;
5375
+ } | NumLike;
5376
+ declare const Since_base: (abstract new () => {
4993
5377
  toBytes(): Bytes$1;
4994
- clone(): WitnessArgs;
4995
- eq(other: WitnessArgsLike): boolean;
5378
+ clone(): Since;
5379
+ eq(other: SinceLike): boolean;
4996
5380
  hash(): Hex;
4997
5381
  toHex(): Hex;
4998
5382
  }) & {
4999
5383
  byteLength?: number;
5000
- encode(_: WitnessArgsLike): Bytes$1;
5001
- decode(_: BytesLike): WitnessArgs;
5002
- fromBytes(_bytes: BytesLike): WitnessArgs;
5003
- from(_: WitnessArgsLike): WitnessArgs;
5384
+ encode(_: SinceLike): Bytes$1;
5385
+ decode(_: BytesLike): Since;
5386
+ fromBytes(_bytes: BytesLike): Since;
5387
+ from(_: SinceLike): Since;
5004
5388
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5005
5389
  toBytes(): Bytes$1;
5006
5390
  clone(): SubType;
@@ -5077,80 +5461,89 @@ declare const WitnessArgs_base: (abstract new () => {
5077
5461
  /**
5078
5462
  * @public
5079
5463
  */
5080
- declare class WitnessArgs extends WitnessArgs_base {
5081
- lock?: Hex | undefined;
5082
- inputType?: Hex | undefined;
5083
- outputType?: Hex | undefined;
5464
+ declare class Since extends Since_base {
5465
+ relative: "absolute" | "relative";
5466
+ metric: "blockNumber" | "epoch" | "timestamp";
5467
+ value: Num;
5084
5468
  /**
5085
- * Creates an instance of WitnessArgs.
5469
+ * Creates an instance of Since.
5086
5470
  *
5087
- * @param lock - The optional lock field of the witness.
5088
- * @param inputType - The optional input type field of the witness.
5089
- * @param outputType - The optional output type field of the witness.
5471
+ * @param relative - Absolute or relative
5472
+ * @param metric - The metric of since
5473
+ * @param value - The value of since
5090
5474
  */
5091
- constructor(lock?: Hex | undefined, inputType?: Hex | undefined, outputType?: Hex | undefined);
5475
+ constructor(relative: "absolute" | "relative", metric: "blockNumber" | "epoch" | "timestamp", value: Num);
5092
5476
  /**
5093
- * Creates a WitnessArgs instance from a WitnessArgsLike object.
5477
+ * Clone a Since.
5094
5478
  *
5095
- * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.
5096
- * @returns A WitnessArgs instance.
5479
+ * @returns A cloned Since instance.
5097
5480
  *
5098
5481
  * @example
5099
5482
  * ```typescript
5100
- * const witnessArgs = WitnessArgs.from({
5101
- * lock: "0x...",
5102
- * inputType: "0x...",
5103
- * outputType: "0x..."
5104
- * });
5483
+ * const since1 = since0.clone();
5105
5484
  * ```
5106
5485
  */
5107
- static from(witnessArgs: WitnessArgsLike): WitnessArgs;
5486
+ clone(): Since;
5487
+ /**
5488
+ * Creates a Since instance from a SinceLike object.
5489
+ *
5490
+ * @param since - A SinceLike object or an instance of Since.
5491
+ * @returns A Since instance.
5492
+ *
5493
+ * @example
5494
+ * ```typescript
5495
+ * const since = Since.from("0x1234567812345678");
5496
+ * ```
5497
+ */
5498
+ static from(since: SinceLike): Since;
5499
+ /**
5500
+ * Converts the Since instance to num.
5501
+ *
5502
+ * @returns A num
5503
+ *
5504
+ * @example
5505
+ * ```typescript
5506
+ * const num = since.toNum();
5507
+ * ```
5508
+ */
5509
+ toNum(): Num;
5510
+ /**
5511
+ * Creates a Since instance from a num-like value.
5512
+ *
5513
+ * @param numLike - The num-like value to convert.
5514
+ * @returns A Since instance.
5515
+ *
5516
+ * @example
5517
+ * ```typescript
5518
+ * const since = Since.fromNum("0x0");
5519
+ * ```
5520
+ */
5521
+ static fromNum(numLike: NumLike): Since;
5108
5522
  }
5109
- /**
5110
- * Convert a bytes to a num.
5111
- *
5112
- * @public
5113
- */
5114
- declare function udtBalanceFrom(dataLike: BytesLike): Num;
5115
- declare const RawTransaction: Codec<EncodableRecord<{
5116
- version: Codec<NumLike, number>;
5117
- cellDeps: Codec<CellDepLike[], CellDep[]>;
5118
- headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5119
- inputs: Codec<CellInputLike[], CellInput[]>;
5120
- outputs: Codec<CellOutputLike[], CellOutput[]>;
5121
- outputsData: Codec<BytesLike[], `0x${string}`[]>;
5122
- }>, DecodedRecord<{
5123
- version: Codec<NumLike, number>;
5124
- cellDeps: Codec<CellDepLike[], CellDep[]>;
5125
- headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5126
- inputs: Codec<CellInputLike[], CellInput[]>;
5127
- outputs: Codec<CellOutputLike[], CellOutput[]>;
5128
- outputsData: Codec<BytesLike[], `0x${string}`[]>;
5129
- }>>;
5130
5523
  /**
5131
5524
  * @public
5132
5525
  */
5133
- type TransactionLike = {
5134
- version?: NumLike | null;
5135
- cellDeps?: CellDepLike[] | null;
5136
- headerDeps?: HexLike[] | null;
5137
- inputs?: CellInputLike[] | null;
5138
- outputs?: (Omit<CellOutputLike, "capacity"> & Partial<Pick<CellOutputLike, "capacity">>)[] | null;
5139
- outputsData?: HexLike[] | null;
5140
- witnesses?: HexLike[] | null;
5526
+ type CellInputLike = ({
5527
+ previousOutput: OutPointLike;
5528
+ } | {
5529
+ outPoint: OutPointLike;
5530
+ }) & {
5531
+ since?: SinceLike | NumLike | null;
5532
+ cellOutput?: CellOutputLike | null;
5533
+ outputData?: HexLike | null;
5141
5534
  };
5142
- declare const Transaction_base: (abstract new () => {
5535
+ declare const CellInput_base: (abstract new () => {
5143
5536
  toBytes(): Bytes$1;
5144
- clone(): Transaction;
5145
- eq(other: TransactionLike): boolean;
5537
+ clone(): CellInput;
5538
+ eq(other: CellInputLike): boolean;
5146
5539
  hash(): Hex;
5147
5540
  toHex(): Hex;
5148
5541
  }) & {
5149
5542
  byteLength?: number;
5150
- encode(_: TransactionLike): Bytes$1;
5151
- decode(_: BytesLike): Transaction;
5152
- fromBytes(_bytes: BytesLike): Transaction;
5153
- from(_: TransactionLike): Transaction;
5543
+ encode(_: CellInputLike): Bytes$1;
5544
+ decode(_: BytesLike): CellInput;
5545
+ fromBytes(_bytes: BytesLike): CellInput;
5546
+ from(_: CellInputLike): CellInput;
5154
5547
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5155
5548
  toBytes(): Bytes$1;
5156
5549
  clone(): SubType;
@@ -5227,269 +5620,710 @@ declare const Transaction_base: (abstract new () => {
5227
5620
  /**
5228
5621
  * @public
5229
5622
  */
5230
- declare class Transaction extends Transaction_base {
5231
- version: Num;
5232
- cellDeps: CellDep[];
5233
- headerDeps: Hex[];
5234
- inputs: CellInput[];
5235
- outputs: CellOutput[];
5236
- outputsData: Hex[];
5237
- witnesses: Hex[];
5238
- /**
5239
- * Creates an instance of Transaction.
5240
- *
5241
- * @param version - The version of the transaction.
5242
- * @param cellDeps - The cell dependencies of the transaction.
5243
- * @param headerDeps - The header dependencies of the transaction.
5244
- * @param inputs - The inputs of the transaction.
5245
- * @param outputs - The outputs of the transaction.
5246
- * @param outputsData - The data associated with the outputs.
5247
- * @param witnesses - The witnesses of the transaction.
5248
- */
5249
- constructor(version: Num, cellDeps: CellDep[], headerDeps: Hex[], inputs: CellInput[], outputs: CellOutput[], outputsData: Hex[], witnesses: Hex[]);
5250
- /**
5251
- * Creates a default Transaction instance with empty fields.
5252
- *
5253
- * @returns A default Transaction instance.
5254
- *
5255
- * @example
5256
- * ```typescript
5257
- * const defaultTx = Transaction.default();
5258
- * ```
5259
- */
5260
- static default(): Transaction;
5261
- /**
5262
- * Copy every properties from another transaction.
5263
- * This method replaces all properties of the current transaction with those from the provided transaction.
5264
- *
5265
- * @param txLike - The transaction-like object to copy properties from.
5266
- *
5267
- * @example
5268
- * ```typescript
5269
- * this.copy(Transaction.default());
5270
- * ```
5271
- */
5272
- copy(txLike: TransactionLike): void;
5623
+ declare class CellInput extends CellInput_base {
5624
+ previousOutput: OutPoint;
5625
+ since: Num;
5626
+ cellOutput?: CellOutput | undefined;
5627
+ outputData?: Hex | undefined;
5273
5628
  /**
5274
- * Creates a deep copy of the transaction.
5275
- * This method creates a new Transaction instance with all nested objects cloned,
5276
- * ensuring that modifications to the cloned transaction do not affect the original.
5277
- *
5278
- * @returns A new Transaction instance that is a deep copy of the current transaction.
5279
- *
5280
- * @example
5281
- * ```typescript
5282
- * const originalTx = Transaction.from({
5283
- * version: 0,
5284
- * inputs: [{ previousOutput: { txHash: "0x...", index: 0 } }],
5285
- * outputs: [{ capacity: 1000n, lock: lockScript }],
5286
- * outputsData: ["0x"],
5287
- * witnesses: ["0x"]
5288
- * });
5289
- *
5290
- * const clonedTx = originalTx.clone();
5291
- *
5292
- * // Modifications to clonedTx won't affect originalTx
5293
- * clonedTx.addOutput({ capacity: 2000n, lock: anotherLockScript });
5294
- * console.log(originalTx.outputs.length); // Still 1
5295
- * console.log(clonedTx.outputs.length); // Now 2
5296
- * ```
5297
- *
5298
- * @remarks
5299
- * The clone operation performs deep copying for:
5300
- * - Cell dependencies (cellDeps) - each CellDep is cloned
5301
- * - Inputs - each CellInput is cloned
5302
- * - Outputs - each CellOutput is cloned
5629
+ * Creates an instance of CellInput.
5303
5630
  *
5304
- * The following are shallow copied (references to immutable data):
5305
- * - Header dependencies (headerDeps) - Hex strings are immutable
5306
- * - Output data (outputsData) - Hex strings are immutable
5307
- * - Witnesses - Hex strings are immutable
5308
- * - Version - bigint is immutable
5631
+ * @param previousOutput - The previous outpoint of the cell.
5632
+ * @param since - The since value of the cell input.
5633
+ * @param cellOutput - The optional cell output associated with the cell input.
5634
+ * @param outputData - The optional output data associated with the cell input.
5309
5635
  */
5310
- clone(): Transaction;
5636
+ constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: Hex | undefined);
5311
5637
  /**
5312
- * Creates a Transaction instance from a TransactionLike object.
5638
+ * Creates a CellInput instance from a CellInputLike object.
5313
5639
  *
5314
- * @param tx - A TransactionLike object or an instance of Transaction.
5315
- * @returns A Transaction instance.
5640
+ * @param cellInput - A CellInputLike object or an instance of CellInput.
5641
+ * @returns A CellInput instance.
5316
5642
  *
5317
5643
  * @example
5318
5644
  * ```typescript
5319
- * const transaction = Transaction.from({
5320
- * version: 0,
5321
- * cellDeps: [],
5322
- * headerDeps: [],
5323
- * inputs: [],
5324
- * outputs: [],
5325
- * outputsData: [],
5326
- * witnesses: []
5645
+ * const cellInput = CellInput.from({
5646
+ * previousOutput: { txHash: "0x...", index: 0 },
5647
+ * since: 0n
5327
5648
  * });
5328
5649
  * ```
5329
5650
  */
5330
- static from(tx: TransactionLike): Transaction;
5651
+ static from(cellInput: CellInputLike): CellInput;
5652
+ getCell(client: Client): Promise<Cell>;
5331
5653
  /**
5332
- * Creates a Transaction instance from a Lumos skeleton.
5333
- *
5334
- * @param skeleton - The Lumos transaction skeleton.
5335
- * @returns A Transaction instance.
5336
- *
5337
- * @throws Will throw an error if an input's outPoint is missing.
5654
+ * Complete extra infos in the input. Including
5655
+ * - Previous cell output
5656
+ * - Previous cell data
5657
+ * The instance will be modified.
5338
5658
  *
5659
+ * @returns true if succeed.
5339
5660
  * @example
5340
5661
  * ```typescript
5341
- * const transaction = Transaction.fromLumosSkeleton(skeleton);
5662
+ * await cellInput.completeExtraInfos(client);
5342
5663
  * ```
5343
5664
  */
5344
- static fromLumosSkeleton(skeleton: LumosTransactionSkeletonType): Transaction;
5665
+ completeExtraInfos(client: Client): Promise<void>;
5345
5666
  /**
5346
- * @deprecated
5347
- * Use ccc.stringify instead.
5348
- * stringify the tx to JSON string.
5667
+ * The extra capacity created when consume this input.
5668
+ * This is usually NervosDAO interest, see https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md.
5669
+ * And it can also be miners' income. (But this is not implemented yet)
5349
5670
  */
5350
- stringify(): string;
5671
+ getExtraCapacity(client: Client): Promise<Num>;
5351
5672
  /**
5352
- * Converts the raw transaction data to bytes.
5673
+ * Clone a CellInput.
5353
5674
  *
5354
- * @returns A Uint8Array containing the raw transaction bytes.
5675
+ * @returns A cloned CellInput instance.
5355
5676
  *
5356
5677
  * @example
5357
5678
  * ```typescript
5358
- * const rawTxBytes = transaction.rawToBytes();
5679
+ * const cellInput1 = cellInput0.clone();
5359
5680
  * ```
5360
5681
  */
5361
- rawToBytes(): Bytes$1;
5362
- /**
5363
- * Calculates the hash of the transaction without witnesses. This is the transaction hash in the usual sense.
5364
- * To calculate the hash of the whole transaction including the witnesses, use transaction.hashFull() instead.
5365
- *
5366
- * @returns The hash of the transaction.
5682
+ clone(): CellInput;
5683
+ }
5684
+ declare const CellInputVec: Codec<CellInputLike[], CellInput[]>;
5685
+ /**
5686
+ * @public
5687
+ */
5688
+ type CellDepLike = {
5689
+ outPoint: OutPointLike;
5690
+ depType: DepTypeLike;
5691
+ };
5692
+ declare const CellDep_base: (abstract new () => {
5693
+ toBytes(): Bytes$1;
5694
+ clone(): CellDep;
5695
+ eq(other: CellDepLike): boolean;
5696
+ hash(): Hex;
5697
+ toHex(): Hex;
5698
+ }) & {
5699
+ byteLength?: number;
5700
+ encode(_: CellDepLike): Bytes$1;
5701
+ decode(_: BytesLike): CellDep;
5702
+ fromBytes(_bytes: BytesLike): CellDep;
5703
+ from(_: CellDepLike): CellDep;
5704
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5705
+ toBytes(): Bytes$1;
5706
+ clone(): SubType;
5707
+ eq(other: SubTypeLike): boolean;
5708
+ hash(): Hex;
5709
+ toHex(): Hex;
5710
+ }) & {
5711
+ byteLength?: number;
5712
+ encode(_: SubTypeLike): Bytes$1;
5713
+ decode(_: BytesLike): SubType;
5714
+ fromBytes(_bytes: BytesLike): SubType;
5715
+ from(_: SubTypeLike): SubType;
5716
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5717
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
5718
+ readonly inner: DecodedType<CodecType>;
5719
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5720
+ _?: undefined | null;
5721
+ }): Result;
5722
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5723
+ _: (inner: DecodedType<CodecType>) => Result;
5724
+ }): Result;
5725
+ toBytes(): Bytes$1;
5726
+ clone(): SubType_1;
5727
+ eq(other: SubTypeLike_1): boolean;
5728
+ hash(): Hex;
5729
+ toHex(): Hex;
5730
+ }) & {
5731
+ byteLength?: number;
5732
+ encode(_: SubTypeLike_1): Bytes$1;
5733
+ decode(_: BytesLike): SubType_1;
5734
+ fromBytes(_bytes: BytesLike): SubType_1;
5735
+ from(_: SubTypeLike_1): SubType_1;
5736
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5737
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5738
+ };
5739
+ };
5740
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
5741
+ readonly inner: DecodedType<CodecType>;
5742
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5743
+ _?: undefined | null;
5744
+ }): Result;
5745
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5746
+ _: (inner: DecodedType<CodecType>) => Result;
5747
+ }): Result;
5748
+ toBytes(): Bytes$1;
5749
+ clone(): SubType;
5750
+ eq(other: SubTypeLike): boolean;
5751
+ hash(): Hex;
5752
+ toHex(): Hex;
5753
+ }) & {
5754
+ byteLength?: number;
5755
+ encode(_: SubTypeLike): Bytes$1;
5756
+ decode(_: BytesLike): SubType;
5757
+ fromBytes(_bytes: BytesLike): SubType;
5758
+ from(_: SubTypeLike): SubType;
5759
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
5760
+ toBytes(): Bytes$1;
5761
+ clone(): SubType_1;
5762
+ eq(other: SubTypeLike_1): boolean;
5763
+ hash(): Hex;
5764
+ toHex(): Hex;
5765
+ }) & {
5766
+ byteLength?: number;
5767
+ encode(_: SubTypeLike_1): Bytes$1;
5768
+ decode(_: BytesLike): SubType_1;
5769
+ fromBytes(_bytes: BytesLike): SubType_1;
5770
+ from(_: SubTypeLike_1): SubType_1;
5771
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5772
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5773
+ };
5774
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5775
+ };
5776
+ };
5777
+ /**
5778
+ * @public
5779
+ */
5780
+ declare class CellDep extends CellDep_base {
5781
+ outPoint: OutPoint;
5782
+ depType: DepType;
5783
+ /**
5784
+ * Creates an instance of CellDep.
5367
5785
  *
5368
- * @example
5369
- * ```typescript
5370
- * const txHash = transaction.hash();
5371
- * ```
5786
+ * @param outPoint - The outpoint of the cell dependency.
5787
+ * @param depType - The dependency type.
5372
5788
  */
5373
- hash(): Hex;
5789
+ constructor(outPoint: OutPoint, depType: DepType);
5374
5790
  /**
5375
- * Calculates the hash of the transaction with witnesses.
5791
+ * Creates a CellDep instance from a CellDepLike object.
5376
5792
  *
5377
- * @returns The hash of the transaction with witnesses.
5793
+ * @param cellDep - A CellDepLike object or an instance of CellDep.
5794
+ * @returns A CellDep instance.
5378
5795
  *
5379
5796
  * @example
5380
5797
  * ```typescript
5381
- * const txFullHash = transaction.hashFull();
5798
+ * const cellDep = CellDep.from({
5799
+ * outPoint: { txHash: "0x...", index: 0 },
5800
+ * depType: "depGroup"
5801
+ * });
5382
5802
  * ```
5383
5803
  */
5384
- hashFull(): Hex;
5804
+ static from(cellDep: CellDepLike): CellDep;
5385
5805
  /**
5386
- * Hashes a witness and updates the hasher.
5806
+ * Clone a CellDep.
5387
5807
  *
5388
- * @param witness - The witness to hash.
5389
- * @param hasher - The hasher instance to update.
5808
+ * @returns A cloned CellDep instance.
5390
5809
  *
5391
5810
  * @example
5392
5811
  * ```typescript
5393
- * Transaction.hashWitnessToHasher("0x...", hasher);
5812
+ * const cellDep1 = cellDep0.clone();
5394
5813
  * ```
5395
5814
  */
5396
- static hashWitnessToHasher(witness: HexLike, hasher: Hasher): void;
5815
+ clone(): CellDep;
5816
+ }
5817
+ declare const CellDepVec: Codec<CellDepLike[], CellDep[]>;
5818
+ /**
5819
+ * @public
5820
+ */
5821
+ type WitnessArgsLike = {
5822
+ lock?: HexLike | null;
5823
+ inputType?: HexLike | null;
5824
+ outputType?: HexLike | null;
5825
+ };
5826
+ declare const WitnessArgs_base: (abstract new () => {
5827
+ toBytes(): Bytes$1;
5828
+ clone(): WitnessArgs;
5829
+ eq(other: WitnessArgsLike): boolean;
5830
+ hash(): Hex;
5831
+ toHex(): Hex;
5832
+ }) & {
5833
+ byteLength?: number;
5834
+ encode(_: WitnessArgsLike): Bytes$1;
5835
+ decode(_: BytesLike): WitnessArgs;
5836
+ fromBytes(_bytes: BytesLike): WitnessArgs;
5837
+ from(_: WitnessArgsLike): WitnessArgs;
5838
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5839
+ toBytes(): Bytes$1;
5840
+ clone(): SubType;
5841
+ eq(other: SubTypeLike): boolean;
5842
+ hash(): Hex;
5843
+ toHex(): Hex;
5844
+ }) & {
5845
+ byteLength?: number;
5846
+ encode(_: SubTypeLike): Bytes$1;
5847
+ decode(_: BytesLike): SubType;
5848
+ fromBytes(_bytes: BytesLike): SubType;
5849
+ from(_: SubTypeLike): SubType;
5850
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5851
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
5852
+ readonly inner: DecodedType<CodecType>;
5853
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5854
+ _?: undefined | null;
5855
+ }): Result;
5856
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5857
+ _: (inner: DecodedType<CodecType>) => Result;
5858
+ }): Result;
5859
+ toBytes(): Bytes$1;
5860
+ clone(): SubType_1;
5861
+ eq(other: SubTypeLike_1): boolean;
5862
+ hash(): Hex;
5863
+ toHex(): Hex;
5864
+ }) & {
5865
+ byteLength?: number;
5866
+ encode(_: SubTypeLike_1): Bytes$1;
5867
+ decode(_: BytesLike): SubType_1;
5868
+ fromBytes(_bytes: BytesLike): SubType_1;
5869
+ from(_: SubTypeLike_1): SubType_1;
5870
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5871
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5872
+ };
5873
+ };
5874
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
5875
+ readonly inner: DecodedType<CodecType>;
5876
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5877
+ _?: undefined | null;
5878
+ }): Result;
5879
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5880
+ _: (inner: DecodedType<CodecType>) => Result;
5881
+ }): Result;
5882
+ toBytes(): Bytes$1;
5883
+ clone(): SubType;
5884
+ eq(other: SubTypeLike): boolean;
5885
+ hash(): Hex;
5886
+ toHex(): Hex;
5887
+ }) & {
5888
+ byteLength?: number;
5889
+ encode(_: SubTypeLike): Bytes$1;
5890
+ decode(_: BytesLike): SubType;
5891
+ fromBytes(_bytes: BytesLike): SubType;
5892
+ from(_: SubTypeLike): SubType;
5893
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
5894
+ toBytes(): Bytes$1;
5895
+ clone(): SubType_1;
5896
+ eq(other: SubTypeLike_1): boolean;
5897
+ hash(): Hex;
5898
+ toHex(): Hex;
5899
+ }) & {
5900
+ byteLength?: number;
5901
+ encode(_: SubTypeLike_1): Bytes$1;
5902
+ decode(_: BytesLike): SubType_1;
5903
+ fromBytes(_bytes: BytesLike): SubType_1;
5904
+ from(_: SubTypeLike_1): SubType_1;
5905
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5906
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5907
+ };
5908
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5909
+ };
5910
+ };
5911
+ /**
5912
+ * @public
5913
+ */
5914
+ declare class WitnessArgs extends WitnessArgs_base {
5915
+ lock?: Hex | undefined;
5916
+ inputType?: Hex | undefined;
5917
+ outputType?: Hex | undefined;
5397
5918
  /**
5398
- * Computes the signing hash information for a given script.
5919
+ * Creates an instance of WitnessArgs.
5399
5920
  *
5400
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
5401
- * @param client - The client for complete extra infos in the transaction.
5402
- * @returns A promise that resolves to an object containing the signing message and the witness position,
5403
- * or undefined if no matching input is found.
5921
+ * @param lock - The optional lock field of the witness.
5922
+ * @param inputType - The optional input type field of the witness.
5923
+ * @param outputType - The optional output type field of the witness.
5924
+ */
5925
+ constructor(lock?: Hex | undefined, inputType?: Hex | undefined, outputType?: Hex | undefined);
5926
+ /**
5927
+ * Creates a WitnessArgs instance from a WitnessArgsLike object.
5928
+ *
5929
+ * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.
5930
+ * @returns A WitnessArgs instance.
5404
5931
  *
5405
5932
  * @example
5406
5933
  * ```typescript
5407
- * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
5408
- * if (signHashInfo) {
5409
- * console.log(signHashInfo.message); // Outputs the signing message
5410
- * console.log(signHashInfo.position); // Outputs the witness position
5411
- * }
5934
+ * const witnessArgs = WitnessArgs.from({
5935
+ * lock: "0x...",
5936
+ * inputType: "0x...",
5937
+ * outputType: "0x..."
5938
+ * });
5412
5939
  * ```
5413
5940
  */
5414
- getSignHashInfo(scriptLike: ScriptLike, client: Client, hasher?: Hasher): Promise<{
5415
- message: Hex;
5416
- position: number;
5417
- } | undefined>;
5941
+ static from(witnessArgs: WitnessArgsLike): WitnessArgs;
5942
+ }
5943
+ /**
5944
+ * Convert a bytes to a num.
5945
+ *
5946
+ * @public
5947
+ */
5948
+ declare function udtBalanceFrom(dataLike: BytesLike): Num;
5949
+ declare const RawTransaction: Codec<EncodableRecord<{
5950
+ version: Codec<NumLike, number>;
5951
+ cellDeps: Codec<CellDepLike[], CellDep[]>;
5952
+ headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5953
+ inputs: Codec<CellInputLike[], CellInput[]>;
5954
+ outputs: Codec<CellOutputLike[], CellOutput[]>;
5955
+ outputsData: Codec<BytesLike[], `0x${string}`[]>;
5956
+ }>, DecodedRecord<{
5957
+ version: Codec<NumLike, number>;
5958
+ cellDeps: Codec<CellDepLike[], CellDep[]>;
5959
+ headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5960
+ inputs: Codec<CellInputLike[], CellInput[]>;
5961
+ outputs: Codec<CellOutputLike[], CellOutput[]>;
5962
+ outputsData: Codec<BytesLike[], `0x${string}`[]>;
5963
+ }>>;
5964
+ /**
5965
+ * @public
5966
+ */
5967
+ type TransactionLike = {
5968
+ version?: NumLike | null;
5969
+ cellDeps?: CellDepLike[] | null;
5970
+ headerDeps?: HexLike[] | null;
5971
+ inputs?: CellInputLike[] | null;
5972
+ outputs?: (Omit<CellOutputLike, "capacity"> & Partial<Pick<CellOutputLike, "capacity">>)[] | null;
5973
+ outputsData?: HexLike[] | null;
5974
+ witnesses?: HexLike[] | null;
5975
+ };
5976
+ declare const Transaction_base: (abstract new () => {
5977
+ toBytes(): Bytes$1;
5978
+ clone(): Transaction;
5979
+ eq(other: TransactionLike): boolean;
5980
+ hash(): Hex;
5981
+ toHex(): Hex;
5982
+ }) & {
5983
+ byteLength?: number;
5984
+ encode(_: TransactionLike): Bytes$1;
5985
+ decode(_: BytesLike): Transaction;
5986
+ fromBytes(_bytes: BytesLike): Transaction;
5987
+ from(_: TransactionLike): Transaction;
5988
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5989
+ toBytes(): Bytes$1;
5990
+ clone(): SubType;
5991
+ eq(other: SubTypeLike): boolean;
5992
+ hash(): Hex;
5993
+ toHex(): Hex;
5994
+ }) & {
5995
+ byteLength?: number;
5996
+ encode(_: SubTypeLike): Bytes$1;
5997
+ decode(_: BytesLike): SubType;
5998
+ fromBytes(_bytes: BytesLike): SubType;
5999
+ from(_: SubTypeLike): SubType;
6000
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6001
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
6002
+ readonly inner: DecodedType<CodecType>;
6003
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
6004
+ _?: undefined | null;
6005
+ }): Result;
6006
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
6007
+ _: (inner: DecodedType<CodecType>) => Result;
6008
+ }): Result;
6009
+ toBytes(): Bytes$1;
6010
+ clone(): SubType_1;
6011
+ eq(other: SubTypeLike_1): boolean;
6012
+ hash(): Hex;
6013
+ toHex(): Hex;
6014
+ }) & {
6015
+ byteLength?: number;
6016
+ encode(_: SubTypeLike_1): Bytes$1;
6017
+ decode(_: BytesLike): SubType_1;
6018
+ fromBytes(_bytes: BytesLike): SubType_1;
6019
+ from(_: SubTypeLike_1): SubType_1;
6020
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6021
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
6022
+ };
6023
+ };
6024
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
6025
+ readonly inner: DecodedType<CodecType>;
6026
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
6027
+ _?: undefined | null;
6028
+ }): Result;
6029
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
6030
+ _: (inner: DecodedType<CodecType>) => Result;
6031
+ }): Result;
6032
+ toBytes(): Bytes$1;
6033
+ clone(): SubType;
6034
+ eq(other: SubTypeLike): boolean;
6035
+ hash(): Hex;
6036
+ toHex(): Hex;
6037
+ }) & {
6038
+ byteLength?: number;
6039
+ encode(_: SubTypeLike): Bytes$1;
6040
+ decode(_: BytesLike): SubType;
6041
+ fromBytes(_bytes: BytesLike): SubType;
6042
+ from(_: SubTypeLike): SubType;
6043
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
6044
+ toBytes(): Bytes$1;
6045
+ clone(): SubType_1;
6046
+ eq(other: SubTypeLike_1): boolean;
6047
+ hash(): Hex;
6048
+ toHex(): Hex;
6049
+ }) & {
6050
+ byteLength?: number;
6051
+ encode(_: SubTypeLike_1): Bytes$1;
6052
+ decode(_: BytesLike): SubType_1;
6053
+ fromBytes(_bytes: BytesLike): SubType_1;
6054
+ from(_: SubTypeLike_1): SubType_1;
6055
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
6056
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6057
+ };
6058
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6059
+ };
6060
+ };
6061
+ /**
6062
+ * @public
6063
+ */
6064
+ declare class Transaction extends Transaction_base {
6065
+ version: Num;
6066
+ cellDeps: CellDep[];
6067
+ headerDeps: Hex[];
6068
+ inputs: CellInput[];
6069
+ outputs: CellOutput[];
6070
+ outputsData: Hex[];
6071
+ witnesses: Hex[];
5418
6072
  /**
5419
- * Find the first occurrence of a input with the specified lock id
6073
+ * Creates an instance of Transaction.
5420
6074
  *
5421
- * @param scriptIdLike - The script associated with the transaction, represented as a ScriptLike object without args.
5422
- * @param client - The client for complete extra infos in the transaction.
5423
- * @returns A promise that resolves to the found index
6075
+ * @param version - The version of the transaction.
6076
+ * @param cellDeps - The cell dependencies of the transaction.
6077
+ * @param headerDeps - The header dependencies of the transaction.
6078
+ * @param inputs - The inputs of the transaction.
6079
+ * @param outputs - The outputs of the transaction.
6080
+ * @param outputsData - The data associated with the outputs.
6081
+ * @param witnesses - The witnesses of the transaction.
6082
+ */
6083
+ constructor(version: Num, cellDeps: CellDep[], headerDeps: Hex[], inputs: CellInput[], outputs: CellOutput[], outputsData: Hex[], witnesses: Hex[]);
6084
+ /**
6085
+ * Creates a default Transaction instance with empty fields.
6086
+ *
6087
+ * @returns A default Transaction instance.
5424
6088
  *
5425
6089
  * @example
5426
6090
  * ```typescript
5427
- * const index = await tx.findInputIndexByLockId(scriptIdLike, client);
6091
+ * const defaultTx = Transaction.default();
5428
6092
  * ```
5429
6093
  */
5430
- findInputIndexByLockId(scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">, client: Client): Promise<number | undefined>;
6094
+ static default(): Transaction;
5431
6095
  /**
5432
- * Find the first occurrence of a input with the specified lock
6096
+ * Copy every properties from another transaction.
6097
+ * This method replaces all properties of the current transaction with those from the provided transaction.
5433
6098
  *
5434
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
5435
- * @param client - The client for complete extra infos in the transaction.
5436
- * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6099
+ * @param txLike - The transaction-like object to copy properties from.
5437
6100
  *
5438
6101
  * @example
5439
6102
  * ```typescript
5440
- * const index = await tx.findInputIndexByLock(scriptLike, client);
6103
+ * this.copy(Transaction.default());
5441
6104
  * ```
5442
6105
  */
5443
- findInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6106
+ copy(txLike: TransactionLike): void;
5444
6107
  /**
5445
- * Find the last occurrence of a input with the specified lock
6108
+ * Creates a deep copy of the transaction.
6109
+ * This method creates a new Transaction instance with all nested objects cloned,
6110
+ * ensuring that modifications to the cloned transaction do not affect the original.
5446
6111
  *
5447
- * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
5448
- * @param client - The client for complete extra infos in the transaction.
5449
- * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6112
+ * @returns A new Transaction instance that is a deep copy of the current transaction.
5450
6113
  *
5451
6114
  * @example
5452
6115
  * ```typescript
5453
- * const index = await tx.findLastInputIndexByLock(scriptLike, client);
6116
+ * const originalTx = Transaction.from({
6117
+ * version: 0,
6118
+ * inputs: [{ previousOutput: { txHash: "0x...", index: 0 } }],
6119
+ * outputs: [{ capacity: 1000n, lock: lockScript }],
6120
+ * outputsData: ["0x"],
6121
+ * witnesses: ["0x"]
6122
+ * });
6123
+ *
6124
+ * const clonedTx = originalTx.clone();
6125
+ *
6126
+ * // Modifications to clonedTx won't affect originalTx
6127
+ * clonedTx.addOutput({ capacity: 2000n, lock: anotherLockScript });
6128
+ * console.log(originalTx.outputs.length); // Still 1
6129
+ * console.log(clonedTx.outputs.length); // Now 2
5454
6130
  * ```
6131
+ *
6132
+ * @remarks
6133
+ * The clone operation performs deep copying for:
6134
+ * - Cell dependencies (cellDeps) - each CellDep is cloned
6135
+ * - Inputs - each CellInput is cloned
6136
+ * - Outputs - each CellOutput is cloned
6137
+ *
6138
+ * The following are shallow copied (references to immutable data):
6139
+ * - Header dependencies (headerDeps) - Hex strings are immutable
6140
+ * - Output data (outputsData) - Hex strings are immutable
6141
+ * - Witnesses - Hex strings are immutable
6142
+ * - Version - bigint is immutable
5455
6143
  */
5456
- findLastInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6144
+ clone(): Transaction;
5457
6145
  /**
5458
- * Add cell deps if they are not existed
6146
+ * Creates a Transaction instance from a TransactionLike object.
5459
6147
  *
5460
- * @param cellDepLikes - The cell deps to add
6148
+ * @param tx - A TransactionLike object or an instance of Transaction.
6149
+ * @returns A Transaction instance.
5461
6150
  *
5462
6151
  * @example
5463
6152
  * ```typescript
5464
- * tx.addCellDeps(cellDep);
6153
+ * const transaction = Transaction.from({
6154
+ * version: 0,
6155
+ * cellDeps: [],
6156
+ * headerDeps: [],
6157
+ * inputs: [],
6158
+ * outputs: [],
6159
+ * outputsData: [],
6160
+ * witnesses: []
6161
+ * });
5465
6162
  * ```
5466
6163
  */
5467
- addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6164
+ static from(tx: TransactionLike): Transaction;
5468
6165
  /**
5469
- * Add cell deps at the start if they are not existed
6166
+ * Creates a Transaction instance from a Lumos skeleton.
5470
6167
  *
5471
- * @param cellDepLikes - The cell deps to add
6168
+ * @param skeleton - The Lumos transaction skeleton.
6169
+ * @returns A Transaction instance.
6170
+ *
6171
+ * @throws Will throw an error if an input's outPoint is missing.
5472
6172
  *
5473
6173
  * @example
5474
6174
  * ```typescript
5475
- * tx.addCellDepsAtBegin(cellDep);
6175
+ * const transaction = Transaction.fromLumosSkeleton(skeleton);
5476
6176
  * ```
5477
6177
  */
5478
- addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6178
+ static fromLumosSkeleton(skeleton: LumosTransactionSkeletonType): Transaction;
5479
6179
  /**
5480
- * Add cell dep from infos if they are not existed
6180
+ * @deprecated
6181
+ * Use ccc.stringify instead.
6182
+ * stringify the tx to JSON string.
6183
+ */
6184
+ stringify(): string;
6185
+ /**
6186
+ * Converts the raw transaction data to bytes.
5481
6187
  *
5482
- * @param client - A client for searching cell deps
5483
- * @param cellDepInfoLikes - The cell dep infos to add
6188
+ * @returns A Uint8Array containing the raw transaction bytes.
5484
6189
  *
5485
6190
  * @example
5486
6191
  * ```typescript
5487
- * tx.addCellDepInfos(client, cellDepInfos);
6192
+ * const rawTxBytes = transaction.rawToBytes();
5488
6193
  * ```
5489
6194
  */
5490
- addCellDepInfos(client: Client, ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<void>;
6195
+ rawToBytes(): Bytes$1;
5491
6196
  /**
5492
- * Add cell deps from known script
6197
+ * Calculates the hash of the transaction without witnesses. This is the transaction hash in the usual sense.
6198
+ * To calculate the hash of the whole transaction including the witnesses, use transaction.hashFull() instead.
6199
+ *
6200
+ * @returns The hash of the transaction.
6201
+ *
6202
+ * @example
6203
+ * ```typescript
6204
+ * const txHash = transaction.hash();
6205
+ * ```
6206
+ */
6207
+ hash(): Hex;
6208
+ /**
6209
+ * Calculates the hash of the transaction with witnesses.
6210
+ *
6211
+ * @returns The hash of the transaction with witnesses.
6212
+ *
6213
+ * @example
6214
+ * ```typescript
6215
+ * const txFullHash = transaction.hashFull();
6216
+ * ```
6217
+ */
6218
+ hashFull(): Hex;
6219
+ /**
6220
+ * Hashes a witness and updates the hasher.
6221
+ *
6222
+ * @param witness - The witness to hash.
6223
+ * @param hasher - The hasher instance to update.
6224
+ *
6225
+ * @example
6226
+ * ```typescript
6227
+ * Transaction.hashWitnessToHasher("0x...", hasher);
6228
+ * ```
6229
+ */
6230
+ static hashWitnessToHasher(witness: HexLike, hasher: Hasher): void;
6231
+ /**
6232
+ * Computes the signing hash information for a given script.
6233
+ *
6234
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6235
+ * @param client - The client for complete extra infos in the transaction.
6236
+ * @returns A promise that resolves to an object containing the signing message and the witness position,
6237
+ * or undefined if no matching input is found.
6238
+ *
6239
+ * @example
6240
+ * ```typescript
6241
+ * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
6242
+ * if (signHashInfo) {
6243
+ * console.log(signHashInfo.message); // Outputs the signing message
6244
+ * console.log(signHashInfo.position); // Outputs the witness position
6245
+ * }
6246
+ * ```
6247
+ */
6248
+ getSignHashInfo(scriptLike: ScriptLike, client: Client, hasher?: Hasher): Promise<{
6249
+ message: Hex;
6250
+ position: number;
6251
+ } | undefined>;
6252
+ /**
6253
+ * Find the first occurrence of a input with the specified lock id
6254
+ *
6255
+ * @param scriptIdLike - The script associated with the transaction, represented as a ScriptLike object without args.
6256
+ * @param client - The client for complete extra infos in the transaction.
6257
+ * @returns A promise that resolves to the found index
6258
+ *
6259
+ * @example
6260
+ * ```typescript
6261
+ * const index = await tx.findInputIndexByLockId(scriptIdLike, client);
6262
+ * ```
6263
+ */
6264
+ findInputIndexByLockId(scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">, client: Client): Promise<number | undefined>;
6265
+ /**
6266
+ * Find the first occurrence of a input with the specified lock
6267
+ *
6268
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6269
+ * @param client - The client for complete extra infos in the transaction.
6270
+ * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6271
+ *
6272
+ * @example
6273
+ * ```typescript
6274
+ * const index = await tx.findInputIndexByLock(scriptLike, client);
6275
+ * ```
6276
+ */
6277
+ findInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6278
+ /**
6279
+ * Find the last occurrence of a input with the specified lock
6280
+ *
6281
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6282
+ * @param client - The client for complete extra infos in the transaction.
6283
+ * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6284
+ *
6285
+ * @example
6286
+ * ```typescript
6287
+ * const index = await tx.findLastInputIndexByLock(scriptLike, client);
6288
+ * ```
6289
+ */
6290
+ findLastInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6291
+ /**
6292
+ * Add cell deps if they are not existed
6293
+ *
6294
+ * @param cellDepLikes - The cell deps to add
6295
+ *
6296
+ * @example
6297
+ * ```typescript
6298
+ * tx.addCellDeps(cellDep);
6299
+ * ```
6300
+ */
6301
+ addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6302
+ /**
6303
+ * Add cell deps at the start if they are not existed
6304
+ *
6305
+ * @param cellDepLikes - The cell deps to add
6306
+ *
6307
+ * @example
6308
+ * ```typescript
6309
+ * tx.addCellDepsAtBegin(cellDep);
6310
+ * ```
6311
+ */
6312
+ addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6313
+ /**
6314
+ * Add cell dep from infos if they are not existed
6315
+ *
6316
+ * @param client - A client for searching cell deps
6317
+ * @param cellDepInfoLikes - The cell dep infos to add
6318
+ *
6319
+ * @example
6320
+ * ```typescript
6321
+ * tx.addCellDepInfos(client, cellDepInfos);
6322
+ * ```
6323
+ */
6324
+ addCellDepInfos(client: Client, ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<void>;
6325
+ /**
6326
+ * Add cell deps from known script
5493
6327
  *
5494
6328
  * @param client - The client for searching known script and cell deps
5495
6329
  * @param scripts - The known scripts to add
@@ -6081,571 +6915,98 @@ declare abstract class ClientCache {
6081
6915
  */
6082
6916
  recordHeaders(..._headers: (ClientBlockHeaderLike | ClientBlockHeaderLike[])[]): Promise<void>;
6083
6917
  /**
6084
- * Get a known block header by hash
6085
- * Implement this method to enable block headers query caching
6086
- * @param _hash
6087
- */
6088
- getHeaderByHash(_hash: HexLike): Promise<ClientBlockHeader | undefined>;
6089
- /**
6090
- * Get a known block header by number
6091
- * Implement this method to enable block headers query caching
6092
- * @param _number
6093
- */
6094
- getHeaderByNumber(_number: NumLike): Promise<ClientBlockHeader | undefined>;
6095
- /**
6096
- * Record known blocks.
6097
- * Implement this method to enable blocks query caching
6098
- * @param _blocks
6099
- */
6100
- recordBlocks(..._blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6101
- /**
6102
- * Get a known block header by hash
6103
- * Implement this method to enable block headers query caching
6104
- * @param _hash
6105
- */
6106
- getBlockByHash(_hash: HexLike): Promise<ClientBlock | undefined>;
6107
- /**
6108
- * Get a known block header by number
6109
- * Implement this method to enable block headers query caching
6110
- * @param _number
6111
- */
6112
- getBlockByNumber(_number: NumLike): Promise<ClientBlock | undefined>;
6113
- /**
6114
- * Checks if a block header is considered confirmed.
6115
- * The default implementation compares the header's timestamp against the current time
6116
- * and a configured confirmation time. Override this method for custom confirmation logic.
6117
- * @param header
6118
- */
6119
- hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6120
- }
6121
- //#endregion
6122
- //#region src/client/cache/memory.d.ts
6123
- declare class ClientCacheMemory extends ClientCache {
6124
- private readonly maxCells;
6125
- private readonly maxTxs;
6126
- private readonly maxBlocks;
6127
- /**
6128
- * OutPoint => [isLive, Cell | OutPoint]
6129
- */
6130
- private readonly cells;
6131
- /**
6132
- * TX Hash => Transaction Response
6133
- */
6134
- private readonly knownTransactions;
6135
- /**
6136
- * Block Number => Block Hash
6137
- */
6138
- private readonly knownBlockHashes;
6139
- /**
6140
- * Block Hash => Block Header / Full Block
6141
- */
6142
- private readonly knownBlocks;
6143
- private readonly confirmedBlockTime;
6144
- /**
6145
- * @param maxCells - Maximum number of cells to store in the cache. Defaults to 512.
6146
- * @param maxTxs - Maximum number of transactions to store in the cache. Defaults to 256.
6147
- * @param maxBlocks - Maximum number of blocks to store in the cache. Defaults to 128.
6148
- * @param confirmedBlockTimeLike - Time in milliseconds after which a block is considered confirmed.
6149
- * Defaults to DEFAULT_CONFIRMED_BLOCK_TIME (50 blocks * 10s).
6150
- */
6151
- constructor(maxCells?: number, maxTxs?: number, maxBlocks?: number, confirmedBlockTimeLike?: NumLike);
6152
- markUsableNoCache(...cellLikes: (CellLike | CellLike[])[]): Promise<void>;
6153
- markUnusable(...outPointLikes: (OutPointLike | OutPointLike[])[]): Promise<void>;
6154
- clear(): Promise<void>;
6155
- findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
6156
- isUnusable(outPointLike: OutPointLike): Promise<boolean>;
6157
- recordCells(...cells: (CellLike | CellLike[])[]): Promise<void>;
6158
- getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
6159
- recordTransactionResponses(...transactions: (ClientTransactionResponseLike | ClientTransactionResponseLike[])[]): Promise<void>;
6160
- getTransactionResponse(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
6161
- recordHeaders(...headers: (ClientBlockHeaderLike | ClientBlockHeaderLike[])[]): Promise<void>;
6162
- getHeaderByHash(hashLike: HexLike): Promise<ClientBlockHeader | undefined>;
6163
- getHeaderByNumber(numberLike: NumLike): Promise<ClientBlockHeader | undefined>;
6164
- recordBlocks(...blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6165
- getBlockByHash(hashLike: HexLike): Promise<ClientBlock | undefined>;
6166
- getBlockByNumber(numberLike: NumLike): Promise<ClientBlock | undefined>;
6167
- hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6168
- }
6169
- //#endregion
6170
- //#region src/client/client.d.ts
6171
- /**
6172
- * @public
6173
- */
6174
- declare abstract class Client {
6175
- cache: ClientCache;
6176
- constructor(config?: {
6177
- cache?: ClientCache;
6178
- });
6179
- abstract get url(): string;
6180
- abstract get addressPrefix(): string;
6181
- /**
6182
- * Get the deployment info for a well-known CKB script.
6183
- * Returns the cell deps and type script info needed to use the script.
6184
- *
6185
- * @param script - The KnownScript enum value.
6186
- * @returns Script info including cellDeps and type hash.
6187
- *
6188
- * @example
6189
- * ```typescript
6190
- * import { ccc } from "@ckb-ccc/core";
6191
- *
6192
- * const client = new ccc.ClientPublicTestnet();
6193
- *
6194
- * // Get xUDT script deployment info
6195
- * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
6196
- * console.log(`xUDT cellDeps:`, xudtInfo.cellDeps);
6197
- *
6198
- * // Build an xUDT type script
6199
- * const xudtType = await ccc.Script.fromKnownScript(
6200
- * client,
6201
- * ccc.KnownScript.XUdt,
6202
- * "0xOWNER_LOCK_HASH...",
6203
- * );
6204
- * ```
6205
- */
6206
- abstract getKnownScript(script: KnownScript): Promise<ScriptInfo>;
6207
- abstract getFeeRateStatistics(blockRange?: NumLike): Promise<{
6208
- mean: Num;
6209
- median: Num;
6210
- }>;
6211
- /**
6212
- * Get the recommended transaction fee rate based on recent blocks.
6213
- * Returns the median fee rate, clamped between min and max fee rates.
6214
- *
6215
- * @param blockRange - Number of recent blocks to analyze.
6216
- * @param options - Optional max fee rate cap.
6217
- * @returns The recommended fee rate in Shannons per KB.
6218
- *
6219
- * @example
6220
- * ```typescript
6221
- * import { ccc } from "@ckb-ccc/core";
6222
- *
6223
- * const client = new ccc.ClientPublicTestnet();
6224
- * const feeRate = await client.getFeeRate();
6225
- * console.log(`Current fee rate: ${feeRate} Shannons/KB`);
6226
- * ```
6227
- */
6228
- getFeeRate(blockRange?: NumLike, options?: {
6229
- maxFeeRate?: NumLike;
6230
- }): Promise<Num>;
6231
- /**
6232
- * Get the latest block number (tip) of the chain.
6233
- *
6234
- * @returns The current tip block number.
6235
- *
6236
- * @example
6237
- * ```typescript
6238
- * import { ccc } from "@ckb-ccc/core";
6239
- *
6240
- * const client = new ccc.ClientPublicTestnet();
6241
- * const tipBlockNumber = await client.getTip();
6242
- * console.log(`Current block height: ${tipBlockNumber}`);
6243
- * ```
6244
- */
6245
- abstract getTip(): Promise<Num>;
6246
- /**
6247
- * Get the header of the latest block.
6248
- *
6249
- * @param verbosity - Verbosity level (0 for hex, 1 for object).
6250
- * @returns The tip block header.
6251
- *
6252
- * @example
6253
- * ```typescript
6254
- * import { ccc } from "@ckb-ccc/core";
6255
- *
6256
- * const client = new ccc.ClientPublicTestnet();
6257
- * const header = await client.getTipHeader();
6258
- * console.log(`Block #${header.number}, hash: ${header.hash}`);
6259
- * ```
6260
- */
6261
- abstract getTipHeader(verbosity?: number | null): Promise<ClientBlockHeader>;
6262
- abstract getBlockByNumberNoCache(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
6263
- abstract getBlockByHashNoCache(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
6264
- abstract getHeaderByNumberNoCache(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
6265
- abstract getHeaderByHashNoCache(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
6266
- getBlockByNumber(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
6267
- getBlockByHash(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
6268
- getHeaderByNumber(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
6269
- getHeaderByHash(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
6270
- abstract estimateCycles(transaction: TransactionLike): Promise<Num>;
6271
- abstract sendTransactionDry(transaction: TransactionLike, validator?: OutputsValidator): Promise<Num>;
6272
- abstract sendTransactionNoCache(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
6273
- abstract getTransactionNoCache(txHash: HexLike): Promise<ClientTransactionResponse | undefined>;
6274
- /**
6275
- * Get a cell by its out point.
6276
- * The cell will be cached if it is found.
6277
- *
6278
- * @param outPointLike - The out point of the cell to get.
6279
- * @returns The cell if it exists, otherwise undefined.
6280
- *
6281
- * @example
6282
- * ```typescript
6283
- * import { ccc } from "@ckb-ccc/core";
6284
- *
6285
- * const client = new ccc.ClientPublicTestnet();
6286
- * const cell = await client.getCell({
6287
- * txHash: "0xTX_HASH...",
6288
- * index: 0,
6289
- * });
6290
- * if (cell) {
6291
- * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
6292
- * console.log(`Lock: ${cell.cellOutput.lock.codeHash}`);
6293
- * console.log(`Data: ${cell.outputData}`);
6294
- * }
6295
- * ```
6296
- */
6297
- getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
6298
- getCellWithHeader(outPointLike: OutPointLike): Promise<{
6299
- cell: Cell;
6300
- header?: ClientBlockHeader;
6301
- } | undefined>;
6302
- abstract getCellLiveNoCache(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
6303
- /**
6304
- * Get a live (unspent) cell by its out point.
6305
- * Unlike getCell(), this verifies the cell is still live on-chain.
6306
- *
6307
- * @param outPointLike - The out point of the cell.
6308
- * @param withData - Whether to include cell data.
6309
- * @param includeTxPool - Whether to include cells in the transaction pool.
6310
- * @returns The live cell, or undefined if spent or not found.
6311
- *
6312
- * @example
6313
- * ```typescript
6314
- * import { ccc } from "@ckb-ccc/core";
6315
- *
6316
- * const client = new ccc.ClientPublicTestnet();
6317
- * const cell = await client.getCellLive(
6318
- * { txHash: "0xTX_HASH...", index: 0 },
6319
- * true, // include data
6320
- * true, // include tx pool
6321
- * );
6322
- * if (cell) {
6323
- * console.log("Cell is still live!");
6324
- * } else {
6325
- * console.log("Cell has been spent or does not exist.");
6326
- * }
6327
- * ```
6328
- */
6329
- getCellLive(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
6330
- abstract findCellsPagedNoCache(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
6331
- /**
6332
- * Find cells with pagination support.
6333
- * Returns one page of results at a time with a cursor for the next page.
6334
- *
6335
- * @param key - The indexer search key.
6336
- * @param order - Sort order ("asc" or "desc").
6337
- * @param limit - Maximum cells per page.
6338
- * @param after - Cursor from previous page for pagination.
6339
- * @returns A page of cells with a cursor for the next page.
6340
- *
6341
- * @example
6342
- * ```typescript
6343
- * import { ccc } from "@ckb-ccc/core";
6344
- *
6345
- * const client = new ccc.ClientPublicTestnet();
6346
- * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
6347
- *
6348
- * // Get first page of cells
6349
- * const page1 = await client.findCellsPaged({
6350
- * script: lock,
6351
- * scriptType: "lock",
6352
- * }, "asc", 20);
6353
- * console.log(`Found ${page1.cells.length} cells`);
6354
- *
6355
- * // Get next page
6356
- * if (page1.cells.length === 20) {
6357
- * const page2 = await client.findCellsPaged(
6358
- * { script: lock, scriptType: "lock" },
6359
- * "asc", 20, page1.lastCursor,
6360
- * );
6361
- * }
6362
- * ```
6363
- */
6364
- findCellsPaged(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
6365
- findCellsOnChain(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
6366
- /**
6367
- * Find cells by search key designed for collectable cells.
6368
- * The result also includes cached cells, the order param only works for cells fetched from RPC.
6369
- *
6370
- * @param keyLike - The search key.
6371
- * @returns A async generator for yielding cells.
6372
- *
6373
- * @example
6374
- * ```typescript
6375
- * import { ccc } from "@ckb-ccc/core";
6376
- *
6377
- * const client = new ccc.ClientPublicTestnet();
6378
- * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
6379
- *
6380
- * // Find all cells owned by a lock script
6381
- * for await (const cell of client.findCells({
6382
- * script: lock,
6383
- * scriptType: "lock",
6384
- * scriptSearchMode: "exact",
6385
- * withData: true,
6386
- * })) {
6387
- * console.log(`Cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
6388
- * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
6389
- * }
6390
- * ```
6391
- */
6392
- findCells(keyLike: ClientCollectableSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
6393
- /**
6394
- * Find cells by lock script, optionally filtered by type script.
6395
- *
6396
- * @param lock - The lock script to search by.
6397
- * @param type - Optional type script filter.
6398
- * @param withData - Whether to include cell data (default: true).
6399
- * @param order - Sort order by block number ("asc" or "desc").
6400
- * @param limit - Page size for each RPC call (default: 10).
6401
- * @returns An async generator yielding matching cells.
6402
- *
6403
- * @example
6404
- * ```typescript
6405
- * import { ccc } from "@ckb-ccc/core";
6406
- *
6407
- * const client = new ccc.ClientPublicTestnet();
6408
- * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
6409
- *
6410
- * // Find all cells belonging to this address
6411
- * for await (const cell of client.findCellsByLock(lock)) {
6412
- * console.log(`${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
6413
- * }
6414
- *
6415
- * // Find only xUDT cells belonging to this address
6416
- * const xudtType = await ccc.Script.fromKnownScript(
6417
- * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
6418
- * );
6419
- * for await (const cell of client.findCellsByLock(lock, xudtType)) {
6420
- * console.log(`UDT cell found`);
6421
- * }
6422
- * ```
6423
- */
6424
- findCellsByLock(lock: ScriptLike, type?: ScriptLike | null, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
6425
- /**
6426
- * Find cells by type script.
6427
- *
6428
- * @param type - The type script to search by.
6429
- * @param withData - Whether to include cell data (default: true).
6430
- * @param order - Sort order by block number.
6431
- * @param limit - Page size for each RPC call (default: 10).
6432
- * @returns An async generator yielding matching cells.
6433
- *
6434
- * @example
6435
- * ```typescript
6436
- * import { ccc } from "@ckb-ccc/core";
6437
- *
6438
- * const client = new ccc.ClientPublicTestnet();
6439
- * // Find all xUDT cells of a specific token
6440
- * const xudtType = await ccc.Script.fromKnownScript(
6441
- * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
6442
- * );
6443
- * for await (const cell of client.findCellsByType(xudtType)) {
6444
- * console.log(`Token cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
6445
- * }
6446
- * ```
6918
+ * Get a known block header by hash
6919
+ * Implement this method to enable block headers query caching
6920
+ * @param _hash
6447
6921
  */
6448
- findCellsByType(type: ScriptLike, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
6449
- findSingletonCellByType(type: ScriptLike, withData?: boolean): Promise<Cell | undefined>;
6922
+ getHeaderByHash(_hash: HexLike): Promise<ClientBlockHeader | undefined>;
6450
6923
  /**
6451
- * Resolve cell dependency info into concrete CellDep objects.
6452
- * If a CellDepInfo specifies a type script, the actual deployed cell is located on-chain.
6453
- *
6454
- * @param cellDepsInfoLike - One or more CellDepInfo or arrays of CellDepInfo.
6455
- * @returns Resolved CellDep array ready to be added to a transaction.
6456
- *
6457
- * @example
6458
- * ```typescript
6459
- * import { ccc } from "@ckb-ccc/core";
6460
- *
6461
- * const client = new ccc.ClientPublicTestnet();
6462
- * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
6463
- * const cellDeps = await client.getCellDeps(xudtInfo.cellDeps);
6464
- * // cellDeps can be added to a transaction:
6465
- * // tx.cellDeps.push(...cellDeps);
6466
- * ```
6924
+ * Get a known block header by number
6925
+ * Implement this method to enable block headers query caching
6926
+ * @param _number
6467
6927
  */
6468
- getCellDeps(...cellDepsInfoLike: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<CellDep[]>;
6469
- abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
6470
- groupByTransaction: true;
6471
- }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsGroupedResponse>;
6472
- abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
6473
- groupByTransaction?: false | null;
6474
- }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse>;
6475
- abstract findTransactionsPaged(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse | ClientFindTransactionsGroupedResponse>;
6476
- findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
6477
- groupByTransaction: true;
6478
- }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
6479
- findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
6480
- groupByTransaction?: false | null;
6481
- }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
6482
- findTransactions(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
6928
+ getHeaderByNumber(_number: NumLike): Promise<ClientBlockHeader | undefined>;
6483
6929
  /**
6484
- * Find transactions related to a lock script, optionally filtered by type script.
6485
- *
6486
- * @param lock - The lock script to search by.
6487
- * @param type - Optional type script filter.
6488
- * @param groupByTransaction - If true, group results by transaction.
6489
- * @param order - Sort order by block number.
6490
- * @param limit - Page size per RPC call.
6491
- * @returns An async generator yielding transaction records.
6492
- *
6493
- * @example
6494
- * ```typescript
6495
- * import { ccc } from "@ckb-ccc/core";
6496
- *
6497
- * const client = new ccc.ClientPublicTestnet();
6498
- * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
6499
- *
6500
- * // List all transactions related to an address (grouped)
6501
- * for await (const txRecord of client.findTransactionsByLock(lock, null, true)) {
6502
- * console.log(`TX: ${txRecord.txHash}, Block: ${txRecord.blockNumber}`);
6503
- * }
6504
- * ```
6930
+ * Record known blocks.
6931
+ * Implement this method to enable blocks query caching
6932
+ * @param _blocks
6505
6933
  */
6506
- findTransactionsByLock(lock: ScriptLike, type: ScriptLike | undefined | null, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
6507
- findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
6508
- findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
6509
- findTransactionsByType(type: ScriptLike, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
6510
- findTransactionsByType(type: ScriptLike, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
6511
- findTransactionsByType(type: ScriptLike, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
6512
- abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
6934
+ recordBlocks(..._blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6513
6935
  /**
6514
- * Get the total CKB balance of a single lock script.
6515
- * Only counts cells with no type script and no data (pure CKB capacity cells).
6516
- *
6517
- * @param lock - The lock script to query balance for.
6518
- * @returns The total capacity in Shannons as a bigint.
6519
- *
6520
- * @example
6521
- * ```typescript
6522
- * import { ccc } from "@ckb-ccc/core";
6523
- *
6524
- * const client = new ccc.ClientPublicTestnet();
6525
- * const { script: lock } = await ccc.Address.fromString(
6526
- * "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq...",
6527
- * client,
6528
- * );
6529
- * const balance = await client.getBalanceSingle(lock);
6530
- * console.log(`Balance: ${ccc.fixedPointToString(balance)} CKB`);
6531
- * ```
6936
+ * Get a known block header by hash
6937
+ * Implement this method to enable block headers query caching
6938
+ * @param _hash
6532
6939
  */
6533
- getBalanceSingle(lock: ScriptLike): Promise<Num>;
6940
+ getBlockByHash(_hash: HexLike): Promise<ClientBlock | undefined>;
6534
6941
  /**
6535
- * Get the total CKB balance across multiple lock scripts.
6536
- * Sums the balance from each lock script.
6537
- *
6538
- * @param locks - An array of lock scripts to query.
6539
- * @returns The combined total capacity in Shannons as a bigint.
6540
- *
6541
- * @example
6542
- * ```typescript
6543
- * import { ccc } from "@ckb-ccc/core";
6544
- *
6545
- * const client = new ccc.ClientPublicTestnet();
6546
- * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
6547
- * await signer.connect();
6548
- *
6549
- * const locks = await signer.getRecommendedAddressObj()
6550
- * .then(({ script }) => [script]);
6551
- * const totalBalance = await client.getBalance(locks);
6552
- * console.log(`Total: ${ccc.fixedPointToString(totalBalance)} CKB`);
6553
- * ```
6942
+ * Get a known block header by number
6943
+ * Implement this method to enable block headers query caching
6944
+ * @param _number
6554
6945
  */
6555
- getBalance(locks: ScriptLike[]): Promise<Num>;
6946
+ getBlockByNumber(_number: NumLike): Promise<ClientBlock | undefined>;
6556
6947
  /**
6557
- * Send a signed transaction to the CKB network.
6558
- * Validates the fee rate against the maximum before sending.
6559
- *
6560
- * @param transaction - The transaction to send.
6561
- * @param validator - Optional outputs validator ("passthrough" or "well_known_scripts_only").
6562
- * @param options - Optional configuration including maxFeeRate.
6563
- * @returns The transaction hash.
6564
- *
6565
- * @example
6566
- * ```typescript
6567
- * import { ccc } from "@ckb-ccc/core";
6568
- *
6569
- * const client = new ccc.ClientPublicTestnet();
6570
- * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
6571
- * await signer.connect();
6572
- *
6573
- * const tx = ccc.Transaction.from({
6574
- * outputs: [{ capacity: ccc.fixedPointFrom(100), lock: receiverLock }],
6575
- * });
6576
- * await tx.completeInputsByCapacity(signer);
6577
- * await tx.completeFeeBy(signer);
6578
- *
6579
- * // Usually you call signer.sendTransaction(tx) which signs then sends.
6580
- * // client.sendTransaction expects an already-signed transaction.
6581
- * const txHash = await client.sendTransaction(tx);
6582
- * ```
6948
+ * Checks if a block header is considered confirmed.
6949
+ * The default implementation compares the header's timestamp against the current time
6950
+ * and a configured confirmation time. Override this method for custom confirmation logic.
6951
+ * @param header
6583
6952
  */
6584
- sendTransaction(transaction: TransactionLike, validator?: OutputsValidator, options?: {
6585
- maxFeeRate?: NumLike;
6586
- }): Promise<Hex>;
6953
+ hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6954
+ }
6955
+ //#endregion
6956
+ //#region src/client/cache/memory.d.ts
6957
+ declare class ClientCacheMemory extends ClientCache {
6958
+ private readonly maxCells;
6959
+ private readonly maxTxs;
6960
+ private readonly maxBlocks;
6587
6961
  /**
6588
- * Get a transaction by its hash, including its status and block info.
6589
- *
6590
- * @param txHashLike - The transaction hash to look up.
6591
- * @returns The transaction response with status, or undefined if not found.
6592
- *
6593
- * @example
6594
- * ```typescript
6595
- * import { ccc } from "@ckb-ccc/core";
6596
- *
6597
- * const client = new ccc.ClientPublicTestnet();
6598
- * const txResponse = await client.getTransaction("0xTX_HASH...");
6599
- * if (txResponse) {
6600
- * console.log(`Status: ${txResponse.status}`);
6601
- * console.log(`Block: ${txResponse.blockNumber}`);
6602
- * console.log(`Outputs: ${txResponse.transaction.outputs.length}`);
6603
- * }
6604
- * ```
6962
+ * OutPoint => [isLive, Cell | OutPoint]
6605
6963
  */
6606
- getTransaction(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
6964
+ private readonly cells;
6607
6965
  /**
6608
- * This method gets specified transaction with its block header (if existed).
6609
- * This is mainly for caching because we need the header to test if we can safely trust the cached tx status.
6610
- * @param txHashLike
6966
+ * TX Hash => Transaction Response
6611
6967
  */
6612
- getTransactionWithHeader(txHashLike: HexLike): Promise<{
6613
- transaction: ClientTransactionResponse;
6614
- header?: ClientBlockHeader;
6615
- } | undefined>;
6968
+ private readonly knownTransactions;
6616
6969
  /**
6617
- * Wait for a transaction to be confirmed on-chain.
6618
- * Polls the node until the transaction reaches the specified confirmation depth.
6619
- *
6620
- * @param txHash - The transaction hash to wait for.
6621
- * @param confirmations - Number of block confirmations to wait for (default: 0 = committed).
6622
- * @param timeout - Maximum wait time in milliseconds (default: 60000).
6623
- * @param interval - Polling interval in milliseconds (default: 2000).
6624
- * @returns The transaction response once confirmed, or throws on timeout.
6625
- *
6626
- * @example
6627
- * ```typescript
6628
- * import { ccc } from "@ckb-ccc/core";
6629
- *
6630
- * const client = new ccc.ClientPublicTestnet();
6631
- * // Wait for transaction to be committed (0 confirmations)
6632
- * const tx = await client.waitTransaction("0xTX_HASH...");
6633
- * console.log(`Confirmed in block: ${tx?.blockNumber}`);
6634
- *
6635
- * // Wait for 4 confirmations with 2 minute timeout
6636
- * const confirmedTx = await client.waitTransaction(
6637
- * "0xTX_HASH...",
6638
- * 4, // confirmations
6639
- * 120000, // timeout: 2 minutes
6640
- * );
6641
- * ```
6970
+ * Block Number => Block Hash
6642
6971
  */
6643
- waitTransaction(txHash: HexLike, confirmations?: number, timeout?: number, interval?: number): Promise<ClientTransactionResponse | undefined>;
6972
+ private readonly knownBlockHashes;
6973
+ /**
6974
+ * Block Hash => Block Header / Full Block
6975
+ */
6976
+ private readonly knownBlocks;
6977
+ private readonly confirmedBlockTime;
6978
+ /**
6979
+ * @param maxCells - Maximum number of cells to store in the cache. Defaults to 512.
6980
+ * @param maxTxs - Maximum number of transactions to store in the cache. Defaults to 256.
6981
+ * @param maxBlocks - Maximum number of blocks to store in the cache. Defaults to 128.
6982
+ * @param confirmedBlockTimeLike - Time in milliseconds after which a block is considered confirmed.
6983
+ * Defaults to DEFAULT_CONFIRMED_BLOCK_TIME (50 blocks * 10s).
6984
+ */
6985
+ constructor(maxCells?: number, maxTxs?: number, maxBlocks?: number, confirmedBlockTimeLike?: NumLike);
6986
+ markUsableNoCache(...cellLikes: (CellLike | CellLike[])[]): Promise<void>;
6987
+ markUnusable(...outPointLikes: (OutPointLike | OutPointLike[])[]): Promise<void>;
6988
+ clear(): Promise<void>;
6989
+ findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
6990
+ isUnusable(outPointLike: OutPointLike): Promise<boolean>;
6991
+ recordCells(...cells: (CellLike | CellLike[])[]): Promise<void>;
6992
+ getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
6993
+ recordTransactionResponses(...transactions: (ClientTransactionResponseLike | ClientTransactionResponseLike[])[]): Promise<void>;
6994
+ getTransactionResponse(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
6995
+ recordHeaders(...headers: (ClientBlockHeaderLike | ClientBlockHeaderLike[])[]): Promise<void>;
6996
+ getHeaderByHash(hashLike: HexLike): Promise<ClientBlockHeader | undefined>;
6997
+ getHeaderByNumber(numberLike: NumLike): Promise<ClientBlockHeader | undefined>;
6998
+ recordBlocks(...blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6999
+ getBlockByHash(hashLike: HexLike): Promise<ClientBlock | undefined>;
7000
+ getBlockByNumber(numberLike: NumLike): Promise<ClientBlock | undefined>;
7001
+ hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6644
7002
  }
6645
7003
  //#endregion
6646
7004
  //#region src/client/jsonRpc/client.d.ts
6647
- type ClientJsonRpcConfig = RequestorJsonRpcConfig & {
6648
- cache?: ClientCache;
7005
+ type ClientJsonRpcConfig = RequestorJsonRpcConfig & ClientConfig & {
7006
+ /**
7007
+ * @deprecated Requestor injection is supported only by legacy constructors.
7008
+ * Use a borrowed Transport with `Client.new` or let `Client.open` create one.
7009
+ */
6649
7010
  requestor?: RequestorJsonRpc;
6650
7011
  };
6651
7012
  /**
@@ -6653,18 +7014,26 @@ type ClientJsonRpcConfig = RequestorJsonRpcConfig & {
6653
7014
  * Provides methods for sending transactions and building JSON-RPC payloads.
6654
7015
  */
6655
7016
  declare abstract class ClientJsonRpc extends Client {
7017
+ private readonly url_;
6656
7018
  readonly requestor: RequestorJsonRpc;
6657
7019
  /**
6658
7020
  * Creates an instance of ClientJsonRpc.
6659
7021
  *
6660
7022
  * @param url_ - The URL of the JSON-RPC server.
6661
7023
  * @param timeout - The timeout for requests in milliseconds
7024
+ * @deprecated Use the concrete Client's `new` or `open` method.
6662
7025
  */
6663
7026
  constructor(url_: string, config?: ClientJsonRpcConfig);
7027
+ /** Creates a Requestor that borrows an existing Transport. */
7028
+ protected static newRequestor(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError">): RequestorJsonRpc;
7029
+ /** Opens a Requestor with ownership of its default Transport. */
7030
+ protected static openRequestor(config: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError">): Owner<RequestorJsonRpc>;
6664
7031
  /**
6665
- * Returns the URL of the JSON-RPC server.
7032
+ * Returns the legacy primary URL of the JSON-RPC server.
6666
7033
  *
6667
7034
  * @returns The URL of the JSON-RPC server.
7035
+ * @deprecated A Client may use multiple endpoints or a Transport without a
7036
+ * URL, so this value does not reliably identify its connection.
6668
7037
  */
6669
7038
  get url(): string;
6670
7039
  /**
@@ -6802,14 +7171,23 @@ declare abstract class ClientJsonRpc extends Client {
6802
7171
  * @public
6803
7172
  */
6804
7173
  declare class ClientPublicMainnet extends ClientJsonRpc {
6805
- private readonly config?;
6806
- constructor(config?: (ClientJsonRpcConfig & {
7174
+ private static defaultUrls;
7175
+ private static resolveConfig;
7176
+ /**
7177
+ * @deprecated Use {@link ClientPublicMainnet.new} with a borrowed Transport or
7178
+ * {@link ClientPublicMainnet.open} when creating Transports.
7179
+ */
7180
+ constructor(config?: ClientJsonRpcConfig & {
7181
+ /** @deprecated URL belongs to Transport construction. */
6807
7182
  url?: string;
6808
- scripts?: Record<KnownScript, ScriptInfoLike | undefined>;
6809
- }) | undefined);
6810
- get scripts(): Record<KnownScript, ScriptInfoLike | undefined>;
7183
+ });
7184
+ /** Creates a Client that borrows an existing Transport. */
7185
+ static new(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError"> & ClientConfig): ClientPublicMainnet;
7186
+ /** Opens a Client with explicit ownership of its default dependencies. */
7187
+ static open(config?: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError" | "urls"> & ClientConfig & {
7188
+ urls?: Parameters<typeof RequestorJsonRpc.open>[0]["urls"];
7189
+ }): Owner<ClientPublicMainnet>;
6811
7190
  get addressPrefix(): string;
6812
- getKnownScript(script: KnownScript): Promise<ScriptInfo>;
6813
7191
  }
6814
7192
  //#endregion
6815
7193
  //#region src/client/clientPublicTestnet.d.ts
@@ -6817,14 +7195,23 @@ declare class ClientPublicMainnet extends ClientJsonRpc {
6817
7195
  * @public
6818
7196
  */
6819
7197
  declare class ClientPublicTestnet extends ClientJsonRpc {
6820
- private readonly config?;
6821
- constructor(config?: (ClientJsonRpcConfig & {
7198
+ private static defaultUrls;
7199
+ private static resolveConfig;
7200
+ /**
7201
+ * @deprecated Use {@link ClientPublicTestnet.new} with a borrowed Transport or
7202
+ * {@link ClientPublicTestnet.open} when creating Transports.
7203
+ */
7204
+ constructor(config?: ClientJsonRpcConfig & {
7205
+ /** @deprecated URL belongs to Transport construction. */
6822
7206
  url?: string;
6823
- scripts?: Record<KnownScript, ScriptInfoLike | undefined>;
6824
- }) | undefined);
6825
- get scripts(): Record<KnownScript, ScriptInfoLike | undefined>;
7207
+ });
7208
+ /** Creates a Client that borrows an existing Transport. */
7209
+ static new(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError"> & ClientConfig): ClientPublicTestnet;
7210
+ /** Opens a Client with explicit ownership of its default dependencies. */
7211
+ static open(config?: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError" | "urls"> & ClientConfig & {
7212
+ urls?: Parameters<typeof RequestorJsonRpc.open>[0]["urls"];
7213
+ }): Owner<ClientPublicTestnet>;
6826
7214
  get addressPrefix(): string;
6827
- getKnownScript(script: KnownScript): Promise<ScriptInfo>;
6828
7215
  }
6829
7216
  //#endregion
6830
7217
  //#region src/address/address.advanced.d.ts
@@ -7103,9 +7490,14 @@ declare class JsonRpcTransformers {
7103
7490
  //#endregion
7104
7491
  //#region src/hasher/advanced.d.ts
7105
7492
  declare const CKB_BLAKE2B_PERSONAL: Bytes$1;
7493
+ //#endregion
7494
+ //#region src/jsonRpc/transports/factory.d.ts
7495
+ declare function jsonRpcTransportFromUri(uri: string, config?: {
7496
+ timeout?: number;
7497
+ }): OwnerUnique<JsonRpcTransportWebSocket> | OwnerUnique<JsonRpcTransportHttp>;
7106
7498
  declare namespace advancedBarrel_d_exports {
7107
- export { ADDRESS_BECH32_LIMIT, AddressFormat, BytesFromEncoding, CKB_BLAKE2B_PERSONAL, CellRecord, ClientCollectableSearchKeyFilterLike, ClientCollectableSearchKeyLike, DEFAULT_CONFIRMED_BLOCK_TIME, DEFAULT_MAX_FEE_RATE, DEFAULT_MIN_FEE_RATE, DEP_TYPES, DEP_TYPE_TO_NUM, HASH_TYPES, HASH_TYPE_TO_NUM, JsonRpcBlock, JsonRpcBlockHeader, JsonRpcBlockUncle, JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerFindTransactionsGroupedResponse, JsonRpcIndexerFindTransactionsResponse, JsonRpcIndexerSearchKey, JsonRpcIndexerSearchKeyFilter, JsonRpcIndexerSearchKeyTransaction, JsonRpcOutPoint, JsonRpcPayload, JsonRpcScript, JsonRpcTransaction, JsonRpcTransformers, MAINNET_SCRIPTS, MapLru, NUM_TO_DEP_TYPE, NUM_TO_HASH_TYPE, TESTNET_SCRIPTS, Transport, TransportFallback, TransportHttp, TransportWebSocket, addressFromPayload, addressPayloadFromString, clientSearchKeyRangeFrom, filterCell, filterData, filterNumByRange, filterScript, filterScriptByLenRange, transportFromUri };
7499
+ export { ADDRESS_BECH32_LIMIT, AddressFormat, BytesFromEncoding, CKB_BLAKE2B_PERSONAL, CellRecord, ClientCollectableSearchKeyFilterLike, ClientCollectableSearchKeyLike, DEFAULT_CONFIRMED_BLOCK_TIME, DEFAULT_MAX_FEE_RATE, DEFAULT_MIN_FEE_RATE, DEP_TYPES, DEP_TYPE_TO_NUM, HASH_TYPES, HASH_TYPE_TO_NUM, JsonRpcBlock, JsonRpcBlockHeader, JsonRpcBlockUncle, JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcIndexerFindTransactionsGroupedResponse, JsonRpcIndexerFindTransactionsResponse, JsonRpcIndexerSearchKey, JsonRpcIndexerSearchKeyFilter, JsonRpcIndexerSearchKeyTransaction, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction, JsonRpcTransformers, MAINNET_SCRIPTS, MapLru, NUM_TO_DEP_TYPE, NUM_TO_HASH_TYPE, SignerJsonRpcInfo, SignerJsonRpcInfoPayload, SignerJsonRpcMessageToSign, SignerJsonRpcTransformers, TESTNET_SCRIPTS, addressFromPayload, addressPayloadFromString, clientSearchKeyRangeFrom, filterCell, filterData, filterNumByRange, filterScript, filterScriptByLenRange, jsonRpcTransportFromUri };
7108
7500
  }
7109
7501
  //#endregion
7110
- export { CellDep as $, DecodedType as $i, SignerCkbPublicKey as $n, CodecByte as $r, ClientFindCellsResponse as $t, DEP_TYPES as A, apply as Ai, verifyMessageNostrEvent as An, keystoreEncrypt as Ar, HashTypeCodec as At, ClientPublicTestnet as B, NumLike as Bi, SignerDummy as Bn, HASH_CKB_LENGTH as Br, Epoch as Bt, DEFAULT_CONFIRMED_BLOCK_TIME as C, CodecUint64LE as Ci, ClientCollectableSearchKeyLike as Cn, Wallet as Cr, depTypeFrom as Ct, filterNumByRange as D, codecUintNumber as Di, barrel_d_exports as Dn, SignPsbtOptionsLike as Dr, udtBalanceFrom as Dt, filterData as E, codecUint as Ei, clientSearchKeyRangeFrom as En, SignPsbtOptions as Er, isDaoOutputLimitExceeded as Et, NUM_TO_HASH_TYPE as F, stringify as Fi, verifyMessageEvmPersonal as Fn, TransportWebSocket as Fr, ScriptVec as Ft, ClientCacheMemory as G, numLeFromBytes as Gi, SignerDoge as Gn, Hasher as Gr, CellDepInfo as Gt, ClientJsonRpc as H, numBeToBytes as Hi, verifyMessageDogeEcdsa as Hn, HasherCkb as Hr, epochFrom as Ht, ADDRESS_BECH32_LIMIT as I, Proxy as Ii, SignerEvmAddressReadonly as In, TransportHttp as Ir, hashTypeFrom as It, ErrorTransactionInsufficientCoin as J, numMin as Ji, MultisigCkbWitness as Jn, One as Jr, ClientBlockHeader as Jt, ClientCache as K, numLeToBytes as Ki, verifyMessageJoyId as Kn, FixedPoint as Kr, CellDepInfoLike as Kt, AddressFormat as L, AbstractConstructor as Li, SignerEvm as Ln, JsonRpcPayload as Lr, hashTypeFromBytes as Lt, NUM_TO_DEP_TYPE as M, isWebview as Mi, SignerNostrPublicKeyReadonly as Mn, RequestorJsonRpcConfig as Mr, Script as Mt, HASH_TYPES as N, reduceAsync as Ni, NostrEvent as Nn, TransportFallback as Nr, ScriptLike as Nt, filterScript as O, Entity as Oi, buildNostrEventFromMessage as On, barrel_d_exports$1 as Or, LumosTransactionSkeletonType as Ot, HASH_TYPE_TO_NUM as P, sleep as Pi, SignerNostr as Pn, transportFromUri as Pr, ScriptOpt as Pt, CellAnyLike as Q, CodecLike as Qi, SignerCkbPrivateKey as Qn, CodecBool as Qr, ClientBlockUncleLike as Qt, addressFromPayload as R, Constructor as Ri, SignerOpenLink as Rn, Transport as Rr, hashTypeToBytes as Rt, CellRecord as S, CodecUint64BE as Si, ClientCollectableSearchKeyFilterLike as Sn, SignerType as Sr, calcDaoProfit as St, filterCell as T, codecPadding as Ti, DEFAULT_MIN_FEE_RATE as Tn, InputToSignLike as Tr, depTypeToBytes as Tt, ClientJsonRpcConfig as U, numFrom as Ui, SignerDogePrivateKey as Un, hashCkb as Ur, epochFromHex as Ut, ClientPublicMainnet as V, numBeFromBytes as Vi, messageHashDogeEcdsa as Vn, HASH_CKB_SHORT_LENGTH as Vr, EpochLike as Vt, Client as W, numFromBytes as Wi, SignerDogeAddressReadonly as Wn, hashCkbShort as Wr, epochToHex as Wt, Cell as X, numToHex as Xi, SignerMultisigCkbReadonly as Xn, fixedPointFrom as Xr, ClientBlockLike as Xt, hashTypeId as Y, numToBytes as Yi, MultisigCkbWitnessLike as Yn, Zero as Yr, ClientBlockHeaderLike as Yt, CellAny as Z, Codec as Zi, SignerCkbScriptReadonly as Zn, fixedPointToString as Zr, ClientBlockUncle as Zt, JsonRpcOutPoint as _, CodecUint32LE as _i, ErrorClientWaitTransactionTimeout as _n, Signer as _r, Transaction as _t, JsonRpcBlockHeader as a, bytesLen as aa, CodecRaw as ai, ClientIndexerSearchKeyLike as an, verifyMessageCkbSecp256k1 as ar, CellLike as at, TESTNET_SCRIPTS as b, CodecUint512LE as bi, ScriptInfoLike as bn, SignerMultisigNotEnoughSignaturesError as br, WitnessArgsLike as bt, JsonRpcCellInput as c, Bytes$1 as ca, CodecUint128LE as ci, ClientTransactionResponse as cn, btcP2pkhAddressFromPublicKey as cr, CellOutputVec as ct, JsonRpcHashType as d, bytesConcatTo as da, CodecUint16LE as di, ErrorClientBaseLike as dn, messageHashBtcEcdsa as dr, DepTypeLike as dt, EncodableType as ea, CodecByte16 as ei, ClientFindTransactionsGroupedResponse as en, SignerCkbAlwaysSuccess as er, CellDepLike as et, JsonRpcIndexerFindTransactionsGroupedResponse as f, bytesEq as fa, CodecUint256 as fi, ErrorClientDuplicatedTransaction as fn, verifyMessageBtcEcdsa as fr, OutPoint as ft, JsonRpcIndexerSearchKeyTransaction as g, CodecUint32BE as gi, ErrorClientVerification as gn, Signature as gr, SinceLike as gt, JsonRpcIndexerSearchKeyFilter as h, BytesFromEncoding as ha, CodecUint32 as hi, ErrorClientResolveUnknown as hn, NetworkPreference as hr, Since as ht, JsonRpcBlock as i, HexLike as ia, CodecBytes as ii, ClientIndexerSearchKeyFilterLike as in, signMessageSecp256k1 as ir, CellInputVec as it, DEP_TYPE_TO_NUM as j, gcd as ji, SignerNostrPrivateKey as jn, RequestorJsonRpc as jr, HashTypeLike as jt, filterScriptByLenRange as k, codec as ki, nostrEventHash as kn, keystoreDecrypt as kr, HashType as kt, JsonRpcCellOutput as l, BytesLike as la, CodecUint16 as li, ClientTransactionResponseLike as ln, btcPublicKeyFromP2pkhAddress as lr, DepType as lt, JsonRpcIndexerSearchKey as m, bytesTo as ma, CodecUint256LE as mi, ErrorClientRBFRejected as mn, SignerBtc as mr, RawTransaction as mt, CKB_BLAKE2B_PERSONAL as n, AddressLike as na, CodecByte4 as ni, ClientIndexerSearchKey as nn, messageHashCkbSecp256k1 as nr, CellInput as nt, JsonRpcBlockUncle as o, bytesLenUnsafe as oa, CodecUint128 as oi, ClientIndexerSearchKeyTransaction as on, verifyMessageSecp256k1 as or, CellOutput as ot, JsonRpcIndexerFindTransactionsResponse as p, bytesFrom as pa, CodecUint256BE as pi, ErrorClientMaxFeeRateExceeded as pn, SignerBtcPublicKeyReadonly as pr, OutPointLike as pt, ErrorTransactionInsufficientCapacity as q, numMax as qi, SignerMultisigCkbPrivateKey as qn, FixedPointLike as qr, ClientBlock as qt, JsonRpcTransformers as r, Hex as ra, CodecByte8 as ri, ClientIndexerSearchKeyFilter as rn, recoverMessageSecp256k1 as rr, CellInputLike as rt, JsonRpcCellDep as s, hexFrom as sa, CodecUint128BE as si, ClientIndexerSearchKeyTransactionLike as sn, btcEcdsaPublicKeyHash as sr, CellOutputLike as st, advancedBarrel_d_exports as t, Address as ta, CodecByte32 as ti, ClientFindTransactionsResponse as tn, SECP256K1_SIGNATURE_LENGTH as tr, CellDepVec as tt, JsonRpcDepType as u, bytesConcat as ua, CodecUint16BE as ui, ErrorClientBase as un, btcVarLengthBytesFrom as ur, DepTypeCodec as ut, JsonRpcScript as v, CodecUint512 as vi, OutputsValidator as vn, SignerInfo as vr, TransactionLike as vt, MapLru as w, CodecUint8 as wi, DEFAULT_MAX_FEE_RATE as wn, InputToSign as wr, depTypeFromBytes as wt, MAINNET_SCRIPTS as x, CodecUint64 as xi, TransactionStatus as xn, SignerSignType as xr, calcDaoClaimEpoch as xt, JsonRpcTransaction as y, CodecUint512BE as yi, ScriptInfo as yn, SignerMultisig as yr, WitnessArgs as yt, addressPayloadFromString as z, Num as zi, SignerAlwaysError as zn, HasherKeecak256 as zr, KnownScript as zt };
7111
- //# sourceMappingURL=advancedBarrel-BwJIDnvL.d.mts.map
7502
+ export { CellDep as $, OwnerRefCount as $i, messageHashDogeEcdsa as $n, JsonRpcTransport as $r, ClientBlockUncle as $t, filterScriptByLenRange as A, BytesLike as Aa, CodecUint32 as Ai, buildNostrEventFromMessage as An, SignerInfo as Ar, HashTypeCodec as At, addressPayloadFromString as B, codecPadding as Bi, SignerJsonRpcHandler as Bn, barrel_d_exports$1 as Br, ClientConfig as Bt, CellRecord as C, AddressLike as Ca, CodecUint128LE as Ci, TransactionStatus as Cn, messageHashBtcEcdsa as Cr, depTypeFrom as Ct, filterData as D, bytesLenUnsafe as Da, CodecUint256 as Di, DEFAULT_MIN_FEE_RATE as Dn, NetworkPreference as Dr, udtBalanceFrom as Dt, filterCell as E, bytesLen as Ea, CodecUint16LE as Ei, DEFAULT_MAX_FEE_RATE as En, SignerBtc as Er, isDaoOutputLimitExceeded as Et, HASH_TYPE_TO_NUM as F, bytesTo as Fa, CodecUint512LE as Fi, NostrEvent as Fn, Wallet as Fr, ScriptVec as Ft, ClientCacheMemory as G, apply as Gi, SignerJsonRpcMessageToSign as Gn, JsonRpcTransportWebSocket as Gr, epochFromHex as Gt, ClientPublicMainnet as H, codecUintNumber as Hi, buildSignerJsonRpcHandler as Hn, keystoreEncrypt as Hr, Epoch as Ht, NUM_TO_HASH_TYPE as I, BytesFromEncoding as Ia, CodecUint64 as Ii, SignerNostr as In, InputToSign as Ir, hashTypeFrom as It, ErrorTransactionInsufficientCoin as J, reduceAsync as Ji, SignerEvmAddressReadonly as Jn, JsonRpcError as Jr, CellDepInfoLike as Jt, ClientCache as K, gcd as Ki, SignerJsonRpcTransformers as Kn, JsonRpcTransportHttp as Kr, epochToHex as Kt, ADDRESS_BECH32_LIMIT as L, CodecUint64BE as Li, SignerJsonRpc as Ln, InputToSignLike as Lr, hashTypeFromBytes as Lt, DEP_TYPE_TO_NUM as M, bytesConcatTo as Ma, CodecUint32LE as Mi, verifyMessageNostrEvent as Mn, SignerMultisigNotEnoughSignaturesError as Mr, Script as Mt, NUM_TO_DEP_TYPE as N, bytesEq as Na, CodecUint512 as Ni, SignerNostrPrivateKey as Nn, SignerSignType as Nr, ScriptLike as Nt, filterNumByRange as O, hexFrom as Oa, CodecUint256BE as Oi, clientSearchKeyRangeFrom as On, Signature as Or, LumosTransactionSkeletonType as Ot, HASH_TYPES as P, bytesFrom as Pa, CodecUint512BE as Pi, SignerNostrPublicKeyReadonly as Pn, SignerType as Pr, ScriptOpt as Pt, CellAnyLike as Q, OwnerUnique as Qi, SignerDummy as Qn, JsonRpcResponse as Qr, ClientBlockLike as Qt, AddressFormat as R, CodecUint64LE as Ri, SignerJsonRpcConfig as Rn, SignPsbtOptions as Rr, hashTypeToBytes as Rt, MAINNET_SCRIPTS as S, Address as Sa, CodecUint128BE as Si, ScriptInfoLike as Sn, btcVarLengthBytesFrom as Sr, calcDaoProfit as St, MapLru as T, HexLike as Ta, CodecUint16BE as Ti, ClientCollectableSearchKeyLike as Tn, SignerBtcPublicKeyReadonly as Tr, depTypeToBytes as Tt, ClientJsonRpc as U, Entity as Ui, SignerJsonRpcInfo as Un, RequestorJsonRpc as Ur, EpochLike as Ut, ClientPublicTestnet as V, codecUint as Vi, SignerJsonRpcHandlerConfig as Vn, keystoreDecrypt as Vr, KnownScript as Vt, ClientJsonRpcConfig as W, codec as Wi, SignerJsonRpcInfoPayload as Wn, RequestorJsonRpcConfig as Wr, epochFrom as Wt, Cell as X, stringify as Xi, SignerOpenLink as Xn, JsonRpcId as Xr, ClientBlockHeader as Xt, hashTypeId as Y, sleep as Yi, SignerEvm as Yn, JsonRpcErrorLike as Yr, ClientBlock as Yt, CellAny as Z, Proxy as Zi, SignerAlwaysError as Zn, JsonRpcPayload as Zr, ClientBlockHeaderLike as Zt, JsonRpcIndexerSearchKeyTransaction as _, numToHex as _a, CodecByte4 as _i, ErrorClientResolveUnknown as _n, verifyMessageCkbSecp256k1 as _r, Transaction as _t, JsonRpcBlock as a, abortSignalAny as aa, hashCkbShort as ai, ClientIndexerSearchKeyFilter as an, SignerMultisigCkbPrivateKey as ar, CellLike as at, JsonRpcTransaction as b, DecodedType as ba, CodecRaw as bi, OutputsValidator as bn, btcP2pkhAddressFromPublicKey as br, WitnessArgsLike as bt, JsonRpcCellDep as c, numBeFromBytes as ca, FixedPointLike as ci, ClientIndexerSearchKeyTransaction as cn, SignerMultisigCkbReadonly as cr, CellOutputVec as ct, JsonRpcDepType as d, numFromBytes as da, fixedPointFrom as di, ClientTransactionResponseLike as dn, SignerCkbPublicKey as dr, DepTypeLike as dt, OwnerAggregated as ea, HasherKeecak256 as ei, ClientBlockUncleLike as en, verifyMessageDogeEcdsa as er, CellDepLike as et, JsonRpcHashType as f, numLeFromBytes as fa, fixedPointToString as fi, ErrorClientBase as fn, SignerCkbAlwaysSuccess as fr, OutPoint as ft, JsonRpcIndexerSearchKeyFilter as g, numToBytes as ga, CodecByte32 as gi, ErrorClientRBFRejected as gn, signMessageSecp256k1 as gr, SinceLike as gt, JsonRpcIndexerSearchKey as h, numMin as ha, CodecByte16 as hi, ErrorClientMaxFeeRateExceeded as hn, recoverMessageSecp256k1 as hr, Since as ht, JsonRpcTransformers as i, Constructor as ia, hashCkb as ii, ClientIndexerSearchKey as in, verifyMessageJoyId as ir, CellInputVec as it, DEP_TYPES as j, bytesConcat as ja, CodecUint32BE as ji, nostrEventHash as jn, SignerMultisig as jr, HashTypeLike as jt, filterScript as k, Bytes$1 as ka, CodecUint256LE as ki, barrel_d_exports as kn, Signer as kr, HashType as kt, JsonRpcCellInput as l, numBeToBytes as la, One as li, ClientIndexerSearchKeyTransactionLike as ln, SignerCkbScriptReadonly as lr, DepType as lt, JsonRpcIndexerFindTransactionsResponse as m, numMax as ma, CodecByte as mi, ErrorClientDuplicatedTransaction as mn, messageHashCkbSecp256k1 as mr, RawTransaction as mt, jsonRpcTransportFromUri as n, OwnerMoved as na, HASH_CKB_SHORT_LENGTH as ni, ClientFindTransactionsGroupedResponse as nn, SignerDogeAddressReadonly as nr, CellInput as nt, JsonRpcBlockHeader as o, Num as oa, Hasher as oi, ClientIndexerSearchKeyFilterLike as on, MultisigCkbWitness as or, CellOutput as ot, JsonRpcIndexerFindTransactionsGroupedResponse as p, numLeToBytes as pa, CodecBool as pi, ErrorClientBaseLike as pn, SECP256K1_SIGNATURE_LENGTH as pr, OutPointLike as pt, ErrorTransactionInsufficientCapacity as q, isWebview as qi, verifyMessageEvmPersonal as qn, JsonRpcTransportFallback as qr, CellDepInfo as qt, CKB_BLAKE2B_PERSONAL as r, AbstractConstructor as ra, HasherCkb as ri, ClientFindTransactionsResponse as rn, SignerDoge as rr, CellInputLike as rt, JsonRpcBlockUncle as s, NumLike as sa, FixedPoint as si, ClientIndexerSearchKeyLike as sn, MultisigCkbWitnessLike as sr, CellOutputLike as st, advancedBarrel_d_exports as t, Owner as ta, HASH_CKB_LENGTH as ti, ClientFindCellsResponse as tn, SignerDogePrivateKey as tr, CellDepVec as tt, JsonRpcCellOutput as u, numFrom as ua, Zero as ui, ClientTransactionResponse as un, SignerCkbPrivateKey as ur, DepTypeCodec as ut, JsonRpcOutPoint as v, Codec as va, CodecByte8 as vi, ErrorClientVerification as vn, verifyMessageSecp256k1 as vr, TransactionLike as vt, DEFAULT_CONFIRMED_BLOCK_TIME as w, Hex as wa, CodecUint16 as wi, ClientCollectableSearchKeyFilterLike as wn, verifyMessageBtcEcdsa as wr, depTypeFromBytes as wt, TESTNET_SCRIPTS as x, EncodableType as xa, CodecUint128 as xi, ScriptInfo as xn, btcPublicKeyFromP2pkhAddress as xr, calcDaoClaimEpoch as xt, JsonRpcScript as y, CodecLike as ya, CodecBytes as yi, ErrorClientWaitTransactionTimeout as yn, btcEcdsaPublicKeyHash as yr, WitnessArgs as yt, addressFromPayload as z, CodecUint8 as zi, SignerJsonRpcConfirmation as zn, SignPsbtOptionsLike as zr, Client as zt };
7503
+ //# sourceMappingURL=advancedBarrel-B57gAzdK.d.ts.map