@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/address/index.d.ts
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"}
|
package/dist/address/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export class Address {
|
|
|
43
43
|
if (!client) {
|
|
44
44
|
throw new Error(`Unknown address prefix ${prefix}`);
|
|
45
45
|
}
|
|
46
|
-
const expectedPrefix =
|
|
46
|
+
const expectedPrefix = client.addressPrefix;
|
|
47
47
|
if (expectedPrefix !== prefix) {
|
|
48
48
|
throw new Error(`Unknown address prefix ${prefix}, expected ${expectedPrefix}`);
|
|
49
49
|
}
|
|
@@ -56,8 +56,8 @@ export class Address {
|
|
|
56
56
|
* @param client - The client instance used to fetch the address prefix.
|
|
57
57
|
* @returns A promise that resolves to an Address instance.
|
|
58
58
|
*/
|
|
59
|
-
static
|
|
60
|
-
return Address.from({ script, prefix:
|
|
59
|
+
static fromScript(script, client) {
|
|
60
|
+
return Address.from({ script, prefix: client.addressPrefix });
|
|
61
61
|
}
|
|
62
62
|
static async fromKnownScript(script, args, client) {
|
|
63
63
|
return Address.from({
|
|
@@ -65,7 +65,7 @@ export class Address {
|
|
|
65
65
|
...(await client.getKnownScript(script)),
|
|
66
66
|
args,
|
|
67
67
|
},
|
|
68
|
-
prefix:
|
|
68
|
+
prefix: client.addressPrefix,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
/**
|
package/dist/client/client.d.ts
CHANGED
|
@@ -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,Q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K,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,OA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;;;;;;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"}
|
|
@@ -33,9 +33,9 @@ export class ClientJsonRpc extends Client {
|
|
|
33
33
|
* @param url - The URL of the JSON-RPC server.
|
|
34
34
|
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
35
35
|
*/
|
|
36
|
-
constructor(
|
|
36
|
+
constructor(url_, timeout = 30000) {
|
|
37
37
|
super();
|
|
38
|
-
this.
|
|
38
|
+
this.url_ = url_;
|
|
39
39
|
this.timeout = timeout;
|
|
40
40
|
/**
|
|
41
41
|
* Send a transaction to node.
|
|
@@ -79,8 +79,8 @@ export class ClientJsonRpc extends Client {
|
|
|
79
79
|
*
|
|
80
80
|
* @returns The URL of the JSON-RPC server.
|
|
81
81
|
*/
|
|
82
|
-
|
|
83
|
-
return this.
|
|
82
|
+
get url() {
|
|
83
|
+
return this.url_;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* 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"}
|
package/dist/signer/btc/index.js
CHANGED
|
@@ -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"}
|
|
@@ -6,13 +6,19 @@ import { Transaction, WitnessArgs } from "../../ckb";
|
|
|
6
6
|
import { KnownScript } from "../../client";
|
|
7
7
|
import { hexFrom } from "../../hex";
|
|
8
8
|
import { numToBytes } from "../../num";
|
|
9
|
-
import { Signer } from "../signer";
|
|
9
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
10
10
|
/**
|
|
11
11
|
* An abstract class extending the Signer class for Bitcoin-like signing operations.
|
|
12
12
|
* This class provides methods to get Bitcoin account, public key, and internal address,
|
|
13
13
|
* as well as signing transactions.
|
|
14
14
|
*/
|
|
15
15
|
export class SignerBtc extends Signer {
|
|
16
|
+
get type() {
|
|
17
|
+
return SignerType.BTC;
|
|
18
|
+
}
|
|
19
|
+
get signType() {
|
|
20
|
+
return SignerSignType.BtcEcdsa;
|
|
21
|
+
}
|
|
16
22
|
/**
|
|
17
23
|
* Gets the internal address, which is the Bitcoin account in this case.
|
|
18
24
|
*
|
|
@@ -21,6 +27,14 @@ export class SignerBtc extends Signer {
|
|
|
21
27
|
async getInternalAddress() {
|
|
22
28
|
return this.getBtcAccount();
|
|
23
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the identity, which is the Bitcoin public key in this case.
|
|
32
|
+
*
|
|
33
|
+
* @returns A promise that resolves to a string representing the identity
|
|
34
|
+
*/
|
|
35
|
+
async getIdentity() {
|
|
36
|
+
return hexFrom(await this.getBtcPublicKey()).slice(2);
|
|
37
|
+
}
|
|
24
38
|
/**
|
|
25
39
|
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
26
40
|
*
|
|
@@ -56,7 +70,7 @@ export class SignerBtc extends Signer {
|
|
|
56
70
|
if (!info) {
|
|
57
71
|
return tx;
|
|
58
72
|
}
|
|
59
|
-
const signature = bytesFrom(await this.
|
|
73
|
+
const signature = bytesFrom(await this.signMessageRaw(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
|
|
60
74
|
signature[0] = 31 + ((signature[0] - 27) % 4);
|
|
61
75
|
const witness = WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
62
76
|
witness.lock = hexFrom(bytesConcat(numToBytes(5 * 4 + signature.length, 4), numToBytes(4 * 4, 4), numToBytes(5 * 4 + signature.length, 4), numToBytes(5 * 4 + signature.length, 4), 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,6 @@
|
|
|
1
|
+
import { verifyMessage } from "@unisat/wallet-utils";
|
|
2
|
+
import { hexFrom } from "../../hex";
|
|
3
|
+
export function verifyMessageBtcEcdsa(message, signature, publicKey) {
|
|
4
|
+
const challenge = typeof message === "string" ? message : hexFrom(message).slice(2);
|
|
5
|
+
return verifyMessage(publicKey, challenge, signature);
|
|
6
|
+
}
|
|
@@ -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"}
|
package/dist/signer/ckb/index.js
CHANGED
|
@@ -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"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { Script } from "../../ckb";
|
|
3
|
-
import { Signer } from "../signer";
|
|
3
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
4
4
|
/**
|
|
5
5
|
* A class extending Signer that provides read-only access to a CKB script.
|
|
6
6
|
* This class does not support signing operations.
|
|
7
7
|
*/
|
|
8
8
|
export class SignerCkbScriptReadonly extends Signer {
|
|
9
|
+
get type() {
|
|
10
|
+
return SignerType.CKB;
|
|
11
|
+
}
|
|
12
|
+
get signType() {
|
|
13
|
+
return SignerSignType.Unknown;
|
|
14
|
+
}
|
|
9
15
|
/**
|
|
10
16
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
11
17
|
*
|
|
@@ -62,6 +68,6 @@ export class SignerCkbScriptReadonly extends Signer {
|
|
|
62
68
|
* ```
|
|
63
69
|
*/
|
|
64
70
|
async getAddressObjs() {
|
|
65
|
-
return [
|
|
71
|
+
return [Address.fromScript(this.script, this.client)];
|
|
66
72
|
}
|
|
67
73
|
}
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { verifySignature } from "@joyid/ckb";
|
|
2
|
+
import { hexFrom } from "../../hex";
|
|
3
|
+
export function verifyMessageJoyId(message, signature, identity) {
|
|
4
|
+
const challenge = typeof message === "string" ? message : hexFrom(message).slice(2);
|
|
5
|
+
const { publicKey, keyType } = JSON.parse(identity);
|
|
6
|
+
return verifySignature({
|
|
7
|
+
challenge,
|
|
8
|
+
pubkey: publicKey,
|
|
9
|
+
keyType,
|
|
10
|
+
...JSON.parse(signature),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -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"}
|
package/dist/signer/evm/index.js
CHANGED
|
@@ -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,OAA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AM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;CA6BxB"}
|
|
@@ -4,12 +4,18 @@ import { Transaction, WitnessArgs } from "../../ckb";
|
|
|
4
4
|
import { KnownScript } from "../../client";
|
|
5
5
|
import { hexFrom } from "../../hex";
|
|
6
6
|
import { numToBytes } from "../../num";
|
|
7
|
-
import { Signer } from "../signer";
|
|
7
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
8
8
|
/**
|
|
9
9
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
10
10
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
11
11
|
*/
|
|
12
12
|
export class SignerEvm extends Signer {
|
|
13
|
+
get type() {
|
|
14
|
+
return SignerType.EVM;
|
|
15
|
+
}
|
|
16
|
+
get signType() {
|
|
17
|
+
return SignerSignType.EvmPersonal;
|
|
18
|
+
}
|
|
13
19
|
/**
|
|
14
20
|
* Gets the internal address, which is the EVM account in this case.
|
|
15
21
|
*
|
|
@@ -66,7 +72,7 @@ export class SignerEvm extends Signer {
|
|
|
66
72
|
if (!info) {
|
|
67
73
|
return tx;
|
|
68
74
|
}
|
|
69
|
-
const signature = bytesFrom(await this.
|
|
75
|
+
const signature = bytesFrom(await this.signMessageRaw(messageTransformer(info.message)));
|
|
70
76
|
if (signature[signature.length - 1] >= 27) {
|
|
71
77
|
signature[signature.length - 1] -= 27;
|
|
72
78
|
}
|
|
@@ -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,6 @@
|
|
|
1
|
+
import { verifyMessage } from "ethers";
|
|
2
|
+
import { bytesFrom } from "../../bytes";
|
|
3
|
+
export function verifyMessageEvmPersonal(message, signature, address) {
|
|
4
|
+
return (address.toLowerCase() ===
|
|
5
|
+
verifyMessage(typeof message === "string" ? message : bytesFrom(message), signature).toLowerCase());
|
|
6
|
+
}
|
package/dist/signer/signer.d.ts
CHANGED
|
@@ -4,6 +4,26 @@ import { Transaction, TransactionLike } from "../ckb";
|
|
|
4
4
|
import { Client } from "../client";
|
|
5
5
|
import { Hex } from "../hex";
|
|
6
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAK7B,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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