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