@ckb-ccc/core 0.0.10-alpha.4 → 0.0.10-alpha.6

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 (135) hide show
  1. package/dist/address/address.advanced.js +4 -2
  2. package/dist/ckb/transaction.d.ts.map +1 -1
  3. package/dist/ckb/transaction.js +1 -2
  4. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +1 -0
  5. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  6. package/dist/signer/ckb/signerCkbPrivateKey.js +7 -7
  7. package/dist/signer/signer/index.d.ts +0 -9
  8. package/dist/signer/signer/index.d.ts.map +1 -1
  9. package/dist/signer/signer/index.js +6 -13
  10. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  11. package/dist.commonjs/address/address.advanced.js +91 -115
  12. package/dist.commonjs/address/advanced.d.ts +1 -1
  13. package/dist.commonjs/address/advanced.js +14 -30
  14. package/dist.commonjs/address/index.d.ts +44 -51
  15. package/dist.commonjs/address/index.js +65 -84
  16. package/dist.commonjs/advanced.d.ts +1 -1
  17. package/dist.commonjs/advanced.js +22 -47
  18. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  19. package/dist.commonjs/advancedBarrel.js +14 -30
  20. package/dist.commonjs/barrel.d.ts +1 -1
  21. package/dist.commonjs/barrel.js +14 -30
  22. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  23. package/dist.commonjs/bytes/index.d.ts +3 -9
  24. package/dist.commonjs/bytes/index.js +26 -28
  25. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  26. package/dist.commonjs/ckb/advanced.js +22 -47
  27. package/dist.commonjs/ckb/index.d.ts +1 -1
  28. package/dist.commonjs/ckb/index.js +14 -30
  29. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  30. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  31. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  32. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  33. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  34. package/dist.commonjs/ckb/script.advanced.js +9 -12
  35. package/dist.commonjs/ckb/script.d.ts +117 -121
  36. package/dist.commonjs/ckb/script.js +176 -220
  37. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  38. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  39. package/dist.commonjs/ckb/transaction.d.ts +722 -806
  40. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  41. package/dist.commonjs/ckb/transaction.js +1190 -1424
  42. package/dist.commonjs/client/advanced.d.ts +1 -1
  43. package/dist.commonjs/client/advanced.js +14 -30
  44. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  45. package/dist.commonjs/client/client.advanced.js +61 -89
  46. package/dist.commonjs/client/client.d.ts +54 -114
  47. package/dist.commonjs/client/client.js +182 -215
  48. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  49. package/dist.commonjs/client/clientPublicMainnet.advanced.js +189 -215
  50. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  51. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  52. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  53. package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -227
  54. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  55. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  56. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  57. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  58. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  59. package/dist.commonjs/client/clientTypes.js +22 -56
  60. package/dist.commonjs/client/index.d.ts +1 -1
  61. package/dist.commonjs/client/index.js +14 -30
  62. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  63. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  64. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  65. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  66. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  67. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  68. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  69. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  70. package/dist.commonjs/fixedPoint/index.js +20 -26
  71. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  72. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  73. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  74. package/dist.commonjs/hasher/index.d.ts +37 -40
  75. package/dist.commonjs/hasher/index.js +48 -58
  76. package/dist.commonjs/hex/index.d.ts +1 -1
  77. package/dist.commonjs/hex/index.js +1 -1
  78. package/dist.commonjs/index.d.ts +1 -1
  79. package/dist.commonjs/index.js +22 -47
  80. package/dist.commonjs/num/index.d.ts +1 -1
  81. package/dist.commonjs/num/index.js +27 -39
  82. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  83. package/dist.commonjs/signer/btc/index.js +14 -30
  84. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  85. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  86. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  87. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  88. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  89. package/dist.commonjs/signer/btc/verify.js +3 -10
  90. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  91. package/dist.commonjs/signer/ckb/index.js +14 -30
  92. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +6 -5
  93. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  94. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +28 -42
  95. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +11 -11
  96. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +35 -45
  97. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  98. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  99. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +3 -9
  100. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +5 -13
  101. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  102. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  103. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  104. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  105. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  106. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  107. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  108. package/dist.commonjs/signer/dummy/index.js +14 -30
  109. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  110. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  111. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  112. package/dist.commonjs/signer/evm/index.js +14 -30
  113. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  114. package/dist.commonjs/signer/evm/signerEvm.js +70 -105
  115. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  116. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  117. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  118. package/dist.commonjs/signer/evm/verify.js +2 -7
  119. package/dist.commonjs/signer/index.d.ts +1 -1
  120. package/dist.commonjs/signer/index.js +14 -30
  121. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  122. package/dist.commonjs/signer/nostr/index.js +14 -30
  123. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  124. package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
  125. package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
  126. package/dist.commonjs/signer/nostr/verify.js +39 -50
  127. package/dist.commonjs/signer/signer/index.d.ts +153 -171
  128. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  129. package/dist.commonjs/signer/signer/index.js +191 -234
  130. package/dist.commonjs/utils/index.d.ts +9 -42
  131. package/dist.commonjs/utils/index.js +12 -18
  132. package/package.json +3 -3
  133. package/src/address/address.advanced.ts +4 -4
  134. package/src/signer/ckb/signerCkbPrivateKey.ts +8 -8
  135. package/src/signer/signer/index.ts +6 -14
