@ckb-ccc/udt 0.1.24 → 0.2.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 +25 -0
- package/dist/barrel.d.mts +179 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +2 -0
- package/dist/barrel.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist.commonjs/barrel.d.ts +180 -2
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +2 -18
- package/dist.commonjs/barrel.js.map +1 -0
- package/dist.commonjs/index.d.ts +2 -3
- package/dist.commonjs/index.js +1 -41
- package/package.json +22 -21
- package/src/udt/index.ts +26 -6
- package/src/udtPausable/index.ts +13 -8
- package/tsdown.config.mts +41 -0
- package/dist/barrel.d.ts +0 -3
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/udt/index.d.ts +0 -108
- package/dist/udt/index.d.ts.map +0 -1
- package/dist/udt/index.js +0 -222
- package/dist/udtPausable/index.d.ts +0 -41
- package/dist/udtPausable/index.d.ts.map +0 -1
- package/dist/udtPausable/index.js +0 -79
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/udt/index.d.ts +0 -108
- package/dist.commonjs/udt/index.d.ts.map +0 -1
- package/dist.commonjs/udt/index.js +0 -226
- package/dist.commonjs/udtPausable/index.d.ts +0 -41
- package/dist.commonjs/udtPausable/index.d.ts.map +0 -1
- package/dist.commonjs/udtPausable/index.js +0 -83
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @ckb-ccc/udt
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#381](https://github.com/ckb-devrel/ccc/pull/381) [`46cc045`](https://github.com/ckb-devrel/ccc/commit/46cc045a3eefe9ba6625482dc7f740a0c59c99d4) Thanks [@Hanssen0](https://github.com/Hanssen0)! - chore: bump packages
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`46cc045`](https://github.com/ckb-devrel/ccc/commit/46cc045a3eefe9ba6625482dc7f740a0c59c99d4)]:
|
|
14
|
+
- @ckb-ccc/core@1.14.0
|
|
15
|
+
- @ckb-ccc/ssri@0.3.0
|
|
16
|
+
|
|
17
|
+
## 0.1.25
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
- [#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
|
|
23
|
+
|
|
24
|
+
- 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)]:
|
|
25
|
+
- @ckb-ccc/core@1.13.0
|
|
26
|
+
- @ckb-ccc/ssri@0.2.23
|
|
27
|
+
|
|
3
28
|
## 0.1.24
|
|
4
29
|
### Patch Changes
|
|
5
30
|
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { ssri } from "@ckb-ccc/ssri";
|
|
3
|
+
|
|
4
|
+
//#region src/udt/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Represents a User Defined Token (UDT) script compliant with the SSRI protocol.
|
|
7
|
+
*
|
|
8
|
+
* This class provides a comprehensive implementation for interacting with User Defined Tokens,
|
|
9
|
+
* supporting various token operations such as querying metadata, checking balances, and performing transfers.
|
|
10
|
+
* It supports both SSRI-compliant UDTs and legacy sUDT/xUDT standard tokens.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @category Blockchain
|
|
14
|
+
* @category Token
|
|
15
|
+
*/
|
|
16
|
+
declare class Udt extends ssri.Trait {
|
|
17
|
+
readonly script: ccc.Script;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new UDT (User Defined Token) script instance.
|
|
20
|
+
* By default it is a SSRI-compliant UDT.
|
|
21
|
+
*
|
|
22
|
+
* @param code - The script code cell of the UDT.
|
|
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.
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const udt = new Udt(code, script, { executor });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config?: {
|
|
32
|
+
executor?: ssri.Executor | null;
|
|
33
|
+
} | null);
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the human-readable name of the User Defined Token.
|
|
36
|
+
*
|
|
37
|
+
* @param context - Optional SSRI context for script execution.
|
|
38
|
+
* @returns A promise resolving to the token's name.
|
|
39
|
+
*/
|
|
40
|
+
name(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the symbol of the UDT.
|
|
43
|
+
* @param context - Optional SSRI context for script execution.
|
|
44
|
+
* @returns The symbol of the UDT.
|
|
45
|
+
*/
|
|
46
|
+
symbol(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the decimals of the UDT.
|
|
49
|
+
* @param context - Optional SSRI context for script execution.
|
|
50
|
+
* @returns The decimals of the UDT.
|
|
51
|
+
*/
|
|
52
|
+
decimals(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<ccc.Num | undefined>>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the icon of the UDT.
|
|
55
|
+
* @param context - Optional SSRI context for script execution.
|
|
56
|
+
* @returns The icon of the UDT.
|
|
57
|
+
*/
|
|
58
|
+
icon(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
59
|
+
/**
|
|
60
|
+
* Transfers UDT to specified addresses.
|
|
61
|
+
* @param signer - The signer to use for the transaction.
|
|
62
|
+
* @param transfers - The array of transfers.
|
|
63
|
+
* @param transfers.to - The receiver of token.
|
|
64
|
+
* @param transfers.amount - The amount of token to the receiver.
|
|
65
|
+
* @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
|
|
66
|
+
* @returns The transaction result.
|
|
67
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const { script: change } = await signer.getRecommendedAddressObj();
|
|
71
|
+
* const { script: to } = await ccc.Address.fromString(receiver, signer.client);
|
|
72
|
+
*
|
|
73
|
+
* const udt = new Udt(
|
|
74
|
+
* {
|
|
75
|
+
* txHash: "0x4e2e832e0b1e7b5994681b621b00c1e65f577ee4b440ef95fa07db9bb3d50269",
|
|
76
|
+
* index: 0,
|
|
77
|
+
* },
|
|
78
|
+
* {
|
|
79
|
+
* codeHash: "0xcc9dc33ef234e14bc788c43a4848556a5fb16401a04662fc55db9bb201987037",
|
|
80
|
+
* hashType: "type",
|
|
81
|
+
* args: "0x71fd1985b2971a9903e4d8ed0d59e6710166985217ca0681437883837b86162f"
|
|
82
|
+
* },
|
|
83
|
+
* );
|
|
84
|
+
*
|
|
85
|
+
* const { res: tx } = await udtTrait.transfer(
|
|
86
|
+
* signer,
|
|
87
|
+
* [{ to, amount: 100 }],
|
|
88
|
+
* );
|
|
89
|
+
*
|
|
90
|
+
* const completedTx = udt.completeUdtBy(tx, signer);
|
|
91
|
+
* await completedTx.completeInputsByCapacity(signer);
|
|
92
|
+
* await completedTx.completeFeeBy(signer);
|
|
93
|
+
* const transferTxHash = await signer.sendTransaction(completedTx);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
transfer(signer: ccc.Signer, transfers: {
|
|
97
|
+
to: ccc.ScriptLike;
|
|
98
|
+
amount: ccc.NumLike;
|
|
99
|
+
}[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
100
|
+
/**
|
|
101
|
+
* Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
|
|
102
|
+
* @param signer - The signer to use for the transaction.
|
|
103
|
+
* @param mints - Array of mints
|
|
104
|
+
* @param mints.to - receiver of token
|
|
105
|
+
* @param mints.amount - amount to the receiver
|
|
106
|
+
* @param tx - Optional existing transaction to build upon
|
|
107
|
+
* @returns The transaction containing the mint operation
|
|
108
|
+
* @tag Mutation - This method represents a mutation of the onchain state
|
|
109
|
+
*/
|
|
110
|
+
mint(signer: ccc.Signer, mints: {
|
|
111
|
+
to: ccc.ScriptLike;
|
|
112
|
+
amount: ccc.NumLike;
|
|
113
|
+
}[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
114
|
+
/**
|
|
115
|
+
* Completes a UDT transaction by adding change output to a specific lock script.
|
|
116
|
+
* @param txLike - The transaction to complete.
|
|
117
|
+
* @param signer - The signer to use for input selection.
|
|
118
|
+
* @param change - The lock script for the change output.
|
|
119
|
+
* @returns The completed transaction.
|
|
120
|
+
*/
|
|
121
|
+
completeChangeToLock(txLike: ccc.TransactionLike, signer: ccc.Signer, change: ccc.ScriptLike): Promise<ccc.Transaction>;
|
|
122
|
+
/**
|
|
123
|
+
* Completes a UDT transaction by adding change output to the signer's address.
|
|
124
|
+
* @param tx - The transaction to complete.
|
|
125
|
+
* @param from - The signer to use for input selection and change address.
|
|
126
|
+
* @returns The completed transaction.
|
|
127
|
+
*/
|
|
128
|
+
completeBy(tx: ccc.TransactionLike, from: ccc.Signer): Promise<ccc.Transaction>;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/udtPausable/index.d.ts
|
|
132
|
+
/**
|
|
133
|
+
* Represents a UDT (User Defined Token) with pausable functionality.
|
|
134
|
+
* @extends {Udt} This must be a SSRI UDT that does not fallback to xUDT.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
declare class UdtPausable extends Udt {
|
|
138
|
+
constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config: {
|
|
139
|
+
executor: ssri.Executor;
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* 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.
|
|
143
|
+
* @param signer - The signer to use for the transaction.
|
|
144
|
+
* @param locks - The array of lock scripts to be paused.
|
|
145
|
+
* @param tx - The transaction to be used.
|
|
146
|
+
* @param extraLockHashes - Additional lock hashes to be paused.
|
|
147
|
+
* @returns The transaction result.
|
|
148
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
|
|
149
|
+
*/
|
|
150
|
+
pause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
151
|
+
/**
|
|
152
|
+
* Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
|
|
153
|
+
* @param signer - The signer to use for the transaction.
|
|
154
|
+
* @param locks - The array of lock scripts to be unpaused.
|
|
155
|
+
* @param tx - The transaction to be used.
|
|
156
|
+
* @param extraLockHashes - Additional lock hashes to be unpaused.
|
|
157
|
+
* @returns The transaction result.
|
|
158
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
|
|
159
|
+
*/
|
|
160
|
+
unpause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
161
|
+
/**
|
|
162
|
+
* 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.
|
|
163
|
+
* @param locks - The lock scripts to check.
|
|
164
|
+
* @param extraLockHashes - Additional lock hashes to check.
|
|
165
|
+
* @returns True if any of the lock scripts are paused, false otherwise.
|
|
166
|
+
*/
|
|
167
|
+
isPaused(locks: ccc.ScriptLike[], extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<boolean[]>>;
|
|
168
|
+
/**
|
|
169
|
+
* Enumerates all paused lock hashes in UDTPausableData.
|
|
170
|
+
* @returns The array of lock hashes.
|
|
171
|
+
*/
|
|
172
|
+
enumeratePaused(offset?: ccc.Num, limit?: ccc.Num): Promise<ssri.ExecutorResponse<ccc.Hex[]>>;
|
|
173
|
+
}
|
|
174
|
+
declare namespace barrel_d_exports {
|
|
175
|
+
export { Udt, UdtPausable };
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { Udt, UdtPausable, barrel_d_exports as t };
|
|
179
|
+
//# sourceMappingURL=barrel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.mts","names":[],"sources":["../src/udt/index.ts","../src/udtPausable/index.ts","../src/barrel.ts"],"mappings":";;;;;;;AAcA;;;;;;;;cAAa,GAAA,SAAY,IAAA,CAAK,KAAA;EAAA,SACZ,MAAA,EAAQ,GAAA,CAAI,MAAA;EAsDhB;;;;;;;;;;;;;cAtCV,IAAA,EAAM,GAAA,CAAI,YAAA,EACV,MAAA,EAAQ,GAAA,CAAI,UAAA,EACZ,MAAA;IACE,QAAA,GAAW,IAAA,CAAK,QAAA;EAAA;EAkJjB;;;;;;EArIG,IAAA,CACJ,OAAA,GAAU,IAAA,CAAK,aAAA,GACd,OAAA,CAAQ,IAAA,CAAK,gBAAA;EA+Lb;;;;;EA5KG,MAAA,CACJ,OAAA,GAAU,IAAA,CAAK,aAAA,GACd,OAAA,CAAQ,IAAA,CAAK,gBAAA;EA0PK;;;;;EAlOf,QAAA,CACJ,OAAA,GAAU,IAAA,CAAK,aAAA,GACd,OAAA,CAAQ,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,GAAA;EAlFJ;;;;;EA0G3B,IAAA,CACJ,OAAA,GAAU,IAAA,CAAK,aAAA,GACd,OAAA,CAAQ,IAAA,CAAK,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDV,QAAA,CACJ,MAAA,EAAQ,GAAA,CAAI,MAAA,EACZ,SAAA;IACE,EAAA,EAAI,GAAA,CAAI,UAAA;IACR,MAAA,EAAQ,GAAA,CAAI,OAAA;EAAA,KAEd,EAAA,GAAK,GAAA,CAAI,eAAA,UACR,OAAA,CAAQ,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,WAAA;EAP/B;;;;;;;;;;EA4DA,IAAA,CACJ,MAAA,EA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I,UAAA,IACX,eAAA,GAAkB,GAAA,CAAI,OAAA,YACrB,OAAA,CAAQ,IAAA,CAAK,gBAAA;EDwLN;;;;ECpKJ,eAAA,CACJ,MAAA,GAAS,GAAA,CAAI,GAAA,EACb,KAAA,GAAQ,GAAA,CAAI,GAAA,GACX,OAAA,CAAQ,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,GAAA;AAAA;AAAA"}
|
package/dist/barrel.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{ccc as t}from"@ckb-ccc/core";import{ssri as n}from"@ckb-ccc/ssri";var r=class extends n.Trait{constructor(e,n,r){super(e,r?.executor),this.script=t.Script.from(n)}async name(e){if(this.executor){let n=await this.executor.runScriptTry(this.code,`UDT.name`,[],{script:this.script,...e});if(n)return n.map(e=>t.bytesTo(e,`utf8`))}return n.ExecutorResponse.new(void 0)}async symbol(e){if(this.executor){let n=await this.executor.runScriptTry(this.code,`UDT.symbol`,[],{script:this.script,...e});if(n)return n.map(e=>t.bytesTo(e,`utf8`))}return n.ExecutorResponse.new(void 0)}async decimals(e){if(this.executor){let n=await this.executor.runScriptTry(this.code,`UDT.decimals`,[],{script:this.script,...e});if(n)return n.map(e=>t.numFromBytes(e))}return n.ExecutorResponse.new(void 0)}async icon(e){if(this.executor){let n=await this.executor.runScriptTry(this.code,`UDT.icon`,[],{script:this.script,...e});if(n)return n.map(e=>t.bytesTo(e,`utf8`))}return n.ExecutorResponse.new(void 0)}async transfer(e,r,i){let a;if(this.executor){let n=t.Transaction.from(i??{});await n.completeInputsAtLeastOne(e);let o=await this.executor.runScriptTry(this.code,`UDT.transfer`,[n.toBytes(),t.ScriptVec.encode(r.map(({to:e})=>e)),t.mol.Uint128Vec.encode(r.map(({amount:e})=>e))],{script:this.script});o&&(a=o.map(e=>t.Transaction.fromBytes(e)))}if(!a){let e=t.Transaction.from(i??{});for(let{to:n,amount:i}of r)e.addOutput({lock:n,type:this.script},t.numLeToBytes(i,16));a=n.ExecutorResponse.new(e)}return a.res.addCellDeps({outPoint:this.code,depType:`code`}),a}async mint(e,r,i){let a;if(this.executor){let n=t.Transaction.from(i??{});await n.completeInputsAtLeastOne(e);let o=await this.executor.runScriptTry(this.code,`UDT.mint`,[n.toBytes(),t.ScriptVec.encode(r.map(({to:e})=>e)),t.mol.Uint128Vec.encode(r.map(({amount:e})=>e))],{script:this.script});o&&(a=o.map(e=>t.Transaction.fromBytes(e)))}if(!a){let e=t.Transaction.from(i??{});for(let{to:n,amount:i}of r)e.addOutput({lock:n,type:this.script},t.numLeToBytes(i,16));a=n.ExecutorResponse.new(e)}return a.res.addCellDeps({outPoint:this.code,depType:`code`}),a}async completeChangeToLock(e,n,r){let i=t.Transaction.from(e);await i.completeInputsByUdt(n,this.script);let a=await i.getInputsUdtBalance(n.client,this.script)-i.getOutputsUdtBalance(this.script);return a>t.Zero&&i.addOutput({lock:r,type:this.script},t.numLeToBytes(a,16)),i}async completeBy(e,t){let{script:n}=await t.getRecommendedAddressObj();return this.completeChangeToLock(e,t,n)}},i=class extends r{constructor(e,t,n){super(e,t,n)}async pause(e,n,r,i){let a=t.Transaction.from(r??{});await a.completeInputsAtLeastOne(e);let o=(await this.assertExecutor().runScript(this.code,`UDTPausable.pause`,[a.toBytes(),t.mol.Byte32Vec.encode(n.map(e=>t.Script.from(e).hash()).concat(i?.map(t.hexFrom)??[]))],{script:this.script})).map(e=>t.Transaction.fromBytes(e));return o.res.addCellDeps({outPoint:this.code,depType:`code`}),o}async unpause(e,n,r,i){let a=t.Transaction.from(r??{});await a.completeInputsAtLeastOne(e);let o=(await this.assertExecutor().runScript(this.code,`UDTPausable.unpause`,[a.toBytes(),t.mol.Byte32Vec.encode(n.map(e=>t.Script.from(e).hash()).concat(i?.map(t.hexFrom)??[]))],{script:this.script})).map(e=>t.Transaction.fromBytes(e));return o.res.addCellDeps({outPoint:this.code,depType:`code`}),o}async isPaused(e,n){return(await this.assertExecutor().runScript(this.code,`UDTPausable.is_paused`,[t.mol.Byte32Vec.encode(e.map(e=>t.Script.from(e).hash()).concat(n?.map(t.hexFrom)??[]))],{script:this.script})).map(e=>t.mol.BoolVec.decode(e))}async enumeratePaused(e,n){return(await this.assertExecutor().runScript(this.code,`UDTPausable.enumerate_paused`,[t.numToBytes(e??0,8),t.numToBytes(n??0,8)],{script:this.script})).map(e=>t.mol.Byte32Vec.decode(e))}},a=e({Udt:()=>r,UdtPausable:()=>i});export{r as Udt,i as UdtPausable,a as t};
|
|
2
|
+
//# sourceMappingURL=barrel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.mjs","names":[],"sources":["../src/udt/index.ts","../src/udtPausable/index.ts","../src/barrel.ts"],"sourcesContent":["import { ccc } from \"@ckb-ccc/core\";\nimport { ssri } from \"@ckb-ccc/ssri\";\n\n/**\n * Represents a User Defined Token (UDT) script compliant with the SSRI protocol.\n *\n * This class provides a comprehensive implementation for interacting with User Defined Tokens,\n * supporting various token operations such as querying metadata, checking balances, and performing transfers.\n * It supports both SSRI-compliant UDTs and legacy sUDT/xUDT standard tokens.\n *\n * @public\n * @category Blockchain\n * @category Token\n */\nexport class Udt extends ssri.Trait {\n public readonly script: ccc.Script;\n\n /**\n * Constructs a new UDT (User Defined Token) script instance.\n * By default it is a SSRI-compliant UDT.\n *\n * @param code - The script code cell of the UDT.\n * @param script - The type script of the UDT.\n * @param config - Optional configuration for the UDT instance.\n * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.\n * @example\n * ```typescript\n * const udt = new Udt(code, script, { executor });\n * ```\n */\n constructor(\n code: ccc.OutPointLike,\n script: ccc.ScriptLike,\n config?: {\n executor?: ssri.Executor | null;\n } | null,\n ) {\n super(code, config?.executor);\n this.script = ccc.Script.from(script);\n }\n\n /**\n * Retrieves the human-readable name of the User Defined Token.\n *\n * @param context - Optional SSRI context for script execution.\n * @returns A promise resolving to the token's name.\n */\n async name(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(this.code, \"UDT.name\", [], {\n script: this.script,\n ...context,\n });\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the symbol of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The symbol of the UDT.\n */\n async symbol(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.symbol\",\n [],\n {\n script: this.script,\n ...context,\n },\n );\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the decimals of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The decimals of the UDT.\n */\n async decimals(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<ccc.Num | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.decimals\",\n [],\n {\n script: this.script,\n ...context,\n },\n );\n if (res) {\n return res.map((res) => ccc.numFromBytes(res));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the icon of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The icon of the UDT.\n */\n async icon(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(this.code, \"UDT.icon\", [], {\n script: this.script,\n ...context,\n });\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Transfers UDT to specified addresses.\n * @param signer - The signer to use for the transaction.\n * @param transfers - The array of transfers.\n * @param transfers.to - The receiver of token.\n * @param transfers.amount - The amount of token to the receiver.\n * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.\n * @example\n * ```typescript\n * const { script: change } = await signer.getRecommendedAddressObj();\n * const { script: to } = await ccc.Address.fromString(receiver, signer.client);\n *\n * const udt = new Udt(\n * {\n * txHash: \"0x4e2e832e0b1e7b5994681b621b00c1e65f577ee4b440ef95fa07db9bb3d50269\",\n * index: 0,\n * },\n * {\n * codeHash: \"0xcc9dc33ef234e14bc788c43a4848556a5fb16401a04662fc55db9bb201987037\",\n * hashType: \"type\",\n * args: \"0x71fd1985b2971a9903e4d8ed0d59e6710166985217ca0681437883837b86162f\"\n * },\n * );\n *\n * const { res: tx } = await udtTrait.transfer(\n * signer,\n * [{ to, amount: 100 }],\n * );\n *\n * const completedTx = udt.completeUdtBy(tx, signer);\n * await completedTx.completeInputsByCapacity(signer);\n * await completedTx.completeFeeBy(signer);\n * const transferTxHash = await signer.sendTransaction(completedTx);\n * ```\n */\n async transfer(\n signer: ccc.Signer,\n transfers: {\n to: ccc.ScriptLike;\n amount: ccc.NumLike;\n }[],\n tx?: ccc.TransactionLike | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n let resTx;\n if (this.executor) {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.transfer\",\n [\n txReq.toBytes(),\n ccc.ScriptVec.encode(transfers.map(({ to }) => to)),\n ccc.mol.Uint128Vec.encode(transfers.map(({ amount }) => amount)),\n ],\n {\n script: this.script,\n },\n );\n if (res) {\n resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n }\n }\n\n if (!resTx) {\n const transfer = ccc.Transaction.from(tx ?? {});\n for (const { to, amount } of transfers) {\n transfer.addOutput(\n {\n lock: to,\n type: this.script,\n },\n ccc.numLeToBytes(amount, 16),\n );\n }\n resTx = ssri.ExecutorResponse.new(transfer);\n }\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.\n * @param signer - The signer to use for the transaction.\n * @param mints - Array of mints\n * @param mints.to - receiver of token\n * @param mints.amount - amount to the receiver\n * @param tx - Optional existing transaction to build upon\n * @returns The transaction containing the mint operation\n * @tag Mutation - This method represents a mutation of the onchain state\n */\n async mint(\n signer: ccc.Signer,\n mints: {\n to: ccc.ScriptLike;\n amount: ccc.NumLike;\n }[],\n tx?: ccc.TransactionLike | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n let resTx;\n if (this.executor) {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.mint\",\n [\n txReq.toBytes(),\n ccc.ScriptVec.encode(mints.map(({ to }) => to)),\n ccc.mol.Uint128Vec.encode(mints.map(({ amount }) => amount)),\n ],\n {\n script: this.script,\n },\n );\n if (res) {\n resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n }\n }\n\n if (!resTx) {\n const mint = ccc.Transaction.from(tx ?? {});\n for (const { to, amount } of mints) {\n mint.addOutput(\n {\n lock: to,\n type: this.script,\n },\n ccc.numLeToBytes(amount, 16),\n );\n }\n resTx = ssri.ExecutorResponse.new(mint);\n }\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Completes a UDT transaction by adding change output to a specific lock script.\n * @param txLike - The transaction to complete.\n * @param signer - The signer to use for input selection.\n * @param change - The lock script for the change output.\n * @returns The completed transaction.\n */\n async completeChangeToLock(\n txLike: ccc.TransactionLike,\n signer: ccc.Signer,\n change: ccc.ScriptLike,\n ) {\n const tx = ccc.Transaction.from(txLike);\n\n await tx.completeInputsByUdt(signer, this.script);\n const balanceDiff =\n (await tx.getInputsUdtBalance(signer.client, this.script)) -\n tx.getOutputsUdtBalance(this.script);\n if (balanceDiff > ccc.Zero) {\n tx.addOutput(\n {\n lock: change,\n type: this.script,\n },\n ccc.numLeToBytes(balanceDiff, 16),\n );\n }\n\n return tx;\n }\n\n /**\n * Completes a UDT transaction by adding change output to the signer's address.\n * @param tx - The transaction to complete.\n * @param from - The signer to use for input selection and change address.\n * @returns The completed transaction.\n */\n async completeBy(tx: ccc.TransactionLike, from: ccc.Signer) {\n const { script } = await from.getRecommendedAddressObj();\n\n return this.completeChangeToLock(tx, from, script);\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { ssri } from \"@ckb-ccc/ssri\";\nimport { Udt } from \"../udt/index.js\";\n\n/**\n * Represents a UDT (User Defined Token) with pausable functionality.\n * @extends {Udt} This must be a SSRI UDT that does not fallback to xUDT.\n * @public\n */\nexport class UdtPausable extends Udt {\n constructor(\n code: ccc.OutPointLike,\n script: ccc.ScriptLike,\n config: {\n executor: ssri.Executor;\n },\n ) {\n super(code, script, config);\n }\n\n /**\n * 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.\n * @param signer - The signer to use for the transaction.\n * @param locks - The array of lock scripts to be paused.\n * @param tx - The transaction to be used.\n * @param extraLockHashes - Additional lock hashes to be paused.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.\n */\n async pause(\n signer: ccc.Signer,\n locks: ccc.ScriptLike[],\n tx?: ccc.TransactionLike | null,\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.pause\",\n [\n txReq.toBytes(),\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n const resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.\n * @param signer - The signer to use for the transaction.\n * @param locks - The array of lock scripts to be unpaused.\n * @param tx - The transaction to be used.\n * @param extraLockHashes - Additional lock hashes to be unpaused.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.\n */\n async unpause(\n signer: ccc.Signer,\n locks: ccc.ScriptLike[],\n tx?: ccc.TransactionLike | null,\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.unpause\",\n [\n txReq.toBytes(),\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n const resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * 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.\n * @param locks - The lock scripts to check.\n * @param extraLockHashes - Additional lock hashes to check.\n * @returns True if any of the lock scripts are paused, false otherwise.\n */\n async isPaused(\n locks: ccc.ScriptLike[],\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<boolean[]>> {\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.is_paused\",\n [\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n return res.map((res) => ccc.mol.BoolVec.decode(res));\n }\n\n /**\n * Enumerates all paused lock hashes in UDTPausableData.\n * @returns The array of lock hashes.\n */\n async enumeratePaused(\n offset?: ccc.Num,\n limit?: ccc.Num,\n ): Promise<ssri.ExecutorResponse<ccc.Hex[]>> {\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.enumerate_paused\",\n [ccc.numToBytes(offset ?? 0, 8), ccc.numToBytes(limit ?? 0, 8)],\n { script: this.script },\n );\n\n return res.map((res) => ccc.mol.Byte32Vec.decode(res));\n }\n}\n","export * from \"./udt/index.js\";\nexport * from \"./udtPausable/index.js\";\n"],"mappings":"6HAcA,IAAa,EAAb,cAAyB,EAAK,KAAM,CAgBlC,YACE,EACA,EACA,EAGA,CACA,MAAM,EAAM,GAAQ,QAAQ,EAC5B,KAAK,OAAS,EAAI,OAAO,KAAK,CAAM,CACtC,CAQA,MAAM,KACJ,EACoD,CACpD,GAAI,KAAK,SAAU,CACjB,IAAM,EAAM,MAAM,KAAK,SAAS,aAAa,KAAK,KAAM,WAAY,CAAC,EAAG,CACtE,OAAQ,KAAK,OACb,GAAG,CACL,CAAC,EACD,GAAI,EACF,OAAO,EAAI,IAAK,GAAQ,EAAI,QAAQ,EAAK,MAAM,CAAC,CAEpD,CAEA,OAAO,EAAK,iBAAiB,IAAI,IAAA,EAAS,CAC5C,CAOA,MAAM,OACJ,EACoD,CACpD,GAAI,KAAK,SAAU,CACjB,IAAM,EAAM,MAAM,KAAK,SAAS,aAC9B,KAAK,KACL,aACA,CAAC,EACD,CACE,OAAQ,KAAK,OACb,GAAG,CACL,CACF,EACA,GAAI,EACF,OAAO,EAAI,IAAK,GAAQ,EAAI,QAAQ,EAAK,MAAM,CAAC,CAEpD,CAEA,OAAO,EAAK,iBAAiB,IAAI,IAAA,EAAS,CAC5C,CAOA,MAAM,SACJ,EACqD,CACrD,GAAI,KAAK,SAAU,CACjB,IAAM,EAAM,MAAM,KAAK,SAAS,aAC9B,KAAK,KACL,e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AAI,YAAY,CACpB,SAAU,KAAK,KACf,QAAS,MACX,CAAC,EACM,CACT,CAQA,MAAM,SACJ,EACA,EAC2C,CAa3C,OAAO,MAZW,KAAK,eAAe,CAAC,CAAC,UACtC,KAAK,KACL,wBACA,CACE,EAAI,IAAI,UAAU,OAChB,EACG,IAAK,GAAM,EAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CACrC,OAAO,GAAiB,IAAI,EAAI,OAAO,GAAK,CAAC,CAAC,CACnD,CACF,EACA,CAAE,OAAQ,KAAK,MAAO,CACxB,EAAA,CACW,IAAK,GAAQ,EAAI,IAAI,QAAQ,OAAO,CAAG,CAAC,CACrD,CAMA,MAAM,gBACJ,EACA,EAC2C,CAQ3C,OAAO,MAPW,KAAK,eAAe,CAAC,CAAC,UACtC,KAAK,KACL,+BACA,CAAC,EAAI,WAAW,GAAU,EAAG,CAAC,EAAG,EAAI,WAAW,GAAS,EAAG,CAAC,CAAC,EAC9D,CAAE,OAAQ,KAAK,MAAO,CACxB,EAAA,CAEW,IAAK,GAAQ,EAAI,IAAI,UAAU,OAAO,CAAG,CAAC,CACvD,CACF"}
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Udt as e,UdtPausable as t,t as n}from"./barrel.mjs";export{e as Udt,t as UdtPausable,n as udt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
|
@@ -1,3 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { ssri } from "@ckb-ccc/ssri";
|
|
3
|
+
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/udt/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Represents a User Defined Token (UDT) script compliant with the SSRI protocol.
|
|
9
|
+
*
|
|
10
|
+
* This class provides a comprehensive implementation for interacting with User Defined Tokens,
|
|
11
|
+
* supporting various token operations such as querying metadata, checking balances, and performing transfers.
|
|
12
|
+
* It supports both SSRI-compliant UDTs and legacy sUDT/xUDT standard tokens.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @category Blockchain
|
|
16
|
+
* @category Token
|
|
17
|
+
*/
|
|
18
|
+
declare class Udt extends ssri.Trait {
|
|
19
|
+
readonly script: ccc.Script;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new UDT (User Defined Token) script instance.
|
|
22
|
+
* By default it is a SSRI-compliant UDT.
|
|
23
|
+
*
|
|
24
|
+
* @param code - The script code cell of the UDT.
|
|
25
|
+
* @param script - The type script of the UDT.
|
|
26
|
+
* @param config - Optional configuration for the UDT instance.
|
|
27
|
+
* @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const udt = new Udt(code, script, { executor });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config?: {
|
|
34
|
+
executor?: ssri.Executor | null;
|
|
35
|
+
} | null);
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the human-readable name of the User Defined Token.
|
|
38
|
+
*
|
|
39
|
+
* @param context - Optional SSRI context for script execution.
|
|
40
|
+
* @returns A promise resolving to the token's name.
|
|
41
|
+
*/
|
|
42
|
+
name(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the symbol of the UDT.
|
|
45
|
+
* @param context - Optional SSRI context for script execution.
|
|
46
|
+
* @returns The symbol of the UDT.
|
|
47
|
+
*/
|
|
48
|
+
symbol(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the decimals of the UDT.
|
|
51
|
+
* @param context - Optional SSRI context for script execution.
|
|
52
|
+
* @returns The decimals of the UDT.
|
|
53
|
+
*/
|
|
54
|
+
decimals(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<ccc.Num | undefined>>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves the icon of the UDT.
|
|
57
|
+
* @param context - Optional SSRI context for script execution.
|
|
58
|
+
* @returns The icon of the UDT.
|
|
59
|
+
*/
|
|
60
|
+
icon(context?: ssri.ContextScript): Promise<ssri.ExecutorResponse<string | undefined>>;
|
|
61
|
+
/**
|
|
62
|
+
* Transfers UDT to specified addresses.
|
|
63
|
+
* @param signer - The signer to use for the transaction.
|
|
64
|
+
* @param transfers - The array of transfers.
|
|
65
|
+
* @param transfers.to - The receiver of token.
|
|
66
|
+
* @param transfers.amount - The amount of token to the receiver.
|
|
67
|
+
* @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.
|
|
68
|
+
* @returns The transaction result.
|
|
69
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const { script: change } = await signer.getRecommendedAddressObj();
|
|
73
|
+
* const { script: to } = await ccc.Address.fromString(receiver, signer.client);
|
|
74
|
+
*
|
|
75
|
+
* const udt = new Udt(
|
|
76
|
+
* {
|
|
77
|
+
* txHash: "0x4e2e832e0b1e7b5994681b621b00c1e65f577ee4b440ef95fa07db9bb3d50269",
|
|
78
|
+
* index: 0,
|
|
79
|
+
* },
|
|
80
|
+
* {
|
|
81
|
+
* codeHash: "0xcc9dc33ef234e14bc788c43a4848556a5fb16401a04662fc55db9bb201987037",
|
|
82
|
+
* hashType: "type",
|
|
83
|
+
* args: "0x71fd1985b2971a9903e4d8ed0d59e6710166985217ca0681437883837b86162f"
|
|
84
|
+
* },
|
|
85
|
+
* );
|
|
86
|
+
*
|
|
87
|
+
* const { res: tx } = await udtTrait.transfer(
|
|
88
|
+
* signer,
|
|
89
|
+
* [{ to, amount: 100 }],
|
|
90
|
+
* );
|
|
91
|
+
*
|
|
92
|
+
* const completedTx = udt.completeUdtBy(tx, signer);
|
|
93
|
+
* await completedTx.completeInputsByCapacity(signer);
|
|
94
|
+
* await completedTx.completeFeeBy(signer);
|
|
95
|
+
* const transferTxHash = await signer.sendTransaction(completedTx);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
transfer(signer: ccc.Signer, transfers: {
|
|
99
|
+
to: ccc.ScriptLike;
|
|
100
|
+
amount: ccc.NumLike;
|
|
101
|
+
}[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
102
|
+
/**
|
|
103
|
+
* Mints new tokens to specified addresses. See the example in `transfer` as they are similar.
|
|
104
|
+
* @param signer - The signer to use for the transaction.
|
|
105
|
+
* @param mints - Array of mints
|
|
106
|
+
* @param mints.to - receiver of token
|
|
107
|
+
* @param mints.amount - amount to the receiver
|
|
108
|
+
* @param tx - Optional existing transaction to build upon
|
|
109
|
+
* @returns The transaction containing the mint operation
|
|
110
|
+
* @tag Mutation - This method represents a mutation of the onchain state
|
|
111
|
+
*/
|
|
112
|
+
mint(signer: ccc.Signer, mints: {
|
|
113
|
+
to: ccc.ScriptLike;
|
|
114
|
+
amount: ccc.NumLike;
|
|
115
|
+
}[], tx?: ccc.TransactionLike | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
116
|
+
/**
|
|
117
|
+
* Completes a UDT transaction by adding change output to a specific lock script.
|
|
118
|
+
* @param txLike - The transaction to complete.
|
|
119
|
+
* @param signer - The signer to use for input selection.
|
|
120
|
+
* @param change - The lock script for the change output.
|
|
121
|
+
* @returns The completed transaction.
|
|
122
|
+
*/
|
|
123
|
+
completeChangeToLock(txLike: ccc.TransactionLike, signer: ccc.Signer, change: ccc.ScriptLike): Promise<ccc.Transaction>;
|
|
124
|
+
/**
|
|
125
|
+
* Completes a UDT transaction by adding change output to the signer's address.
|
|
126
|
+
* @param tx - The transaction to complete.
|
|
127
|
+
* @param from - The signer to use for input selection and change address.
|
|
128
|
+
* @returns The completed transaction.
|
|
129
|
+
*/
|
|
130
|
+
completeBy(tx: ccc.TransactionLike, from: ccc.Signer): Promise<ccc.Transaction>;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/udtPausable/index.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Represents a UDT (User Defined Token) with pausable functionality.
|
|
136
|
+
* @extends {Udt} This must be a SSRI UDT that does not fallback to xUDT.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
declare class UdtPausable extends Udt {
|
|
140
|
+
constructor(code: ccc.OutPointLike, script: ccc.ScriptLike, config: {
|
|
141
|
+
executor: ssri.Executor;
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* 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.
|
|
145
|
+
* @param signer - The signer to use for the transaction.
|
|
146
|
+
* @param locks - The array of lock scripts to be paused.
|
|
147
|
+
* @param tx - The transaction to be used.
|
|
148
|
+
* @param extraLockHashes - Additional lock hashes to be paused.
|
|
149
|
+
* @returns The transaction result.
|
|
150
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
|
|
151
|
+
*/
|
|
152
|
+
pause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
153
|
+
/**
|
|
154
|
+
* Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.
|
|
155
|
+
* @param signer - The signer to use for the transaction.
|
|
156
|
+
* @param locks - The array of lock scripts to be unpaused.
|
|
157
|
+
* @param tx - The transaction to be used.
|
|
158
|
+
* @param extraLockHashes - Additional lock hashes to be unpaused.
|
|
159
|
+
* @returns The transaction result.
|
|
160
|
+
* @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.
|
|
161
|
+
*/
|
|
162
|
+
unpause(signer: ccc.Signer, locks: ccc.ScriptLike[], tx?: ccc.TransactionLike | null, extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<ccc.Transaction>>;
|
|
163
|
+
/**
|
|
164
|
+
* 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.
|
|
165
|
+
* @param locks - The lock scripts to check.
|
|
166
|
+
* @param extraLockHashes - Additional lock hashes to check.
|
|
167
|
+
* @returns True if any of the lock scripts are paused, false otherwise.
|
|
168
|
+
*/
|
|
169
|
+
isPaused(locks: ccc.ScriptLike[], extraLockHashes?: ccc.HexLike[] | null): Promise<ssri.ExecutorResponse<boolean[]>>;
|
|
170
|
+
/**
|
|
171
|
+
* Enumerates all paused lock hashes in UDTPausableData.
|
|
172
|
+
* @returns The array of lock hashes.
|
|
173
|
+
*/
|
|
174
|
+
enumeratePaused(offset?: ccc.Num, limit?: ccc.Num): Promise<ssri.ExecutorResponse<ccc.Hex[]>>;
|
|
175
|
+
}
|
|
176
|
+
declare namespace barrel_d_exports {
|
|
177
|
+
export { Udt, UdtPausable };
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { Udt, UdtPausable, barrel_d_exports as t };
|
|
3
181
|
//# sourceMappingURL=barrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","names":[],"sources":["../src/udt/index.ts","../src/udtPausable/index.ts","../src/barrel.ts"],"mappings":";;;;;;;;;;;;;;;;;cAca,GAAA,SAAY,IAAA,CAAK,KAAA;EAAA,SACZ,MAAA,EAAQ,GAAA,CAAI,MAAA;;;;;;;AAD9B;;;;;;;cAiBI,IAAA,EAAM,GAAA,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wnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./udt/index.js"), exports);
|
|
18
|
-
__exportStar(require("./udtPausable/index.js"), exports);
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};let n=require("@ckb-ccc/core"),r=require("@ckb-ccc/ssri");var i=class extends r.ssri.Trait{constructor(e,t,r){super(e,r?.executor),this.script=n.ccc.Script.from(t)}async name(e){if(this.executor){let t=await this.executor.runScriptTry(this.code,`UDT.name`,[],{script:this.script,...e});if(t)return t.map(e=>n.ccc.bytesTo(e,`utf8`))}return r.ssri.ExecutorResponse.new(void 0)}async symbol(e){if(this.executor){let t=await this.executor.runScriptTry(this.code,`UDT.symbol`,[],{script:this.script,...e});if(t)return t.map(e=>n.ccc.bytesTo(e,`utf8`))}return r.ssri.ExecutorResponse.new(void 0)}async decimals(e){if(this.executor){let t=await this.executor.runScriptTry(this.code,`UDT.decimals`,[],{script:this.script,...e});if(t)return t.map(e=>n.ccc.numFromBytes(e))}return r.ssri.ExecutorResponse.new(void 0)}async icon(e){if(this.executor){let t=await this.executor.runScriptTry(this.code,`UDT.icon`,[],{script:this.script,...e});if(t)return t.map(e=>n.ccc.bytesTo(e,`utf8`))}return r.ssri.ExecutorResponse.new(void 0)}async transfer(e,t,i){let a;if(this.executor){let r=n.ccc.Transaction.from(i??{});await r.completeInputsAtLeastOne(e);let o=await this.executor.runScriptTry(this.code,`UDT.transfer`,[r.toBytes(),n.ccc.ScriptVec.encode(t.map(({to:e})=>e)),n.ccc.mol.Uint128Vec.encode(t.map(({amount:e})=>e))],{script:this.script});o&&(a=o.map(e=>n.ccc.Transaction.fromBytes(e)))}if(!a){let e=n.ccc.Transaction.from(i??{});for(let{to:r,amount:i}of t)e.addOutput({lock:r,type:this.script},n.ccc.numLeToBytes(i,16));a=r.ssri.ExecutorResponse.new(e)}return a.res.addCellDeps({outPoint:this.code,depType:`code`}),a}async mint(e,t,i){let a;if(this.executor){let r=n.ccc.Transaction.from(i??{});await r.completeInputsAtLeastOne(e);let o=await this.executor.runScriptTry(this.code,`UDT.mint`,[r.toBytes(),n.ccc.ScriptVec.encode(t.map(({to:e})=>e)),n.ccc.mol.Uint128Vec.encode(t.map(({amount:e})=>e))],{script:this.script});o&&(a=o.map(e=>n.ccc.Transaction.fromBytes(e)))}if(!a){let e=n.ccc.Transaction.from(i??{});for(let{to:r,amount:i}of t)e.addOutput({lock:r,type:this.script},n.ccc.numLeToBytes(i,16));a=r.ssri.ExecutorResponse.new(e)}return a.res.addCellDeps({outPoint:this.code,depType:`code`}),a}async completeChangeToLock(e,t,r){let i=n.ccc.Transaction.from(e);await i.completeInputsByUdt(t,this.script);let a=await i.getInputsUdtBalance(t.client,this.script)-i.getOutputsUdtBalance(this.script);return a>n.ccc.Zero&&i.addOutput({lock:r,type:this.script},n.ccc.numLeToBytes(a,16)),i}async completeBy(e,t){let{script:n}=await t.getRecommendedAddressObj();return this.completeChangeToLock(e,t,n)}},a=class extends i{constructor(e,t,n){super(e,t,n)}async pause(e,t,r,i){let a=n.ccc.Transaction.from(r??{});await a.completeInputsAtLeastOne(e);let o=(await this.assertExecutor().runScript(this.code,`UDTPausable.pause`,[a.toBytes(),n.ccc.mol.Byte32Vec.encode(t.map(e=>n.ccc.Script.from(e).hash()).concat(i?.map(n.ccc.hexFrom)??[]))],{script:this.script})).map(e=>n.ccc.Transaction.fromBytes(e));return o.res.addCellDeps({outPoint:this.code,depType:`code`}),o}async unpause(e,t,r,i){let a=n.ccc.Transaction.from(r??{});await a.completeInputsAtLeastOne(e);let o=(await this.assertExecutor().runScript(this.code,`UDTPausable.unpause`,[a.toBytes(),n.ccc.mol.Byte32Vec.encode(t.map(e=>n.ccc.Script.from(e).hash()).concat(i?.map(n.ccc.hexFrom)??[]))],{script:this.script})).map(e=>n.ccc.Transaction.fromBytes(e));return o.res.addCellDeps({outPoint:this.code,depType:`code`}),o}async isPaused(e,t){return(await this.assertExecutor().runScript(this.code,`UDTPausable.is_paused`,[n.ccc.mol.Byte32Vec.encode(e.map(e=>n.ccc.Script.from(e).hash()).concat(t?.map(n.ccc.hexFrom)??[]))],{script:this.script})).map(e=>n.ccc.mol.BoolVec.decode(e))}async enumeratePaused(e,t){return(await this.assertExecutor().runScript(this.code,`UDTPausable.enumerate_paused`,[n.ccc.numToBytes(e??0,8),n.ccc.numToBytes(t??0,8)],{script:this.script})).map(e=>n.ccc.mol.Byte32Vec.decode(e))}},o=t({Udt:()=>i,UdtPausable:()=>a});exports.Udt=i,exports.UdtPausable=a,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
2
|
+
//# sourceMappingURL=barrel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.js","names":["ssri","ccc","ccc"],"sources":["../src/udt/index.ts","../src/udtPausable/index.ts","../src/barrel.ts"],"sourcesContent":["import { ccc } from \"@ckb-ccc/core\";\nimport { ssri } from \"@ckb-ccc/ssri\";\n\n/**\n * Represents a User Defined Token (UDT) script compliant with the SSRI protocol.\n *\n * This class provides a comprehensive implementation for interacting with User Defined Tokens,\n * supporting various token operations such as querying metadata, checking balances, and performing transfers.\n * It supports both SSRI-compliant UDTs and legacy sUDT/xUDT standard tokens.\n *\n * @public\n * @category Blockchain\n * @category Token\n */\nexport class Udt extends ssri.Trait {\n public readonly script: ccc.Script;\n\n /**\n * Constructs a new UDT (User Defined Token) script instance.\n * By default it is a SSRI-compliant UDT.\n *\n * @param code - The script code cell of the UDT.\n * @param script - The type script of the UDT.\n * @param config - Optional configuration for the UDT instance.\n * @param config.executor - The SSRI executor instance. If provided, enables SSRI-based operations.\n * @example\n * ```typescript\n * const udt = new Udt(code, script, { executor });\n * ```\n */\n constructor(\n code: ccc.OutPointLike,\n script: ccc.ScriptLike,\n config?: {\n executor?: ssri.Executor | null;\n } | null,\n ) {\n super(code, config?.executor);\n this.script = ccc.Script.from(script);\n }\n\n /**\n * Retrieves the human-readable name of the User Defined Token.\n *\n * @param context - Optional SSRI context for script execution.\n * @returns A promise resolving to the token's name.\n */\n async name(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(this.code, \"UDT.name\", [], {\n script: this.script,\n ...context,\n });\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the symbol of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The symbol of the UDT.\n */\n async symbol(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.symbol\",\n [],\n {\n script: this.script,\n ...context,\n },\n );\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the decimals of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The decimals of the UDT.\n */\n async decimals(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<ccc.Num | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.decimals\",\n [],\n {\n script: this.script,\n ...context,\n },\n );\n if (res) {\n return res.map((res) => ccc.numFromBytes(res));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Retrieves the icon of the UDT.\n * @param context - Optional SSRI context for script execution.\n * @returns The icon of the UDT.\n */\n async icon(\n context?: ssri.ContextScript,\n ): Promise<ssri.ExecutorResponse<string | undefined>> {\n if (this.executor) {\n const res = await this.executor.runScriptTry(this.code, \"UDT.icon\", [], {\n script: this.script,\n ...context,\n });\n if (res) {\n return res.map((res) => ccc.bytesTo(res, \"utf8\"));\n }\n }\n\n return ssri.ExecutorResponse.new(undefined);\n }\n\n /**\n * Transfers UDT to specified addresses.\n * @param signer - The signer to use for the transaction.\n * @param transfers - The array of transfers.\n * @param transfers.to - The receiver of token.\n * @param transfers.amount - The amount of token to the receiver.\n * @param tx - Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction object.\n * @example\n * ```typescript\n * const { script: change } = await signer.getRecommendedAddressObj();\n * const { script: to } = await ccc.Address.fromString(receiver, signer.client);\n *\n * const udt = new Udt(\n * {\n * txHash: \"0x4e2e832e0b1e7b5994681b621b00c1e65f577ee4b440ef95fa07db9bb3d50269\",\n * index: 0,\n * },\n * {\n * codeHash: \"0xcc9dc33ef234e14bc788c43a4848556a5fb16401a04662fc55db9bb201987037\",\n * hashType: \"type\",\n * args: \"0x71fd1985b2971a9903e4d8ed0d59e6710166985217ca0681437883837b86162f\"\n * },\n * );\n *\n * const { res: tx } = await udtTrait.transfer(\n * signer,\n * [{ to, amount: 100 }],\n * );\n *\n * const completedTx = udt.completeUdtBy(tx, signer);\n * await completedTx.completeInputsByCapacity(signer);\n * await completedTx.completeFeeBy(signer);\n * const transferTxHash = await signer.sendTransaction(completedTx);\n * ```\n */\n async transfer(\n signer: ccc.Signer,\n transfers: {\n to: ccc.ScriptLike;\n amount: ccc.NumLike;\n }[],\n tx?: ccc.TransactionLike | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n let resTx;\n if (this.executor) {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.transfer\",\n [\n txReq.toBytes(),\n ccc.ScriptVec.encode(transfers.map(({ to }) => to)),\n ccc.mol.Uint128Vec.encode(transfers.map(({ amount }) => amount)),\n ],\n {\n script: this.script,\n },\n );\n if (res) {\n resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n }\n }\n\n if (!resTx) {\n const transfer = ccc.Transaction.from(tx ?? {});\n for (const { to, amount } of transfers) {\n transfer.addOutput(\n {\n lock: to,\n type: this.script,\n },\n ccc.numLeToBytes(amount, 16),\n );\n }\n resTx = ssri.ExecutorResponse.new(transfer);\n }\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Mints new tokens to specified addresses. See the example in `transfer` as they are similar.\n * @param signer - The signer to use for the transaction.\n * @param mints - Array of mints\n * @param mints.to - receiver of token\n * @param mints.amount - amount to the receiver\n * @param tx - Optional existing transaction to build upon\n * @returns The transaction containing the mint operation\n * @tag Mutation - This method represents a mutation of the onchain state\n */\n async mint(\n signer: ccc.Signer,\n mints: {\n to: ccc.ScriptLike;\n amount: ccc.NumLike;\n }[],\n tx?: ccc.TransactionLike | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n let resTx;\n if (this.executor) {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.executor.runScriptTry(\n this.code,\n \"UDT.mint\",\n [\n txReq.toBytes(),\n ccc.ScriptVec.encode(mints.map(({ to }) => to)),\n ccc.mol.Uint128Vec.encode(mints.map(({ amount }) => amount)),\n ],\n {\n script: this.script,\n },\n );\n if (res) {\n resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n }\n }\n\n if (!resTx) {\n const mint = ccc.Transaction.from(tx ?? {});\n for (const { to, amount } of mints) {\n mint.addOutput(\n {\n lock: to,\n type: this.script,\n },\n ccc.numLeToBytes(amount, 16),\n );\n }\n resTx = ssri.ExecutorResponse.new(mint);\n }\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Completes a UDT transaction by adding change output to a specific lock script.\n * @param txLike - The transaction to complete.\n * @param signer - The signer to use for input selection.\n * @param change - The lock script for the change output.\n * @returns The completed transaction.\n */\n async completeChangeToLock(\n txLike: ccc.TransactionLike,\n signer: ccc.Signer,\n change: ccc.ScriptLike,\n ) {\n const tx = ccc.Transaction.from(txLike);\n\n await tx.completeInputsByUdt(signer, this.script);\n const balanceDiff =\n (await tx.getInputsUdtBalance(signer.client, this.script)) -\n tx.getOutputsUdtBalance(this.script);\n if (balanceDiff > ccc.Zero) {\n tx.addOutput(\n {\n lock: change,\n type: this.script,\n },\n ccc.numLeToBytes(balanceDiff, 16),\n );\n }\n\n return tx;\n }\n\n /**\n * Completes a UDT transaction by adding change output to the signer's address.\n * @param tx - The transaction to complete.\n * @param from - The signer to use for input selection and change address.\n * @returns The completed transaction.\n */\n async completeBy(tx: ccc.TransactionLike, from: ccc.Signer) {\n const { script } = await from.getRecommendedAddressObj();\n\n return this.completeChangeToLock(tx, from, script);\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { ssri } from \"@ckb-ccc/ssri\";\nimport { Udt } from \"../udt/index.js\";\n\n/**\n * Represents a UDT (User Defined Token) with pausable functionality.\n * @extends {Udt} This must be a SSRI UDT that does not fallback to xUDT.\n * @public\n */\nexport class UdtPausable extends Udt {\n constructor(\n code: ccc.OutPointLike,\n script: ccc.ScriptLike,\n config: {\n executor: ssri.Executor;\n },\n ) {\n super(code, script, config);\n }\n\n /**\n * 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.\n * @param signer - The signer to use for the transaction.\n * @param locks - The array of lock scripts to be paused.\n * @param tx - The transaction to be used.\n * @param extraLockHashes - Additional lock hashes to be paused.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.\n */\n async pause(\n signer: ccc.Signer,\n locks: ccc.ScriptLike[],\n tx?: ccc.TransactionLike | null,\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.pause\",\n [\n txReq.toBytes(),\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n const resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * Unpauses the UDT for the specified lock scripts. Note that this method is only available if the pausable UDT uses external pause list.\n * @param signer - The signer to use for the transaction.\n * @param locks - The array of lock scripts to be unpaused.\n * @param tx - The transaction to be used.\n * @param extraLockHashes - Additional lock hashes to be unpaused.\n * @returns The transaction result.\n * @tag Mutation - This method represents a mutation of the onchain state and will return a transaction to be sent.\n */\n async unpause(\n signer: ccc.Signer,\n locks: ccc.ScriptLike[],\n tx?: ccc.TransactionLike | null,\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<ccc.Transaction>> {\n const txReq = ccc.Transaction.from(tx ?? {});\n await txReq.completeInputsAtLeastOne(signer);\n\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.unpause\",\n [\n txReq.toBytes(),\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n const resTx = res.map((res) => ccc.Transaction.fromBytes(res));\n resTx.res.addCellDeps({\n outPoint: this.code,\n depType: \"code\",\n });\n return resTx;\n }\n\n /**\n * 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.\n * @param locks - The lock scripts to check.\n * @param extraLockHashes - Additional lock hashes to check.\n * @returns True if any of the lock scripts are paused, false otherwise.\n */\n async isPaused(\n locks: ccc.ScriptLike[],\n extraLockHashes?: ccc.HexLike[] | null,\n ): Promise<ssri.ExecutorResponse<boolean[]>> {\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.is_paused\",\n [\n ccc.mol.Byte32Vec.encode(\n locks\n .map((l) => ccc.Script.from(l).hash())\n .concat(extraLockHashes?.map(ccc.hexFrom) ?? []),\n ),\n ],\n { script: this.script },\n );\n return res.map((res) => ccc.mol.BoolVec.decode(res));\n }\n\n /**\n * Enumerates all paused lock hashes in UDTPausableData.\n * @returns The array of lock hashes.\n */\n async enumeratePaused(\n offset?: ccc.Num,\n limit?: ccc.Num,\n ): Promise<ssri.ExecutorResponse<ccc.Hex[]>> {\n const res = await this.assertExecutor().runScript(\n this.code,\n \"UDTPausable.enumerate_paused\",\n [ccc.numToBytes(offset ?? 0, 8), ccc.numToBytes(limit ?? 0, 8)],\n { script: this.script },\n );\n\n return res.map((res) => ccc.mol.Byte32Vec.decode(res));\n }\n}\n","export * from \"./udt/index.js\";\nexport * from \"./udtPausable/index.js\";\n"],"mappings":"iRAcA,IAAa,EAAb,cAAyBA,EAAAA,KAAK,KAAM,CAgBlC,YACE,EACA,EACA,EAGA,CACA,MAAM,EAAM,GAAQ,QAAQ,EAC5B,KAAK,OAASC,EAAAA,IAAI,OAAO,KAAK,CAAM,CACtC,CAQA,MAAM,KACJ,EACoD,CACpD,GAAI,KAAK,SAAU,CACjB,IAAM,EAAM,MAAM,KAAK,SAAS,aAAa,KA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,KAAK,MAAO,CACxB,EAAA,CACW,IAAK,GAAQA,EAAAA,IAAI,IAAI,QAAQ,OAAO,CAAG,CAAC,CACrD,CAMA,MAAM,gBACJ,EACA,EAC2C,CAQ3C,OAAO,MAPW,KAAK,eAAe,CAAC,CAAC,UACtC,KAAK,KACL,+BACA,CAACA,EAAAA,IAAI,WAAW,GAAU,EAAG,CAAC,EAAGA,EAAAA,IAAI,WAAW,GAAS,EAAG,CAAC,CAAC,EAC9D,CAAE,OAAQ,KAAK,MAAO,CACxB,EAAA,CAEW,IAAK,GAAQA,EAAAA,IAAI,IAAI,UAAU,OAAO,CAAG,CAAC,CACvD,CACF"}
|
package/dist.commonjs/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { Udt, UdtPausable, t as barrel_d_exports } from "./barrel.js";
|
|
2
|
+
export { Udt, UdtPausable, barrel_d_exports as udt };
|
package/dist.commonjs/index.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.udt = void 0;
|
|
40
|
-
__exportStar(require("./barrel.js"), exports);
|
|
41
|
-
exports.udt = __importStar(require("./barrel.js"));
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./barrel.js");exports.Udt=e.Udt,exports.UdtPausable=e.UdtPausable,Object.defineProperty(exports,"udt",{enumerable:!0,get:function(){return e.t}});
|