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

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 (110) hide show
  1. package/dist/ckb/transaction.d.ts +2 -4
  2. package/dist/ckb/transaction.d.ts.map +1 -1
  3. package/dist/ckb/transaction.js +12 -12
  4. package/dist/client/client.js +1 -1
  5. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  6. package/dist.commonjs/address/address.advanced.js +92 -114
  7. package/dist.commonjs/address/advanced.d.ts +1 -1
  8. package/dist.commonjs/address/advanced.js +14 -30
  9. package/dist.commonjs/address/index.d.ts +44 -51
  10. package/dist.commonjs/address/index.js +68 -87
  11. package/dist.commonjs/advanced.d.ts +1 -1
  12. package/dist.commonjs/advanced.js +22 -47
  13. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  14. package/dist.commonjs/advancedBarrel.js +14 -30
  15. package/dist.commonjs/barrel.d.ts +1 -1
  16. package/dist.commonjs/barrel.js +14 -30
  17. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  18. package/dist.commonjs/bytes/index.d.ts +3 -9
  19. package/dist.commonjs/bytes/index.js +26 -28
  20. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  21. package/dist.commonjs/ckb/advanced.js +22 -47
  22. package/dist.commonjs/ckb/index.d.ts +1 -1
  23. package/dist.commonjs/ckb/index.js +14 -30
  24. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  25. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  26. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  27. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  28. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  29. package/dist.commonjs/ckb/script.advanced.js +9 -12
  30. package/dist.commonjs/ckb/script.d.ts +76 -76
  31. package/dist.commonjs/ckb/script.js +126 -166
  32. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  33. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  34. package/dist.commonjs/ckb/transaction.d.ts +530 -570
  35. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  36. package/dist.commonjs/ckb/transaction.js +722 -839
  37. package/dist.commonjs/client/advanced.d.ts +1 -1
  38. package/dist.commonjs/client/advanced.js +14 -30
  39. package/dist.commonjs/client/client.d.ts +21 -52
  40. package/dist.commonjs/client/client.js +57 -66
  41. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +2 -5
  42. package/dist.commonjs/client/clientPublicMainnet.advanced.js +24 -30
  43. package/dist.commonjs/client/clientPublicMainnet.d.ts +4 -6
  44. package/dist.commonjs/client/clientPublicMainnet.js +9 -9
  45. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +2 -5
  46. package/dist.commonjs/client/clientPublicTestnet.advanced.js +24 -30
  47. package/dist.commonjs/client/clientPublicTestnet.d.ts +4 -6
  48. package/dist.commonjs/client/clientPublicTestnet.js +9 -9
  49. package/dist.commonjs/client/clientTypes.d.ts +36 -51
  50. package/dist.commonjs/client/clientTypes.js +19 -34
  51. package/dist.commonjs/client/index.d.ts +1 -1
  52. package/dist.commonjs/client/index.js +14 -30
  53. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  54. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  55. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -92
  56. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  57. package/dist.commonjs/client/jsonRpc/transformers.d.ts +38 -78
  58. package/dist.commonjs/client/jsonRpc/transformers.js +150 -175
  59. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  60. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  61. package/dist.commonjs/fixedPoint/index.js +20 -26
  62. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  63. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  64. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  65. package/dist.commonjs/hasher/index.d.ts +36 -36
  66. package/dist.commonjs/hasher/index.js +45 -52
  67. package/dist.commonjs/hex/index.d.ts +1 -1
  68. package/dist.commonjs/hex/index.js +1 -1
  69. package/dist.commonjs/index.d.ts +1 -1
  70. package/dist.commonjs/index.js +22 -47
  71. package/dist.commonjs/num/index.d.ts +1 -1
  72. package/dist.commonjs/num/index.js +19 -30
  73. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  74. package/dist.commonjs/signer/btc/index.js +14 -30
  75. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  76. package/dist.commonjs/signer/btc/signerBtc.js +65 -85
  77. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  78. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  79. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  80. package/dist.commonjs/signer/btc/verify.js +2 -5
  81. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  82. package/dist.commonjs/signer/ckb/index.js +14 -30
  83. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  84. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  85. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  86. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  87. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  88. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  89. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  90. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  91. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  92. package/dist.commonjs/signer/dummy/index.js +14 -30
  93. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  94. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  95. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  96. package/dist.commonjs/signer/evm/index.js +14 -30
  97. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  98. package/dist.commonjs/signer/evm/signerEvm.js +68 -100
  99. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  100. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  101. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  102. package/dist.commonjs/signer/evm/verify.js +2 -7
  103. package/dist.commonjs/signer/index.d.ts +1 -1
  104. package/dist.commonjs/signer/index.js +14 -30
  105. package/dist.commonjs/signer/signer/index.d.ts +153 -159
  106. package/dist.commonjs/signer/signer/index.js +181 -204
  107. package/dist.commonjs/utils/index.d.ts +8 -36
  108. package/dist.commonjs/utils/index.js +12 -18
  109. package/package.json +2 -2
  110. package/src/ckb/transaction.ts +14 -13
