@ckb-ccc/core 0.0.8-alpha.3 → 0.0.8-alpha.4

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 (138) hide show
  1. package/dist/ckb/script.js +2 -2
  2. package/dist/ckb/transaction.js +2 -2
  3. package/dist/client/client.d.ts +1 -0
  4. package/dist/client/client.d.ts.map +1 -1
  5. package/dist/client/client.js +1 -0
  6. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  7. package/dist/client/clientPublicMainnet.advanced.js +35 -1
  8. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  9. package/dist/client/clientPublicTestnet.advanced.js +20 -0
  10. package/dist/hasher/index.d.ts +17 -2
  11. package/dist/hasher/index.d.ts.map +1 -1
  12. package/dist/hasher/index.js +19 -2
  13. package/dist/signer/nostr/signerNostr.js +2 -2
  14. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  15. package/dist.commonjs/address/address.advanced.js +89 -115
  16. package/dist.commonjs/address/advanced.d.ts +1 -1
  17. package/dist.commonjs/address/advanced.js +14 -30
  18. package/dist.commonjs/address/index.d.ts +44 -51
  19. package/dist.commonjs/address/index.js +65 -84
  20. package/dist.commonjs/advanced.d.ts +1 -1
  21. package/dist.commonjs/advanced.js +22 -47
  22. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  23. package/dist.commonjs/advancedBarrel.js +14 -30
  24. package/dist.commonjs/barrel.d.ts +1 -1
  25. package/dist.commonjs/barrel.js +14 -30
  26. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  27. package/dist.commonjs/bytes/index.d.ts +3 -9
  28. package/dist.commonjs/bytes/index.js +26 -28
  29. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  30. package/dist.commonjs/ckb/advanced.js +22 -47
  31. package/dist.commonjs/ckb/index.d.ts +1 -1
  32. package/dist.commonjs/ckb/index.js +14 -30
  33. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  34. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  35. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  36. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  37. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  38. package/dist.commonjs/ckb/script.advanced.js +9 -12
  39. package/dist.commonjs/ckb/script.d.ts +117 -121
  40. package/dist.commonjs/ckb/script.js +176 -220
  41. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  42. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  43. package/dist.commonjs/ckb/transaction.d.ts +717 -792
  44. package/dist.commonjs/ckb/transaction.js +1155 -1383
  45. package/dist.commonjs/client/advanced.d.ts +1 -1
  46. package/dist.commonjs/client/advanced.js +14 -30
  47. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  48. package/dist.commonjs/client/client.advanced.js +61 -89
  49. package/dist.commonjs/client/client.d.ts +54 -113
  50. package/dist.commonjs/client/client.d.ts.map +1 -1
  51. package/dist.commonjs/client/client.js +182 -214
  52. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  53. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  54. package/dist.commonjs/client/clientPublicMainnet.advanced.js +161 -144
  55. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  56. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  57. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  58. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  59. package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -204
  60. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  61. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  62. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  63. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  64. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  65. package/dist.commonjs/client/clientTypes.js +22 -56
  66. package/dist.commonjs/client/index.d.ts +1 -1
  67. package/dist.commonjs/client/index.js +14 -30
  68. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  69. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  70. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  71. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  72. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  73. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  74. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  75. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  76. package/dist.commonjs/fixedPoint/index.js +20 -26
  77. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  78. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  79. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  80. package/dist.commonjs/hasher/index.d.ts +53 -38
  81. package/dist.commonjs/hasher/index.d.ts.map +1 -1
  82. package/dist.commonjs/hasher/index.js +69 -58
  83. package/dist.commonjs/hex/index.d.ts +1 -1
  84. package/dist.commonjs/hex/index.js +1 -1
  85. package/dist.commonjs/index.d.ts +1 -1
  86. package/dist.commonjs/index.js +22 -47
  87. package/dist.commonjs/num/index.d.ts +1 -1
  88. package/dist.commonjs/num/index.js +27 -39
  89. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  90. package/dist.commonjs/signer/btc/index.js +14 -30
  91. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  92. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  93. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  94. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  95. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  96. package/dist.commonjs/signer/btc/verify.js +3 -10
  97. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  98. package/dist.commonjs/signer/ckb/index.js +14 -30
  99. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  100. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  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 +150 -156
  128. package/dist.commonjs/signer/signer/index.js +181 -208
  129. package/dist.commonjs/utils/index.d.ts +8 -38
  130. package/dist.commonjs/utils/index.js +12 -18
  131. package/package.json +3 -3
  132. package/src/ckb/script.ts +2 -2
  133. package/src/ckb/transaction.ts +2 -2
  134. package/src/client/client.ts +1 -0
  135. package/src/client/clientPublicMainnet.advanced.ts +40 -1
  136. package/src/client/clientPublicTestnet.advanced.ts +23 -0
  137. package/src/hasher/index.ts +27 -2
  138. package/src/signer/nostr/signerNostr.ts +2 -2
