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

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