@ickb/sdk 1000.0.71 → 1000.0.81

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.
Files changed (49) hide show
  1. package/dist/codec.d.ts +3 -0
  2. package/dist/codec.d.ts.map +1 -0
  3. package/dist/codec.js +58 -0
  4. package/dist/codec.js.map +1 -0
  5. package/dist/constants.d.ts +23 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/constants.js +95 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/sdk.d.ts +51 -0
  12. package/dist/sdk.d.ts.map +1 -0
  13. package/dist/sdk.js +242 -0
  14. package/dist/sdk.js.map +1 -0
  15. package/package.json +33 -18
  16. package/src/constants.ts +50 -45
  17. package/src/sdk.ts +2 -2
  18. package/dist/cjs/codec.d.ts +0 -14
  19. package/dist/cjs/codec.d.ts.map +0 -1
  20. package/dist/cjs/codec.js +0 -125
  21. package/dist/cjs/codec.js.map +0 -1
  22. package/dist/cjs/constants.d.ts +0 -49
  23. package/dist/cjs/constants.d.ts.map +0 -1
  24. package/dist/cjs/constants.js +0 -156
  25. package/dist/cjs/constants.js.map +0 -1
  26. package/dist/cjs/index.d.ts.map +0 -1
  27. package/dist/cjs/index.js +0 -20
  28. package/dist/cjs/index.js.map +0 -1
  29. package/dist/cjs/sdk.d.ts +0 -178
  30. package/dist/cjs/sdk.d.ts.map +0 -1
  31. package/dist/cjs/sdk.js +0 -362
  32. package/dist/cjs/sdk.js.map +0 -1
  33. package/dist/esm/codec.d.ts +0 -14
  34. package/dist/esm/codec.d.ts.map +0 -1
  35. package/dist/esm/codec.js +0 -122
  36. package/dist/esm/codec.js.map +0 -1
  37. package/dist/esm/constants.d.ts +0 -49
  38. package/dist/esm/constants.d.ts.map +0 -1
  39. package/dist/esm/constants.js +0 -152
  40. package/dist/esm/constants.js.map +0 -1
  41. package/dist/esm/index.d.ts +0 -4
  42. package/dist/esm/index.d.ts.map +0 -1
  43. package/dist/esm/index.js.map +0 -1
  44. package/dist/esm/sdk.d.ts +0 -178
  45. package/dist/esm/sdk.d.ts.map +0 -1
  46. package/dist/esm/sdk.js +0 -358
  47. package/dist/esm/sdk.js.map +0 -1
  48. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  49. /package/dist/{esm/index.js → index.js} +0 -0
package/src/constants.ts CHANGED
@@ -4,21 +4,6 @@ import { DaoManager } from "@ickb/dao";
4
4
  import { OrderManager } from "@ickb/order";
5
5
  import { CapacityManager, unique, type ScriptDeps } from "@ickb/utils";
6
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
7
  /**
23
8
  * Retrieves the configuration for the given deployment environment.
24
9
  *
@@ -28,19 +13,19 @@ export const UDT_DECIMALS = 8;
28
13
  * It sets up various managers (UDT, Logic, OwnedOwner, Order, Dao, Capacity) and also
29
14
  * aggregates a unique list of known bot scripts.
30
15
  *
31
- * @param deps - Either a network identifier ("mainnet"/"testnet") or an object containing
16
+ * @param d - Either a network identifier ("mainnet"/"testnet") or an object containing
32
17
  * explicit script dependencies for devnet.
33
18
  * @param bots - An optional array of bot script-like objects to augment the list of known bots.
34
19
  * @returns An object containing the instantiated managers and bots.
35
20
  */
