@ckb-ccc/udt 0.1.24 → 0.1.25

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @ckb-ccc/udt
2
2
 
3
+ ## 0.1.25
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#379](https://github.com/ckb-devrel/ccc/pull/379) [`f01a05b`](https://github.com/ckb-devrel/ccc/commit/f01a05bab332d9f4e0cf7f84aecfd688f8e9f346) Thanks [@Hanssen0](https://github.com/Hanssen0)! - chore: bump pnpm to v11.8.0
9
+
10
+ - Updated dependencies [[`1148a5c`](https://github.com/ckb-devrel/ccc/commit/1148a5c403cde985fb4ba713ccfa0c163d287174), [`bf0f8d8`](https://github.com/ckb-devrel/ccc/commit/bf0f8d8ca011e627821445a10bc38519510e5b9d), [`a803d5f`](https://github.com/ckb-devrel/ccc/commit/a803d5fba8d0e082c6aba14db156856025402e72), [`bf0f8d8`](https://github.com/ckb-devrel/ccc/commit/bf0f8d8ca011e627821445a10bc38519510e5b9d), [`6727ffe`](https://github.com/ckb-devrel/ccc/commit/6727ffe05f60e6bfb2060a565c19acb0fd0f375e), [`f01a05b`](https://github.com/ckb-devrel/ccc/commit/f01a05bab332d9f4e0cf7f84aecfd688f8e9f346), [`a526890`](https://github.com/ckb-devrel/ccc/commit/a5268909ea9d61c4e2f5187a43e2318327b27cae), [`4bb3d9d`](https://github.com/ckb-devrel/ccc/commit/4bb3d9d2ef36b3ee8820036625abd9befb1980c4), [`9f7ecb6`](https://github.com/ckb-devrel/ccc/commit/9f7ecb6ab8db9c6866dad029f2888e1e5cfcbe7d)]:
11
+ - @ckb-ccc/core@1.13.0
12
+ - @ckb-ccc/ssri@0.2.23
13
+
3
14
  ## 0.1.24
4
15
  ### Patch Changes
5
16
 
@@ -15,14 +15,15 @@ export declare class Udt extends ssri.Trait {
15
15
  readonly script: ccc.Script;
16
16
  /**
17
17
  * Constructs a new UDT (User Defined Token) script instance.
18
- * By default it is a SSRI-compliant UDT. By providing `xudtType`, it is compatible with the legacy xUDT.
18
+ * By default it is a SSRI-compliant UDT.
19
19
  *
20
- * @param executor - The SSRI executor instance.
21
20
  * @param code - The script code cell of the UDT.
22
21
  * @param script - The type script of the UDT.
22
+ * @param config - Optional configuration for the UDT instance.
23
+ * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
23
24
  * @example
24
25
  * ```typescript
25
- * const udt = new Udt(executor, code, script);
26
+ * const udt = new Udt(code, script, { executor });
26
27
  * ```
27
28
  */
28
29
  constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config?: {
@@ -31,30 +32,35 @@ export declare class Udt extends ssri.Trait {
31
32
  /**
32
33
  * Retrieves the human-readable name of the User Defined Token.
33
34
  *
35
+ * @param context - Optional SSRI context for script execution.
34
36
  * @returns A promise resolving to the token's name.
35
37
  */
36
38
  name(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
37
39
  /**
38
40
  * Retrieves the symbol of the UDT.
41
+ * @param context - Optional SSRI context for script execution.
39
42
  * @returns The symbol of the UDT.
40
43
  */
41
44
  symbol(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
42
45
  /**
43
46
  * Retrieves the decimals of the UDT.
47
+ * @param context - Optional SSRI context for script execution.
44
48
  * @returns The decimals of the UDT.
45
49
  */
46
50
  decimals(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<ccc.Num | undefined>>;
47
51
  /**
48
- * Retrieves the icon of the UDT
52
+ * Retrieves the icon of the UDT.
53
+ * @param context - Optional SSRI context for script execution.
49
54
  * @returns The icon of the UDT.
50
55
  */
51
56
  icon(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
52
57
  /**
53
58
  * Transfers UDT to specified addresses.
54
- * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
59
+ * @param signer - The signer to use for the transaction.
55
60
  * @param transfers - The array of transfers.
56
61
  * @param transfers.to - The receiver of token.
57
62
  * @param transfers.amount - The amount of token to the receiver.
63
+ * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
58
64
  * @returns The transaction result.
59
65
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
60
66
  * @example
@@ -91,10 +97,11 @@ export declare class Udt extends ssri.Trait {
91
97
  }[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
92
98
  /**
93
99
  * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
94
- * @param tx - Optional existing transaction to build upon
100
+ * @param signer - The signer to use for the transaction.
95
101
  * @param mints - Array of mints
96
102
  * @param mints.to - receiver of token
97
103
  * @param mints.amount - amount to the receiver
104
+ * @param tx - Optional existing transaction to build upon
98
105
  * @returns The transaction containing the mint operation
99
106
  * @tag Mutation - This method represents a mutation of the onchain state
100
107
  */
@@ -102,7 +109,20 @@ export declare class Udt extends ssri.Trait {
102
109
  to: ccc.ScriptLike;
103
110
  amount: ccc.NumLike;
104
111
  }[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
112
+ /**
113
+ * Completes a UDT transaction by adding change output to a specific lock script.
114
+ * @param txLike - The transaction to complete.
115
+ * @param signer - The signer to use for input selection.
116
+ * @param change - The lock script for the change output.
117
+ * @returns The completed transaction.
118
+ */
105
119
  completeChangeToLock(txLike: ccc.TransactionLike, signer: ccc.Signer, change: ccc.ScriptLike): Promise<ccc.Transaction>;
120
+ /**
121
+ * Completes a UDT transaction by adding change output to the signer's address.
122
+ * @param tx - The transaction to complete.
123
+ * @param from - The signer to use for input selection and change address.
124
+ * @returns The completed transaction.
125
+ */
106
126
  completeBy(tx: ccc.TransactionLike, from: ccc.Signer): Promise<ccc.Transaction>;
107
127
  }
108
128
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","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AAE,GAAG,CAAC,eAAe,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,MAAM,EAAE,GAAG,CAAC,UAAU;IAqBxB;;;;;OAKG;IACG,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM;CAK3D"}
package/dist/udt/index.js CHANGED
@@ -14,14 +14,15 @@ import { ssri } from "@ckb-ccc/ssri";
14
14
  export class Udt extends ssri.Trait {
15
15
  /**
16
16
  * Constructs a new UDT (User Defined Token) script instance.
17
- * By default it is a SSRI-compliant UDT. By providing `xudtType`, it is compatible with the legacy xUDT.
17
+ * By default it is a SSRI-compliant UDT.
18
18
  *
19
- * @param executor - The SSRI executor instance.
20
19
  * @param code - The script code cell of the UDT.
21
20
  * @param script - The type script of the UDT.
21
+ * @param config - Optional configuration for the UDT instance.
22
+ * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
22
23
  * @example
23
24
  * ```typescript
24
- * const udt = new Udt(executor, code, script);
25
+ * const udt = new Udt(code, script, { executor });
25
26
  * ```
26
27
  */
27
28
  constructor(code, script, config) {
@@ -31,6 +32,7 @@ export class Udt extends ssri.Trait {
31
32
  /**
32
33
  * Retrieves the human-readable name of the User Defined Token.
33
34
  *
35
+ * @param context - Optional SSRI context for script execution.
34
36
  * @returns A promise resolving to the token's name.
35
37
  */
36
38
  async name(context) {
@@ -47,6 +49,7 @@ export class Udt extends ssri.Trait {
47
49
  }
48
50
  /**
49
51
  * Retrieves the symbol of the UDT.
52
+ * @param context - Optional SSRI context for script execution.
50
53
  * @returns The symbol of the UDT.
51
54
  */
52
55
  async symbol(context) {
@@ -63,6 +66,7 @@ export class Udt extends ssri.Trait {
63
66
  }
64
67
  /**
65
68
  * Retrieves the decimals of the UDT.
69
+ * @param context - Optional SSRI context for script execution.
66
70
  * @returns The decimals of the UDT.
67
71
  */
68
72
  async decimals(context) {
@@ -78,7 +82,8 @@ export class Udt extends ssri.Trait {
78
82
  return ssri.ExecutorResponse.new(undefined);
79
83
  }
80
84
  /**
81
- * Retrieves the icon of the UDT
85
+ * Retrieves the icon of the UDT.
86
+ * @param context - Optional SSRI context for script execution.
82
87
  * @returns The icon of the UDT.
83
88
  */
84
89
  async icon(context) {
@@ -95,10 +100,11 @@ export class Udt extends ssri.Trait {
95
100
  }
96
101
  /**
97
102
  * Transfers UDT to specified addresses.
98
- * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
103
+ * @param signer - The signer to use for the transaction.
99
104
  * @param transfers - The array of transfers.
100
105
  * @param transfers.to - The receiver of token.
101
106
  * @param transfers.amount - The amount of token to the receiver.
107
+ * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
102
108
  * @returns The transaction result.
103
109
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
104
110
  * @example
@@ -163,10 +169,11 @@ export class Udt extends ssri.Trait {
163
169
  }
164
170
  /**
165
171
  * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
166
- * @param tx - Optional existing transaction to build upon
172
+ * @param signer - The signer to use for the transaction.
167
173
  * @param mints - Array of mints
168
174
  * @param mints.to - receiver of token
169
175
  * @param mints.amount - amount to the receiver
176
+ * @param tx - Optional existing transaction to build upon
170
177
  * @returns The transaction containing the mint operation
171
178
  * @tag Mutation - This method represents a mutation of the onchain state
172
179
  */
@@ -202,6 +209,13 @@ export class Udt extends ssri.Trait {
202
209
  });
203
210
  return resTx;
204
211
  }
212
+ /**
213
+ * Completes a UDT transaction by adding change output to a specific lock script.
214
+ * @param txLike - The transaction to complete.
215
+ * @param signer - The signer to use for input selection.
216
+ * @param change - The lock script for the change output.
217
+ * @returns The completed transaction.
218
+ */
205
219
  async completeChangeToLock(txLike, signer, change) {
206
220
  const tx = ccc.Transaction.from(txLike);
207
221
  await tx.completeInputsByUdt(signer, this.script);
@@ -215,6 +229,12 @@ export class Udt extends ssri.Trait {
215
229
  }
216
230
  return tx;
217
231
  }
232
+ /**
233
+ * Completes a UDT transaction by adding change output to the signer's address.
234
+ * @param tx - The transaction to complete.
235
+ * @param from - The signer to use for input selection and change address.
236
+ * @returns The completed transaction.
237
+ */
218
238
  async completeBy(tx, from) {
219
239
  const { script } = await from.getRecommendedAddressObj();
220
240
  return this.completeChangeToLock(tx, from, script);
@@ -11,25 +11,30 @@ export declare class UdtPausable extends Udt {
11
11
  executor: ssri.Executor;
12
12
  });
13
13
  /**
14
- * Pauses the UDT for the specified lock hashes. Pausing/Unpause without lock hashes should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
15
- * @param {ccc.HexLike[]} lockHashes - The array of lock hashes to be paused.
16
- * @param {ccc.TransactionLike} tx - The transaction to be used.
14
+ * Pauses the UDT for the specified lock scripts. Pausing/Unpause without lock scripts should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
15
+ * @param signer - The signer to use for the transaction.
16
+ * @param locks - The array of lock scripts to be paused.
17
+ * @param tx - The transaction to be used.
18
+ * @param extraLockHashes - Additional lock hashes to be paused.
17
19
  * @returns The transaction result.
18
20
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
19
21
  */
20
22
  pause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
21
23
  /**
22
- * Unpauses the UDT for the specified lock hashes. Note that this method is only available if the pausable UDT uses external pause list.
24
+ * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
25
+ * @param signer - The signer to use for the transaction.
26
+ * @param locks - The array of lock scripts to be unpaused.
23
27
  * @param tx - The transaction to be used.
24
- * @param lockHashes - The array of lock hashes to be unpaused.
28
+ * @param extraLockHashes - Additional lock hashes to be unpaused.
25
29
  * @returns The transaction result.
26
30
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
27
31
  */
28
32
  unpause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
29
33
  /**
30
- * Checks if the UDT is paused for the specified lock hashes within a transaction. If not using external pause list, it can also be run on Code environment level.
31
- * @param lockHashes - The lock hashes to check.
32
- * @returns True if any of the lock hashes are paused, false otherwise.
34
+ * Checks if the UDT is paused for the specified lock scripts within a transaction. If not using external pause list, it can also be run on Code environment level.
35
+ * @param locks - The lock scripts to check.
36
+ * @param extraLockHashes - Additional lock hashes to check.
37
+ * @returns True if any of the lock scripts are paused, false otherwise.
33
38
  */
34
39
  isPaused(locks: ccc.ScriptLike[], extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<boolean[]>>;
35
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/udtPausable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,GAAG;gBAEhC,IAAI,EAAE,GAAG,CAAC,YAAY,EACtB,MAAM,EAAE,GAAG,CAAC,UAAU,EACtB,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;KACzB;IAKH;;;;;;OAMG;IACG,KAAK,CACT,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;;OAMG;IACG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AAe,GAAG,IAAI,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;;;;OAQG;IACG,OAAO,CACX,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAgB5C;;;OAGG;IACG,eAAe,CACnB,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,EAChB,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,GACd,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;CAU7C"}
@@ -10,9 +10,11 @@ export class UdtPausable extends Udt {
10
10
  super(code, script, config);
11
11
  }
12
12
  /**
13
- * Pauses the UDT for the specified lock hashes. Pausing/Unpause without lock hashes should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
14
- * @param {ccc.HexLike[]} lockHashes - The array of lock hashes to be paused.
15
- * @param {ccc.TransactionLike} tx - The transaction to be used.
13
+ * Pauses the UDT for the specified lock scripts. Pausing/Unpause without lock scripts should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
14
+ * @param signer - The signer to use for the transaction.
15
+ * @param locks - The array of lock scripts to be paused.
16
+ * @param tx - The transaction to be used.
17
+ * @param extraLockHashes - Additional lock hashes to be paused.
16
18
  * @returns The transaction result.
17
19
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
18
20
  */
@@ -33,9 +35,11 @@ export class UdtPausable extends Udt {
33
35
  return resTx;
34
36
  }
35
37
  /**
36
- * Unpauses the UDT for the specified lock hashes. Note that this method is only available if the pausable UDT uses external pause list.
38
+ * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
39
+ * @param signer - The signer to use for the transaction.
40
+ * @param locks - The array of lock scripts to be unpaused.
37
41
  * @param tx - The transaction to be used.
38
- * @param lockHashes - The array of lock hashes to be unpaused.
42
+ * @param extraLockHashes - Additional lock hashes to be unpaused.
39
43
  * @returns The transaction result.
40
44
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
41
45
  */
@@ -56,9 +60,10 @@ export class UdtPausable extends Udt {
56
60
  return resTx;
57
61
  }
58
62
  /**
59
- * Checks if the UDT is paused for the specified lock hashes within a transaction. If not using external pause list, it can also be run on Code environment level.
60
- * @param lockHashes - The lock hashes to check.
61
- * @returns True if any of the lock hashes are paused, false otherwise.
63
+ * Checks if the UDT is paused for the specified lock scripts within a transaction. If not using external pause list, it can also be run on Code environment level.
64
+ * @param locks - The lock scripts to check.
65
+ * @param extraLockHashes - Additional lock hashes to check.
66
+ * @returns True if any of the lock scripts are paused, false otherwise.
62
67
  */
63
68
  async isPaused(locks, extraLockHashes) {
64
69
  const res = await this.assertExecutor().runScript(this.code, "UDTPausable.is_paused", [
@@ -15,14 +15,15 @@ export declare class Udt extends ssri.Trait {
15
15
  readonly script: ccc.Script;
16
16
  /**
17
17
  * Constructs a new UDT (User Defined Token) script instance.
18
- * By default it is a SSRI-compliant UDT. By providing `xudtType`, it is compatible with the legacy xUDT.
18
+ * By default it is a SSRI-compliant UDT.
19
19
  *
20
- * @param executor - The SSRI executor instance.
21
20
  * @param code - The script code cell of the UDT.
22
21
  * @param script - The type script of the UDT.
22
+ * @param config - Optional configuration for the UDT instance.
23
+ * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
23
24
  * @example
24
25
  * ```typescript
25
- * const udt = new Udt(executor, code, script);
26
+ * const udt = new Udt(code, script, { executor });
26
27
  * ```
27
28
  */
28
29
  constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config?: {
@@ -31,30 +32,35 @@ export declare class Udt extends ssri.Trait {
31
32
  /**
32
33
  * Retrieves the human-readable name of the User Defined Token.
33
34
  *
35
+ * @param context - Optional SSRI context for script execution.
34
36
  * @returns A promise resolving to the token's name.
35
37
  */
36
38
  name(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
37
39
  /**
38
40
  * Retrieves the symbol of the UDT.
41
+ * @param context - Optional SSRI context for script execution.
39
42
  * @returns The symbol of the UDT.
40
43
  */
41
44
  symbol(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
42
45
  /**
43
46
  * Retrieves the decimals of the UDT.
47
+ * @param context - Optional SSRI context for script execution.
44
48
  * @returns The decimals of the UDT.
45
49
  */
46
50
  decimals(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<ccc.Num | undefined>>;
47
51
  /**
48
- * Retrieves the icon of the UDT
52
+ * Retrieves the icon of the UDT.
53
+ * @param context - Optional SSRI context for script execution.
49
54
  * @returns The icon of the UDT.
50
55
  */
51
56
  icon(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
52
57
  /**
53
58
  * Transfers UDT to specified addresses.
54
- * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
59
+ * @param signer - The signer to use for the transaction.
55
60
  * @param transfers - The array of transfers.
56
61
  * @param transfers.to - The receiver of token.
57
62
  * @param transfers.amount - The amount of token to the receiver.
63
+ * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
58
64
  * @returns The transaction result.
59
65
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
60
66
  * @example
@@ -91,10 +97,11 @@ export declare class Udt extends ssri.Trait {
91
97
  }[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
92
98
  /**
93
99
  * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
94
- * @param tx - Optional existing transaction to build upon
100
+ * @param signer - The signer to use for the transaction.
95
101
  * @param mints - Array of mints
96
102
  * @param mints.to - receiver of token
97
103
  * @param mints.amount - amount to the receiver
104
+ * @param tx - Optional existing transaction to build upon
98
105
  * @returns The transaction containing the mint operation
99
106
  * @tag Mutation - This method represents a mutation of the onchain state
100
107
  */
@@ -102,7 +109,20 @@ export declare class Udt extends ssri.Trait {
102
109
  to: ccc.ScriptLike;
103
110
  amount: ccc.NumLike;
104
111
  }[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
112
+ /**
113
+ * Completes a UDT transaction by adding change output to a specific lock script.
114
+ * @param txLike - The transaction to complete.
115
+ * @param signer - The signer to use for input selection.
116
+ * @param change - The lock script for the change output.
117
+ * @returns The completed transaction.
118
+ */
105
119
  completeChangeToLock(txLike: ccc.TransactionLike, signer: ccc.Signer, change: ccc.ScriptLike): Promise<ccc.Transaction>;
120
+ /**
121
+ * Completes a UDT transaction by adding change output to the signer's address.
122
+ * @param tx - The transaction to complete.
123
+ * @param from - The signer to use for input selection and change address.
124
+ * @returns The completed transaction.
125
+ */
106
126
  completeBy(tx: ccc.TransactionLike, from: ccc.Signer): Promise<ccc.Transaction>;
107
127
  }
108
128
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/udt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;;;;;;;GAUG;AACH,qBAAa,GAAI,S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I,EAAE,GAAG,CAAC,MAAM;CAK3D"}
@@ -17,14 +17,15 @@ const ssri_1 = require("@ckb-ccc/ssri");
17
17
  class Udt extends ssri_1.ssri.Trait {
18
18
  /**
19
19
  * Constructs a new UDT (User Defined Token) script instance.
20
- * By default it is a SSRI-compliant UDT. By providing `xudtType`, it is compatible with the legacy xUDT.
20
+ * By default it is a SSRI-compliant UDT.
21
21
  *
22
- * @param executor - The SSRI executor instance.
23
22
  * @param code - The script code cell of the UDT.
24
23
  * @param script - The type script of the UDT.
24
+ * @param config - Optional configuration for the UDT instance.
25
+ * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
25
26
  * @example
26
27
  * ```typescript
27
- * const udt = new Udt(executor, code, script);
28
+ * const udt = new Udt(code, script, { executor });
28
29
  * ```
29
30
  */
30
31
  constructor(code, script, config) {
@@ -34,6 +35,7 @@ class Udt extends ssri_1.ssri.Trait {
34
35
  /**
35
36
  * Retrieves the human-readable name of the User Defined Token.
36
37
  *
38
+ * @param context - Optional SSRI context for script execution.
37
39
  * @returns A promise resolving to the token's name.
38
40
  */
39
41
  async name(context) {
@@ -50,6 +52,7 @@ class Udt extends ssri_1.ssri.Trait {
50
52
  }
51
53
  /**
52
54
  * Retrieves the symbol of the UDT.
55
+ * @param context - Optional SSRI context for script execution.
53
56
  * @returns The symbol of the UDT.
54
57
  */
55
58
  async symbol(context) {
@@ -66,6 +69,7 @@ class Udt extends ssri_1.ssri.Trait {
66
69
  }
67
70
  /**
68
71
  * Retrieves the decimals of the UDT.
72
+ * @param context - Optional SSRI context for script execution.
69
73
  * @returns The decimals of the UDT.
70
74
  */
71
75
  async decimals(context) {
@@ -81,7 +85,8 @@ class Udt extends ssri_1.ssri.Trait {
81
85
  return ssri_1.ssri.ExecutorResponse.new(undefined);
82
86
  }
83
87
  /**
84
- * Retrieves the icon of the UDT
88
+ * Retrieves the icon of the UDT.
89
+ * @param context - Optional SSRI context for script execution.
85
90
  * @returns The icon of the UDT.
86
91
  */
87
92
  async icon(context) {
@@ -98,10 +103,11 @@ class Udt extends ssri_1.ssri.Trait {
98
103
  }
99
104
  /**
100
105
  * Transfers UDT to specified addresses.
101
- * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
106
+ * @param signer - The signer to use for the transaction.
102
107
  * @param transfers - The array of transfers.
103
108
  * @param transfers.to - The receiver of token.
104
109
  * @param transfers.amount - The amount of token to the receiver.
110
+ * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
105
111
  * @returns The transaction result.
106
112
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
107
113
  * @example
@@ -166,10 +172,11 @@ class Udt extends ssri_1.ssri.Trait {
166
172
  }
167
173
  /**
168
174
  * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
169
- * @param tx - Optional existing transaction to build upon
175
+ * @param signer - The signer to use for the transaction.
170
176
  * @param mints - Array of mints
171
177
  * @param mints.to - receiver of token
172
178
  * @param mints.amount - amount to the receiver
179
+ * @param tx - Optional existing transaction to build upon
173
180
  * @returns The transaction containing the mint operation
174
181
  * @tag Mutation - This method represents a mutation of the onchain state
175
182
  */
@@ -205,6 +212,13 @@ class Udt extends ssri_1.ssri.Trait {
205
212
  });
206
213
  return resTx;
207
214
  }
215
+ /**
216
+ * Completes a UDT transaction by adding change output to a specific lock script.
217
+ * @param txLike - The transaction to complete.
218
+ * @param signer - The signer to use for input selection.
219
+ * @param change - The lock script for the change output.
220
+ * @returns The completed transaction.
221
+ */
208
222
  async completeChangeToLock(txLike, signer, change) {
209
223
  const tx = core_1.ccc.Transaction.from(txLike);
210
224
  await tx.completeInputsByUdt(signer, this.script);
@@ -218,6 +232,12 @@ class Udt extends ssri_1.ssri.Trait {
218
232
  }
219
233
  return tx;
220
234
  }
235
+ /**
236
+ * Completes a UDT transaction by adding change output to the signer's address.
237
+ * @param tx - The transaction to complete.
238
+ * @param from - The signer to use for input selection and change address.
239
+ * @returns The completed transaction.
240
+ */
221
241
  async completeBy(tx, from) {
222
242
  const { script } = await from.getRecommendedAddressObj();
223
243
  return this.completeChangeToLock(tx, from, script);
@@ -11,25 +11,30 @@ export declare class UdtPausable extends Udt {
11
11
  executor: ssri.Executor;
12
12
  });
13
13
  /**
14
- * Pauses the UDT for the specified lock hashes. Pausing/Unpause without lock hashes should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
15
- * @param {ccc.HexLike[]} lockHashes - The array of lock hashes to be paused.
16
- * @param {ccc.TransactionLike} tx - The transaction to be used.
14
+ * Pauses the UDT for the specified lock scripts. Pausing/Unpause without lock scripts should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
15
+ * @param signer - The signer to use for the transaction.
16
+ * @param locks - The array of lock scripts to be paused.
17
+ * @param tx - The transaction to be used.
18
+ * @param extraLockHashes - Additional lock hashes to be paused.
17
19
  * @returns The transaction result.
18
20
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
19
21
  */
20
22
  pause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
21
23
  /**
22
- * Unpauses the UDT for the specified lock hashes. Note that this method is only available if the pausable UDT uses external pause list.
24
+ * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
25
+ * @param signer - The signer to use for the transaction.
26
+ * @param locks - The array of lock scripts to be unpaused.
23
27
  * @param tx - The transaction to be used.
24
- * @param lockHashes - The array of lock hashes to be unpaused.
28
+ * @param extraLockHashes - Additional lock hashes to be unpaused.
25
29
  * @returns The transaction result.
26
30
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
27
31
  */
28
32
  unpause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
29
33
  /**
30
- * Checks if the UDT is paused for the specified lock hashes within a transaction. If not using external pause list, it can also be run on Code environment level.
31
- * @param lockHashes - The lock hashes to check.
32
- * @returns True if any of the lock hashes are paused, false otherwise.
34
+ * Checks if the UDT is paused for the specified lock scripts within a transaction. If not using external pause list, it can also be run on Code environment level.
35
+ * @param locks - The lock scripts to check.
36
+ * @param extraLockHashes - Additional lock hashes to check.
37
+ * @returns True if any of the lock scripts are paused, false otherwise.
33
38
  */
34
39
  isPaused(locks: ccc.ScriptLike[], extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<boolean[]>>;
35
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/udtPausable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,GAAG;gBAEhC,IAAI,EAAE,GAAG,CAAC,YAAY,EACtB,MAAM,EAAE,GAAG,CAAC,UAAU,EACtB,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;KACzB;IAKH;;;;;;OAMG;IACG,KAAK,CACT,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;;OAMG;IACG,OAAO,CACX,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,EAAE,CAAC,EAAE,GAAG,CAAC,eAA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AAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;;;;OAQG;IACG,OAAO,CACX,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,GAAG,IAAI,EAC/B,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAyBlD;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE,EACvB,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAgB5C;;;OAGG;IACG,eAAe,CACnB,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,EAChB,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,GACd,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;CAU7C"}
@@ -13,9 +13,11 @@ class UdtPausable extends index_js_1.Udt {
13
13
  super(code, script, config);
14
14
  }
15
15
  /**
16
- * Pauses the UDT for the specified lock hashes. Pausing/Unpause without lock hashes should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
17
- * @param {ccc.HexLike[]} lockHashes - The array of lock hashes to be paused.
18
- * @param {ccc.TransactionLike} tx - The transaction to be used.
16
+ * Pauses the UDT for the specified lock scripts. Pausing/Unpause without lock scripts should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
17
+ * @param signer - The signer to use for the transaction.
18
+ * @param locks - The array of lock scripts to be paused.
19
+ * @param tx - The transaction to be used.
20
+ * @param extraLockHashes - Additional lock hashes to be paused.
19
21
  * @returns The transaction result.
20
22
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
21
23
  */
@@ -36,9 +38,11 @@ class UdtPausable extends index_js_1.Udt {
36
38
  return resTx;
37
39
  }
38
40
  /**
39
- * Unpauses the UDT for the specified lock hashes. Note that this method is only available if the pausable UDT uses external pause list.
41
+ * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
42
+ * @param signer - The signer to use for the transaction.
43
+ * @param locks - The array of lock scripts to be unpaused.
40
44
  * @param tx - The transaction to be used.
41
- * @param lockHashes - The array of lock hashes to be unpaused.
45
+ * @param extraLockHashes - Additional lock hashes to be unpaused.
42
46
  * @returns The transaction result.
43
47
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
44
48
  */
@@ -59,9 +63,10 @@ class UdtPausable extends index_js_1.Udt {
59
63
  return resTx;
60
64
  }
61
65
  /**
62
- * Checks if the UDT is paused for the specified lock hashes within a transaction. If not using external pause list, it can also be run on Code environment level.
63
- * @param lockHashes - The lock hashes to check.
64
- * @returns True if any of the lock hashes are paused, false otherwise.
66
+ * Checks if the UDT is paused for the specified lock scripts within a transaction. If not using external pause list, it can also be run on Code environment level.
67
+ * @param locks - The lock scripts to check.
68
+ * @param extraLockHashes - Additional lock hashes to check.
69
+ * @returns True if any of the lock scripts are paused, false otherwise.
65
70
  */
66
71
  async isPaused(locks, extraLockHashes) {
67
72
  const res = await this.assertExecutor().runScript(this.code, "UDTPausable.is_paused", [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/udt",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "UDT",
5
5
  "author": "Alive24 <xct24@live.com>",
6
6
  "license": "MIT",
@@ -39,8 +39,8 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@ckb-ccc/core": "1.12.5",
43
- "@ckb-ccc/ssri": "0.2.22"
42
+ "@ckb-ccc/core": "1.13.0",
43
+ "@ckb-ccc/ssri": "0.2.23"
44
44
  },
45
45
  "scripts": {
46
46
  "test": "jest",
package/src/udt/index.ts CHANGED
@@ -17,14 +17,15 @@ export class Udt extends ssri.Trait {
17
17
 
18
18
  /**
19
19
  * Constructs a new UDT (User Defined Token) script instance.
20
- * By default it is a SSRI-compliant UDT. By providing `xudtType`, it is compatible with the legacy xUDT.
20
+ * By default it is a SSRI-compliant UDT.
21
21
  *
22
- * @param executor - The SSRI executor instance.
23
22
  * @param code - The script code cell of the UDT.
24
23
  * @param script - The type script of the UDT.
24
+ * @param config - Optional configuration for the UDT instance.
25
+ * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
25
26
  * @example
26
27
  * ```typescript
27
- * const udt = new Udt(executor, code, script);
28
+ * const udt = new Udt(code, script, { executor });
28
29
  * ```
29
30
  */
30
31
  constructor(
@@ -41,6 +42,7 @@ export class Udt extends ssri.Trait {
41
42
  /**
42
43
  * Retrieves the human-readable name of the User Defined Token.
43
44
  *
45
+ * @param context - Optional SSRI context for script execution.
44
46
  * @returns A promise resolving to the token's name.
45
47
  */
46
48
  async name(
@@ -61,6 +63,7 @@ export class Udt extends ssri.Trait {
61
63
 
62
64
  /**
63
65
  * Retrieves the symbol of the UDT.
66
+ * @param context - Optional SSRI context for script execution.
64
67
  * @returns The symbol of the UDT.
65
68
  */
66
69
  async symbol(
@@ -86,6 +89,7 @@ export class Udt extends ssri.Trait {
86
89
 
87
90
  /**
88
91
  * Retrieves the decimals of the UDT.
92
+ * @param context - Optional SSRI context for script execution.
89
93
  * @returns The decimals of the UDT.
90
94
  */
91
95
  async decimals(
@@ -110,7 +114,8 @@ export class Udt extends ssri.Trait {
110
114
  }
111
115
 
112
116
  /**
113
- * Retrieves the icon of the UDT
117
+ * Retrieves the icon of the UDT.
118
+ * @param context - Optional SSRI context for script execution.
114
119
  * @returns The icon of the UDT.
115
120
  */
116
121
  async icon(
@@ -131,10 +136,11 @@ export class Udt extends ssri.Trait {
131
136
 
132
137
  /**
133
138
  * Transfers UDT to specified addresses.
134
- * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
139
+ * @param signer - The signer to use for the transaction.
135
140
  * @param transfers - The array of transfers.
136
141
  * @param transfers.to - The receiver of token.
137
142
  * @param transfers.amount - The amount of token to the receiver.
143
+ * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
138
144
  * @returns The transaction result.
139
145
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
140
146
  * @example
@@ -217,10 +223,11 @@ export class Udt extends ssri.Trait {
217
223
 
218
224
  /**
219
225
  * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
220
- * @param tx - Optional existing transaction to build upon
226
+ * @param signer - The signer to use for the transaction.
221
227
  * @param mints - Array of mints
222
228
  * @param mints.to - receiver of token
223
229
  * @param mints.amount - amount to the receiver
230
+ * @param tx - Optional existing transaction to build upon
224
231
  * @returns The transaction containing the mint operation
225
232
  * @tag Mutation - This method represents a mutation of the onchain state
226
233
  */
@@ -274,6 +281,13 @@ export class Udt extends ssri.Trait {
274
281
  return resTx;
275
282
  }
276
283
 
284
+ /**
285
+ * Completes a UDT transaction by adding change output to a specific lock script.
286
+ * @param txLike - The transaction to complete.
287
+ * @param signer - The signer to use for input selection.
288
+ * @param change - The lock script for the change output.
289
+ * @returns The completed transaction.
290
+ */
277
291
  async completeChangeToLock(
278
292
  txLike: ccc.TransactionLike,
279
293
  signer: ccc.Signer,
@@ -298,6 +312,12 @@ export class Udt extends ssri.Trait {
298
312
  return tx;
299
313
  }
300
314
 
315
+ /**
316
+ * Completes a UDT transaction by adding change output to the signer's address.
317
+ * @param tx - The transaction to complete.
318
+ * @param from - The signer to use for input selection and change address.
319
+ * @returns The completed transaction.
320
+ */
301
321
  async completeBy(tx: ccc.TransactionLike, from: ccc.Signer) {
302
322
  const { script } = await from.getRecommendedAddressObj();
303
323
 
@@ -19,9 +19,11 @@ export class UdtPausable extends Udt {
19
19
  }
20
20
 
21
21
  /**
22
- * Pauses the UDT for the specified lock hashes. Pausing/Unpause without lock hashes should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
23
- * @param {ccc.HexLike[]} lockHashes - The array of lock hashes to be paused.
24
- * @param {ccc.TransactionLike} tx - The transaction to be used.
22
+ * Pauses the UDT for the specified lock scripts. Pausing/Unpause without lock scripts should take effect on the global level. Note that this method is only available if the pausable UDT uses external pause list.
23
+ * @param signer - The signer to use for the transaction.
24
+ * @param locks - The array of lock scripts to be paused.
25
+ * @param tx - The transaction to be used.
26
+ * @param extraLockHashes - Additional lock hashes to be paused.
25
27
  * @returns The transaction result.
26
28
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
27
29
  */
@@ -56,9 +58,11 @@ export class UdtPausable extends Udt {
56
58
  }
57
59
 
58
60
  /**
59
- * Unpauses the UDT for the specified lock hashes. Note that this method is only available if the pausable UDT uses external pause list.
61
+ * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
62
+ * @param signer - The signer to use for the transaction.
63
+ * @param locks - The array of lock scripts to be unpaused.
60
64
  * @param tx - The transaction to be used.
61
- * @param lockHashes - The array of lock hashes to be unpaused.
65
+ * @param extraLockHashes - Additional lock hashes to be unpaused.
62
66
  * @returns The transaction result.
63
67
  * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
64
68
  */
@@ -93,9 +97,10 @@ export class UdtPausable extends Udt {
93
97
  }
94
98
 
95
99
  /**
96
- * Checks if the UDT is paused for the specified lock hashes within a transaction. If not using external pause list, it can also be run on Code environment level.
97
- * @param lockHashes - The lock hashes to check.
98
- * @returns True if any of the lock hashes are paused, false otherwise.
100
+ * Checks if the UDT is paused for the specified lock scripts within a transaction. If not using external pause list, it can also be run on Code environment level.
101
+ * @param locks - The lock scripts to check.
102
+ * @param extraLockHashes - Additional lock hashes to check.
103
+ * @returns True if any of the lock scripts are paused, false otherwise.
99
104
  */
100
105
  async isPaused(
101
106
  locks: ccc.ScriptLike[],