@ckb-ccc/core 1.19.1 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/advanced.d.mts +2 -2
  3. package/dist/advanced.mjs +1 -1
  4. package/{dist.commonjs/advancedBarrel-CSQ2SmeJ.d.ts → dist/advancedBarrel-Di0YBlWc.d.mts} +2029 -1639
  5. package/dist/advancedBarrel-Di0YBlWc.d.mts.map +1 -0
  6. package/dist/advancedBarrel.d.mts +2 -2
  7. package/dist/advancedBarrel.mjs +1 -1
  8. package/dist/advancedBarrel.mjs.map +1 -1
  9. package/dist/barrel-G6e8gZrB.mjs +7 -0
  10. package/dist/barrel-G6e8gZrB.mjs.map +1 -0
  11. package/dist/barrel.d.mts +2 -2
  12. package/dist/barrel.mjs +1 -1
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.mjs +1 -1
  15. package/dist/transformers-DxPrDQko.mjs +2 -0
  16. package/dist/transformers-DxPrDQko.mjs.map +1 -0
  17. package/dist.commonjs/advanced.d.ts +2 -2
  18. package/dist.commonjs/advanced.js +1 -1
  19. package/{dist/advancedBarrel-BwJIDnvL.d.mts → dist.commonjs/advancedBarrel-B57gAzdK.d.ts} +2030 -1638
  20. package/dist.commonjs/advancedBarrel-B57gAzdK.d.ts.map +1 -0
  21. package/dist.commonjs/advancedBarrel.d.ts +2 -2
  22. package/dist.commonjs/advancedBarrel.js +1 -1
  23. package/dist.commonjs/advancedBarrel.js.map +1 -1
  24. package/dist.commonjs/barrel-BOCFtFjq.js +23 -0
  25. package/dist.commonjs/barrel-BOCFtFjq.js.map +1 -0
  26. package/dist.commonjs/barrel.d.ts +2 -2
  27. package/dist.commonjs/barrel.js +1 -1
  28. package/dist.commonjs/index.d.ts +2 -2
  29. package/dist.commonjs/index.js +1 -1
  30. package/dist.commonjs/{rolldown-runtime-DWNI8pZO.js → rolldown-runtime-Chgba0Kb.js} +1 -1
  31. package/dist.commonjs/transformers-0FqvcPy2.js +2 -0
  32. package/dist.commonjs/transformers-0FqvcPy2.js.map +1 -0
  33. package/package.json +8 -7
  34. package/src/advancedBarrel.ts +1 -0
  35. package/src/bytes/advanced.ts +1 -6
  36. package/src/bytes/index.ts +37 -10
  37. package/src/ckb/transaction.ts +7 -5
  38. package/src/client/client.ts +75 -19
  39. package/src/client/clientPublicMainnet.ts +75 -36
  40. package/src/client/clientPublicTestnet.ts +75 -36
  41. package/src/client/jsonRpc/client.ts +77 -30
  42. package/src/client/jsonRpc/transformers.ts +4 -4
  43. package/src/jsonRpc/index.ts +1 -0
  44. package/src/jsonRpc/requestor.ts +74 -21
  45. package/src/jsonRpc/transports/advanced.ts +0 -4
  46. package/src/jsonRpc/transports/factory.ts +12 -5
  47. package/src/jsonRpc/transports/fallback.ts +9 -5
  48. package/src/jsonRpc/transports/http.ts +21 -17
  49. package/src/jsonRpc/transports/index.ts +4 -0
  50. package/src/jsonRpc/transports/transport.ts +32 -6
  51. package/src/jsonRpc/transports/webSocket.ts +67 -20
  52. package/src/keystore/index.ts +3 -3
  53. package/src/molecule/codec.ts +20 -17
  54. package/src/signer/advanced.ts +1 -0
  55. package/src/signer/btc/verify.ts +2 -2
  56. package/src/signer/ckb/secp256k1Signing.ts +3 -3
  57. package/src/signer/doge/signerDoge.ts +1 -1
  58. package/src/signer/doge/signerDogePrivateKey.ts +1 -1
  59. package/src/signer/index.ts +1 -0
  60. package/src/signer/jsonRpc/handler.ts +217 -0
  61. package/src/signer/jsonRpc/index.ts +2 -0
  62. package/src/signer/jsonRpc/network.ts +15 -0
  63. package/src/signer/jsonRpc/signer.ts +234 -0
  64. package/src/signer/jsonRpc/transformers.ts +67 -0
  65. package/src/utils/abortSignal.ts +42 -0
  66. package/src/utils/index.ts +2 -0
  67. package/src/utils/owner/aggregated.ts +56 -0
  68. package/src/utils/owner/index.ts +4 -0
  69. package/src/utils/owner/owner.ts +141 -0
  70. package/src/utils/owner/refCount.ts +78 -0
  71. package/src/utils/owner/unique.ts +30 -0
  72. package/tsdown.config.mts +1 -0
  73. package/dist/address.advanced-Cka_9tcR.mjs +0 -2
  74. package/dist/address.advanced-Cka_9tcR.mjs.map +0 -1
  75. package/dist/advancedBarrel-BwJIDnvL.d.mts.map +0 -1
  76. package/dist/barrel-DsK2p-Rh.mjs +0 -7
  77. package/dist/barrel-DsK2p-Rh.mjs.map +0 -1
  78. package/dist.commonjs/address.advanced-BTrmYDic.js +0 -2
  79. package/dist.commonjs/address.advanced-BTrmYDic.js.map +0 -1
  80. package/dist.commonjs/advancedBarrel-CSQ2SmeJ.d.ts.map +0 -1
  81. package/dist.commonjs/barrel-D8_wJLfr.js +0 -23
  82. package/dist.commonjs/barrel-D8_wJLfr.js.map +0 -1
@@ -1,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,94 @@ 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 scriptsPromise?;
3163
+ private internalAddressPromise?;
3164
+ private identityPromise?;
3165
+ private readonly replacedListeners;
3166
+ private constructor();
3167
+ /** Creates a Signer that borrows an existing Transport. */
3168
+ static new(client: Client, config: SignerJsonRpcConfig): Promise<SignerJsonRpc>;
3169
+ get type(): SignerType;
3170
+ get signType(): SignerSignType;
3171
+ get url(): string;
3172
+ get name(): string | undefined;
3173
+ get icon(): string | undefined;
3174
+ connect(): Promise<void>;
3175
+ disconnect(): Promise<void>;
3176
+ onReplaced(listener: () => void): () => boolean;
3177
+ replace(): void;
3178
+ isConnected(): Promise<boolean>;
3179
+ getScripts(): Promise<Script[]>;
3180
+ getAddressObjs(): Promise<Address[]>;
3181
+ getInternalAddress(): Promise<string>;
3182
+ getIdentity(): Promise<string>;
3183
+ signMessageRaw: Signer["signMessageRaw"];
3184
+ prepareTransaction: Signer["prepareTransaction"];
3185
+ signOnlyTransaction: Signer["signOnlyTransaction"];
3186
+ buildSender(rpcMethod: Parameters<RequestorJsonRpc["request"]>[0], inTransformers?: Parameters<RequestorJsonRpc["request"]>[2], outTransformer?: Parameters<RequestorJsonRpc["request"]>[3]): (...request: unknown[]) => Promise<unknown>;
3187
+ private clearReadCache;
3188
+ private requestConnect;
3189
+ }
3190
+ //#endregion
2878
3191
  //#region src/signer/nostr/signerNostr.d.ts
