@ckb-ccc/core 1.19.1 → 1.20.0

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