@@ -2,50 +2,44 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _1 = require(".");
4
4
  describe("fixedPointToString", () => {
5
- const cases = [
6
- [0n, "0"],
7
- [1n, "0.00000001"],
8
- [100000000n, "1"],
9
- [1000000000n, "10"],
10
- [1010100000n, "10.101"],
11
- [11n, "1.1", 1],
12
- [0n, "0", 1],
13
- [1n, "1", 0],
14
- [0n, "0", 0],
15
- ];
16
- cases.forEach(([i, o, decimals]) =>
17
- test(`${i} with ${decimals ?? "default"} decimals = "${o}"`, () => {
18
- expect((0, _1.fixedPointToString)(i, decimals)).toBe(o);
19
- }),
20
- );
5
+ const cases = [
6
+ [0n, "0"],
7
+ [1n, "0.00000001"],
8
+ [100000000n, "1"],
9
+ [1000000000n, "10"],
10
+ [1010100000n, "10.101"],
11
+ [11n, "1.1", 1],
12
+ [0n, "0", 1],
13
+ [1n, "1", 0],
14
+ [0n, "0", 0],
15
+ ];
16
+ cases.forEach(([i, o, decimals]) => test(`${i} with ${decimals ?? "default"} decimals = "${o}"`, () => {
17
+ expect((0, _1.fixedPointToString)(i, decimals)).toBe(o);
18
+ }));
21
19
  });
22
20
  describe("fixedPointFrom string", () => {
23
- const cases = [
24
- ["0", 0n],
25
- ["0.00000001", 1n],
26
- ["1", 100000000n],
27
- ["10", 1000000000n],
28
- ["10.101", 1010100000n],
29
- ["1.1", 11n, 1],
30
- ["0", 0n, 1],
31
- ["1", 1n, 0],
32
- ["0", 0n, 0],
33
- ];
34
- cases.forEach(([i, o, decimals]) =>
35
- test(`"${i}" = ${o} with ${decimals ?? "default"} decimals `, () => {
36
- expect((0, _1.fixedPointFrom)(i, decimals)).toBe(o);
37
- }),
38
- );
21
+ const cases = [
22
+ ["0", 0n],
23
+ ["0.00000001", 1n],
24
+ ["1", 100000000n],
25
+ ["10", 1000000000n],
26
+ ["10.101", 1010100000n],
27
+ ["1.1", 11n, 1],
28
+ ["0", 0n, 1],
29
+ ["1", 1n, 0],
30
+ ["0", 0n, 0],
31
+ ];
32
+ cases.forEach(([i, o, decimals]) => test(`"${i}" = ${o} with ${decimals ?? "default"} decimals `, () => {
33
+ expect((0, _1.fixedPointFrom)(i, decimals)).toBe(o);
34
+ }));
39
35
  });
40
36
  describe("fixedPointFrom number", () => {
41
- const cases = [
42
- [0.00000001, 1n],
43
- [10.101, 1010100000n],
44
- [1.1, 11n, 1],
45
- ];
46
- cases.forEach(([i, o, decimals]) =>
47
- test(`${i} = ${o} with ${decimals ?? "default"} decimals `, () => {
48
- expect((0, _1.fixedPointFrom)(i, decimals)).toBe(o);
49
- }),
50
- );
37
+ const cases = [
38
+ [0.00000001, 1n],
39
+ [10.101, 1010100000n],
40
+ [1.1, 11n, 1],
41
+ ];
42
+ cases.forEach(([i, o, decimals]) => test(`${i} = ${o} with ${decimals ?? "default"} decimals `, () => {
43
+ expect((0, _1.fixedPointFrom)(i, decimals)).toBe(o);
44
+ }));
51
45
  });
@@ -1,2 +1,2 @@
1
1
  export declare const CKB_BLAKE2B_PERSONAL = "ckb-default-hash";
2
- //# sourceMappingURL=advanced.d.ts.map
2
+ //# sourceMappingURL=advanced.d.ts.map
@@ -1,41 +1,41 @@
1
1
  import { BytesLike } from "../bytes";
