@ckb-ccc/core 0.0.5-alpha.0 → 0.0.5-alpha.10

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 (230) hide show
  1. package/dist/address/index.d.ts +1 -1
  2. package/dist/address/index.d.ts.map +1 -1
  3. package/dist/address/index.js +4 -4
  4. package/dist/ckb/transaction.d.ts +2 -2
  5. package/dist/ckb/transaction.d.ts.map +1 -1
  6. package/dist/ckb/transaction.js +2 -3
  7. package/dist/client/client.d.ts +6 -3
  8. package/dist/client/client.d.ts.map +1 -1
  9. package/dist/client/client.js +16 -0
  10. package/dist/client/clientPublicMainnet.d.ts +1 -1
  11. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  12. package/dist/client/clientPublicMainnet.js +1 -1
  13. package/dist/client/clientPublicTestnet.d.ts +1 -1
  14. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  15. package/dist/client/clientPublicTestnet.js +1 -1
  16. package/dist/client/jsonRpc/index.d.ts +15 -5
  17. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  18. package/dist/client/jsonRpc/index.js +16 -6
  19. package/dist/signer/btc/index.d.ts +1 -0
  20. package/dist/signer/btc/index.d.ts.map +1 -1
  21. package/dist/signer/btc/index.js +1 -0
  22. package/dist/signer/btc/signerBtc.d.ts +9 -1
  23. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  24. package/dist/signer/btc/signerBtc.js +19 -3
  25. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
  26. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  27. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
  28. package/dist/signer/btc/verify.d.ts +3 -0
  29. package/dist/signer/btc/verify.d.ts.map +1 -0
  30. package/dist/signer/btc/verify.js +6 -0
  31. package/dist/signer/ckb/index.d.ts +1 -0
  32. package/dist/signer/ckb/index.d.ts.map +1 -1
  33. package/dist/signer/ckb/index.js +1 -0
  34. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -7
  35. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  36. package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -10
  37. package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
  38. package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
  39. package/dist/signer/ckb/verifyJoyId.js +12 -0
  40. package/dist/signer/dummy/alwaysError.d.ts +9 -0
  41. package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
  42. package/dist/signer/dummy/alwaysError.js +10 -0
  43. package/dist/signer/dummy/dummy.d.ts +12 -0
  44. package/dist/signer/dummy/dummy.d.ts.map +1 -0
  45. package/dist/signer/dummy/dummy.js +19 -0
  46. package/dist/signer/dummy/index.d.ts +4 -0
  47. package/dist/signer/dummy/index.d.ts.map +1 -0
  48. package/dist/signer/dummy/index.js +3 -0
  49. package/dist/signer/dummy/openLink.d.ts +9 -0
  50. package/dist/signer/dummy/openLink.d.ts.map +1 -0
  51. package/dist/signer/dummy/openLink.js +10 -0
  52. package/dist/signer/evm/index.d.ts +1 -0
  53. package/dist/signer/evm/index.d.ts.map +1 -1
  54. package/dist/signer/evm/index.js +1 -0
  55. package/dist/signer/evm/signerEvm.d.ts +3 -1
  56. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  57. package/dist/signer/evm/signerEvm.js +10 -4
  58. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
  59. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  60. package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
  61. package/dist/signer/evm/verify.d.ts +3 -0
  62. package/dist/signer/evm/verify.d.ts.map +1 -0
  63. package/dist/signer/evm/verify.js +6 -0
  64. package/dist/signer/index.d.ts +1 -0
  65. package/dist/signer/index.d.ts.map +1 -1
  66. package/dist/signer/index.js +1 -0
  67. package/{dist.commonjs/signer/signer.d.ts → dist/signer/signer/index.d.ts} +75 -24
  68. package/dist/signer/signer/index.d.ts.map +1 -0
  69. package/dist/signer/signer/index.js +205 -0
  70. package/dist/utils/index.d.ts +60 -0
  71. package/dist/utils/index.d.ts.map +1 -1
  72. package/dist/utils/index.js +20 -0
  73. package/dist.commonjs/address/address.advanced.d.ts +29 -24
  74. package/dist.commonjs/address/address.advanced.js +114 -92
  75. package/dist.commonjs/address/advanced.d.ts +1 -1
  76. package/dist.commonjs/address/advanced.js +30 -14
  77. package/dist.commonjs/address/index.d.ts +51 -44
  78. package/dist.commonjs/address/index.d.ts.map +1 -1
  79. package/dist.commonjs/address/index.js +87 -68
  80. package/dist.commonjs/advanced.d.ts +1 -1
  81. package/dist.commonjs/advanced.js +47 -22
  82. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  83. package/dist.commonjs/advancedBarrel.js +30 -14
  84. package/dist.commonjs/barrel.d.ts +1 -1
  85. package/dist.commonjs/barrel.js +30 -14
  86. package/dist.commonjs/bytes/advanced.d.ts +11 -2
  87. package/dist.commonjs/bytes/index.d.ts +9 -3
  88. package/dist.commonjs/bytes/index.js +28 -26
  89. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  90. package/dist.commonjs/ckb/advanced.js +47 -22
  91. package/dist.commonjs/ckb/index.d.ts +1 -1
  92. package/dist.commonjs/ckb/index.js +30 -14
  93. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
  94. package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
  95. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  96. package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
  97. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  98. package/dist.commonjs/ckb/script.advanced.js +12 -9
  99. package/dist.commonjs/ckb/script.d.ts +76 -76
  100. package/dist.commonjs/ckb/script.js +166 -126
  101. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  102. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  103. package/dist.commonjs/ckb/transaction.d.ts +570 -532
  104. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  105. package/dist.commonjs/ckb/transaction.js +839 -723
  106. package/dist.commonjs/client/advanced.d.ts +1 -1
  107. package/dist.commonjs/client/advanced.js +30 -14
  108. package/dist.commonjs/client/client.d.ts +53 -19
  109. package/dist.commonjs/client/client.d.ts.map +1 -1
  110. package/dist.commonjs/client/client.js +68 -43
  111. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +5 -2
  112. package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -24
  113. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -4
  114. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  115. package/dist.commonjs/client/clientPublicMainnet.js +9 -9
  116. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +5 -2
  117. package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -24
  118. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -4
  119. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  120. package/dist.commonjs/client/clientPublicTestnet.js +9 -9
  121. package/dist.commonjs/client/clientTypes.d.ts +51 -36
  122. package/dist.commonjs/client/clientTypes.js +34 -19
  123. package/dist.commonjs/client/index.d.ts +1 -1
  124. package/dist.commonjs/client/index.js +30 -14
  125. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  126. package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
  127. package/dist.commonjs/client/jsonRpc/index.d.ts +93 -66
  128. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  129. package/dist.commonjs/client/jsonRpc/index.js +135 -98
  130. package/dist.commonjs/client/jsonRpc/transformers.d.ts +78 -38
  131. package/dist.commonjs/client/jsonRpc/transformers.js +175 -150
  132. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  133. package/dist.commonjs/fixedPoint/index.d.ts +9 -3
  134. package/dist.commonjs/fixedPoint/index.js +26 -20
  135. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  136. package/dist.commonjs/fixedPoint/index.test.js +42 -36
  137. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  138. package/dist.commonjs/hasher/index.d.ts +36 -36
  139. package/dist.commonjs/hasher/index.js +52 -45
  140. package/dist.commonjs/hex/index.d.ts +1 -1
  141. package/dist.commonjs/hex/index.js +1 -1
  142. package/dist.commonjs/index.d.ts +1 -1
  143. package/dist.commonjs/index.js +47 -22
  144. package/dist.commonjs/num/index.d.ts +1 -1
  145. package/dist.commonjs/num/index.js +30 -19
  146. package/dist.commonjs/signer/btc/index.d.ts +2 -1
  147. package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
  148. package/dist.commonjs/signer/btc/index.js +31 -14
  149. package/dist.commonjs/signer/btc/signerBtc.d.ts +48 -40
  150. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  151. package/dist.commonjs/signer/btc/signerBtc.js +85 -49
  152. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
  153. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  154. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
  155. package/dist.commonjs/signer/btc/verify.d.ts +7 -0
  156. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
  157. package/dist.commonjs/signer/btc/verify.js +13 -0
  158. package/dist.commonjs/signer/ckb/index.d.ts +2 -1
  159. package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
  160. package/dist.commonjs/signer/ckb/index.js +31 -14
  161. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +46 -50
  162. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  163. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -58
  164. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +7 -0
  165. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
  166. package/dist.commonjs/signer/ckb/verifyJoyId.js +19 -0
  167. package/dist.commonjs/signer/dummy/alwaysError.d.ts +9 -0
  168. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
  169. package/dist.commonjs/signer/dummy/alwaysError.js +14 -0
  170. package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
  171. package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
  172. package/dist.commonjs/signer/dummy/dummy.js +23 -0
  173. package/dist.commonjs/signer/dummy/index.d.ts +4 -0
  174. package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
  175. package/dist.commonjs/signer/dummy/index.js +35 -0
  176. package/dist.commonjs/signer/dummy/openLink.d.ts +9 -0
  177. package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
  178. package/dist.commonjs/signer/dummy/openLink.js +14 -0
  179. package/dist.commonjs/signer/evm/index.d.ts +2 -1
  180. package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
  181. package/dist.commonjs/signer/evm/index.js +31 -14
  182. package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -37
  183. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  184. package/dist.commonjs/signer/evm/signerEvm.js +101 -63
  185. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
  186. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  187. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
  188. package/dist.commonjs/signer/evm/verify.d.ts +7 -0
  189. package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
  190. package/dist.commonjs/signer/evm/verify.js +15 -0
  191. package/dist.commonjs/signer/index.d.ts +2 -1
  192. package/dist.commonjs/signer/index.d.ts.map +1 -1
  193. package/dist.commonjs/signer/index.js +31 -14
  194. package/dist.commonjs/signer/signer/index.d.ts +190 -0
  195. package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
  196. package/dist.commonjs/signer/signer/index.js +234 -0
  197. package/dist.commonjs/utils/index.d.ts +94 -6
  198. package/dist.commonjs/utils/index.d.ts.map +1 -1
  199. package/dist.commonjs/utils/index.js +33 -5
  200. package/package.json +6 -3
  201. package/src/address/index.ts +4 -7
  202. package/src/ckb/transaction.ts +4 -5
  203. package/src/client/client.ts +27 -3
  204. package/src/client/clientPublicMainnet.ts +1 -1
  205. package/src/client/clientPublicTestnet.ts +1 -1
  206. package/src/client/jsonRpc/index.ts +21 -5
  207. package/src/signer/btc/index.ts +1 -0
  208. package/src/signer/btc/signerBtc.ts +22 -7
  209. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
  210. package/src/signer/btc/verify.ts +14 -0
  211. package/src/signer/ckb/index.ts +1 -0
  212. package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -11
  213. package/src/signer/ckb/verifyJoyId.ts +20 -0
  214. package/src/signer/dummy/alwaysError.ts +17 -0
  215. package/src/signer/dummy/dummy.ts +28 -0
  216. package/src/signer/dummy/index.ts +3 -0
  217. package/src/signer/dummy/openLink.ts +17 -0
  218. package/src/signer/evm/index.ts +1 -0
  219. package/src/signer/evm/signerEvm.ts +16 -10
  220. package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
  221. package/src/signer/evm/verify.ts +16 -0
  222. package/src/signer/index.ts +1 -0
  223. package/src/signer/{signer.ts → signer/index.ts} +146 -24
  224. package/src/utils/index.ts +108 -0
  225. package/dist/signer/signer.d.ts +0 -133
  226. package/dist/signer/signer.d.ts.map +0 -1
  227. package/dist/signer/signer.js +0 -112
  228. package/dist.commonjs/signer/signer.d.ts.map +0 -1
  229. package/dist.commonjs/signer/signer.js +0 -117
  230. package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
