@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
|
@@ -11,108 +11,79 @@ const hex_1 = require("../../hex");
|
|
|
11
11
|
const signer_1 = require("../signer");
|
|
12
12
|
const verify_1 = require("./verify");
|
|
13
13
|
class SignerNostr extends signer_1.Signer {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.client,
|
|
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
|
-
* Signs a transaction without modifying it.
|
|
85
|
-
*
|
|
86
|
-
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
87
|
-
* @returns A promise that resolves to a signed Transaction object.
|
|
88
|
-
*/
|
|
89
|
-
async signOnlyTransaction(txLike) {
|
|
90
|
-
let tx = ckb_1.Transaction.from(txLike);
|
|
91
|
-
const { script } = await this.getRecommendedAddressObj();
|
|
92
|
-
const info = await tx.getSignHashInfo(script, this.client);
|
|
93
|
-
if (!info) {
|
|
94
|
-
return tx;
|
|
14
|
+
get type() {
|
|
15
|
+
return signer_1.SignerType.Nostr;
|
|
16
|
+
}
|
|
17
|
+
get signType() {
|
|
18
|
+
return signer_1.SignerSignType.NostrEvent;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sign a message.
|
|
22
|
+
*
|
|
23
|
+
* @returns A promise that resolves to the signature.
|
|
24
|
+
*/
|
|
25
|
+
async signMessageRaw(message) {
|
|
26
|
+
return (0, hex_1.hexFrom)((await this.signNostrEvent((0, verify_1.buildNostrEventFromMessage)(message))).sig);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gets the internal address, which is the EVM account in this case.
|
|
30
|
+
*
|
|
31
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
32
|
+
*/
|
|
33
|
+
async getInternalAddress() {
|
|
34
|
+
return bech32_1.bech32.encode("npub", bech32_1.bech32.toWords((0, bytes_1.bytesFrom)(await this.getNostrPublicKey())));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
38
|
+
*
|
|
39
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
40
|
+
*/
|
|
41
|
+
async getAddressObjs() {
|
|
42
|
+
const publicKey = await this.getNostrPublicKey();
|
|
43
|
+
return [
|
|
44
|
+
await address_1.Address.fromKnownScript(this.client, client_1.KnownScript.NostrLock, (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)([0x00], (0, hasher_1.ckbHash)(publicKey).slice(0, 42)))),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* prepare a transaction before signing.
|
|
49
|
+
*
|
|
50
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
51
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
52
|
+
*/
|
|
53
|
+
async prepareTransaction(txLike) {
|
|
54
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
55
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
56
|
+
await tx.addCellDepsOfKnownScripts(this.client, client_1.KnownScript.NostrLock);
|
|
57
|
+
await tx.prepareSighashAllWitness(script, 572, this.client);
|
|
58
|
+
return tx;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Signs a transaction without modifying it.
|
|
62
|
+
*
|
|
63
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
64
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
65
|
+
*/
|
|
66
|
+
async signOnlyTransaction(txLike) {
|
|
67
|
+
let tx = ckb_1.Transaction.from(txLike);
|
|
68
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
69
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
70
|
+
if (!info) {
|
|
71
|
+
return tx;
|
|
72
|
+
}
|
|
73
|
+
const signedEvent = (0, bytes_1.bytesFrom)(JSON.stringify(await this.signNostrEvent({
|
|
74
|
+
pubkey: (await this.getNostrPublicKey()).slice(2),
|
|
75
|
+
tags: [[SignerNostr.CKB_SIG_HASH_ALL_TAG, info.message.slice(2)]],
|
|
76
|
+
created_at: Math.floor(Date.now() / 1000),
|
|
77
|
+
kind: SignerNostr.CKB_UNLOCK_EVENT_KIND,
|
|
78
|
+
content: SignerNostr.CKB_UNLOCK_EVENT_CONTENT,
|
|
79
|
+
})), "utf8");
|
|
80
|
+
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
81
|
+
witness.lock = (0, hex_1.hexFrom)(signedEvent);
|
|
82
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
83
|
+
return tx;
|
|
95
84
|
}
|
|
96
|
-
const signedEvent = (0, bytes_1.bytesFrom)(
|
|
97
|
-
JSON.stringify(
|
|
98
|
-
await this.signNostrEvent({
|
|
99
|
-
pubkey: (await this.getNostrPublicKey()).slice(2),
|
|
100
|
-
tags: [[SignerNostr.CKB_SIG_HASH_ALL_TAG, info.message.slice(2)]],
|
|
101
|
-
created_at: Math.floor(Date.now() / 1000),
|
|
102
|
-
kind: SignerNostr.CKB_UNLOCK_EVENT_KIND,
|
|
103
|
-
content: SignerNostr.CKB_UNLOCK_EVENT_CONTENT,
|
|
104
|
-
}),
|
|
105
|
-
),
|
|
106
|
-
"utf8",
|
|
107
|
-
);
|
|
108
|
-
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
109
|
-
witness.lock = (0, hex_1.hexFrom)(signedEvent);
|
|
110
|
-
tx.setWitnessArgsAt(info.position, witness);
|
|
111
|
-
return tx;
|
|
112
|
-
}
|
|
113
85
|
}
|
|
114
86
|
exports.SignerNostr = SignerNostr;
|
|
115
87
|
SignerNostr.CKB_SIG_HASH_ALL_TAG = "ckb_sighash_all";
|
|
116
88
|
SignerNostr.CKB_UNLOCK_EVENT_KIND = 23334;
|
|
117
|
-
SignerNostr.CKB_UNLOCK_EVENT_CONTENT =
|
|
118
|
-
"Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n";
|
|
89
|
+
SignerNostr.CKB_UNLOCK_EVENT_CONTENT = "Signing a CKB transaction\n\nIMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message\n";
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { BytesLike } from "../../bytes";
|
|
2
2
|
import { NostrEvent } from "./signerNostr";
|
|
3
|
-
export declare function buildNostrEventFromMessage(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function verifyMessageNostrEvent(
|
|
7
|
-
message: string | BytesLike,
|
|
8
|
-
signature: string,
|
|
9
|
-
address: string,
|
|
10
|
-
): boolean;
|
|
11
|
-
//# sourceMappingURL=verify.d.ts.map
|
|
3
|
+
export declare function buildNostrEventFromMessage(message: string | BytesLike): NostrEvent;
|
|
4
|
+
export declare function verifyMessageNostrEvent(message: string | BytesLike, signature: string, address: string): boolean;
|
|
5
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -7,58 +7,47 @@ const bech32_1 = require("bech32");
|
|
|
7
7
|
const bytes_1 = require("../../bytes");
|
|
8
8
|
const hex_1 = require("../../hex");
|
|
9
9
|
function buildNostrEventFromMessage(message) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
content:
|
|
32
|
-
typeof message === "string" ? message : (0, hex_1.hexFrom)(message),
|
|
33
|
-
tags: [],
|
|
34
|
-
};
|
|
10
|
+
if (typeof message === "string") {
|
|
11
|
+
try {
|
|
12
|
+
const event = JSON.parse(message);
|
|
13
|
+
if (typeof event === "object" &&
|
|
14
|
+
typeof event.created_at === "number" &&
|
|
15
|
+
typeof event.kind === "number" &&
|
|
16
|
+
typeof event.content === "string" &&
|
|
17
|
+
Array.isArray(event.args) &&
|
|
18
|
+
event.args.every((tag) => Array.isArray(tag) &&
|
|
19
|
+
tag.every((v) => typeof v === "string"))) {
|
|
20
|
+
return event;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (_) { }
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: 23335,
|
|
27
|
+
created_at: 0,
|
|
28
|
+
content: typeof message === "string" ? message : (0, hex_1.hexFrom)(message),
|
|
29
|
+
tags: [],
|
|
30
|
+
};
|
|
35
31
|
}
|
|
36
32
|
exports.buildNostrEventFromMessage = buildNostrEventFromMessage;
|
|
37
33
|
function verifyMessageNostrEvent(message, signature, address) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
signature.slice(2),
|
|
57
|
-
eventHash.slice(2),
|
|
58
|
-
publicKey,
|
|
59
|
-
);
|
|
60
|
-
} catch (_) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
34
|
+
const { words } = bech32_1.bech32.decode(address);
|
|
35
|
+
const publicKey = (0, hex_1.hexFrom)(bech32_1.bech32.fromWords(words)).slice(2);
|
|
36
|
+
const event = buildNostrEventFromMessage(message);
|
|
37
|
+
const serialized = JSON.stringify([
|
|
38
|
+
0,
|
|
39
|
+
publicKey,
|
|
40
|
+
event.created_at,
|
|
41
|
+
event.kind,
|
|
42
|
+
event.tags,
|
|
43
|
+
event.content,
|
|
44
|
+
]);
|
|
45
|
+
const eventHash = (0, hex_1.hexFrom)((0, sha256_1.sha256)((0, bytes_1.bytesFrom)(serialized, "utf8")));
|
|
46
|
+
try {
|
|
47
|
+
return secp256k1_1.schnorr.verify(signature.slice(2), eventHash.slice(2), publicKey);
|
|
48
|
+
}
|
|
49
|
+
catch (_) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
63
52
|
}
|
|
64
53
|
exports.verifyMessageNostrEvent = verifyMessageNostrEvent;
|
|
@@ -5,183 +5,177 @@ import { Client } from "../../client";
|
|
|
5
5
|
import { Hex } from "../../hex";
|
|
6
6
|
import { Num } from "../../num";
|
|
7
7
|
export declare enum SignerSignType {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
Unknown = "Unknown",
|
|
9
|
+
BtcEcdsa = "BtcEcdsa",
|
|
10
|
+
EvmPersonal = "EvmPersonal",
|
|
11
|
+
JoyId = "JoyId",
|
|
12
|
+
NostrEvent = "NostrEvent"
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* An enumeration of signer display types in wallet.
|
|
16
16
|
*/
|
|
17
17
|
export declare enum SignerType {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
EVM = "EVM",
|
|
19
|
+
BTC = "BTC",
|
|
20
|
+
CKB = "CKB",
|
|
21
|
+
Nostr = "Nostr"
|
|
22
22
|
}
|
|
23
23
|
export declare class Signature {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
signature: string;
|
|
25
|
+
identity: string;
|
|
26
|
+
signType: SignerSignType;
|
|
27
|
+
constructor(signature: string, identity: string, signType: SignerSignType);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* An abstract class representing a generic signer.
|
|
31
31
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
32
32
|
*/
|
|
33
33
|
export declare abstract class Signer {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
167
|
-
* @returns A promise that resolves to the signed Transaction object.
|
|
168
|
-
* @throws Will throw an error if not implemented.
|
|
169
|
-
*/
|
|
170
|
-
signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
|
|
34
|
+
protected client_: Client;
|
|
35
|
+
constructor(client_: Client);
|
|
36
|
+
abstract get type(): SignerType;
|
|
37
|
+
abstract get signType(): SignerSignType;
|
|
38
|
+
get client(): Client;
|
|
39
|
+
static verifyMessage(message: string | BytesLike, signature: Signature): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Replace the current client.
|
|
42
|
+
* returns false if the new client is invalid for this signer.
|
|
43
|
+
*/
|
|
44
|
+
replaceClient(client: Client): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Connects to the signer.
|
|
47
|
+
*
|
|
48
|
+
* @returns A promise that resolves when the connection is complete.
|
|
49
|
+
*/
|
|
50
|
+
abstract connect(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Check if the signer is connected.
|
|
53
|
+
*
|
|
54
|
+
* @returns A promise that resolves the connection status.
|
|
55
|
+
*/
|
|
56
|
+
abstract isConnected(): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the internal address associated with the signer.
|
|
59
|
+
*
|
|
60
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
61
|
+
*/
|
|
62
|
+
abstract getInternalAddress(): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the identity for verifying signature, usually it's address
|
|
65
|
+
*
|
|
66
|
+
* @returns A promise that resolves to a string representing the identity
|
|
67
|
+
*/
|
|
68
|
+
getIdentity(): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Gets an array of Address objects associated with the signer.
|
|
71
|
+
*
|
|
72
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
73
|
+
*/
|
|
74
|
+
abstract getAddressObjs(): Promise<Address[]>;
|
|
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
|
+
getRecommendedAddressObj(_preference?: unknown): Promise<Address>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the recommended address for the signer as a string.
|
|
84
|
+
*
|
|
85
|
+
* @param preference - Optional preference parameter.
|
|
86
|
+
* @returns A promise that resolves to the recommended address as a string.
|
|
87
|
+
*/
|
|
88
|
+
getRecommendedAddress(preference?: unknown): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Gets an array of addresses associated with the signer as strings.
|
|
91
|
+
*
|
|
92
|
+
* @returns A promise that resolves to an array of addresses as strings.
|
|
93
|
+
*/
|
|
94
|
+
getAddresses(): Promise<string[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Gets balance of all addresses
|
|
97
|
+
*
|
|
98
|
+
* @returns A promise that resolves to the balance
|
|
99
|
+
*/
|
|
100
|
+
getBalance(): Promise<Num>;
|
|
101
|
+
/**
|
|
102
|
+
* Signs a message.
|
|
103
|
+
*
|
|
104
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
105
|
+
* @returns A promise that resolves to the signature info.
|
|
106
|
+
* @throws Will throw an error if not implemented.
|
|
107
|
+
*/
|
|
108
|
+
signMessage(message: string | BytesLike): Promise<Signature>;
|
|
109
|
+
/**
|
|
110
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
111
|
+
*
|
|
112
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
113
|
+
* @returns A promise that resolves to the signature as a string.
|
|
114
|
+
* @throws Will throw an error if not implemented.
|
|
115
|
+
*/
|
|
116
|
+
signMessageRaw(_: string | BytesLike): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Verify a signature.
|
|
119
|
+
*
|
|
120
|
+
* @param _ - The original message.
|
|
121
|
+
* @param _ - The signature to verify.
|
|
122
|
+
* @returns A promise that resolves to the verification result.
|
|
123
|
+
* @throws Will throw an error if not implemented.
|
|
124
|
+
*/
|
|
125
|
+
verifyMessage(message: string | BytesLike, signature: string | Signature): Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
128
|
+
*
|
|
129
|
+
* @param _0 - The original message.
|
|
130
|
+
* @param _1 - The signature to verify.
|
|
131
|
+
* @returns A promise that resolves to the verification result.
|
|
132
|
+
* @throws Will throw an error if not implemented.
|
|
133
|
+
*/
|
|
134
|
+
verifyMessageRaw(_0: string | BytesLike, _1: string): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* Sends a transaction after signing it.
|
|
137
|
+
*
|
|
138
|
+
* @param tx - The transaction to send, represented as a TransactionLike object.
|
|
139
|
+
* @returns A promise that resolves to the transaction hash as a Hex string.
|
|
140
|
+
*/
|
|
141
|
+
sendTransaction(tx: TransactionLike): Promise<Hex>;
|
|
142
|
+
/**
|
|
143
|
+
* Signs a transaction.
|
|
144
|
+
*
|
|
145
|
+
* @param tx - The transaction to sign, represented as a TransactionLike object.
|
|
146
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
147
|
+
*/
|
|
148
|
+
signTransaction(tx: TransactionLike): Promise<Transaction>;
|
|
149
|
+
/**
|
|
150
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
151
|
+
*
|
|
152
|
+
* @param _ - The transaction to prepare, represented as a TransactionLike object.
|
|
153
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
154
|
+
* @throws Will throw an error if not implemented.
|
|
155
|
+
*/
|
|
156
|
+
prepareTransaction(_: TransactionLike): Promise<Transaction>;
|
|
157
|
+
/**
|
|
158
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
159
|
+
*
|
|
160
|
+
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
161
|
+
* @returns A promise that resolves to the signed Transaction object.
|
|
162
|
+
* @throws Will throw an error if not implemented.
|
|
163
|
+
*/
|
|
164
|
+
signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
|
|
171
165
|
}
|
|
172
166
|
/**
|
|
173
167
|
* A class representing information about a signer, including its type and the signer instance.
|
|
174
168
|
*/
|
|
175
169
|
export declare class SignerInfo {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
name: string;
|
|
171
|
+
signer: Signer;
|
|
172
|
+
constructor(name: string, signer: Signer);
|
|
179
173
|
}
|
|
180
174
|
/**
|
|
181
175
|
* Represents a wallet with a name, icon, and an array of signer information.
|
|
182
176
|
*/
|
|
183
177
|
export type Wallet = {
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
name: string;
|
|
179
|
+
icon: string;
|
|
186
180
|
};
|
|
187
|
-
//# sourceMappingURL=index.d.ts.map
|
|
181
|
+
//# sourceMappingURL=index.d.ts.map
|