2
2
  import { Hex } from "../hex";
3
3
  export declare class Hasher {
4
- private readonly hasher;
5
- /**
6
- * Creates an instance of Hasher.
7
- *
8
- * @param outLength - The output length of the hash in bytes. Default is 32.
9
- * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
10
- */
11
- constructor(outLength?: number, personal?: string);
12
- /**
13
- * Updates the hash with the given data.
14
- *
15
- * @param data - The data to update the hash with.
16
- * @returns The current Hasher instance for chaining.
17
- *
18
- * @example
19
- * ```typescript
20
- * const hasher = new Hasher();
21
- * hasher.update("some data").update("more data");
22
- * const hash = hasher.digest();
23
- * ```
24
- */
25
- update(data: BytesLike): Hasher;
26
- /**
27
- * Finalizes the hash and returns the digest as a hexadecimal string.
28
- *
29
- * @returns The hexadecimal string representation of the hash.
30
- *
31
- * @example
32
- * ```typescript
33
- * const hasher = new Hasher();
34
- * hasher.update("some data");
35
- * const hash = hasher.digest(); // Outputs something like "0x..."
36
- * ```
37
- */
38
- digest(): Hex;
4
+ private readonly hasher;
5
+ /**
6
+ * Creates an instance of Hasher.
7
+ *
8
+ * @param outLength - The output length of the hash in bytes. Default is 32.
9
+ * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
10
+ */
11
+ constructor(outLength?: number, personal?: string);
12
+ /**
13
+ * Updates the hash with the given data.
14
+ *
15
+ * @param data - The data to update the hash with.
16
+ * @returns The current Hasher instance for chaining.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const hasher = new Hasher();
21
+ * hasher.update("some data").update("more data");
22
+ * const hash = hasher.digest();
23
+ * ```
24
+ */
25
+ update(data: BytesLike): Hasher;
26
+ /**
27
+ * Finalizes the hash and returns the digest as a hexadecimal string.
28
+ *
29
+ * @returns The hexadecimal string representation of the hash.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const hasher = new Hasher();
34
+ * hasher.update("some data");
35
+ * const hash = hasher.digest(); // Outputs something like "0x..."
36
+ * ```
37
+ */
38
+ digest(): Hex;
39
39
  }
40
40
  /**
41
41
  * Computes the CKB hash of the given data using the Blake2b algorithm.
@@ -49,4 +49,4 @@ export declare class Hasher {
49
49
  * ```
50
50
  */
51
51
  export declare function ckbHash(data: BytesLike): Hex;
52
- //# sourceMappingURL=index.d.ts.map
52
+ //# sourceMappingURL=index.d.ts.map
@@ -1,61 +1,54 @@
1
1
  "use strict";
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : { default: mod };
6
- };
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
7
5
  Object.defineProperty(exports, "__esModule", { value: true });
8
6
  exports.ckbHash = exports.Hasher = void 0;
9
7
  const blake2b_1 = __importDefault(require("blake2b"));
10
8
  const bytes_1 = require("../bytes");
11
9
  const advanced_1 = require("./advanced");
12
10
  class Hasher {
13
- /**
14
- * Creates an instance of Hasher.
15
- *
16
- * @param outLength - The output length of the hash in bytes. Default is 32.
17
- * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
18
- */
19
- constructor(outLength = 32, personal = advanced_1.CKB_BLAKE2B_PERSONAL) {
20
- this.hasher = (0, blake2b_1.default)(
21
- outLength,
22
- undefined,
23
- undefined,
24
- (0, bytes_1.bytesFrom)(personal, "utf8"),
25
- );
26
- }
27
- /**
28
- * Updates the hash with the given data.
29
- *
30
- * @param data - The data to update the hash with.
31
- * @returns The current Hasher instance for chaining.
32
- *
33
- * @example
34
- * ```typescript
35
- * const hasher = new Hasher();
36
- * hasher.update("some data").update("more data");
37
- * const hash = hasher.digest();
38
- * ```
39
- */
40
- update(data) {
41
- this.hasher.update((0, bytes_1.bytesFrom)(data));
42
- return this;
43
- }
44
- /**
45
- * Finalizes the hash and returns the digest as a hexadecimal string.
46
- *
47
- * @returns The hexadecimal string representation of the hash.
48
- *
49
- * @example
50
- * ```typescript
51
- * const hasher = new Hasher();
52
- * hasher.update("some data");
53
- * const hash = hasher.digest(); // Outputs something like "0x..."
54
- * ```
55
- */
56
- digest() {
57
- return `0x${this.hasher.digest("hex")}`;
58
- }
11
+ /**
12
+ * Creates an instance of Hasher.
13
+ *
14
+ * @param outLength - The output length of the hash in bytes. Default is 32.
15
+ * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
16
+ */
17
+ constructor(outLength = 32, personal = advanced_1.CKB_BLAKE2B_PERSONAL) {
18
+ this.hasher = (0, blake2b_1.default)(outLength, undefined, undefined, (0, bytes_1.bytesFrom)(personal, "utf8"));
19
+ }
20
+ /**
21
+ * Updates the hash with the given data.
22
+ *
23
+ * @param data - The data to update the hash with.
24
+ * @returns The current Hasher instance for chaining.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const hasher = new Hasher();
29
+ * hasher.update("some data").update("more data");
30
+ * const hash = hasher.digest();
31
+ * ```
32
+ */
33
+ update(data) {
34
+ this.hasher.update((0, bytes_1.bytesFrom)(data));
35
+ return this;
36
+ }
37
+ /**
38
+ * Finalizes the hash and returns the digest as a hexadecimal string.
39
+ *
40
+ * @returns The hexadecimal string representation of the hash.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const hasher = new Hasher();
45
+ * hasher.update("some data");
46
+ * const hash = hasher.digest(); // Outputs something like "0x..."
47
+ * ```
48
+ */
49
+ digest() {
50
+ return `0x${this.hasher.digest("hex")}`;
51
+ }
59
52
  }
