@ickb/sdk 1000.0.52 → 1000.0.71
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/dist/cjs/codec.d.ts +14 -0
- package/dist/cjs/codec.d.ts.map +1 -0
- package/dist/cjs/codec.js +125 -0
- package/dist/cjs/codec.js.map +1 -0
- package/dist/cjs/constants.d.ts +49 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +156 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -189
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +17 -338
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sdk.d.ts +178 -0
- package/dist/cjs/sdk.d.ts.map +1 -0
- package/dist/cjs/sdk.js +362 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/codec.d.ts +14 -0
- package/dist/esm/codec.d.ts.map +1 -0
- package/dist/esm/codec.js +122 -0
- package/dist/esm/codec.js.map +1 -0
- package/dist/esm/constants.d.ts +49 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +152 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +3 -189
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -336
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sdk.d.ts +178 -0
- package/dist/esm/sdk.d.ts.map +1 -0
- package/dist/esm/sdk.js +358 -0
- package/dist/esm/sdk.js.map +1 -0
- package/package.json +8 -8
- package/src/codec.ts +138 -0
- package/src/constants.ts +200 -0
- package/src/index.ts +3 -573
- package/src/sdk.ts +513 -0
package/src/constants.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { IckbUdtManager, LogicManager, OwnedOwnerManager } from "@ickb/core";
|
|
3
|
+
import { DaoManager } from "@ickb/dao";
|
|
4
|
+
import { OrderManager } from "@ickb/order";
|
|
5
|
+
import { CapacityManager, unique, type ScriptDeps } from "@ickb/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The iCKB UDT name.
|
|
9
|
+
*/
|
|
10
|
+
export const UDT_NAME = "iCKB";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The iCKB UDT symbol.
|
|
14
|
+
*/
|
|
15
|
+
export const UDT_SYMBOL = "iCKB";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The iCKB UDT number of decimals.
|
|
19
|
+
*/
|
|
20
|
+
export const UDT_DECIMALS = 8;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the configuration for the given deployment environment.
|
|
24
|
+
*
|
|
25
|
+
* Accepts either a string identifier ("mainnet" or "testnet") or a custom configuration
|
|
26
|
+
* object containing script dependencies for a devnet.
|
|
27
|
+
*
|
|
28
|
+
* It sets up various managers (UDT, Logic, OwnedOwner, Order, Dao, Capacity) and also
|
|
29
|
+
* aggregates a unique list of known bot scripts.
|
|
30
|
+
*
|
|
31
|
+
* @param deps - Either a network identifier ("mainnet"/"testnet") or an object containing
|
|
32
|
+
* explicit script dependencies for devnet.
|
|
33
|
+
* @param bots - An optional array of bot script-like objects to augment the list of known bots.
|
|
34
|
+
* @returns An object containing the instantiated managers and bots.
|
|
35
|
+
*/
|
|
36
|
+
export function getConfig(
|
|
37
|
+
deps:
|
|
38
|
+
| "mainnet"
|
|
39
|
+
| "testnet"
|
|
40
|
+
| {
|
|
41
|
+
// For devnet configuration provide explicit script dependencies.
|
|
42
|
+
udt: ScriptDeps;
|
|
43
|
+
ickbLogic: ScriptDeps;
|
|
44
|
+
ownedOwner: ScriptDeps;
|
|
45
|
+
order: ScriptDeps;
|
|
46
|
+
dao: ScriptDeps;
|
|
47
|
+
},
|
|
48
|
+
bots: ccc.ScriptLike[] = [],
|
|
49
|
+
): {
|
|
50
|
+
managers: {
|
|
51
|
+
udt: IckbUdtManager;
|
|
52
|
+
ickbLogic: LogicManager;
|
|
53
|
+
ownedOwner: OwnedOwnerManager;
|
|
54
|
+
order: OrderManager;
|
|
55
|
+
dao: DaoManager;
|
|
56
|
+
capacity: CapacityManager;
|
|
57
|
+
};
|
|
58
|
+
bots: ccc.Script[];
|
|
59
|
+
} {
|
|
60
|
+
// If deps is provided as a network string, use the pre-defined constants.
|
|
61
|
+
if (deps === "mainnet" || deps === "testnet") {
|
|
62
|
+
bots = bots.concat(
|
|
63
|
+
deps === "mainnet" ? MAINNET_KNOWN_BOTS : TESTNET_KNOWN_BOTS,
|
|
64
|
+
);
|
|
65
|
+
const depGroup = deps === "mainnet" ? MAINNET_DEP_GROUP : TESTNET_DEP_GROUP;
|
|
66
|
+
deps = {
|
|
67
|
+
udt: from(UDT, depGroup),
|
|
68
|
+
ickbLogic: from(ICKB_LOGIC, depGroup),
|
|
69
|
+
ownedOwner: from(OWNED_OWNER, depGroup),
|
|
70
|
+
order: from(ORDER, depGroup),
|
|
71
|
+
dao: from(DAO, depGroup),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const daoManager = DaoManager.fromDeps(deps);
|
|
76
|
+
const ickbUdtManager = IckbUdtManager.fromDeps(deps, daoManager);
|
|
77
|
+
return {
|
|
78
|
+
managers: {
|
|
79
|
+
udt: ickbUdtManager,
|
|
80
|
+
ickbLogic: LogicManager.fromDeps(deps, daoManager, ickbUdtManager),
|
|
81
|
+
ownedOwner: OwnedOwnerManager.fromDeps(deps, daoManager, ickbUdtManager),
|
|
82
|
+
order: OrderManager.fromDeps(deps, ickbUdtManager),
|
|
83
|
+
dao: daoManager,
|
|
84
|
+
capacity: CapacityManager.withAnyData(),
|
|
85
|
+
},
|
|
86
|
+
bots: [...unique(bots.map((b) => ccc.Script.from(b)))],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Wraps a script-like object into a ScriptDeps structure.
|
|
92
|
+
*
|
|
93
|
+
* @param script - The script or script-like object.
|
|
94
|
+
* @param cellDeps - Additional cell dependencies that the script may require.
|
|
95
|
+
* @returns An object containing the script and its associated cell dependencies.
|
|
96
|
+
*/
|
|
97
|
+
function from(script: ccc.ScriptLike, ...cellDeps: ccc.CellDep[]): ScriptDeps {
|
|
98
|
+
return {
|
|
99
|
+
script: ccc.Script.from(script),
|
|
100
|
+
cellDeps,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* UDT (User Defined Token) lock script information used for onchain validation.
|
|
106
|
+
*/
|
|
107
|
+
const UDT = {
|
|
108
|
+
codeHash:
|
|
109
|
+
"0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95",
|
|
110
|
+
hashType: "data1",
|
|
111
|
+
args: "0xb73b6ab39d79390c6de90a09c96b290c331baf1798ed6f97aed02590929734e800000080",
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* DAO (Decentralized Autonomous Organization) lock script information.
|
|
116
|
+
*/
|
|
117
|
+
const DAO = {
|
|
118
|
+
codeHash:
|
|
119
|
+
"0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
|
|
120
|
+
hashType: "type",
|
|
121
|
+
args: "0x",
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Logic script information for the iCKB logic contract.
|
|
126
|
+
*/
|
|
127
|
+
const ICKB_LOGIC = {
|
|
128
|
+
codeHash:
|
|
129
|
+
"0x2a8100ab5990fa055ab1b50891702e1e895c7bd1df6322cd725c1a6115873bd3",
|
|
130
|
+
hashType: "data1",
|
|
131
|
+
args: "0x",
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* OwnedOwner lock script information.
|
|
136
|
+
*/
|
|
137
|
+
const OWNED_OWNER = {
|
|
138
|
+
codeHash:
|
|
139
|
+
"0xacc79e07d107831feef4c70c9e683dac5644d5993b9cb106dca6e74baa381bd0",
|
|
140
|
+
hashType: "data1",
|
|
141
|
+
args: "0x",
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Order lock script information.
|
|
146
|
+
*/
|
|
147
|
+
const ORDER = {
|
|
148
|
+
codeHash:
|
|
149
|
+
"0x49dfb6afee5cc8ac4225aeea8cb8928b150caf3cd92fea33750683c74b13254a",
|
|
150
|
+
hashType: "data1",
|
|
151
|
+
args: "0x",
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Mainnet dependency group cell dep.
|
|
156
|
+
*/
|
|
157
|
+
const MAINNET_DEP_GROUP = ccc.CellDep.from({
|
|
158
|
+
outPoint: {
|
|
159
|
+
txHash:
|
|
160
|
+
"0x621a6f38de3b9f453016780edac3b26bfcbfa3e2ecb47c2da275471a5d3ed165",
|
|
161
|
+
index: "0x0",
|
|
162
|
+
},
|
|
163
|
+
depType: "depGroup",
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Testnet dependency group cell dep.
|
|
168
|
+
*/
|
|
169
|
+
const TESTNET_DEP_GROUP = ccc.CellDep.from({
|
|
170
|
+
outPoint: {
|
|
171
|
+
txHash:
|
|
172
|
+
"0xf7ece4fb33d8378344cab11fcd6a4c6f382fd4207ac921cf5821f30712dcd311",
|
|
173
|
+
index: "0x0",
|
|
174
|
+
},
|
|
175
|
+
depType: "depGroup",
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Array of known bot scripts on the mainnet.
|
|
180
|
+
*/
|
|
181
|
+
const MAINNET_KNOWN_BOTS = [
|
|
182
|
+
{
|
|
183
|
+
codeHash:
|
|
184
|
+
"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
185
|
+
hashType: "type",
|
|
186
|
+
args: "0xd096cb29e2f68a85a46bd6bf6cbee6327959ba64",
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Array of known bot scripts on the testnet.
|
|
192
|
+
*/
|
|
193
|
+
const TESTNET_KNOWN_BOTS = [
|
|
194
|
+
{
|
|
195
|
+
codeHash:
|
|
196
|
+
"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
197
|
+
hashType: "type",
|
|
198
|
+
args: "0xb4380110f7679ac31cefe4925485645d82bf619f",
|
|
199
|
+
},
|
|
200
|
+
];
|