@ckb-ccc/eip6963 0.0.4-alpha.1 → 0.0.4-alpha.11
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/README.md +12 -7
- package/dist/signer.d.ts +2 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +7 -0
- package/dist/signersFactory.d.ts +1 -0
- package/dist/signersFactory.d.ts.map +1 -1
- package/dist/signersFactory.js +8 -1
- package/package.json +3 -3
- package/src/signer.ts +8 -0
- package/src/signersFactory.ts +11 -4
package/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
<h1 align="center" style="font-size:
|
|
2
|
-
CCC
|
|
1
|
+
<h1 align="center" style="font-size: 48px;">
|
|
2
|
+
CCC's support for EIP6963
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<img alt="
|
|
6
|
+
<a href="https://www.npmjs.com/package/@ckb-ccc/eip6963"><img
|
|
7
|
+
alt="NPM Version" src="https://img.shields.io/npm/v/%40ckb-ccc%2Feip6963"
|
|
8
|
+
/></a>
|
|
9
|
+
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
|
|
10
|
+
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
|
|
11
|
+
<img alt="GitHub deployments" src="https://img.shields.io/github/deployments/ckb-ecofund/ccc/production" />
|
|
12
|
+
<a href="https://ckbccc-demo.vercel.app/"><img
|
|
13
|
+
alt="Demo" src="https://img.shields.io/website?url=https%3A%2F%2Fckbccc-demo.vercel.app%2F&label=Demo"
|
|
14
|
+
/></a>
|
|
10
15
|
</p>
|
|
11
16
|
|
|
12
17
|
<p align="center">
|
|
@@ -29,4 +34,4 @@ This project is still under active development, and we are looking forward to yo
|
|
|
29
34
|
|
|
30
35
|
<h3 align="center">
|
|
31
36
|
Read more about CCC on its <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
|
|
32
|
-
</h3>
|
|
37
|
+
</h3>
|
package/dist/signer.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { ProviderDetail as EIP6963ProviderDetail } from "./eip6963.advanced";
|
|
|
3
3
|
export declare class Signer extends ccc.SignerEvm {
|
|
4
4
|
readonly detail: EIP6963ProviderDetail;
|
|
5
5
|
constructor(client: ccc.Client, detail: EIP6963ProviderDetail);
|
|
6
|
+
replaceClient(client: ccc.Client): Promise<Signer>;
|
|
6
7
|
getEvmAccount(): Promise<`0x${string}`>;
|
|
7
8
|
connect(): Promise<void>;
|
|
9
|
+
isConnected(): Promise<boolean>;
|
|
8
10
|
signMessage(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
9
11
|
}
|
|
10
12
|
//# sourceMappingURL=signer.d.ts.map
|
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,cAAc,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAGrB,MAAM,EAAE,qBAAqB;gBAD7C,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,MAAM,EAAE,qBAAqB;IAKzC,aAAa;IAIb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAUrE"}
|
|
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,cAAc,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAGrB,MAAM,EAAE,qBAAqB;gBAD7C,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,MAAM,EAAE,qBAAqB;IAKzC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD,aAAa;IAIb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAUrE"}
|
package/dist/signer.js
CHANGED
|
@@ -4,12 +4,19 @@ export class Signer extends ccc.SignerEvm {
|
|
|
4
4
|
super(client);
|
|
5
5
|
this.detail = detail;
|
|
6
6
|
}
|
|
7
|
+
async replaceClient(client) {
|
|
8
|
+
return new Signer(client, this.detail);
|
|
9
|
+
}
|
|
7
10
|
async getEvmAccount() {
|
|
8
11
|
return (await this.detail.provider.request({ method: "eth_accounts" }))[0];
|
|
9
12
|
}
|
|
10
13
|
async connect() {
|
|
11
14
|
await this.detail.provider.request({ method: "eth_requestAccounts" });
|
|
12
15
|
}
|
|
16
|
+
async isConnected() {
|
|
17
|
+
return (await this.detail.provider.request({ method: "eth_accounts" })).length !== 0;
|
|
18
|
+
}
|
|
19
|
+
;
|
|
13
20
|
async signMessage(message) {
|
|
14
21
|
const challenge = typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
|
|
15
22
|
const address = await this.getEvmAccount();
|
package/dist/signersFactory.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
2
2
|
import { Signer as EIP6963Signer } from "./signer";
|
|
3
3
|
export declare class SignerFactory {
|
|
4
4
|
private readonly client;
|
|
5
|
+
private readonly existedUuids;
|
|
5
6
|
constructor(client: ccc.Client);
|
|
6
7
|
subscribeSigners(callback: (newSigner: EIP6963Signer) => unknown): () => void;
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnD,qBAAa,aAAa;IAGZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;gBAEhB,MAAM,EAAE,GAAG,CAAC,MAAM;IAE/C,gBAAgB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,OAAO;CAmBjE"}
|
package/dist/signersFactory.js
CHANGED
|
@@ -2,10 +2,17 @@ import { Signer as EIP6963Signer } from "./signer";
|
|
|
2
2
|
export class SignerFactory {
|
|
3
3
|
constructor(client) {
|
|
4
4
|
this.client = client;
|
|
5
|
+
this.existedUuids = [];
|
|
5
6
|
}
|
|
6
7
|
subscribeSigners(callback) {
|
|
7
8
|
const onNewProvider = (event) => {
|
|
8
|
-
const
|
|
9
|
+
const { detail } = event;
|
|
10
|
+
const { uuid } = detail.info;
|
|
11
|
+
if (this.existedUuids.indexOf(uuid) !== -1) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.existedUuids.push(uuid);
|
|
15
|
+
const signer = new EIP6963Signer(this.client, detail);
|
|
9
16
|
callback(signer);
|
|
10
17
|
};
|
|
11
18
|
window.addEventListener("eip6963:announceProvider", onNewProvider);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/eip6963",
|
|
3
|
-
"version": "0.0.4-alpha.
|
|
3
|
+
"version": "0.0.4-alpha.11",
|
|
4
4
|
"description": "Common Chains Connector's support for EIP6963",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ckb-ccc/core": "0.0.4-alpha.
|
|
38
|
+
"@ckb-ccc/core": "0.0.4-alpha.11"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "db0297c0753349e2650d2845f42f546316078d5d"
|
|
41
41
|
}
|
package/src/signer.ts
CHANGED
|
@@ -9,6 +9,10 @@ export class Signer extends ccc.SignerEvm {
|
|
|
9
9
|
super(client);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
async replaceClient(client: ccc.Client): Promise<Signer> {
|
|
13
|
+
return new Signer(client, this.detail);
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
async getEvmAccount() {
|
|
13
17
|
return (await this.detail.provider.request({ method: "eth_accounts" }))[0];
|
|
14
18
|
}
|
|
@@ -17,6 +21,10 @@ export class Signer extends ccc.SignerEvm {
|
|
|
17
21
|
await this.detail.provider.request({ method: "eth_requestAccounts" });
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
async isConnected(): Promise<boolean> {
|
|
25
|
+
return (await this.detail.provider.request({ method: "eth_accounts" })).length !== 0;
|
|
26
|
+
};
|
|
27
|
+
|
|
20
28
|
async signMessage(message: string | ccc.BytesLike): Promise<ccc.Hex> {
|
|
21
29
|
const challenge =
|
|
22
30
|
typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
|
package/src/signersFactory.ts
CHANGED
|
@@ -3,14 +3,21 @@ import { AnnounceProviderEvent as EIP6963AnnounceProviderEvent } from "./eip6963
|
|
|
3
3
|
import { Signer as EIP6963Signer } from "./signer";
|
|
4
4
|
|
|
5
5
|
export class SignerFactory {
|
|
6
|
+
private readonly existedUuids: string[] = [];
|
|
7
|
+
|
|
6
8
|
constructor(private readonly client: ccc.Client) {}
|
|
7
9
|
|
|
8
10
|
subscribeSigners(callback: (newSigner: EIP6963Signer) => unknown) {
|
|
9
11
|
const onNewProvider = (event: Event) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
12
|
+
const { detail } = event as unknown as EIP6963AnnounceProviderEvent;
|
|
13
|
+
const { uuid } = detail.info;
|
|
14
|
+
|
|
15
|
+
if (this.existedUuids.indexOf(uuid) !== -1) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.existedUuids.push(uuid);
|
|
20
|
+
const signer = new EIP6963Signer(this.client, detail);
|
|
14
21
|
callback(signer);
|
|
15
22
|
};
|
|
16
23
|
|