36
21
  export function getConfig(
37
- deps:
22
+ d:
38
23
  | "mainnet"
39
24
  | "testnet"
40
25
  | {
41
26
  // For devnet configuration provide explicit script dependencies.
42
27
  udt: ScriptDeps;
43
- ickbLogic: ScriptDeps;
28
+ logic: ScriptDeps;
44
29
  ownedOwner: ScriptDeps;
45
30
  order: ScriptDeps;
46
31
  dao: ScriptDeps;
@@ -48,40 +33,60 @@ export function getConfig(
48
33
  bots: ccc.ScriptLike[] = [],
49
34
  ): {
50
35
  managers: {
51
- udt: IckbUdtManager;
52
- ickbLogic: LogicManager;
36
+ capacity: CapacityManager;
37
+ dao: DaoManager;
38
+ ickbUdt: IckbUdtManager;
39
+ logic: LogicManager;
53
40
  ownedOwner: OwnedOwnerManager;
54
41
  order: OrderManager;
55
- dao: DaoManager;
56
- capacity: CapacityManager;
57
42
  };
58
43
  bots: ccc.Script[];
59
44
  } {
60
45
  // If deps is provided as a network string, use the pre-defined constants.
61
- if (deps === "mainnet" || deps === "testnet") {
46
+ if (d === "mainnet" || d === "testnet") {
62
47
  bots = bots.concat(
63
- deps === "mainnet" ? MAINNET_KNOWN_BOTS : TESTNET_KNOWN_BOTS,
48
+ d === "mainnet" ? MAINNET_KNOWN_BOTS : TESTNET_KNOWN_BOTS,
64
49
  );
65
- const depGroup = deps === "mainnet" ? MAINNET_DEP_GROUP : TESTNET_DEP_GROUP;
66
- deps = {
50
+ const depGroup = d === "mainnet" ? MAINNET_DEP_GROUP : TESTNET_DEP_GROUP;
51
+ d = {
67
52
  udt: from(UDT, depGroup),
68
- ickbLogic: from(ICKB_LOGIC, depGroup),
53
+ logic: from(ICKB_LOGIC, depGroup),
69
54
  ownedOwner: from(OWNED_OWNER, depGroup),
70
55
  order: from(ORDER, depGroup),
71
56
  dao: from(DAO, depGroup),
72
57
  };
73
58
  }
74
59
 
75
- const daoManager = DaoManager.fromDeps(deps);
76
- const ickbUdtManager = IckbUdtManager.fromDeps(deps, daoManager);
60
+ const capacity = CapacityManager.withAnyData();
61
+ const dao = new DaoManager(d.dao.script, d.dao.cellDeps);
62
+ const ickbUdt = new IckbUdtManager(
63
+ d.udt.script,
64
+ d.udt.cellDeps,
65
+ d.logic.script,
66
+ dao,
67
+ );
68
+ const logic = new LogicManager(
69
+ d.logic.script,
70
+ d.logic.cellDeps,
71
+ dao,
72
+ ickbUdt,
73
+ );
74
+ const ownedOwner = new OwnedOwnerManager(
75
+ d.ownedOwner.script,
76
+ d.ownedOwner.cellDeps,
77
+ dao,
78
+ ickbUdt,
79
+ );
80
+ const order = new OrderManager(d.order.script, d.order.cellDeps, ickbUdt);
81
+
77
82
  return {
78
83
  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(),
84
+ capacity,
85
+ dao,
86
+ ickbUdt,
87
+ logic,
88
+ ownedOwner,
89
+ order,
85
90
  },
86
91
  bots: [...unique(bots.map((b) => ccc.Script.from(b)))],
87
92
  };
@@ -101,16 +106,6 @@ function from(script: ccc.ScriptLike, ...cellDeps: ccc.CellDep[]): ScriptDeps {
101
106
  };
102
107
  }
103
108
 
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
109
  /**
115
110
  * DAO (Decentralized Autonomous Organization) lock script information.
116
111
  */
@@ -121,6 +116,16 @@ const DAO = {
121
116
  args: "0x",
122
117
  };
123
118
 
119
+ /**
120
+ * UDT (User Defined Token) lock script information used for onchain validation.
121
+ */
122
+ const UDT = {
123
+ codeHash:
124
+ "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95",
125
+ hashType: "data1",
126
+ args: "0xb73b6ab39d79390c6de90a09c96b290c331baf1798ed6f97aed02590929734e800000080",
127
+ };
128
+
124
129
  /**
125
130
  * Logic script information for the iCKB logic contract.
126
131
  */
package/src/sdk.ts CHANGED
@@ -55,11 +55,11 @@ export class IckbSdk {
55
55
  */
56
56
  static from(...args: Parameters<typeof getConfig>): IckbSdk {
57
57
  const {
58
- managers: { ownedOwner, ickbLogic, order, capacity },
58
+ managers: { ownedOwner, logic, order, capacity },
59
59
  bots,
60
60
  } = getConfig(...args);
61
61
 
62
- return new IckbSdk(ownedOwner, ickbLogic, order, capacity, bots);
62
+ return new IckbSdk(ownedOwner, logic, order, capacity, bots);
63
63
  }
64
64
 
65
65
  /**
@@ -1,14 +0,0 @@
1
- import { mol } from "@ckb-ccc/core";
2
- /**
3
- * Codec for encoding and decoding a pool snapshot.
4
- *
5
- * The PoolSnapshotCodec encodes an array of 1024 numbers representing event counts for bins,
6
- * where the number of bits used per bin is dynamically computed as the ceiling of log2(max + 1)
7
- * across all bins. The codec provides methods to encode the array into a Uint8Array and decode
8
- * a Uint8Array back to the original array of numbers.
9
- *
10
- * @remarks The total number of bits for encoding all the bins is computed as bitsPerBin * 1024. The codec
11
- * does not have a fixed byteLength since it depends on the data.
12
- */
13
- export declare const PoolSnapshot: mol.Codec<number[], number[]>;
14
- //# sourceMappingURL=codec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,GAAG,EAAE,MAAM,eAAe,CAAC;AAKzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,+BAkDvB,CAAC"}
package/dist/cjs/codec.js DELETED
@@ -1,125 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PoolSnapshot = void 0;
4
- const core_1 = require("@ckb-ccc/core");
5
- const utils_1 = require("@ickb/utils");
6
- const N = 1024;
7
- /**
8
- * Codec for encoding and decoding a pool snapshot.
9
- *
10
- * The PoolSnapshotCodec encodes an array of 1024 numbers representing event counts for bins,
11
- * where the number of bits used per bin is dynamically computed as the ceiling of log2(max + 1)
12
- * across all bins. The codec provides methods to encode the array into a Uint8Array and decode
13
- * a Uint8Array back to the original array of numbers.
14
- *
15
- * @remarks The total number of bits for encoding all the bins is computed as bitsPerBin * 1024. The codec
16
- * does not have a fixed byteLength since it depends on the data.
17
- */
18
- exports.PoolSnapshot = core_1.mol.Codec.from({
19
- /**
20
- * Encodes an array of 1024 bin counts into a Uint8Array.
21
- *
22
- * @param bins - An array of 1024 numbers. Each number represents the event count for a bin.
23
- * @returns A Uint8Array containing the packed bit representation of the bin counts.
24
- * @throws Error if the input array does not contain exactly 1024 elements.
25
- */
26
- encode: (bins) => {
27
- if (bins.length !== N) {
28
- throw new Error("Expected 1024 bins");
29
- }
30
- const bitsPerBin = computeBits(bins);
31
- const buffer = new Uint8Array((bitsPerBin * N) >> 3);
32
- let bitOffset = 0;
33
- for (const count of bins) {
34
- packBits(buffer, bitOffset, bitsPerBin, count);
35
- bitOffset += bitsPerBin;
36
- }
37
- return buffer;
38
- },
39
- /**
40
- * Decodes a buffer into an array of 1024 bin counts.
41
- *
42
- * The function automatically computes the number of bits per bin from the buffer length,
43
- * expecting that the total number of bits in the buffer is a multiple of 1024.
44
- *
45
- * @param bufferLike - The input that can be converted into a Uint8Array.
46
- * @returns An array of 1024 numbers representing the decoded bin counts.
47
- * @throws Error if the buffer length is invalid (i.e., its total bit count is not divisible by 1024).
48
- */
49
- decode: (bufferLike) => {
50
- const buffer = core_1.ccc.bytesFrom(bufferLike);
51
- // Determine bitsPerBin from the fixed structure (totalBits divided by N).
52
- const bitsPerBin = (buffer.byteLength * 8) / N;
53
- if (!Number.isInteger(bitsPerBin)) {
54
- throw new Error("Invalid buffer length for 1024 bins");
55
- }
56
- const bins = new Array(N);
57
- let bitOffset = 0;
58
- for (let i = 0; i < N; i++) {
59
- bins[i] = unpackBits(buffer, bitOffset, bitsPerBin);
60
- bitOffset += bitsPerBin;
61
- }
62
- return bins;
63
- },
64
- // Note: The byteLength is not fixed as it depends on the data (i.e., the maximum bin count).
65
- });
66
- /**
67
- * Computes the minimal number of bits required to represent the maximum number in the bins.
68
- *
69
- * Given an array of numbers that represent counts for each bin, this function calculates
70
- * the number of bits required to represent the maximum bin count. A minimum of 1 bit is
71
- * always returned.
72
- *
73
- * @param bins - An array of numbers, each representing a bin's value.
74
- * @returns The minimal number of bits required to represent the highest value among the bins.
75
- */
76
- function computeBits(bins) {
77
- return Math.ceil(Math.log2(1 + (0, utils_1.max)(1, ...bins)));
78
- }
79
- /**
80
- * Packs a given numeric value into a Uint8Array (bit array) at the specified bit offset and width.
81
- *
82
- * The function encodes the given number into the provided buffer, using the specified number of bits (width)
83
- * starting from the specified bit offset. Each bit of the value is written into the buffer.
84
- *
85
- * @param buffer - The Uint8Array into which the value will be packed.
86
- * @param bitOffset - The starting bit index in the array where the value should be packed.
87
- * @param width - The number of bits to use for packing the value.
88
- * @param value - The numeric value to pack.
89
- */
90
- function packBits(buffer, bitOffset, width, value) {
91
- let offset = bitOffset;
92
- for (let i = 0; i < width; i++) {
93
- const byteIndex = offset >> 3;
94
- const bitInByte = offset % 8;
95
- const bit = (value >> i) & 1;
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- buffer[byteIndex] |= bit << bitInByte;
98
- offset++;
99
- }
100
- }
101
- /**
102
- * Unpacks a numeric value from a Uint8Array (bit array) starting at a given bit offset with a specified width.
103
- *
104
- * The function reads bits from the buffer starting at the bit offset and reconstructs a numeric value
105
- * using the specified number of bits (width).
106
- *
107
- * @param buffer - The Uint8Array from which the value will be unpacked.
108
- * @param bitOffset - The starting bit index in the buffer.
109
- * @param width - The number of bits to read for unpacking the value.
110
- * @returns The numeric value resulting from decoding the specified bits.
111
- */
112
- function unpackBits(buffer, bitOffset, width) {
113
- let value = 0;
114
- let offset = bitOffset;
115
- for (let i = 0; i < width; i++) {
116
- const byteIndex = offset >> 3;
117
- const bitInByte = offset % 8;
118
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
119
- const bit = (buffer[byteIndex] >> bitInByte) & 1;
120
- value |= bit << i;
121
- offset++;
122
- }
123
- return value;
124
- }
125
- //# sourceMappingURL=codec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec.js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G,MAAM,IAAI,CAAC,CAAC;QAC9B,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC;QAC7B,oEAAoE;QACpE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAE,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;QAClD,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC;QAClB,MAAM,EAAE,CAAC;IACX,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,49 +0,0 @@
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, type ScriptDeps } from "@ickb/utils";
6
- /**
7
- * The iCKB UDT name.
8
- */
9
- export declare const UDT_NAME = "iCKB";
10
- /**
11
- * The iCKB UDT symbol.
12
- */
13
- export declare const UDT_SYMBOL = "iCKB";
14
- /**
15
- * The iCKB UDT number of decimals.
16
- */
17
- export declare const UDT_DECIMALS = 8;
18
- /**
19
- * Retrieves the configuration for the given deployment environment.
20
- *
21
- * Accepts either a string identifier ("mainnet" or "testnet") or a custom configuration
22
- * object containing script dependencies for a devnet.
23
- *
24
- * It sets up various managers (UDT, Logic, OwnedOwner, Order, Dao, Capacity) and also
25
- * aggregates a unique list of known bot scripts.
26
- *
27
- * @param deps - Either a network identifier ("mainnet"/"testnet") or an object containing
28
- * explicit script dependencies for devnet.
29
- * @param bots - An optional array of bot script-like objects to augment the list of known bots.
30
- * @returns An object containing the instantiated managers and bots.
31
- */
32
- export declare function getConfig(deps: "mainnet" | "testnet" | {
33
- udt: ScriptDeps;
34
- ickbLogic: ScriptDeps;
35
- ownedOwner: ScriptDeps;
36
- order: ScriptDeps;
37
- dao: ScriptDeps;
38
- }, bots?: ccc.ScriptLike[]): {
39
- managers: {
40
- udt: IckbUdtManager;
41
- ickbLogic: LogicManager;
42
- ownedOwner: OwnedOwnerManager;
43
- order: OrderManager;
44
- dao: DaoManager;
45
- capacity: CapacityManager;
46
- };
47
- bots: ccc.Script[];
48
- };
49
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAU,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,IAAI,EACA,SAAS,GACT,SAAS,GACT;IAEE,GAAG,EAAE,UAAU,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,UAAU,CAAC;CACjB,EACL,IAAI,GAAE,GAAG,CAAC,UAAU,EAAO,GAC1B;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,cAAc,CAAC;QACpB,SAAS,EAAE,YAAY,CAAC;QACxB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,KAAK,EAAE,YAAY,CAAC;QACpB,GAAG,EAAE,UAAU,CAAC;QAChB,QAAQ,EAAE,eAAe,CAAC;KAC3B,CAAC;IACF,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;CACpB,CA6BA"}
@@ -1,156 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UDT_DECIMALS = exports.UDT_SYMBOL = exports.UDT_NAME = void 0;
4
- exports.getConfig = getConfig;
5
- const core_1 = require("@ckb-ccc/core");
6
- const core_2 = require("@ickb/core");
7
- const dao_1 = require("@ickb/dao");
8
- const order_1 = require("@ickb/order");
9
- const utils_1 = require("@ickb/utils");
10
- /**
11
- * The iCKB UDT name.
12
- */
13
- exports.UDT_NAME = "iCKB";
14
- /**
15
- * The iCKB UDT symbol.
16
- */
17
- exports.UDT_SYMBOL = "iCKB";
18
- /**
19
- * The iCKB UDT number of decimals.
20
- */
21
- exports.UDT_DECIMALS = 8;
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
- function getConfig(deps, bots = []) {
37
- // If deps is provided as a network string, use the pre-defined constants.
38
- if (deps === "mainnet" || deps === "testnet") {
39
- bots = bots.concat(deps === "mainnet" ? MAINNET_KNOWN_BOTS : TESTNET_KNOWN_BOTS);
40
- const depGroup = deps === "mainnet" ? MAINNET_DEP_GROUP : TESTNET_DEP_GROUP;
41
- deps = {
42
- udt: from(UDT, depGroup),
43
- ickbLogic: from(ICKB_LOGIC, depGroup),
44
- ownedOwner: from(OWNED_OWNER, depGroup),
45
- order: from(ORDER, depGroup),
46
- dao: from(DAO, depGroup),
47
- };
48
- }
49
- const daoManager = dao_1.DaoManager.fromDeps(deps);
50
- const ickbUdtManager = core_2.IckbUdtManager.fromDeps(deps, daoManager);
51
- return {
52
- managers: {
53
- udt: ickbUdtManager,
54
- ickbLogic: core_2.LogicManager.fromDeps(deps, daoManager, ickbUdtManager),
55
- ownedOwner: core_2.OwnedOwnerManager.fromDeps(deps, daoManager, ickbUdtManager),
56
- order: order_1.OrderManager.fromDeps(deps, ickbUdtManager),
57
- dao: daoManager,
58
- capacity: utils_1.CapacityManager.withAnyData(),
59
- },
60
- bots: [...(0, utils_1.unique)(bots.map((b) => core_1.ccc.Script.from(b)))],
61
- };
62
- }
63
- /**
64
- * Wraps a script-like object into a ScriptDeps structure.
65
- *
66
- * @param script - The script or script-like object.
67
- * @param cellDeps - Additional cell dependencies that the script may require.
68
- * @returns An object containing the script and its associated cell dependencies.
69
- */
70
- function from(script, ...cellDeps) {
71
- return {
72
- script: core_1.ccc.Script.from(script),
73
- cellDeps,
74
- };
75
- }
76
- /**
77
- * UDT (User Defined Token) lock script information used for onchain validation.
78
- */
79
- const UDT = {
80
- codeHash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95",
81
- hashType: "data1",
82
- args: "0xb73b6ab39d79390c6de90a09c96b290c331baf1798ed6f97aed02590929734e800000080",
83
- };
84
- /**
85
- * DAO (Decentralized Autonomous Organization) lock script information.
86
- */
87
- const DAO = {
88
- codeHash: "0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e",
89
- hashType: "type",
90
- args: "0x",
91
- };
92
- /**
93
- * Logic script information for the iCKB logic contract.
94
- */
95
- const ICKB_LOGIC = {
96
- codeHash: "0x2a8100ab5990fa055ab1b50891702e1e895c7bd1df6322cd725c1a6115873bd3",
97
- hashType: "data1",
98
- args: "0x",
99
- };
100
- /**
101
- * OwnedOwner lock script information.
102
- */
103
- const OWNED_OWNER = {
104
- codeHash: "0xacc79e07d107831feef4c70c9e683dac5644d5993b9cb106dca6e74baa381bd0",
105
- hashType: "data1",
106
- args: "0x",
107
- };
108
- /**
109
- * Order lock script information.
110
- */
111
- const ORDER = {
112
- codeHash: "0x49dfb6afee5cc8ac4225aeea8cb8928b150caf3cd92fea33750683c74b13254a",
113
- hashType: "data1",
114
- args: "0x",
115
- };
116
- /**
117
- * Mainnet dependency group cell dep.
118
- */
119
- const MAINNET_DEP_GROUP = core_1.ccc.CellDep.from({
120
- outPoint: {
121
- txHash: "0x621a6f38de3b9f453016780edac3b26bfcbfa3e2ecb47c2da275471a5d3ed165",
122
- index: "0x0",
123
- },
124
- depType: "depGroup",
125
- });
126
- /**
127
- * Testnet dependency group cell dep.
128
- */
129
- const TESTNET_DEP_GROUP = core_1.ccc.CellDep.from({
130
- outPoint: {
131
- txHash: "0xf7ece4fb33d8378344cab11fcd6a4c6f382fd4207ac921cf5821f30712dcd311",
132
- index: "0x0",
133
- },
134
- depType: "depGroup",
135
- });
136
- /**
137
- * Array of known bot scripts on the mainnet.
138
- */
139
- const MAINNET_KNOWN_BOTS = [
140
- {
141
- codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
142
- hashType: "type",
143
- args: "0xd096cb29e2f68a85a46bd6bf6cbee6327959ba64",
144
- },
145
- ];
146
- /**
147
- * Array of known bot scripts on the testnet.
148
- */
149
- const TESTNET_KNOWN_BOTS = [
150
- {
151
- codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
152
- hashType: "type",
153
- args: "0xb4380110f7679ac31cefe4925485645d82bf619f",
154
- },
155
- ];
156
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAmCA,8BAoDC;AAvFD,wCAAoC;AACpC,qCAA6E;AAC7E,mCAAuC;AACvC,uCAA2C;AAC3C,uCAAuE;AAEvE;;GAEG;AACU,QAAA,QAAQ,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACU,QAAA,UAAU,GAAG,MAAM,CAAC;AAEjC;;GAEG;AACU,QAAA,YAAY,GA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AC,IAAI,CAAC;IACzC,QAAQ,EAAE;QACR,MAAM,EACJ,oEAAoE;QACtE,KAAK,EAAE,KAAK;KACb;IACD,OAAO,EAAE,UAAU;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB;QACE,QAAQ,EACN,oEAAoE;QACtE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB;QACE,QAAQ,EACN,oEAAoE;QACtE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
package/dist/cjs/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
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 __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("./sdk.js"), exports);
18
- __exportStar(require("./codec.js"), exports);
19
- __exportStar(require("./constants.js"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,iDAA+B"}