@@ -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,43 @@
1
1
  import { BytesLike } from "../bytes";
2
+ import { CellInputLike } from "../ckb";
2
3
  import { Hex } from "../hex";
4
+ import { NumLike } from "../num";
3
5
  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;
6
+ private readonly hasher;
7
+ /**
8
+ * Creates an instance of Hasher.
9
+ *
10
+ * @param outLength - The output length of the hash in bytes. Default is 32.
11
+ * @param personal - The personal string for the Blake2b algorithm. Default is CKB_BLAKE2B_PERSONAL.
12
+ */
13
+ constructor(outLength?: number, personal?: string);
14
+ /**
15
+ * Updates the hash with the given data.
16
+ *
17
+ * @param data - The data to update the hash with.
18
+ * @returns The current Hasher instance for chaining.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const hasher = new Hasher();
23
+ * hasher.update("some data").update("more data");
24
+ * const hash = hasher.digest();
25
+ * ```
26
+ */
27
+ update(data: BytesLike): Hasher;
28
+ /**
29
+ * Finalizes the hash and returns the digest as a hexadecimal string.
30
+ *
31
+ * @returns The hexadecimal string representation of the hash.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const hasher = new Hasher();
36
+ * hasher.update("some data");
37
+ * const hash = hasher.digest(); // Outputs something like "0x..."
38
+ * ```
39
+ */
40
+ digest(): Hex;
39
41
  }
40
42
  /**
41
43
  * Computes the CKB hash of the given data using the Blake2b algorithm.
@@ -45,8 +47,21 @@ export declare class Hasher {
45
47
  *
46
48
  * @example
47
49
  * ```typescript
48
- * const hash = ckbHash("some data"); // Outputs something like "0x..."
50
+ * const hash = hashCkb("some data"); // Outputs something like "0x..."
49
51
  * ```
50
52
  */
51
- export declare function ckbHash(...data: BytesLike[]): Hex;
52
- //# sourceMappingURL=index.d.ts.map
53
+ export declare function hashCkb(...data: BytesLike[]): Hex;
54
+ /**
55
+ * Computes the Type ID hash of the given data.
56
+ *
57
+ * @param cellInput - The first cell input of the transaction.
58
+ * @param outputIndex - The output index of the Type ID cell.
59
+ * @returns The hexadecimal string representation of the hash.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
64
+ * ```
65
+ */
66
+ export declare function hashTypeId(cellInputLike: CellInputLike, outputIndex: NumLike): Hex;
67
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC;;;;;OAKG;gBAES,SAAS,SAAK,EAAE,QAAQ,SAAuB;IAS3D;;;;;;;;;;;;OAYG;IAEH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAK/B;;;;;;;;;;;OAWG;IAEH,MAAM,IAAI,GAAG;CAGd;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,CAIjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,UAAU,CAAC;AAChD,OAAO,EAAa,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAgB,MAAM,QAAQ,CAAC;AAG/C,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC;;;;;OAKG;gBAES,SAAS,SAAK,EAAE,QAAQ,SAAuB;IAS3D;;;;;;;;;;;;OAYG;IAEH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAK/B;;;;;;;;;;;OAWG;IAEH,MAAM,IAAI,GAAG;CAGd;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,CAIjD;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,OAAO,GACnB,GAAG,CAKL"}
@@ -1,61 +1,56 @@
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
- exports.ckbHash = exports.Hasher = void 0;
6
+ exports.hashTypeId = exports.hashCkb = exports.Hasher = void 0;
9
7
  const blake2b_1 = __importDefault(require("blake2b"));