60
53
  exports.Hasher = Hasher;
61
54
  /**
@@ -70,6 +63,6 @@ exports.Hasher = Hasher;
70
63
  * ```
71
64
  */
72
65
  function ckbHash(data) {
73
- return new Hasher().update(data).digest();
66
+ return new Hasher().update(data).digest();
74
67
  }
75
68
  exports.ckbHash = ckbHash;
@@ -21,4 +21,4 @@ export type HexLike = BytesLike;
21
21
  * ```
22
22
  */
23
23
  export declare function hexFrom(hex: HexLike): Hex;
24
- //# sourceMappingURL=index.d.ts.map
24
+ //# sourceMappingURL=index.d.ts.map
@@ -15,6 +15,6 @@ const bytes_1 = require("../bytes");
15
15
  * ```
16
16
  */
17
17
  function hexFrom(hex) {
18
- return `0x${(0, bytes_1.bytesTo)((0, bytes_1.bytesFrom)(hex), "hex")}`;
18
+ return `0x${(0, bytes_1.bytesTo)((0, bytes_1.bytesFrom)(hex), "hex")}`;
19
19
  }
20
20
  exports.hexFrom = hexFrom;
@@ -1,3 +1,3 @@
1
1
  export * from "./barrel";
2
2
  export * as ccc from "./barrel";
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1,55 +1,30 @@
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 __exportStar =
35
- (this && this.__exportStar) ||
36
- function (m, exports) {
37
- for (var p in m)
38
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
39
- __createBinding(exports, m, p);
40
- };
41
- var __importStar =
42
- (this && this.__importStar) ||
43
- 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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
44
22
  if (mod && mod.__esModule) return mod;
45
23
  var result = {};
46
- if (mod != null)
47
- for (var k in mod)
48
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
49
- __createBinding(result, mod, k);
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
50
25
  __setModuleDefault(result, mod);
51
26
  return result;
52
- };
27
+ };
53
28
  Object.defineProperty(exports, "__esModule", { value: true });
54
29
  exports.ccc = void 0;
55
30
  __exportStar(require("./barrel"), exports);
@@ -109,4 +109,4 @@ export declare function numLeFromBytes(val: BytesLike): Num;
109
109
  * ```
110
110
  */
111
111
  export declare function numBeFromBytes(val: BytesLike): Num;
112
- //# sourceMappingURL=index.d.ts.map
112
+ //# sourceMappingURL=index.d.ts.map
@@ -1,14 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.numBeFromBytes =
4
- exports.numLeFromBytes =
5
- exports.numFromBytes =
6
- exports.numBeToBytes =
7
- exports.numLeToBytes =
8
- exports.numToBytes =
9
- exports.numToHex =
10
- exports.numFrom =
11
- void 0;
3
+ exports.numBeFromBytes = exports.numLeFromBytes = exports.numFromBytes = exports.numBeToBytes = exports.numLeToBytes = exports.numToBytes = exports.numToHex = exports.numFrom = void 0;
12
4
  const bytes_1 = require("../bytes");
13
5
  const hex_1 = require("../hex");
14
6
  /**
@@ -24,13 +16,13 @@ const hex_1 = require("../hex");
24
16
  * ```
