@ckb-ccc/core 0.0.8-alpha.3 → 0.0.8-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/script.js +2 -2
- package/dist/ckb/transaction.js +2 -2
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +1 -0
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +35 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +20 -0
- package/dist/hasher/index.d.ts +17 -2
- package/dist/hasher/index.d.ts.map +1 -1
- package/dist/hasher/index.js +19 -2
- package/dist/signer/nostr/signerNostr.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.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 +54 -113
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +182 -214
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +161 -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.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -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 +53 -38
- package/dist.commonjs/hasher/index.d.ts.map +1 -1
- package/dist.commonjs/hasher/index.js +69 -58
- 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 +3 -3
- package/src/ckb/script.ts +2 -2
- package/src/ckb/transaction.ts +2 -2
- package/src/client/client.ts +1 -0
- package/src/client/clientPublicMainnet.advanced.ts +40 -1
- package/src/client/clientPublicTestnet.advanced.ts +23 -0
- package/src/hasher/index.ts +27 -2
- package/src/signer/nostr/signerNostr.ts +2 -2
|
@@ -14,112 +14,77 @@ const signer_1 = require("../signer");
|
|
|
14
14
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
15
15
|
*/
|
|
16
16
|
class SignerEvm extends signer_1.Signer {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
get signType() {
|
|
21
|
-
return signer_1.SignerSignType.EvmPersonal;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Gets the internal address, which is the EVM account in this case.
|
|
25
|
-
*
|
|
26
|
-
* @returns A promise that resolves to a string representing the internal address.
|
|
27
|
-
*/
|
|
28
|
-
async getInternalAddress() {
|
|
29
|
-
return this.getEvmAccount();
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
33
|
-
*
|
|
34
|
-
* @returns A promise that resolves to an array of Address objects.
|
|
35
|
-
*/
|
|
36
|
-
async getAddressObjs() {
|
|
37
|
-
const account = await this.getEvmAccount();
|
|
38
|
-
return [
|
|
39
|
-
await this._getOmniLockEvmAddressObj(account),
|
|
40
|
-
await this._getOmniLockOldEvmAddressObj(account),
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
async _getOmniLockEvmAddressObj(account) {
|
|
44
|
-
return address_1.Address.fromKnownScript(
|
|
45
|
-
this.client,
|
|
46
|
-
client_1.KnownScript.OmniLock,
|
|
47
|
-
(0, hex_1.hexFrom)([0x12, ...(0, bytes_1.bytesFrom)(account), 0x00]),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
async _getOmniLockOldEvmAddressObj(account) {
|
|
51
|
-
return address_1.Address.fromKnownScript(
|
|
52
|
-
this.client,
|
|
53
|
-
client_1.KnownScript.OmniLock,
|
|
54
|
-
(0, hex_1.hexFrom)([0x1, ...(0, bytes_1.bytesFrom)(account), 0x00]),
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
59
|
-
*
|
|
60
|
-
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
61
|
-
* @returns A promise that resolves to the prepared Transaction object.
|
|
62
|
-
*/
|
|
63
|
-
async prepareTransaction(txLike) {
|
|
64
|
-
const tx = ckb_1.Transaction.from(txLike);
|
|
65
|
-
await tx.addCellDepsOfKnownScripts(
|
|
66
|
-
this.client,
|
|
67
|
-
client_1.KnownScript.OmniLock,
|
|
68
|
-
);
|
|
69
|
-
return (0, utils_1.reduceAsync)(
|
|
70
|
-
await this.getAddressObjs(),
|
|
71
|
-
(tx, { script }) => tx.prepareSighashAllWitness(script, 85, this.client),
|
|
72
|
-
tx,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Signs a transaction without modifying it.
|
|
77
|
-
*
|
|
78
|
-
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
79
|
-
* @returns A promise that resolves to a signed Transaction object.
|
|
80
|
-
*/
|
|
81
|
-
async signOnlyTransaction(txLike) {
|
|
82
|
-
let tx = ckb_1.Transaction.from(txLike);
|
|
83
|
-
const account = await this.getEvmAccount();
|
|
84
|
-
const { script: evmScript } = await this._getOmniLockEvmAddressObj(account);
|
|
85
|
-
const { script: oldEvmScript } =
|
|
86
|
-
await this._getOmniLockOldEvmAddressObj(account);
|
|
87
|
-
tx = await this._signOmniLockScriptForTransaction(
|
|
88
|
-
tx,
|
|
89
|
-
evmScript,
|
|
90
|
-
(hash) => `CKB transaction: ${hash}`,
|
|
91
|
-
);
|
|
92
|
-
tx = await this._signOmniLockScriptForTransaction(
|
|
93
|
-
tx,
|
|
94
|
-
oldEvmScript,
|
|
95
|
-
(hash) => (0, bytes_1.bytesFrom)(hash),
|
|
96
|
-
);
|
|
97
|
-
return tx;
|
|
98
|
-
}
|
|
99
|
-
async _signOmniLockScriptForTransaction(tx, script, messageTransformer) {
|
|
100
|
-
const info = await tx.getSignHashInfo(script, this.client);
|
|
101
|
-
if (!info) {
|
|
102
|
-
return tx;
|
|
17
|
+
get type() {
|
|
18
|
+
return signer_1.SignerType.EVM;
|
|
103
19
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
20
|
+
get signType() {
|
|
21
|
+
return signer_1.SignerSignType.EvmPersonal;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the internal address, which is the EVM account in this case.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
27
|
+
*/
|
|
28
|
+
async getInternalAddress() {
|
|
29
|
+
return this.getEvmAccount();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
35
|
+
*/
|
|
36
|
+
async getAddressObjs() {
|
|
37
|
+
const account = await this.getEvmAccount();
|
|
38
|
+
return [
|
|
39
|
+
await this._getOmniLockEvmAddressObj(account),
|
|
40
|
+
await this._getOmniLockOldEvmAddressObj(account),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
async _getOmniLockEvmAddressObj(account) {
|
|
44
|
+
return address_1.Address.fromKnownScript(this.client, client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x12, ...(0, bytes_1.bytesFrom)(account), 0x00]));
|
|
45
|
+
}
|
|
46
|
+
async _getOmniLockOldEvmAddressObj(account) {
|
|
47
|
+
return address_1.Address.fromKnownScript(this.client, client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x1, ...(0, bytes_1.bytesFrom)(account), 0x00]));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
51
|
+
*
|
|
52
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
53
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
54
|
+
*/
|
|
55
|
+
async prepareTransaction(txLike) {
|
|
56
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
57
|
+
await tx.addCellDepsOfKnownScripts(this.client, client_1.KnownScript.OmniLock);
|
|
58
|
+
return (0, utils_1.reduceAsync)(await this.getAddressObjs(), (tx, { script }) => tx.prepareSighashAllWitness(script, 85, this.client), 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 account = await this.getEvmAccount();
|
|
69
|
+
const { script: evmScript } = await this._getOmniLockEvmAddressObj(account);
|
|
70
|
+
const { script: oldEvmScript } = await this._getOmniLockOldEvmAddressObj(account);
|
|
71
|
+
tx = await this._signOmniLockScriptForTransaction(tx, evmScript, (hash) => `CKB transaction: ${hash}`);
|
|
72
|
+
tx = await this._signOmniLockScriptForTransaction(tx, oldEvmScript, (hash) => (0, bytes_1.bytesFrom)(hash));
|
|
73
|
+
return tx;
|
|
74
|
+
}
|
|
75
|
+
async _signOmniLockScriptForTransaction(tx, script, messageTransformer) {
|
|
76
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
77
|
+
if (!info) {
|
|
78
|
+
return tx;
|
|
79
|
+
}
|
|
80
|
+
const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(messageTransformer(info.message)));
|
|
81
|
+
if (signature[signature.length - 1] >= 27) {
|
|
82
|
+
signature[signature.length - 1] -= 27;
|
|
83
|
+
}
|
|
84
|
+
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
85
|
+
witness.lock = (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)((0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(4 * 4, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(signature.length, 4), signature));
|
|
86
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
87
|
+
return tx;
|
|
109
88
|
}
|
|
110
|
-
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
111
|
-
witness.lock = (0, hex_1.hexFrom)(
|
|
112
|
-
(0, bytes_1.bytesConcat)(
|
|
113
|
-
(0, num_1.numToBytes)(5 * 4 + signature.length, 4),
|
|
114
|
-
(0, num_1.numToBytes)(4 * 4, 4),
|
|
115
|
-
(0, num_1.numToBytes)(5 * 4 + signature.length, 4),
|
|
116
|
-
(0, num_1.numToBytes)(5 * 4 + signature.length, 4),
|
|
117
|
-
(0, num_1.numToBytes)(signature.length, 4),
|
|
118
|
-
signature,
|
|
119
|
-
),
|
|
120
|
-
);
|
|
121
|
-
tx.setWitnessArgsAt(info.position, witness);
|
|
122
|
-
return tx;
|
|
123
|
-
}
|
|
124
89
|
}
|
|
125
90
|
exports.SignerEvm = SignerEvm;
|
|
@@ -6,41 +6,41 @@ import { SignerEvm } from "./signerEvm";
|
|
|
6
6
|
* This class does not support signing operations.
|
|
7
7
|
*/
|
|
8
8
|
export declare class SignerEvmAddressReadonly extends SignerEvm {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
9
|
+
private readonly address;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of SignerEvmAddressReadonly.
|
|
12
|
+
*
|
|
13
|
+
* @param client - The client instance used for communication.
|
|
14
|
+
* @param address - The EVM address associated with the signer.
|
|
15
|
+
*/
|
|
16
|
+
constructor(client: Client, address: HexLike);
|
|
17
|
+
/**
|
|
18
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
19
|
+
*
|
|
20
|
+
* @returns A promise that resolves when the connection is complete.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* await signer.connect();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
connect(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the signer is connected.
|
|
30
|
+
*
|
|
31
|
+
* @returns A promise that resolves the connection status.
|
|
32
|
+
*/
|
|
33
|
+
isConnected(): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the EVM account associated with the signer.
|
|
36
|
+
*
|
|
37
|
+
* @returns A promise that resolves to a string representing the EVM account.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const account = await signer.getEvmAccount(); // Outputs the EVM account
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
getEvmAccount(): Promise<string>;
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=signerEvmAddressReadonly.d.ts.map
|
|
46
|
+
//# sourceMappingURL=signerEvmAddressReadonly.d.ts.map
|
|
@@ -8,47 +8,47 @@ const signerEvm_1 = require("./signerEvm");
|
|
|
8
8
|
* This class does not support signing operations.
|
|
9
9
|
*/
|
|
10
10
|
class SignerEvmAddressReadonly extends signerEvm_1.SignerEvm {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of SignerEvmAddressReadonly.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The client instance used for communication.
|
|
15
|
+
* @param address - The EVM address associated with the signer.
|
|
16
|
+
*/
|
|
17
|
+
constructor(client, address) {
|
|
18
|
+
super(client);
|
|
19
|
+
this.address = (0, hex_1.hexFrom)(address);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
23
|
+
*
|
|
24
|
+
* @returns A promise that resolves when the connection is complete.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* await signer.connect();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
async connect() { }
|
|
32
|
+
/**
|
|
33
|
+
* Check if the signer is connected.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves the connection status.
|
|
36
|
+
*/
|
|
37
|
+
async isConnected() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the EVM account associated with the signer.
|
|
42
|
+
*
|
|
43
|
+
* @returns A promise that resolves to a string representing the EVM account.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const account = await signer.getEvmAccount(); // Outputs the EVM account
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
async getEvmAccount() {
|
|
51
|
+
return this.address;
|
|
52
|
+
}
|
|
53
53
|
}
|
|
54
54
|
exports.SignerEvmAddressReadonly = SignerEvmAddressReadonly;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { BytesLike } from "../../bytes";
|
|
2
|
-
export declare function verifyMessageEvmPersonal(
|
|
3
|
-
|
|
4
|
-
signature: string,
|
|
5
|
-
address: string,
|
|
6
|
-
): boolean;
|
|
7
|
-
//# sourceMappingURL=verify.d.ts.map
|
|
2
|
+
export declare function verifyMessageEvmPersonal(message: string | BytesLike, signature: string, address: string): boolean;
|
|
3
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -4,12 +4,7 @@ exports.verifyMessageEvmPersonal = void 0;
|
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const bytes_1 = require("../../bytes");
|
|
6
6
|
function verifyMessageEvmPersonal(message, signature, address) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(0, ethers_1.verifyMessage)(
|
|
10
|
-
typeof message === "string" ? message : (0, bytes_1.bytesFrom)(message),
|
|
11
|
-
signature,
|
|
12
|
-
).toLowerCase()
|
|
13
|
-
);
|
|
7
|
+
return (address.toLowerCase() ===
|
|
8
|
+
(0, ethers_1.verifyMessage)(typeof message === "string" ? message : (0, bytes_1.bytesFrom)(message), signature).toLowerCase());
|
|
14
9
|
}
|
|
15
10
|
exports.verifyMessageEvmPersonal = verifyMessageEvmPersonal;
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./btc"), exports);
|
|
34
18
|
__exportStar(require("./ckb"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./signerNostr";
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./signerNostr"), exports);
|
|
@@ -4,63 +4,63 @@ import { Transaction, TransactionLike } from "../../ckb";
|
|
|
4
4
|
import { Hex } from "../../hex";
|
|
5
5
|
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
6
6
|
export interface NostrEvent {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
id?: string;
|
|
8
|
+
pubkey?: string;
|
|
9
|
+
sig?: string;
|
|
10
|
+
created_at: number;
|
|
11
|
+
kind: number;
|
|
12
|
+
tags: string[][];
|
|
13
|
+
content: string;
|
|
14
14
|
}
|
|
15
15
|
export declare abstract class SignerNostr extends Signer {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
16
|
+
static CKB_SIG_HASH_ALL_TAG: string;
|
|
17
|
+
static CKB_UNLOCK_EVENT_KIND: number;
|
|
18
|
+
static CKB_UNLOCK_EVENT_CONTENT: string;
|
|
19
|
+
get type(): SignerType;
|
|
20
|
+
get signType(): SignerSignType;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the Nostr public key associated with the signer.
|
|
23
|
+
*
|
|
24
|
+
* @returns A promise that resolves to a string representing the Nostr public key.
|
|
25
|
+
*/
|
|
26
|
+
abstract getNostrPublicKey(): Promise<Hex>;
|
|
27
|
+
/**
|
|
28
|
+
* Sign a nostr event.
|
|
29
|
+
*
|
|
30
|
+
* @returns A promise that resolves to the signed event.
|
|
31
|
+
*/
|
|
32
|
+
abstract signNostrEvent(event: NostrEvent): Promise<Required<NostrEvent>>;
|
|
33
|
+
/**
|
|
34
|
+
* Sign a message.
|
|
35
|
+
*
|
|
36
|
+
* @returns A promise that resolves to the signature.
|
|
37
|
+
*/
|
|
38
|
+
signMessageRaw(message: string | BytesLike): Promise<Hex>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the internal address, which is the EVM account in this case.
|
|
41
|
+
*
|
|
42
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
43
|
+
*/
|
|
44
|
+
getInternalAddress(): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
47
|
+
*
|
|
48
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
49
|
+
*/
|
|
50
|
+
getAddressObjs(): Promise<Address[]>;
|
|
51
|
+
/**
|
|
52
|
+
* prepare a transaction before signing.
|
|
53
|
+
*
|
|
54
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
55
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
56
|
+
*/
|
|
57
|
+
prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
58
|
+
/**
|
|
59
|
+
* Signs a transaction without modifying it.
|
|
60
|
+
*
|
|
61
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
62
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
63
|
+
*/
|
|
64
|
+
signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
65
65
|
}
|
|
66
|
-
//# sourceMappingURL=signerNostr.d.ts.map
|
|
66
|
+
//# sourceMappingURL=signerNostr.d.ts.map
|