2879
3192
  /**
2880
3193
  * @public
@@ -2975,7 +3288,7 @@ declare function buildNostrEventFromMessage(message: string | BytesLike): NostrE
2975
3288
  declare function nostrEventHash(event: NostrEvent): Bytes$1;
2976
3289
  declare function verifyMessageNostrEvent(message: string | BytesLike, signature: string, address: string): boolean;
2977
3290
  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 };
3291
+ 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
3292
  }
2980
3293
  //#endregion
2981
3294
  //#region src/client/clientTypes.advanced.d.ts
@@ -3728,830 +4041,599 @@ declare enum KnownScript {
3728
4041
  TimeLock = "TimeLock"
3729
4042
  }
3730
4043
  //#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;
4044
+ //#region src/client/client.d.ts
4045
+ type ClientConfig = {
4046
+ cache?: ClientCache;
4047
+ scripts?: Partial<Record<KnownScript, ScriptInfoLike>>;
4048
+ };
3785
4049
  /**
3786
4050
  * @public
3787
4051
  */
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;
4052
+ declare abstract class Client {
4053
+ cache: ClientCache;
4054
+ private readonly scripts;
4055
+ constructor(config?: ClientConfig);
3885
4056
  /**
3886
- * Creates an instance of Script.
4057
+ * The legacy primary URL associated with this Client.
3887
4058
  *
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.
4059
+ * @deprecated A Client may use multiple endpoints or a Transport without a
4060
+ * URL, so this value does not reliably identify its connection.
3891
4061
  */
3892
- constructor(codeHash: Hex, hashType: HashType, args: Hex);
3893
- get occupiedSize(): number;
4062
+ abstract get url(): string;
4063
+ abstract get addressPrefix(): string;
3894
4064
  /**
3895
- * Clone a script.
4065
+ * Get the deployment info for a well-known CKB script.
4066
+ * Returns the cell deps and type script info needed to use the script.
3896
4067
  *
3897
- * @returns A cloned Script instance.
4068
+ * @param script - The KnownScript enum value.
4069
+ * @returns Script info including cellDeps and type hash.
3898
4070
  *
3899
4071
  * @example
3900
4072
  * ```typescript
3901
- * const script1 = script0.clone();
4073
+ * import { ccc } from "@ckb-ccc/core";
4074
+ *
4075
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4076
+ * const client = clientOwner.value;
4077
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4078
+ *
4079
+ * // Get xUDT script deployment info
4080
+ * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
4081
+ * console.log(`xUDT cellDeps:`, xudtInfo.cellDeps);
4082
+ *
4083
+ * // Build an xUDT type script
4084
+ * const xudtType = await ccc.Script.fromKnownScript(
4085
+ * client,
4086
+ * ccc.KnownScript.XUdt,
4087
+ * "0xOWNER_LOCK_HASH...",
4088
+ * );
3902
4089
  * ```
3903
4090
  */
3904
- clone(): Script;
4091
+ getKnownScript(script: KnownScript): Promise<ScriptInfo>;
4092
+ abstract getFeeRateStatistics(blockRange?: NumLike): Promise<{
4093
+ mean: Num;
4094
+ median: Num;
4095
+ }>;
3905
4096
  /**
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
4097
+ * Get the recommended transaction fee rate based on recent blocks.
4098
+ * Returns the median fee rate, clamped between min and max fee rates.
4099
+ *
4100
+ * @param blockRange - Number of recent blocks to analyze.
4101
+ * @param options - Optional max fee rate cap.
4102
+ * @returns The recommended fee rate in Shannons per KB.
3910
4103
  *
3911
4104
  * @example
3912
4105
  * ```typescript
3913
- * const isEqual = script0.eq(script1);
4106
+ * import { ccc } from "@ckb-ccc/core";
4107
+ *
4108
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4109
+ * const client = clientOwner.value;
4110
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4111
+ * const feeRate = await client.getFeeRate();
4112
+ * console.log(`Current fee rate: ${feeRate} Shannons/KB`);
3914
4113
  * ```
3915
4114
  */
3916
- eq(other: ScriptLike): boolean;
4115
+ getFeeRate(blockRange?: NumLike, options?: {
4116
+ maxFeeRate?: NumLike;
4117
+ }): Promise<Num>;
3917
4118
  /**
3918
- * Creates a Script instance from a ScriptLike object.
4119
+ * Get the latest block number (tip) of the chain.
3919
4120
  *
3920
- * @param script - A ScriptLike object or an instance of Script.
3921
- * @returns A Script instance.
4121
+ * @returns The current tip block number.
3922
4122
  *
3923
4123
  * @example
3924
4124
  * ```typescript
3925
- * const script = Script.from({
3926
- * codeHash: "0x1234...",
3927
- * hashType: "type",
3928
- * args: "0xabcd..."
4125
+ * import { ccc } from "@ckb-ccc/core";
4126
+ *
4127
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4128
+ * const client = clientOwner.value;
4129
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4130
+ * const tipBlockNumber = await client.getTip();
4131
+ * console.log(`Current block height: ${tipBlockNumber}`);
4132
+ * ```
4133
+ */
4134
+ abstract getTip(): Promise<Num>;
4135
+ /**
4136
+ * Get the header of the latest block.
4137
+ *
4138
+ * @param verbosity - Verbosity level (0 for hex, 1 for object).
4139
+ * @returns The tip block header.
4140
+ *
4141
+ * @example
4142
+ * ```typescript
4143
+ * import { ccc } from "@ckb-ccc/core";
4144
+ *
4145
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4146
+ * const client = clientOwner.value;
4147
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4148
+ * const header = await client.getTipHeader();
4149
+ * console.log(`Block #${header.number}, hash: ${header.hash}`);
4150
+ * ```
4151
+ */
4152
+ abstract getTipHeader(verbosity?: number | null): Promise<ClientBlockHeader>;
4153
+ abstract getBlockByNumberNoCache(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4154
+ abstract getBlockByHashNoCache(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4155
+ abstract getHeaderByNumberNoCache(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4156
+ abstract getHeaderByHashNoCache(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4157
+ getBlockByNumber(blockNumber: NumLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4158
+ getBlockByHash(blockHash: HexLike, verbosity?: number | null, withCycles?: boolean | null): Promise<ClientBlock | undefined>;
4159
+ getHeaderByNumber(blockNumber: NumLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4160
+ getHeaderByHash(blockHash: HexLike, verbosity?: number | null): Promise<ClientBlockHeader | undefined>;
4161
+ abstract estimateCycles(transaction: TransactionLike): Promise<Num>;
4162
+ abstract sendTransactionDry(transaction: TransactionLike, validator?: OutputsValidator): Promise<Num>;
4163
+ abstract sendTransactionNoCache(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
4164
+ abstract getTransactionNoCache(txHash: HexLike): Promise<ClientTransactionResponse | undefined>;
4165
+ /**
4166
+ * Get a cell by its out point.
4167
+ * The cell will be cached if it is found.
4168
+ *
4169
+ * @param outPointLike - The out point of the cell to get.
4170
+ * @returns The cell if it exists, otherwise undefined.
4171
+ *
4172
+ * @example
4173
+ * ```typescript
4174
+ * import { ccc } from "@ckb-ccc/core";
4175
+ *
4176
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4177
+ * const client = clientOwner.value;
4178
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4179
+ * const cell = await client.getCell({
4180
+ * txHash: "0xTX_HASH...",
4181
+ * index: 0,
3929
4182
  * });
4183
+ * if (cell) {
4184
+ * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4185
+ * console.log(`Lock: ${cell.cellOutput.lock.codeHash}`);
4186
+ * console.log(`Data: ${cell.outputData}`);
4187
+ * }
3930
4188
  * ```
3931
4189
  */
3932
- static from(script: ScriptLike): Script;
4190
+ getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
4191
+ getCellWithHeader(outPointLike: OutPointLike): Promise<{
4192
+ cell: Cell;
4193
+ header?: ClientBlockHeader;
4194
+ } | undefined>;
4195
+ abstract getCellLiveNoCache(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
3933
4196
  /**
3934
- * Creates a Script instance from client and known script.
4197
+ * Get a live (unspent) cell by its out point.
4198
+ * Unlike getCell(), this verifies the cell is still live on-chain.
3935
4199
  *
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.
4200
+ * @param outPointLike - The out point of the cell.
4201
+ * @param withData - Whether to include cell data.
4202
+ * @param includeTxPool - Whether to include cells in the transaction pool.
4203
+ * @returns The live cell, or undefined if spent or not found.
3940
4204
  *
3941
4205
  * @example
3942
4206
  * ```typescript
3943
- * const script = await Script.fromKnownScript(
3944
- * client,
3945
- * KnownScript.XUdt,
3946
- * args: "0xabcd..."
4207
+ * import { ccc } from "@ckb-ccc/core";
4208
+ *
4209
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4210
+ * const client = clientOwner.value;
4211
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4212
+ * const cell = await client.getCellLive(
4213
+ * { txHash: "0xTX_HASH...", index: 0 },
4214
+ * true, // include data
4215
+ * true, // include tx pool
3947
4216
  * );
4217
+ * if (cell) {
4218
+ * console.log("Cell is still live!");
4219
+ * } else {
4220
+ * console.log("Cell has been spent or does not exist.");
4221
+ * }
3948
4222
  * ```
3949
4223
  */
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;
4224
+ getCellLive(outPointLike: OutPointLike, withData?: boolean | null, includeTxPool?: boolean | null): Promise<Cell | undefined>;
4225
+ abstract findCellsPagedNoCache(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
4136
4226
  /**
4137
- * Creates an instance of OutPoint.
4227
+ * Find cells with pagination support.
4228
+ * Returns one page of results at a time with a cursor for the next page.
4138
4229
  *
4139
- * @param txHash - The transaction hash.
4140
- * @param index - The index of the output in the transaction.
4230
+ * @param key - The indexer search key.
4231
+ * @param order - Sort order ("asc" or "desc").
4232
+ * @param limit - Maximum cells per page.
4233
+ * @param after - Cursor from previous page for pagination.
4234
+ * @returns A page of cells with a cursor for the next page.
4235
+ *
4236
+ * @example
4237
+ * ```typescript
4238
+ * import { ccc } from "@ckb-ccc/core";
4239
+ *
4240
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4241
+ * const client = clientOwner.value;
4242
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4243
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4244
+ *
4245
+ * // Get first page of cells
4246
+ * const page1 = await client.findCellsPaged({
4247
+ * script: lock,
4248
+ * scriptType: "lock",
4249
+ * }, "asc", 20);
4250
+ * console.log(`Found ${page1.cells.length} cells`);
4251
+ *
4252
+ * // Get next page
4253
+ * if (page1.cells.length === 20) {
4254
+ * const page2 = await client.findCellsPaged(
4255
+ * { script: lock, scriptType: "lock" },
4256
+ * "asc", 20, page1.lastCursor,
4257
+ * );
4258
+ * }
4259
+ * ```
4141
4260
  */
4142
- constructor(txHash: Hex, index: Num);
4261
+ findCellsPaged(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindCellsResponse>;
4262
+ findCellsOnChain(key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4143
4263
  /**
4144
- * Creates an OutPoint instance from an OutPointLike object.
4264
+ * Find cells by search key designed for collectable cells.
4265
+ * The result also includes cached cells, the order param only works for cells fetched from RPC.
4145
4266
  *
4146
- * @param outPoint - An OutPointLike object or an instance of OutPoint.
4147
- * @returns An OutPoint instance.
4267
+ * @param keyLike - The search key.
4268
+ * @returns A async generator for yielding cells.
4148
4269
  *
4149
4270
  * @example
4150
4271
  * ```typescript
4151
- * const outPoint = OutPoint.from({ txHash: "0x...", index: 0 });
4272
+ * import { ccc } from "@ckb-ccc/core";
4273
+ *
4274
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4275
+ * const client = clientOwner.value;
4276
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4277
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4278
+ *
4279
+ * // Find all cells owned by a lock script
4280
+ * for await (const cell of client.findCells({
4281
+ * script: lock,
4282
+ * scriptType: "lock",
4283
+ * scriptSearchMode: "exact",
4284
+ * withData: true,
4285
+ * })) {
4286
+ * console.log(`Cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
4287
+ * console.log(`Capacity: ${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4288
+ * }
4152
4289
  * ```
4153
4290
  */
4154
- static from(outPoint: OutPointLike): OutPoint;
4291
+ findCells(keyLike: ClientCollectableSearchKeyLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4155
4292
  /**
4156
- * Clone a OutPoint.
4293
+ * Find cells by lock script, optionally filtered by type script.
4157
4294
  *
4158
- * @returns A cloned OutPoint instance.
4295
+ * @param lock - The lock script to search by.
4296
+ * @param type - Optional type script filter.
4297
+ * @param withData - Whether to include cell data (default: true).
4298
+ * @param order - Sort order by block number ("asc" or "desc").
4299
+ * @param limit - Page size for each RPC call (default: 10).
4300
+ * @returns An async generator yielding matching cells.
4159
4301
  *
4160
4302
  * @example
4161
4303
  * ```typescript
4162
- * const outPoint1 = outPoint0.clone();
4304
+ * import { ccc } from "@ckb-ccc/core";
4305
+ *
4306
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4307
+ * const client = clientOwner.value;
4308
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4309
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4310
+ *
4311
+ * // Find all cells belonging to this address
4312
+ * for await (const cell of client.findCellsByLock(lock)) {
4313
+ * console.log(`${ccc.fixedPointToString(cell.cellOutput.capacity)} CKB`);
4314
+ * }
4315
+ *
4316
+ * // Find only xUDT cells belonging to this address
4317
+ * const xudtType = await ccc.Script.fromKnownScript(
4318
+ * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
4319
+ * );
4320
+ * for await (const cell of client.findCellsByLock(lock, xudtType)) {
4321
+ * console.log(`UDT cell found`);
4322
+ * }
4163
4323
  * ```
4164
4324
  */
4165
- clone(): OutPoint;
4325
+ findCellsByLock(lock: ScriptLike, type?: ScriptLike | null, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4166
4326
  /**
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
4327
+ * Find cells by type script.
4328
+ *
4329
+ * @param type - The type script to search by.
4330
+ * @param withData - Whether to include cell data (default: true).
4331
+ * @param order - Sort order by block number.
4332
+ * @param limit - Page size for each RPC call (default: 10).
4333
+ * @returns An async generator yielding matching cells.
4171
4334
  *
4172
4335
  * @example
4173
4336
  * ```typescript
4174
- * const isEqual = outPoint0.eq(outPoint1);
4337
+ * import { ccc } from "@ckb-ccc/core";
4338
+ *
4339
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4340
+ * const client = clientOwner.value;
4341
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4342
+ * // Find all xUDT cells of a specific token
4343
+ * const xudtType = await ccc.Script.fromKnownScript(
4344
+ * client, ccc.KnownScript.XUdt, "0xOWNER_LOCK_HASH...",
4345
+ * );
4346
+ * for await (const cell of client.findCellsByType(xudtType)) {
4347
+ * console.log(`Token cell: ${cell.outPoint.txHash}:${cell.outPoint.index}`);
4348
+ * }
4175
4349
  * ```
4176
4350
  */
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;
4351
+ findCellsByType(type: ScriptLike, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
4352
+ findSingletonCellByType(type: ScriptLike, withData?: boolean): Promise<Cell | undefined>;
4288
4353
  /**
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.
4354
+ * Resolve cell dependency info into concrete CellDep objects.
4355
+ * If a CellDepInfo specifies a type script, the actual deployed cell is located on-chain.
4291
4356
  *
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.
4357
+ * @param cellDepsInfoLike - One or more CellDepInfo or arrays of CellDepInfo.
4358
+ * @returns Resolved CellDep array ready to be added to a transaction.
4297
4359
  *
4298
4360
  * @example
4299
4361
  * ```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
- * });
4362
+ * import { ccc } from "@ckb-ccc/core";
4306
4363
  *
4307
- * // Automatic capacity calculation
4308
- * const cellOutput2 = CellOutput.from({
4309
- * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
4310
- * }, "0x1234"); // Capacity will be calculated automatically
4364
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4365
+ * const client = clientOwner.value;
4366
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4367
+ * const xudtInfo = await client.getKnownScript(ccc.KnownScript.XUdt);
4368
+ * const cellDeps = await client.getCellDeps(xudtInfo.cellDeps);
4369
+ * // cellDeps can be added to a transaction:
4370
+ * // tx.cellDeps.push(...cellDeps);
4311
4371
  * ```
4312
4372
  */
4313
- static from(cellOutput: CellOutputLike, outputData?: HexLike | null): CellOutput;
4373
+ getCellDeps(...cellDepsInfoLike: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<CellDep[]>;
4374
+ abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4375
+ groupByTransaction: true;
4376
+ }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsGroupedResponse>;
4377
+ abstract findTransactionsPaged(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4378
+ groupByTransaction?: false | null;
4379
+ }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse>;
4380
+ abstract findTransactionsPaged(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse | ClientFindTransactionsGroupedResponse>;
4381
+ findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4382
+ groupByTransaction: true;
4383
+ }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4384
+ findTransactions(key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
4385
+ groupByTransaction?: false | null;
4386
+ }, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4387
+ findTransactions(key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4314
4388
  /**
4315
- * Clone a CellOutput.
4389
+ * Find transactions related to a lock script, optionally filtered by type script.
4316
4390
  *
4317
- * @returns A cloned CellOutput instance.
4391
+ * @param lock - The lock script to search by.
4392
+ * @param type - Optional type script filter.
4393
+ * @param groupByTransaction - If true, group results by transaction.
4394
+ * @param order - Sort order by block number.
4395
+ * @param limit - Page size per RPC call.
4396
+ * @returns An async generator yielding transaction records.
4318
4397
  *
4319
4398
  * @example
4320
4399
  * ```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.
4400
+ * import { ccc } from "@ckb-ccc/core";
4353
4401
  *
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.
4402
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4403
+ * const client = clientOwner.value;
4404
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4405
+ * const { script: lock } = await ccc.Address.fromString("ckt1q...", client);
4406
+ *
4407
+ * // List all transactions related to an address (grouped)
4408
+ * for await (const txRecord of client.findTransactionsByLock(lock, null, true)) {
4409
+ * console.log(`TX: ${txRecord.txHash}, Block: ${txRecord.blockNumber}`);
4410
+ * }
4411
+ * ```
4357
4412
  */
4358
- constructor(cellOutput: CellOutput, outputData: Hex, outPoint?: OutPoint);
4413
+ findTransactionsByLock(lock: ScriptLike, type: ScriptLike | undefined | null, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4414
+ findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4415
+ findTransactionsByLock(lock: ScriptLike, type?: ScriptLike | null, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4416
+ findTransactionsByType(type: ScriptLike, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
4417
+ findTransactionsByType(type: ScriptLike, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
4418
+ findTransactionsByType(type: ScriptLike, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
4419
+ abstract getCellsCapacity(key: ClientIndexerSearchKeyLike): Promise<Num>;
4359
4420
  /**
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`.
4421
+ * Get the total CKB balance of a single lock script.
4422
+ * Only counts cells with no type script and no data (pure CKB capacity cells).
4363
4423
  *
4364
- * @param cell - A `CellAnyLike` object.
4365
- * @returns A new `CellAny` instance.
4424
+ * @param lock - The lock script to query balance for.
4425
+ * @returns The total capacity in Shannons as a bigint.
4366
4426
  *
4367
4427
  * @example
4368
4428
  * ```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
- * });
4429
+ * import { ccc } from "@ckb-ccc/core";
4374
4430
  *
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
- * });
4431
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4432
+ * const client = clientOwner.value;
4433
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4434
+ * const { script: lock } = await ccc.Address.fromString(
4435
+ * "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq...",
4436
+ * client,
4437
+ * );
4438
+ * const balance = await client.getBalanceSingle(lock);
4439
+ * console.log(`Balance: ${ccc.fixedPointToString(balance)} CKB`);
4381
4440
  * ```
4382
4441
  */
4383
- static from(cell: CellAnyLike): CellAny;
4442
+ getBalanceSingle(lock: ScriptLike): Promise<Num>;
4384
4443
  /**
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`.
4444
+ * Get the total CKB balance across multiple lock scripts.
4445
+ * Sums the balance from each lock script.
4387
4446
  *
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.
4447
+ * @param locks - An array of lock scripts to query.
4448
+ * @returns The combined total capacity in Shannons as a bigint.
4394
4449
  *
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.
4450
+ * @example
4451
+ * ```typescript
4452
+ * import { ccc } from "@ckb-ccc/core";
4400
4453
  *
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.
4454
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4455
+ * const client = clientOwner.value;
4456
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4457
+ * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
4458
+ * await signer.connect();
4459
+ *
4460
+ * const locks = await signer.getRecommendedAddressObj()
4461
+ * .then(({ script }) => [script]);
4462
+ * const totalBalance = await client.getBalance(locks);
4463
+ * console.log(`Total: ${ccc.fixedPointToString(totalBalance)} CKB`);
4464
+ * ```
4405
4465
  */
4406
- isNervosDao(client: Client, phase?: "deposited" | "withdrew"): Promise<boolean>;
4466
+ getBalance(locks: ScriptLike[]): Promise<Num>;
4407
4467
  /**
4408
- * Clones the `CellAny` instance.
4468
+ * Send a signed transaction to the CKB network.
4469
+ * Validates the fee rate against the maximum before sending.
4409
4470
  *
4410
- * @returns A new `CellAny` instance that is a deep copy of the current one.
4471
+ * @param transaction - The transaction to send.
4472
+ * @param validator - Optional outputs validator ("passthrough" or "well_known_scripts_only").
4473
+ * @param options - Optional configuration including maxFeeRate.
4474
+ * @returns The transaction hash.
4411
4475
  *
4412
4476
  * @example
4413
4477
  * ```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.
4478
+ * import { ccc } from "@ckb-ccc/core";
4452
4479
  *
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.
4480
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4481
+ * const client = clientOwner.value;
4482
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4483
+ * const signer = new ccc.SignerCkbPrivateKey(client, "0x...");
4484
+ * await signer.connect();
4458
4485
  *
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"
4486
+ * const tx = ccc.Transaction.from({
4487
+ * outputs: [{ capacity: ccc.fixedPointFrom(100), lock: receiverLock }],
4469
4488
  * });
4489
+ * await tx.completeInputsByCapacity(signer);
4490
+ * await tx.completeFeeBy(signer);
4470
4491
  *
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
- * });
4492
+ * // Usually you call signer.sendTransaction(tx) which signs then sends.
4493
+ * // client.sendTransaction expects an already-signed transaction.
4494
+ * const txHash = await client.sendTransaction(tx);
4480
4495
  * ```
4481
4496
  */
4482
- static from(cell: CellLike): Cell;
4497
+ sendTransaction(transaction: TransactionLike, validator?: OutputsValidator, options?: {
4498
+ maxFeeRate?: NumLike;
4499
+ }): Promise<Hex>;
4483
4500
  /**
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
4501
+ * Get a transaction by its hash, including its status and block info.
4487
4502
  *
4488
- * @param client - A client for searching DAO related headers
4489
- * @returns Profit
4503
+ * @param txHashLike - The transaction hash to look up.
4504
+ * @returns The transaction response with status, or undefined if not found.
4490
4505
  *
4491
4506
  * @example
4492
4507
  * ```typescript
4493
- * const profit = await cell.getDaoProfit(client);
4508
+ * import { ccc } from "@ckb-ccc/core";
4509
+ *
4510
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4511
+ * const client = clientOwner.value;
4512
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4513
+ * const txResponse = await client.getTransaction("0xTX_HASH...");
4514
+ * if (txResponse) {
4515
+ * console.log(`Status: ${txResponse.status}`);
4516
+ * console.log(`Block: ${txResponse.blockNumber}`);
4517
+ * console.log(`Outputs: ${txResponse.transaction.outputs.length}`);
4518
+ * }
4494
4519
  * ```
4495
4520
  */
4496
- getDaoProfit(client: Client): Promise<Num>;
4521
+ getTransaction(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
4497
4522
  /**
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
- * ```
4523
+ * This method gets specified transaction with its block header (if existed).
4524
+ * This is mainly for caching because we need the header to test if we can safely trust the cached tx status.
4525
+ * @param txHashLike
4512
4526
  */
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
- }>;
4527
+ getTransactionWithHeader(txHashLike: HexLike): Promise<{
4528
+ transaction: ClientTransactionResponse;
4529
+ header?: ClientBlockHeader;
4530
+ } | undefined>;
4523
4531
  /**
4524
- * Clone a Cell
4532
+ * Wait for a transaction to be confirmed on-chain.
4533
+ * Polls the node until the transaction reaches the specified confirmation depth.
4525
4534
  *
4526
- * @returns A cloned Cell instance.
4535
+ * @param txHash - The transaction hash to wait for.
4536
+ * @param confirmations - Number of block confirmations to wait for (default: 0 = committed).
4537
+ * @param timeout - Maximum wait time in milliseconds (default: 60000).
4538
+ * @param interval - Polling interval in milliseconds (default: 2000).
4539
+ * @returns The transaction response once confirmed, or throws on timeout.
4527
4540
  *
4528
4541
  * @example
4529
4542
  * ```typescript
4530
- * const cell1 = cell0.clone();
4543
+ * import { ccc } from "@ckb-ccc/core";
4544
+ *
4545
+ * const clientOwner = ccc.ClientPublicTestnet.open();
4546
+ * const client = clientOwner.value;
4547
+ * // Call `await clientOwner.dispose()` when the client is no longer needed.
4548
+ * // Wait for transaction to be committed (0 confirmations)
4549
+ * const tx = await client.waitTransaction("0xTX_HASH...");
4550
+ * console.log(`Confirmed in block: ${tx?.blockNumber}`);
4551
+ *
4552
+ * // Wait for 4 confirmations with 2 minute timeout
4553
+ * const confirmedTx = await client.waitTransaction(
4554
+ * "0xTX_HASH...",
4555
+ * 4, // confirmations
4556
+ * 120000, // timeout: 2 minutes
4557
+ * );
4531
4558
  * ```
4532
4559
  */
4533
- clone(): Cell;
4560
+ waitTransaction(txHash: HexLike, confirmations?: number, timeout?: number, interval?: number): Promise<ClientTransactionResponse | undefined>;
4534
4561
  }
4562
+ //#endregion
4563
+ //#region src/ckb/script.d.ts
4564
+ declare const HashTypeCodec: Codec<HashTypeLike, HashType>;
4535
4565
  /**
4536
4566
  * @public
4537
4567
  */
4538
- type SinceLike = {
4539
- relative: "absolute" | "relative";
4540
- metric: "blockNumber" | "epoch" | "timestamp";
4541
- value: NumLike;
4542
- } | NumLike;
4543
- declare const Since_base: (abstract new () => {
4568
+ type HashTypeLike = string | number | bigint;
4569
+ /**
4570
+ * @public
4571
+ */
4572
+ type HashType = "type" | "data" | "data1" | "data2";
4573
+ /**
4574
+ * Converts a HashTypeLike value to a HashType.
4575
+ * @public
4576
+ *
4577
+ * @param val - The value to convert, which can be a string, number, or bigint.
4578
+ * @returns The corresponding HashType.
4579
+ *
4580
+ * @throws Will throw an error if the input value is not a valid hash type.
4581
+ *
4582
+ * @example
4583
+ * ```typescript
4584
+ * const hashType = hashTypeFrom(1); // Outputs "data"
4585
+ * const hashType = hashTypeFrom("type"); // Outputs "type"
4586
+ * ```
4587
+ */
4588
+ declare function hashTypeFrom(val: HashTypeLike): HashType;
4589
+ /**
4590
+ * Converts a HashTypeLike value to its corresponding byte representation.
4591
+ * @public
4592
+ *
4593
+ * @param hashType - The hash type value to convert.
4594
+ * @returns A Uint8Array containing the byte representation of the hash type.
4595
+ *
4596
+ * @example
4597
+ * ```typescript
4598
+ * const hashTypeBytes = hashTypeToBytes("type"); // Outputs Uint8Array [0]
4599
+ * ```
4600
+ */
4601
+ declare function hashTypeToBytes(hashType: HashTypeLike): Bytes$1;
4602
+ /**
4603
+ * Converts a byte-like value to a HashType.
4604
+ * @public
4605
+ *
4606
+ * @param bytes - The byte-like value to convert.
4607
+ * @returns The corresponding HashType.
4608
+ *
4609
+ * @throws Will throw an error if the input bytes do not correspond to a valid hash type.
4610
+ *
4611
+ * @example
4612
+ * ```typescript
4613
+ * const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs "type"
4614
+ * ```
4615
+ */
4616
+ declare function hashTypeFromBytes(bytes: BytesLike): HashType;
4617
+ /**
4618
+ * @public
4619
+ */
4620
+ type ScriptLike = {
4621
+ codeHash: BytesLike;
4622
+ hashType: HashTypeLike;
4623
+ args: BytesLike;
4624
+ };
4625
+ declare const Script_base: (abstract new () => {
4544
4626
  toBytes(): Bytes$1;
4545
- clone(): Since;
4546
- eq(other: SinceLike): boolean;
4627
+ clone(): Script;
4628
+ eq(other: ScriptLike): boolean;
4547
4629
  hash(): Hex;
4548
4630
  toHex(): Hex;
4549
4631
  }) & {
4550
4632
  byteLength?: number;
4551
- encode(_: SinceLike): Bytes$1;
4552
- decode(_: BytesLike): Since;
4553
- fromBytes(_bytes: BytesLike): Since;
4554
- from(_: SinceLike): Since;
4633
+ encode(_: ScriptLike): Bytes$1;
4634
+ decode(_: BytesLike): Script;
4635
+ fromBytes(_bytes: BytesLike): Script;
4636
+ from(_: ScriptLike): Script;
4555
4637
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4556
4638
  toBytes(): Bytes$1;
4557
4639
  clone(): SubType;
@@ -4628,89 +4710,182 @@ declare const Since_base: (abstract new () => {
4628
4710
  /**
4629
4711
  * @public
4630
4712
  */
4631
- declare class Since extends Since_base {
4632
- relative: "absolute" | "relative";
4633
- metric: "blockNumber" | "epoch" | "timestamp";
4634
- value: Num;
4713
+ declare class Script extends Script_base {
4714
+ codeHash: Hex;
4715
+ hashType: HashType;
4716
+ args: Hex;
4635
4717
  /**
4636
- * Creates an instance of Since.
4718
+ * Creates an instance of Script.
4637
4719
  *
4638
- * @param relative - Absolute or relative
4639
- * @param metric - The metric of since
4640
- * @param value - The value of since
4720
+ * @param codeHash - The code hash of the script.
4721
+ * @param hashType - The hash type of the script.
4722
+ * @param args - The arguments for the script.
4641
4723
  */
4642
- constructor(relative: "absolute" | "relative", metric: "blockNumber" | "epoch" | "timestamp", value: Num);
4724
+ constructor(codeHash: Hex, hashType: HashType, args: Hex);
4725
+ get occupiedSize(): number;
4643
4726
  /**
4644
- * Clone a Since.
4727
+ * Clone a script.
4645
4728
  *
4646
- * @returns A cloned Since instance.
4729
+ * @returns A cloned Script instance.
4647
4730
  *
4648
4731
  * @example
4649
4732
  * ```typescript
4650
- * const since1 = since0.clone();
4733
+ * const script1 = script0.clone();
4651
4734
  * ```
4652
4735
  */
4653
- clone(): Since;
4736
+ clone(): Script;
4654
4737
  /**
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.
4738
+ * Check if the script is equal to another script.
4739
+ * @public
4740
+ * @param other - The other script to compare with
4741
+ * @returns True if the scripts are equal, false otherwise
4659
4742
  *
4660
4743
  * @example
4661
4744
  * ```typescript
4662
- * const since = Since.from("0x1234567812345678");
4745
+ * const isEqual = script0.eq(script1);
4663
4746
  * ```
4664
4747
  */
4665
- static from(since: SinceLike): Since;
4748
+ eq(other: ScriptLike): boolean;
4666
4749
  /**
4667
- * Converts the Since instance to num.
4750
+ * Creates a Script instance from a ScriptLike object.
4668
4751
  *
4669
- * @returns A num
4752
+ * @param script - A ScriptLike object or an instance of Script.
4753
+ * @returns A Script instance.
4670
4754
  *
4671
4755
  * @example
4672
4756
  * ```typescript
4673
- * const num = since.toNum();
4757
+ * const script = Script.from({
4758
+ * codeHash: "0x1234...",
4759
+ * hashType: "type",
4760
+ * args: "0xabcd..."
4761
+ * });
4674
4762
  * ```
4675
4763
  */
4676
- toNum(): Num;
4764
+ static from(script: ScriptLike): Script;
4677
4765
  /**
4678
- * Creates a Since instance from a num-like value.
4766
+ * Creates a Script instance from client and known script.
4679
4767
  *
4680
- * @param numLike - The num-like value to convert.
4681
- * @returns A Since instance.
4768
+ * @param knownScript - A KnownScript enum.
4769
+ * @param args - Args for the script.
4770
+ * @param client - A ScriptLike object or an instance of Script.
4771
+ * @returns A promise that resolves to the script instance.
4682
4772
  *
4683
4773
  * @example
4684
4774
  * ```typescript
4685
- * const since = Since.fromNum("0x0");
4775
+ * const script = await Script.fromKnownScript(
4776
+ * client,
4777
+ * KnownScript.XUdt,
4778
+ * args: "0xabcd..."
4779
+ * );
4686
4780
  * ```
4687
4781
  */
4688
- static fromNum(numLike: NumLike): Since;
4782
+ static fromKnownScript(client: Client, knownScript: KnownScript, args: HexLike): Promise<Script>;
4783
+ }
4784
+ declare const ScriptOpt: Codec<ScriptLike | null | undefined, Script | undefined>;
4785
+ declare const ScriptVec: Codec<ScriptLike[], Script[]>;
4786
+ //#endregion
4787
+ //#region src/ckb/transactionLumos.d.ts
4788
+ interface LumosTransactionSkeletonType {
4789
+ cellDeps: {
4790
+ toArray(): CellDepLike[];
4791
+ };
4792
+ headerDeps: {
4793
+ toArray(): HexLike[];
4794
+ };
4795
+ inputs: {
4796
+ toArray(): {
4797
+ outPoint?: OutPointLike;
4798
+ cellOutput: CellOutputLike;
4799
+ data: HexLike;
4800
+ }[];
4801
+ };
4802
+ inputSinces: {
4803
+ get(i: number, defaultVal: string): HexLike;
4804
+ };
4805
+ outputs: {
4806
+ toArray(): {
4807
+ cellOutput: CellOutputLike;
4808
+ data: HexLike;
4809
+ }[];
4810
+ };
4811
+ witnesses: {
4812
+ toArray(): HexLike[];
4813
+ };
4689
4814
  }
4815
+ //#endregion
4816
+ //#region src/ckb/transaction.d.ts
4817
+ declare const DepTypeCodec: Codec<DepTypeLike, DepType>;
4690
4818
  /**
4691
4819
  * @public
4692
4820
  */
4693
- type CellInputLike = ({
4694
- previousOutput: OutPointLike;
4695
- } | {
4696
- outPoint: OutPointLike;
4697
- }) & {
4698
- since?: SinceLike | NumLike | null;
4699
- cellOutput?: CellOutputLike | null;
4700
- outputData?: HexLike | null;
4821
+ type DepTypeLike = string | number | bigint;
4822
+ /**
4823
+ * @public
4824
+ */
4825
+ type DepType = "depGroup" | "code";
4826
+ /**
4827
+ * Converts a DepTypeLike value to a DepType.
4828
+ * @public
4829
+ *
4830
+ * @param val - The value to convert, which can be a string, number, or bigint.
4831
+ * @returns The corresponding DepType.
4832
+ *
4833
+ * @throws Will throw an error if the input value is not a valid dep type.
4834
+ *
4835
+ * @example
4836
+ * ```typescript
4837
+ * const depType = depTypeFrom(1); // Outputs "code"
4838
+ * const depType = depTypeFrom("depGroup"); // Outputs "depGroup"
4839
+ * ```
4840
+ */
4841
+ declare function depTypeFrom(val: DepTypeLike): DepType;
4842
+ /**
4843
+ * Converts a DepTypeLike value to its corresponding byte representation.
4844
+ * @public
4845
+ *
4846
+ * @param depType - The dep type value to convert.
4847
+ * @returns A Uint8Array containing the byte representation of the dep type.
4848
+ *
4849
+ * @example
4850
+ * ```typescript
4851
+ * const depTypeBytes = depTypeToBytes("code"); // Outputs Uint8Array [1]
4852
+ * ```
4853
+ */
4854
+ declare function depTypeToBytes(depType: DepTypeLike): Bytes$1;
4855
+ /**
4856
+ * Converts a byte-like value to a DepType.
4857
+ * @public
4858
+ *
4859
+ * @param bytes - The byte-like value to convert.
4860
+ * @returns The corresponding DepType.
4861
+ *
4862
+ * @throws Will throw an error if the input bytes do not correspond to a valid dep type.
4863
+ *
4864
+ * @example
4865
+ * ```typescript
4866
+ * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs "code"
4867
+ * ```
4868
+ */
4869
+ declare function depTypeFromBytes(bytes: BytesLike): DepType;
4870
+ /**
4871
+ * @public
4872
+ */
4873
+ type OutPointLike = {
4874
+ txHash: HexLike;
4875
+ index: NumLike;
4701
4876
  };
4702
- declare const CellInput_base: (abstract new () => {
4877
+ declare const OutPoint_base: (abstract new () => {
4703
4878
  toBytes(): Bytes$1;
4704
- clone(): CellInput;
4705
- eq(other: CellInputLike): boolean;
4879
+ clone(): OutPoint;
4880
+ eq(other: OutPointLike): boolean;
4706
4881
  hash(): Hex;
4707
4882
  toHex(): Hex;
4708
4883
  }) & {
4709
4884
  byteLength?: number;
4710
- encode(_: CellInputLike): Bytes$1;
4711
- decode(_: BytesLike): CellInput;
4712
- fromBytes(_bytes: BytesLike): CellInput;
4713
- from(_: CellInputLike): CellInput;
4885
+ encode(_: OutPointLike): Bytes$1;
4886
+ decode(_: BytesLike): OutPoint;
4887
+ fromBytes(_bytes: BytesLike): OutPoint;
4888
+ from(_: OutPointLike): OutPoint;
4714
4889
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4715
4890
  toBytes(): Bytes$1;
4716
4891
  clone(): SubType;
@@ -4787,87 +4962,72 @@ declare const CellInput_base: (abstract new () => {
4787
4962
  /**
4788
4963
  * @public
4789
4964
  */
4790
- declare class CellInput extends CellInput_base {
4791
- previousOutput: OutPoint;
4792
- since: Num;
4793
- cellOutput?: CellOutput | undefined;
4794
- outputData?: Hex | undefined;
4965
+ declare class OutPoint extends OutPoint_base {
4966
+ txHash: Hex;
4967
+ index: Num;
4795
4968
  /**
4796
- * Creates an instance of CellInput.
4969
+ * Creates an instance of OutPoint.
4797
4970
  *
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.
4971
+ * @param txHash - The transaction hash.
4972
+ * @param index - The index of the output in the transaction.
4802
4973
  */
4803
- constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: Hex | undefined);
4974
+ constructor(txHash: Hex, index: Num);
4804
4975
  /**
4805
- * Creates a CellInput instance from a CellInputLike object.
4976
+ * Creates an OutPoint instance from an OutPointLike object.
4806
4977
  *
4807
- * @param cellInput - A CellInputLike object or an instance of CellInput.
4808
- * @returns A CellInput instance.
4978
+ * @param outPoint - An OutPointLike object or an instance of OutPoint.
4979
+ * @returns An OutPoint instance.
4809
4980
  *
4810
4981
  * @example
4811
4982
  * ```typescript
4812
- * const cellInput = CellInput.from({
4813
- * previousOutput: { txHash: "0x...", index: 0 },
4814
- * since: 0n
4815
- * });
4983
+ * const outPoint = OutPoint.from({ txHash: "0x...", index: 0 });
4816
4984
  * ```
4817
4985
  */
4818
- static from(cellInput: CellInputLike): CellInput;
4819
- getCell(client: Client): Promise<Cell>;
4986
+ static from(outPoint: OutPointLike): OutPoint;
4820
4987
  /**
4821
- * Complete extra infos in the input. Including
4822
- * - Previous cell output
4823
- * - Previous cell data
4824
- * The instance will be modified.
4988
+ * Clone a OutPoint.
4989
+ *
4990
+ * @returns A cloned OutPoint instance.
4825
4991
  *
4826
- * @returns true if succeed.
4827
4992
  * @example
4828
4993
  * ```typescript
4829
- * await cellInput.completeExtraInfos(client);
4994
+ * const outPoint1 = outPoint0.clone();
4830
4995
  * ```
4831
4996
  */
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>;
4997
+ clone(): OutPoint;
4839
4998
  /**
4840
- * Clone a CellInput.
4841
- *
4842
- * @returns A cloned CellInput instance.
4999
+ * Check if the OutPoint is equal to another OutPoint.
5000
+ * @public
5001
+ * @param other - The other OutPoint to compare with
5002
+ * @returns True if the OutPoints are equal, false otherwise
4843
5003
  *
4844
5004
  * @example
4845
5005
  * ```typescript
4846
- * const cellInput1 = cellInput0.clone();
5006
+ * const isEqual = outPoint0.eq(outPoint1);
4847
5007
  * ```
4848
5008
  */
4849
- clone(): CellInput;
5009
+ eq(other: OutPointLike): boolean;
4850
5010
  }
4851
- declare const CellInputVec: Codec<CellInputLike[], CellInput[]>;
4852
5011
  /**
4853
5012
  * @public
4854
5013
  */
4855
- type CellDepLike = {
4856
- outPoint: OutPointLike;
4857
- depType: DepTypeLike;
5014
+ type CellOutputLike = {
5015
+ capacity?: NumLike | null;
5016
+ lock: ScriptLike;
5017
+ type?: ScriptLike | null;
4858
5018
  };
4859
- declare const CellDep_base: (abstract new () => {
5019
+ declare const CellOutput_base: (abstract new () => {
4860
5020
  toBytes(): Bytes$1;
4861
- clone(): CellDep;
4862
- eq(other: CellDepLike): boolean;
5021
+ clone(): CellOutput;
5022
+ eq(other: CellOutputLike): boolean;
4863
5023
  hash(): Hex;
4864
5024
  toHex(): Hex;
4865
5025
  }) & {
4866
5026
  byteLength?: number;
4867
- encode(_: CellDepLike): Bytes$1;
4868
- decode(_: BytesLike): CellDep;
4869
- fromBytes(_bytes: BytesLike): CellDep;
4870
- from(_: CellDepLike): CellDep;
5027
+ encode(_: CellOutputLike): Bytes$1;
5028
+ decode(_: BytesLike): CellOutput;
5029
+ fromBytes(_bytes: BytesLike): CellOutput;
5030
+ from(_: CellOutputLike): CellOutput;
4871
5031
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
4872
5032
  toBytes(): Bytes$1;
4873
5033
  clone(): SubType;
@@ -4944,64 +5104,286 @@ declare const CellDep_base: (abstract new () => {
4944
5104
  /**
4945
5105
  * @public
4946
5106
  */
4947
- declare class CellDep extends CellDep_base {
4948
- outPoint: OutPoint;
4949
- depType: DepType;
5107
+ declare class CellOutput extends CellOutput_base {
5108
+ capacity: Num;
5109
+ lock: Script;
5110
+ type?: Script | undefined;
4950
5111
  /**
4951
- * Creates an instance of CellDep.
5112
+ * Creates an instance of CellOutput.
4952
5113
  *
4953
- * @param outPoint - The outpoint of the cell dependency.
4954
- * @param depType - The dependency type.
5114
+ * @param capacity - The capacity of the cell.
5115
+ * @param lock - The lock script of the cell.
5116
+ * @param type - The optional type script of the cell.
4955
5117
  */
4956
- constructor(outPoint: OutPoint, depType: DepType);
5118
+ constructor(capacity: Num, lock: Script, type?: Script | undefined);
5119
+ get occupiedSize(): number;
4957
5120
  /**
4958
- * Creates a CellDep instance from a CellDepLike object.
5121
+ * Creates a CellOutput instance from a CellOutputLike object.
5122
+ * This method supports automatic capacity calculation when outputData is provided and capacity is 0 or omitted.
4959
5123
  *
4960
- * @param cellDep - A CellDepLike object or an instance of CellDep.
4961
- * @returns A CellDep instance.
5124
+ * @param cellOutput - A CellOutputLike object or an instance of CellOutput.
5125
+ * @param outputData - Optional output data used for automatic capacity calculation.
5126
+ * When provided and capacity is 0, the capacity will be calculated
5127
+ * as occupiedSize + outputData.length.
5128
+ * @returns A CellOutput instance.
4962
5129
  *
4963
5130
  * @example
4964
5131
  * ```typescript
4965
- * const cellDep = CellDep.from({
4966
- * outPoint: { txHash: "0x...", index: 0 },
4967
- * depType: "depGroup"
5132
+ * // Basic usage with explicit capacity
5133
+ * const cellOutput1 = CellOutput.from({
5134
+ * capacity: 1000n,
5135
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." },
5136
+ * type: { codeHash: "0x...", hashType: "type", args: "0x..." }
4968
5137
  * });
5138
+ *
5139
+ * // Automatic capacity calculation
5140
+ * const cellOutput2 = CellOutput.from({
5141
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5142
+ * }, "0x1234"); // Capacity will be calculated automatically
4969
5143
  * ```
4970
5144
  */
4971
- static from(cellDep: CellDepLike): CellDep;
5145
+ static from(cellOutput: CellOutputLike, outputData?: HexLike | null): CellOutput;
4972
5146
  /**
4973
- * Clone a CellDep.
5147
+ * Clone a CellOutput.
4974
5148
  *
4975
- * @returns A cloned CellDep instance.
5149
+ * @returns A cloned CellOutput instance.
4976
5150
  *
4977
5151
  * @example
4978
5152
  * ```typescript
4979
- * const cellDep1 = cellDep0.clone();
5153
+ * const cellOutput1 = cellOutput0.clone();
4980
5154
  * ```
4981
5155
  */
4982
- clone(): CellDep;
5156
+ clone(): CellOutput;
4983
5157
  }
4984
- declare const CellDepVec: Codec<CellDepLike[], CellDep[]>;
5158
+ declare const CellOutputVec: Codec<CellOutputLike[], CellOutput[]>;
4985
5159
  /**
4986
5160
  * @public
5161
+ * Represents a cell-like object that may or may not be on-chain.
5162
+ * It can optionally have an `outPoint` (or `previousOutput`).
5163
+ * This is used as a flexible input for creating `CellAny` instances.
5164
+ * @see CellAny
4987
5165
  */
4988
- type WitnessArgsLike = {
4989
- lock?: HexLike | null;
4990
- inputType?: HexLike | null;
4991
- outputType?: HexLike | null;
5166
+ type CellAnyLike = {
5167
+ outPoint?: OutPointLike | null;
5168
+ previousOutput?: OutPointLike | null;
5169
+ cellOutput: CellOutputLike;
5170
+ outputData?: HexLike | null;
4992
5171
  };
4993
- declare const WitnessArgs_base: (abstract new () => {
5172
+ /**
5173
+ * Represents a CKB cell that can be either on-chain (with an `outPoint`) or off-chain (without an `outPoint`).
5174
+ * This class provides a unified interface for handling cells before they are included in a transaction,
5175
+ * or for cells that are already part of the blockchain state.
5176
+ *
5177
+ * @public
5178
+ */
5179
+ declare class CellAny {
5180
+ cellOutput: CellOutput;
5181
+ outputData: Hex;
5182
+ outPoint: OutPoint | undefined;
5183
+ /**
5184
+ * Creates an instance of CellAny.
5185
+ *
5186
+ * @param cellOutput - The cell output of the cell.
5187
+ * @param outputData - The output data of the cell.
5188
+ * @param outPoint - The optional output point of the cell. If provided, the cell is considered on-chain.
5189
+ */
5190
+ constructor(cellOutput: CellOutput, outputData: Hex, outPoint?: OutPoint);
5191
+ /**
5192
+ * Creates a `CellAny` instance from a `CellAnyLike` object.
5193
+ * This factory method provides a convenient way to create `CellAny` instances
5194
+ * from plain objects, automatically handling the optional `outPoint` or `previousOutput`.
5195
+ *
5196
+ * @param cell - A `CellAnyLike` object.
5197
+ * @returns A new `CellAny` instance.
5198
+ *
5199
+ * @example
5200
+ * ```typescript
5201
+ * // Create an off-chain cell (e.g., a new output)
5202
+ * const offChainCell = CellAny.from({
5203
+ * cellOutput: { capacity: 1000n, lock: lockScript },
5204
+ * outputData: "0x"
5205
+ * });
5206
+ *
5207
+ * // Create an on-chain cell from an input
5208
+ * const onChainCell = CellAny.from({
5209
+ * outPoint: { txHash: "0x...", index: 0 },
5210
+ * cellOutput: { capacity: 2000n, lock: lockScript },
5211
+ * outputData: "0x1234"
5212
+ * });
5213
+ * ```
5214
+ */
5215
+ static from(cell: CellAnyLike): CellAny;
5216
+ /**
5217
+ * Calculates the total occupied size of the cell in bytes.
5218
+ * This includes the size of the `CellOutput` structure plus the size of the `outputData`.
5219
+ *
5220
+ * @returns The total occupied size in bytes.
5221
+ */
5222
+ get occupiedSize(): number;
5223
+ /**
5224
+ * Calculates the free capacity of the cell.
5225
+ * Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.
5226
+ *
5227
+ * @returns The free capacity in shannons as a `Num`.
5228
+ */
5229
+ get capacityFree(): bigint;
5230
+ /**
5231
+ * Checks if the cell is a Nervos DAO cell and optionally checks its phase.
5232
+ *
5233
+ * @param client - A CKB client instance to fetch known script information.
5234
+ * @param phase - Optional phase to check: "deposited" or "withdrew".
5235
+ * If omitted, it checks if the cell is a DAO cell regardless of phase.
5236
+ * @returns A promise that resolves to `true` if the cell is a matching Nervos DAO cell, `false` otherwise.
5237
+ */
5238
+ isNervosDao(client: Client, phase?: "deposited" | "withdrew"): Promise<boolean>;
5239
+ /**
5240
+ * Clones the `CellAny` instance.
5241
+ *
5242
+ * @returns A new `CellAny` instance that is a deep copy of the current one.
5243
+ *
5244
+ * @example
5245
+ * ```typescript
5246
+ * const clonedCell = cellAny.clone();
5247
+ * ```
5248
+ */
5249
+ clone(): CellAny;
5250
+ }
5251
+ /**
5252
+ * Represents a cell-like object that is guaranteed to be on-chain.
5253
+ * It must have an `outPoint` (or its alias `previousOutput`).
5254
+ * This is used as a type constraint for creating `Cell` instances.
5255
+ * @see Cell
5256
+ * @public
5257
+ */
5258
+ type CellLike = CellAnyLike & ({
5259
+ outPoint: OutPointLike;
5260
+ previousOutput?: undefined | null;
5261
+ } | {
5262
+ outPoint?: undefined | null;
5263
+ previousOutput: OutPointLike;
5264
+ });
5265
+ /**
5266
+ * Represents an on-chain CKB cell, which is a `CellAny` that is guaranteed to have an `outPoint`.
5267
+ * This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.
5268
+ * @public
5269
+ */
5270
+ declare class Cell extends CellAny {
5271
+ outPoint: OutPoint;
5272
+ /**
5273
+ * Creates an instance of an on-chain Cell.
5274
+ *
5275
+ * @param outPoint - The output point of the cell.
5276
+ * @param cellOutput - The cell output of the cell.
5277
+ * @param outputData - The output data of the cell.
5278
+ */
5279
+ constructor(outPoint: OutPoint, cellOutput: CellOutput, outputData: Hex);
5280
+ /**
5281
+ * Creates a Cell instance from a CellLike object.
5282
+ * This method accepts either `outPoint` or `previousOutput` to specify the cell's location,
5283
+ * and supports automatic capacity calculation for the cell output.
5284
+ *
5285
+ * @param cell - A CellLike object or an instance of Cell. The object can use either:
5286
+ * - `outPoint`: For referencing a cell output
5287
+ * - `previousOutput`: For referencing a cell input (alternative name for outPoint)
5288
+ * The cellOutput can omit capacity for automatic calculation.
5289
+ * @returns A Cell instance.
5290
+ *
5291
+ * @example
5292
+ * ```typescript
5293
+ * // Using outPoint with explicit capacity
5294
+ * const cell1 = Cell.from({
5295
+ * outPoint: { txHash: "0x...", index: 0 },
5296
+ * cellOutput: {
5297
+ * capacity: 1000n,
5298
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5299
+ * },
5300
+ * outputData: "0x"
5301
+ * });
5302
+ *
5303
+ * // Using previousOutput with automatic capacity calculation
5304
+ * const cell2 = Cell.from({
5305
+ * previousOutput: { txHash: "0x...", index: 0 },
5306
+ * cellOutput: {
5307
+ * lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
5308
+ * // capacity will be calculated automatically
5309
+ * },
5310
+ * outputData: "0x1234"
5311
+ * });
5312
+ * ```
5313
+ */
5314
+ static from(cell: CellLike): Cell;
5315
+ /**
5316
+ * Gets confirmed Nervos DAO profit of a Cell
5317
+ * It returns non-zero value only when the cell is in withdrawal phase 2
5318
+ * See https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md
5319
+ *
5320
+ * @param client - A client for searching DAO related headers
5321
+ * @returns Profit
5322
+ *
5323
+ * @example
5324
+ * ```typescript
5325
+ * const profit = await cell.getDaoProfit(client);
5326
+ * ```
5327
+ */
5328
+ getDaoProfit(client: Client): Promise<Num>;
5329
+ /**
5330
+ * Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.
5331
+ *
5332
+ * @param client - A CKB client instance to fetch cell and header data.
5333
+ * @returns A promise that resolves to an object containing header information.
5334
+ * - If not a DAO cell, returns `{}`.
5335
+ * - If a deposited DAO cell, returns `{ depositHeader }`.
5336
+ * - If a withdrawn DAO cell, returns `{ depositHeader, withdrawHeader }`.
5337
+ *
5338
+ * @throws If the cell is a DAO cell but its corresponding headers cannot be fetched.
5339
+ *
5340
+ * @example
5341
+ * ```typescript
5342
+ * const daoInfo = await cell.getNervosDaoInfo(client);
5343
+ * ```
5344
+ */
5345
+ getNervosDaoInfo(client: Client): Promise<{
5346
+ depositHeader?: undefined;
5347
+ withdrawHeader?: undefined;
5348
+ } | {
5349
+ depositHeader: ClientBlockHeader;
5350
+ withdrawHeader?: undefined;
5351
+ } | {
5352
+ depositHeader: ClientBlockHeader;
5353
+ withdrawHeader: ClientBlockHeader;
5354
+ }>;
5355
+ /**
5356
+ * Clone a Cell
5357
+ *
5358
+ * @returns A cloned Cell instance.
5359
+ *
5360
+ * @example
5361
+ * ```typescript
5362
+ * const cell1 = cell0.clone();
5363
+ * ```
5364
+ */
5365
+ clone(): Cell;
5366
+ }
5367
+ /**
5368
+ * @public
5369
+ */
5370
+ type SinceLike = {
5371
+ relative: "absolute" | "relative";
5372
+ metric: "blockNumber" | "epoch" | "timestamp";
5373
+ value: NumLike;
5374
+ } | NumLike;
5375
+ declare const Since_base: (abstract new () => {
4994
5376
  toBytes(): Bytes$1;
4995
- clone(): WitnessArgs;
4996
- eq(other: WitnessArgsLike): boolean;
5377
+ clone(): Since;
5378
+ eq(other: SinceLike): boolean;
4997
5379
  hash(): Hex;
4998
5380
  toHex(): Hex;
4999
5381
  }) & {
5000
5382
  byteLength?: number;
5001
- encode(_: WitnessArgsLike): Bytes$1;
5002
- decode(_: BytesLike): WitnessArgs;
5003
- fromBytes(_bytes: BytesLike): WitnessArgs;
5004
- from(_: WitnessArgsLike): WitnessArgs;
5383
+ encode(_: SinceLike): Bytes$1;
5384
+ decode(_: BytesLike): Since;
5385
+ fromBytes(_bytes: BytesLike): Since;
5386
+ from(_: SinceLike): Since;
5005
5387
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5006
5388
  toBytes(): Bytes$1;
5007
5389
  clone(): SubType;
@@ -5078,80 +5460,89 @@ declare const WitnessArgs_base: (abstract new () => {
5078
5460
  /**
5079
5461
  * @public
5080
5462
  */
5081
- declare class WitnessArgs extends WitnessArgs_base {
5082
- lock?: Hex | undefined;
5083
- inputType?: Hex | undefined;
5084
- outputType?: Hex | undefined;
5463
+ declare class Since extends Since_base {
5464
+ relative: "absolute" | "relative";
5465
+ metric: "blockNumber" | "epoch" | "timestamp";
5466
+ value: Num;
5085
5467
  /**
5086
- * Creates an instance of WitnessArgs.
5468
+ * Creates an instance of Since.
5087
5469
  *
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.
5470
+ * @param relative - Absolute or relative
5471
+ * @param metric - The metric of since
5472
+ * @param value - The value of since
5091
5473
  */
5092
- constructor(lock?: Hex | undefined, inputType?: Hex | undefined, outputType?: Hex | undefined);
5474
+ constructor(relative: "absolute" | "relative", metric: "blockNumber" | "epoch" | "timestamp", value: Num);
5093
5475
  /**
5094
- * Creates a WitnessArgs instance from a WitnessArgsLike object.
5476
+ * Clone a Since.
5095
5477
  *
5096
- * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.
5097
- * @returns A WitnessArgs instance.
5478
+ * @returns A cloned Since instance.
5098
5479
  *
5099
5480
  * @example
5100
5481
  * ```typescript
5101
- * const witnessArgs = WitnessArgs.from({
5102
- * lock: "0x...",
5103
- * inputType: "0x...",
5104
- * outputType: "0x..."
5105
- * });
5482
+ * const since1 = since0.clone();
5106
5483
  * ```
5107
5484
  */
5108
- static from(witnessArgs: WitnessArgsLike): WitnessArgs;
5485
+ clone(): Since;
5486
+ /**
5487
+ * Creates a Since instance from a SinceLike object.
5488
+ *
5489
+ * @param since - A SinceLike object or an instance of Since.
5490
+ * @returns A Since instance.
5491
+ *
5492
+ * @example
5493
+ * ```typescript
5494
+ * const since = Since.from("0x1234567812345678");
5495
+ * ```
5496
+ */
5497
+ static from(since: SinceLike): Since;
5498
+ /**
5499
+ * Converts the Since instance to num.
5500
+ *
5501
+ * @returns A num
5502
+ *
5503
+ * @example
5504
+ * ```typescript
5505
+ * const num = since.toNum();
5506
+ * ```
5507
+ */
5508
+ toNum(): Num;
5509
+ /**
5510
+ * Creates a Since instance from a num-like value.
5511
+ *
5512
+ * @param numLike - The num-like value to convert.
5513
+ * @returns A Since instance.
5514
+ *
5515
+ * @example
5516
+ * ```typescript
5517
+ * const since = Since.fromNum("0x0");
5518
+ * ```
5519
+ */
5520
+ static fromNum(numLike: NumLike): Since;
5109
5521
  }
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
5522
  /**
5132
5523
  * @public
5133
5524
  */
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;
5525
+ type CellInputLike = ({
5526
+ previousOutput: OutPointLike;
5527
+ } | {
5528
+ outPoint: OutPointLike;
5529
+ }) & {
5530
+ since?: SinceLike | NumLike | null;
5531
+ cellOutput?: CellOutputLike | null;
5532
+ outputData?: HexLike | null;
5142
5533
  };
5143
- declare const Transaction_base: (abstract new () => {
5534
+ declare const CellInput_base: (abstract new () => {
5144
5535
  toBytes(): Bytes$1;
5145
- clone(): Transaction;
5146
- eq(other: TransactionLike): boolean;
5536
+ clone(): CellInput;
5537
+ eq(other: CellInputLike): boolean;
5147
5538
  hash(): Hex;
5148
5539
  toHex(): Hex;
5149
5540
  }) & {
5150
5541
  byteLength?: number;
5151
- encode(_: TransactionLike): Bytes$1;
5152
- decode(_: BytesLike): Transaction;
5153
- fromBytes(_bytes: BytesLike): Transaction;
5154
- from(_: TransactionLike): Transaction;
5542
+ encode(_: CellInputLike): Bytes$1;
5543
+ decode(_: BytesLike): CellInput;
5544
+ fromBytes(_bytes: BytesLike): CellInput;
5545
+ from(_: CellInputLike): CellInput;
5155
5546
  Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5156
5547
  toBytes(): Bytes$1;
5157
5548
  clone(): SubType;
@@ -5228,269 +5619,710 @@ declare const Transaction_base: (abstract new () => {
5228
5619
  /**
5229
5620
  * @public
5230
5621
  */
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;
5622
+ declare class CellInput extends CellInput_base {
5623
+ previousOutput: OutPoint;
5624
+ since: Num;
5625
+ cellOutput?: CellOutput | undefined;
5626
+ outputData?: Hex | undefined;
5274
5627
  /**
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
5628
+ * Creates an instance of CellInput.
5304
5629
  *
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
5630
+ * @param previousOutput - The previous outpoint of the cell.
5631
+ * @param since - The since value of the cell input.
5632
+ * @param cellOutput - The optional cell output associated with the cell input.
5633
+ * @param outputData - The optional output data associated with the cell input.
5310
5634
  */
5311
- clone(): Transaction;
5635
+ constructor(previousOutput: OutPoint, since: Num, cellOutput?: CellOutput | undefined, outputData?: Hex | undefined);
5312
5636
  /**
5313
- * Creates a Transaction instance from a TransactionLike object.
5637
+ * Creates a CellInput instance from a CellInputLike object.
5314
5638
  *
5315
- * @param tx - A TransactionLike object or an instance of Transaction.
5316
- * @returns A Transaction instance.
5639
+ * @param cellInput - A CellInputLike object or an instance of CellInput.
5640
+ * @returns A CellInput instance.
5317
5641
  *
5318
5642
  * @example
5319
5643
  * ```typescript
5320
- * const transaction = Transaction.from({
5321
- * version: 0,
5322
- * cellDeps: [],
5323
- * headerDeps: [],
5324
- * inputs: [],
5325
- * outputs: [],
5326
- * outputsData: [],
5327
- * witnesses: []
5644
+ * const cellInput = CellInput.from({
5645
+ * previousOutput: { txHash: "0x...", index: 0 },
5646
+ * since: 0n
5328
5647
  * });
5329
5648
  * ```
5330
5649
  */
5331
- static from(tx: TransactionLike): Transaction;
5650
+ static from(cellInput: CellInputLike): CellInput;
5651
+ getCell(client: Client): Promise<Cell>;
5332
5652
  /**
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.
5653
+ * Complete extra infos in the input. Including
5654
+ * - Previous cell output
5655
+ * - Previous cell data
5656
+ * The instance will be modified.
5339
5657
  *
5658
+ * @returns true if succeed.
5340
5659
  * @example
5341
5660
  * ```typescript
5342
- * const transaction = Transaction.fromLumosSkeleton(skeleton);
5661
+ * await cellInput.completeExtraInfos(client);
5343
5662
  * ```
5344
5663
  */
5345
- static fromLumosSkeleton(skeleton: LumosTransactionSkeletonType): Transaction;
5664
+ completeExtraInfos(client: Client): Promise<void>;
5346
5665
  /**
5347
- * @deprecated
5348
- * Use ccc.stringify instead.
5349
- * stringify the tx to JSON string.
5666
+ * The extra capacity created when consume this input.
5667
+ * This is usually NervosDAO interest, see https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0023-dao-deposit-withdraw/0023-dao-deposit-withdraw.md.
5668
+ * And it can also be miners' income. (But this is not implemented yet)
5350
5669
  */
5351
- stringify(): string;
5670
+ getExtraCapacity(client: Client): Promise<Num>;
5352
5671
  /**
5353
- * Converts the raw transaction data to bytes.
5672
+ * Clone a CellInput.
5354
5673
  *
5355
- * @returns A Uint8Array containing the raw transaction bytes.
5674
+ * @returns A cloned CellInput instance.
5356
5675
  *
5357
5676
  * @example
5358
5677
  * ```typescript
5359
- * const rawTxBytes = transaction.rawToBytes();
5678
+ * const cellInput1 = cellInput0.clone();
5360
5679
  * ```
5361
5680
  */
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.
5681
+ clone(): CellInput;
5682
+ }
5683
+ declare const CellInputVec: Codec<CellInputLike[], CellInput[]>;
5684
+ /**
5685
+ * @public
5686
+ */
5687
+ type CellDepLike = {
5688
+ outPoint: OutPointLike;
5689
+ depType: DepTypeLike;
5690
+ };
5691
+ declare const CellDep_base: (abstract new () => {
5692
+ toBytes(): Bytes$1;
5693
+ clone(): CellDep;
5694
+ eq(other: CellDepLike): boolean;
5695
+ hash(): Hex;
5696
+ toHex(): Hex;
5697
+ }) & {
5698
+ byteLength?: number;
5699
+ encode(_: CellDepLike): Bytes$1;
5700
+ decode(_: BytesLike): CellDep;
5701
+ fromBytes(_bytes: BytesLike): CellDep;
5702
+ from(_: CellDepLike): CellDep;
5703
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5704
+ toBytes(): Bytes$1;
5705
+ clone(): SubType;
5706
+ eq(other: SubTypeLike): boolean;
5707
+ hash(): Hex;
5708
+ toHex(): Hex;
5709
+ }) & {
5710
+ byteLength?: number;
5711
+ encode(_: SubTypeLike): Bytes$1;
5712
+ decode(_: BytesLike): SubType;
5713
+ fromBytes(_bytes: BytesLike): SubType;
5714
+ from(_: SubTypeLike): SubType;
5715
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5716
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
5717
+ readonly inner: DecodedType<CodecType>;
5718
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5719
+ _?: undefined | null;
5720
+ }): Result;
5721
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5722
+ _: (inner: DecodedType<CodecType>) => Result;
5723
+ }): Result;
5724
+ toBytes(): Bytes$1;
5725
+ clone(): SubType_1;
5726
+ eq(other: SubTypeLike_1): boolean;
5727
+ hash(): Hex;
5728
+ toHex(): Hex;
5729
+ }) & {
5730
+ byteLength?: number;
5731
+ encode(_: SubTypeLike_1): Bytes$1;
5732
+ decode(_: BytesLike): SubType_1;
5733
+ fromBytes(_bytes: BytesLike): SubType_1;
5734
+ from(_: SubTypeLike_1): SubType_1;
5735
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5736
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5737
+ };
5738
+ };
5739
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
5740
+ readonly inner: DecodedType<CodecType>;
5741
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5742
+ _?: undefined | null;
5743
+ }): Result;
5744
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5745
+ _: (inner: DecodedType<CodecType>) => Result;
5746
+ }): Result;
5747
+ toBytes(): Bytes$1;
5748
+ clone(): SubType;
5749
+ eq(other: SubTypeLike): boolean;
5750
+ hash(): Hex;
5751
+ toHex(): Hex;
5752
+ }) & {
5753
+ byteLength?: number;
5754
+ encode(_: SubTypeLike): Bytes$1;
5755
+ decode(_: BytesLike): SubType;
5756
+ fromBytes(_bytes: BytesLike): SubType;
5757
+ from(_: SubTypeLike): SubType;
5758
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
5759
+ toBytes(): Bytes$1;
5760
+ clone(): SubType_1;
5761
+ eq(other: SubTypeLike_1): boolean;
5762
+ hash(): Hex;
5763
+ toHex(): Hex;
5764
+ }) & {
5765
+ byteLength?: number;
5766
+ encode(_: SubTypeLike_1): Bytes$1;
5767
+ decode(_: BytesLike): SubType_1;
5768
+ fromBytes(_bytes: BytesLike): SubType_1;
5769
+ from(_: SubTypeLike_1): SubType_1;
5770
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5771
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5772
+ };
5773
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5774
+ };
5775
+ };
5776
+ /**
5777
+ * @public
5778
+ */
5779
+ declare class CellDep extends CellDep_base {
5780
+ outPoint: OutPoint;
5781
+ depType: DepType;
5782
+ /**
5783
+ * Creates an instance of CellDep.
5368
5784
  *
5369
- * @example
5370
- * ```typescript
5371
- * const txHash = transaction.hash();
5372
- * ```
5785
+ * @param outPoint - The outpoint of the cell dependency.
5786
+ * @param depType - The dependency type.
5373
5787
  */
5374
- hash(): Hex;
5788
+ constructor(outPoint: OutPoint, depType: DepType);
5375
5789
  /**
5376
- * Calculates the hash of the transaction with witnesses.
5790
+ * Creates a CellDep instance from a CellDepLike object.
5377
5791
  *
5378
- * @returns The hash of the transaction with witnesses.
5792
+ * @param cellDep - A CellDepLike object or an instance of CellDep.
5793
+ * @returns A CellDep instance.
5379
5794
  *
5380
5795
  * @example
5381
5796
  * ```typescript
5382
- * const txFullHash = transaction.hashFull();
5797
+ * const cellDep = CellDep.from({
5798
+ * outPoint: { txHash: "0x...", index: 0 },
5799
+ * depType: "depGroup"
5800
+ * });
5383
5801
  * ```
5384
5802
  */
5385
- hashFull(): Hex;
5803
+ static from(cellDep: CellDepLike): CellDep;
5386
5804
  /**
5387
- * Hashes a witness and updates the hasher.
5805
+ * Clone a CellDep.
5388
5806
  *
5389
- * @param witness - The witness to hash.
5390
- * @param hasher - The hasher instance to update.
5807
+ * @returns A cloned CellDep instance.
5391
5808
  *
5392
5809
  * @example
5393
5810
  * ```typescript
5394
- * Transaction.hashWitnessToHasher("0x...", hasher);
5811
+ * const cellDep1 = cellDep0.clone();
5395
5812
  * ```
5396
5813
  */
5397
- static hashWitnessToHasher(witness: HexLike, hasher: Hasher): void;
5814
+ clone(): CellDep;
5815
+ }
5816
+ declare const CellDepVec: Codec<CellDepLike[], CellDep[]>;
5817
+ /**
5818
+ * @public
5819
+ */
5820
+ type WitnessArgsLike = {
5821
+ lock?: HexLike | null;
5822
+ inputType?: HexLike | null;
5823
+ outputType?: HexLike | null;
5824
+ };
5825
+ declare const WitnessArgs_base: (abstract new () => {
5826
+ toBytes(): Bytes$1;
5827
+ clone(): WitnessArgs;
5828
+ eq(other: WitnessArgsLike): boolean;
5829
+ hash(): Hex;
5830
+ toHex(): Hex;
5831
+ }) & {
5832
+ byteLength?: number;
5833
+ encode(_: WitnessArgsLike): Bytes$1;
5834
+ decode(_: BytesLike): WitnessArgs;
5835
+ fromBytes(_bytes: BytesLike): WitnessArgs;
5836
+ from(_: WitnessArgsLike): WitnessArgs;
5837
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5838
+ toBytes(): Bytes$1;
5839
+ clone(): SubType;
5840
+ eq(other: SubTypeLike): boolean;
5841
+ hash(): Hex;
5842
+ toHex(): Hex;
5843
+ }) & {
5844
+ byteLength?: number;
5845
+ encode(_: SubTypeLike): Bytes$1;
5846
+ decode(_: BytesLike): SubType;
5847
+ fromBytes(_bytes: BytesLike): SubType;
5848
+ from(_: SubTypeLike): SubType;
5849
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5850
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
5851
+ readonly inner: DecodedType<CodecType>;
5852
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5853
+ _?: undefined | null;
5854
+ }): Result;
5855
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5856
+ _: (inner: DecodedType<CodecType>) => Result;
5857
+ }): Result;
5858
+ toBytes(): Bytes$1;
5859
+ clone(): SubType_1;
5860
+ eq(other: SubTypeLike_1): boolean;
5861
+ hash(): Hex;
5862
+ toHex(): Hex;
5863
+ }) & {
5864
+ byteLength?: number;
5865
+ encode(_: SubTypeLike_1): Bytes$1;
5866
+ decode(_: BytesLike): SubType_1;
5867
+ fromBytes(_bytes: BytesLike): SubType_1;
5868
+ from(_: SubTypeLike_1): SubType_1;
5869
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5870
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5871
+ };
5872
+ };
5873
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
5874
+ readonly inner: DecodedType<CodecType>;
5875
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
5876
+ _?: undefined | null;
5877
+ }): Result;
5878
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
5879
+ _: (inner: DecodedType<CodecType>) => Result;
5880
+ }): Result;
5881
+ toBytes(): Bytes$1;
5882
+ clone(): SubType;
5883
+ eq(other: SubTypeLike): boolean;
5884
+ hash(): Hex;
5885
+ toHex(): Hex;
5886
+ }) & {
5887
+ byteLength?: number;
5888
+ encode(_: SubTypeLike): Bytes$1;
5889
+ decode(_: BytesLike): SubType;
5890
+ fromBytes(_bytes: BytesLike): SubType;
5891
+ from(_: SubTypeLike): SubType;
5892
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
5893
+ toBytes(): Bytes$1;
5894
+ clone(): SubType_1;
5895
+ eq(other: SubTypeLike_1): boolean;
5896
+ hash(): Hex;
5897
+ toHex(): Hex;
5898
+ }) & {
5899
+ byteLength?: number;
5900
+ encode(_: SubTypeLike_1): Bytes$1;
5901
+ decode(_: BytesLike): SubType_1;
5902
+ fromBytes(_bytes: BytesLike): SubType_1;
5903
+ from(_: SubTypeLike_1): SubType_1;
5904
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
5905
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5906
+ };
5907
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
5908
+ };
5909
+ };
5910
+ /**
5911
+ * @public
5912
+ */
5913
+ declare class WitnessArgs extends WitnessArgs_base {
5914
+ lock?: Hex | undefined;
5915
+ inputType?: Hex | undefined;
5916
+ outputType?: Hex | undefined;
5398
5917
  /**
5399
- * Computes the signing hash information for a given script.
5918
+ * Creates an instance of WitnessArgs.
5400
5919
  *
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.
5920
+ * @param lock - The optional lock field of the witness.
5921
+ * @param inputType - The optional input type field of the witness.
5922
+ * @param outputType - The optional output type field of the witness.
5923
+ */
5924
+ constructor(lock?: Hex | undefined, inputType?: Hex | undefined, outputType?: Hex | undefined);
5925
+ /**
5926
+ * Creates a WitnessArgs instance from a WitnessArgsLike object.
5927
+ *
5928
+ * @param witnessArgs - A WitnessArgsLike object or an instance of WitnessArgs.
5929
+ * @returns A WitnessArgs instance.
5405
5930
  *
5406
5931
  * @example
5407
5932
  * ```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
- * }
5933
+ * const witnessArgs = WitnessArgs.from({
5934
+ * lock: "0x...",
5935
+ * inputType: "0x...",
5936
+ * outputType: "0x..."
5937
+ * });
5413
5938
  * ```
5414
5939
  */
5415
- getSignHashInfo(scriptLike: ScriptLike, client: Client, hasher?: Hasher): Promise<{
5416
- message: Hex;
5417
- position: number;
5418
- } | undefined>;
5940
+ static from(witnessArgs: WitnessArgsLike): WitnessArgs;
5941
+ }
5942
+ /**
5943
+ * Convert a bytes to a num.
5944
+ *
5945
+ * @public
5946
+ */
5947
+ declare function udtBalanceFrom(dataLike: BytesLike): Num;
5948
+ declare const RawTransaction: Codec<EncodableRecord<{
5949
+ version: Codec<NumLike, number>;
5950
+ cellDeps: Codec<CellDepLike[], CellDep[]>;
5951
+ headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5952
+ inputs: Codec<CellInputLike[], CellInput[]>;
5953
+ outputs: Codec<CellOutputLike[], CellOutput[]>;
5954
+ outputsData: Codec<BytesLike[], `0x${string}`[]>;
5955
+ }>, DecodedRecord<{
5956
+ version: Codec<NumLike, number>;
5957
+ cellDeps: Codec<CellDepLike[], CellDep[]>;
5958
+ headerDeps: Codec<BytesLike[], `0x${string}`[]>;
5959
+ inputs: Codec<CellInputLike[], CellInput[]>;
5960
+ outputs: Codec<CellOutputLike[], CellOutput[]>;
5961
+ outputsData: Codec<BytesLike[], `0x${string}`[]>;
5962
+ }>>;
5963
+ /**
5964
+ * @public
5965
+ */
5966
+ type TransactionLike = {
5967
+ version?: NumLike | null;
5968
+ cellDeps?: CellDepLike[] | null;
5969
+ headerDeps?: HexLike[] | null;
5970
+ inputs?: CellInputLike[] | null;
5971
+ outputs?: (Omit<CellOutputLike, "capacity"> & Partial<Pick<CellOutputLike, "capacity">>)[] | null;
5972
+ outputsData?: HexLike[] | null;
5973
+ witnesses?: HexLike[] | null;
5974
+ };
5975
+ declare const Transaction_base: (abstract new () => {
5976
+ toBytes(): Bytes$1;
5977
+ clone(): Transaction;
5978
+ eq(other: TransactionLike): boolean;
5979
+ hash(): Hex;
5980
+ toHex(): Hex;
5981
+ }) & {
5982
+ byteLength?: number;
5983
+ encode(_: TransactionLike): Bytes$1;
5984
+ decode(_: BytesLike): Transaction;
5985
+ fromBytes(_bytes: BytesLike): Transaction;
5986
+ from(_: TransactionLike): Transaction;
5987
+ Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
5988
+ toBytes(): Bytes$1;
5989
+ clone(): SubType;
5990
+ eq(other: SubTypeLike): boolean;
5991
+ hash(): Hex;
5992
+ toHex(): Hex;
5993
+ }) & {
5994
+ byteLength?: number;
5995
+ encode(_: SubTypeLike): Bytes$1;
5996
+ decode(_: BytesLike): SubType;
5997
+ fromBytes(_bytes: BytesLike): SubType;
5998
+ from(_: SubTypeLike): SubType;
5999
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6000
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new (inner: DecodedType<CodecType>) => {
6001
+ readonly inner: DecodedType<CodecType>;
6002
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
6003
+ _?: undefined | null;
6004
+ }): Result;
6005
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
6006
+ _: (inner: DecodedType<CodecType>) => Result;
6007
+ }): Result;
6008
+ toBytes(): Bytes$1;
6009
+ clone(): SubType_1;
6010
+ eq(other: SubTypeLike_1): boolean;
6011
+ hash(): Hex;
6012
+ toHex(): Hex;
6013
+ }) & {
6014
+ byteLength?: number;
6015
+ encode(_: SubTypeLike_1): Bytes$1;
6016
+ decode(_: BytesLike): SubType_1;
6017
+ fromBytes(_bytes: BytesLike): SubType_1;
6018
+ from(_: SubTypeLike_1): SubType_1;
6019
+ Base<SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6020
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
6021
+ };
6022
+ };
6023
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): (abstract new (inner: DecodedType<CodecType>) => {
6024
+ readonly inner: DecodedType<CodecType>;
6025
+ match<Result>(handlers: UnionMatchHandlers<CodecType, Result> & {
6026
+ _?: undefined | null;
6027
+ }): Result;
6028
+ match<Result>(handlers: Partial<UnionMatchHandlers<CodecType, Result>> & {
6029
+ _: (inner: DecodedType<CodecType>) => Result;
6030
+ }): Result;
6031
+ toBytes(): Bytes$1;
6032
+ clone(): SubType;
6033
+ eq(other: SubTypeLike): boolean;
6034
+ hash(): Hex;
6035
+ toHex(): Hex;
6036
+ }) & {
6037
+ byteLength?: number;
6038
+ encode(_: SubTypeLike): Bytes$1;
6039
+ decode(_: BytesLike): SubType;
6040
+ fromBytes(_bytes: BytesLike): SubType;
6041
+ from(_: SubTypeLike): SubType;
6042
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): (abstract new () => {
6043
+ toBytes(): Bytes$1;
6044
+ clone(): SubType_1;
6045
+ eq(other: SubTypeLike_1): boolean;
6046
+ hash(): Hex;
6047
+ toHex(): Hex;
6048
+ }) & {
6049
+ byteLength?: number;
6050
+ encode(_: SubTypeLike_1): Bytes$1;
6051
+ decode(_: BytesLike): SubType_1;
6052
+ fromBytes(_bytes: BytesLike): SubType_1;
6053
+ from(_: SubTypeLike_1): SubType_1;
6054
+ Base<SubTypeLike_1, SubType_1 = SubTypeLike_1>(): /*elided*/ any;
6055
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6056
+ };
6057
+ BaseUnion<CodecType extends CodecLike<any, UnionDecoded<any, any>>, SubTypeLike, SubType = SubTypeLike>(): /*elided*/ any;
6058
+ };
6059
+ };
6060
+ /**
6061
+ * @public
6062
+ */
6063
+ declare class Transaction extends Transaction_base {
6064
+ version: Num;
6065
+ cellDeps: CellDep[];
6066
+ headerDeps: Hex[];
6067
+ inputs: CellInput[];
6068
+ outputs: CellOutput[];
6069
+ outputsData: Hex[];
6070
+ witnesses: Hex[];
5419
6071
  /**
5420
- * Find the first occurrence of a input with the specified lock id
6072
+ * Creates an instance of Transaction.
5421
6073
  *
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
6074
+ * @param version - The version of the transaction.
6075
+ * @param cellDeps - The cell dependencies of the transaction.
6076
+ * @param headerDeps - The header dependencies of the transaction.
6077
+ * @param inputs - The inputs of the transaction.
6078
+ * @param outputs - The outputs of the transaction.
6079
+ * @param outputsData - The data associated with the outputs.
6080
+ * @param witnesses - The witnesses of the transaction.
6081
+ */
6082
+ constructor(version: Num, cellDeps: CellDep[], headerDeps: Hex[], inputs: CellInput[], outputs: CellOutput[], outputsData: Hex[], witnesses: Hex[]);
6083
+ /**
6084
+ * Creates a default Transaction instance with empty fields.
6085
+ *
6086
+ * @returns A default Transaction instance.
5425
6087
  *
5426
6088
  * @example
5427
6089
  * ```typescript
5428
- * const index = await tx.findInputIndexByLockId(scriptIdLike, client);
6090
+ * const defaultTx = Transaction.default();
5429
6091
  * ```
5430
6092
  */
5431
- findInputIndexByLockId(scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">, client: Client): Promise<number | undefined>;
6093
+ static default(): Transaction;
5432
6094
  /**
5433
- * Find the first occurrence of a input with the specified lock
6095
+ * Copy every properties from another transaction.
6096
+ * This method replaces all properties of the current transaction with those from the provided transaction.
5434
6097
  *
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.
6098
+ * @param txLike - The transaction-like object to copy properties from.
5438
6099
  *
5439
6100
  * @example
5440
6101
  * ```typescript
5441
- * const index = await tx.findInputIndexByLock(scriptLike, client);
6102
+ * this.copy(Transaction.default());
5442
6103
  * ```
5443
6104
  */
5444
- findInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6105
+ copy(txLike: TransactionLike): void;
5445
6106
  /**
5446
- * Find the last occurrence of a input with the specified lock
6107
+ * Creates a deep copy of the transaction.
6108
+ * This method creates a new Transaction instance with all nested objects cloned,
6109
+ * ensuring that modifications to the cloned transaction do not affect the original.
5447
6110
  *
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.
6111
+ * @returns A new Transaction instance that is a deep copy of the current transaction.
5451
6112
  *
5452
6113
  * @example
5453
6114
  * ```typescript
5454
- * const index = await tx.findLastInputIndexByLock(scriptLike, client);
6115
+ * const originalTx = Transaction.from({
6116
+ * version: 0,
6117
+ * inputs: [{ previousOutput: { txHash: "0x...", index: 0 } }],
6118
+ * outputs: [{ capacity: 1000n, lock: lockScript }],
6119
+ * outputsData: ["0x"],
6120
+ * witnesses: ["0x"]
6121
+ * });
6122
+ *
6123
+ * const clonedTx = originalTx.clone();
6124
+ *
6125
+ * // Modifications to clonedTx won't affect originalTx
6126
+ * clonedTx.addOutput({ capacity: 2000n, lock: anotherLockScript });
6127
+ * console.log(originalTx.outputs.length); // Still 1
6128
+ * console.log(clonedTx.outputs.length); // Now 2
5455
6129
  * ```
6130
+ *
6131
+ * @remarks
6132
+ * The clone operation performs deep copying for:
6133
+ * - Cell dependencies (cellDeps) - each CellDep is cloned
6134
+ * - Inputs - each CellInput is cloned
6135
+ * - Outputs - each CellOutput is cloned
6136
+ *
6137
+ * The following are shallow copied (references to immutable data):
6138
+ * - Header dependencies (headerDeps) - Hex strings are immutable
6139
+ * - Output data (outputsData) - Hex strings are immutable
6140
+ * - Witnesses - Hex strings are immutable
6141
+ * - Version - bigint is immutable
5456
6142
  */
5457
- findLastInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6143
+ clone(): Transaction;
5458
6144
  /**
5459
- * Add cell deps if they are not existed
6145
+ * Creates a Transaction instance from a TransactionLike object.
5460
6146
  *
5461
- * @param cellDepLikes - The cell deps to add
6147
+ * @param tx - A TransactionLike object or an instance of Transaction.
6148
+ * @returns A Transaction instance.
5462
6149
  *
5463
6150
  * @example
5464
6151
  * ```typescript
5465
- * tx.addCellDeps(cellDep);
6152
+ * const transaction = Transaction.from({
6153
+ * version: 0,
6154
+ * cellDeps: [],
6155
+ * headerDeps: [],
6156
+ * inputs: [],
6157
+ * outputs: [],
6158
+ * outputsData: [],
6159
+ * witnesses: []
6160
+ * });
5466
6161
  * ```
5467
6162
  */
5468
- addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6163
+ static from(tx: TransactionLike): Transaction;
5469
6164
  /**
5470
- * Add cell deps at the start if they are not existed
6165
+ * Creates a Transaction instance from a Lumos skeleton.
5471
6166
  *
5472
- * @param cellDepLikes - The cell deps to add
6167
+ * @param skeleton - The Lumos transaction skeleton.
6168
+ * @returns A Transaction instance.
6169
+ *
6170
+ * @throws Will throw an error if an input's outPoint is missing.
5473
6171
  *
5474
6172
  * @example
5475
6173
  * ```typescript
5476
- * tx.addCellDepsAtBegin(cellDep);
6174
+ * const transaction = Transaction.fromLumosSkeleton(skeleton);
5477
6175
  * ```
5478
6176
  */
5479
- addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6177
+ static fromLumosSkeleton(skeleton: LumosTransactionSkeletonType): Transaction;
5480
6178
  /**
5481
- * Add cell dep from infos if they are not existed
6179
+ * @deprecated
6180
+ * Use ccc.stringify instead.
6181
+ * stringify the tx to JSON string.
6182
+ */
6183
+ stringify(): string;
6184
+ /**
6185
+ * Converts the raw transaction data to bytes.
5482
6186
  *
5483
- * @param client - A client for searching cell deps
5484
- * @param cellDepInfoLikes - The cell dep infos to add
6187
+ * @returns A Uint8Array containing the raw transaction bytes.
5485
6188
  *
5486
6189
  * @example
5487
6190
  * ```typescript
5488
- * tx.addCellDepInfos(client, cellDepInfos);
6191
+ * const rawTxBytes = transaction.rawToBytes();
5489
6192
  * ```
5490
6193
  */
5491
- addCellDepInfos(client: Client, ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<void>;
6194
+ rawToBytes(): Bytes$1;
5492
6195
  /**
5493
- * Add cell deps from known script
6196
+ * Calculates the hash of the transaction without witnesses. This is the transaction hash in the usual sense.
6197
+ * To calculate the hash of the whole transaction including the witnesses, use transaction.hashFull() instead.
6198
+ *
6199
+ * @returns The hash of the transaction.
6200
+ *
6201
+ * @example
6202
+ * ```typescript
6203
+ * const txHash = transaction.hash();
6204
+ * ```
6205
+ */
6206
+ hash(): Hex;
6207
+ /**
6208
+ * Calculates the hash of the transaction with witnesses.
6209
+ *
6210
+ * @returns The hash of the transaction with witnesses.
6211
+ *
6212
+ * @example
6213
+ * ```typescript
6214
+ * const txFullHash = transaction.hashFull();
6215
+ * ```
6216
+ */
6217
+ hashFull(): Hex;
6218
+ /**
6219
+ * Hashes a witness and updates the hasher.
6220
+ *
6221
+ * @param witness - The witness to hash.
6222
+ * @param hasher - The hasher instance to update.
6223
+ *
6224
+ * @example
6225
+ * ```typescript
6226
+ * Transaction.hashWitnessToHasher("0x...", hasher);
6227
+ * ```
6228
+ */
6229
+ static hashWitnessToHasher(witness: HexLike, hasher: Hasher): void;
6230
+ /**
6231
+ * Computes the signing hash information for a given script.
6232
+ *
6233
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6234
+ * @param client - The client for complete extra infos in the transaction.
6235
+ * @returns A promise that resolves to an object containing the signing message and the witness position,
6236
+ * or undefined if no matching input is found.
6237
+ *
6238
+ * @example
6239
+ * ```typescript
6240
+ * const signHashInfo = await tx.getSignHashInfo(scriptLike, client);
6241
+ * if (signHashInfo) {
6242
+ * console.log(signHashInfo.message); // Outputs the signing message
6243
+ * console.log(signHashInfo.position); // Outputs the witness position
6244
+ * }
6245
+ * ```
6246
+ */
6247
+ getSignHashInfo(scriptLike: ScriptLike, client: Client, hasher?: Hasher): Promise<{
6248
+ message: Hex;
6249
+ position: number;
6250
+ } | undefined>;
6251
+ /**
6252
+ * Find the first occurrence of a input with the specified lock id
6253
+ *
6254
+ * @param scriptIdLike - The script associated with the transaction, represented as a ScriptLike object without args.
6255
+ * @param client - The client for complete extra infos in the transaction.
6256
+ * @returns A promise that resolves to the found index
6257
+ *
6258
+ * @example
6259
+ * ```typescript
6260
+ * const index = await tx.findInputIndexByLockId(scriptIdLike, client);
6261
+ * ```
6262
+ */
6263
+ findInputIndexByLockId(scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">, client: Client): Promise<number | undefined>;
6264
+ /**
6265
+ * Find the first occurrence of a input with the specified lock
6266
+ *
6267
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6268
+ * @param client - The client for complete extra infos in the transaction.
6269
+ * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6270
+ *
6271
+ * @example
6272
+ * ```typescript
6273
+ * const index = await tx.findInputIndexByLock(scriptLike, client);
6274
+ * ```
6275
+ */
6276
+ findInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6277
+ /**
6278
+ * Find the last occurrence of a input with the specified lock
6279
+ *
6280
+ * @param scriptLike - The script associated with the transaction, represented as a ScriptLike object.
6281
+ * @param client - The client for complete extra infos in the transaction.
6282
+ * @returns A promise that resolves to the found index, or undefined if no matching input is found.
6283
+ *
6284
+ * @example
6285
+ * ```typescript
6286
+ * const index = await tx.findLastInputIndexByLock(scriptLike, client);
6287
+ * ```
6288
+ */
6289
+ findLastInputIndexByLock(scriptLike: ScriptLike, client: Client): Promise<number | undefined>;
6290
+ /**
6291
+ * Add cell deps if they are not existed
6292
+ *
6293
+ * @param cellDepLikes - The cell deps to add
6294
+ *
6295
+ * @example
6296
+ * ```typescript
6297
+ * tx.addCellDeps(cellDep);
6298
+ * ```
6299
+ */
6300
+ addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6301
+ /**
6302
+ * Add cell deps at the start if they are not existed
6303
+ *
6304
+ * @param cellDepLikes - The cell deps to add
6305
+ *
6306
+ * @example
6307
+ * ```typescript
6308
+ * tx.addCellDepsAtBegin(cellDep);
6309
+ * ```
6310
+ */
6311
+ addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void;
6312
+ /**
6313
+ * Add cell dep from infos if they are not existed
6314
+ *
6315
+ * @param client - A client for searching cell deps
6316
+ * @param cellDepInfoLikes - The cell dep infos to add
6317
+ *
6318
+ * @example
6319
+ * ```typescript
6320
+ * tx.addCellDepInfos(client, cellDepInfos);
6321
+ * ```
6322
+ */
6323
+ addCellDepInfos(client: Client, ...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]): Promise<void>;
6324
+ /**
6325
+ * Add cell deps from known script
5494
6326
  *
5495
6327
  * @param client - The client for searching known script and cell deps
5496
6328
  * @param scripts - The known scripts to add
@@ -6082,571 +6914,98 @@ declare abstract class ClientCache {
6082
6914
  */
6083
6915
  recordHeaders(..._headers: (ClientBlockHeaderLike | ClientBlockHeaderLike[])[]): Promise<void>;
6084
6916
  /**
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
- * ```
6917
+ * Get a known block header by hash
6918
+ * Implement this method to enable block headers query caching
6919
+ * @param _hash
6448
6920
  */
6449
- findCellsByType(type: ScriptLike, withData?: boolean, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
6450
- findSingletonCellByType(type: ScriptLike, withData?: boolean): Promise<Cell | undefined>;
6921
+ getHeaderByHash(_hash: HexLike): Promise<ClientBlockHeader | undefined>;
6451
6922
  /**
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
- * ```
6923
+ * Get a known block header by number
6924
+ * Implement this method to enable block headers query caching
6925
+ * @param _number
6468
6926
  */
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]>;
6927
+ getHeaderByNumber(_number: NumLike): Promise<ClientBlockHeader | undefined>;
6484
6928
  /**
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
- * ```
6929
+ * Record known blocks.
6930
+ * Implement this method to enable blocks query caching
6931
+ * @param _blocks
6506
6932
  */
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>;
6933
+ recordBlocks(..._blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6514
6934
  /**
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
- * ```
6935
+ * Get a known block header by hash
6936
+ * Implement this method to enable block headers query caching
6937
+ * @param _hash
6533
6938
  */
6534
- getBalanceSingle(lock: ScriptLike): Promise<Num>;
6939
+ getBlockByHash(_hash: HexLike): Promise<ClientBlock | undefined>;
6535
6940
  /**
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
- * ```
6941
+ * Get a known block header by number
6942
+ * Implement this method to enable block headers query caching
6943
+ * @param _number
6555
6944
  */
6556
- getBalance(locks: ScriptLike[]): Promise<Num>;
6945
+ getBlockByNumber(_number: NumLike): Promise<ClientBlock | undefined>;
6557
6946
  /**
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
- * ```
6947
+ * Checks if a block header is considered confirmed.
6948
+ * The default implementation compares the header's timestamp against the current time
6949
+ * and a configured confirmation time. Override this method for custom confirmation logic.
6950
+ * @param header
6584
6951
  */
6585
- sendTransaction(transaction: TransactionLike, validator?: OutputsValidator, options?: {
6586
- maxFeeRate?: NumLike;
6587
- }): Promise<Hex>;
6952
+ hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6953
+ }
6954
+ //#endregion
6955
+ //#region src/client/cache/memory.d.ts
6956
+ declare class ClientCacheMemory extends ClientCache {
6957
+ private readonly maxCells;
6958
+ private readonly maxTxs;
6959
+ private readonly maxBlocks;
6588
6960
  /**
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
- * ```
6961
+ * OutPoint => [isLive, Cell | OutPoint]
6606
6962
  */
6607
- getTransaction(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
6963
+ private readonly cells;
6608
6964
  /**
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
6965
+ * TX Hash => Transaction Response
6612
6966
  */
6613
- getTransactionWithHeader(txHashLike: HexLike): Promise<{
6614
- transaction: ClientTransactionResponse;
6615
- header?: ClientBlockHeader;
6616
- } | undefined>;
6967
+ private readonly knownTransactions;
6617
6968
  /**
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
- * ```
6969
+ * Block Number => Block Hash
6643
6970
  */
6644
- waitTransaction(txHash: HexLike, confirmations?: number, timeout?: number, interval?: number): Promise<ClientTransactionResponse | undefined>;
6971
+ private readonly knownBlockHashes;
6972
+ /**
6973
+ * Block Hash => Block Header / Full Block
6974
+ */
6975
+ private readonly knownBlocks;
6976
+ private readonly confirmedBlockTime;
6977
+ /**
6978
+ * @param maxCells - Maximum number of cells to store in the cache. Defaults to 512.
6979
+ * @param maxTxs - Maximum number of transactions to store in the cache. Defaults to 256.
6980
+ * @param maxBlocks - Maximum number of blocks to store in the cache. Defaults to 128.
6981
+ * @param confirmedBlockTimeLike - Time in milliseconds after which a block is considered confirmed.
6982
+ * Defaults to DEFAULT_CONFIRMED_BLOCK_TIME (50 blocks * 10s).
6983
+ */
6984
+ constructor(maxCells?: number, maxTxs?: number, maxBlocks?: number, confirmedBlockTimeLike?: NumLike);
6985
+ markUsableNoCache(...cellLikes: (CellLike | CellLike[])[]): Promise<void>;
6986
+ markUnusable(...outPointLikes: (OutPointLike | OutPointLike[])[]): Promise<void>;
6987
+ clear(): Promise<void>;
6988
+ findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
6989
+ isUnusable(outPointLike: OutPointLike): Promise<boolean>;
6990
+ recordCells(...cells: (CellLike | CellLike[])[]): Promise<void>;
6991
+ getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
6992
+ recordTransactionResponses(...transactions: (ClientTransactionResponseLike | ClientTransactionResponseLike[])[]): Promise<void>;
6993
+ getTransactionResponse(txHashLike: HexLike): Promise<ClientTransactionResponse | undefined>;
6994
+ recordHeaders(...headers: (ClientBlockHeaderLike | ClientBlockHeaderLike[])[]): Promise<void>;
6995
+ getHeaderByHash(hashLike: HexLike): Promise<ClientBlockHeader | undefined>;
6996
+ getHeaderByNumber(numberLike: NumLike): Promise<ClientBlockHeader | undefined>;
6997
+ recordBlocks(...blocks: (ClientBlockLike | ClientBlockLike[])[]): Promise<void>;
6998
+ getBlockByHash(hashLike: HexLike): Promise<ClientBlock | undefined>;
6999
+ getBlockByNumber(numberLike: NumLike): Promise<ClientBlock | undefined>;
7000
+ hasHeaderConfirmed(header: ClientBlockHeader): boolean;
6645
7001
  }
6646
7002
  //#endregion
6647
7003
  //#region src/client/jsonRpc/client.d.ts
6648
- type ClientJsonRpcConfig = RequestorJsonRpcConfig & {
6649
- cache?: ClientCache;
7004
+ type ClientJsonRpcConfig = RequestorJsonRpcConfig & ClientConfig & {
7005
+ /**
7006
+ * @deprecated Requestor injection is supported only by legacy constructors.
7007
+ * Use a borrowed Transport with `Client.new` or let `Client.open` create one.
7008
+ */
6650
7009
  requestor?: RequestorJsonRpc;
6651
7010
  };
6652
7011
  /**
@@ -6654,18 +7013,26 @@ type ClientJsonRpcConfig = RequestorJsonRpcConfig & {
6654
7013
  * Provides methods for sending transactions and building JSON-RPC payloads.
6655
7014
  */
6656
7015
  declare abstract class ClientJsonRpc extends Client {
7016
+ private readonly url_;
6657
7017
  readonly requestor: RequestorJsonRpc;
6658
7018
  /**
6659
7019
  * Creates an instance of ClientJsonRpc.
6660
7020
  *
6661
7021
  * @param url_ - The URL of the JSON-RPC server.
6662
7022
  * @param timeout - The timeout for requests in milliseconds
7023
+ * @deprecated Use the concrete Client's `new` or `open` method.
6663
7024
  */
6664
7025
  constructor(url_: string, config?: ClientJsonRpcConfig);
7026
+ /** Creates a Requestor that borrows an existing Transport. */
7027
+ protected static newRequestor(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError">): RequestorJsonRpc;
7028
+ /** Opens a Requestor with ownership of its default Transport. */
7029
+ protected static openRequestor(config: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError">): Owner<RequestorJsonRpc>;
6665
7030
  /**
6666
- * Returns the URL of the JSON-RPC server.
7031
+ * Returns the legacy primary URL of the JSON-RPC server.
6667
7032
  *
6668
7033
  * @returns The URL of the JSON-RPC server.
7034
+ * @deprecated A Client may use multiple endpoints or a Transport without a
7035
+ * URL, so this value does not reliably identify its connection.
6669
7036
  */
6670
7037
  get url(): string;
6671
7038
  /**
@@ -6803,14 +7170,23 @@ declare abstract class ClientJsonRpc extends Client {
6803
7170
  * @public
6804
7171
  */
6805
7172
  declare class ClientPublicMainnet extends ClientJsonRpc {
6806
- private readonly config?;
6807
- constructor(config?: (ClientJsonRpcConfig & {
7173
+ private static defaultUrls;
7174
+ private static resolveConfig;
7175
+ /**
7176
+ * @deprecated Use {@link ClientPublicMainnet.new} with a borrowed Transport or
7177
+ * {@link ClientPublicMainnet.open} when creating Transports.
7178
+ */
7179
+ constructor(config?: ClientJsonRpcConfig & {
7180
+ /** @deprecated URL belongs to Transport construction. */
6808
7181
  url?: string;
6809
- scripts?: Record<KnownScript, ScriptInfoLike | undefined>;
6810
- }) | undefined);
6811
- get scripts(): Record<KnownScript, ScriptInfoLike | undefined>;
7182
+ });
7183
+ /** Creates a Client that borrows an existing Transport. */
7184
+ static new(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError"> & ClientConfig): ClientPublicMainnet;
7185
+ /** Opens a Client with explicit ownership of its default dependencies. */
7186
+ static open(config?: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError" | "urls"> & ClientConfig & {
7187
+ urls?: Parameters<typeof RequestorJsonRpc.open>[0]["urls"];
7188
+ }): Owner<ClientPublicMainnet>;
6812
7189
  get addressPrefix(): string;
6813
- getKnownScript(script: KnownScript): Promise<ScriptInfo>;
6814
7190
  }
6815
7191
  //#endregion
6816
7192
  //#region src/client/clientPublicTestnet.d.ts
@@ -6818,14 +7194,23 @@ declare class ClientPublicMainnet extends ClientJsonRpc {
6818
7194
  * @public
6819
7195
  */
6820
7196
  declare class ClientPublicTestnet extends ClientJsonRpc {
6821
- private readonly config?;
6822
- constructor(config?: (ClientJsonRpcConfig & {
7197
+ private static defaultUrls;
7198
+ private static resolveConfig;
7199
+ /**
7200
+ * @deprecated Use {@link ClientPublicTestnet.new} with a borrowed Transport or
7201
+ * {@link ClientPublicTestnet.open} when creating Transports.
7202
+ */
7203
+ constructor(config?: ClientJsonRpcConfig & {
7204
+ /** @deprecated URL belongs to Transport construction. */
6823
7205
  url?: string;
6824
- scripts?: Record<KnownScript, ScriptInfoLike | undefined>;
6825
- }) | undefined);
6826
- get scripts(): Record<KnownScript, ScriptInfoLike | undefined>;
7206
+ });
7207
+ /** Creates a Client that borrows an existing Transport. */
7208
+ static new(config: Omit<Parameters<typeof RequestorJsonRpc.new>[0], "onError"> & ClientConfig): ClientPublicTestnet;
7209
+ /** Opens a Client with explicit ownership of its default dependencies. */
7210
+ static open(config?: Omit<Parameters<typeof RequestorJsonRpc.open>[0], "onError" | "urls"> & ClientConfig & {
7211
+ urls?: Parameters<typeof RequestorJsonRpc.open>[0]["urls"];
7212
+ }): Owner<ClientPublicTestnet>;
6827
7213
  get addressPrefix(): string;
6828
- getKnownScript(script: KnownScript): Promise<ScriptInfo>;
6829
7214
  }
6830
7215
  //#endregion
6831
7216
  //#region src/address/address.advanced.d.ts
@@ -7104,9 +7489,14 @@ declare class JsonRpcTransformers {
7104
7489
  //#endregion
7105
7490
  //#region src/hasher/advanced.d.ts
7106
7491
  declare const CKB_BLAKE2B_PERSONAL: Bytes$1;
7492
+ //#endregion
7493
+ //#region src/jsonRpc/transports/factory.d.ts
7494
+ declare function jsonRpcTransportFromUri(uri: string, config?: {
7495
+ timeout?: number;
7496
+ }): OwnerUnique<JsonRpcTransportWebSocket> | OwnerUnique<JsonRpcTransportHttp>;
7107
7497
  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 };
7498
+ 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
7499
  }
7110
7500
  //#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
7501
+ 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 };
7502
+ //# sourceMappingURL=advancedBarrel-Di0YBlWc.d.mts.map