@ckb-ccc/core 0.0.8-alpha.3 → 0.0.9-alpha.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 (143) 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/signer/signer/index.d.ts +12 -0
  15. package/dist/signer/signer/index.d.ts.map +1 -1
  16. package/dist/signer/signer/index.js +18 -0
  17. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  18. package/dist.commonjs/address/address.advanced.js +89 -115
  19. package/dist.commonjs/address/advanced.d.ts +1 -1
  20. package/dist.commonjs/address/advanced.js +14 -30
  21. package/dist.commonjs/address/index.d.ts +44 -51
  22. package/dist.commonjs/address/index.js +65 -84
  23. package/dist.commonjs/advanced.d.ts +1 -1
  24. package/dist.commonjs/advanced.js +22 -47
  25. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  26. package/dist.commonjs/advancedBarrel.js +14 -30
  27. package/dist.commonjs/barrel.d.ts +1 -1
  28. package/dist.commonjs/barrel.js +14 -30
  29. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  30. package/dist.commonjs/bytes/index.d.ts +3 -9
  31. package/dist.commonjs/bytes/index.js +26 -28
  32. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  33. package/dist.commonjs/ckb/advanced.js +22 -47
  34. package/dist.commonjs/ckb/index.d.ts +1 -1
  35. package/dist.commonjs/ckb/index.js +14 -30
  36. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  37. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  38. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  39. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  40. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  41. package/dist.commonjs/ckb/script.advanced.js +9 -12
  42. package/dist.commonjs/ckb/script.d.ts +117 -121
  43. package/dist.commonjs/ckb/script.js +176 -220
  44. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  45. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  46. package/dist.commonjs/ckb/transaction.d.ts +717 -792
  47. package/dist.commonjs/ckb/transaction.js +1155 -1383
  48. package/dist.commonjs/client/advanced.d.ts +1 -1
  49. package/dist.commonjs/client/advanced.js +14 -30
  50. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  51. package/dist.commonjs/client/client.advanced.js +61 -89
  52. package/dist.commonjs/client/client.d.ts +54 -113
  53. package/dist.commonjs/client/client.d.ts.map +1 -1
  54. package/dist.commonjs/client/client.js +182 -214
  55. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  56. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  57. package/dist.commonjs/client/clientPublicMainnet.advanced.js +161 -144
  58. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  59. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  60. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  61. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  62. package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -204
  63. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  64. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  65. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  66. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  67. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  68. package/dist.commonjs/client/clientTypes.js +22 -56
  69. package/dist.commonjs/client/index.d.ts +1 -1
  70. package/dist.commonjs/client/index.js +14 -30
  71. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  72. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  73. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  74. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  75. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  76. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  77. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  78. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  79. package/dist.commonjs/fixedPoint/index.js +20 -26
  80. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  81. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  82. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  83. package/dist.commonjs/hasher/index.d.ts +53 -38
  84. package/dist.commonjs/hasher/index.d.ts.map +1 -1
  85. package/dist.commonjs/hasher/index.js +69 -58
  86. package/dist.commonjs/hex/index.d.ts +1 -1
  87. package/dist.commonjs/hex/index.js +1 -1
  88. package/dist.commonjs/index.d.ts +1 -1
  89. package/dist.commonjs/index.js +22 -47
  90. package/dist.commonjs/num/index.d.ts +1 -1
  91. package/dist.commonjs/num/index.js +27 -39
  92. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  93. package/dist.commonjs/signer/btc/index.js +14 -30
  94. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  95. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  96. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  97. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  98. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  99. package/dist.commonjs/signer/btc/verify.js +3 -10
  100. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  101. package/dist.commonjs/signer/ckb/index.js +14 -30
  102. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  103. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  104. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  105. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  106. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  107. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  108. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  109. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  110. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  111. package/dist.commonjs/signer/dummy/index.js +14 -30
  112. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  113. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  114. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  115. package/dist.commonjs/signer/evm/index.js +14 -30
  116. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  117. package/dist.commonjs/signer/evm/signerEvm.js +70 -105
  118. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  119. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  120. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  121. package/dist.commonjs/signer/evm/verify.js +2 -7
  122. package/dist.commonjs/signer/index.d.ts +1 -1
  123. package/dist.commonjs/signer/index.js +14 -30
  124. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  125. package/dist.commonjs/signer/nostr/index.js +14 -30
  126. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  127. package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
  128. package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
  129. package/dist.commonjs/signer/nostr/verify.js +39 -50
  130. package/dist.commonjs/signer/signer/index.d.ts +162 -156
  131. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  132. package/dist.commonjs/signer/signer/index.js +199 -208
  133. package/dist.commonjs/utils/index.d.ts +8 -38
  134. package/dist.commonjs/utils/index.js +12 -18
  135. package/package.json +3 -3
  136. package/src/ckb/script.ts +2 -2
  137. package/src/ckb/transaction.ts +2 -2
  138. package/src/client/client.ts +1 -0
  139. package/src/client/clientPublicMainnet.advanced.ts +40 -1
  140. package/src/client/clientPublicTestnet.advanced.ts +23 -0
  141. package/src/hasher/index.ts +27 -2
  142. package/src/signer/nostr/signerNostr.ts +2 -2
  143. package/src/signer/signer/index.ts +45 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAMhC,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,UAAU,eAAe;CAC1B;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,KAAK,UAAU;CAChB;AAED,qBAAa,SAAS;IAEX,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,cAAc;gBAFxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,cAAc;CAElC;AAED;;;GAGG;AACH,8B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AAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;GAEG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -1,39 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignerInfo =
