@ckb-ccc/eip6963 0.0.4-alpha.0 → 0.0.4-alpha.10

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 ADDED
@@ -0,0 +1,37 @@
1
+ <h1 align="center" style="font-size: 48px;">
2
+ CCC's support for EIP6963
3
+ </h1>
4
+
5
+ <p align="center">
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>
15
+ </p>
16
+
17
+ <p align="center">
18
+ "Common Chains Connector" is where CCC begins.
19
+ <br />
20
+ CCC helps you to interoperate wallets from different chain ecosystems with CKB,
21
+ <br />
22
+ fully enabling CKB's cryptographic freedom power.
23
+ </p>
24
+
25
+ ## Preview
26
+
27
+ <p align="center">
28
+ <a href="https://ckbccc-demo.vercel.app/">
29
+ <img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
30
+ </a>
31
+ </p>
32
+
33
+ This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc-demo.vercel.app/).
34
+
35
+ <h3 align="center">
36
+ Read more about CCC on its <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
37
+ </h3>
@@ -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;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,GAAG,CAAC,MAAM;IAE/C,gBAAgB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,OAAO;CAcjE"}
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"}
@@ -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 signer = new EIP6963Signer(this.client, event.detail);
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,14 +1,14 @@
1
1
  {
2
2
  "name": "@ckb-ccc/eip6963",
3
- "version": "0.0.4-alpha.0",
3
+ "version": "0.0.4-alpha.10",
4
4
  "description": "Common Chains Connector's support for EIP6963",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
8
- "homepage": "https://github.com/Hanssen0/ccc",
8
+ "homepage": "https://github.com/ckb-ecofund/ccc",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git://github.com/Hanssen0/ccc.git"
11
+ "url": "git://github.com/ckb-ecofund/ccc.git"
12
12
  },
13
13
  "main": "dist/index.js",
14
14
  "exports": {
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@ckb-ccc/core": "0.0.4-alpha.0"
38
+ "@ckb-ccc/core": "0.0.4-alpha.8"
39
39
  },
40
- "gitHead": "e49045ed4b2778c92d6f49b79c17125245141a21"
40
+ "gitHead": "dec13b260f57a1b244c69af5566e316a4c329e35"
41
41
  }
@@ -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 signer = new EIP6963Signer(
11
- this.client,
12
- (event as unknown as EIP6963AnnounceProviderEvent).detail,
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