@ckb-ccc/spore 1.5.17 → 1.6.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 +23 -0
- package/dist/advanced.d.mts +3 -0
- package/dist/advanced.mjs +1 -0
- package/dist/advancedBarrel.d.mts +30 -0
- package/dist/advancedBarrel.d.mts.map +1 -0
- package/dist/advancedBarrel.mjs +1 -0
- package/dist/barrel-B4pnDQ_D.d.mts +324 -0
- package/dist/barrel-B4pnDQ_D.d.mts.map +1 -0
- package/dist/barrel-C4fV1nUf.mjs +2 -0
- package/dist/barrel-C4fV1nUf.mjs.map +1 -0
- package/dist/barrel.d.mts +3 -0
- package/dist/barrel.mjs +1 -0
- package/dist/cluster-KsFIhwZx.mjs +2 -0
- package/dist/cluster-KsFIhwZx.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist/types-1b682ehT.d.mts +1048 -0
- package/dist/types-1b682ehT.d.mts.map +1 -0
- package/dist.commonjs/advanced.d.ts +3 -3
- package/dist.commonjs/advanced.js +1 -41
- package/dist.commonjs/advancedBarrel.d.ts +29 -4
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/advancedBarrel.js +1 -20
- package/dist.commonjs/barrel-Dj_LwfvL.js +2 -0
- package/dist.commonjs/barrel-Dj_LwfvL.js.map +1 -0
- package/dist.commonjs/barrel-DsEUm55S.d.ts +324 -0
- package/dist.commonjs/barrel-DsEUm55S.d.ts.map +1 -0
- package/dist.commonjs/barrel.d.ts +3 -5
- package/dist.commonjs/barrel.js +1 -43
- package/dist.commonjs/cluster-CGo0DCM9.js +2 -0
- package/dist.commonjs/cluster-CGo0DCM9.js.map +1 -0
- package/dist.commonjs/index.d.ts +3 -3
- package/dist.commonjs/index.js +1 -41
- package/dist.commonjs/types-DjAlFsfK.d.ts +1050 -0
- package/dist.commonjs/types-DjAlFsfK.d.ts.map +1 -0
- package/package.json +30 -33
- package/src/cobuild/index.ts +10 -10
- package/src/codec/cluster.ts +2 -2
- package/src/codec/spore.ts +1 -1
- package/src/spore/advanced.ts +2 -2
- package/tsdown.config.mts +43 -0
- package/dist/advanced.d.ts +0 -3
- package/dist/advanced.d.ts.map +0 -1
- package/dist/advanced.js +0 -2
- package/dist/advancedBarrel.d.ts +0 -5
- package/dist/advancedBarrel.d.ts.map +0 -1
- package/dist/advancedBarrel.js +0 -4
- package/dist/barrel.d.ts +0 -5
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -4
- package/dist/cluster/index.d.ts +0 -95
- package/dist/cluster/index.d.ts.map +0 -1
- package/dist/cluster/index.js +0 -165
- package/dist/cobuild/index.d.ts +0 -12
- package/dist/cobuild/index.d.ts.map +0 -1
- package/dist/cobuild/index.js +0 -167
- package/dist/codec/cluster.d.ts +0 -34
- package/dist/codec/cluster.d.ts.map +0 -1
- package/dist/codec/cluster.js +0 -62
- package/dist/codec/cobuild/buildingPacket.d.ts +0 -268
- package/dist/codec/cobuild/buildingPacket.d.ts.map +0 -1
- package/dist/codec/cobuild/buildingPacket.js +0 -33
- package/dist/codec/cobuild/index.d.ts +0 -4
- package/dist/codec/cobuild/index.d.ts.map +0 -1
- package/dist/codec/cobuild/index.js +0 -3
- package/dist/codec/cobuild/sporeAction.d.ts +0 -589
- package/dist/codec/cobuild/sporeAction.d.ts.map +0 -1
- package/dist/codec/cobuild/sporeAction.js +0 -90
- package/dist/codec/cobuild/witnessLayout.d.ts +0 -126
- package/dist/codec/cobuild/witnessLayout.d.ts.map +0 -1
- package/dist/codec/cobuild/witnessLayout.js +0 -26
- package/dist/codec/index.d.ts +0 -4
- package/dist/codec/index.d.ts.map +0 -1
- package/dist/codec/index.js +0 -3
- package/dist/codec/spore.d.ts +0 -10
- package/dist/codec/spore.d.ts.map +0 -1
- package/dist/codec/spore.js +0 -16
- package/dist/dob/api/decode.d.ts +0 -8
- package/dist/dob/api/decode.d.ts.map +0 -1
- package/dist/dob/api/decode.js +0 -63
- package/dist/dob/api/encode.d.ts +0 -5
- package/dist/dob/api/encode.d.ts.map +0 -1
- package/dist/dob/api/encode.js +0 -81
- package/dist/dob/api/index.d.ts +0 -3
- package/dist/dob/api/index.d.ts.map +0 -1
- package/dist/dob/api/index.js +0 -2
- package/dist/dob/config/index.d.ts +0 -2
- package/dist/dob/config/index.d.ts.map +0 -1
- package/dist/dob/config/index.js +0 -1
- package/dist/dob/config/predefined.d.ts +0 -8
- package/dist/dob/config/predefined.d.ts.map +0 -1
- package/dist/dob/config/predefined.js +0 -59
- package/dist/dob/helper/check.d.ts +0 -5
- package/dist/dob/helper/check.d.ts.map +0 -1
- package/dist/dob/helper/check.js +0 -75
- package/dist/dob/helper/error.d.ts +0 -2
- package/dist/dob/helper/error.d.ts.map +0 -1
- package/dist/dob/helper/error.js +0 -40
- package/dist/dob/helper/index.d.ts +0 -4
- package/dist/dob/helper/index.d.ts.map +0 -1
- package/dist/dob/helper/index.js +0 -3
- package/dist/dob/helper/object.d.ts +0 -59
- package/dist/dob/helper/object.d.ts.map +0 -1
- package/dist/dob/helper/object.js +0 -1
- package/dist/dob/index.d.ts +0 -4
- package/dist/dob/index.d.ts.map +0 -1
- package/dist/dob/index.js +0 -3
- package/dist/helper/index.d.ts +0 -7
- package/dist/helper/index.d.ts.map +0 -1
- package/dist/helper/index.js +0 -18
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/predefined/advanced.d.ts +0 -3
- package/dist/predefined/advanced.d.ts.map +0 -1
- package/dist/predefined/advanced.js +0 -2
- package/dist/predefined/index.d.ts +0 -3
- package/dist/predefined/index.d.ts.map +0 -1
- package/dist/predefined/index.js +0 -2
- package/dist/predefined/mainnet.advanced.d.ts +0 -4
- package/dist/predefined/mainnet.advanced.d.ts.map +0 -1
- package/dist/predefined/mainnet.advanced.js +0 -61
- package/dist/predefined/testnet.advanced.d.ts +0 -4
- package/dist/predefined/testnet.advanced.d.ts.map +0 -1
- package/dist/predefined/testnet.advanced.js +0 -88
- package/dist/predefined/types.d.ts +0 -17
- package/dist/predefined/types.d.ts.map +0 -1
- package/dist/predefined/types.js +0 -18
- package/dist/predefined/utils.d.ts +0 -7
- package/dist/predefined/utils.d.ts.map +0 -1
- package/dist/predefined/utils.js +0 -26
- package/dist/spore/advanced.d.ts +0 -4
- package/dist/spore/advanced.d.ts.map +0 -1
- package/dist/spore/advanced.js +0 -54
- package/dist/spore/index.d.ts +0 -129
- package/dist/spore/index.d.ts.map +0 -1
- package/dist/spore/index.js +0 -218
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/barrel.d.ts.map +0 -1
- package/dist.commonjs/cluster/index.d.ts +0 -95
- package/dist.commonjs/cluster/index.d.ts.map +0 -1
- package/dist.commonjs/cluster/index.js +0 -173
- package/dist.commonjs/cobuild/index.d.ts +0 -12
- package/dist.commonjs/cobuild/index.d.ts.map +0 -1
- package/dist.commonjs/cobuild/index.js +0 -178
- package/dist.commonjs/codec/cluster.d.ts +0 -34
- package/dist.commonjs/codec/cluster.d.ts.map +0 -1
- package/dist.commonjs/codec/cluster.js +0 -71
- package/dist.commonjs/codec/cobuild/buildingPacket.d.ts +0 -268
- package/dist.commonjs/codec/cobuild/buildingPacket.d.ts.map +0 -1
- package/dist.commonjs/codec/cobuild/buildingPacket.js +0 -36
- package/dist.commonjs/codec/cobuild/index.d.ts +0 -4
- package/dist.commonjs/codec/cobuild/index.d.ts.map +0 -1
- package/dist.commonjs/codec/cobuild/index.js +0 -19
- package/dist.commonjs/codec/cobuild/sporeAction.d.ts +0 -589
- package/dist.commonjs/codec/cobuild/sporeAction.d.ts.map +0 -1
- package/dist.commonjs/codec/cobuild/sporeAction.js +0 -93
- package/dist.commonjs/codec/cobuild/witnessLayout.d.ts +0 -126
- package/dist.commonjs/codec/cobuild/witnessLayout.d.ts.map +0 -1
- package/dist.commonjs/codec/cobuild/witnessLayout.js +0 -29
- package/dist.commonjs/codec/index.d.ts +0 -4
- package/dist.commonjs/codec/index.d.ts.map +0 -1
- package/dist.commonjs/codec/index.js +0 -19
- package/dist.commonjs/codec/spore.d.ts +0 -10
- package/dist.commonjs/codec/spore.d.ts.map +0 -1
- package/dist.commonjs/codec/spore.js +0 -21
- package/dist.commonjs/dob/api/decode.d.ts +0 -8
- package/dist.commonjs/dob/api/decode.d.ts.map +0 -1
- package/dist.commonjs/dob/api/decode.js +0 -70
- package/dist.commonjs/dob/api/encode.d.ts +0 -5
- package/dist.commonjs/dob/api/encode.d.ts.map +0 -1
- package/dist.commonjs/dob/api/encode.js +0 -86
- package/dist.commonjs/dob/api/index.d.ts +0 -3
- package/dist.commonjs/dob/api/index.d.ts.map +0 -1
- package/dist.commonjs/dob/api/index.js +0 -18
- package/dist.commonjs/dob/config/index.d.ts +0 -2
- package/dist.commonjs/dob/config/index.d.ts.map +0 -1
- package/dist.commonjs/dob/config/index.js +0 -17
- package/dist.commonjs/dob/config/predefined.d.ts +0 -8
- package/dist.commonjs/dob/config/predefined.d.ts.map +0 -1
- package/dist.commonjs/dob/config/predefined.js +0 -63
- package/dist.commonjs/dob/helper/check.d.ts +0 -5
- package/dist.commonjs/dob/helper/check.d.ts.map +0 -1
- package/dist.commonjs/dob/helper/check.js +0 -80
- package/dist.commonjs/dob/helper/error.d.ts +0 -2
- package/dist.commonjs/dob/helper/error.d.ts.map +0 -1
- package/dist.commonjs/dob/helper/error.js +0 -43
- package/dist.commonjs/dob/helper/index.d.ts +0 -4
- package/dist.commonjs/dob/helper/index.d.ts.map +0 -1
- package/dist.commonjs/dob/helper/index.js +0 -19
- package/dist.commonjs/dob/helper/object.d.ts +0 -59
- package/dist.commonjs/dob/helper/object.d.ts.map +0 -1
- package/dist.commonjs/dob/helper/object.js +0 -2
- package/dist.commonjs/dob/index.d.ts +0 -4
- package/dist.commonjs/dob/index.d.ts.map +0 -1
- package/dist.commonjs/dob/index.js +0 -19
- package/dist.commonjs/helper/index.d.ts +0 -7
- package/dist.commonjs/helper/index.d.ts.map +0 -1
- package/dist.commonjs/helper/index.js +0 -21
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/predefined/advanced.d.ts +0 -3
- package/dist.commonjs/predefined/advanced.d.ts.map +0 -1
- package/dist.commonjs/predefined/advanced.js +0 -18
- package/dist.commonjs/predefined/index.d.ts +0 -3
- package/dist.commonjs/predefined/index.d.ts.map +0 -1
- package/dist.commonjs/predefined/index.js +0 -18
- package/dist.commonjs/predefined/mainnet.advanced.d.ts +0 -4
- package/dist.commonjs/predefined/mainnet.advanced.d.ts.map +0 -1
- package/dist.commonjs/predefined/mainnet.advanced.js +0 -64
- package/dist.commonjs/predefined/testnet.advanced.d.ts +0 -4
- package/dist.commonjs/predefined/testnet.advanced.d.ts.map +0 -1
- package/dist.commonjs/predefined/testnet.advanced.js +0 -91
- package/dist.commonjs/predefined/types.d.ts +0 -17
- package/dist.commonjs/predefined/types.d.ts.map +0 -1
- package/dist.commonjs/predefined/types.js +0 -22
- package/dist.commonjs/predefined/utils.d.ts +0 -7
- package/dist.commonjs/predefined/utils.d.ts.map +0 -1
- package/dist.commonjs/predefined/utils.js +0 -32
- package/dist.commonjs/spore/advanced.d.ts +0 -4
- package/dist.commonjs/spore/advanced.d.ts.map +0 -1
- package/dist.commonjs/spore/advanced.js +0 -57
- package/dist.commonjs/spore/index.d.ts +0 -129
- package/dist.commonjs/spore/index.d.ts.map +0 -1
- package/dist.commonjs/spore/index.js +0 -227
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { SporeDataView } from "../codec/index.js";
|
|
3
|
-
import { SporeScriptInfo, SporeScriptInfoLike } from "../predefined/index.js";
|
|
4
|
-
export declare function findSpore(client: ccc.Client, id: ccc.HexLike, scripts?: SporeScriptInfoLike[]): Promise<{
|
|
5
|
-
cell: ccc.Cell;
|
|
6
|
-
spore: ccc.Cell;
|
|
7
|
-
sporeData: SporeDataView;
|
|
8
|
-
scriptInfo: SporeScriptInfo;
|
|
9
|
-
} | undefined>;
|
|
10
|
-
export declare function assertSpore(client: ccc.Client, args: ccc.HexLike, scripts?: SporeScriptInfoLike[]): Promise<{
|
|
11
|
-
cell: ccc.Cell;
|
|
12
|
-
scriptInfo: SporeScriptInfo;
|
|
13
|
-
}>;
|
|
14
|
-
/**
|
|
15
|
-
* Create one Spore cell with the specified Spore data.
|
|
16
|
-
*
|
|
17
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
18
|
-
* @param params.data specific format of data required by Spore protocol
|
|
19
|
-
* @param params.to owner of new spore cell, signer if no provided
|
|
20
|
-
* @param params.clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
21
|
-
* - undefined: error if the spore has a cluster but the clusterMode is not set
|
|
22
|
-
* - lockProxy: put a cell that uses the same lock from Cluster cell in both Inputs and Outputs
|
|
23
|
-
* - clusterCell: directly put Cluster cell in Inputs and Outputs
|
|
24
|
-
* - skip: don't handle the cluster logic
|
|
25
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
26
|
-
* @param params.scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
27
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
28
|
-
* @returns
|
|
29
|
-
* - **tx**: a new transaction that contains created Spore cells
|
|
30
|
-
* - **id**: the sporeId of created Spore cell
|
|
31
|
-
*/
|
|
32
|
-
export declare function createSpore(params: {
|
|
33
|
-
signer: ccc.Signer;
|
|
34
|
-
data: SporeDataView;
|
|
35
|
-
to?: ccc.ScriptLike;
|
|
36
|
-
clusterMode?: "lockProxy" | "clusterCell" | "skip";
|
|
37
|
-
tx?: ccc.TransactionLike;
|
|
38
|
-
scriptInfo?: SporeScriptInfoLike;
|
|
39
|
-
scriptInfoHash?: ccc.HexLike;
|
|
40
|
-
}): Promise<{
|
|
41
|
-
tx: ccc.Transaction;
|
|
42
|
-
id: ccc.Hex;
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* Transfer one Spore cell
|
|
46
|
-
*
|
|
47
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
48
|
-
* @param params.id sporeId
|
|
49
|
-
* @param params.to Spore's new owner
|
|
50
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
51
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
52
|
-
* @returns
|
|
53
|
-
* - **tx**: a new transaction that contains transferred Spore cells
|
|
54
|
-
*/
|
|
55
|
-
export declare function transferSpore(params: {
|
|
56
|
-
signer: ccc.Signer;
|
|
57
|
-
id: ccc.HexLike;
|
|
58
|
-
to: ccc.ScriptLike;
|
|
59
|
-
tx?: ccc.TransactionLike;
|
|
60
|
-
scripts?: SporeScriptInfoLike[];
|
|
61
|
-
scriptInfoHash?: ccc.HexLike;
|
|
62
|
-
}): Promise<{
|
|
63
|
-
tx: ccc.Transaction;
|
|
64
|
-
}>;
|
|
65
|
-
/**
|
|
66
|
-
* Melt one Spore cell
|
|
67
|
-
*
|
|
68
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
69
|
-
* @param params.id sporeId to be melted
|
|
70
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
71
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
72
|
-
* @returns
|
|
73
|
-
* - **tx**: a new transaction that contains melted Spore cell
|
|
74
|
-
*/
|
|
75
|
-
export declare function meltSpore(params: {
|
|
76
|
-
signer: ccc.Signer;
|
|
77
|
-
id: ccc.HexLike;
|
|
78
|
-
tx?: ccc.TransactionLike;
|
|
79
|
-
scripts?: SporeScriptInfoLike[];
|
|
80
|
-
scriptInfoHash?: ccc.HexLike;
|
|
81
|
-
}): Promise<{
|
|
82
|
-
tx: ccc.Transaction;
|
|
83
|
-
}>;
|
|
84
|
-
/**
|
|
85
|
-
* Search on-chain spores under the signer's control, if cluster provided, filter spores belonging to this cluster
|
|
86
|
-
*
|
|
87
|
-
* @param params.signer the owner of spores
|
|
88
|
-
* @param params.order the order in creation time of spores
|
|
89
|
-
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
90
|
-
* @param params.scriptInfos the deployed script infos of spores
|
|
91
|
-
* @returns specified spore cells
|
|
92
|
-
*/
|
|
93
|
-
export declare function findSporesBySigner(params: {
|
|
94
|
-
signer: ccc.Signer;
|
|
95
|
-
order?: "asc" | "desc";
|
|
96
|
-
limit?: number;
|
|
97
|
-
clusterId?: ccc.HexLike;
|
|
98
|
-
scriptInfos?: SporeScriptInfoLike[];
|
|
99
|
-
}): AsyncGenerator<{
|
|
100
|
-
cell: ccc.Cell;
|
|
101
|
-
spore: ccc.Cell;
|
|
102
|
-
sporeData: SporeDataView;
|
|
103
|
-
scriptInfo: SporeScriptInfo;
|
|
104
|
-
}>;
|
|
105
|
-
/**
|
|
106
|
-
* Search on-chain spores under the specified lock or not, if cluster provided, filter spores belonging to this cluster
|
|
107
|
-
*
|
|
108
|
-
* @param params.client the client to search spores
|
|
109
|
-
* @param params.lock the lock of spores
|
|
110
|
-
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
111
|
-
* @param params.scriptInfos the deployed script infos of spores
|
|
112
|
-
* @param params.limit the limit of spores to search
|
|
113
|
-
* @param params.order the order in creation time of spores
|
|
114
|
-
* @returns specified spore cells
|
|
115
|
-
*/
|
|
116
|
-
export declare function findSpores(params: {
|
|
117
|
-
client: ccc.Client;
|
|
118
|
-
lock?: ccc.ScriptLike;
|
|
119
|
-
clusterId?: ccc.HexLike;
|
|
120
|
-
scriptInfos?: SporeScriptInfoLike[];
|
|
121
|
-
limit?: number;
|
|
122
|
-
order?: "asc" | "desc";
|
|
123
|
-
}): AsyncGenerator<{
|
|
124
|
-
cell: ccc.Cell;
|
|
125
|
-
spore: ccc.Cell;
|
|
126
|
-
sporeData: SporeDataView;
|
|
127
|
-
scriptInfo: SporeScriptInfo;
|
|
128
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IACjB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC,CAiCD;AAED;;;;;;;;;;GAUG;AACH,wBAAuB,UAAU,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB,GAAG,cAAc,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC;IACf,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC,CAwCD"}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findSpore = findSpore;
|
|
4
|
-
exports.assertSpore = assertSpore;
|
|
5
|
-
exports.createSpore = createSpore;
|
|
6
|
-
exports.transferSpore = transferSpore;
|
|
7
|
-
exports.meltSpore = meltSpore;
|
|
8
|
-
exports.findSporesBySigner = findSporesBySigner;
|
|
9
|
-
exports.findSpores = findSpores;
|
|
10
|
-
const core_1 = require("@ckb-ccc/core");
|
|
11
|
-
const advanced_js_1 = require("../advanced.js");
|
|
12
|
-
const index_js_1 = require("../codec/index.js");
|
|
13
|
-
const index_js_2 = require("../helper/index.js");
|
|
14
|
-
const index_js_3 = require("../predefined/index.js");
|
|
15
|
-
const advanced_js_2 = require("./advanced.js");
|
|
16
|
-
async function findSpore(client, id, scripts) {
|
|
17
|
-
const found = await (0, index_js_2.findSingletonCellByArgs)(client, id, scripts ?? Object.values((0, index_js_3.getSporeScriptInfos)(client)));
|
|
18
|
-
if (!found) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
cell: found.cell,
|
|
23
|
-
spore: found.cell,
|
|
24
|
-
sporeData: (0, index_js_1.unpackToRawSporeData)(found.cell.outputData),
|
|
25
|
-
scriptInfo: found.scriptInfo,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async function assertSpore(client, args, scripts) {
|
|
29
|
-
const res = await findSpore(client, args, scripts);
|
|
30
|
-
if (!res) {
|
|
31
|
-
throw new Error(`Spore ${core_1.ccc.hexFrom(args)} not found`);
|
|
32
|
-
}
|
|
33
|
-
return res;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Create one Spore cell with the specified Spore data.
|
|
37
|
-
*
|
|
38
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
39
|
-
* @param params.data specific format of data required by Spore protocol
|
|
40
|
-
* @param params.to owner of new spore cell, signer if no provided
|
|
41
|
-
* @param params.clusterMode how to process cluster cell **(if clusterId is not provided in SporeData, this parameter will be ignored)**
|
|
42
|
-
* - undefined: error if the spore has a cluster but the clusterMode is not set
|
|
43
|
-
* - lockProxy: put a cell that uses the same lock from Cluster cell in both Inputs and Outputs
|
|
44
|
-
* - clusterCell: directly put Cluster cell in Inputs and Outputs
|
|
45
|
-
* - skip: don't handle the cluster logic
|
|
46
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
47
|
-
* @param params.scriptInfo the script info of Spore cell, if not provided, the default script info will be used
|
|
48
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
49
|
-
* @returns
|
|
50
|
-
* - **tx**: a new transaction that contains created Spore cells
|
|
51
|
-
* - **id**: the sporeId of created Spore cell
|
|
52
|
-
*/
|
|
53
|
-
async function createSpore(params) {
|
|
54
|
-
const { signer, data, to, clusterMode, scriptInfoHash } = params;
|
|
55
|
-
const scriptInfo = params.scriptInfo ?? (0, index_js_3.getSporeScriptInfo)(signer.client);
|
|
56
|
-
// prepare transaction
|
|
57
|
-
const actions = [];
|
|
58
|
-
const ids = [];
|
|
59
|
-
const tx = core_1.ccc.Transaction.from(params.tx ?? {});
|
|
60
|
-
await tx.completeInputsAtLeastOne(signer);
|
|
61
|
-
const { script: lock } = await signer.getRecommendedAddressObj();
|
|
62
|
-
// build spore cell
|
|
63
|
-
const id = core_1.ccc.hashTypeId(tx.inputs[0], tx.outputs.length);
|
|
64
|
-
ids.push(id);
|
|
65
|
-
const packedData = (0, index_js_1.packRawSporeData)(data);
|
|
66
|
-
tx.addOutput({
|
|
67
|
-
lock: to ?? lock,
|
|
68
|
-
type: {
|
|
69
|
-
...scriptInfo,
|
|
70
|
-
args: id,
|
|
71
|
-
},
|
|
72
|
-
}, packedData);
|
|
73
|
-
// create spore action
|
|
74
|
-
if (scriptInfo.cobuild) {
|
|
75
|
-
const output = tx.outputs[tx.outputs.length - 1];
|
|
76
|
-
const createAction = (0, advanced_js_1.assembleCreateSporeAction)(output, packedData, scriptInfoHash);
|
|
77
|
-
actions.push(createAction);
|
|
78
|
-
}
|
|
79
|
-
// complete cellDeps
|
|
80
|
-
await tx.addCellDepInfos(signer.client, scriptInfo.cellDeps);
|
|
81
|
-
const action = await (0, advanced_js_2.prepareCluster)(signer, tx, data, clusterMode);
|
|
82
|
-
if (action) {
|
|
83
|
-
actions.push(action);
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
tx: await (0, advanced_js_1.prepareSporeTransaction)(signer, tx, actions),
|
|
87
|
-
id,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Transfer one Spore cell
|
|
92
|
-
*
|
|
93
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
94
|
-
* @param params.id sporeId
|
|
95
|
-
* @param params.to Spore's new owner
|
|
96
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
97
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
98
|
-
* @returns
|
|
99
|
-
* - **tx**: a new transaction that contains transferred Spore cells
|
|
100
|
-
*/
|
|
101
|
-
async function transferSpore(params) {
|
|
102
|
-
const { signer, id, to, scripts, scriptInfoHash } = params;
|
|
103
|
-
// prepare transaction
|
|
104
|
-
const tx = core_1.ccc.Transaction.from(params.tx ?? {});
|
|
105
|
-
const { cell: sporeCell, scriptInfo: sporeScriptInfo } = await assertSpore(signer.client, id, scripts);
|
|
106
|
-
await tx.addCellDepInfos(signer.client, sporeScriptInfo.cellDeps);
|
|
107
|
-
tx.addInput(sporeCell);
|
|
108
|
-
tx.addOutput({
|
|
109
|
-
lock: to,
|
|
110
|
-
type: sporeCell.cellOutput.type,
|
|
111
|
-
}, sporeCell.outputData);
|
|
112
|
-
const actions = sporeScriptInfo.cobuild
|
|
113
|
-
? [
|
|
114
|
-
(0, advanced_js_1.assembleTransferSporeAction)(sporeCell.cellOutput, tx.outputs[tx.outputs.length - 1], scriptInfoHash),
|
|
115
|
-
]
|
|
116
|
-
: [];
|
|
117
|
-
return {
|
|
118
|
-
tx: await (0, advanced_js_1.prepareSporeTransaction)(signer, tx, actions),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Melt one Spore cell
|
|
123
|
-
*
|
|
124
|
-
* @param params.signer who takes the responsibility to balance and sign the transaction
|
|
125
|
-
* @param params.id sporeId to be melted
|
|
126
|
-
* @param params.tx the transaction skeleton, if not provided, a new one will be created
|
|
127
|
-
* @param params.scriptInfoHash the script info hash used in cobuild
|
|
128
|
-
* @returns
|
|
129
|
-
* - **tx**: a new transaction that contains melted Spore cell
|
|
130
|
-
*/
|
|
131
|
-
async function meltSpore(params) {
|
|
132
|
-
const { signer, id, scripts, scriptInfoHash } = params;
|
|
133
|
-
// prepare transaction
|
|
134
|
-
const tx = core_1.ccc.Transaction.from(params.tx ?? {});
|
|
135
|
-
// build spore cell
|
|
136
|
-
const { cell: sporeCell, scriptInfo: sporeScriptInfo } = await assertSpore(signer.client, id, scripts);
|
|
137
|
-
await tx.addCellDepInfos(signer.client, sporeScriptInfo.cellDeps);
|
|
138
|
-
tx.addInput(sporeCell);
|
|
139
|
-
const actions = sporeScriptInfo.cobuild
|
|
140
|
-
? [(0, advanced_js_1.assembleMeltSporeAction)(sporeCell.cellOutput, scriptInfoHash)]
|
|
141
|
-
: [];
|
|
142
|
-
return {
|
|
143
|
-
tx: await (0, advanced_js_1.prepareSporeTransaction)(signer, tx, actions),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Search on-chain spores under the signer's control, if cluster provided, filter spores belonging to this cluster
|
|
148
|
-
*
|
|
149
|
-
* @param params.signer the owner of spores
|
|
150
|
-
* @param params.order the order in creation time of spores
|
|
151
|
-
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
152
|
-
* @param params.scriptInfos the deployed script infos of spores
|
|
153
|
-
* @returns specified spore cells
|
|
154
|
-
*/
|
|
155
|
-
async function* findSporesBySigner(params) {
|
|
156
|
-
const { signer, clusterId, scriptInfos, limit, order } = params;
|
|
157
|
-
for (const scriptInfo of scriptInfos ??
|
|
158
|
-
Object.values((0, index_js_3.getSporeScriptInfos)(signer.client))) {
|
|
159
|
-
if (!scriptInfo) {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
for await (const spore of signer.findCells({
|
|
163
|
-
script: {
|
|
164
|
-
...scriptInfo,
|
|
165
|
-
args: [],
|
|
166
|
-
},
|
|
167
|
-
}, true, order, limit)) {
|
|
168
|
-
const sporeData = (0, index_js_1.unpackToRawSporeData)(spore.outputData);
|
|
169
|
-
if (!clusterId ||
|
|
170
|
-
(clusterId === "" && !sporeData.clusterId) ||
|
|
171
|
-
sporeData.clusterId === core_1.ccc.hexFrom(clusterId)) {
|
|
172
|
-
yield {
|
|
173
|
-
cell: spore,
|
|
174
|
-
spore,
|
|
175
|
-
sporeData,
|
|
176
|
-
scriptInfo: index_js_3.SporeScriptInfo.from(scriptInfo),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Search on-chain spores under the specified lock or not, if cluster provided, filter spores belonging to this cluster
|
|
184
|
-
*
|
|
185
|
-
* @param params.client the client to search spores
|
|
186
|
-
* @param params.lock the lock of spores
|
|
187
|
-
* @param params.clusterId the cluster that spores belong to. "" to find public spores
|
|
188
|
-
* @param params.scriptInfos the deployed script infos of spores
|
|
189
|
-
* @param params.limit the limit of spores to search
|
|
190
|
-
* @param params.order the order in creation time of spores
|
|
191
|
-
* @returns specified spore cells
|
|
192
|
-
*/
|
|
193
|
-
async function* findSpores(params) {
|
|
194
|
-
const { client, lock, clusterId, scriptInfos, limit, order } = params;
|
|
195
|
-
for (const scriptInfo of scriptInfos ??
|
|
196
|
-
Object.values((0, index_js_3.getSporeScriptInfos)(client))) {
|
|
197
|
-
if (!scriptInfo) {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
for await (const spore of client.findCells({
|
|
201
|
-
script: {
|
|
202
|
-
...scriptInfo,
|
|
203
|
-
args: [],
|
|
204
|
-
},
|
|
205
|
-
scriptType: "type",
|
|
206
|
-
scriptSearchMode: "prefix",
|
|
207
|
-
withData: true,
|
|
208
|
-
filter: lock
|
|
209
|
-
? {
|
|
210
|
-
script: lock,
|
|
211
|
-
}
|
|
212
|
-
: undefined,
|
|
213
|
-
}, order, limit)) {
|
|
214
|
-
const sporeData = (0, index_js_1.unpackToRawSporeData)(spore.outputData);
|
|
215
|
-
if (!clusterId ||
|
|
216
|
-
(clusterId === "" && !sporeData.clusterId) ||
|
|
217
|
-
sporeData.clusterId === core_1.ccc.hexFrom(clusterId)) {
|
|
218
|
-
yield {
|
|
219
|
-
cell: spore,
|
|
220
|
-
spore,
|
|
221
|
-
sporeData,
|
|
222
|
-
scriptInfo: index_js_3.SporeScriptInfo.from(scriptInfo),
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|