@ckb-ccc/connector 0.0.5-alpha.9 → 0.0.6-alpha.0
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/assets/chains/nostr.svg.d.ts +2 -0
- package/dist/assets/chains/nostr.svg.d.ts.map +1 -0
- package/dist/assets/chains/nostr.svg.js +2 -0
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +15 -6
- package/dist/scenes/signers.d.ts.map +1 -1
- package/dist/scenes/signers.js +2 -0
- package/package.json +3 -3
- package/src/assets/chains/nostr.svg.ts +5 -0
- package/src/connector/index.ts +15 -6
- package/src/scenes/signers.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nostr.svg.d.ts","sourceRoot":"","sources":["../../../src/assets/chains/nostr.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,QAErB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { encodeSvgToImgSrc } from "../utils";
|
|
2
|
+
export const NOSTR_SVG = encodeSvgToImgSrc('<svg version="1.1" id="_8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" style="enable-background:new 0 0 256 256;" xml:space="preserve"><style type="text/css">.st0{fill:none;} .st1{fill:#FFFFFF;} .st2{fill:#662482;}</style><g><path class="st0" d="M0,0v256h256V0H0z M231.2,159.2c0,20.7,0,31.1-3.5,42.2c-4.4,12.2-14,21.8-26.2,26.2 c-11.1,3.5-21.5,3.5-42.2,3.5H96.8c-20.7,0-31.1,0-42.2-3.5c-12.2-4.4-21.8-14-26.2-26.2c-3.5-11.1-3.5-21.5-3.5-42.2V96.8 c0-20.7,0-31.1,3.5-42.2c4.4-12.2,14-21.8,26.2-26.2c11.2-3.5,21.5-3.5,42.2-3.5h62.5c20.7,0,31.1,0,42.2,3.5 c12.2,4.4,21.8,14,26.2,26.2c3.5,11.1,3.5,21.5,3.5,42.2V159.2z"/> <circle class="st1" cx="137.9" cy="99" r="12.1"/><path class="st1" d="M210.8,115.9c0-47.3-27.7-68.7-64.4-68.7c-16.4,0-31,4.4-42.4,12.5c-3.8,2.7-9,0.1-9-4.5 c0-3.1-2.5-5.7-5.7-5.7H57.7c-3.1,0-5.7,2.5-5.7,5.7v144c0,3.1,2.5,5.7,5.7,5.7h33.7c3.1,0,5.6-2.5,5.6-5.6v-8.4 c0-62.8-33.2-109.8-0.4-116c30-5.7,64.1-3,64.5,20.1c0,2,0.3,8,8.6,11.2c5,2,12.6,2.6,22.6,2.4c0,0,9.1-0.7,9.1,8.5 c0,11.5-20.4,10.7-20.4,10.7c-6.7,0.3-22.6-1.5-31.7,1.2c-4.8,1.5-9,4.2-11.5,9.1c-4.2,8.3-6.2,26.5-6.5,45.5v15.5 c0,3.1,2.5,5.7,5.7,5.7h68c3.1,0,5.7-2.5,5.7-5.7l0,0V115.9z"/><path class="st2" d="M227.6,54.6c-4.4-12.2-14-21.8-26.2-26.2c-11.1-3.5-21.5-3.5-42.2-3.5H96.8c-20.7,0-31.1,0-42.2,3.5 c-12.2,4.4-21.8,14-26.2,26.2c-3.5,11.2-3.5,21.5-3.5,42.2v62.5c0,20.7,0,31.1,3.5,42.2c4.4,12.2,14,21.8,26.2,26.2 c11.2,3.5,21.5,3.5,42.2,3.5h62.5c20.7,0,31.1,0,42.2-3.5c12.2-4.4,21.8-14,26.2-26.2c3.5-11.1,3.5-21.5,3.5-42.2V96.8 C231.2,76.1,231.2,65.7,227.6,54.6z M205.1,204.8h-68c-3.1,0-5.7-2.5-5.7-5.7v-15.5c0.3-19,2.3-37.2,6.5-45.5 c2.5-5,6.7-7.7,11.5-9.1c9-2.7,24.9-0.9,31.7-1.2c0,0,20.4,0.8,20.4-10.7c0-9.3-9.1-8.5-9.1-8.5c-10,0.3-17.7-0.4-22.6-2.4 c-8.3-3.3-8.6-9.2-8.6-11.2c-0.4-23.1-34.5-25.9-64.5-20.1c-32.8,6.2,0.4,53.3,0.4,116v8.4c-0.1,3.1-2.5,5.6-5.6,5.6H57.7 c-3.1,0-5.7-2.5-5.7-5.7v-144c0-3.1,2.5-5.7,5.7-5.7h31.7c3.1,0,5.7,2.5,5.7,5.7c0,4.7,5.2,7.2,9,4.5c11.4-8.2,26-12.5,42.4-12.5 c36.7,0,64.4,21.4,64.4,68.7v83.2l0,0C210.8,202.3,208.3,204.8,205.1,204.8z M125.7,99c0-6.7,5.4-12.1,12.1-12.1S150,92.3,150,99 s-5.4,12.1-12.1,12.1S125.7,105.8,125.7,99z"/></g></svg>');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAkB,MAAM,uBAAuB,CAAC;AA0B5D,qBACa,qBAAsB,SAAQ,UAAU;IAEnD,OAAO,CAAC,OAAO,CAA2B;IAEnC,YAAY,CAAC,EAAE,CACpB,UAAU,EAAE,GAAG,CAAC,UAAU,EAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,KACf,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtB,OAAO,CAAC,cAAc,CAAsB;IAGrC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,GAAG,CAAC,MAAM,CAAiC;IACnD,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM;IAKnC,OAAO,CAAC,KAAK,CAAiC;IAE9C,OAAO,CAAC,cAAc,CAAC,CAAoB;IAE3C,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC,OAAO,CAAC,eAAe,CAAC,CAAS;IAGjC,OAAO,CAAC,UAAU,CAAC,CAAS;IAE5B,OAAO,CAAC,UAAU,CAAC,CAAS;IAErB,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,MAAM,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IAG/B,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,OAAO,CAAC,CAAU;YAEZ,gBAAgB;YAUhB,aAAa;IAYpB,UAAU;IAOjB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,cAAc;IAUtB,iBAAiB,IAAI,IAAI;IAMzB,UAAU,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAoCnD,OAAO,CAAC,aAAa;YAoGP,SAAS;IAyCvB,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,CAAe;IAC3C,SAAS,EAAE,GAAG,CAAC,cAAc,CAAC,CAAe;IAC7C,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,CAAe;IAE3C,MAAM;IA+FN,OAAO;IAUP,OAAO,CAAC,aAAa,CAgBnB;IAEF,OAAO,CAAC,qBAAqB,CAqC3B;IAEF,MAAM,CAAC,MAAM,0BAsPX;CACH"}
|
package/dist/connector/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ccc } from "@ckb-ccc/ccc";
|
|
|
8
8
|
import { LitElement, css, html } from "lit";
|
|
9
9
|
import { customElement, property, state } from "lit/decorators.js";
|
|
10
10
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
11
|
+
import { NOSTR_SVG } from "../assets/chains/nostr.svg";
|
|
11
12
|
import { CLOSE_SVG } from "../assets/close.svg";
|
|
12
13
|
import { JOY_ID_SVG } from "../assets/joy-id.svg";
|
|
13
14
|
import { LEFT_SVG } from "../assets/left.svg";
|
|
@@ -111,7 +112,6 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
|
111
112
|
this.scene = Scene.SelectingWallets;
|
|
112
113
|
}
|
|
113
114
|
disconnect() {
|
|
114
|
-
this.signer?.signer?.disconnect();
|
|
115
115
|
this.walletName = undefined;
|
|
116
116
|
this.signerName = undefined;
|
|
117
117
|
this.saveConnection();
|
|
@@ -163,13 +163,18 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
|
163
163
|
reloadSigners() {
|
|
164
164
|
this.wallets = [];
|
|
165
165
|
(async () => {
|
|
166
|
-
|
|
166
|
+
const signer = this.signer;
|
|
167
|
+
if (!signer) {
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
if (await signer.signer.replaceClient(this.client)) {
|
|
171
|
+
this.signer = {
|
|
172
|
+
...signer,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.signer = undefined;
|
|
177
|
+
}
|
|
173
178
|
})();
|
|
174
179
|
this.resetListeners.forEach((listener) => listener());
|
|
175
180
|
this.resetListeners = [];
|
|
@@ -188,6 +193,10 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
|
188
193
|
if (okxBitcoinSigner) {
|
|
189
194
|
this.addSigner("OKX Wallet", "BTC", OKX_SVG, okxBitcoinSigner);
|
|
190
195
|
}
|
|
196
|
+
const nip07Signer = ccc.Nip07.getNip07Signer(this.client);
|
|
197
|
+
if (nip07Signer) {
|
|
198
|
+
this.addSigner("Nostr", "Nostr", NOSTR_SVG, nip07Signer);
|
|
199
|
+
}
|
|
191
200
|
const eip6963Manager = new ccc.Eip6963.SignerFactory(this.client);
|
|
192
201
|
this.resetListeners.push(eip6963Manager.subscribeSigners((signer) => {
|
|
193
202
|
this.addSigner(`${signer.detail.info.name}`, "EVM", signer.detail.info.icon, signer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signers.d.ts","sourceRoot":"","sources":["../../src/scenes/signers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"signers.d.ts","sourceRoot":"","sources":["../../src/scenes/signers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAKnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,GAAG,MAAM,CAO7D;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,EACzB,gBAAgB,EAAE,CAChB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,GAAG,CAAC,UAAU,KACnB,OAAO,gDA4Bb"}
|
package/dist/scenes/signers.js
CHANGED
|
@@ -2,11 +2,13 @@ import { ccc } from "@ckb-ccc/ccc";
|
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { repeat } from "lit/directives/repeat.js";
|
|
4
4
|
import { BTC_SVG, CKB_SVG, ETH_SVG } from "../assets/chains";
|
|
5
|
+
import { NOSTR_SVG } from "../assets/chains/nostr.svg";
|
|
5
6
|
export function signerTypeToIcon(type) {
|
|
6
7
|
return {
|
|
7
8
|
[ccc.SignerType.BTC]: BTC_SVG,
|
|
8
9
|
[ccc.SignerType.EVM]: ETH_SVG,
|
|
9
10
|
[ccc.SignerType.CKB]: CKB_SVG,
|
|
11
|
+
[ccc.SignerType.Nostr]: NOSTR_SVG,
|
|
10
12
|
}[type];
|
|
11
13
|
}
|
|
12
14
|
export function generateSignersScene(wallet, onSignerSelected) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-alpha.0",
|
|
4
4
|
"description": "Common Chains Connector UI",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ckb-ccc/ccc": "0.0.
|
|
40
|
+
"@ckb-ccc/ccc": "0.0.6-alpha.0",
|
|
41
41
|
"lit": "^3.1.3"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "2cbb4f450ed88e773a353a13ad006dbe6208f67f"
|
|
44
44
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { encodeSvgToImgSrc } from "../utils";
|
|
2
|
+
|
|
3
|
+
export const NOSTR_SVG = encodeSvgToImgSrc(
|
|
4
|
+
'<svg version="1.1" id="_8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" style="enable-background:new 0 0 256 256;" xml:space="preserve"><style type="text/css">.st0{fill:none;} .st1{fill:#FFFFFF;} .st2{fill:#662482;}</style><g><path class="st0" d="M0,0v256h256V0H0z M231.2,159.2c0,20.7,0,31.1-3.5,42.2c-4.4,12.2-14,21.8-26.2,26.2 c-11.1,3.5-21.5,3.5-42.2,3.5H96.8c-20.7,0-31.1,0-42.2-3.5c-12.2-4.4-21.8-14-26.2-26.2c-3.5-11.1-3.5-21.5-3.5-42.2V96.8 c0-20.7,0-31.1,3.5-42.2c4.4-12.2,14-21.8,26.2-26.2c11.2-3.5,21.5-3.5,42.2-3.5h62.5c20.7,0,31.1,0,42.2,3.5 c12.2,4.4,21.8,14,26.2,26.2c3.5,11.1,3.5,21.5,3.5,42.2V159.2z"/> <circle class="st1" cx="137.9" cy="99" r="12.1"/><path class="st1" d="M210.8,115.9c0-47.3-27.7-68.7-64.4-68.7c-16.4,0-31,4.4-42.4,12.5c-3.8,2.7-9,0.1-9-4.5 c0-3.1-2.5-5.7-5.7-5.7H57.7c-3.1,0-5.7,2.5-5.7,5.7v144c0,3.1,2.5,5.7,5.7,5.7h33.7c3.1,0,5.6-2.5,5.6-5.6v-8.4 c0-62.8-33.2-109.8-0.4-116c30-5.7,64.1-3,64.5,20.1c0,2,0.3,8,8.6,11.2c5,2,12.6,2.6,22.6,2.4c0,0,9.1-0.7,9.1,8.5 c0,11.5-20.4,10.7-20.4,10.7c-6.7,0.3-22.6-1.5-31.7,1.2c-4.8,1.5-9,4.2-11.5,9.1c-4.2,8.3-6.2,26.5-6.5,45.5v15.5 c0,3.1,2.5,5.7,5.7,5.7h68c3.1,0,5.7-2.5,5.7-5.7l0,0V115.9z"/><path class="st2" d="M227.6,54.6c-4.4-12.2-14-21.8-26.2-26.2c-11.1-3.5-21.5-3.5-42.2-3.5H96.8c-20.7,0-31.1,0-42.2,3.5 c-12.2,4.4-21.8,14-26.2,26.2c-3.5,11.2-3.5,21.5-3.5,42.2v62.5c0,20.7,0,31.1,3.5,42.2c4.4,12.2,14,21.8,26.2,26.2 c11.2,3.5,21.5,3.5,42.2,3.5h62.5c20.7,0,31.1,0,42.2-3.5c12.2-4.4,21.8-14,26.2-26.2c3.5-11.1,3.5-21.5,3.5-42.2V96.8 C231.2,76.1,231.2,65.7,227.6,54.6z M205.1,204.8h-68c-3.1,0-5.7-2.5-5.7-5.7v-15.5c0.3-19,2.3-37.2,6.5-45.5 c2.5-5,6.7-7.7,11.5-9.1c9-2.7,24.9-0.9,31.7-1.2c0,0,20.4,0.8,20.4-10.7c0-9.3-9.1-8.5-9.1-8.5c-10,0.3-17.7-0.4-22.6-2.4 c-8.3-3.3-8.6-9.2-8.6-11.2c-0.4-23.1-34.5-25.9-64.5-20.1c-32.8,6.2,0.4,53.3,0.4,116v8.4c-0.1,3.1-2.5,5.6-5.6,5.6H57.7 c-3.1,0-5.7-2.5-5.7-5.7v-144c0-3.1,2.5-5.7,5.7-5.7h31.7c3.1,0,5.7,2.5,5.7,5.7c0,4.7,5.2,7.2,9,4.5c11.4-8.2,26-12.5,42.4-12.5 c36.7,0,64.4,21.4,64.4,68.7v83.2l0,0C210.8,202.3,208.3,204.8,205.1,204.8z M125.7,99c0-6.7,5.4-12.1,12.1-12.1S150,92.3,150,99 s-5.4,12.1-12.1,12.1S125.7,105.8,125.7,99z"/></g></svg>',
|
|
5
|
+
);
|
package/src/connector/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ccc } from "@ckb-ccc/ccc";
|
|
|
2
2
|
import { LitElement, PropertyValues, css, html } from "lit";
|
|
3
3
|
import { customElement, property, state } from "lit/decorators.js";
|
|
4
4
|
import { Ref, createRef, ref } from "lit/directives/ref.js";
|
|
5
|
+
import { NOSTR_SVG } from "../assets/chains/nostr.svg";
|
|
5
6
|
import { CLOSE_SVG } from "../assets/close.svg";
|
|
6
7
|
import { JOY_ID_SVG } from "../assets/joy-id.svg";
|
|
7
8
|
import { LEFT_SVG } from "../assets/left.svg";
|
|
@@ -97,7 +98,6 @@ export class WebComponentConnector extends LitElement {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
public disconnect() {
|
|
100
|
-
this.signer?.signer?.disconnect();
|
|
101
101
|
this.walletName = undefined;
|
|
102
102
|
this.signerName = undefined;
|
|
103
103
|
this.saveConnection();
|
|
@@ -172,14 +172,18 @@ export class WebComponentConnector extends LitElement {
|
|
|
172
172
|
this.wallets = [];
|
|
173
173
|
|
|
174
174
|
(async () => {
|
|
175
|
-
|
|
175
|
+
const signer = this.signer;
|
|
176
|
+
if (!signer) {
|
|
176
177
|
return;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
if (await signer.signer.replaceClient(this.client)) {
|
|
181
|
+
this.signer = {
|
|
182
|
+
...signer,
|
|
183
|
+
};
|
|
184
|
+
} else {
|
|
185
|
+
this.signer = undefined;
|
|
186
|
+
}
|
|
183
187
|
})();
|
|
184
188
|
|
|
185
189
|
this.resetListeners.forEach((listener) => listener());
|
|
@@ -207,6 +211,11 @@ export class WebComponentConnector extends LitElement {
|
|
|
207
211
|
this.addSigner("OKX Wallet", "BTC", OKX_SVG, okxBitcoinSigner);
|
|
208
212
|
}
|
|
209
213
|
|
|
214
|
+
const nip07Signer = ccc.Nip07.getNip07Signer(this.client);
|
|
215
|
+
if (nip07Signer) {
|
|
216
|
+
this.addSigner("Nostr", "Nostr", NOSTR_SVG, nip07Signer);
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
const eip6963Manager = new ccc.Eip6963.SignerFactory(this.client);
|
|
211
220
|
this.resetListeners.push(
|
|
212
221
|
eip6963Manager.subscribeSigners((signer) => {
|
package/src/scenes/signers.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ccc } from "@ckb-ccc/ccc";
|
|
|
2
2
|
import { html } from "lit";
|
|
3
3
|
import { repeat } from "lit/directives/repeat.js";
|
|
4
4
|
import { BTC_SVG, CKB_SVG, ETH_SVG } from "../assets/chains";
|
|
5
|
+
import { NOSTR_SVG } from "../assets/chains/nostr.svg";
|
|
5
6
|
import { WalletWithSigners } from "../types";
|
|
6
7
|
|
|
7
8
|
export function signerTypeToIcon(type: ccc.SignerType): string {
|
|
@@ -9,6 +10,7 @@ export function signerTypeToIcon(type: ccc.SignerType): string {
|
|
|
9
10
|
[ccc.SignerType.BTC]: BTC_SVG,
|
|
10
11
|
[ccc.SignerType.EVM]: ETH_SVG,
|
|
11
12
|
[ccc.SignerType.CKB]: CKB_SVG,
|
|
13
|
+
[ccc.SignerType.Nostr]: NOSTR_SVG,
|
|
12
14
|
}[type];
|
|
13
15
|
}
|
|
14
16
|
|