10
8
  const bytes_1 = require("../bytes");
9
+ const ckb_1 = require("../ckb");
10
+ const num_1 = require("../num");
11
11
  const advanced_1 = require("./advanced");
12
12
  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
- }
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)(outLength, undefined, undefined, (0, bytes_1.bytesFrom)(personal, "utf8"));
21
+ }
22
+ /**
23
+ * Updates the hash with the given data.
24
+ *
25
+ * @param data - The data to update the hash with.
26
+ * @returns The current Hasher instance for chaining.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const hasher = new Hasher();
31
+ * hasher.update("some data").update("more data");
32
+ * const hash = hasher.digest();
33
+ * ```
34
+ */
35
+ update(data) {
36
+ this.hasher.update((0, bytes_1.bytesFrom)(data));
37
+ return this;
38
+ }
39
+ /**
40
+ * Finalizes the hash and returns the digest as a hexadecimal string.
41
+ *
42
+ * @returns The hexadecimal string representation of the hash.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const hasher = new Hasher();
47
+ * hasher.update("some data");
48
+ * const hash = hasher.digest(); // Outputs something like "0x..."
49
+ * ```
50
+ */
51
+ digest() {
52
+ return `0x${this.hasher.digest("hex")}`;
53
+ }
59
54
  }
60
55
  exports.Hasher = Hasher;
61
56
  /**
@@ -66,12 +61,28 @@ exports.Hasher = Hasher;
66
61
  *
67
62
  * @example
68
63
  * ```typescript
69
- * const hash = ckbHash("some data"); // Outputs something like "0x..."
64
+ * const hash = hashCkb("some data"); // Outputs something like "0x..."
70
65
  * ```
71
66
  */
72
- function ckbHash(...data) {
73
- const hasher = new Hasher();
74
- data.forEach((d) => hasher.update(d));
75
- return hasher.digest();
67
+ function hashCkb(...data) {
68
+ const hasher = new Hasher();
69
+ data.forEach((d) => hasher.update(d));
70
+ return hasher.digest();
76
71
  }
77
- exports.ckbHash = ckbHash;
72
+ exports.hashCkb = hashCkb;
73
+ /**
74
+ * Computes the Type ID hash of the given data.
75
+ *
76
+ * @param cellInput - The first cell input of the transaction.
77
+ * @param outputIndex - The output index of the Type ID cell.
78
+ * @returns The hexadecimal string representation of the hash.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const hash = hashTypeId(cellInput, outputIndex); // Outputs something like "0x..."
83
+ * ```
84
+ */
85
+ function hashTypeId(cellInputLike, outputIndex) {
86
+ return hashCkb(ckb_1.CellInput.from(cellInputLike).toBytes(), (0, num_1.numLeToBytes)(outputIndex, 8));
87
+ }
88
+ exports.hashTypeId = hashTypeId;
@@ -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);
@@ -121,4 +121,4 @@ export declare function numLeFromBytes(val: BytesLike): Num;
121
121
  * ```
122
122
  */
123
123
  export declare function numBeFromBytes(val: BytesLike): Num;
124
- //# sourceMappingURL=index.d.ts.map
124
+ //# sourceMappingURL=index.d.ts.map
@@ -1,15 +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
- exports.numMax =
12
- void 0;
3
+ exports.numBeFromBytes = exports.numLeFromBytes = exports.numFromBytes = exports.numBeToBytes = exports.numLeToBytes = exports.numToBytes = exports.numToHex = exports.numFrom = exports.numMax = void 0;
13
4
  const bytes_1 = require("../bytes");
14
5
  const hex_1 = require("../hex");
15
6
  /**
@@ -24,14 +15,14 @@ const hex_1 = require("../hex");
24
15
  * ```
25
16
  */
26
17
  function numMax(a, ...numbers) {
27
- let max = numFrom(a);
28
- numbers.forEach((nLike) => {
29
- const n = numFrom(nLike);
30
- if (n > max) {
31
- max = n;
32
- }
33
- });
34
- return max;
18
+ let max = numFrom(a);
19
+ numbers.forEach((nLike) => {
20
+ const n = numFrom(nLike);
21
+ if (n > max) {
22
+ max = n;
23
+ }
24
+ });
25
+ return max;
35
26
  }