25
17
  */
26
18
  function numFrom(val) {
27
- if (typeof val === "bigint") {
28
- return val;
29
- }
30
- if (typeof val === "string" || typeof val === "number") {
31
- return BigInt(val);
32
- }
33
- return BigInt((0, hex_1.hexFrom)(val));
19
+ if (typeof val === "bigint") {
20
+ return val;
21
+ }
22
+ if (typeof val === "string" || typeof val === "number") {
23
+ return BigInt(val);
24
+ }
25
+ return BigInt((0, hex_1.hexFrom)(val));
34
26
  }
35
27
  exports.numFrom = numFrom;
36
28
  /**
@@ -45,7 +37,7 @@ exports.numFrom = numFrom;
45
37
  * ```
46
38
  */
47
39
  function numToHex(val) {
48
- return `0x${numFrom(val).toString(16)}`;
40
+ return `0x${numFrom(val).toString(16)}`;
49
41
  }
50
42
  exports.numToHex = numToHex;
51
43
  /**
@@ -61,7 +53,7 @@ exports.numToHex = numToHex;
61
53
  * ```
62
54
  */
63
55
  function numToBytes(val, bytes) {
64
- return numLeToBytes(val, bytes);
56
+ return numLeToBytes(val, bytes);
65
57
  }
66
58
  exports.numToBytes = numToBytes;
67
59
  /**
@@ -77,7 +69,7 @@ exports.numToBytes = numToBytes;
77
69
  * ```
78
70
  */
79
71
  function numLeToBytes(val, bytes) {
80
- return numBeToBytes(val, bytes).reverse();
72
+ return numBeToBytes(val, bytes).reverse();
81
73
  }
82
74
  exports.numLeToBytes = numLeToBytes;
83
75
  /**
@@ -93,14 +85,11 @@ exports.numLeToBytes = numLeToBytes;
93
85
  * ```
94
86
  */
95
87
  function numBeToBytes(val, bytes) {
96
- const rawBytes = (0, bytes_1.bytesFrom)(numFrom(val).toString(16));
97
- if (bytes == null) {
98
- return rawBytes;
99
- }
100
- return (0, bytes_1.bytesConcat)(
101
- Array.from(Array(bytes - rawBytes.length), () => 0),
102
- rawBytes,
103
- );
88
+ const rawBytes = (0, bytes_1.bytesFrom)(numFrom(val).toString(16));
89
+ if (bytes == null) {
90
+ return rawBytes;
91
+ }
92
+ return (0, bytes_1.bytesConcat)(Array.from(Array(bytes - rawBytes.length), () => 0), rawBytes);
104
93
  }
105
94
  exports.numBeToBytes = numBeToBytes;
106
95
  /**
@@ -115,7 +104,7 @@ exports.numBeToBytes = numBeToBytes;
115
104
  * ```
116
105
  */
117
106
  function numFromBytes(val) {
118
- return numLeFromBytes(val);
107
+ return numLeFromBytes(val);
119
108
  }
120
109
  exports.numFromBytes = numFromBytes;
121
110
  /**
@@ -130,7 +119,7 @@ exports.numFromBytes = numFromBytes;
130
119
  * ```
131
120
  */
132
121
  function numLeFromBytes(val) {
133
- return numBeFromBytes((0, bytes_1.bytesFrom)(val).reverse());
122
+ return numBeFromBytes((0, bytes_1.bytesFrom)(val).reverse());
134
123
  }
135
124
  exports.numLeFromBytes = numLeFromBytes;
136
125
  /**
@@ -145,6 +134,6 @@ exports.numLeFromBytes = numLeFromBytes;
145
134
  * ```
146
135
  */
147
136
  function numBeFromBytes(val) {
148
- return numFrom((0, bytes_1.bytesFrom)(val));
137
+ return numFrom((0, bytes_1.bytesFrom)(val));
149
138
  }
150
139
  exports.numBeFromBytes = numBeFromBytes;
@@ -1,4 +1,4 @@
1
1
  export * from "./signerBtc";
2
2
  export * from "./signerBtcPublicKeyReadonly";
3
3
  export * from "./verify";
4
- //# sourceMappingURL=index.d.ts.map
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,34 +1,18 @@
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 __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
- };
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
+ };
32
16
  Object.defineProperty(exports, "__esModule", { value: true });
33
17
  __exportStar(require("./signerBtc"), exports);
34
18
  __exportStar(require("./signerBtcPublicKeyReadonly"), exports);