@ckb-ccc/core 1.9.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/ckb/hash.d.ts +18 -0
- package/dist/ckb/hash.d.ts.map +1 -0
- package/dist/ckb/hash.js +19 -0
- package/dist/ckb/index.d.ts +2 -0
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +2 -0
- package/dist/ckb/script.d.ts +12 -0
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/script.js +17 -0
- package/dist/ckb/transaction.d.ts +326 -25
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +354 -79
- package/dist/ckb/transactionErrors.d.ts +15 -0
- package/dist/ckb/transactionErrors.d.ts.map +1 -0
- package/dist/ckb/transactionErrors.js +21 -0
- package/dist/client/cache/cache.d.ts +7 -0
- package/dist/client/cache/cache.d.ts.map +1 -1
- package/dist/client/cache/cache.js +11 -0
- package/dist/client/cache/memory.advanced.d.ts +36 -3
- package/dist/client/cache/memory.advanced.d.ts.map +1 -1
- package/dist/client/cache/memory.advanced.js +53 -25
- package/dist/client/cache/memory.d.ts +10 -1
- package/dist/client/cache/memory.d.ts.map +1 -1
- package/dist/client/cache/memory.js +13 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +6 -9
- package/dist/client/clientTypes.advanced.d.ts +0 -1
- package/dist/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist/client/clientTypes.advanced.js +0 -1
- package/dist/hasher/hasherCkb.d.ts +0 -16
- package/dist/hasher/hasherCkb.d.ts.map +1 -1
- package/dist/hasher/hasherCkb.js +0 -18
- package/dist/molecule/codec.d.ts +30 -10
- package/dist/molecule/codec.d.ts.map +1 -1
- package/dist/molecule/codec.js +46 -13
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +18 -6
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +18 -6
- package/dist/signer/signer/index.d.ts +11 -1
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +23 -0
- package/dist.commonjs/ckb/hash.d.ts +18 -0
- package/dist.commonjs/ckb/hash.d.ts.map +1 -0
- package/dist.commonjs/ckb/hash.js +22 -0
- package/dist.commonjs/ckb/index.d.ts +2 -0
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +2 -0
- package/dist.commonjs/ckb/script.d.ts +12 -0
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.js +17 -0
- package/dist.commonjs/ckb/transaction.d.ts +326 -25
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +353 -78
- package/dist.commonjs/ckb/transactionErrors.d.ts +15 -0
- package/dist.commonjs/ckb/transactionErrors.d.ts.map +1 -0
- package/dist.commonjs/ckb/transactionErrors.js +26 -0
- package/dist.commonjs/client/cache/cache.d.ts +7 -0
- package/dist.commonjs/client/cache/cache.d.ts.map +1 -1
- package/dist.commonjs/client/cache/cache.js +11 -0
- package/dist.commonjs/client/cache/memory.advanced.d.ts +36 -3
- package/dist.commonjs/client/cache/memory.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/cache/memory.advanced.js +54 -26
- package/dist.commonjs/client/cache/memory.d.ts +10 -1
- package/dist.commonjs/client/cache/memory.d.ts.map +1 -1
- package/dist.commonjs/client/cache/memory.js +12 -1
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +5 -8
- package/dist.commonjs/client/clientTypes.advanced.d.ts +0 -1
- package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.advanced.js +1 -2
- package/dist.commonjs/hasher/hasherCkb.d.ts +0 -16
- package/dist.commonjs/hasher/hasherCkb.d.ts.map +1 -1
- package/dist.commonjs/hasher/hasherCkb.js +2 -21
- package/dist.commonjs/molecule/codec.d.ts +30 -10
- package/dist.commonjs/molecule/codec.d.ts.map +1 -1
- package/dist.commonjs/molecule/codec.js +46 -13
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +18 -6
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +18 -6
- package/dist.commonjs/signer/signer/index.d.ts +11 -1
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +23 -0
- package/package.json +1 -1
- package/prettier.config.mjs +1 -1
- package/src/ckb/hash.ts +28 -0
- package/src/ckb/index.ts +2 -0
- package/src/ckb/script.ts +20 -0
- package/src/ckb/transaction.ts +436 -80
- package/src/ckb/transactionErrors.ts +36 -0
- package/src/client/cache/cache.ts +14 -1
- package/src/client/cache/memory.advanced.ts +57 -30
- package/src/client/cache/memory.ts +18 -1
- package/src/client/client.ts +5 -10
- package/src/client/clientTypes.advanced.ts +0 -1
- package/src/hasher/hasherCkb.ts +0 -26
- package/src/molecule/codec.ts +50 -13
- package/src/signer/ckb/signerCkbScriptReadonly.ts +24 -8
- package/src/signer/signer/index.ts +34 -0
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { Address } from "../../address/index.js";
|
|
2
|
-
import { ScriptLike } from "../../ckb/index.js";
|
|
2
|
+
import { Script, ScriptLike } from "../../ckb/index.js";
|
|
3
3
|
import { Client } from "../../client/index.js";
|
|
4
4
|
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
7
|
-
* This
|
|
6
|
+
* A read-only signer for a CKB script. It can be used to get addresses,
|
|
7
|
+
* but not to sign transactions. This is useful when you want to watch an address
|
|
8
|
+
* without having the private key.
|
|
9
|
+
*
|
|
8
10
|
* @public
|
|
9
11
|
*/
|
|
10
12
|
export declare class SignerCkbScriptReadonly extends Signer {
|
|
13
|
+
/**
|
|
14
|
+
* The type of the signer.
|
|
15
|
+
*/
|
|
11
16
|
get type(): SignerType;
|
|
17
|
+
/**
|
|
18
|
+
* The sign type of the signer.
|
|
19
|
+
* As this is a read-only signer, the sign type is {@link SignerSignType.Unknown}.
|
|
20
|
+
*/
|
|
12
21
|
get signType(): SignerSignType;
|
|
13
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The scripts associated with the signer.
|
|
24
|
+
*/
|
|
25
|
+
readonly scripts: Script[];
|
|
14
26
|
/**
|
|
15
27
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
16
28
|
*
|
|
17
29
|
* @param client - The client instance used for communication.
|
|
18
|
-
* @param
|
|
30
|
+
* @param scripts - The scripts associated with the signer. Can be a single script, an array of scripts, or multiple script arguments.
|
|
19
31
|
*/
|
|
20
|
-
constructor(client: Client,
|
|
32
|
+
constructor(client: Client, ...scripts: (ScriptLike | ScriptLike[])[]);
|
|
21
33
|
/**
|
|
22
34
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
23
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD;;OAEG;IACH,IAAI,IAAI,IAAI,UAAU,CAErB;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;OAEG;IACH,SAAgB,OAAO,EAAE,MAAM,EAAE,CAAC;IAElC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,UAAU,GAAG,UAAU,EAAE,CAAC,EAAE;IASrE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAK3C"}
|
|
@@ -2,14 +2,23 @@ import { Address } from "../../address/index.js";
|
|
|
2
2
|
import { Script } from "../../ckb/index.js";
|
|
3
3
|
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
6
|
-
* This
|
|
5
|
+
* A read-only signer for a CKB script. It can be used to get addresses,
|
|
6
|
+
* but not to sign transactions. This is useful when you want to watch an address
|
|
7
|
+
* without having the private key.
|
|
8
|
+
*
|
|
7
9
|
* @public
|
|
8
10
|
*/
|
|
9
11
|
export class SignerCkbScriptReadonly extends Signer {
|
|
12
|
+
/**
|
|
13
|
+
* The type of the signer.
|
|
14
|
+
*/
|
|
10
15
|
get type() {
|
|
11
16
|
return SignerType.CKB;
|
|
12
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The sign type of the signer.
|
|
20
|
+
* As this is a read-only signer, the sign type is {@link SignerSignType.Unknown}.
|
|
21
|
+
*/
|
|
13
22
|
get signType() {
|
|
14
23
|
return SignerSignType.Unknown;
|
|
15
24
|
}
|
|
@@ -17,11 +26,14 @@ export class SignerCkbScriptReadonly extends Signer {
|
|
|
17
26
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
18
27
|
*
|
|
19
28
|
* @param client - The client instance used for communication.
|
|
20
|
-
* @param
|
|
29
|
+
* @param scripts - The scripts associated with the signer. Can be a single script, an array of scripts, or multiple script arguments.
|
|
21
30
|
*/
|
|
22
|
-
constructor(client,
|
|
31
|
+
constructor(client, ...scripts) {
|
|
23
32
|
super(client);
|
|
24
|
-
this.
|
|
33
|
+
this.scripts = scripts.flat().map(Script.from);
|
|
34
|
+
if (this.scripts.length === 0) {
|
|
35
|
+
throw new Error("SignerCkbScriptReadonly requires at least one script.");
|
|
36
|
+
}
|
|
25
37
|
}
|
|
26
38
|
/**
|
|
27
39
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
@@ -61,6 +73,6 @@ export class SignerCkbScriptReadonly extends Signer {
|
|
|
61
73
|
* ```
|
|
62
74
|
*/
|
|
63
75
|
async getAddressObjs() {
|
|
64
|
-
return
|
|
76
|
+
return this.scripts.map((script) => Address.fromScript(script, this.client));
|
|
65
77
|
}
|
|
66
78
|
}
|
|
@@ -2,7 +2,7 @@ import { Address } from "../../address/index.js";
|
|
|
2
2
|
import { ClientCollectableSearchKeyFilterLike } from "../../advancedBarrel.js";
|
|
3
3
|
import { BytesLike } from "../../bytes/index.js";
|
|
4
4
|
import { Cell, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
5
|
-
import { Client, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse } from "../../client/index.js";
|
|
5
|
+
import { Client, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKeyFilterLike } from "../../client/index.js";
|
|
6
6
|
import { Hex } from "../../hex/index.js";
|
|
7
7
|
import { Num } from "../../num/index.js";
|
|
8
8
|
/**
|
|
@@ -131,6 +131,16 @@ export declare abstract class Signer {
|
|
|
131
131
|
* @returns A promise that resolves to an array of addresses as strings.
|
|
132
132
|
*/
|
|
133
133
|
getAddresses(): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Find cells of this signer
|
|
136
|
+
*
|
|
137
|
+
* @param filter - The filter for the search key.
|
|
138
|
+
* @param withData - Whether to include cell data in the response.
|
|
139
|
+
* @param order - The order of the returned cells, can be "asc" or "desc".
|
|
140
|
+
* @param limit - The maximum number of cells for every querying chunk.
|
|
141
|
+
* @returns A async generator that yields all matching cells
|
|
142
|
+
*/
|
|
143
|
+
findCellsOnChain(filter: ClientIndexerSearchKeyFilterLike, withData?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
|
|
134
144
|
/**
|
|
135
145
|
* Find cells of this signer
|
|
136
146
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,MAAM,EACN,qCAAqC,EACrC,8BAA8B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,MAAM,EACN,qCAAqC,EACrC,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,oB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G;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;;GAGG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -130,6 +130,29 @@ export class Signer {
|
|
|
130
130
|
async getAddresses() {
|
|
131
131
|
return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Find cells of this signer
|
|
135
|
+
*
|
|
136
|
+
* @param filter - The filter for the search key.
|
|
137
|
+
* @param withData - Whether to include cell data in the response.
|
|
138
|
+
* @param order - The order of the returned cells, can be "asc" or "desc".
|
|
139
|
+
* @param limit - The maximum number of cells for every querying chunk.
|
|
140
|
+
* @returns A async generator that yields all matching cells
|
|
141
|
+
*/
|
|
142
|
+
async *findCellsOnChain(filter, withData, order, limit) {
|
|
143
|
+
const scripts = await this.getAddressObjs();
|
|
144
|
+
for (const { script } of scripts) {
|
|
145
|
+
for await (const cell of this.client.findCellsOnChain({
|
|
146
|
+
script,
|
|
147
|
+
scriptType: "lock",
|
|
148
|
+
filter,
|
|
149
|
+
scriptSearchMode: "exact",
|
|
150
|
+
withData,
|
|
151
|
+
}, order, limit)) {
|
|
152
|
+
yield cell;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
133
156
|
/**
|
|
134
157
|
* Find cells of this signer
|
|
135
158
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hex } from "../hex/index.js";
|
|
2
|
+
import { NumLike } from "../num/index.js";
|
|
3
|
+
import { CellInputLike } from "./transaction.js";
|
|
4
|
+
/**
|
|
5
|
+
* Computes the Type ID hash of the given data.
|
|
6
|
+
* @public
|
|
7
|
+
*
|
|
8
|
+
* @param cellInputLike - The first cell input of the transaction.
|
|
9
|
+
* @param outputIndex - The output index of the Type ID cell.
|
|
10
|
+
* @returns The hexadecimal string representation of the hash.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function hashTypeId(cellInputLike: CellInputLike, outputIndex: NumLike): Hex;
|
|
18
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/ckb/hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAgB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAa,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;;;;;;;;;;GAYG;AAEH,wBAAgB,UAAU,CACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,OAAO,GACnB,GAAG,CAKL"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashTypeId = hashTypeId;
|
|
4
|
+
const hasherCkb_js_1 = require("../hasher/hasherCkb.js");
|
|
5
|
+
const index_js_1 = require("../num/index.js");
|
|
6
|
+
const transaction_js_1 = require("./transaction.js");
|
|
7
|
+
/**
|
|
8
|
+
* Computes the Type ID hash of the given data.
|
|
9
|
+
* @public
|
|
10
|
+
*
|
|
11
|
+
* @param cellInputLike - The first cell input of the transaction.
|
|
12
|
+
* @param outputIndex - The output index of the Type ID cell.
|
|
13
|
+
* @returns The hexadecimal string representation of the hash.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function hashTypeId(cellInputLike, outputIndex) {
|
|
21
|
+
return (0, hasherCkb_js_1.hashCkb)(transaction_js_1.CellInput.from(cellInputLike).toBytes(), (0, index_js_1.numLeToBytes)(outputIndex, 8));
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hash.js"), exports);
|
|
17
18
|
__exportStar(require("./script.js"), exports);
|
|
18
19
|
__exportStar(require("./transaction.js"), exports);
|
|
20
|
+
__exportStar(require("./transactionErrors.js"), exports);
|
|
19
21
|
__exportStar(require("./transactionLumos.js"), exports);
|
|
@@ -103,6 +103,18 @@ export declare class Script extends Script_base {
|
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
105
|
clone(): Script;
|
|
106
|
+
/**
|
|
107
|
+
* Check if the script is equal to another script.
|
|
108
|
+
* @public
|
|
109
|
+
* @param other - The other script to compare with
|
|
110
|
+
* @returns True if the scripts are equal, false otherwise
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const isEqual = script0.eq(script1);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
eq(other: ScriptLike): boolean;
|
|
106
118
|
/**
|
|
107
119
|
* Creates a Script instance from a ScriptLike object.
|
|
108
120
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../src/ckb/script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAO3C,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,QAAQ,CAI1D,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACpD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,QAAQ,CAmBxD;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,KAAK,CAE7D;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,CAE5D;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,SA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118,6 +118,23 @@ let Script = Script_1 = class Script extends index_js_3.mol.Entity.Base() {
|
|
|
118
118
|
clone() {
|
|
119
119
|
return new Script_1(this.codeHash, this.hashType, this.args);
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if the script is equal to another script.
|
|
123
|
+
* @public
|
|
124
|
+
* @param other - The other script to compare with
|
|
125
|
+
* @returns True if the scripts are equal, false otherwise
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const isEqual = script0.eq(script1);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
eq(other) {
|
|
133
|
+
other = Script_1.from(other);
|
|
134
|
+
return (this.args === other.args &&
|
|
135
|
+
this.codeHash === other.codeHash &&
|
|
136
|
+
this.hashType === other.hashType);
|
|
137
|
+
}
|
|
121
138
|
/**
|
|
122
139
|
* Creates a Script instance from a ScriptLike object.
|
|
123
140
|
*
|