4
- exports.Signer =
5
- exports.Signature =
6
- exports.SignerType =
7
- exports.SignerSignType =
8
- void 0;
3
+ exports.SignerInfo = exports.Signer = exports.Signature = exports.SignerType = exports.SignerSignType = void 0;
9
4
  const btc_1 = require("../btc");
10
5
  const verifyJoyId_1 = require("../ckb/verifyJoyId");
11
6
  const verify_1 = require("../evm/verify");
12
7
  const verify_2 = require("../nostr/verify");
13
8
  var SignerSignType;
14
9
  (function (SignerSignType) {
15
- SignerSignType["Unknown"] = "Unknown";
16
- SignerSignType["BtcEcdsa"] = "BtcEcdsa";
17
- SignerSignType["EvmPersonal"] = "EvmPersonal";
18
- SignerSignType["JoyId"] = "JoyId";
19
- SignerSignType["NostrEvent"] = "NostrEvent";
10
+ SignerSignType["Unknown"] = "Unknown";
11
+ SignerSignType["BtcEcdsa"] = "BtcEcdsa";
12
+ SignerSignType["EvmPersonal"] = "EvmPersonal";
13
+ SignerSignType["JoyId"] = "JoyId";
14
+ SignerSignType["NostrEvent"] = "NostrEvent";
20
15
  })(SignerSignType || (exports.SignerSignType = SignerSignType = {}));
21
16
  /**
22
17
  * An enumeration of signer display types in wallet.
23
18
  */
24
19
  var SignerType;
25
20
  (function (SignerType) {
26
- SignerType["EVM"] = "EVM";
27
- SignerType["BTC"] = "BTC";
28
- SignerType["CKB"] = "CKB";
29
- SignerType["Nostr"] = "Nostr";
21
+ SignerType["EVM"] = "EVM";
22
+ SignerType["BTC"] = "BTC";
23
+ SignerType["CKB"] = "CKB";
24
+ SignerType["Nostr"] = "Nostr";
30
25
  })(SignerType || (exports.SignerType = SignerType = {}));
31
26
  class Signature {
32
- constructor(signature, identity, signType) {
33
- this.signature = signature;
34
- this.identity = identity;
35
- this.signType = signType;
36
- }
27
+ constructor(signature, identity, signType) {
28
+ this.signature = signature;
29
+ this.identity = identity;
30
+ this.signType = signType;
31
+ }
37
32
  }
38
33
  exports.Signature = Signature;
39
34
  /**
@@ -41,199 +36,195 @@ exports.Signature = Signature;
41
36
  * This class provides methods to connect, get addresses, and sign transactions.
42
37
  */
