@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-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/address/index.d.ts +1 -1
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +4 -4
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.d.ts +1 -1
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.d.ts +1 -1
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/jsonRpc/index.d.ts +3 -3
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +4 -4
- package/dist/signer/btc/index.d.ts +1 -0
- package/dist/signer/btc/index.d.ts.map +1 -1
- package/dist/signer/btc/index.js +1 -0
- package/dist/signer/btc/signerBtc.d.ts +9 -1
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +16 -2
- package/dist/signer/btc/verify.d.ts +3 -0
- package/dist/signer/btc/verify.d.ts.map +1 -0
- package/dist/signer/btc/verify.js +6 -0
- package/dist/signer/ckb/index.d.ts +1 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +1 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -2
- package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist/signer/ckb/verifyJoyId.js +12 -0
- package/dist/signer/evm/index.d.ts +1 -0
- package/dist/signer/evm/index.d.ts.map +1 -1
- package/dist/signer/evm/index.js +1 -0
- package/dist/signer/evm/signerEvm.d.ts +3 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +8 -2
- package/dist/signer/evm/verify.d.ts +3 -0
- package/dist/signer/evm/verify.d.ts.map +1 -0
- package/dist/signer/evm/verify.js +6 -0
- package/dist/signer/signer.d.ts +60 -14
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +95 -16
- package/dist.commonjs/address/index.d.ts +1 -1
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +4 -4
- package/dist.commonjs/client/client.d.ts +2 -2
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts +1 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +1 -1
- package/dist.commonjs/client/clientPublicTestnet.d.ts +1 -1
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +1 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts +3 -3
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +4 -4
- package/dist.commonjs/signer/btc/index.d.ts +1 -0
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/index.js +1 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts +9 -1
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +15 -1
- package/dist.commonjs/signer/btc/verify.d.ts +3 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/verify.js +10 -0
- package/dist.commonjs/signer/ckb/index.d.ts +1 -0
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +1 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +7 -1
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.js +16 -0
- package/dist.commonjs/signer/evm/index.d.ts +1 -0
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/index.js +1 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts +3 -1
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +7 -1
- package/dist.commonjs/signer/evm/verify.d.ts +3 -0
- package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/verify.js +10 -0
- package/dist.commonjs/signer/signer.d.ts +60 -14
- package/dist.commonjs/signer/signer.d.ts.map +1 -1
- package/dist.commonjs/signer/signer.js +97 -17
- package/package.json +6 -3
- package/src/address/index.ts +4 -7
- package/src/client/client.ts +2 -2
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/jsonRpc/index.ts +3 -3
- package/src/signer/btc/index.ts +1 -0
- package/src/signer/btc/signerBtc.ts +19 -2
- package/src/signer/btc/verify.ts +14 -0
- package/src/signer/ckb/index.ts +1 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -2
- package/src/signer/ckb/verifyJoyId.ts +20 -0
- package/src/signer/evm/index.ts +1 -0
- package/src/signer/evm/signerEvm.ts +10 -2
- package/src/signer/evm/verify.ts +16 -0
- package/src/signer/signer.ts +125 -15
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
package/dist/signer/signer.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { verifyMessageBtcEcdsa } from "./btc";
|
|
2
|
+
import { verifyMessageJoyId } from "./ckb/verifyJoyId";
|
|
3
|
+
import { verifyMessageEvmPersonal } from "./evm/verify";
|
|
4
|
+
export var SignerSignType;
|
|
5
|
+
(function (SignerSignType) {
|
|
6
|
+
SignerSignType["Unknown"] = "Unknown";
|
|
7
|
+
SignerSignType["BtcEcdsa"] = "BtcEcdsa";
|
|
8
|
+
SignerSignType["EvmPersonal"] = "EvmPersonal";
|
|
9
|
+
SignerSignType["JoyId"] = "JoyId";
|
|
10
|
+
})(SignerSignType || (SignerSignType = {}));
|
|
11
|
+
/**
|
|
12
|
+
* An enumeration of signer display types in wallet.
|
|
13
|
+
*/
|
|
14
|
+
export var SignerType;
|
|
15
|
+
(function (SignerType) {
|
|
16
|
+
SignerType["EVM"] = "EVM";
|
|
17
|
+
SignerType["BTC"] = "BTC";
|
|
18
|
+
SignerType["CKB"] = "CKB";
|
|
19
|
+
})(SignerType || (SignerType = {}));
|
|
20
|
+
export class Signature {
|
|
21
|
+
constructor(signature, identity, signType) {
|
|
22
|
+
this.signature = signature;
|
|
23
|
+
this.identity = identity;
|
|
24
|
+
this.signType = signType;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
1
27
|
/**
|
|
2
28
|
* An abstract class representing a generic signer.
|
|
3
29
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -9,12 +35,32 @@ export class Signer {
|
|
|
9
35
|
get client() {
|
|
10
36
|
return this.client_;
|
|
11
37
|
}
|
|
38
|
+
static async verifyMessage(message, signature) {
|
|
39
|
+
switch (signature.signType) {
|
|
40
|
+
case SignerSignType.EvmPersonal:
|
|
41
|
+
return verifyMessageEvmPersonal(message, signature.signature, signature.identity);
|
|
42
|
+
case SignerSignType.BtcEcdsa:
|
|
43
|
+
return verifyMessageBtcEcdsa(message, signature.signature, signature.identity);
|
|
44
|
+
case SignerSignType.JoyId:
|
|
45
|
+
return verifyMessageJoyId(message, signature.signature, signature.identity);
|
|
46
|
+
case SignerSignType.Unknown:
|
|
47
|
+
throw new Error("Unknown signer sign type");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
12
50
|
/**
|
|
13
51
|
* Disconnects to the signer.
|
|
14
52
|
*
|
|
15
53
|
* @returns A promise that resolves when disconnected.
|
|
16
54
|
*/
|
|
17
55
|
async disconnect() { }
|
|
56
|
+
/**
|
|
57
|
+
* Gets the identity for verifying signature, usually it's address
|
|
58
|
+
*
|
|
59
|
+
* @returns A promise that resolves to a string representing the identity
|
|
60
|
+
*/
|
|
61
|
+
async getIdentity() {
|
|
62
|
+
return this.getInternalAddress();
|
|
63
|
+
}
|
|
18
64
|
/**
|
|
19
65
|
* Gets the recommended Address object for the signer.
|
|
20
66
|
*
|
|
@@ -50,14 +96,57 @@ export class Signer {
|
|
|
50
96
|
return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
|
|
51
97
|
}
|
|
52
98
|
/**
|
|
53
|
-
* Signs a message.
|
|
99
|
+
* Signs a message.
|
|
54
100
|
*
|
|
55
101
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
56
|
-
* @returns A promise that resolves to the
|
|
102
|
+
* @returns A promise that resolves to the signature info.
|
|
57
103
|
* @throws Will throw an error if not implemented.
|
|
58
104
|
*/
|
|
59
|
-
signMessage(
|
|
60
|
-
|
|
105
|
+
async signMessage(message) {
|
|
106
|
+
return {
|
|
107
|
+
signature: await this.signMessageRaw(message),
|
|
108
|
+
identity: await this.getIdentity(),
|
|
109
|
+
signType: this.signType,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
114
|
+
*
|
|
115
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
116
|
+
* @returns A promise that resolves to the signature as a string.
|
|
117
|
+
* @throws Will throw an error if not implemented.
|
|
118
|
+
*/
|
|
119
|
+
signMessageRaw(_) {
|
|
120
|
+
throw Error("Signer.signMessageRaw not implemented");
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Verify a signature.
|
|
124
|
+
*
|
|
125
|
+
* @param _ - The original message.
|
|
126
|
+
* @param _ - The signature to verify.
|
|
127
|
+
* @returns A promise that resolves to the verification result.
|
|
128
|
+
* @throws Will throw an error if not implemented.
|
|
129
|
+
*/
|
|
130
|
+
async verifyMessage(message, signature) {
|
|
131
|
+
if (typeof signature === "string") {
|
|
132
|
+
return this.verifyMessageRaw(message, signature);
|
|
133
|
+
}
|
|
134
|
+
if (signature.identity !== (await this.getIdentity()) ||
|
|
135
|
+
![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return this.verifyMessageRaw(message, signature.signature);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
142
|
+
*
|
|
143
|
+
* @param _0 - The original message.
|
|
144
|
+
* @param _1 - The signature to verify.
|
|
145
|
+
* @returns A promise that resolves to the verification result.
|
|
146
|
+
* @throws Will throw an error if not implemented.
|
|
147
|
+
*/
|
|
148
|
+
verifyMessageRaw(_0, _1) {
|
|
149
|
+
throw Error("Signer.verifyMessageRaw not implemented");
|
|
61
150
|
}
|
|
62
151
|
/**
|
|
63
152
|
* Sends a transaction after signing it.
|
|
@@ -89,7 +178,7 @@ export class Signer {
|
|
|
89
178
|
throw Error("Signer.prepareTransaction not implemented");
|
|
90
179
|
}
|
|
91
180
|
/**
|
|
92
|
-
* Signs a transaction without
|
|
181
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
93
182
|
*
|
|
94
183
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
95
184
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -99,22 +188,12 @@ export class Signer {
|
|
|
99
188
|
throw Error("Signer.signOnlyTransaction not implemented");
|
|
100
189
|
}
|
|
101
190
|
}
|
|
102
|
-
/**
|
|
103
|
-
* An enumeration of signer types.
|
|
104
|
-
*/
|
|
105
|
-
export var SignerType;
|
|
106
|
-
(function (SignerType) {
|
|
107
|
-
SignerType["EVM"] = "EVM";
|
|
108
|
-
SignerType["BTC"] = "BTC";
|
|
109
|
-
SignerType["CKB"] = "CKB";
|
|
110
|
-
})(SignerType || (SignerType = {}));
|
|
111
191
|
/**
|
|
112
192
|
* A class representing information about a signer, including its type and the signer instance.
|
|
113
193
|
*/
|
|
114
194
|
export class SignerInfo {
|
|
115
|
-
constructor(name,
|
|
195
|
+
constructor(name, signer) {
|
|
116
196
|
this.name = name;
|
|
117
|
-
this.type = type;
|
|
118
197
|
this.signer = signer;
|
|
119
198
|
}
|
|
120
199
|
}
|
|
@@ -42,7 +42,7 @@ export declare class Address {
|
|
|
42
42
|
* @param client - The client instance used to fetch the address prefix.
|
|
43
43
|
* @returns A promise that resolves to an Address instance.
|
|
44
44
|
*/
|
|
45
|
-
static fromScript(script: ScriptLike, client: Client):
|
|
45
|
+
static fromScript(script: ScriptLike, client: Client): Address;
|
|
46
46
|
static fromKnownScript(script: KnownScript, args: HexLike, client: Client): Promise<Address>;
|
|
47
47
|
/**
|
|
48
48
|
* Converts the Address instance to a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAQjC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,qBAAa,OAAO;IAQT,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IARvB;;;;;OAKG;gBAEM,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGvB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAQ1C;;;;;;;;OAQG;WAEU,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;;OAMG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAQjC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,qBAAa,OAAO;IAQT,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IARvB;;;;;OAKG;gBAEM,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGvB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAQ1C;;;;;;;;OAQG;WAEU,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;;OAMG;IAEH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;WAIjD,eAAe,CAC1B,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM;IAWhB;;;;OAIG;IAEH,QAAQ,IAAI,MAAM;CAcnB"}
|
|
@@ -46,7 +46,7 @@ class Address {
|
|
|
46
46
|
if (!client) {
|
|
47
47
|
throw new Error(`Unknown address prefix ${prefix}`);
|
|
48
48
|
}
|
|
49
|
-
const expectedPrefix =
|
|
49
|
+
const expectedPrefix = client.addressPrefix;
|
|
50
50
|
if (expectedPrefix !== prefix) {
|
|
51
51
|
throw new Error(`Unknown address prefix ${prefix}, expected ${expectedPrefix}`);
|
|
52
52
|
}
|
|
@@ -59,8 +59,8 @@ class Address {
|
|
|
59
59
|
* @param client - The client instance used to fetch the address prefix.
|
|
60
60
|
* @returns A promise that resolves to an Address instance.
|
|
61
61
|
*/
|
|
62
|
-
static
|
|
63
|
-
return Address.from({ script, prefix:
|
|
62
|
+
static fromScript(script, client) {
|
|
63
|
+
return Address.from({ script, prefix: client.addressPrefix });
|
|
64
64
|
}
|
|
65
65
|
static async fromKnownScript(script, args, client) {
|
|
66
66
|
return Address.from({
|
|
@@ -68,7 +68,7 @@ class Address {
|
|
|
68
68
|
...(await client.getKnownScript(script)),
|
|
69
69
|
args,
|
|
70
70
|
},
|
|
71
|
-
prefix:
|
|
71
|
+
prefix: client.addressPrefix,
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -11,8 +11,8 @@ export declare enum KnownScript {
|
|
|
11
11
|
OmniLock = 5
|
|
12
12
|
}
|
|
13
13
|
export declare abstract class Client {
|
|
14
|
-
abstract
|
|
15
|
-
abstract
|
|
14
|
+
abstract get url(): string;
|
|
15
|
+
abstract get addressPrefix(): string;
|
|
16
16
|
abstract getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
17
17
|
abstract sendTransaction(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
|
|
18
18
|
abstract getTransaction(txHash: HexLike): Promise<ClientTransactionResponse | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,KAAK,GAAG,IAAI,MAAM,CAAC;IAC3B,QAAQ,KAAK,aAAa,IAAI,MAAM,CAAC;IAErC,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAEtC,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB3D,QAAQ,CAAC,cAAc,CACrB,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,CAAC,EAAE,OAAO,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC;IAE5B,SAAS,CACd,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,SAAK,GACT,cAAc,CAAC,IAAI,CAAC;IAoBvB,sBAAsB,CACpB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,QAAQ,UAAO,GACd,cAAc,CAAC,IAAI,CAAC;IAYvB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,EAAE,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAElE,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAYhD,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAOpD"}
|
|
@@ -3,7 +3,7 @@ import { KnownScript } from "./client";
|
|
|
3
3
|
import { ClientJsonRpc } from "./jsonRpc";
|
|
4
4
|
export declare class ClientPublicMainnet extends ClientJsonRpc {
|
|
5
5
|
constructor(url?: string, timeout?: number);
|
|
6
|
-
|
|
6
|
+
get addressPrefix(): string;
|
|
7
7
|
getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=clientPublicMainnet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
|
|
@@ -3,7 +3,7 @@ import { KnownScript } from "./client";
|
|
|
3
3
|
import { ClientJsonRpc } from "./jsonRpc";
|
|
4
4
|
export declare class ClientPublicTestnet extends ClientJsonRpc {
|
|
5
5
|
constructor(url?: string, timeout?: number);
|
|
6
|
-
|
|
6
|
+
get addressPrefix(): string;
|
|
7
7
|
getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=clientPublicTestnet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
|
|
@@ -9,7 +9,7 @@ import { JsonRpcPayload } from "./advanced";
|
|
|
9
9
|
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class ClientJsonRpc extends Client {
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly url_;
|
|
13
13
|
private readonly timeout;
|
|
14
14
|
/**
|
|
15
15
|
* Creates an instance of ClientJsonRpc.
|
|
@@ -17,13 +17,13 @@ export declare abstract class ClientJsonRpc extends Client {
|
|
|
17
17
|
* @param url - The URL of the JSON-RPC server.
|
|
18
18
|
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
19
19
|
*/
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(url_: string, timeout?: number);
|
|
21
21
|
/**
|
|
22
22
|
* Returns the URL of the JSON-RPC server.
|
|
23
23
|
*
|
|
24
24
|
* @returns The URL of the JSON-RPC server.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
get url(): string;
|
|
27
27
|
/**
|
|
28
28
|
* Send a transaction to node.
|
|
29
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AA0BjE;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;IAS9C,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AA0BjE;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;IAS9C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B;;;;;OAKG;gBAGgB,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ;IAKlC;;;;OAIG;IAEH,IAAI,GAAG,WAEN;IAED;;;;;;OAMG;IAEH,eAAe,gBAKA,eAAe,cAChB,gBAAgB,GAAG,SAAS,KACrC,QAAQ,GAAG,CAAC,CAAC;IAElB;;;;;OAKG;IAEH,cAAc,WAIA,OAAO,KAAK,QAAQ,yBAAyB,CAAC,CAAC;IAE7D;;;;;;;;OAQG;IAEH,cAAc,QASP,0BAA0B,UACvB,KAAK,GAAG,MAAM,UACd,OAAO,UACP,MAAM,KACX,QAAQ,uBAAuB,CAAC,CAAC;IAEtC;;;;;OAKG;IAEH,gBAAgB,QAIL,0BAA0B,KAAK,QAAQ,GAAG,CAAC,CAAC;IAEvD;;;;;;;OAOG;IAEH,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,YAEd,OAAO,EAAE;IAkBjC;;;;;;;OAOG;IAEG,IAAI,CAAC,OAAO,EAAE,cAAc;IA4BlC;;;;;;OAMG;IAEH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
|
|
@@ -39,9 +39,9 @@ class ClientJsonRpc extends client_1.Client {
|
|
|
39
39
|
* @param url - The URL of the JSON-RPC server.
|
|
40
40
|
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
41
41
|
*/
|
|
42
|
-
constructor(
|
|
42
|
+
constructor(url_, timeout = 30000) {
|
|
43
43
|
super();
|
|
44
|
-
this.
|
|
44
|
+
this.url_ = url_;
|
|
45
45
|
this.timeout = timeout;
|
|
46
46
|
/**
|
|
47
47
|
* Send a transaction to node.
|
|
@@ -85,8 +85,8 @@ class ClientJsonRpc extends client_1.Client {
|
|
|
85
85
|
*
|
|
86
86
|
* @returns The URL of the JSON-RPC server.
|
|
87
87
|
*/
|
|
88
|
-
|
|
89
|
-
return this.
|
|
88
|
+
get url() {
|
|
89
|
+
return this.url_;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Builds a sender function for a JSON-RPC method.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC"}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./signerBtc"), exports);
|
|
18
18
|
__exportStar(require("./signerBtcPublicKeyReadonly"), exports);
|
|
19
|
+
__exportStar(require("./verify"), exports);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { Transaction, TransactionLike } from "../../ckb";
|
|
3
3
|
import { HexLike } from "../../hex";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* An abstract class extending the Signer class for Bitcoin-like signing operations.
|
|
7
7
|
* This class provides methods to get Bitcoin account, public key, and internal address,
|
|
8
8
|
* as well as signing transactions.
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class SignerBtc extends Signer {
|
|
11
|
+
get type(): SignerType;
|
|
12
|
+
get signType(): SignerSignType;
|
|
11
13
|
/**
|
|
12
14
|
* Gets the Bitcoin account associated with the signer.
|
|
13
15
|
*
|
|
@@ -26,6 +28,12 @@ export declare abstract class SignerBtc extends Signer {
|
|
|
26
28
|
* @returns A promise that resolves to a string representing the internal address.
|
|
27
29
|
*/
|
|
28
30
|
getInternalAddress(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the identity, which is the Bitcoin public key in this case.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves to a string representing the identity
|
|
35
|
+
*/
|
|
36
|
+
getIdentity(): Promise<string>;
|
|
29
37
|
/**
|
|
30
38
|
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
31
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
|
|
@@ -16,6 +16,12 @@ const signer_1 = require("../signer");
|
|
|
16
16
|
* as well as signing transactions.
|
|
17
17
|
*/
|
|
18
18
|
class SignerBtc extends signer_1.Signer {
|
|
19
|
+
get type() {
|
|
20
|
+
return signer_1.SignerType.BTC;
|
|
21
|
+
}
|
|
22
|
+
get signType() {
|
|
23
|
+
return signer_1.SignerSignType.BtcEcdsa;
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
* Gets the internal address, which is the Bitcoin account in this case.
|
|
21
27
|
*
|
|
@@ -24,6 +30,14 @@ class SignerBtc extends signer_1.Signer {
|
|
|
24
30
|
async getInternalAddress() {
|
|
25
31
|
return this.getBtcAccount();
|
|
26
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the identity, which is the Bitcoin public key in this case.
|
|
35
|
+
*
|
|
36
|
+
* @returns A promise that resolves to a string representing the identity
|
|
37
|
+
*/
|
|
38
|
+
async getIdentity() {
|
|
39
|
+
return (0, hex_1.hexFrom)(await this.getBtcPublicKey()).slice(2);
|
|
40
|
+
}
|
|
27
41
|
/**
|
|
28
42
|
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
29
43
|
*
|
|
@@ -59,7 +73,7 @@ class SignerBtc extends signer_1.Signer {
|
|
|
59
73
|
if (!info) {
|
|
60
74
|
return tx;
|
|
61
75
|
}
|
|
62
|
-
const signature = (0, bytes_1.bytesFrom)(await this.
|
|
76
|
+
const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
|
|
63
77
|
signature[0] = 31 + ((signature[0] - 27) % 4);
|
|
64
78
|
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
65
79
|
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));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAKT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageBtcEcdsa = void 0;
|
|
4
|
+
const wallet_utils_1 = require("@unisat/wallet-utils");
|
|
5
|
+
const hex_1 = require("../../hex");
|
|
6
|
+
function verifyMessageBtcEcdsa(message, signature, publicKey) {
|
|
7
|
+
const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
|
|
8
|
+
return (0, wallet_utils_1.verifyMessage)(publicKey, challenge, signature);
|
|
9
|
+
}
|
|
10
|
+
exports.verifyMessageBtcEcdsa = verifyMessageBtcEcdsa;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { ScriptLike } from "../../ckb";
|
|
3
3
|
import { Client } from "../../client";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* A class extending Signer that provides read-only access to a CKB script.
|
|
7
7
|
* This class does not support signing operations.
|
|
8
8
|
*/
|
|
9
9
|
export declare class SignerCkbScriptReadonly extends Signer {
|
|
10
|
+
get type(): SignerType;
|
|
11
|
+
get signType(): SignerSignType;
|
|
10
12
|
private readonly script;
|
|
11
13
|
/**
|
|
12
14
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIrE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -9,6 +9,12 @@ const signer_1 = require("../signer");
|
|
|
9
9
|
* This class does not support signing operations.
|
|
10
10
|
*/
|
|
11
11
|
class SignerCkbScriptReadonly extends signer_1.Signer {
|
|
12
|
+
get type() {
|
|
13
|
+
return signer_1.SignerType.CKB;
|
|
14
|
+
}
|
|
15
|
+
get signType() {
|
|
16
|
+
return signer_1.SignerSignType.Unknown;
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
14
20
|
*
|
|
@@ -65,7 +71,7 @@ class SignerCkbScriptReadonly extends signer_1.Signer {
|
|
|
65
71
|
* ```
|
|
66
72
|
*/
|
|
67
73
|
async getAddressObjs() {
|
|
68
|
-
return [
|
|
74
|
+
return [address_1.Address.fromScript(this.script, this.client)];
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
exports.SignerCkbScriptReadonly = SignerCkbScriptReadonly;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyJoyId.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/verifyJoyId.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageJoyId = void 0;
|
|
4
|
+
const ckb_1 = require("@joyid/ckb");
|
|
5
|
+
const hex_1 = require("../../hex");
|
|
6
|
+
function verifyMessageJoyId(message, signature, identity) {
|
|
7
|
+
const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
|
|
8
|
+
const { publicKey, keyType } = JSON.parse(identity);
|
|
9
|
+
return (0, ckb_1.verifySignature)({
|
|
10
|
+
challenge,
|
|
11
|
+
pubkey: publicKey,
|
|
12
|
+
keyType,
|
|
13
|
+
...JSON.parse(signature),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.verifyMessageJoyId = verifyMessageJoyId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC"}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./signerEvm"), exports);
|
|
18
18
|
__exportStar(require("./signerEvmAddressReadonly"), exports);
|
|
19
|
+
__exportStar(require("./verify"), exports);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { BytesLike } from "../../bytes";
|
|
3
3
|
import { Script, Transaction, TransactionLike } from "../../ckb";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
7
7
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class SignerEvm extends Signer {
|
|
10
|
+
get type(): SignerType;
|
|
11
|
+
get signType(): SignerSignType;
|
|
10
12
|
/**
|
|
11
13
|
* Gets the EVM account associated with the signer.
|
|
12
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAQpC,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5D,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAYvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAsBlE,iCAAiC,CACrC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;CA6BxB"}
|
|
@@ -13,6 +13,12 @@ const signer_1 = require("../signer");
|
|
|
13
13
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
14
14
|
*/
|
|
15
15
|
class SignerEvm extends signer_1.Signer {
|
|
16
|
+
get type() {
|
|
17
|
+
return signer_1.SignerType.EVM;
|
|
18
|
+
}
|
|
19
|
+
get signType() {
|
|
20
|
+
return signer_1.SignerSignType.EvmPersonal;
|
|
21
|
+
}
|
|
16
22
|
/**
|
|
17
23
|
* Gets the internal address, which is the EVM account in this case.
|
|
18
24
|
*
|
|
@@ -69,7 +75,7 @@ class SignerEvm extends signer_1.Signer {
|
|
|
69
75
|
if (!info) {
|
|
70
76
|
return tx;
|
|
71
77
|
}
|
|
72
|
-
const signature = (0, bytes_1.bytesFrom)(await this.
|
|
78
|
+
const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(messageTransformer(info.message)));
|
|
73
79
|
if (signature[signature.length - 1] >= 27) {
|
|
74
80
|
signature[signature.length - 1] -= 27;
|
|
75
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAEnD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAQT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageEvmPersonal = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const bytes_1 = require("../../bytes");
|
|
6
|
+
function verifyMessageEvmPersonal(message, signature, address) {
|
|
7
|
+
return (address.toLowerCase() ===
|
|
8
|
+
(0, ethers_1.verifyMessage)(typeof message === "string" ? message : (0, bytes_1.bytesFrom)(message), signature).toLowerCase());
|
|
9
|
+
}
|
|
10
|
+
exports.verifyMessageEvmPersonal = verifyMessageEvmPersonal;
|