@ckb-ccc/core 0.1.0-alpha.6 → 0.1.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.
Files changed (172) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/barrel.d.ts +1 -0
  3. package/dist/barrel.d.ts.map +1 -1
  4. package/dist/barrel.js +1 -0
  5. package/dist/ckb/transactionLumos.d.ts +2 -1
  6. package/dist/ckb/transactionLumos.d.ts.map +1 -1
  7. package/dist/client/client.js +1 -1
  8. package/dist/molecule/codec.d.ts +118 -0
  9. package/dist/molecule/codec.d.ts.map +1 -0
  10. package/dist/molecule/codec.js +446 -0
  11. package/dist/molecule/index.d.ts +3 -0
  12. package/dist/molecule/index.d.ts.map +1 -0
  13. package/dist/molecule/index.js +2 -0
  14. package/dist/molecule/predefined.d.ts +52 -0
  15. package/dist/molecule/predefined.d.ts.map +1 -0
  16. package/dist/molecule/predefined.js +95 -0
  17. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  18. package/dist/signer/btc/signerBtc.js +2 -3
  19. package/dist/signer/btc/verify.d.ts +14 -1
  20. package/dist/signer/btc/verify.d.ts.map +1 -1
  21. package/dist/signer/btc/verify.js +22 -1
  22. package/dist/signer/doge/index.d.ts +5 -0
  23. package/dist/signer/doge/index.d.ts.map +1 -0
  24. package/dist/signer/doge/index.js +4 -0
  25. package/dist/signer/doge/signerDoge.d.ts +52 -0
  26. package/dist/signer/doge/signerDoge.d.ts.map +1 -0
  27. package/dist/signer/doge/signerDoge.js +82 -0
  28. package/dist/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
  29. package/dist/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
  30. package/dist/signer/doge/signerDogeAddressReadonly.js +45 -0
  31. package/dist/signer/doge/signerDogePrivateKey.d.ts +52 -0
  32. package/dist/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
  33. package/dist/signer/doge/signerDogePrivateKey.js +68 -0
  34. package/dist/signer/doge/verify.d.ts +6 -0
  35. package/dist/signer/doge/verify.d.ts.map +1 -0
  36. package/dist/signer/doge/verify.js +17 -0
  37. package/dist/signer/index.d.ts +1 -0
  38. package/dist/signer/index.d.ts.map +1 -1
  39. package/dist/signer/index.js +1 -0
  40. package/dist/signer/nostr/index.d.ts +1 -0
  41. package/dist/signer/nostr/index.d.ts.map +1 -1
  42. package/dist/signer/nostr/index.js +1 -0
  43. package/dist/signer/signer/index.d.ts +4 -2
  44. package/dist/signer/signer/index.d.ts.map +1 -1
  45. package/dist/signer/signer/index.js +5 -0
  46. package/dist.commonjs/address/address.advanced.js +23 -28
  47. package/dist.commonjs/address/advanced.js +1 -17
  48. package/dist.commonjs/address/index.js +11 -15
  49. package/dist.commonjs/advanced.js +2 -31
  50. package/dist.commonjs/advancedBarrel.js +5 -21
  51. package/dist.commonjs/barrel.d.ts +1 -0
  52. package/dist.commonjs/barrel.d.ts.map +1 -1
  53. package/dist.commonjs/barrel.js +12 -27
  54. package/dist.commonjs/bytes/advanced.js +1 -2
  55. package/dist.commonjs/bytes/index.js +7 -12
  56. package/dist.commonjs/ckb/advanced.js +3 -32
  57. package/dist.commonjs/ckb/index.js +3 -19
  58. package/dist.commonjs/ckb/molecule.advanced/generated.js +64 -131
  59. package/dist.commonjs/ckb/molecule.advanced/index.js +2 -19
  60. package/dist.commonjs/ckb/script.advanced.js +3 -6
  61. package/dist.commonjs/ckb/script.js +23 -53
  62. package/dist.commonjs/ckb/transaction.advanced.js +3 -6
  63. package/dist.commonjs/ckb/transaction.js +122 -163
  64. package/dist.commonjs/ckb/transactionLumos.d.ts +2 -1
  65. package/dist.commonjs/ckb/transactionLumos.d.ts.map +1 -1
  66. package/dist.commonjs/ckb/transactionLumos.js +1 -2
  67. package/dist.commonjs/client/advanced.js +6 -22
  68. package/dist.commonjs/client/cache/advanced.js +1 -17
  69. package/dist.commonjs/client/cache/cache.js +3 -7
  70. package/dist.commonjs/client/cache/index.js +2 -18
  71. package/dist.commonjs/client/cache/memory.advanced.js +21 -28
  72. package/dist.commonjs/client/cache/memory.js +19 -23
  73. package/dist.commonjs/client/client.js +22 -26
  74. package/dist.commonjs/client/clientPublicMainnet.advanced.js +22 -25
  75. package/dist.commonjs/client/clientPublicMainnet.js +8 -15
  76. package/dist.commonjs/client/clientPublicTestnet.advanced.js +22 -25
  77. package/dist.commonjs/client/clientPublicTestnet.js +8 -15
  78. package/dist.commonjs/client/clientTypes.advanced.js +3 -6
  79. package/dist.commonjs/client/clientTypes.js +29 -43
  80. package/dist.commonjs/client/index.js +6 -22
  81. package/dist.commonjs/client/jsonRpc/advanced.js +2 -18
  82. package/dist.commonjs/client/jsonRpc/index.js +37 -41
  83. package/dist.commonjs/client/jsonRpc/transformers.js +57 -61
  84. package/dist.commonjs/client/jsonRpc/types.js +1 -2
  85. package/dist.commonjs/client/transports/advanced.js +8 -25
  86. package/dist.commonjs/client/transports/http.js +1 -5
  87. package/dist.commonjs/client/transports/transport.js +1 -2
  88. package/dist.commonjs/client/transports/webSocket.js +3 -10
  89. package/dist.commonjs/fixedPoint/index.js +4 -9
  90. package/dist.commonjs/hasher/advanced.js +1 -4
  91. package/dist.commonjs/hasher/hasher.js +1 -2
  92. package/dist.commonjs/hasher/hasherCkb.js +14 -20
  93. package/dist.commonjs/hasher/hasherKeecak256.js +7 -11
  94. package/dist.commonjs/hasher/index.js +3 -19
  95. package/dist.commonjs/hex/index.js +3 -6
  96. package/dist.commonjs/index.js +2 -31
  97. package/dist.commonjs/keystore/index.js +21 -25
  98. package/dist.commonjs/molecule/codec.d.ts +118 -0
  99. package/dist.commonjs/molecule/codec.d.ts.map +1 -0
  100. package/dist.commonjs/molecule/codec.js +446 -0
  101. package/dist.commonjs/molecule/index.d.ts +3 -0
  102. package/dist.commonjs/molecule/index.d.ts.map +1 -0
  103. package/dist.commonjs/molecule/index.js +2 -0
  104. package/dist.commonjs/molecule/predefined.d.ts +52 -0
  105. package/dist.commonjs/molecule/predefined.d.ts.map +1 -0
  106. package/dist.commonjs/molecule/predefined.js +95 -0
  107. package/dist.commonjs/num/index.js +17 -29
  108. package/dist.commonjs/signer/btc/index.js +3 -19
  109. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  110. package/dist.commonjs/signer/btc/signerBtc.js +20 -25
  111. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +4 -8
  112. package/dist.commonjs/signer/btc/verify.d.ts +14 -1
  113. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
  114. package/dist.commonjs/signer/btc/verify.js +29 -11
  115. package/dist.commonjs/signer/ckb/index.js +5 -21
  116. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +16 -20
  117. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +20 -24
  118. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +8 -12
  119. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +12 -16
  120. package/dist.commonjs/signer/ckb/verifyJoyId.js +5 -8
  121. package/dist.commonjs/signer/doge/index.d.ts +5 -0
  122. package/dist.commonjs/signer/doge/index.d.ts.map +1 -0
  123. package/dist.commonjs/signer/doge/index.js +4 -0
  124. package/dist.commonjs/signer/doge/signerDoge.d.ts +52 -0
  125. package/dist.commonjs/signer/doge/signerDoge.d.ts.map +1 -0
  126. package/dist.commonjs/signer/doge/signerDoge.js +82 -0
  127. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
  128. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
  129. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +45 -0
  130. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts +52 -0
  131. package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
  132. package/dist.commonjs/signer/doge/signerDogePrivateKey.js +68 -0
  133. package/dist.commonjs/signer/doge/verify.d.ts +6 -0
  134. package/dist.commonjs/signer/doge/verify.d.ts.map +1 -0
  135. package/dist.commonjs/signer/doge/verify.js +17 -0
  136. package/dist.commonjs/signer/dummy/alwaysError.js +2 -6
  137. package/dist.commonjs/signer/dummy/dummy.js +3 -7
  138. package/dist.commonjs/signer/dummy/index.js +3 -19
  139. package/dist.commonjs/signer/dummy/openLink.js +2 -6
  140. package/dist.commonjs/signer/evm/index.js +3 -19
  141. package/dist.commonjs/signer/evm/signerEvm.js +31 -35
  142. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +4 -8
  143. package/dist.commonjs/signer/evm/verify.js +4 -7
  144. package/dist.commonjs/signer/index.d.ts +1 -0
  145. package/dist.commonjs/signer/index.d.ts.map +1 -1
  146. package/dist.commonjs/signer/index.js +7 -22
  147. package/dist.commonjs/signer/nostr/index.d.ts +1 -0
  148. package/dist.commonjs/signer/nostr/index.d.ts.map +1 -1
  149. package/dist.commonjs/signer/nostr/index.js +2 -17
  150. package/dist.commonjs/signer/nostr/signerNostr.js +21 -25
  151. package/dist.commonjs/signer/nostr/verify.js +12 -16
  152. package/dist.commonjs/signer/signer/index.d.ts +4 -2
  153. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  154. package/dist.commonjs/signer/signer/index.js +22 -23
  155. package/dist.commonjs/utils/index.js +6 -12
  156. package/package.json +3 -1
  157. package/src/barrel.ts +1 -0
  158. package/src/ckb/transactionLumos.ts +2 -1
  159. package/src/client/client.ts +1 -1
  160. package/src/molecule/codec.ts +610 -0
  161. package/src/molecule/index.ts +2 -0
  162. package/src/molecule/predefined.ts +114 -0
  163. package/src/signer/btc/signerBtc.ts +2 -3
  164. package/src/signer/btc/verify.ts +31 -2
  165. package/src/signer/doge/index.ts +4 -0
  166. package/src/signer/doge/signerDoge.ts +116 -0
  167. package/src/signer/doge/signerDogeAddressReadonly.ts +52 -0
  168. package/src/signer/doge/signerDogePrivateKey.ts +97 -0
  169. package/src/signer/doge/verify.ts +38 -0
  170. package/src/signer/index.ts +1 -0
  171. package/src/signer/nostr/index.ts +1 -0
  172. package/src/signer/signer/index.ts +9 -0