43
38
  class Signer {
44
- constructor(client_) {
45
- this.client_ = client_;
46
- }
47
- get client() {
48
- return this.client_;
49
- }
50
- static async verifyMessage(message, signature) {
51
- switch (signature.signType) {
52
- case SignerSignType.EvmPersonal:
53
- return (0, verify_1.verifyMessageEvmPersonal)(
54
- message,
55
- signature.signature,
56
- signature.identity,
57
- );
58
- case SignerSignType.BtcEcdsa:
59
- return (0, btc_1.verifyMessageBtcEcdsa)(
60
- message,
61
- signature.signature,
62
- signature.identity,
63
- );
64
- case SignerSignType.JoyId:
65
- return (0, verifyJoyId_1.verifyMessageJoyId)(
66
- message,
67
- signature.signature,
68
- signature.identity,
69
- );
70
- case SignerSignType.NostrEvent:
71
- return (0, verify_2.verifyMessageNostrEvent)(
72
- message,
73
- signature.signature,
74
- signature.identity,
75
- );
76
- case SignerSignType.Unknown:
77
- throw new Error("Unknown signer sign type");
78
- }
79
- }
80
- /**
81
- * Replace the current client.
82
- * returns false if the new client is invalid for this signer.
83
- */
84
- async replaceClient(client) {
85
- this.client_ = client;
86
- return true;
87
- }
88
- /**
89
- * Gets the identity for verifying signature, usually it's address
90
- *
91
- * @returns A promise that resolves to a string representing the identity
92
- */
93
- async getIdentity() {
94
- return this.getInternalAddress();
95
- }
96
- /**
97
- * Gets the recommended Address object for the signer.
98
- *
99
- * @param _preference - Optional preference parameter.
100
- * @returns A promise that resolves to the recommended Address object.
101
- */
102
- async getRecommendedAddressObj(_preference) {
103
- return (await this.getAddressObjs())[0];
104
- }
105
- /**
106
- * Gets the recommended address for the signer as a string.
107
- *
108
- * @param preference - Optional preference parameter.
109
- * @returns A promise that resolves to the recommended address as a string.
110
- */
111
- async getRecommendedAddress(preference) {
112
- return (await this.getRecommendedAddressObj(preference)).toString();
113
- }
114
- /**
115
- * Gets an array of addresses associated with the signer as strings.
116
- *
117
- * @returns A promise that resolves to an array of addresses as strings.
118
- */
119
- async getAddresses() {
120
- return this.getAddressObjs().then((addresses) =>
121
- addresses.map((address) => address.toString()),
122
- );
123
- }
124
- /**
125
- * Gets balance of all addresses
126
- *
127
- * @returns A promise that resolves to the balance
128
- */
129
- async getBalance() {
130
- return this.client.getBalance(
131
- (await this.getAddressObjs()).map(({ script }) => script),
132
- );
133
- }
134
- /**
135
- * Signs a message.
136
- *
137
- * @param _ - The message to sign, as a string or BytesLike object.
138
- * @returns A promise that resolves to the signature info.
139
- * @throws Will throw an error if not implemented.
140
- */
141
- async signMessage(message) {
142
- return {
143
- signature: await this.signMessageRaw(message),
144
- identity: await this.getIdentity(),
145
- signType: this.signType,
146
- };
147
- }
148
- /**
149
- * Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
150
- *
151
- * @param _ - The message to sign, as a string or BytesLike object.
152
- * @returns A promise that resolves to the signature as a string.
153
- * @throws Will throw an error if not implemented.
154
- */
155
- signMessageRaw(_) {
156
- throw Error("Signer.signMessageRaw not implemented");
157
- }
158
- /**
159
- * Verify a signature.
160
- *
161
- * @param _ - The original message.
162
- * @param _ - The signature to verify.
163
- * @returns A promise that resolves to the verification result.
164
- * @throws Will throw an error if not implemented.
165
- */
166
- async verifyMessage(message, signature) {
167
- if (typeof signature === "string") {
168
- return this.verifyMessageRaw(message, signature);
169
- }
170
- if (
171
- signature.identity !== (await this.getIdentity()) ||
172
- ![SignerSignType.Unknown, this.signType].includes(signature.signType)
173
- ) {
174
- return false;
175
- }
176
- return this.verifyMessageRaw(message, signature.signature);
177
- }
178
- /**
179
- * Verify a string signature. This method is not implemented and should be overridden by subclasses.
180
- *
181
- * @param _0 - The original message.
182
- * @param _1 - The signature to verify.
183
- * @returns A promise that resolves to the verification result.
184
- * @throws Will throw an error if not implemented.
185
- */
186
- verifyMessageRaw(_0, _1) {
187
- throw Error("Signer.verifyMessageRaw not implemented");
188
- }
189
- /**
190
- * Sends a transaction after signing it.
191
- *
192
- * @param tx - The transaction to send, represented as a TransactionLike object.
193
- * @returns A promise that resolves to the transaction hash as a Hex string.
194
- */
195
- async sendTransaction(tx) {
196
- return this.client.sendTransaction(await this.signTransaction(tx));
197
- }
198
- /**
199
- * Signs a transaction.
200
- *
201
- * @param tx - The transaction to sign, represented as a TransactionLike object.
202
- * @returns A promise that resolves to the signed Transaction object.
203
- */
204
- async signTransaction(tx) {
205
- const preparedTx = await this.prepareTransaction(tx);
206
- return this.signOnlyTransaction(preparedTx);
207
- }
208
- /**
209
- * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
210
- *
211
- * @param _ - The transaction to prepare, represented as a TransactionLike object.
212
- * @returns A promise that resolves to the prepared Transaction object.
213
- * @throws Will throw an error if not implemented.
214
- */
215
- prepareTransaction(_) {
216
- throw Error("Signer.prepareTransaction not implemented");
217
- }
218
- /**
219
- * Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
220
- *
221
- * @param _ - The transaction to sign, represented as a TransactionLike object.
222
- * @returns A promise that resolves to the signed Transaction object.
223
- * @throws Will throw an error if not implemented.
224
- */
225
- signOnlyTransaction(_) {
226
- throw Error("Signer.signOnlyTransaction not implemented");
227
- }
39
+ constructor(client_) {
40
+ this.client_ = client_;
41
+ }
42
+ get client() {
43
+ return this.client_;
44
+ }
45
+ // Returns the preference if we need to switch network
46
+ // undefined otherwise
47
+ matchNetworkPreference(preferences, currentNetwork) {
48
+ if (preferences.some(({ signerType, addressPrefix, network }) => {
49
+ signerType === this.type &&
50
+ addressPrefix === this.client.addressPrefix &&
51
+ network === currentNetwork;
52
+ })) {
53
+ return;
54
+ }
55
+ return preferences.find(({ signerType, addressPrefix }) => signerType === this.type && addressPrefix === this.client.addressPrefix);
56
+ }
57
+ static async verifyMessage(message, signature) {
58
+ switch (signature.signType) {
59
+ case SignerSignType.EvmPersonal:
60
+ return (0, verify_1.verifyMessageEvmPersonal)(message, signature.signature, signature.identity);
61
+ case SignerSignType.BtcEcdsa:
62
+ return (0, btc_1.verifyMessageBtcEcdsa)(message, signature.signature, signature.identity);
63
+ case SignerSignType.JoyId:
64
+ return (0, verifyJoyId_1.verifyMessageJoyId)(message, signature.signature, signature.identity);
65
+ case SignerSignType.NostrEvent:
66
+ return (0, verify_2.verifyMessageNostrEvent)(message, signature.signature, signature.identity);
67
+ case SignerSignType.Unknown:
68
+ throw new Error("Unknown signer sign type");
69
+ }
70
+ }
71
+ /**
72
+ * Replace the current client.
73
+ * returns false if the new client is invalid for this signer.
74
+ */
75
+ async replaceClient(client) {
76
+ this.client_ = client;
77
+ return true;
78
+ }
79
+ /**
80
+ * Disconnects to the signer.
81
+ *
82
+ * @returns A promise that resolves when the signer is disconnected.
83
+ */
84
+ async disconnect() { }
85
+ /**
86
+ * Gets the identity for verifying signature, usually it's address
87
+ *
88
+ * @returns A promise that resolves to a string representing the identity
89
+ */
90
+ async getIdentity() {
91
+ return this.getInternalAddress();
92
+ }
93
+ /**
94
+ * Gets the recommended Address object for the signer.
95
+ *
96
+ * @param _preference - Optional preference parameter.
97
+ * @returns A promise that resolves to the recommended Address object.
98
+ */
99
+ async getRecommendedAddressObj(_preference) {
100
+ return (await this.getAddressObjs())[0];
101
+ }
102
+ /**
103
+ * Gets the recommended address for the signer as a string.
104
+ *
105
+ * @param preference - Optional preference parameter.
106
+ * @returns A promise that resolves to the recommended address as a string.
107
+ */
108
+ async getRecommendedAddress(preference) {
109
+ return (await this.getRecommendedAddressObj(preference)).toString();
110
+ }
111
+ /**
112
+ * Gets an array of addresses associated with the signer as strings.
113
+ *
114
+ * @returns A promise that resolves to an array of addresses as strings.
115
+ */
116
+ async getAddresses() {
117
+ return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
118
+ }
119
+ /**
120
+ * Gets balance of all addresses
121
+ *
122
+ * @returns A promise that resolves to the balance
123
+ */
124
+ async getBalance() {
125
+ return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
126
+ }
127
+ /**
128
+ * Signs a message.
129
+ *
130
+ * @param _ - The message to sign, as a string or BytesLike object.
131
+ * @returns A promise that resolves to the signature info.
132
+ * @throws Will throw an error if not implemented.
133
+ */
134
+ async signMessage(message) {
135
+ return {
136
+ signature: await this.signMessageRaw(message),
137
+ identity: await this.getIdentity(),
138
+ signType: this.signType,
139
+ };
140
+ }
141
+ /**
142
+ * Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
143
+ *
144
+ * @param _ - The message to sign, as a string or BytesLike object.
145
+ * @returns A promise that resolves to the signature as a string.
146
+ * @throws Will throw an error if not implemented.
147
+ */
148
+ signMessageRaw(_) {
149
+ throw Error("Signer.signMessageRaw not implemented");
150
+ }
151
+ /**
152
+ * Verify a signature.
153
+ *
154
+ * @param _ - The original message.
155
+ * @param _ - The signature to verify.
156
+ * @returns A promise that resolves to the verification result.
157
+ * @throws Will throw an error if not implemented.
158
+ */
159
+ async verifyMessage(message, signature) {
160
+ if (typeof signature === "string") {
161
+ return this.verifyMessageRaw(message, signature);
162
+ }
163
+ if (signature.identity !== (await this.getIdentity()) ||
164
+ ![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
165
+ return false;
166
+ }
167
+ return this.verifyMessageRaw(message, signature.signature);
168
+ }
169
+ /**
170
+ * Verify a string signature. This method is not implemented and should be overridden by subclasses.
171
+ *
172
+ * @param _0 - The original message.
173
+ * @param _1 - The signature to verify.
174
+ * @returns A promise that resolves to the verification result.
175
+ * @throws Will throw an error if not implemented.
176
+ */
177
+ verifyMessageRaw(_0, _1) {
178
+ throw Error("Signer.verifyMessageRaw not implemented");
179
+ }
180
+ /**
181
+ * Sends a transaction after signing it.
182
+ *
183
+ * @param tx - The transaction to send, represented as a TransactionLike object.
184
+ * @returns A promise that resolves to the transaction hash as a Hex string.
185
+ */
186
+ async sendTransaction(tx) {
187
+ return this.client.sendTransaction(await this.signTransaction(tx));
188
+ }
189
+ /**
190
+ * Signs a transaction.
191
+ *
192
+ * @param tx - The transaction to sign, represented as a TransactionLike object.
193
+ * @returns A promise that resolves to the signed Transaction object.
194
+ */
195
+ async signTransaction(tx) {
196
+ const preparedTx = await this.prepareTransaction(tx);
197
+ return this.signOnlyTransaction(preparedTx);
198
+ }
199
+ /**
200
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
201
+ *
202
+ * @param _ - The transaction to prepare, represented as a TransactionLike object.
203
+ * @returns A promise that resolves to the prepared Transaction object.
204
+ * @throws Will throw an error if not implemented.
205
+ */
206
+ prepareTransaction(_) {
207
+ throw Error("Signer.prepareTransaction not implemented");
208
+ }
209
+ /**
210
+ * Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
211
+ *
212
+ * @param _ - The transaction to sign, represented as a TransactionLike object.
213
+ * @returns A promise that resolves to the signed Transaction object.
214
+ * @throws Will throw an error if not implemented.
215
+ */
216
+ signOnlyTransaction(_) {
217
+ throw Error("Signer.signOnlyTransaction not implemented");
218
+ }
228
219
  }
229
220
  exports.Signer = Signer;
230
221
  /**
231
222
  * A class representing information about a signer, including its type and the signer instance.
232
223
  */
233
224
  class SignerInfo {
234
- constructor(name, signer) {
235
- this.name = name;
236
- this.signer = signer;
237
- }
225
+ constructor(name, signer) {
226
+ this.name = name;
227
+ this.signer = signer;
228
+ }
238
229
  }
239
230
  exports.SignerInfo = SignerInfo;
@@ -5,10 +5,7 @@
5
5
  * @param value - The value to be transformed.
6
6
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
7
7
  */
8
- export declare function apply<T, R>(
9
- transformer: (val: T) => R,
10
- value: undefined,
11
- ): undefined;
8
+ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined): undefined;
12
9
  /**
13
10
  * A type safe way to apply a transformer on a value if it's not empty.
14
11
  *
@@ -16,10 +13,7 @@ export declare function apply<T, R>(
16
13
  * @param value - The value to be transformed.
17
14
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
18
15
  */
