@ckb-ccc/eip6963 0.0.12-alpha.1 → 0.0.12
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/CHANGELOG.md +8 -0
- package/README.md +5 -5
- package/dist/eip1193.advanced.d.ts +3 -16
- package/dist/eip1193.advanced.d.ts.map +1 -1
- package/dist/eip6963.advanced.d.ts +0 -10
- package/dist/eip6963.advanced.d.ts.map +1 -1
- package/dist/signer.d.ts +8 -9
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +8 -9
- package/dist/signersFactory.d.ts +2 -2
- package/dist/signersFactory.js +2 -2
- package/dist.commonjs/eip1193.advanced.d.ts +3 -16
- package/dist.commonjs/eip1193.advanced.d.ts.map +1 -1
- package/dist.commonjs/eip6963.advanced.d.ts +0 -10
- package/dist.commonjs/eip6963.advanced.d.ts.map +1 -1
- package/dist.commonjs/signer.d.ts +8 -9
- package/dist.commonjs/signer.d.ts.map +1 -1
- package/dist.commonjs/signer.js +8 -9
- package/dist.commonjs/signersFactory.d.ts +2 -2
- package/dist.commonjs/signersFactory.js +2 -2
- package/package.json +8 -9
- package/src/eip1193.advanced.ts +3 -16
- package/src/eip6963.advanced.ts +0 -10
- package/src/signer.ts +8 -9
- package/src/signersFactory.ts +2 -2
- package/typedoc.json +6 -0
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://ckbccc
|
|
2
|
+
<a href="https://app.ckbccc.com/">
|
|
3
3
|
<img alt="Logo" src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/logo.svg" width="20%" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
|
|
16
16
|
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
|
|
17
17
|
<img alt="GitHub deployments" src="https://img.shields.io/github/deployments/ckb-ecofund/ccc/production" />
|
|
18
|
-
<a href="https://ckbccc
|
|
18
|
+
<a href="https://app.ckbccc.com/"><img
|
|
19
19
|
alt="Demo" src="https://img.shields.io/website?url=https%3A%2F%2Fckbccc-demo.vercel.app%2F&label=Demo"
|
|
20
20
|
/></a>
|
|
21
21
|
</p>
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
## Preview
|
|
34
34
|
|
|
35
35
|
<p align="center">
|
|
36
|
-
<a href="https://ckbccc
|
|
36
|
+
<a href="https://app.ckbccc.com/">
|
|
37
37
|
<img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
|
|
38
38
|
</a>
|
|
39
39
|
</p>
|
|
40
40
|
|
|
41
|
-
This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc
|
|
41
|
+
This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.
|
|
42
42
|
|
|
43
43
|
<h3 align="center">
|
|
44
|
-
Read more about CCC on
|
|
44
|
+
Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
|
|
45
45
|
</h3>
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { Hex } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing a provider for interacting with Ethereum-compatible wallets.
|
|
4
|
-
* @interface
|
|
5
4
|
*/
|
|
6
5
|
export interface Provider {
|
|
7
6
|
/**
|
|
8
7
|
* Sends a request to the provider.
|
|
9
|
-
* @type {RequestMethod}
|
|
10
8
|
*/
|
|
11
9
|
request: RequestMethod;
|
|
12
10
|
/**
|
|
13
11
|
* Adds an event listener to the provider.
|
|
14
|
-
* @type {OnMethod}
|
|
15
12
|
*/
|
|
16
13
|
on: OnMethod;
|
|
17
14
|
/**
|
|
18
15
|
* Removes an event listener from the provider.
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
16
|
+
* @param eventName - The name of the event to remove the listener from.
|
|
17
|
+
* @param listener - The listener function to remove.
|
|
18
|
+
* @returns The provider instance.
|
|
22
19
|
*/
|
|
23
20
|
removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Interface representing a method to send requests to the provider.
|
|
27
|
-
* @interface
|
|
28
24
|
*/
|
|
29
25
|
export interface RequestMethod {
|
|
30
26
|
/**
|
|
31
27
|
* Signs a message with the personal account.
|
|
32
28
|
* @param request - The request object.
|
|
33
|
-
* @param request.method - The method name.
|
|
34
|
-
* @param request.params - The method parameters.
|
|
35
29
|
* @returns A promise that resolves to the signed message.
|
|
36
30
|
*/
|
|
37
31
|
(request: {
|
|
@@ -41,8 +35,6 @@ export interface RequestMethod {
|
|
|
41
35
|
/**
|
|
42
36
|
* Requests the accounts from the provider.
|
|
43
37
|
* @param request - The request object.
|
|
44
|
-
* @param request.method - The method name.
|
|
45
|
-
* @param request.params - The optional method parameters.
|
|
46
38
|
* @returns A promise that resolves to an array of account addresses.
|
|
47
39
|
*/
|
|
48
40
|
(request: {
|
|
@@ -52,8 +44,6 @@ export interface RequestMethod {
|
|
|
52
44
|
/**
|
|
53
45
|
* Gets the accounts from the provider.
|
|
54
46
|
* @param request - The request object.
|
|
55
|
-
* @param request.method - The method name.
|
|
56
|
-
* @param request.params - The optional method parameters.
|
|
57
47
|
* @returns A promise that resolves to an array of account addresses.
|
|
58
48
|
*/
|
|
59
49
|
(request: {
|
|
@@ -63,8 +53,6 @@ export interface RequestMethod {
|
|
|
63
53
|
/**
|
|
64
54
|
* Sends a generic request to the provider.
|
|
65
55
|
* @param request - The request object.
|
|
66
|
-
* @param request.method - The method name.
|
|
67
|
-
* @param request.params - The optional method parameters.
|
|
68
56
|
* @returns A promise that resolves to the response from the provider.
|
|
69
57
|
*/
|
|
70
58
|
(request: {
|
|
@@ -74,7 +62,6 @@ export interface RequestMethod {
|
|
|
74
62
|
}
|
|
75
63
|
/**
|
|
76
64
|
* Interface representing a method to add event listeners to the provider.
|
|
77
|
-
* @interface
|
|
78
65
|
*/
|
|
79
66
|
export interface OnMethod {
|
|
80
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAC;IAEb;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,QAAQ,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE5E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,qBAAqB,CAAC;QAC9B,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnB;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE1E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnD,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,QAAQ,CAAC;CAC1E"}
|
|
@@ -1,54 +1,44 @@
|
|
|
1
1
|
import { Provider as EIP1193Provider } from "./eip1193.advanced.js";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing an event announcing a provider.
|
|
4
|
-
* @interface
|
|
5
4
|
*/
|
|
6
5
|
export interface AnnounceProviderEvent {
|
|
7
6
|
/**
|
|
8
7
|
* The detail of the provider.
|
|
9
|
-
* @type {ProviderDetail}
|
|
10
8
|
*/
|
|
11
9
|
detail: ProviderDetail;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* Interface representing the details of a provider.
|
|
15
|
-
* @interface
|
|
16
13
|
*/
|
|
17
14
|
export interface ProviderDetail {
|
|
18
15
|
/**
|
|
19
16
|
* The information about the provider.
|
|
20
|
-
* @type {ProviderInfo}
|
|
21
17
|
*/
|
|
22
18
|
info: ProviderInfo;
|
|
23
19
|
/**
|
|
24
20
|
* The provider instance compliant with EIP-1193.
|
|
25
|
-
* @type {EIP1193Provider}
|
|
26
21
|
*/
|
|
27
22
|
provider: EIP1193Provider;
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Interface representing information about a provider.
|
|
31
|
-
* @interface
|
|
32
26
|
*/
|
|
33
27
|
export interface ProviderInfo {
|
|
34
28
|
/**
|
|
35
29
|
* The reverse DNS name of the provider.
|
|
36
|
-
* @type {string}
|
|
37
30
|
*/
|
|
38
31
|
rdns: string;
|
|
39
32
|
/**
|
|
40
33
|
* The UUID of the provider.
|
|
41
|
-
* @type {string}
|
|
42
34
|
*/
|
|
43
35
|
uuid: string;
|
|
44
36
|
/**
|
|
45
37
|
* The name of the provider.
|
|
46
|
-
* @type {string}
|
|
47
38
|
*/
|
|
48
39
|
name: string;
|
|
49
40
|
/**
|
|
50
41
|
* The icon URL of the provider.
|
|
51
|
-
* @type {string}
|
|
52
42
|
*/
|
|
53
43
|
icon: string;
|
|
54
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/signer.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { Provider } from "./eip1193.advanced.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerEvm}
|
|
4
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class Signer extends ccc.SignerEvm {
|
|
9
8
|
readonly provider: Provider;
|
|
10
9
|
private accountCache?;
|
|
11
10
|
/**
|
|
12
11
|
* Creates an instance of Signer.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param client - The client instance.
|
|
13
|
+
* @param provider - The provider.
|
|
15
14
|
*/
|
|
16
15
|
constructor(client: ccc.Client, provider: Provider);
|
|
17
16
|
/**
|
|
@@ -21,19 +20,19 @@ export declare class Signer extends ccc.SignerEvm {
|
|
|
21
20
|
getEvmAccount(): Promise<ccc.Hex>;
|
|
22
21
|
/**
|
|
23
22
|
* Connects to the provider by requesting accounts.
|
|
24
|
-
* @returns
|
|
23
|
+
* @returns A promise that resolves when the connection is established.
|
|
25
24
|
*/
|
|
26
25
|
connect(): Promise<void>;
|
|
27
26
|
onReplaced(listener: () => void): () => void;
|
|
28
27
|
/**
|
|
29
28
|
* Checks if the provider is connected.
|
|
30
|
-
* @returns
|
|
29
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
31
30
|
*/
|
|
32
31
|
isConnected(): Promise<boolean>;
|
|
33
32
|
/**
|
|
34
33
|
* Signs a raw message with the personal account.
|
|
35
|
-
* @param
|
|
36
|
-
* @returns
|
|
34
|
+
* @param message - The message to sign.
|
|
35
|
+
* @returns A promise that resolves to the signed message.
|
|
37
36
|
*/
|
|
38
37
|
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
39
38
|
}
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAUrB,QAAQ,EAAE,QAAQ;IATpC,OAAO,CAAC,YAAY,CAAC,CAAsB;IAE3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAKpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAOvC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiB5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAMrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAWxE"}
|
package/dist/signer.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
4
|
-
* @
|
|
5
|
-
* @extends {ccc.SignerEvm}
|
|
3
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export class Signer extends ccc.SignerEvm {
|
|
8
7
|
/**
|
|
9
8
|
* Creates an instance of Signer.
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
9
|
+
* @param client - The client instance.
|
|
10
|
+
* @param provider - The provider.
|
|
12
11
|
*/
|
|
13
12
|
constructor(client, provider) {
|
|
14
13
|
super(client);
|
|
@@ -25,7 +24,7 @@ export class Signer extends ccc.SignerEvm {
|
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Connects to the provider by requesting accounts.
|
|
28
|
-
* @returns
|
|
27
|
+
* @returns A promise that resolves when the connection is established.
|
|
29
28
|
*/
|
|
30
29
|
async connect() {
|
|
31
30
|
await this.provider.request({ method: "eth_requestAccounts" });
|
|
@@ -46,15 +45,15 @@ export class Signer extends ccc.SignerEvm {
|
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* Checks if the provider is connected.
|
|
49
|
-
* @returns
|
|
48
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
50
49
|
*/
|
|
51
50
|
async isConnected() {
|
|
52
51
|
return ((await this.provider.request({ method: "eth_accounts" })).length !== 0);
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* Signs a raw message with the personal account.
|
|
56
|
-
* @param
|
|
57
|
-
* @returns
|
|
55
|
+
* @param message - The message to sign.
|
|
56
|
+
* @returns A promise that resolves to the signed message.
|
|
58
57
|
*/
|
|
59
58
|
async signMessageRaw(message) {
|
|
60
59
|
const challenge = typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
|
package/dist/signersFactory.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { ProviderDetail } from "./eip6963.advanced.js";
|
|
|
3
3
|
import { Signer } from "./signer.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class representing a factory for creating and managing Signer instances.
|
|
6
|
-
* @
|
|
6
|
+
* @public
|
|
7
7
|
*/
|
|
8
8
|
export declare class SignerFactory {
|
|
9
9
|
private readonly client;
|
|
10
10
|
private readonly existedUuids;
|
|
11
11
|
/**
|
|
12
12
|
* Creates an instance of SignerFactory.
|
|
13
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
14
|
*/
|
|
15
15
|
constructor(client: ccc.Client);
|
|
16
16
|
/**
|
package/dist/signersFactory.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Signer } from "./signer.js";
|
|
2
2
|
/**
|
|
3
3
|
* Class representing a factory for creating and managing Signer instances.
|
|
4
|
-
* @
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export class SignerFactory {
|
|
7
7
|
/**
|
|
8
8
|
* Creates an instance of SignerFactory.
|
|
9
|
-
* @param
|
|
9
|
+
* @param client - The client instance.
|
|
10
10
|
*/
|
|
11
11
|
constructor(client) {
|
|
12
12
|
this.client = client;
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { Hex } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing a provider for interacting with Ethereum-compatible wallets.
|
|
4
|
-
* @interface
|
|
5
4
|
*/
|
|
6
5
|
export interface Provider {
|
|
7
6
|
/**
|
|
8
7
|
* Sends a request to the provider.
|
|
9
|
-
* @type {RequestMethod}
|
|
10
8
|
*/
|
|
11
9
|
request: RequestMethod;
|
|
12
10
|
/**
|
|
13
11
|
* Adds an event listener to the provider.
|
|
14
|
-
* @type {OnMethod}
|
|
15
12
|
*/
|
|
16
13
|
on: OnMethod;
|
|
17
14
|
/**
|
|
18
15
|
* Removes an event listener from the provider.
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
16
|
+
* @param eventName - The name of the event to remove the listener from.
|
|
17
|
+
* @param listener - The listener function to remove.
|
|
18
|
+
* @returns The provider instance.
|
|
22
19
|
*/
|
|
23
20
|
removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Interface representing a method to send requests to the provider.
|
|
27
|
-
* @interface
|
|
28
24
|
*/
|
|
29
25
|
export interface RequestMethod {
|
|
30
26
|
/**
|
|
31
27
|
* Signs a message with the personal account.
|
|
32
28
|
* @param request - The request object.
|
|
33
|
-
* @param request.method - The method name.
|
|
34
|
-
* @param request.params - The method parameters.
|
|
35
29
|
* @returns A promise that resolves to the signed message.
|
|
36
30
|
*/
|
|
37
31
|
(request: {
|
|
@@ -41,8 +35,6 @@ export interface RequestMethod {
|
|
|
41
35
|
/**
|
|
42
36
|
* Requests the accounts from the provider.
|
|
43
37
|
* @param request - The request object.
|
|
44
|
-
* @param request.method - The method name.
|
|
45
|
-
* @param request.params - The optional method parameters.
|
|
46
38
|
* @returns A promise that resolves to an array of account addresses.
|
|
47
39
|
*/
|
|
48
40
|
(request: {
|
|
@@ -52,8 +44,6 @@ export interface RequestMethod {
|
|
|
52
44
|
/**
|
|
53
45
|
* Gets the accounts from the provider.
|
|
54
46
|
* @param request - The request object.
|
|
55
|
-
* @param request.method - The method name.
|
|
56
|
-
* @param request.params - The optional method parameters.
|
|
57
47
|
* @returns A promise that resolves to an array of account addresses.
|
|
58
48
|
*/
|
|
59
49
|
(request: {
|
|
@@ -63,8 +53,6 @@ export interface RequestMethod {
|
|
|
63
53
|
/**
|
|
64
54
|
* Sends a generic request to the provider.
|
|
65
55
|
* @param request - The request object.
|
|
66
|
-
* @param request.method - The method name.
|
|
67
|
-
* @param request.params - The optional method parameters.
|
|
68
56
|
* @returns A promise that resolves to the response from the provider.
|
|
69
57
|
*/
|
|
70
58
|
(request: {
|
|
@@ -74,7 +62,6 @@ export interface RequestMethod {
|
|
|
74
62
|
}
|
|
75
63
|
/**
|
|
76
64
|
* Interface representing a method to add event listeners to the provider.
|
|
77
|
-
* @interface
|
|
78
65
|
*/
|
|
79
66
|
export interface OnMethod {
|
|
80
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAC;IAEb;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,QAAQ,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE5E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,qBAAqB,CAAC;QAC9B,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnB;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE1E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnD,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,QAAQ,CAAC;CAC1E"}
|
|
@@ -1,54 +1,44 @@
|
|
|
1
1
|
import { Provider as EIP1193Provider } from "./eip1193.advanced.js";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing an event announcing a provider.
|
|
4
|
-
* @interface
|
|
5
4
|
*/
|
|
6
5
|
export interface AnnounceProviderEvent {
|
|
7
6
|
/**
|
|
8
7
|
* The detail of the provider.
|
|
9
|
-
* @type {ProviderDetail}
|
|
10
8
|
*/
|
|
11
9
|
detail: ProviderDetail;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* Interface representing the details of a provider.
|
|
15
|
-
* @interface
|
|
16
13
|
*/
|
|
17
14
|
export interface ProviderDetail {
|
|
18
15
|
/**
|
|
19
16
|
* The information about the provider.
|
|
20
|
-
* @type {ProviderInfo}
|
|
21
17
|
*/
|
|
22
18
|
info: ProviderInfo;
|
|
23
19
|
/**
|
|
24
20
|
* The provider instance compliant with EIP-1193.
|
|
25
|
-
* @type {EIP1193Provider}
|
|
26
21
|
*/
|
|
27
22
|
provider: EIP1193Provider;
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Interface representing information about a provider.
|
|
31
|
-
* @interface
|
|
32
26
|
*/
|
|
33
27
|
export interface ProviderInfo {
|
|
34
28
|
/**
|
|
35
29
|
* The reverse DNS name of the provider.
|
|
36
|
-
* @type {string}
|
|
37
30
|
*/
|
|
38
31
|
rdns: string;
|
|
39
32
|
/**
|
|
40
33
|
* The UUID of the provider.
|
|
41
|
-
* @type {string}
|
|
42
34
|
*/
|
|
43
35
|
uuid: string;
|
|
44
36
|
/**
|
|
45
37
|
* The name of the provider.
|
|
46
|
-
* @type {string}
|
|
47
38
|
*/
|
|
48
39
|
name: string;
|
|
49
40
|
/**
|
|
50
41
|
* The icon URL of the provider.
|
|
51
|
-
* @type {string}
|
|
52
42
|
*/
|
|
53
43
|
icon: string;
|
|
54
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { Provider } from "./eip1193.advanced.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerEvm}
|
|
4
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class Signer extends ccc.SignerEvm {
|
|
9
8
|
readonly provider: Provider;
|
|
10
9
|
private accountCache?;
|
|
11
10
|
/**
|
|
12
11
|
* Creates an instance of Signer.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param client - The client instance.
|
|
13
|
+
* @param provider - The provider.
|
|
15
14
|
*/
|
|
16
15
|
constructor(client: ccc.Client, provider: Provider);
|
|
17
16
|
/**
|
|
@@ -21,19 +20,19 @@ export declare class Signer extends ccc.SignerEvm {
|
|
|
21
20
|
getEvmAccount(): Promise<ccc.Hex>;
|
|
22
21
|
/**
|
|
23
22
|
* Connects to the provider by requesting accounts.
|
|
24
|
-
* @returns
|
|
23
|
+
* @returns A promise that resolves when the connection is established.
|
|
25
24
|
*/
|
|
26
25
|
connect(): Promise<void>;
|
|
27
26
|
onReplaced(listener: () => void): () => void;
|
|
28
27
|
/**
|
|
29
28
|
* Checks if the provider is connected.
|
|
30
|
-
* @returns
|
|
29
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
31
30
|
*/
|
|
32
31
|
isConnected(): Promise<boolean>;
|
|
33
32
|
/**
|
|
34
33
|
* Signs a raw message with the personal account.
|
|
35
|
-
* @param
|
|
36
|
-
* @returns
|
|
34
|
+
* @param message - The message to sign.
|
|
35
|
+
* @returns A promise that resolves to the signed message.
|
|
37
36
|
*/
|
|
38
37
|
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
39
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAUrB,QAAQ,EAAE,QAAQ;IATpC,OAAO,CAAC,YAAY,CAAC,CAAsB;IAE3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAKpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAOvC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiB5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAMrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAWxE"}
|
package/dist.commonjs/signer.js
CHANGED
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Signer = void 0;
|
|
4
4
|
const core_1 = require("@ckb-ccc/core");
|
|
5
5
|
/**
|
|
6
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
7
|
-
* @
|
|
8
|
-
* @extends {ccc.SignerEvm}
|
|
6
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
9
|
class Signer extends core_1.ccc.SignerEvm {
|
|
11
10
|
/**
|
|
12
11
|
* Creates an instance of Signer.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param client - The client instance.
|
|
13
|
+
* @param provider - The provider.
|
|
15
14
|
*/
|
|
16
15
|
constructor(client, provider) {
|
|
17
16
|
super(client);
|
|
@@ -28,7 +27,7 @@ class Signer extends core_1.ccc.SignerEvm {
|
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Connects to the provider by requesting accounts.
|
|
31
|
-
* @returns
|
|
30
|
+
* @returns A promise that resolves when the connection is established.
|
|
32
31
|
*/
|
|
33
32
|
async connect() {
|
|
34
33
|
await this.provider.request({ method: "eth_requestAccounts" });
|
|
@@ -49,15 +48,15 @@ class Signer extends core_1.ccc.SignerEvm {
|
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* Checks if the provider is connected.
|
|
52
|
-
* @returns
|
|
51
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
53
52
|
*/
|
|
54
53
|
async isConnected() {
|
|
55
54
|
return ((await this.provider.request({ method: "eth_accounts" })).length !== 0);
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* Signs a raw message with the personal account.
|
|
59
|
-
* @param
|
|
60
|
-
* @returns
|
|
58
|
+
* @param message - The message to sign.
|
|
59
|
+
* @returns A promise that resolves to the signed message.
|
|
61
60
|
*/
|
|
62
61
|
async signMessageRaw(message) {
|
|
63
62
|
const challenge = typeof message === "string" ? core_1.ccc.bytesFrom(message, "utf8") : message;
|
|
@@ -3,14 +3,14 @@ import { ProviderDetail } from "./eip6963.advanced.js";
|
|
|
3
3
|
import { Signer } from "./signer.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class representing a factory for creating and managing Signer instances.
|
|
6
|
-
* @
|
|
6
|
+
* @public
|
|
7
7
|
*/
|
|
8
8
|
export declare class SignerFactory {
|
|
9
9
|
private readonly client;
|
|
10
10
|
private readonly existedUuids;
|
|
11
11
|
/**
|
|
12
12
|
* Creates an instance of SignerFactory.
|
|
13
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
14
|
*/
|
|
15
15
|
constructor(client: ccc.Client);
|
|
16
16
|
/**
|
|
@@ -4,12 +4,12 @@ exports.SignerFactory = void 0;
|
|
|
4
4
|
const signer_js_1 = require("./signer.js");
|
|
5
5
|
/**
|
|
6
6
|
* Class representing a factory for creating and managing Signer instances.
|
|
7
|
-
* @
|
|
7
|
+
* @public
|
|
8
8
|
*/
|
|
9
9
|
class SignerFactory {
|
|
10
10
|
/**
|
|
11
11
|
* Creates an instance of SignerFactory.
|
|
12
|
-
* @param
|
|
12
|
+
* @param client - The client instance.
|
|
13
13
|
*/
|
|
14
14
|
constructor(client) {
|
|
15
15
|
this.client = client;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/eip6963",
|
|
3
|
-
"version": "0.0.12
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for EIP6963",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
"default": "./dist.commonjs/advanced.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
27
|
-
"lint": "eslint",
|
|
28
|
-
"format": "prettier --write . && eslint --fix"
|
|
29
|
-
},
|
|
30
25
|
"devDependencies": {
|
|
31
26
|
"@eslint/js": "^9.1.1",
|
|
32
27
|
"copyfiles": "^2.4.1",
|
|
@@ -43,7 +38,11 @@
|
|
|
43
38
|
"access": "public"
|
|
44
39
|
},
|
|
45
40
|
"dependencies": {
|
|
46
|
-
"@ckb-ccc/core": "0.0.12
|
|
41
|
+
"@ckb-ccc/core": "0.0.12"
|
|
47
42
|
},
|
|
48
|
-
"
|
|
49
|
-
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
45
|
+
"lint": "eslint",
|
|
46
|
+
"format": "prettier --write . && eslint --fix"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/eip1193.advanced.ts
CHANGED
|
@@ -2,26 +2,23 @@ import { Hex } from "@ckb-ccc/core";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface representing a provider for interacting with Ethereum-compatible wallets.
|
|
5
|
-
* @interface
|
|
6
5
|
*/
|
|
7
6
|
export interface Provider {
|
|
8
7
|
/**
|
|
9
8
|
* Sends a request to the provider.
|
|
10
|
-
* @type {RequestMethod}
|
|
11
9
|
*/
|
|
12
10
|
request: RequestMethod;
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Adds an event listener to the provider.
|
|
16
|
-
* @type {OnMethod}
|
|
17
14
|
*/
|
|
18
15
|
on: OnMethod;
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Removes an event listener from the provider.
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @returns
|
|
19
|
+
* @param eventName - The name of the event to remove the listener from.
|
|
20
|
+
* @param listener - The listener function to remove.
|
|
21
|
+
* @returns The provider instance.
|
|
25
22
|
*/
|
|
26
23
|
removeListener(
|
|
27
24
|
eventName: string,
|
|
@@ -31,14 +28,11 @@ export interface Provider {
|
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
30
|
* Interface representing a method to send requests to the provider.
|
|
34
|
-
* @interface
|
|
35
31
|
*/
|
|
36
32
|
export interface RequestMethod {
|
|
37
33
|
/**
|
|
38
34
|
* Signs a message with the personal account.
|
|
39
35
|
* @param request - The request object.
|
|
40
|
-
* @param request.method - The method name.
|
|
41
|
-
* @param request.params - The method parameters.
|
|
42
36
|
* @returns A promise that resolves to the signed message.
|
|
43
37
|
*/
|
|
44
38
|
(request: { method: "personal_sign"; params: [string, Hex] }): Promise<Hex>;
|
|
@@ -46,8 +40,6 @@ export interface RequestMethod {
|
|
|
46
40
|
/**
|
|
47
41
|
* Requests the accounts from the provider.
|
|
48
42
|
* @param request - The request object.
|
|
49
|
-
* @param request.method - The method name.
|
|
50
|
-
* @param request.params - The optional method parameters.
|
|
51
43
|
* @returns A promise that resolves to an array of account addresses.
|
|
52
44
|
*/
|
|
53
45
|
(request: {
|
|
@@ -58,8 +50,6 @@ export interface RequestMethod {
|
|
|
58
50
|
/**
|
|
59
51
|
* Gets the accounts from the provider.
|
|
60
52
|
* @param request - The request object.
|
|
61
|
-
* @param request.method - The method name.
|
|
62
|
-
* @param request.params - The optional method parameters.
|
|
63
53
|
* @returns A promise that resolves to an array of account addresses.
|
|
64
54
|
*/
|
|
65
55
|
(request: { method: "eth_accounts"; params?: undefined }): Promise<Hex[]>;
|
|
@@ -67,8 +57,6 @@ export interface RequestMethod {
|
|
|
67
57
|
/**
|
|
68
58
|
* Sends a generic request to the provider.
|
|
69
59
|
* @param request - The request object.
|
|
70
|
-
* @param request.method - The method name.
|
|
71
|
-
* @param request.params - The optional method parameters.
|
|
72
60
|
* @returns A promise that resolves to the response from the provider.
|
|
73
61
|
*/
|
|
74
62
|
(request: {
|
|
@@ -79,7 +67,6 @@ export interface RequestMethod {
|
|
|
79
67
|
|
|
80
68
|
/**
|
|
81
69
|
* Interface representing a method to add event listeners to the provider.
|
|
82
|
-
* @interface
|
|
83
70
|
*/
|
|
84
71
|
export interface OnMethod {
|
|
85
72
|
/**
|
package/src/eip6963.advanced.ts
CHANGED
|
@@ -2,60 +2,50 @@ import { Provider as EIP1193Provider } from "./eip1193.advanced.js";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Interface representing an event announcing a provider.
|
|
5
|
-
* @interface
|
|
6
5
|
*/
|
|
7
6
|
export interface AnnounceProviderEvent {
|
|
8
7
|
/**
|
|
9
8
|
* The detail of the provider.
|
|
10
|
-
* @type {ProviderDetail}
|
|
11
9
|
*/
|
|
12
10
|
detail: ProviderDetail;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* Interface representing the details of a provider.
|
|
17
|
-
* @interface
|
|
18
15
|
*/
|
|
19
16
|
export interface ProviderDetail {
|
|
20
17
|
/**
|
|
21
18
|
* The information about the provider.
|
|
22
|
-
* @type {ProviderInfo}
|
|
23
19
|
*/
|
|
24
20
|
info: ProviderInfo;
|
|
25
21
|
|
|
26
22
|
/**
|
|
27
23
|
* The provider instance compliant with EIP-1193.
|
|
28
|
-
* @type {EIP1193Provider}
|
|
29
24
|
*/
|
|
30
25
|
provider: EIP1193Provider;
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
/**
|
|
34
29
|
* Interface representing information about a provider.
|
|
35
|
-
* @interface
|
|
36
30
|
*/
|
|
37
31
|
export interface ProviderInfo {
|
|
38
32
|
/**
|
|
39
33
|
* The reverse DNS name of the provider.
|
|
40
|
-
* @type {string}
|
|
41
34
|
*/
|
|
42
35
|
rdns: string;
|
|
43
36
|
|
|
44
37
|
/**
|
|
45
38
|
* The UUID of the provider.
|
|
46
|
-
* @type {string}
|
|
47
39
|
*/
|
|
48
40
|
uuid: string;
|
|
49
41
|
|
|
50
42
|
/**
|
|
51
43
|
* The name of the provider.
|
|
52
|
-
* @type {string}
|
|
53
44
|
*/
|
|
54
45
|
name: string;
|
|
55
46
|
|
|
56
47
|
/**
|
|
57
48
|
* The icon URL of the provider.
|
|
58
|
-
* @type {string}
|
|
59
49
|
*/
|
|
60
50
|
icon: string;
|
|
61
51
|
}
|
package/src/signer.ts
CHANGED
|
@@ -2,17 +2,16 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
2
2
|
import { Provider } from "./eip1193.advanced.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
6
|
-
* @
|
|
7
|
-
* @extends {ccc.SignerEvm}
|
|
5
|
+
* Class representing an EVM signer that extends SignerEvm
|
|
6
|
+
* @public
|
|
8
7
|
*/
|
|
9
8
|
export class Signer extends ccc.SignerEvm {
|
|
10
9
|
private accountCache?: ccc.Hex = undefined;
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Creates an instance of Signer.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
|
+
* @param provider - The provider.
|
|
16
15
|
*/
|
|
17
16
|
constructor(
|
|
18
17
|
client: ccc.Client,
|
|
@@ -34,7 +33,7 @@ export class Signer extends ccc.SignerEvm {
|
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* Connects to the provider by requesting accounts.
|
|
37
|
-
* @returns
|
|
36
|
+
* @returns A promise that resolves when the connection is established.
|
|
38
37
|
*/
|
|
39
38
|
async connect(): Promise<void> {
|
|
40
39
|
await this.provider.request({ method: "eth_requestAccounts" });
|
|
@@ -59,7 +58,7 @@ export class Signer extends ccc.SignerEvm {
|
|
|
59
58
|
|
|
60
59
|
/**
|
|
61
60
|
* Checks if the provider is connected.
|
|
62
|
-
* @returns
|
|
61
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
63
62
|
*/
|
|
64
63
|
async isConnected(): Promise<boolean> {
|
|
65
64
|
return (
|
|
@@ -69,8 +68,8 @@ export class Signer extends ccc.SignerEvm {
|
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
70
|
* Signs a raw message with the personal account.
|
|
72
|
-
* @param
|
|
73
|
-
* @returns
|
|
71
|
+
* @param message - The message to sign.
|
|
72
|
+
* @returns A promise that resolves to the signed message.
|
|
74
73
|
*/
|
|
75
74
|
async signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex> {
|
|
76
75
|
const challenge =
|
package/src/signersFactory.ts
CHANGED
|
@@ -8,14 +8,14 @@ import { Signer } from "./signer.js";
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Class representing a factory for creating and managing Signer instances.
|
|
11
|
-
* @
|
|
11
|
+
* @public
|
|
12
12
|
*/
|
|
13
13
|
export class SignerFactory {
|
|
14
14
|
private readonly existedUuids: string[] = [];
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates an instance of SignerFactory.
|
|
18
|
-
* @param
|
|
18
|
+
* @param client - The client instance.
|
|
19
19
|
*/
|
|
20
20
|
constructor(private readonly client: ccc.Client) {}
|
|
21
21
|
|