@ckb-ccc/core 0.0.9-alpha.1 → 0.0.10-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.
- package/dist/ckb/transaction.d.ts +19 -15
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +44 -10
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +30 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +3 -3
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/clientTypes.advanced.d.ts +8 -8
- package/dist/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist/client/clientTypes.d.ts +2 -2
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +2 -2
- package/dist/signer/ckb/index.d.ts +3 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +3 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts +12 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
- package/dist/signer/ckb/signerCkbPrivateKey.js +38 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts +18 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
- package/dist/signer/ckb/signerCkbPublicKey.js +44 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +5 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.js +14 -0
- package/dist/signer/evm/signerEvm.d.ts +2 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +2 -2
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/signer/index.d.ts +8 -6
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +9 -5
- package/dist/utils/index.d.ts +18 -9
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist.commonjs/address/address.advanced.d.ts +29 -24
- package/dist.commonjs/address/address.advanced.js +115 -89
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +30 -14
- package/dist.commonjs/address/index.d.ts +51 -44
- package/dist.commonjs/address/index.js +84 -65
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +47 -22
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/bytes/advanced.d.ts +11 -2
- package/dist.commonjs/bytes/index.d.ts +9 -3
- package/dist.commonjs/bytes/index.js +28 -26
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +47 -22
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +30 -14
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +12 -9
- package/dist.commonjs/ckb/script.d.ts +121 -117
- package/dist.commonjs/ckb/script.js +220 -176
- 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 +806 -718
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +1425 -1158
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +30 -14
- package/dist.commonjs/client/client.advanced.d.ts +23 -6
- package/dist.commonjs/client/client.advanced.js +89 -61
- package/dist.commonjs/client/client.d.ts +114 -54
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +215 -182
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +8 -4
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +215 -161
- package/dist.commonjs/client/clientPublicMainnet.d.ts +8 -6
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +17 -15
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +6 -3
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +227 -199
- package/dist.commonjs/client/clientPublicTestnet.d.ts +8 -6
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +13 -13
- package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
- package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.advanced.js +1 -1
- package/dist.commonjs/client/clientTypes.d.ts +52 -27
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +56 -22
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +30 -14
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
- package/dist.commonjs/client/jsonRpc/index.d.ts +94 -75
- package/dist.commonjs/client/jsonRpc/index.js +135 -108
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +76 -36
- package/dist.commonjs/client/jsonRpc/transformers.js +174 -152
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +9 -3
- package/dist.commonjs/fixedPoint/index.js +26 -20
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +42 -36
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +40 -37
- package/dist.commonjs/hasher/index.js +58 -48
- 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 +47 -22
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +39 -27
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +30 -14
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.js +89 -66
- 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 +6 -2
- package/dist.commonjs/signer/btc/verify.js +10 -3
- package/dist.commonjs/signer/ckb/index.d.ts +4 -1
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +33 -14
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +12 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +56 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +18 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +58 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +11 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +27 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -2
- package/dist.commonjs/signer/ckb/verifyJoyId.js +11 -8
- 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 +30 -14
- 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 +30 -14
- package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -38
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +105 -70
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +38 -38
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
- package/dist.commonjs/signer/evm/verify.d.ts +6 -2
- package/dist.commonjs/signer/evm/verify.js +7 -2
- package/dist.commonjs/signer/index.d.ts +1 -1
- package/dist.commonjs/signer/index.js +30 -14
- package/dist.commonjs/signer/nostr/index.d.ts +1 -1
- package/dist.commonjs/signer/nostr/index.js +30 -14
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
- package/dist.commonjs/signer/nostr/signerNostr.js +100 -71
- package/dist.commonjs/signer/nostr/verify.d.ts +9 -3
- package/dist.commonjs/signer/nostr/verify.js +50 -39
- package/dist.commonjs/signer/signer/index.d.ts +171 -160
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +235 -195
- package/dist.commonjs/utils/index.d.ts +56 -14
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +19 -13
- package/package.json +2 -2
- package/src/ckb/transaction.ts +87 -33
- package/src/client/client.ts +1 -1
- package/src/client/clientPublicMainnet.advanced.ts +34 -2
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.advanced.ts +3 -3
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/clientTypes.advanced.ts +8 -8
- package/src/client/clientTypes.ts +4 -4
- package/src/signer/ckb/index.ts +3 -0
- package/src/signer/ckb/signerCkbPrivateKey.ts +58 -0
- package/src/signer/ckb/signerCkbPublicKey.ts +63 -0
- package/src/signer/ckb/verifyCkbSecp256k1.ts +27 -0
- package/src/signer/evm/signerEvm.ts +2 -2
- package/src/signer/evm/signerEvmAddressReadonly.ts +1 -1
- package/src/signer/signer/index.ts +17 -9
- package/src/utils/index.ts +24 -12
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerInfo =
|
|
3
|
+
exports.SignerInfo =
|
|
4
|
+
exports.Signer =
|
|
5
|
+
exports.Signature =
|
|
6
|
+
exports.SignerType =
|
|
7
|
+
exports.SignerSignType =
|
|
8
|
+
void 0;
|
|
4
9
|
const btc_1 = require("../btc");
|
|
10
|
+
const verifyCkbSecp256k1_1 = require("../ckb/verifyCkbSecp256k1");
|
|
5
11
|
const verifyJoyId_1 = require("../ckb/verifyJoyId");
|
|
6
12
|
const verify_1 = require("../evm/verify");
|
|
7
13
|
const verify_2 = require("../nostr/verify");
|
|
8
14
|
var SignerSignType;
|
|
9
15
|
(function (SignerSignType) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
SignerSignType["Unknown"] = "Unknown";
|
|
17
|
+
SignerSignType["BtcEcdsa"] = "BtcEcdsa";
|
|
18
|
+
SignerSignType["EvmPersonal"] = "EvmPersonal";
|
|
19
|
+
SignerSignType["JoyId"] = "JoyId";
|
|
20
|
+
SignerSignType["NostrEvent"] = "NostrEvent";
|
|
21
|
+
SignerSignType["CkbSecp256k1"] = "CkbSecp256k1";
|
|
15
22
|
})(SignerSignType || (exports.SignerSignType = SignerSignType = {}));
|
|
16
23
|
/**
|
|
17
24
|
* An enumeration of signer display types in wallet.
|
|
18
25
|
*/
|
|
19
26
|
var SignerType;
|
|
20
27
|
(function (SignerType) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
SignerType["EVM"] = "EVM";
|
|
29
|
+
SignerType["BTC"] = "BTC";
|
|
30
|
+
SignerType["CKB"] = "CKB";
|
|
31
|
+
SignerType["Nostr"] = "Nostr";
|
|
25
32
|
})(SignerType || (exports.SignerType = SignerType = {}));
|
|
26
33
|
class Signature {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
constructor(signature, identity, signType) {
|
|
35
|
+
this.signature = signature;
|
|
36
|
+
this.identity = identity;
|
|
37
|
+
this.signType = signType;
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
exports.Signature = Signature;
|
|
34
41
|
/**
|
|
@@ -36,195 +43,228 @@ exports.Signature = Signature;
|
|
|
36
43
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
37
44
|
*/
|
|
38
45
|
class Signer {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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();
|
|
46
|
+
constructor(client_) {
|
|
47
|
+
this.client_ = client_;
|
|
48
|
+
}
|
|
49
|
+
get client() {
|
|
50
|
+
return this.client_;
|
|
51
|
+
}
|
|
52
|
+
// Returns the preference if we need to switch network
|
|
53
|
+
// undefined otherwise
|
|
54
|
+
matchNetworkPreference(preferences, currentNetwork) {
|
|
55
|
+
if (
|
|
56
|
+
preferences.some(({ signerType, addressPrefix, network }) => {
|
|
57
|
+
signerType === this.type &&
|
|
58
|
+
addressPrefix === this.client.addressPrefix &&
|
|
59
|
+
network === currentNetwork;
|
|
60
|
+
})
|
|
61
|
+
) {
|
|
62
|
+
return;
|
|
110
63
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
64
|
+
return preferences.find(
|
|
65
|
+
({ signerType, addressPrefix }) =>
|
|
66
|
+
signerType === this.type && addressPrefix === this.client.addressPrefix,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
static async verifyMessage(message, signature) {
|
|
70
|
+
switch (signature.signType) {
|
|
71
|
+
case SignerSignType.EvmPersonal:
|
|
72
|
+
return (0, verify_1.verifyMessageEvmPersonal)(
|
|
73
|
+
message,
|
|
74
|
+
signature.signature,
|
|
75
|
+
signature.identity,
|
|
76
|
+
);
|
|
77
|
+
case SignerSignType.BtcEcdsa:
|
|
78
|
+
return (0, btc_1.verifyMessageBtcEcdsa)(
|
|
79
|
+
message,
|
|
80
|
+
signature.signature,
|
|
81
|
+
signature.identity,
|
|
82
|
+
);
|
|
83
|
+
case SignerSignType.JoyId:
|
|
84
|
+
return (0, verifyJoyId_1.verifyMessageJoyId)(
|
|
85
|
+
message,
|
|
86
|
+
signature.signature,
|
|
87
|
+
signature.identity,
|
|
88
|
+
);
|
|
89
|
+
case SignerSignType.NostrEvent:
|
|
90
|
+
return (0, verify_2.verifyMessageNostrEvent)(
|
|
91
|
+
message,
|
|
92
|
+
signature.signature,
|
|
93
|
+
signature.identity,
|
|
94
|
+
);
|
|
95
|
+
case SignerSignType.CkbSecp256k1:
|
|
96
|
+
return (0, verifyCkbSecp256k1_1.verifyMessageCkbSecp256k1)(
|
|
97
|
+
message,
|
|
98
|
+
signature.signature,
|
|
99
|
+
signature.identity,
|
|
100
|
+
);
|
|
101
|
+
case SignerSignType.Unknown:
|
|
102
|
+
throw new Error("Unknown signer sign type");
|
|
118
103
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Register a listener to be called when this signer is replaced.
|
|
107
|
+
*
|
|
108
|
+
* @returns A function for unregister
|
|
109
|
+
*/
|
|
110
|
+
onReplaced(_) {
|
|
111
|
+
return () => {};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Disconnects to the signer.
|
|
115
|
+
*
|
|
116
|
+
* @returns A promise that resolves when the signer is disconnected.
|
|
117
|
+
*/
|
|
118
|
+
async disconnect() {}
|
|
119
|
+
/**
|
|
120
|
+
* Gets the identity for verifying signature, usually it's address
|
|
121
|
+
*
|
|
122
|
+
* @returns A promise that resolves to a string representing the identity
|
|
123
|
+
*/
|
|
124
|
+
async getIdentity() {
|
|
125
|
+
return this.getInternalAddress();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets the recommended Address object for the signer.
|
|
129
|
+
*
|
|
130
|
+
* @param _preference - Optional preference parameter.
|
|
131
|
+
* @returns A promise that resolves to the recommended Address object.
|
|
132
|
+
*/
|
|
133
|
+
async getRecommendedAddressObj(_preference) {
|
|
134
|
+
return (await this.getAddressObjs())[0];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets the recommended address for the signer as a string.
|
|
138
|
+
*
|
|
139
|
+
* @param preference - Optional preference parameter.
|
|
140
|
+
* @returns A promise that resolves to the recommended address as a string.
|
|
141
|
+
*/
|
|
142
|
+
async getRecommendedAddress(preference) {
|
|
143
|
+
return (await this.getRecommendedAddressObj(preference)).toString();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets an array of addresses associated with the signer as strings.
|
|
147
|
+
*
|
|
148
|
+
* @returns A promise that resolves to an array of addresses as strings.
|
|
149
|
+
*/
|
|
150
|
+
async getAddresses() {
|
|
151
|
+
return this.getAddressObjs().then((addresses) =>
|
|
152
|
+
addresses.map((address) => address.toString()),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Gets balance of all addresses
|
|
157
|
+
*
|
|
158
|
+
* @returns A promise that resolves to the balance
|
|
159
|
+
*/
|
|
160
|
+
async getBalance() {
|
|
161
|
+
return this.client.getBalance(
|
|
162
|
+
(await this.getAddressObjs()).map(({ script }) => script),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Signs a message.
|
|
167
|
+
*
|
|
168
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
169
|
+
* @returns A promise that resolves to the signature info.
|
|
170
|
+
* @throws Will throw an error if not implemented.
|
|
171
|
+
*/
|
|
172
|
+
async signMessage(message) {
|
|
173
|
+
return {
|
|
174
|
+
signature: await this.signMessageRaw(message),
|
|
175
|
+
identity: await this.getIdentity(),
|
|
176
|
+
signType: this.signType,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
181
|
+
*
|
|
182
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
183
|
+
* @returns A promise that resolves to the signature as a string.
|
|
184
|
+
* @throws Will throw an error if not implemented.
|
|
185
|
+
*/
|
|
186
|
+
signMessageRaw(_) {
|
|
187
|
+
throw Error("Signer.signMessageRaw not implemented");
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Verify a signature.
|
|
191
|
+
*
|
|
192
|
+
* @param _ - The original message.
|
|
193
|
+
* @param _ - The signature to verify.
|
|
194
|
+
* @returns A promise that resolves to the verification result.
|
|
195
|
+
* @throws Will throw an error if not implemented.
|
|
196
|
+
*/
|
|
197
|
+
async verifyMessage(message, signature) {
|
|
198
|
+
if (typeof signature === "string") {
|
|
199
|
+
return this.verifyMessageRaw(message, signature);
|
|
126
200
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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");
|
|
201
|
+
if (
|
|
202
|
+
signature.identity !== (await this.getIdentity()) ||
|
|
203
|
+
![SignerSignType.Unknown, this.signType].includes(signature.signType)
|
|
204
|
+
) {
|
|
205
|
+
return false;
|
|
218
206
|
}
|
|
207
|
+
return this.verifyMessageRaw(message, signature.signature);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
211
|
+
*
|
|
212
|
+
* @param _0 - The original message.
|
|
213
|
+
* @param _1 - The signature to verify.
|
|
214
|
+
* @returns A promise that resolves to the verification result.
|
|
215
|
+
* @throws Will throw an error if not implemented.
|
|
216
|
+
*/
|
|
217
|
+
verifyMessageRaw(_0, _1) {
|
|
218
|
+
throw Error("Signer.verifyMessageRaw not implemented");
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Sends a transaction after signing it.
|
|
222
|
+
*
|
|
223
|
+
* @param tx - The transaction to send, represented as a TransactionLike object.
|
|
224
|
+
* @returns A promise that resolves to the transaction hash as a Hex string.
|
|
225
|
+
*/
|
|
226
|
+
async sendTransaction(tx) {
|
|
227
|
+
return this.client.sendTransaction(await this.signTransaction(tx));
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Signs a transaction.
|
|
231
|
+
*
|
|
232
|
+
* @param tx - The transaction to sign, represented as a TransactionLike object.
|
|
233
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
234
|
+
*/
|
|
235
|
+
async signTransaction(tx) {
|
|
236
|
+
const preparedTx = await this.prepareTransaction(tx);
|
|
237
|
+
return this.signOnlyTransaction(preparedTx);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
241
|
+
*
|
|
242
|
+
* @param _ - The transaction to prepare, represented as a TransactionLike object.
|
|
243
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
244
|
+
* @throws Will throw an error if not implemented.
|
|
245
|
+
*/
|
|
246
|
+
prepareTransaction(_) {
|
|
247
|
+
throw Error("Signer.prepareTransaction not implemented");
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
251
|
+
*
|
|
252
|
+
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
253
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
254
|
+
* @throws Will throw an error if not implemented.
|
|
255
|
+
*/
|
|
256
|
+
signOnlyTransaction(_) {
|
|
257
|
+
throw Error("Signer.signOnlyTransaction not implemented");
|
|
258
|
+
}
|
|
219
259
|
}
|
|
220
260
|
exports.Signer = Signer;
|
|
221
261
|
/**
|
|
222
262
|
* A class representing information about a signer, including its type and the signer instance.
|
|
223
263
|
*/
|
|
224
264
|
class SignerInfo {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
265
|
+
constructor(name, signer) {
|
|
266
|
+
this.name = name;
|
|
267
|
+
this.signer = signer;
|
|
268
|
+
}
|
|
229
269
|
}
|
|
230
270
|
exports.SignerInfo = SignerInfo;
|
|
@@ -3,23 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param transformer - The transformer.
|
|
5
5
|
* @param value - The value to be transformed.
|
|
6
|
-
* @returns If the value is empty, it
|
|
6
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
7
7
|
*/
|
|
8
|
-
export declare function apply<T, R>(
|
|
8
|
+
export declare function apply<T, R>(
|
|
9
|
+
transformer: (val: T) => R,
|
|
10
|
+
value: undefined,
|
|
11
|
+
): undefined;
|
|
9
12
|
/**
|
|
10
13
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
11
14
|
*
|
|
12
15
|
* @param transformer - The transformer.
|
|
13
16
|
* @param value - The value to be transformed.
|
|
14
|
-
* @returns If the value is empty, it
|
|
17
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
15
18
|
*/
|
|
16
|
-
export declare function apply<T, R>(
|
|
19
|
+
export declare function apply<T, R>(
|
|
20
|
+
transformer: (val: T) => R,
|
|
21
|
+
value: null,
|
|
22
|
+
): undefined;
|
|
17
23
|
/**
|
|
18
24
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
19
25
|
*
|
|
20
26
|
* @param transformer - The transformer.
|
|
21
27
|
* @param value - The value to be transformed.
|
|
22
|
-
* @returns If the value is empty, it
|
|
28
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
23
29
|
*/
|
|
24
30
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
25
31
|
/**
|
|
@@ -27,25 +33,46 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
|
27
33
|
*
|
|
28
34
|
* @param transformer - The transformer.
|
|
29
35
|
* @param value - The value to be transformed.
|
|
30
|
-
* @returns If the value is empty, it
|
|
36
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
31
37
|
*/
|
|
32
|
-
export declare function apply<T, R>(
|
|
38
|
+
export declare function apply<T, R>(
|
|
39
|
+
transformer: (val: T) => R,
|
|
40
|
+
value: T | undefined,
|
|
41
|
+
): R | undefined;
|
|
33
42
|
/**
|
|
34
43
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
35
44
|
*
|
|
36
45
|
* @param transformer - The transformer.
|
|
37
46
|
* @param value - The value to be transformed.
|
|
38
|
-
* @returns If the value is empty, it
|
|
47
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
39
48
|
*/
|
|
40
|
-
export declare function apply<T, R>(
|
|
49
|
+
export declare function apply<T, R>(
|
|
50
|
+
transformer: (val: T) => R,
|
|
51
|
+
value: T | null,
|
|
52
|
+
): R | undefined;
|
|
41
53
|
/**
|
|
42
54
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
43
55
|
*
|
|
44
56
|
* @param transformer - The transformer.
|
|
45
57
|
* @param value - The value to be transformed.
|
|
46
|
-
* @returns If the value is empty, it
|
|
58
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
47
59
|
*/
|
|
48
|
-
export declare function apply<T, R>(
|
|
60
|
+
export declare function apply<T, R>(
|
|
61
|
+
transformer: (val: T) => R,
|
|
62
|
+
value: undefined | null,
|
|
63
|
+
): undefined;
|
|
64
|
+
/**
|
|
65
|
+
/**
|
|
66
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
67
|
+
*
|
|
68
|
+
* @param transformer - The transformer.
|
|
69
|
+
* @param value - The value to be transformed.
|
|
70
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
71
|
+
*/
|
|
72
|
+
export declare function apply<T, R>(
|
|
73
|
+
transformer: (val: T) => R,
|
|
74
|
+
value: T | undefined | null,
|
|
75
|
+
): R | undefined;
|
|
49
76
|
/**
|
|
50
77
|
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
51
78
|
*
|
|
@@ -53,7 +80,13 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined
|
|
|
53
80
|
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
54
81
|
* @returns The accumulated result.
|
|
55
82
|
*/
|
|
56
|
-
export declare function reduceAsync<T, V>(
|
|
83
|
+
export declare function reduceAsync<T, V>(
|
|
84
|
+
values: T[],
|
|
85
|
+
accumulator: (
|
|
86
|
+
a: T,
|
|
87
|
+
b: T,
|
|
88
|
+
) => Promise<T | undefined | null | void> | T | undefined | null | void,
|
|
89
|
+
): Promise<T>;
|
|
57
90
|
/**
|
|
58
91
|
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
59
92
|
*
|
|
@@ -62,6 +95,15 @@ export declare function reduceAsync<T, V>(values: T[], accumulator: (a: T, b: T)
|
|
|
62
95
|
* @param init - The initial value.
|
|
63
96
|
* @returns The accumulated result.
|
|
64
97
|
*/
|
|
65
|
-
export declare function reduceAsync<T, V>(
|
|
98
|
+
export declare function reduceAsync<T, V>(
|
|
99
|
+
values: V[],
|
|
100
|
+
accumulator: (
|
|
101
|
+
a: T,
|
|
102
|
+
b: V,
|
|
103
|
+
i: number,
|
|
104
|
+
values: V[],
|
|
105
|
+
) => Promise<T | undefined | null | void> | T | undefined | null | void,
|
|
106
|
+
init: T,
|
|
107
|
+
): Promise<T>;
|
|
66
108
|
export declare function isWebview(userAgent: string): boolean;
|
|
67
|
-
//# sourceMappingURL=index.d.ts.map
|
|
109
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,CAAC;AAChF;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,SAAS,CAAC;AACjB;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,CAAC;AACb;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,GAC1B,CAAC,GAAG,SAAS,CAAC;AAmBjB;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,KACD,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GACtE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,CAAC,EAAE,KACR,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,EACvE,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,CAAC,CAAC,CAAC;AA4Bd,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -6,27 +6,33 @@ exports.isWebview = exports.reduceAsync = exports.apply = void 0;
|
|
|
6
6
|
*
|
|
7
7
|
* @param transformer - The transformer.
|
|
8
8
|
* @param value - The value to be transformed.
|
|
9
|
-
* @returns If the value is empty, it
|
|
9
|
+
* @returns If the value is empty, it becomes undefined. Otherwise it will be transformed.
|
|
10
10
|
*/
|
|
11
11
|
function apply(transformer, value) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (value == null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return transformer(value);
|
|
16
16
|
}
|
|
17
17
|
exports.apply = apply;
|
|
18
18
|
async function reduceAsync(values, accumulator, init) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
init = values[0];
|
|
24
|
-
values = values.slice(1);
|
|
19
|
+
if (init === undefined) {
|
|
20
|
+
if (values.length === 0) {
|
|
21
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
|
25
22
|
}
|
|
26
|
-
|
|
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
|
+
);
|
|
27
33
|
}
|
|
28
34
|
exports.reduceAsync = reduceAsync;
|
|
29
35
|
function isWebview(userAgent) {
|
|
30
|
-
|
|
36
|
+
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
|
|
31
37
|
}
|
|
32
38
|
exports.isWebview = isWebview;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10-alpha.4",
|
|
4
4
|
"description": "Core of CCC - CKBer's Codebase",
|
|
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": "61228337bbf4bdc0bc082e3c9530f843c2182106"
|
|
72
72
|
}
|