@@ -1,6 +1,6 @@
1
1
  export * from "./generated";
2
2
  export declare function molOptional<T>(mol: {
3
- hasValue: () => boolean;
4
- value: () => T;
3
+ hasValue: () => boolean;
4
+ value: () => T;
5
5
  }): T | undefined;
6
- //# sourceMappingURL=index.d.ts.map
6
+ //# sourceMappingURL=index.d.ts.map
@@ -1,25 +1,41 @@
1
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
- };
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __exportStar =
26
+ (this && this.__exportStar) ||
27
+ function (m, exports) {
28
+ for (var p in m)
29
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
30
+ __createBinding(exports, m, p);
31
+ };
16
32
  Object.defineProperty(exports, "__esModule", { value: true });
17
33
  exports.molOptional = void 0;
18
34
  __exportStar(require("./generated"), exports);
19
35
  function molOptional(mol) {
20
- if (mol.hasValue()) {
21
- return mol.value();
22
- }
23
- return;
36
+ if (mol.hasValue()) {
37
+ return mol.value();
38
+ }
39
+ return;
24
40
  }
25
41
  exports.molOptional = molOptional;
@@ -2,4 +2,4 @@ import { type HashType } from "./script";
2
2
  export declare const HASH_TYPE_TO_NUM: Record<HashType, number>;