19
- export declare function apply<T, R>(
20
- transformer: (val: T) => R,
21
- value: null,
22
- ): null;
16
+ export declare function apply<T, R>(transformer: (val: T) => R, value: null): null;
23
17
  /**
24
18
  * A type safe way to apply a transformer on a value if it's not empty.
25
19
  *
@@ -35,10 +29,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
35
29
  * @param value - The value to be transformed.
36
30
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
37
31
  */
38
- export declare function apply<T, R>(
39
- transformer: (val: T) => R,
40
- value: T | undefined,
41
- ): R | undefined;
32
+ export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined): R | undefined;
42
33
  /**
43
34
  * A type safe way to apply a transformer on a value if it's not empty.
44
35
  *
@@ -46,10 +37,7 @@ export declare function apply<T, R>(
46
37
  * @param value - The value to be transformed.
47
38
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
48
39
  */
49
- export declare function apply<T, R>(
50
- transformer: (val: T) => R,
51
- value: T | null,
52
- ): R | null;
40
+ export declare function apply<T, R>(transformer: (val: T) => R, value: T | null): R | null;
53
41
  /**
54
42
  * A type safe way to apply a transformer on a value if it's not empty.
55
43
  *
@@ -57,10 +45,7 @@ export declare function apply<T, R>(
57
45
  * @param value - The value to be transformed.
58
46
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
59
47
  */