36
27
  exports.numMax = numMax;
37
28
  /**
@@ -47,13 +38,13 @@ exports.numMax = numMax;
47
38
  * ```
48
39
  */
49
40
  function numFrom(val) {
50
- if (typeof val === "bigint") {
51
- return val;
52
- }
53
- if (typeof val === "string" || typeof val === "number") {
54
- return BigInt(val);
55
- }
56
- return BigInt((0, hex_1.hexFrom)(val));
41
+ if (typeof val === "bigint") {
42
+ return val;
43
+ }
44
+ if (typeof val === "string" || typeof val === "number") {
45
+ return BigInt(val);
46
+ }
47
+ return BigInt((0, hex_1.hexFrom)(val));
57
48
  }
58
49
  exports.numFrom = numFrom;
59
50
  /**
@@ -68,7 +59,7 @@ exports.numFrom = numFrom;
68
59
  * ```
69
60
  */
70
61
  function numToHex(val) {
71
- return `0x${numFrom(val).toString(16)}`;
62
+ return `0x${numFrom(val).toString(16)}`;
72
63
  }
73
64
  exports.numToHex = numToHex;
74
65
  /**
@@ -84,7 +75,7 @@ exports.numToHex = numToHex;
84
75
  * ```
85
76
  */
86
77
  function numToBytes(val, bytes) {
87
- return numLeToBytes(val, bytes);
78
+ return numLeToBytes(val, bytes);
88
79
  }
89
80
  exports.numToBytes = numToBytes;
90
81
  /**
@@ -100,7 +91,7 @@ exports.numToBytes = numToBytes;
100
91
  * ```
101
92
  */
102
93
  function numLeToBytes(val, bytes) {
103
- return numBeToBytes(val, bytes).reverse();
94
+ return numBeToBytes(val, bytes).reverse();
104
95
  }
105
96
  exports.numLeToBytes = numLeToBytes;
106
97
  /**
@@ -116,14 +107,11 @@ exports.numLeToBytes = numLeToBytes;
116
107
  * ```
117
108
  */
118
109
  function numBeToBytes(val, bytes) {
119
- const rawBytes = (0, bytes_1.bytesFrom)(numFrom(val).toString(16));
120
- if (bytes == null) {
121
- return rawBytes;
122
- }
123
- return (0, bytes_1.bytesConcat)(
124
- Array.from(Array(bytes - rawBytes.length), () => 0),
125
- rawBytes,
126
- );
110
+ const rawBytes = (0, bytes_1.bytesFrom)(numFrom(val).toString(16));
111
+ if (bytes == null) {
112
+ return rawBytes;
113
+ }
114
+ return (0, bytes_1.bytesConcat)(Array.from(Array(bytes - rawBytes.length), () => 0), rawBytes);
127
115
  }
128
116
  exports.numBeToBytes = numBeToBytes;
129
117
  /**
@@ -138,7 +126,7 @@ exports.numBeToBytes = numBeToBytes;
138
126
  * ```
139
127
  */
140
128
  function numFromBytes(val) {
141
- return numLeFromBytes(val);
129
+ return numLeFromBytes(val);
142
130
  }
143
131
  exports.numFromBytes = numFromBytes;
144
132
  /**
@@ -153,7 +141,7 @@ exports.numFromBytes = numFromBytes;
153
141
  * ```
154
142
  */
155
143
  function numLeFromBytes(val) {
156
- return numBeFromBytes((0, bytes_1.bytesFrom)(val).reverse());
144
+ return numBeFromBytes((0, bytes_1.bytesFrom)(val).reverse());
157
145
  }
158
146
  exports.numLeFromBytes = numLeFromBytes;
159
147
  /**
@@ -168,6 +156,6 @@ exports.numLeFromBytes = numLeFromBytes;
168
156
  * ```
169
157
  */
170
158
  function numBeFromBytes(val) {
171
- return numFrom((0, bytes_1.bytesFrom)(val));
159
+ return numFrom((0, bytes_1.bytesFrom)(val));
172
160
  }
173
161
  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);