3
3
  export declare const NUM_TO_HASH_TYPE: Record<number, HashType>;
4
4
  export declare const HASH_TYPES: string[];
5
- //# sourceMappingURL=script.advanced.d.ts.map
5
+ //# sourceMappingURL=script.advanced.d.ts.map
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HASH_TYPES = exports.NUM_TO_HASH_TYPE = exports.HASH_TYPE_TO_NUM = void 0;
3
+ exports.HASH_TYPES =
4
+ exports.NUM_TO_HASH_TYPE =
5
+ exports.HASH_TYPE_TO_NUM =
6
+ void 0;
4
7
  exports.HASH_TYPE_TO_NUM = {
5
- type: 0x01,
6
- data: 0x00,
7
- data1: 0x02,
8
- data2: 0x04,
8
+ type: 0x01,
9
+ data: 0x00,
10
+ data1: 0x02,
11
+ data2: 0x04,
9
12
  };
10
13
  exports.NUM_TO_HASH_TYPE = {
11
- 0x01: "type",
12
- 0x00: "data",
13
- 0x02: "data1",
14
- 0x04: "data2",
14
+ 0x01: "type",
15
+ 0x00: "data",
16
+ 0x02: "data1",
17
+ 0x04: "data2",
15
18
  };
16
19
  exports.HASH_TYPES = Object.keys(exports.HASH_TYPE_TO_NUM);