60
- export declare function apply<T, R>(
61
- transformer: (val: T) => R,
62
- value: undefined | null,
63
- ): undefined | null;
48
+ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined | null): undefined | null;
64
49
  /**
65
50
  * Similar to Array.reduce, but the accumulator can returns Promise.
66
51
  *
@@ -68,13 +53,7 @@ export declare function apply<T, R>(
68
53
  * @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
69
54
  * @returns The accumulated result.
70
55
  */
71
- export declare function reduceAsync<T, V>(
72
- values: T[],
73
- accumulator: (
74
- a: T,
75
- b: T,
76
- ) => Promise<T | undefined | null | void> | T | undefined | null | void,
77
- ): Promise<T>;
56
+ export declare function reduceAsync<T, V>(values: T[], accumulator: (a: T, b: T) => Promise<T | undefined | null | void> | T | undefined | null | void): Promise<T>;
78
57
  /**
79
58
  * Similar to Array.reduce, but the accumulator can returns Promise.
80
59
  *
@@ -83,15 +62,6 @@ export declare function reduceAsync<T, V>(
83
62
  * @param init - The initial value.
84
63
  * @returns The accumulated result.
85
64
  */
86
- export declare function reduceAsync<T, V>(
87
- values: V[],
88
- accumulator: (
89
- a: T,
90
- b: V,
91
- i: number,
92
- values: V[],
93
- ) => Promise<T | undefined | null | void> | T | undefined | null | void,
94
- init: T,
95
- ): Promise<T>;
65
+ export declare function reduceAsync<T, V>(values: V[], accumulator: (a: T, b: V, i: number, values: V[]) => Promise<T | undefined | null | void> | T | undefined | null | void, init: T): Promise<T>;
96
66
  export declare function isWebview(userAgent: string): boolean;
