@ckb-ccc/core 0.0.7-alpha.1 → 0.0.7-alpha.2
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.
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +2 -2
- package/dist.commonjs/address/address.advanced.d.ts +24 -29
- package/dist.commonjs/address/address.advanced.js +89 -115
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +14 -30
- package/dist.commonjs/address/index.d.ts +44 -51
- package/dist.commonjs/address/index.js +65 -84
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +22 -47
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +14 -30
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +14 -30
- package/dist.commonjs/bytes/advanced.d.ts +2 -11
- package/dist.commonjs/bytes/index.d.ts +3 -9
- package/dist.commonjs/bytes/index.js +26 -28
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +22 -47
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +14 -30
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +9 -12
- package/dist.commonjs/ckb/script.d.ts +117 -121
- package/dist.commonjs/ckb/script.js +176 -220
- package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/transaction.advanced.js +4 -4
- package/dist.commonjs/ckb/transaction.d.ts +717 -792
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +1155 -1383
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +14 -30
- package/dist.commonjs/client/client.advanced.d.ts +6 -23
- package/dist.commonjs/client/client.advanced.js +61 -89
- package/dist.commonjs/client/client.d.ts +53 -113
- package/dist.commonjs/client/client.js +181 -214
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +127 -144
- package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicMainnet.js +15 -17
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +179 -204
- package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
- package/dist.commonjs/client/clientPublicTestnet.js +13 -13
- package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
- package/dist.commonjs/client/clientTypes.advanced.js +1 -1
- package/dist.commonjs/client/clientTypes.d.ts +26 -51
- package/dist.commonjs/client/clientTypes.js +22 -56
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +14 -30
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
- package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
- package/dist.commonjs/client/jsonRpc/index.js +108 -135
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
- package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +3 -9
- package/dist.commonjs/fixedPoint/index.js +20 -26
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +36 -42
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +36 -36
- package/dist.commonjs/hasher/index.js +47 -54
- package/dist.commonjs/hex/index.d.ts +1 -1
- package/dist.commonjs/hex/index.js +1 -1
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +22 -47
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +27 -39
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +14 -30
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.js +66 -89
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
- package/dist.commonjs/signer/btc/verify.d.ts +2 -6
- package/dist.commonjs/signer/btc/verify.js +3 -10
- package/dist.commonjs/signer/ckb/index.d.ts +1 -1
- package/dist.commonjs/signer/ckb/index.js +14 -30
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
- package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
- package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
- package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
- package/dist.commonjs/signer/dummy/dummy.js +16 -16
- package/dist.commonjs/signer/dummy/index.d.ts +1 -1
- package/dist.commonjs/signer/dummy/index.js +14 -30
- package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
- package/dist.commonjs/signer/dummy/openLink.js +7 -7
- package/dist.commonjs/signer/evm/index.d.ts +1 -1
- package/dist.commonjs/signer/evm/index.js +14 -30
- package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
- package/dist.commonjs/signer/evm/signerEvm.js +70 -105
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
- package/dist.commonjs/signer/evm/verify.d.ts +2 -6
- package/dist.commonjs/signer/evm/verify.js +2 -7
- package/dist.commonjs/signer/index.d.ts +1 -1
- package/dist.commonjs/signer/index.js +14 -30
- package/dist.commonjs/signer/nostr/index.d.ts +1 -1
- package/dist.commonjs/signer/nostr/index.js +14 -30
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
- package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
- package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
- package/dist.commonjs/signer/nostr/verify.js +39 -50
- package/dist.commonjs/signer/signer/index.d.ts +150 -156
- package/dist.commonjs/signer/signer/index.js +181 -208
- package/dist.commonjs/utils/index.d.ts +8 -38
- package/dist.commonjs/utils/index.js +12 -18
- package/package.json +2 -2
- package/src/ckb/transaction.ts +3 -2
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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,177 @@ exports.Signature = Signature;
|
|
|
41
36
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
42
37
|
*/
|
|
43
38
|
class Signer {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
) {
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
+
static async verifyMessage(message, signature) {
|
|
46
|
+
switch (signature.signType) {
|
|
47
|
+
case SignerSignType.EvmPersonal:
|
|
48
|
+
return (0, verify_1.verifyMessageEvmPersonal)(message, signature.signature, signature.identity);
|
|
49
|
+
case SignerSignType.BtcEcdsa:
|
|
50
|
+
return (0, btc_1.verifyMessageBtcEcdsa)(message, signature.signature, signature.identity);
|
|
51
|
+
case SignerSignType.JoyId:
|
|
52
|
+
return (0, verifyJoyId_1.verifyMessageJoyId)(message, signature.signature, signature.identity);
|
|
53
|
+
case SignerSignType.NostrEvent:
|
|
54
|
+
return (0, verify_2.verifyMessageNostrEvent)(message, signature.signature, signature.identity);
|
|
55
|
+
case SignerSignType.Unknown:
|
|
56
|
+
throw new Error("Unknown signer sign type");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Replace the current client.
|
|
61
|
+
* returns false if the new client is invalid for this signer.
|
|
62
|
+
*/
|
|
63
|
+
async replaceClient(client) {
|
|
64
|
+
this.client_ = client;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the identity for verifying signature, usually it's address
|
|
69
|
+
*
|
|
70
|
+
* @returns A promise that resolves to a string representing the identity
|
|
71
|
+
*/
|
|
72
|
+
async getIdentity() {
|
|
73
|
+
return this.getInternalAddress();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the recommended Address object for the signer.
|
|
77
|
+
*
|
|
78
|
+
* @param _preference - Optional preference parameter.
|
|
79
|
+
* @returns A promise that resolves to the recommended Address object.
|
|
80
|
+
*/
|
|
81
|
+
async getRecommendedAddressObj(_preference) {
|
|
82
|
+
return (await this.getAddressObjs())[0];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the recommended address for the signer as a string.
|
|
86
|
+
*
|
|
87
|
+
* @param preference - Optional preference parameter.
|
|
88
|
+
* @returns A promise that resolves to the recommended address as a string.
|
|
89
|
+
*/
|
|
90
|
+
async getRecommendedAddress(preference) {
|
|
91
|
+
return (await this.getRecommendedAddressObj(preference)).toString();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gets an array of addresses associated with the signer as strings.
|
|
95
|
+
*
|
|
96
|
+
* @returns A promise that resolves to an array of addresses as strings.
|
|
97
|
+
*/
|
|
98
|
+
async getAddresses() {
|
|
99
|
+
return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Gets balance of all addresses
|
|
103
|
+
*
|
|
104
|
+
* @returns A promise that resolves to the balance
|
|
105
|
+
*/
|
|
106
|
+
async getBalance() {
|
|
107
|
+
return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Signs a message.
|
|
111
|
+
*
|
|
112
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
113
|
+
* @returns A promise that resolves to the signature info.
|
|
114
|
+
* @throws Will throw an error if not implemented.
|
|
115
|
+
*/
|
|
116
|
+
async signMessage(message) {
|
|
117
|
+
return {
|
|
118
|
+
signature: await this.signMessageRaw(message),
|
|
119
|
+
identity: await this.getIdentity(),
|
|
120
|
+
signType: this.signType,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
125
|
+
*
|
|
126
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
127
|
+
* @returns A promise that resolves to the signature as a string.
|
|
128
|
+
* @throws Will throw an error if not implemented.
|
|
129
|
+
*/
|
|
130
|
+
signMessageRaw(_) {
|
|
131
|
+
throw Error("Signer.signMessageRaw not implemented");
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Verify a signature.
|
|
135
|
+
*
|
|
136
|
+
* @param _ - The original message.
|
|
137
|
+
* @param _ - The signature to verify.
|
|
138
|
+
* @returns A promise that resolves to the verification result.
|
|
139
|
+
* @throws Will throw an error if not implemented.
|
|
140
|
+
*/
|
|
141
|
+
async verifyMessage(message, signature) {
|
|
142
|
+
if (typeof signature === "string") {
|
|
143
|
+
return this.verifyMessageRaw(message, signature);
|
|
144
|
+
}
|
|
145
|
+
if (signature.identity !== (await this.getIdentity()) ||
|
|
146
|
+
![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return this.verifyMessageRaw(message, signature.signature);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
153
|
+
*
|
|
154
|
+
* @param _0 - The original message.
|
|
155
|
+
* @param _1 - 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
|
+
verifyMessageRaw(_0, _1) {
|
|
160
|
+
throw Error("Signer.verifyMessageRaw not implemented");
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sends a transaction after signing it.
|
|
164
|
+
*
|
|
165
|
+
* @param tx - The transaction to send, represented as a TransactionLike object.
|
|
166
|
+
* @returns A promise that resolves to the transaction hash as a Hex string.
|
|
167
|
+
*/
|
|
168
|
+
async sendTransaction(tx) {
|
|
169
|
+
return this.client.sendTransaction(await this.signTransaction(tx));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Signs a transaction.
|
|
173
|
+
*
|
|
174
|
+
* @param tx - The transaction to sign, represented as a TransactionLike object.
|
|
175
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
176
|
+
*/
|
|
177
|
+
async signTransaction(tx) {
|
|
178
|
+
const preparedTx = await this.prepareTransaction(tx);
|
|
179
|
+
return this.signOnlyTransaction(preparedTx);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
183
|
+
*
|
|
184
|
+
* @param _ - The transaction to prepare, represented as a TransactionLike object.
|
|
185
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
186
|
+
* @throws Will throw an error if not implemented.
|
|
187
|
+
*/
|
|
188
|
+
prepareTransaction(_) {
|
|
189
|
+
throw Error("Signer.prepareTransaction not implemented");
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
193
|
+
*
|
|
194
|
+
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
195
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
196
|
+
* @throws Will throw an error if not implemented.
|
|
197
|
+
*/
|
|
198
|
+
signOnlyTransaction(_) {
|
|
199
|
+
throw Error("Signer.signOnlyTransaction not implemented");
|
|
200
|
+
}
|
|
228
201
|
}
|
|
229
202
|
exports.Signer = Signer;
|
|
230
203
|
/**
|
|
231
204
|
* A class representing information about a signer, including its type and the signer instance.
|
|
232
205
|
*/
|
|
233
206
|
class SignerInfo {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
207
|
+
constructor(name, signer) {
|
|
208
|
+
this.name = name;
|
|
209
|
+
this.signer = signer;
|
|
210
|
+
}
|
|
238
211
|
}
|
|
239
212
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
+
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
|
|
37
31
|
}
|
|
38
32
|
exports.isWebview = isWebview;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/core",
|
|
3
|
-
"version": "0.0.7-alpha.
|
|
3
|
+
"version": "0.0.7-alpha.2",
|
|
4
4
|
"description": "Common Chains Connector Core",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"cross-fetch": "^4.0.0",
|
|
69
69
|
"ethers": "^6.13.1"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "4b773c10f39944c6380d556dbf0b35e911935d13"
|
|
72
72
|
}
|
package/src/ckb/transaction.ts
CHANGED
|
@@ -1074,9 +1074,10 @@ export class Transaction {
|
|
|
1074
1074
|
hasher.update(this.hash());
|
|
1075
1075
|
|
|
1076
1076
|
for (let i = 0; i < this.witnesses.length; i += 1) {
|
|
1077
|
-
const input =
|
|
1078
|
-
await input.completeExtraInfos(client);
|
|
1077
|
+
const input = this.inputs[i];
|
|
1079
1078
|
if (input) {
|
|
1079
|
+
await input.completeExtraInfos(client);
|
|
1080
|
+
|
|
1080
1081
|
if (!input.cellOutput) {
|
|
1081
1082
|
throw new Error("Unable to complete input");
|
|
1082
1083
|
}
|