@@ -45,82 +45,82 @@ export declare function hashTypeToBytes(hashType: HashTypeLike): Bytes;
45
45
  */
46
46
  export declare function hashTypeFromBytes(bytes: BytesLike): HashType;
47
47
  export type ScriptLike = {
48
- codeHash: BytesLike;
49
- hashType: HashTypeLike;
50
- args: BytesLike;
48
+ codeHash: BytesLike;
49
+ hashType: HashTypeLike;
50
+ args: BytesLike;
51
51
  };
52
52
  export declare class Script {
53
- codeHash: Hex;
54
- hashType: HashType;
55
- args: Hex;
56
- /**
57
- * Creates an instance of Script.
58
- *
59
- * @param codeHash - The code hash of the script.
60
- * @param hashType - The hash type of the script.
61
- * @param args - The arguments for the script.
62
- */
63
- constructor(codeHash: Hex, hashType: HashType, args: Hex);
64
- /**
65
- * Creates a Script instance from a ScriptLike object.
66
- *
67
- * @param script - A ScriptLike object or an instance of Script.
68
- * @returns A Script instance.
69
- *
70
- * @example
71
- * ```typescript
72
- * const script = Script.from({
73
- * codeHash: "0x1234...",
74
- * hashType: "type",
75
- * args: "0xabcd..."
76
- * });
77
- * ```
78
- */
79
- static from(script: ScriptLike): Script;
80
- /**
81
- * Converts the Script instance to molecule data format.
82
- *
83
- * @returns An object representing the script in molecule data format.
84
- */
85
- _toMolData(): {
86
- codeHash: Uint8Array;
87
- hashType: Uint8Array;
88
- args: Uint8Array;
89
- };
90
- /**
91
- * Converts the Script instance to bytes.
92
- *
93
- * @returns A Uint8Array containing the script bytes.
94
- *
95
- * @example
96
- * ```typescript
97
- * const scriptBytes = script.toBytes();
98
- * ```
99
- */
100
- toBytes(): Bytes;
101
- /**
102
- * Creates a Script instance from a byte-like value or molecule Script.
103
- *
104
- * @param bytes - The byte-like value or molecule Script to convert.
105
- * @returns A Script instance.
106
- *
107
- * @example
108
- * ```typescript
109
- * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
110
- * ```
111
- */
112
- static fromBytes(bytes: BytesLike | mol.Script): Script;
113
- /**
114
- * Compares the current Script instance with another ScriptLike object for equality.
115
- *
116
- * @param val - The ScriptLike object to compare with.
117
- * @returns True if the scripts are equal, otherwise false.
118
- *
119
- * @example
120
- * ```typescript
121
- * const isEqual = script.eq(anotherScript);
122
- * ```
123
- */
124
- eq(val: ScriptLike): boolean;
53
+ codeHash: Hex;
54
+ hashType: HashType;
55
+ args: Hex;
56
+ /**
57
+ * Creates an instance of Script.
58
+ *
59
+ * @param codeHash - The code hash of the script.
60
+ * @param hashType - The hash type of the script.
61
+ * @param args - The arguments for the script.
62
+ */
63
+ constructor(codeHash: Hex, hashType: HashType, args: Hex);
64
+ /**
65
+ * Creates a Script instance from a ScriptLike object.
66
+ *
67
+ * @param script - A ScriptLike object or an instance of Script.
68
+ * @returns A Script instance.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const script = Script.from({
73
+ * codeHash: "0x1234...",
74
+ * hashType: "type",
75
+ * args: "0xabcd..."
76
+ * });
77
+ * ```
78
+ */
79
+ static from(script: ScriptLike): Script;
80
+ /**
81
+ * Converts the Script instance to molecule data format.
82
+ *
83
+ * @returns An object representing the script in molecule data format.
84
+ */
85
+ _toMolData(): {
86
+ codeHash: Uint8Array;
87
+ hashType: Uint8Array;
88
+ args: Uint8Array;
89
+ };
90
+ /**
91
+ * Converts the Script instance to bytes.
92
+ *
93
+ * @returns A Uint8Array containing the script bytes.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const scriptBytes = script.toBytes();
98
+ * ```
99
+ */
100
+ toBytes(): Bytes;
101
+ /**
102
+ * Creates a Script instance from a byte-like value or molecule Script.
103
+ *
104
+ * @param bytes - The byte-like value or molecule Script to convert.
105
+ * @returns A Script instance.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
110
+ * ```
111
+ */
112
+ static fromBytes(bytes: BytesLike | mol.Script): Script;
113
+ /**
114
+ * Compares the current Script instance with another ScriptLike object for equality.
115
+ *
116
+ * @param val - The ScriptLike object to compare with.
117
+ * @returns True if the scripts are equal, otherwise false.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const isEqual = script.eq(anotherScript);
122
+ * ```
123
+ */
124
+ eq(val: ScriptLike): boolean;
125
125
  }