@@ -1,54 +1,29 @@
1
1
  "use strict";
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) {
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) {
37
19
  if (mod && mod.__esModule) return mod;
38
20
  var result = {};
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);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
22
  __setModuleDefault(result, mod);
44
23
  return result;
45
- };
24
+ };
46
25
  Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.Script =
48
- exports.hashTypeFromBytes =
49
- exports.hashTypeToBytes =
50
- exports.hashTypeFrom =
51
- void 0;
26
+ exports.Script = exports.hashTypeFromBytes = exports.hashTypeToBytes = exports.hashTypeFrom = void 0;
52
27
  const bytes_1 = require("../bytes");
53
28
  const hasher_1 = require("../hasher");
54
29
  const hex_1 = require("../hex");
@@ -69,22 +44,22 @@ const script_advanced_1 = require("./script.advanced");
69
44
  * ```
70
45
  */
71
46
  function hashTypeFrom(val) {
72
- const hashType = (() => {
73
- if (typeof val === "number") {
74
- return script_advanced_1.NUM_TO_HASH_TYPE[val];
75
- }
76
- if (typeof val === "bigint") {
77
- return script_advanced_1.NUM_TO_HASH_TYPE[Number(val)];
78
- }
79
- if (!script_advanced_1.HASH_TYPES.includes(val)) {
80
- return;
47
+ const hashType = (() => {
48
+ if (typeof val === "number") {
49
+ return script_advanced_1.NUM_TO_HASH_TYPE[val];
50
+ }
51
+ if (typeof val === "bigint") {
52
+ return script_advanced_1.NUM_TO_HASH_TYPE[Number(val)];
53
+ }
54
+ if (!script_advanced_1.HASH_TYPES.includes(val)) {
55
+ return;
56
+ }
57
+ return val;
58
+ })();
59
+ if (hashType === undefined) {
60
+ throw new Error(`Invalid hash type ${val}`);
81
61
  }
82
- return val;
83
- })();
84
- if (hashType === undefined) {
85
- throw new Error(`Invalid hash type ${val}`);
86
- }
87
- return hashType;
62
+ return hashType;
88
63
  }
89
64
  exports.hashTypeFrom = hashTypeFrom;
90
65
  /**
@@ -99,9 +74,7 @@ exports.hashTypeFrom = hashTypeFrom;
99
74
  * ```
100
75
  */