97
- //# sourceMappingURL=index.d.ts.map
67
+ //# sourceMappingURL=index.d.ts.map
@@ -9,30 +9,24 @@ exports.isWebview = exports.reduceAsync = exports.apply = void 0;
9
9
  * @returns If the value is empty, it remains its type. Otherwise it will be transformed.
10
10
  */
11
11
  function apply(transformer, value) {
12
- if (value == null) {
13
- return value;
14
- }
15
- return transformer(value);
12
+ if (value == null) {
13
+ return value;
14
+ }
15
+ return transformer(value);
16
16
  }
17
17
  exports.apply = apply;
18
18
  async function reduceAsync(values, accumulator, init) {
19
- if (init === undefined) {
20
- if (values.length === 0) {
21
- throw new TypeError("Reduce of empty array with no initial value");
19
+ if (init === undefined) {
20
+ if (values.length === 0) {
21
+ throw new TypeError("Reduce of empty array with no initial value");
22
+ }
23
+ init = values[0];
24
+ values = values.slice(1);
22
25
  }
23
- init = values[0];
24
- values = values.slice(1);
25
- }
26
- return values.reduce(
27
- (current, b, i, array) =>
28
- current.then((v) =>
29
- Promise.resolve(accumulator(v, b, i, array)).then((r) => r ?? v),
30
- ),
31
- Promise.resolve(init),
32
- );
26
+ return values.reduce((current, b, i, array) => current.then((v) => Promise.resolve(accumulator(v, b, i, array)).then((r) => r ?? v)), Promise.resolve(init));
33
27
  }
34
28
  exports.reduceAsync = reduceAsync;
35
29
  function isWebview(userAgent) {
36
- return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
30
+ return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
37
31
  }
38
32
  exports.isWebview = isWebview;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ckb-ccc/core",
3
- "version": "0.0.8-alpha.3",
4
- "description": "Common Chains Connector Core",
3
+ "version": "0.0.9-alpha.0",
4
+ "description": "Core of CCC - CKBer's Codebase",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -68,5 +68,5 @@
68
68
  "cross-fetch": "^4.0.0",
69
69
  "ethers": "^6.13.1"
70
70
  },