126
- //# sourceMappingURL=script.d.ts.map
126
+ //# sourceMappingURL=script.d.ts.map
@@ -1,29 +1,54 @@
1
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 __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 __importStar = (this && this.__importStar) || function (mod) {
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __setModuleDefault =
26
+ (this && this.__setModuleDefault) ||
27
+ (Object.create
28
+ ? function (o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }
31
+ : function (o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar =
35
+ (this && this.__importStar) ||
36
+ function (mod) {
19
37
  if (mod && mod.__esModule) return mod;
20
38
  var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
+ if (mod != null)
40
+ for (var k in mod)
41
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
42
+ __createBinding(result, mod, k);
22
43
  __setModuleDefault(result, mod);
23
44
  return result;
24
- };
45
+ };
25
46
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Script = exports.hashTypeFromBytes = exports.hashTypeToBytes = exports.hashTypeFrom = void 0;
47
+ exports.Script =
48
+ exports.hashTypeFromBytes =
49
+ exports.hashTypeToBytes =
50
+ exports.hashTypeFrom =
51
+ void 0;
27
52
  const bytes_1 = require("../bytes");
28
53
  const hex_1 = require("../hex");
29
54
  const mol = __importStar(require("./molecule.advanced"));
@@ -43,22 +68,22 @@ const script_advanced_1 = require("./script.advanced");
43
68
  * ```
44
69
  */
45
70
  function hashTypeFrom(val) {
46
- const hashType = (() => {
47
- if (typeof val === "number") {
48
- return script_advanced_1.NUM_TO_HASH_TYPE[val];
49
- }
50
- if (typeof val === "bigint") {
51
- return script_advanced_1.NUM_TO_HASH_TYPE[Number(val)];
52
- }
53
- if (!script_advanced_1.HASH_TYPES.includes(val)) {
54
- return;
55
- }
56
- return val;
57
- })();
58
- if (hashType === undefined) {
59
- throw new Error(`Invalid hash type ${val}`);
71
+ const hashType = (() => {
72
+ if (typeof val === "number") {
73
+ return script_advanced_1.NUM_TO_HASH_TYPE[val];
74
+ }
75
+ if (typeof val === "bigint") {
76
+ return script_advanced_1.NUM_TO_HASH_TYPE[Number(val)];
77
+ }
78
+ if (!script_advanced_1.HASH_TYPES.includes(val)) {
79
+ return;
60
80
  }
61
- return hashType;
81
+ return val;
82
+ })();
83
+ if (hashType === undefined) {
84
+ throw new Error(`Invalid hash type ${val}`);
85
+ }
86
+ return hashType;
62
87
  }
63
88
  exports.hashTypeFrom = hashTypeFrom;
64
89
  /**
@@ -73,7 +98,9 @@ exports.hashTypeFrom = hashTypeFrom;
73
98
  * ```
74
99
  */
75
100
  function hashTypeToBytes(hashType) {
76
- return (0, bytes_1.bytesFrom)([script_advanced_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
101
+ return (0, bytes_1.bytesFrom)([
102
+ script_advanced_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)],
103
+ ]);
77
104
  }
78
105
  exports.hashTypeToBytes = hashTypeToBytes;
79
106
  /**
@@ -90,99 +117,112 @@ exports.hashTypeToBytes = hashTypeToBytes;
90
117
  * ```
91
118
  */
92
119
  function hashTypeFromBytes(bytes) {
93
- return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
120
+ return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
94
121
  }
95
122
  exports.hashTypeFromBytes = hashTypeFromBytes;
96
123
  class Script {
97
- /**
98
- * Creates an instance of Script.
99
- *
100
- * @param codeHash - The code hash of the script.
101
- * @param hashType - The hash type of the script.
102
- * @param args - The arguments for the script.
103
- */
104
- constructor(codeHash, hashType, args) {
105
- this.codeHash = codeHash;
106
- this.hashType = hashType;
107
- this.args = args;
108
- }
109
- /**
110
- * Creates a Script instance from a ScriptLike object.
111
- *
112
- * @param script - A ScriptLike object or an instance of Script.
113
- * @returns A Script instance.
114
- *
115
- * @example
116
- * ```typescript
117
- * const script = Script.from({
118
- * codeHash: "0x1234...",
119
- * hashType: "type",
120
- * args: "0xabcd..."
121
- * });
122
- * ```
123
- */
124
- static from(script) {
125
- if (script instanceof Script) {
126
- return script;
127
- }
128
- return new Script((0, hex_1.hexFrom)(script.codeHash), hashTypeFrom(script.hashType), (0, hex_1.hexFrom)(script.args));
129
- }
130
- /**
131
- * Converts the Script instance to molecule data format.
132
- *
133
- * @returns An object representing the script in molecule data format.
134
- */
135
- _toMolData() {
136
- return {
137
- codeHash: (0, bytes_1.bytesFrom)(this.codeHash),
138
- hashType: hashTypeToBytes(this.hashType),
139
- args: (0, bytes_1.bytesFrom)(this.args),
140
- };
141
- }
142
- /**
143
- * Converts the Script instance to bytes.
144
- *
145
- * @returns A Uint8Array containing the script bytes.
146
- *
147
- * @example
148
- * ```typescript
149
- * const scriptBytes = script.toBytes();
150
- * ```
151
- */
152
- toBytes() {
153
- return (0, bytes_1.bytesFrom)(mol.SerializeScript(this._toMolData()));
154
- }
155
- /**
156
- * Creates a Script instance from a byte-like value or molecule Script.
157
- *
158
- * @param bytes - The byte-like value or molecule Script to convert.
159
- * @returns A Script instance.
160
- *
161
- * @example
162
- * ```typescript
163
- * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
164
- * ```
165
- */
166
- static fromBytes(bytes) {
167
- const view = bytes instanceof mol.Script ? bytes : new mol.Script((0, bytes_1.bytesFrom)(bytes));
168
- return new Script((0, hex_1.hexFrom)(view.getCodeHash().raw()), hashTypeFromBytes([view.getHashType()]), (0, hex_1.hexFrom)(view.getArgs().raw()));
169
- }
170
- /**
171
- * Compares the current Script instance with another ScriptLike object for equality.
172
- *
173
- * @param val - The ScriptLike object to compare with.
174
- * @returns True if the scripts are equal, otherwise false.
175
- *
176
- * @example
177
- * ```typescript
178
- * const isEqual = script.eq(anotherScript);
179
- * ```
180
- */
181
- eq(val) {
182
- const script = Script.from(val);
183
- return (this.codeHash === script.codeHash &&
184
- this.args === script.args &&
185
- this.hashType === script.hashType);
124
+ /**
125
+ * Creates an instance of Script.
126
+ *
127
+ * @param codeHash - The code hash of the script.
128
+ * @param hashType - The hash type of the script.
129
+ * @param args - The arguments for the script.
130
+ */
131
+ constructor(codeHash, hashType, args) {
132
+ this.codeHash = codeHash;
133
+ this.hashType = hashType;
134
+ this.args = args;
135
+ }
136
+ /**
137
+ * Creates a Script instance from a ScriptLike object.
138
+ *
139
+ * @param script - A ScriptLike object or an instance of Script.
140
+ * @returns A Script instance.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const script = Script.from({
145
+ * codeHash: "0x1234...",
146
+ * hashType: "type",
147
+ * args: "0xabcd..."
148
+ * });
149
+ * ```
150
+ */
151
+ static from(script) {
152
+ if (script instanceof Script) {
153
+ return script;
186
154
  }
155
+ return new Script(
156
+ (0, hex_1.hexFrom)(script.codeHash),
157
+ hashTypeFrom(script.hashType),
158
+ (0, hex_1.hexFrom)(script.args),
159
+ );
160
+ }
161
+ /**
162
+ * Converts the Script instance to molecule data format.
163
+ *
164
+ * @returns An object representing the script in molecule data format.
165
+ */
166
+ _toMolData() {
167
+ return {
168
+ codeHash: (0, bytes_1.bytesFrom)(this.codeHash),
169
+ hashType: hashTypeToBytes(this.hashType),
170
+ args: (0, bytes_1.bytesFrom)(this.args),
171
+ };
172
+ }
173
+ /**
174
+ * Converts the Script instance to bytes.
175
+ *
176
+ * @returns A Uint8Array containing the script bytes.
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * const scriptBytes = script.toBytes();
181
+ * ```
182
+ */
183
+ toBytes() {
184
+ return (0, bytes_1.bytesFrom)(mol.SerializeScript(this._toMolData()));
185
+ }
186
+ /**
187
+ * Creates a Script instance from a byte-like value or molecule Script.
188
+ *
189
+ * @param bytes - The byte-like value or molecule Script to convert.
190
+ * @returns A Script instance.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
195
+ * ```
196
+ */
197
+ static fromBytes(bytes) {
198
+ const view =
199
+ bytes instanceof mol.Script
200
+ ? bytes
201
+ : new mol.Script((0, bytes_1.bytesFrom)(bytes));
202
+ return new Script(
203
+ (0, hex_1.hexFrom)(view.getCodeHash().raw()),
204
+ hashTypeFromBytes([view.getHashType()]),
205
+ (0, hex_1.hexFrom)(view.getArgs().raw()),
206
+ );
207
+ }
208
+ /**
209
+ * Compares the current Script instance with another ScriptLike object for equality.
210
+ *
211
+ * @param val - The ScriptLike object to compare with.
212
+ * @returns True if the scripts are equal, otherwise false.
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const isEqual = script.eq(anotherScript);
217
+ * ```
218
+ */
219
+ eq(val) {
220
+ const script = Script.from(val);
221
+ return (
222
+ this.codeHash === script.codeHash &&
223
+ this.args === script.args &&
224
+ this.hashType === script.hashType
225
+ );
226
+ }
187
227
  }
188
228
  exports.Script = Script;
@@ -2,4 +2,4 @@ import { type DepType } from "./transaction";
2
2
  export declare const DEP_TYPE_TO_NUM: Record<DepType, number>;
3
3
  export declare const NUM_TO_DEP_TYPE: Record<number, DepType>;
4
4
  export declare const DEP_TYPES: string[];
5
- //# sourceMappingURL=transaction.advanced.d.ts.map
5
+ //# sourceMappingURL=transaction.advanced.d.ts.map
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEP_TYPES = exports.NUM_TO_DEP_TYPE = exports.DEP_TYPE_TO_NUM = void 0;
4
4
  exports.DEP_TYPE_TO_NUM = {
5
- code: 0x00,
6
- depGroup: 0x01,
5
+ code: 0x00,
6
+ depGroup: 0x01,
7
7
  };
8
8
  exports.NUM_TO_DEP_TYPE = {
9
- 0x00: "code",
10
- 0x01: "depGroup",
9
+ 0x00: "code",
10
+ 0x01: "depGroup",
11
11
  };
12
12
  exports.DEP_TYPES = Object.keys(exports.DEP_TYPE_TO_NUM);