101
76
  function hashTypeToBytes(hashType) {
102
- return (0, bytes_1.bytesFrom)([
103
- script_advanced_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)],
104
- ]);
77
+ return (0, bytes_1.bytesFrom)([script_advanced_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
105
78
  }
106
79
  exports.hashTypeToBytes = hashTypeToBytes;
107
80
  /**
@@ -118,166 +91,149 @@ exports.hashTypeToBytes = hashTypeToBytes;
118
91
  * ```
119
92
  */
120
93
  function hashTypeFromBytes(bytes) {
121
- return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
94
+ return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
122
95
  }
123
96
  exports.hashTypeFromBytes = hashTypeFromBytes;
124
97
  class Script {
125
- /**
126
- * Creates an instance of Script.
127
- *
128
- * @param codeHash - The code hash of the script.
129
- * @param hashType - The hash type of the script.
130
- * @param args - The arguments for the script.
131
- */
132
- constructor(codeHash, hashType, args) {
133
- this.codeHash = codeHash;
134
- this.hashType = hashType;
135
- this.args = args;
136
- }
137
- get occupiedSize() {
138
- return 33 + (0, bytes_1.bytesFrom)(this.args).length;
139
- }
140
- /**
141
- * Clone a script.
142
- *
143
- * @returns A cloned Script instance.
144
- *
145
- * @example
146
- * ```typescript
147
- * const script1 = script0.clone();
148
- * ```
149
- */
150
- clone() {
151
- return new Script(this.codeHash, this.hashType, this.args);
152
- }
153
- /**
154
- * Creates a Script instance from a ScriptLike object.
155
- *
156
- * @param script - A ScriptLike object or an instance of Script.
157
- * @returns A Script instance.
158
- *
159
- * @example
160
- * ```typescript
161
- * const script = Script.from({
162
- * codeHash: "0x1234...",
163
- * hashType: "type",
164
- * args: "0xabcd..."
165
- * });
166
- * ```
167
- */
168
- static from(script) {
169
- if (script instanceof Script) {
170
- return script;
98
+ /**
99
+ * Creates an instance of Script.
100
+ *
101
+ * @param codeHash - The code hash of the script.
102
+ * @param hashType - The hash type of the script.
103
+ * @param args - The arguments for the script.
104
+ */
105
+ constructor(codeHash, hashType, args) {
106
+ this.codeHash = codeHash;
107
+ this.hashType = hashType;
108
+ this.args = args;
109
+ }
110
+ get occupiedSize() {
111
+ return 33 + (0, bytes_1.bytesFrom)(this.args).length;
112
+ }
113
+ /**
114
+ * Clone a script.
115
+ *
116
+ * @returns A cloned Script instance.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const script1 = script0.clone();
121
+ * ```
122
+ */
123
+ clone() {
124
+ return new Script(this.codeHash, this.hashType, this.args);
125
+ }
126
+ /**
127
+ * Creates a Script instance from a ScriptLike object.
128
+ *
129
+ * @param script - A ScriptLike object or an instance of Script.
130
+ * @returns A Script instance.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const script = Script.from({
135
+ * codeHash: "0x1234...",
136
+ * hashType: "type",
137
+ * args: "0xabcd..."
138
+ * });
139
+ * ```
140
+ */
141
+ static from(script) {
142
+ if (script instanceof Script) {
143
+ return script;
144
+ }
145
+ return new Script((0, hex_1.hexFrom)(script.codeHash), hashTypeFrom(script.hashType), (0, hex_1.hexFrom)(script.args));
146
+ }
147
+ /**
148
+ * Creates a Script instance from client and known script.
149
+ *
150
+ * @param knownScript - A KnownScript enum.
151
+ * @param args - Args for the script.
152
+ * @param client - A ScriptLike object or an instance of Script.
153
+ * @returns A promise that resolves to the script instance.
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const script = await Script.fromKnownScript(
158
+ * client,
159
+ * KnownScript.XUdt,
160
+ * args: "0xabcd..."
161
+ * );
162
+ * ```
163
+ */
164
+ static async fromKnownScript(client, knownScript, args) {
165
+ const script = await client.getKnownScript(knownScript);
166
+ return new Script(script.codeHash, script.hashType, (0, hex_1.hexFrom)(args));
167
+ }
168
+ /**
169
+ * Converts the Script instance to molecule data format.
170
+ *
171
+ * @returns An object representing the script in molecule data format.
172
+ */
173
+ _toMolData() {
174
+ return {
175
+ codeHash: (0, bytes_1.bytesFrom)(this.codeHash),
176
+ hashType: hashTypeToBytes(this.hashType),
177
+ args: (0, bytes_1.bytesFrom)(this.args),
178
+ };
179
+ }
180
+ /**
181
+ * Converts the Script instance to bytes.
182
+ *
183
+ * @returns A Uint8Array containing the script bytes.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const scriptBytes = script.toBytes();
188
+ * ```
189
+ */
190
+ toBytes() {
191
+ return (0, bytes_1.bytesFrom)(mol.SerializeScript(this._toMolData()));
192
+ }
193
+ /**
194
+ * Get hash of a script
195
+ *
196
+ * @returns Hash of this script
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * const hash = script.hash();
201
+ * ```
202
+ */
203
+ hash() {
204
+ return (0, hasher_1.hashCkb)(this.toBytes());
205
+ }
206
+ /**
207
+ * Creates a Script instance from a byte-like value or molecule Script.
208
+ *
209
+ * @param bytes - The byte-like value or molecule Script to convert.
210
+ * @returns A Script instance.
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
215
+ * ```
216
+ */
217
+ static fromBytes(bytes) {
218
+ const view = bytes instanceof mol.Script ? bytes : new mol.Script((0, bytes_1.bytesFrom)(bytes));
219
+ return new Script((0, hex_1.hexFrom)(view.getCodeHash().raw()), hashTypeFromBytes([view.getHashType()]), (0, hex_1.hexFrom)(view.getArgs().raw()));
220
+ }
221
+ /**
222
+ * Compares the current Script instance with another ScriptLike object for equality.
223
+ *
224
+ * @param val - The ScriptLike object to compare with.
225
+ * @returns True if the scripts are equal, otherwise false.
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * const isEqual = script.eq(anotherScript);
230
+ * ```
231
+ */
232
+ eq(val) {
233
+ const script = Script.from(val);
234
+ return (this.codeHash === script.codeHash &&
235
+ this.args === script.args &&
236
+ this.hashType === script.hashType);
171
237
  }
172
- return new Script(
173
- (0, hex_1.hexFrom)(script.codeHash),
174
- hashTypeFrom(script.hashType),
175
- (0, hex_1.hexFrom)(script.args),
176
- );
177
- }
178
- /**
179
- * Creates a Script instance from client and known script.
180
- *
181
- * @param knownScript - A KnownScript enum.
182
- * @param args - Args for the script.
183
- * @param client - A ScriptLike object or an instance of Script.
184
- * @returns A promise that resolves to the script instance.
185
- *
186
- * @example
187
- * ```typescript
188
- * const script = await Script.fromKnownScript(
189
- * client,
190
- * KnownScript.XUdt,
191
- * args: "0xabcd..."
192
- * );
193
- * ```
194
- */
195
- static async fromKnownScript(client, knownScript, args) {
196
- const script = await client.getKnownScript(knownScript);
197
- return new Script(
198
- script.codeHash,
199
- script.hashType,
200
- (0, hex_1.hexFrom)(args),
201
- );
202
- }
203
- /**
204
- * Converts the Script instance to molecule data format.
205
- *
206
- * @returns An object representing the script in molecule data format.
207
- */
208
- _toMolData() {
209
- return {
210
- codeHash: (0, bytes_1.bytesFrom)(this.codeHash),
211
- hashType: hashTypeToBytes(this.hashType),
212
- args: (0, bytes_1.bytesFrom)(this.args),
213
- };
214
- }
215
- /**
216
- * Converts the Script instance to bytes.
217
- *
218
- * @returns A Uint8Array containing the script bytes.
219
- *
220
- * @example
221
- * ```typescript
222
- * const scriptBytes = script.toBytes();
223
- * ```
224
- */
225
- toBytes() {
226
- return (0, bytes_1.bytesFrom)(mol.SerializeScript(this._toMolData()));
227
- }
228
- /**
229
- * Get hash of a script
230
- *
231
- * @returns Hash of this script
232
- *
233
- * @example
234
- * ```typescript
235
- * const hash = script.hash();
236
- * ```
237
- */
238
- hash() {
239
- return (0, hasher_1.hashCkb)(this.toBytes());
240
- }
241
- /**
242
- * Creates a Script instance from a byte-like value or molecule Script.
243
- *
244
- * @param bytes - The byte-like value or molecule Script to convert.
245
- * @returns A Script instance.
246
- *
247
- * @example
248
- * ```typescript
249
- * const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
250
- * ```
251
- */
252
- static fromBytes(bytes) {
253
- const view =
254
- bytes instanceof mol.Script
255
- ? bytes
256
- : new mol.Script((0, bytes_1.bytesFrom)(bytes));
257
- return new Script(
258
- (0, hex_1.hexFrom)(view.getCodeHash().raw()),
259
- hashTypeFromBytes([view.getHashType()]),
260
- (0, hex_1.hexFrom)(view.getArgs().raw()),
261
- );
262
- }
263
- /**
264
- * Compares the current Script instance with another ScriptLike object for equality.
265
- *
266
- * @param val - The ScriptLike object to compare with.
267
- * @returns True if the scripts are equal, otherwise false.
268
- *
269
- * @example
270
- * ```typescript
271
- * const isEqual = script.eq(anotherScript);
272
- * ```
273
- */
274
- eq(val) {
275
- const script = Script.from(val);
276
- return (
277
- this.codeHash === script.codeHash &&
278
- this.args === script.args &&
279
- this.hashType === script.hashType
280
- );
281
- }
282
238
  }
283
239
  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);