71
- "gitHead": "bddfa3e5631252194dfde32b79ee589703f18afb"
71
+ "gitHead": "ac4435006da9c9e48b3b66fc329e6f539156b252"
72
72
  }
package/src/ckb/script.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Bytes, BytesLike, bytesFrom } from "../bytes";
2
2
  import { Client, KnownScript } from "../client";
3
- import { ckbHash } from "../hasher";
3
+ import { hashCkb } from "../hasher";
4
4
  import { Hex, HexLike, hexFrom } from "../hex";
5
5
  import * as mol from "./molecule.advanced";
6
6
  import {
@@ -214,7 +214,7 @@ export class Script {
214
214
  * ```
215
215
  */
216
216
  hash(): Hex {
217
- return ckbHash(this.toBytes());
217
+ return hashCkb(this.toBytes());
218
218
  }
219
219
 
220
220
  /**
@@ -3,7 +3,7 @@ import { ClientCollectableSearchKeyFilterLike } from "../advancedBarrel";
3
3
  import { Bytes, BytesLike, bytesFrom } from "../bytes";
4
4
  import { CellDepInfoLike, Client, KnownScript } from "../client";
5
5
  import { Zero, fixedPointFrom } from "../fixedPoint";
6
- import { Hasher, ckbHash } from "../hasher";
6
+ import { Hasher, hashCkb } from "../hasher";
7
7
  import { Hex, HexLike, hexFrom } from "../hex";
8
8
  import {
9
9
  Num,
@@ -1026,7 +1026,7 @@ export class Transaction {
1026
1026
  */
1027
1027
 
1028
1028
  hash() {
1029
- return ckbHash(this.rawToBytes());
1029
+ return hashCkb(this.rawToBytes());
1030
1030
  }
1031
1031
 
1032
1032
  /**