@@ -1,45 +1,12 @@
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) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Transaction = exports.WitnessArgs = exports.CellDep = exports.CellInput = exports.Since = exports.Cell = exports.CellOutput = exports.OutPoint = void 0;
27
- exports.depTypeFrom = depTypeFrom;
28
- exports.depTypeToBytes = depTypeToBytes;
29
- exports.depTypeFromBytes = depTypeFromBytes;
30
- exports.epochFrom = epochFrom;
31
- exports.epochFromHex = epochFromHex;
32
- exports.epochToHex = epochToHex;
33
- exports.udtBalanceFrom = udtBalanceFrom;
34
- const index_js_1 = require("../bytes/index.js");
35
- const index_js_2 = require("../fixedPoint/index.js");
36
- const index_js_3 = require("../hasher/index.js");
37
- const index_js_4 = require("../hex/index.js");
38
- const index_js_5 = require("../num/index.js");
39
- const index_js_6 = require("../utils/index.js");
40
- const mol = __importStar(require("./molecule.advanced/index.js"));
41
- const script_js_1 = require("./script.js");
42
- const transaction_advanced_js_1 = require("./transaction.advanced.js");
1
+ import { bytesFrom } from "../bytes/index.js";
2
+ import { Zero, fixedPointFrom, fixedPointToString, } from "../fixedPoint/index.js";
3
+ import { HasherCkb, hashCkb } from "../hasher/index.js";
4
+ import { hexFrom } from "../hex/index.js";
5
+ import { numFrom, numFromBytes, numToBytes, numToHex, } from "../num/index.js";
6
+ import { apply, reduceAsync } from "../utils/index.js";
7
+ import * as mol from "./molecule.advanced/index.js";
8
+ import { Script } from "./script.js";
9
+ import { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from "./transaction.advanced.js";
43
10
  /**
44
11
  * Converts a DepTypeLike value to a DepType.
45
12
  * @public
@@ -55,13 +22,13 @@ const transaction_advanced_js_1 = require("./transaction.advanced.js");
55
22
  * const depType = depTypeFrom("depGroup"); // Outputs "depGroup"
56
23
  * ```
57
24
  */
58
- function depTypeFrom(val) {
25
+ export function depTypeFrom(val) {
59
26
  const depType = (() => {
60
27
  if (typeof val === "number") {
61
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[val];
28
+ return NUM_TO_DEP_TYPE[val];
62
29
  }
63
30
  if (typeof val === "bigint") {
64
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[Number(val)];
31
+ return NUM_TO_DEP_TYPE[Number(val)];
65
32
  }
66
33
  return val;
67
34
  })();
@@ -82,8 +49,8 @@ function depTypeFrom(val) {
82
49
  * const depTypeBytes = depTypeToBytes("code"); // Outputs Uint8Array [1]
83
50
  * ```
84
51
  */
85
- function depTypeToBytes(depType) {
86
- return (0, index_js_1.bytesFrom)([transaction_advanced_js_1.DEP_TYPE_TO_NUM[depTypeFrom(depType)]]);
52
+ export function depTypeToBytes(depType) {
53
+ return bytesFrom([DEP_TYPE_TO_NUM[depTypeFrom(depType)]]);
87
54
  }
88
55
  /**
89
56
  * Converts a byte-like value to a DepType.
@@ -99,13 +66,13 @@ function depTypeToBytes(depType) {
99
66
  * const depType = depTypeFromBytes(new Uint8Array([1])); // Outputs "code"
100
67
  * ```
101
68
  */
102
- function depTypeFromBytes(bytes) {
103
- return transaction_advanced_js_1.NUM_TO_DEP_TYPE[(0, index_js_1.bytesFrom)(bytes)[0]];
69
+ export function depTypeFromBytes(bytes) {
70
+ return NUM_TO_DEP_TYPE[bytesFrom(bytes)[0]];
104
71
  }
105
72
  /**
106
73
  * @public
107
74
  */
108
- class OutPoint {
75
+ export class OutPoint {
109
76
  /**
110
77
  * Creates an instance of OutPoint.
111
78
  *
@@ -144,7 +111,7 @@ class OutPoint {
144
111
  if (outPoint instanceof OutPoint) {
145
112
  return outPoint;
146
113
  }
147
- return new OutPoint((0, index_js_4.hexFrom)(outPoint.txHash), (0, index_js_5.numFrom)(outPoint.index));
114
+ return new OutPoint(hexFrom(outPoint.txHash), numFrom(outPoint.index));
148
115
  }
149
116
  /**
150
117
  * Converts the OutPoint instance to molecule data format.
@@ -153,8 +120,8 @@ class OutPoint {
153
120
  */
154
121
  _toMolData() {
155
122
  return {
156
- txHash: (0, index_js_1.bytesFrom)(this.txHash),
157
- index: (0, index_js_5.numToBytes)(this.index, 4),
123
+ txHash: bytesFrom(this.txHash),
124
+ index: numToBytes(this.index, 4),
158
125
  };
159
126
  }
160
127
  /**
@@ -168,7 +135,7 @@ class OutPoint {
168
135
  * ```
169
136
  */
170
137
  toBytes() {
171
- return (0, index_js_1.bytesFrom)(mol.SerializeOutPoint(this._toMolData()));
138
+ return bytesFrom(mol.SerializeOutPoint(this._toMolData()));
172
139
  }
173
140
  /**
174
141
  * Creates an OutPoint instance from a byte-like value or molecule OutPoint.
@@ -184,8 +151,8 @@ class OutPoint {
184
151
  static fromBytes(bytes) {
185
152
  const view = bytes instanceof mol.OutPoint
186
153
  ? bytes
187
- : new mol.OutPoint((0, index_js_1.bytesFrom)(bytes));
188
- return new OutPoint((0, index_js_4.hexFrom)(view.getTxHash().raw()), (0, index_js_5.numFromBytes)(view.getIndex().raw()));
154
+ : new mol.OutPoint(bytesFrom(bytes));
155
+ return new OutPoint(hexFrom(view.getTxHash().raw()), numFromBytes(view.getIndex().raw()));
189
156
  }
190
157
  /**
191
158
  * Compares the current OutPoint instance with another OutPointLike object for equality.
@@ -203,11 +170,10 @@ class OutPoint {
203
170
  return this.txHash === outPoint.txHash && this.index === outPoint.index;
204
171
  }
205
172
  }
206
- exports.OutPoint = OutPoint;
207
173
  /**
208
174
  * @public
209
175
  */
210
- class CellOutput {
176
+ export class CellOutput {
211
177
  /**
212
178
  * Creates an instance of CellOutput.
213
179
  *
@@ -255,7 +221,7 @@ class CellOutput {
255
221
  if (cellOutput instanceof CellOutput) {
256
222
  return cellOutput;
257
223
  }
258
- return new CellOutput((0, index_js_5.numFrom)(cellOutput.capacity), script_js_1.Script.from(cellOutput.lock), (0, index_js_6.apply)(script_js_1.Script.from, cellOutput.type));
224
+ return new CellOutput(numFrom(cellOutput.capacity), Script.from(cellOutput.lock), apply(Script.from, cellOutput.type));
259
225
  }
260
226
  /**
261
227
  * Converts the CellOutput instance to molecule data format.
@@ -264,7 +230,7 @@ class CellOutput {
264
230
  */
265
231
  _toMolData() {
266
232
  return {
267
- capacity: (0, index_js_5.numToBytes)(this.capacity, 8),
233
+ capacity: numToBytes(this.capacity, 8),
268
234
  lock: this.lock._toMolData(),
269
235
  type: this.type?._toMolData(),
270
236
  };
@@ -280,7 +246,7 @@ class CellOutput {
280
246
  * ```
281
247
  */
282
248
  toBytes() {
283
- return (0, index_js_1.bytesFrom)(mol.SerializeCellOutput(this._toMolData()));
249
+ return bytesFrom(mol.SerializeCellOutput(this._toMolData()));
284
250
  }
285
251
  /**
286
252
  * Creates a CellOutput instance from a byte-like value or molecule CellOutput.
@@ -296,15 +262,14 @@ class CellOutput {
296
262
  static fromBytes(bytes) {
297
263
  const view = bytes instanceof mol.CellOutput
298
264
  ? bytes
299
- : new mol.CellOutput((0, index_js_1.bytesFrom)(bytes));
300
- return new CellOutput((0, index_js_5.numFromBytes)(view.getCapacity().raw()), script_js_1.Script.fromBytes(view.getLock()), (0, index_js_6.apply)(script_js_1.Script.fromBytes, mol.molOptional(view.getType())));
265
+ : new mol.CellOutput(bytesFrom(bytes));
266
+ return new CellOutput(numFromBytes(view.getCapacity().raw()), Script.fromBytes(view.getLock()), apply(Script.fromBytes, mol.molOptional(view.getType())));
301
267
  }
302
268
  }
303
- exports.CellOutput = CellOutput;
304
269
  /**
305
270
  * @public
306
271
  */
307
- class Cell {
272
+ export class Cell {
308
273
  /**
309
274
  * Creates an instance of Cell.
310
275
  *
@@ -327,7 +292,7 @@ class Cell {
327
292
  if (cell instanceof Cell) {
328
293
  return cell;
329
294
  }
330
- return new Cell(OutPoint.from(cell.outPoint), CellOutput.from(cell.cellOutput), (0, index_js_4.hexFrom)(cell.outputData));
295
+ return new Cell(OutPoint.from(cell.outPoint), CellOutput.from(cell.cellOutput), hexFrom(cell.outputData));
331
296
  }
332
297
  /**
333
298
  * Clone a Cell
@@ -343,37 +308,36 @@ class Cell {
343
308
  return new Cell(this.outPoint.clone(), this.cellOutput.clone(), this.outputData);
344
309
  }
345
310
  }
346
- exports.Cell = Cell;
347
311
  /**
348
312
  * @public
349
313
  */
350
- function epochFrom(epochLike) {
351
- return [(0, index_js_5.numFrom)(epochLike[0]), (0, index_js_5.numFrom)(epochLike[1]), (0, index_js_5.numFrom)(epochLike[2])];
314
+ export function epochFrom(epochLike) {
315
+ return [numFrom(epochLike[0]), numFrom(epochLike[1]), numFrom(epochLike[2])];
352
316
  }
353
317
  /**
354
318
  * @public
355
319
  */
356
- function epochFromHex(hex) {
357
- const num = (0, index_js_5.numFrom)((0, index_js_4.hexFrom)(hex));
320
+ export function epochFromHex(hex) {
321
+ const num = numFrom(hexFrom(hex));
358
322
  return [
359
- num & (0, index_js_5.numFrom)("0xffffff"),
360
- (num >> (0, index_js_5.numFrom)(24)) & (0, index_js_5.numFrom)("0xffff"),
361
- (num >> (0, index_js_5.numFrom)(40)) & (0, index_js_5.numFrom)("0xffff"),
323
+ num & numFrom("0xffffff"),
324
+ (num >> numFrom(24)) & numFrom("0xffff"),
325
+ (num >> numFrom(40)) & numFrom("0xffff"),
362
326
  ];
363
327
  }
364
328
  /**
365
329
  * @public
366
330
  */
367
- function epochToHex(epochLike) {
331
+ export function epochToHex(epochLike) {
368
332
  const epoch = epochFrom(epochLike);
369
- return (0, index_js_5.numToHex)((0, index_js_5.numFrom)(epoch[0]) +
370
- ((0, index_js_5.numFrom)(epoch[1]) << (0, index_js_5.numFrom)(24)) +
371
- ((0, index_js_5.numFrom)(epoch[2]) << (0, index_js_5.numFrom)(40)));
333
+ return numToHex(numFrom(epoch[0]) +
334
+ (numFrom(epoch[1]) << numFrom(24)) +
335
+ (numFrom(epoch[2]) << numFrom(40)));
372
336
  }
373
337
  /**
374
338
  * @public
375
339
  */
376
- class Since {
340
+ export class Since {
377
341
  /**
378
342
  * Creates an instance of Since.
379
343
  *
@@ -415,7 +379,7 @@ class Since {
415
379
  return since;
416
380
  }
417
381
  if (typeof since === "object" && "relative" in since) {
418
- return new Since(since.relative, since.metric, (0, index_js_5.numFrom)(since.value));
382
+ return new Since(since.relative, since.metric, numFrom(since.value));
419
383
  }
420
384
  return Since.fromNum(since);
421
385
  }
@@ -431,11 +395,11 @@ class Since {
431
395
  */
432
396
  toNum() {
433
397
  return (this.value |
434
- (this.relative === "absolute" ? index_js_2.Zero : (0, index_js_5.numFrom)("0x8000000000000000")) |
398
+ (this.relative === "absolute" ? Zero : numFrom("0x8000000000000000")) |
435
399
  {
436
- blockNumber: (0, index_js_5.numFrom)("0x0000000000000000"),
437
- epoch: (0, index_js_5.numFrom)("0x2000000000000000"),
438
- timestamp: (0, index_js_5.numFrom)("0x4000000000000000"),
400
+ blockNumber: numFrom("0x0000000000000000"),
401
+ epoch: numFrom("0x2000000000000000"),
402
+ timestamp: numFrom("0x4000000000000000"),
439
403
  }[this.metric]);
440
404
  }
441
405
  /**
@@ -450,18 +414,17 @@ class Since {
450
414
  * ```
451
415
  */
452
416
  static fromNum(numLike) {
453
- const num = (0, index_js_5.numFrom)(numLike);
454
- const relative = num >> (0, index_js_5.numFrom)(63) === index_js_2.Zero ? "absolute" : "relative";
455
- const metric = ["blockNumber", "epoch", "timestamp"][Number((num >> (0, index_js_5.numFrom)(61)) & (0, index_js_5.numFrom)(3))];
456
- const value = num & (0, index_js_5.numFrom)("0x00ffffffffffffff");
417
+ const num = numFrom(numLike);
418
+ const relative = num >> numFrom(63) === Zero ? "absolute" : "relative";
419
+ const metric = ["blockNumber", "epoch", "timestamp"][Number((num >> numFrom(61)) & numFrom(3))];
420
+ const value = num & numFrom("0x00ffffffffffffff");
457
421
  return new Since(relative, metric, value);
458
422
  }
459
423
  }
460
- exports.Since = Since;
461
424
  /**
462
425
  * @public
463
426
  */
464
- class CellInput {
427
+ export class CellInput {
465
428
  /**
466
429
  * Creates an instance of CellInput.
467
430
  *
@@ -507,7 +470,7 @@ class CellInput {
507
470
  if (cellInput instanceof CellInput) {
508
471
  return cellInput;
509
472
  }
510
- return new CellInput(OutPoint.from(cellInput.previousOutput), Since.from(cellInput.since ?? 0).toNum(), (0, index_js_6.apply)(CellOutput.from, cellInput.cellOutput), (0, index_js_6.apply)(index_js_4.hexFrom, cellInput.outputData));
473
+ return new CellInput(OutPoint.from(cellInput.previousOutput), Since.from(cellInput.since ?? 0).toNum(), apply(CellOutput.from, cellInput.cellOutput), apply(hexFrom, cellInput.outputData));
511
474
  }
512
475
  /**
513
476
  * Complete extra infos in the input. Like the output of the out point.
@@ -538,7 +501,7 @@ class CellInput {
538
501
  _toMolData() {
539
502
  return {
540
503
  previousOutput: this.previousOutput._toMolData(),
541
- since: (0, index_js_5.numToBytes)(this.since, 8),
504
+ since: numToBytes(this.since, 8),
542
505
  };
543
506
  }
544
507
  /**
@@ -552,7 +515,7 @@ class CellInput {
552
515
  * ```
553
516
  */
554
517
  toBytes() {
555
- return (0, index_js_1.bytesFrom)(mol.SerializeCellInput(this._toMolData()));
518
+ return bytesFrom(mol.SerializeCellInput(this._toMolData()));
556
519
  }
557
520
  /**
558
521
  * Creates a CellInput instance from a byte-like value or molecule CellInput.
@@ -568,15 +531,14 @@ class CellInput {
568
531
  static fromBytes(bytes) {
569
532
  const view = bytes instanceof mol.CellInput
570
533
  ? bytes
571
- : new mol.CellInput((0, index_js_1.bytesFrom)(bytes));
572
- return new CellInput(OutPoint.fromBytes(view.getPreviousOutput()), (0, index_js_5.numFromBytes)(view.getSince().raw()));
534
+ : new mol.CellInput(bytesFrom(bytes));
535
+ return new CellInput(OutPoint.fromBytes(view.getPreviousOutput()), numFromBytes(view.getSince().raw()));
573
536
  }
574
537
  }
575
- exports.CellInput = CellInput;
576
538
  /**
577
539
  * @public
578
540
  */
579
- class CellDep {
541
+ export class CellDep {
580
542
  /**
581
543
  * Creates an instance of CellDep.
582
544
  *
@@ -642,7 +604,7 @@ class CellDep {
642
604
  * ```
643
605
  */
644
606
  toBytes() {
645
- return (0, index_js_1.bytesFrom)(mol.SerializeCellDep(this._toMolData()));
607
+ return bytesFrom(mol.SerializeCellDep(this._toMolData()));
646
608
  }
647
609
  /**
648
610
  * Creates a CellDep instance from a byte-like value or molecule CellDep.
@@ -656,7 +618,7 @@ class CellDep {
656
618
  * ```
657
619
  */
658
620
  fromBytes(bytes) {
659
- const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep((0, index_js_1.bytesFrom)(bytes));
621
+ const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep(bytesFrom(bytes));
660
622
  return new CellDep(OutPoint.fromBytes(view.getOutPoint()), depTypeFromBytes([view.getDepType()]));
661
623
  }
662
624
  /**
@@ -675,11 +637,10 @@ class CellDep {
675
637
  return (this.outPoint.eq(cellDep.outPoint) && this.depType === cellDep.depType);
676
638
  }
677
639
  }
678
- exports.CellDep = CellDep;
679
640
  /**
680
641
  * @public
681
642
  */
682
- class WitnessArgs {
643
+ export class WitnessArgs {
683
644
  /**
684
645
  * Creates an instance of WitnessArgs.
685
646
  *
@@ -711,7 +672,7 @@ class WitnessArgs {
711
672
  if (witnessArgs instanceof WitnessArgs) {
712
673
  return witnessArgs;
713
674
  }
714
- return new WitnessArgs((0, index_js_6.apply)(index_js_4.hexFrom, witnessArgs.lock), (0, index_js_6.apply)(index_js_4.hexFrom, witnessArgs.inputType), (0, index_js_6.apply)(index_js_4.hexFrom, witnessArgs.outputType));
675
+ return new WitnessArgs(apply(hexFrom, witnessArgs.lock), apply(hexFrom, witnessArgs.inputType), apply(hexFrom, witnessArgs.outputType));
715
676
  }
716
677
  /**
717
678
  * Converts the WitnessArgs instance to molecule data format.
@@ -720,9 +681,9 @@ class WitnessArgs {
720
681
  */
721
682
  _toMolData() {
722
683
  return {
723
- lock: (0, index_js_6.apply)(index_js_1.bytesFrom, this.lock),
724
- inputType: (0, index_js_6.apply)(index_js_1.bytesFrom, this.inputType),
725
- outputType: (0, index_js_6.apply)(index_js_1.bytesFrom, this.outputType),
684
+ lock: apply(bytesFrom, this.lock),
685
+ inputType: apply(bytesFrom, this.inputType),
686
+ outputType: apply(bytesFrom, this.outputType),
726
687
  };
727
688
  }
728
689
  /**
@@ -736,7 +697,7 @@ class WitnessArgs {
736
697
  * ```
737
698
  */
738
699
  toBytes() {
739
- return (0, index_js_1.bytesFrom)(mol.SerializeWitnessArgs(this._toMolData()));
700
+ return bytesFrom(mol.SerializeWitnessArgs(this._toMolData()));
740
701
  }
741
702
  /**
742
703
  * Creates a WitnessArgs instance from a byte-like value or molecule WitnessArgs.
@@ -752,25 +713,24 @@ class WitnessArgs {
752
713
  static fromBytes(bytes) {
753
714
  const view = bytes instanceof mol.WitnessArgs
754
715
  ? bytes
755
- : new mol.WitnessArgs((0, index_js_1.bytesFrom)(bytes));
756
- return new WitnessArgs((0, index_js_6.apply)(index_js_4.hexFrom, mol.molOptional(view.getLock())?.raw()), (0, index_js_6.apply)(index_js_4.hexFrom, mol.molOptional(view.getInputType())?.raw()), (0, index_js_6.apply)(index_js_4.hexFrom, mol.molOptional(view.getOutputType())?.raw()));
716
+ : new mol.WitnessArgs(bytesFrom(bytes));
717
+ return new WitnessArgs(apply(hexFrom, mol.molOptional(view.getLock())?.raw()), apply(hexFrom, mol.molOptional(view.getInputType())?.raw()), apply(hexFrom, mol.molOptional(view.getOutputType())?.raw()));
757
718
  }
758
719
  }
759
- exports.WitnessArgs = WitnessArgs;
760
720
  /**
761
721
  * @public
762
722
  */
763
- function udtBalanceFrom(dataLike) {
764
- const data = (0, index_js_1.bytesFrom)(dataLike).slice(0, 16);
723
+ export function udtBalanceFrom(dataLike) {
724
+ const data = bytesFrom(dataLike).slice(0, 16);
765
725
  if (data.length !== 16) {
766
726
  throw new Error("Invalid UDT cell data");
767
727
  }
768
- return (0, index_js_5.numFromBytes)(data);
728
+ return numFromBytes(data);
769
729
  }
770
730
  /**
771
731
  * @public
772
732
  */
773
- class Transaction {
733
+ export class Transaction {
774
734
  /**
775
735
  * Creates an instance of Transaction.
776
736
  *
@@ -863,17 +823,17 @@ class Transaction {
863
823
  ...output,
864
824
  capacity: output.capacity ?? 0,
865
825
  });
866
- if (o.capacity === index_js_2.Zero) {
867
- o.capacity = (0, index_js_2.fixedPointFrom)(o.occupiedSize +
868
- ((0, index_js_6.apply)(index_js_1.bytesFrom, tx.outputsData?.[i])?.length ?? 0));
826
+ if (o.capacity === Zero) {
827
+ o.capacity = fixedPointFrom(o.occupiedSize +
828
+ (apply(bytesFrom, tx.outputsData?.[i])?.length ?? 0));
869
829
  }
870
830
  return o;
871
831
  }) ?? [];
872
- const outputsData = outputs.map((_, i) => (0, index_js_4.hexFrom)(tx.outputsData?.[i] ?? "0x"));
832
+ const outputsData = outputs.map((_, i) => hexFrom(tx.outputsData?.[i] ?? "0x"));
873
833
  if (tx.outputsData != null && outputsData.length < tx.outputsData.length) {
874
- outputsData.push(...tx.outputsData.slice(outputsData.length).map((d) => (0, index_js_4.hexFrom)(d)));
834
+ outputsData.push(...tx.outputsData.slice(outputsData.length).map((d) => hexFrom(d)));
875
835
  }
876
- return new Transaction((0, index_js_5.numFrom)(tx.version ?? 0), tx.cellDeps?.map((cellDep) => CellDep.from(cellDep)) ?? [], tx.headerDeps?.map(index_js_4.hexFrom) ?? [], tx.inputs?.map((input) => CellInput.from(input)) ?? [], outputs, outputsData, tx.witnesses?.map(index_js_4.hexFrom) ?? []);
836
+ return new Transaction(numFrom(tx.version ?? 0), tx.cellDeps?.map((cellDep) => CellDep.from(cellDep)) ?? [], tx.headerDeps?.map(hexFrom) ?? [], tx.inputs?.map((input) => CellInput.from(input)) ?? [], outputs, outputsData, tx.witnesses?.map(hexFrom) ?? []);
877
837
  }
878
838
  /**
879
839
  * Creates a Transaction instance from a Lumos skeleton.
@@ -912,7 +872,7 @@ class Transaction {
912
872
  stringify() {
913
873
  return JSON.stringify(this, (_, value) => {
914
874
  if (typeof value === "bigint") {
915
- return (0, index_js_5.numToHex)(value);
875
+ return numToHex(value);
916
876
  }
917
877
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
918
878
  return value;
@@ -929,13 +889,13 @@ class Transaction {
929
889
  * ```
930
890
  */
931
891
  rawToBytes() {
932
- return (0, index_js_1.bytesFrom)(mol.SerializeRawTransaction({
933
- version: (0, index_js_5.numToBytes)(this.version, 4),
892
+ return bytesFrom(mol.SerializeRawTransaction({
893
+ version: numToBytes(this.version, 4),
934
894
  cellDeps: this.cellDeps.map((d) => d._toMolData()),
935
- headerDeps: this.headerDeps.map((header) => (0, index_js_1.bytesFrom)(header)),
895
+ headerDeps: this.headerDeps.map((header) => bytesFrom(header)),
936
896
  inputs: this.inputs.map((i) => i._toMolData()),
937
897
  outputs: this.outputs.map((o) => o._toMolData()),
938
- outputsData: this.outputsData.map((header) => (0, index_js_1.bytesFrom)(header)),
898
+ outputsData: this.outputsData.map((header) => bytesFrom(header)),
939
899
  }));
940
900
  }
941
901
  /**
@@ -949,16 +909,16 @@ class Transaction {
949
909
  * ```
950
910
  */
951
911
  toBytes() {
952
- return (0, index_js_1.bytesFrom)(mol.SerializeTransaction({
912
+ return bytesFrom(mol.SerializeTransaction({
953
913
  raw: {
954
- version: (0, index_js_5.numToBytes)(this.version, 4),
914
+ version: numToBytes(this.version, 4),
955
915
  cellDeps: this.cellDeps.map((d) => d._toMolData()),
956
- headerDeps: this.headerDeps.map((header) => (0, index_js_1.bytesFrom)(header)),
916
+ headerDeps: this.headerDeps.map((header) => bytesFrom(header)),
957
917
  inputs: this.inputs.map((i) => i._toMolData()),
958
918
  outputs: this.outputs.map((o) => o._toMolData()),
959
- outputsData: this.outputsData.map((header) => (0, index_js_1.bytesFrom)(header)),
919
+ outputsData: this.outputsData.map((header) => bytesFrom(header)),
960
920
  },
961
- witnesses: this.witnesses.map((witness) => (0, index_js_1.bytesFrom)(witness)),
921
+ witnesses: this.witnesses.map((witness) => bytesFrom(witness)),
962
922
  }));
963
923
  }
964
924
  /**
@@ -972,7 +932,7 @@ class Transaction {
972
932
  * ```
973
933
  */
974
934
  hash() {
975
- return (0, index_js_3.hashCkb)(this.rawToBytes());
935
+ return hashCkb(this.rawToBytes());
976
936
  }
977
937
  /**
978
938
  * Hashes a witness and updates the hasher.
@@ -986,8 +946,8 @@ class Transaction {
986
946
  * ```
987
947
  */
988
948
  static hashWitnessToHasher(witness, hasher) {
989
- const raw = (0, index_js_1.bytesFrom)((0, index_js_4.hexFrom)(witness));
990
- hasher.update((0, index_js_5.numToBytes)(raw.length, 8));
949
+ const raw = bytesFrom(hexFrom(witness));
950
+ hasher.update(numToBytes(raw.length, 8));
991
951
  hasher.update(raw);
992
952
  }
993
953
  /**
@@ -1007,8 +967,8 @@ class Transaction {
1007
967
  * }
1008
968
  * ```
1009
969
  */
1010
- async getSignHashInfo(scriptLike, client, hasher = new index_js_3.HasherCkb()) {
1011
- const script = script_js_1.Script.from(scriptLike);
970
+ async getSignHashInfo(scriptLike, client, hasher = new HasherCkb()) {
971
+ const script = Script.from(scriptLike);
1012
972
  let position = -1;
1013
973
  hasher.update(this.hash());
1014
974
  for (let i = 0; i < this.witnesses.length; i += 1) {
@@ -1051,7 +1011,7 @@ class Transaction {
1051
1011
  * ```
1052
1012
  */
1053
1013
  async findInputIndexByLockId(scriptIdLike, client) {
1054
- const script = script_js_1.Script.from({ ...scriptIdLike, args: "0x" });
1014
+ const script = Script.from({ ...scriptIdLike, args: "0x" });
1055
1015
  for (let i = 0; i < this.inputs.length; i += 1) {
1056
1016
  const input = this.inputs[i];
1057
1017
  await input.completeExtraInfos(client);
@@ -1077,7 +1037,7 @@ class Transaction {
1077
1037
  * ```
1078
1038
  */
1079
1039
  async findInputIndexByLock(scriptLike, client) {
1080
- const script = script_js_1.Script.from(scriptLike);
1040
+ const script = Script.from(scriptLike);
1081
1041
  for (let i = 0; i < this.inputs.length; i += 1) {
1082
1042
  const input = this.inputs[i];
1083
1043
  await input.completeExtraInfos(client);
@@ -1102,7 +1062,7 @@ class Transaction {
1102
1062
  * ```
1103
1063
  */
1104
1064
  async findLastInputIndexByLock(scriptLike, client) {
1105
- const script = script_js_1.Script.from(scriptLike);
1065
+ const script = Script.from(scriptLike);
1106
1066
  for (let i = this.inputs.length - 1; i >= 0; i -= 1) {
1107
1067
  const input = this.inputs[i];
1108
1068
  await input.completeExtraInfos(client);
@@ -1197,7 +1157,7 @@ class Transaction {
1197
1157
  if (this.outputsData.length < index) {
1198
1158
  this.outputsData.push(...Array.from(new Array(index - this.outputsData.length), () => "0x"));
1199
1159
  }
1200
- this.outputsData[index] = (0, index_js_4.hexFrom)(witness);
1160
+ this.outputsData[index] = hexFrom(witness);
1201
1161
  }
1202
1162
  /**
1203
1163
  * Add output
@@ -1215,8 +1175,8 @@ class Transaction {
1215
1175
  ...outputLike,
1216
1176
  capacity: outputLike.capacity ?? 0,
1217
1177
  });
1218
- if (output.capacity === index_js_2.Zero) {
1219
- output.capacity = (0, index_js_2.fixedPointFrom)(output.occupiedSize + (0, index_js_1.bytesFrom)(outputData).length);
1178
+ if (output.capacity === Zero) {
1179
+ output.capacity = fixedPointFrom(output.occupiedSize + bytesFrom(outputData).length);
1220
1180
  }
1221
1181
  const i = this.outputs.push(output) - 1;
1222
1182
  this.setOutputDataAt(i, outputData);
@@ -1253,7 +1213,7 @@ class Transaction {
1253
1213
  if (this.witnesses.length < index) {
1254
1214
  this.witnesses.push(...Array.from(new Array(index - this.witnesses.length), () => "0x"));
1255
1215
  }
1256
- this.witnesses[index] = (0, index_js_4.hexFrom)(witness.toBytes());
1216
+ this.witnesses[index] = hexFrom(witness.toBytes());
1257
1217
  }
1258
1218
  /**
1259
1219
  * Prepare dummy witness for sighash all method
@@ -1274,23 +1234,23 @@ class Transaction {
1274
1234
  return;
1275
1235
  }
1276
1236
  const witness = this.getWitnessArgsAt(position) ?? WitnessArgs.from({});
1277
- witness.lock = (0, index_js_4.hexFrom)(Array.from(new Array(lockLen), () => 0));
1237
+ witness.lock = hexFrom(Array.from(new Array(lockLen), () => 0));
1278
1238
  this.setWitnessArgsAt(position, witness);
1279
1239
  }
1280
1240
  async getInputsCapacity(client) {
1281
- return (0, index_js_6.reduceAsync)(this.inputs, async (acc, input) => {
1241
+ return reduceAsync(this.inputs, async (acc, input) => {
1282
1242
  await input.completeExtraInfos(client);
1283
1243
  if (!input.cellOutput) {
1284
1244
  throw new Error("Unable to complete input");
1285
1245
  }
1286
1246
  return acc + input.cellOutput.capacity;
1287
- }, (0, index_js_5.numFrom)(0));
1247
+ }, numFrom(0));
1288
1248
  }
1289
1249
  getOutputsCapacity() {
1290
- return this.outputs.reduce((acc, { capacity }) => acc + capacity, (0, index_js_5.numFrom)(0));
1250
+ return this.outputs.reduce((acc, { capacity }) => acc + capacity, numFrom(0));
1291
1251
  }
1292
1252
  async getInputsUdtBalance(client, type) {
1293
- return (0, index_js_6.reduceAsync)(this.inputs, async (acc, input) => {
1253
+ return reduceAsync(this.inputs, async (acc, input) => {
1294
1254
  await input.completeExtraInfos(client);
1295
1255
  if (!input.cellOutput || !input.outputData) {
1296
1256
  throw new Error("Unable to complete input");
@@ -1299,7 +1259,7 @@ class Transaction {
1299
1259
  return;
1300
1260
  }
1301
1261
  return acc + udtBalanceFrom(input.outputData);
1302
- }, (0, index_js_5.numFrom)(0));
1262
+ }, numFrom(0));
1303
1263
  }
1304
1264
  getOutputsUdtBalance(type) {
1305
1265
  return this.outputs.reduce((acc, output, i) => {
@@ -1307,7 +1267,7 @@ class Transaction {
1307
1267
  return acc;
1308
1268
  }
1309
1269
  return acc + udtBalanceFrom(this.outputsData[i]);
1310
- }, (0, index_js_5.numFrom)(0));
1270
+ }, numFrom(0));
1311
1271
  }
1312
1272
  async completeInputs(from, filter, accumulator, init) {
1313
1273
  const collectedCells = [];
@@ -1341,7 +1301,7 @@ class Transaction {
1341
1301
  };
1342
1302
  }
1343
1303
  async completeInputsByCapacity(from, capacityTweak, filter) {
1344
- const exceptedCapacity = this.getOutputsCapacity() + (0, index_js_5.numFrom)(capacityTweak ?? 0);
1304
+ const exceptedCapacity = this.getOutputsCapacity() + numFrom(capacityTweak ?? 0);
1345
1305
  const inputsCapacity = await this.getInputsCapacity(from.client);
1346
1306
  if (inputsCapacity >= exceptedCapacity) {
1347
1307
  return 0;
@@ -1356,13 +1316,13 @@ class Transaction {
1356
1316
  if (accumulated === undefined) {
1357
1317
  return addedCount;
1358
1318
  }
1359
- throw new Error(`Insufficient CKB, need ${(0, index_js_2.fixedPointToString)(exceptedCapacity - accumulated)} extra CKB`);
1319
+ throw new Error(`Insufficient CKB, need ${fixedPointToString(exceptedCapacity - accumulated)} extra CKB`);
1360
1320
  }
1361
1321
  async completeInputsAll(from, filter) {
1362
1322
  const { addedCount } = await this.completeInputs(from, filter ?? {
1363
1323
  scriptLenRange: [0, 1],
1364
1324
  outputDataLenRange: [0, 1],
1365
- }, (acc, { cellOutput: { capacity } }) => acc + capacity, index_js_2.Zero);
1325
+ }, (acc, { cellOutput: { capacity } }) => acc + capacity, Zero);
1366
1326
  return addedCount;
1367
1327
  }
1368
1328
  async completeInputsByUdt(from, type) {
@@ -1373,7 +1333,7 @@ class Transaction {
1373
1333
  }
1374
1334
  const { addedCount, accumulated } = await this.completeInputs(from, {
1375
1335
  script: type,
1376
- outputDataLenRange: [16, (0, index_js_5.numFrom)("0xffffffff")],
1336
+ outputDataLenRange: [16, numFrom("0xffffffff")],
1377
1337
  }, (acc, { outputData }) => {
1378
1338
  const balance = udtBalanceFrom(outputData);
1379
1339
  const sum = acc + balance;
@@ -1386,14 +1346,14 @@ class Transaction {
1386
1346
  }
1387
1347
  estimateFee(feeRate) {
1388
1348
  const txSize = this.toBytes().length + 4;
1389
- return ((0, index_js_5.numFrom)(txSize) * (0, index_js_5.numFrom)(feeRate) + (0, index_js_5.numFrom)(1000)) / (0, index_js_5.numFrom)(1000);
1349
+ return (numFrom(txSize) * numFrom(feeRate) + numFrom(1000)) / numFrom(1000);
1390
1350
  }
1391
1351
  async completeFee(from, change, expectedFeeRate, filter) {
1392
1352
  const feeRate = expectedFeeRate ?? (await from.client.getFeeRate());
1393
1353
  // Complete all inputs extra infos for cache
1394
1354
  await this.getInputsCapacity(from.client);
1395
- let leastFee = index_js_2.Zero;
1396
- let leastExtraCapacity = index_js_2.Zero;
1355
+ let leastFee = Zero;
1356
+ let leastExtraCapacity = Zero;
1397
1357
  while (true) {
1398
1358
  const tx = this.clone();
1399
1359
  const collected = await (async () => {
@@ -1401,14 +1361,14 @@ class Transaction {
1401
1361
  return await tx.completeInputsByCapacity(from, leastFee + leastExtraCapacity, filter);
1402
1362
  }
1403
1363
  catch (err) {
1404
- if (leastExtraCapacity !== index_js_2.Zero) {
1364
+ if (leastExtraCapacity !== Zero) {
1405
1365
  throw new Error("Not enough capacity for the change cell");
1406
1366
  }
1407
1367
  throw err;
1408
1368
  }
1409
1369
  })();
1410
1370
  await from.prepareTransaction(tx);
1411
- if (leastFee === index_js_2.Zero) {
1371
+ if (leastFee === Zero) {
1412
1372
  // The initial fee is calculated based on prepared transaction
1413
1373
  leastFee = tx.estimateFee(feeRate);
1414
1374
  }
@@ -1418,9 +1378,9 @@ class Transaction {
1418
1378
  this.copy(tx);
1419
1379
  return [collected, false];
1420
1380
  }
1421
- const needed = (0, index_js_5.numFrom)(await Promise.resolve(change(tx, extraCapacity - leastFee)));
1381
+ const needed = numFrom(await Promise.resolve(change(tx, extraCapacity - leastFee)));
1422
1382
  // No enough extra capacity to create new cells for change
1423
- if (needed > index_js_2.Zero) {
1383
+ if (needed > Zero) {
1424
1384
  leastExtraCapacity = needed;
1425
1385
  continue;
1426
1386
  }
@@ -1444,10 +1404,10 @@ class Transaction {
1444
1404
  }
1445
1405
  }
1446
1406
  completeFeeChangeToLock(from, change, feeRate, filter) {
1447
- const script = script_js_1.Script.from(change);
1407
+ const script = Script.from(change);
1448
1408
  return this.completeFee(from, (tx, capacity) => {
1449
1409
  const changeCell = CellOutput.from({ capacity: 0, lock: script });
1450
- const occupiedCapacity = (0, index_js_2.fixedPointFrom)(changeCell.occupiedSize);
1410
+ const occupiedCapacity = fixedPointFrom(changeCell.occupiedSize);
1451
1411
  if (capacity < occupiedCapacity) {
1452
1412
  return occupiedCapacity;
1453
1413
  }
@@ -1461,7 +1421,7 @@ class Transaction {
1461
1421
  return this.completeFeeChangeToLock(from, script, feeRate, filter);
1462
1422
  }
1463
1423
  completeFeeChangeToOutput(from, index, feeRate, filter) {
1464
- const change = Number((0, index_js_5.numFrom)(index));
1424
+ const change = Number(numFrom(index));
1465
1425
  if (!this.outputs[change]) {
1466
1426
  throw new Error("Non-existed output to change");
1467
1427
  }
@@ -1471,4 +1431,3 @@ class Transaction {
1471
1431
  }, feeRate, filter);
1472
1432
  }
1473
1433
  }
1474
- exports.Transaction = Transaction;