@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-alpha.8
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/dummy/alwaysError.d.ts +10 -0
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist/signer/dummy/alwaysError.js +13 -0
- package/dist/signer/dummy/dummy.d.ts +12 -0
- package/dist/signer/dummy/dummy.d.ts.map +1 -0
- package/dist/signer/dummy/dummy.js +19 -0
- package/dist/signer/dummy/index.d.ts +4 -0
- package/dist/signer/dummy/index.d.ts.map +1 -0
- package/dist/signer/dummy/index.js +3 -0
- package/dist/signer/dummy/openLink.d.ts +10 -0
- package/dist/signer/dummy/openLink.d.ts.map +1 -0
- package/dist/signer/dummy/openLink.js +13 -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/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/dist/signer/{signer.d.ts → signer/index.d.ts} +67 -21
- package/dist/signer/signer/index.d.ts.map +1 -0
- package/dist/signer/{signer.js → signer/index.js} +95 -16
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- 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/dummy/alwaysError.d.ts +10 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/alwaysError.js +17 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/dummy.js +23 -0
- package/dist.commonjs/signer/dummy/index.d.ts +4 -0
- package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/index.js +19 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts +10 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/openLink.js +17 -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/index.d.ts +1 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +1 -0
- package/dist.commonjs/signer/{signer.d.ts → signer/index.d.ts} +67 -21
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/{signer.js → signer/index.js} +97 -17
- package/dist.commonjs/utils/index.d.ts +1 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +5 -1
- 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/dummy/alwaysError.ts +21 -0
- package/src/signer/dummy/dummy.ts +28 -0
- package/src/signer/dummy/index.ts +3 -0
- package/src/signer/dummy/openLink.ts +21 -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/index.ts +1 -0
- package/src/signer/{signer.ts → signer/index.ts} +131 -21
- package/src/utils/index.ts +4 -0
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { Address } from "
|
|
2
|
-
import { BytesLike } from "
|
|
3
|
-
import { Transaction, TransactionLike } from "
|
|
4
|
-
import { Client } from "
|
|
5
|
-
import { Hex } from "
|
|
6
|
-
import { Num } from "
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { BytesLike } from "../../bytes";
|
|
3
|
+
import { Transaction, TransactionLike } from "../../ckb";
|
|
4
|
+
import { Client } from "../../client";
|
|
5
|
+
import { Hex } from "../../hex";
|
|
6
|
+
import { Num } from "../../num";
|
|
7
|
+
export declare enum SignerSignType {
|
|
8
|
+
Unknown = "Unknown",
|
|
9
|
+
BtcEcdsa = "BtcEcdsa",
|
|
10
|
+
EvmPersonal = "EvmPersonal",
|
|
11
|
+
JoyId = "JoyId"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An enumeration of signer display types in wallet.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum SignerType {
|
|
17
|
+
EVM = "EVM",
|
|
18
|
+
BTC = "BTC",
|
|
19
|
+
CKB = "CKB"
|
|
20
|
+
}
|
|
21
|
+
export declare class Signature {
|
|
22
|
+
signature: string;
|
|
23
|
+
identity: string;
|
|
24
|
+
signType: SignerSignType;
|
|
25
|
+
constructor(signature: string, identity: string, signType: SignerSignType);
|
|
26
|
+
}
|
|
7
27
|
/**
|
|
8
28
|
* An abstract class representing a generic signer.
|
|
9
29
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -11,7 +31,10 @@ import { Num } from "../num";
|
|
|
11
31
|
export declare abstract class Signer {
|
|
12
32
|
protected client_: Client;
|
|
13
33
|
constructor(client_: Client);
|
|
34
|
+
abstract get type(): SignerType;
|
|
35
|
+
abstract get signType(): SignerSignType;
|
|
14
36
|
get client(): Client;
|
|
37
|
+
static verifyMessage(message: string | BytesLike, signature: Signature): Promise<boolean>;
|
|
15
38
|
/**
|
|
16
39
|
* Construct a new signer with the client replaced.
|
|
17
40
|
*
|
|
@@ -42,6 +65,12 @@ export declare abstract class Signer {
|
|
|
42
65
|
* @returns A promise that resolves to a string representing the internal address.
|
|
43
66
|
*/
|
|
44
67
|
abstract getInternalAddress(): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the identity for verifying signature, usually it's address
|
|
70
|
+
*
|
|
71
|
+
* @returns A promise that resolves to a string representing the identity
|
|
72
|
+
*/
|
|
73
|
+
getIdentity(): Promise<string>;
|
|
45
74
|
/**
|
|
46
75
|
* Gets an array of Address objects associated with the signer.
|
|
47
76
|
*
|
|
@@ -75,13 +104,39 @@ export declare abstract class Signer {
|
|
|
75
104
|
*/
|
|
76
105
|
getBalance(): Promise<Num>;
|
|
77
106
|
/**
|
|
78
|
-
* Signs a message.
|
|
107
|
+
* Signs a message.
|
|
108
|
+
*
|
|
109
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
110
|
+
* @returns A promise that resolves to the signature info.
|
|
111
|
+
* @throws Will throw an error if not implemented.
|
|
112
|
+
*/
|
|
113
|
+
signMessage(message: string | BytesLike): Promise<Signature>;
|
|
114
|
+
/**
|
|
115
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
79
116
|
*
|
|
80
117
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
81
|
-
* @returns A promise that resolves to the
|
|
118
|
+
* @returns A promise that resolves to the signature as a string.
|
|
119
|
+
* @throws Will throw an error if not implemented.
|
|
120
|
+
*/
|
|
121
|
+
signMessageRaw(_: string | BytesLike): Promise<string>;
|
|
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
|
+
verifyMessage(message: string | BytesLike, signature: string | Signature): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
133
|
+
*
|
|
134
|
+
* @param _0 - The original message.
|
|
135
|
+
* @param _1 - The signature to verify.
|
|
136
|
+
* @returns A promise that resolves to the verification result.
|
|
82
137
|
* @throws Will throw an error if not implemented.
|
|
83
138
|
*/
|
|
84
|
-
|
|
139
|
+
verifyMessageRaw(_0: string | BytesLike, _1: string): Promise<boolean>;
|
|
85
140
|
/**
|
|
86
141
|
* Sends a transaction after signing it.
|
|
87
142
|
*
|
|
@@ -105,7 +160,7 @@ export declare abstract class Signer {
|
|
|
105
160
|
*/
|
|
106
161
|
prepareTransaction(_: TransactionLike): Promise<Transaction>;
|
|
107
162
|
/**
|
|
108
|
-
* Signs a transaction without
|
|
163
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
109
164
|
*
|
|
110
165
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
111
166
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -113,22 +168,13 @@ export declare abstract class Signer {
|
|
|
113
168
|
*/
|
|
114
169
|
signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
|
|
115
170
|
}
|
|
116
|
-
/**
|
|
117
|
-
* An enumeration of signer types.
|
|
118
|
-
*/
|
|
119
|
-
export declare enum SignerType {
|
|
120
|
-
EVM = "EVM",
|
|
121
|
-
BTC = "BTC",
|
|
122
|
-
CKB = "CKB"
|
|
123
|
-
}
|
|
124
171
|
/**
|
|
125
172
|
* A class representing information about a signer, including its type and the signer instance.
|
|
126
173
|
*/
|
|
127
174
|
export declare class SignerInfo {
|
|
128
175
|
name: string;
|
|
129
|
-
type: SignerType;
|
|
130
176
|
signer: Signer;
|
|
131
|
-
constructor(name: string,
|
|
177
|
+
constructor(name: string, signer: Signer);
|
|
132
178
|
}
|
|
133
179
|
/**
|
|
134
180
|
* Represents a wallet with a name, icon, and an array of signer information.
|
|
@@ -137,4 +183,4 @@ export type Wallet = {
|
|
|
137
183
|
name: string;
|
|
138
184
|
icon: string;
|
|
139
185
|
};
|
|
140
|
-
//# sourceMappingURL=
|
|
186
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAKhC,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,qBAAa,SAAS;IAEX,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,cAAc;gBAFxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,cAAc;CAElC;AAED;;;GAGG;AACH,8BAAsB,MAAM;IACd,SAAS,CAAC,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAErC,QAAQ,KAAK,IAAI,IAAI,UAAU,CAAC;IAChC,QAAQ,KAAK,QAAQ,IAAI,cAAc,CAAC;IAExC,IAAI,MAAM,IAAI,MAAM,CAEnB;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CAAC;IAenB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItE;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;GAEG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -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
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
|
4
4
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined): R | undefined;
|
|
5
5
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | null): R | null;
|
|
6
6
|
export declare function apply<T, R>(transformer: (val: T) => R, value: undefined | null): undefined | null;
|
|
7
|
+
export declare function isWebview(userAgent: string): boolean;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC;AAYpB,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
package/dist/utils/index.js
CHANGED
|
@@ -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,8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b,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,C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c,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"}
|