@ckb-ccc/connector 0.0.9-alpha.2 → 0.0.10-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/index.d.ts +1 -0
- package/dist/assets/chains/index.d.ts.map +1 -1
- package/dist/assets/chains/index.js +1 -0
- package/dist/barrel.d.ts +2 -1
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +2 -1
- package/dist/components/button-pill.d.ts +7 -0
- package/dist/components/button-pill.d.ts.map +1 -0
- package/dist/components/button-pill.js +54 -0
- package/dist/components/button.d.ts +7 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +60 -0
- package/dist/components/copy-button.d.ts +10 -0
- package/dist/components/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button.js +76 -0
- package/dist/components/dialog.d.ts +8 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +103 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/connector/index.d.ts +8 -21
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +59 -496
- package/dist/scenes/connected.d.ts +12 -1
- package/dist/scenes/connected.d.ts.map +1 -1
- package/dist/scenes/connected.js +204 -59
- package/dist/scenes/index.d.ts +2 -3
- package/dist/scenes/index.d.ts.map +1 -1
- package/dist/scenes/index.js +2 -3
- package/dist/scenes/{connecting.d.ts → selecting/connecting.d.ts} +1 -1
- package/dist/scenes/selecting/connecting.d.ts.map +1 -0
- package/dist/scenes/{connecting.js → selecting/connecting.js} +5 -5
- package/dist/scenes/selecting/index.d.ts +19 -0
- package/dist/scenes/selecting/index.d.ts.map +1 -0
- package/dist/scenes/selecting/index.js +164 -0
- package/dist/scenes/{signers.d.ts → selecting/signers.d.ts} +1 -1
- package/dist/scenes/selecting/signers.d.ts.map +1 -0
- package/dist/scenes/{signers.js → selecting/signers.js} +6 -7
- package/dist/scenes/{wallets.d.ts → selecting/wallets.d.ts} +1 -1
- package/dist/scenes/selecting/wallets.d.ts.map +1 -0
- package/dist/scenes/{wallets.js → selecting/wallets.js} +3 -3
- package/dist/signers/index.d.ts +28 -0
- package/dist/signers/index.d.ts.map +1 -0
- package/dist/signers/index.js +104 -0
- package/package.json +3 -3
- package/src/assets/chains/index.ts +1 -0
- package/src/barrel.ts +3 -1
- package/src/components/button-pill.ts +48 -0
- package/src/components/button.ts +54 -0
- package/src/components/copy-button.ts +69 -0
- package/src/components/dialog.ts +97 -0
- package/src/components/index.ts +4 -0
- package/src/connector/index.ts +67 -596
- package/src/scenes/connected.ts +197 -68
- package/src/scenes/index.ts +2 -3
- package/src/scenes/{connecting.ts → selecting/connecting.ts} +6 -6
- package/src/scenes/selecting/index.ts +181 -0
- package/src/scenes/{signers.ts → selecting/signers.ts} +7 -8
- package/src/scenes/{wallets.ts → selecting/wallets.ts} +4 -4
- package/src/signers/index.ts +186 -0
- package/dist/assets/chains/ckb.sm.svg.d.ts +0 -2
- package/dist/assets/chains/ckb.sm.svg.d.ts.map +0 -1
- package/dist/assets/chains/ckb.sm.svg.js +0 -2
- package/dist/assets/copy.svg.d.ts +0 -2
- package/dist/assets/copy.svg.d.ts.map +0 -1
- package/dist/assets/copy.svg.js +0 -2
- package/dist/events/index.d.ts +0 -7
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/index.js +0 -10
- package/dist/scenes/connecting.d.ts.map +0 -1
- package/dist/scenes/signers.d.ts.map +0 -1
- package/dist/scenes/wallets.d.ts.map +0 -1
- package/src/assets/chains/ckb.sm.svg.ts +0 -5
- package/src/assets/copy.svg.ts +0 -5
- package/src/events/index.ts +0 -11
package/dist/connector/index.js
CHANGED
|
@@ -8,109 +8,23 @@ 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 {
|
|
12
|
-
import { CLOSE_SVG } from "../assets/close.svg";
|
|
13
|
-
import { JOY_ID_SVG } from "../assets/joy-id.svg";
|
|
14
|
-
import { LEFT_SVG } from "../assets/left.svg";
|
|
15
|
-
import { METAMASK_SVG } from "../assets/metamask.svg";
|
|
16
|
-
import { OKX_SVG } from "../assets/okx.svg";
|
|
17
|
-
import { UNI_SAT_SVG } from "../assets/uni-sat.svg";
|
|
18
|
-
import { ClosedEvent, WillUpdateEvent } from "../events";
|
|
19
|
-
import { generateConnectingScene, generateSignersScene, generateWalletsScene, } from "../scenes";
|
|
20
|
-
import { generateConnectedScene } from "../scenes/connected";
|
|
21
|
-
var Scene;
|
|
22
|
-
(function (Scene) {
|
|
23
|
-
Scene["SelectingWallets"] = "SelectingWallets";
|
|
24
|
-
Scene["SelectingSigners"] = "SelectingSigners";
|
|
25
|
-
Scene["Connecting"] = "Connecting";
|
|
26
|
-
Scene["Connected"] = "Connected";
|
|
27
|
-
})(Scene || (Scene = {}));
|
|
11
|
+
import { SignersController } from "../signers";
|
|
28
12
|
let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
29
13
|
constructor() {
|
|
30
14
|
super(...arguments);
|
|
31
|
-
this.wallets = [];
|
|
32
|
-
this.resetListeners = [];
|
|
33
15
|
this.client = new ccc.ClientPublicTestnet();
|
|
34
|
-
this.
|
|
16
|
+
this.signersController = new SignersController(this);
|
|
35
17
|
this.mainRef = createRef();
|
|
36
|
-
this.headerRef = createRef();
|
|
37
18
|
this.bodyRef = createRef();
|
|
38
|
-
this.closedHandler = () => {
|
|
39
|
-
if ([
|
|
40
|
-
Scene.SelectingSigners,
|
|
41
|
-
Scene.SelectingWallets,
|
|
42
|
-
Scene.Connecting,
|
|
43
|
-
].includes(this.scene)) {
|
|
44
|
-
this.scene = Scene.SelectingWallets;
|
|
45
|
-
this.selectedSigner = undefined;
|
|
46
|
-
this.selectedWallet = undefined;
|
|
47
|
-
}
|
|
48
|
-
this.dispatchEvent(new ClosedEvent());
|
|
49
|
-
};
|
|
50
|
-
this.signerSelectedHandler = (wallet, signerInfo) => {
|
|
51
|
-
this.scene = Scene.Connecting;
|
|
52
|
-
this.connectingError = undefined;
|
|
53
|
-
this.selectedWallet = wallet;
|
|
54
|
-
this.selectedSigner = signerInfo;
|
|
55
|
-
(async () => {
|
|
56
|
-
const { signer } = signerInfo;
|
|
57
|
-
try {
|
|
58
|
-
await signer.connect();
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
if (typeof error === "object") {
|
|
62
|
-
const message = error?.message;
|
|
63
|
-
if (typeof message === "string") {
|
|
64
|
-
this.connectingError = message;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.connectingError = JSON.stringify(message);
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.connectingError = JSON.stringify(error);
|
|
72
|
-
}
|
|
73
|
-
if (!(await signer.isConnected())) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
this.scene = Scene.Connected;
|
|
77
|
-
this.walletName = wallet.name;
|
|
78
|
-
this.signerName = signerInfo.name;
|
|
79
|
-
this.saveConnection();
|
|
80
|
-
this.closedHandler();
|
|
81
|
-
this.internalAddress = await signer.getInternalAddress();
|
|
82
|
-
this.recommendAddress = await signer.getRecommendedAddress();
|
|
83
|
-
this.balance = await signer.getBalance();
|
|
84
|
-
})();
|
|
85
|
-
};
|
|
86
19
|
}
|
|
87
20
|
setClient(client) {
|
|
88
21
|
this.client = client;
|
|
89
22
|
}
|
|
90
|
-
async updateSignerInfo() {
|
|
91
|
-
const signer = this.signer?.signer;
|
|
92
|
-
if (!signer) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.recommendAddress = await signer.getRecommendedAddress();
|
|
96
|
-
this.internalAddress = await signer.getInternalAddress();
|
|
97
|
-
this.balance = await signer.getBalance();
|
|
98
|
-
}
|
|
99
|
-
async prepareSigner() {
|
|
100
|
-
if (this.signer && (await this.signer.signer.isConnected())) {
|
|
101
|
-
await this.updateSignerInfo();
|
|
102
|
-
this.scene = Scene.Connected;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this.wallet = undefined;
|
|
106
|
-
this.signer = undefined;
|
|
107
|
-
this.scene = Scene.SelectingWallets;
|
|
108
|
-
}
|
|
109
23
|
disconnect() {
|
|
110
24
|
this.walletName = undefined;
|
|
111
25
|
this.signerName = undefined;
|
|
112
26
|
this.saveConnection();
|
|
113
|
-
this.
|
|
27
|
+
this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
|
|
114
28
|
this.signer?.signer.disconnect();
|
|
115
29
|
}
|
|
116
30
|
loadConnection() {
|
|
@@ -127,186 +41,78 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
|
127
41
|
connectedCallback() {
|
|
128
42
|
super.connectedCallback();
|
|
129
43
|
this.loadConnection();
|
|
130
|
-
this.reloadSigners();
|
|
131
|
-
// Delay for extensions to load
|
|
132
|
-
setTimeout(() => this.reloadSigners(), 100);
|
|
133
44
|
}
|
|
134
45
|
willUpdate(changedProperties) {
|
|
135
|
-
if (changedProperties.has("
|
|
46
|
+
if (changedProperties.has("name") ||
|
|
47
|
+
changedProperties.has("icon") ||
|
|
48
|
+
changedProperties.has("client") ||
|
|
136
49
|
changedProperties.has("signerFilter") ||
|
|
137
50
|
changedProperties.has("preferredNetworks")) {
|
|
138
|
-
this.
|
|
51
|
+
this.signersController.refresh();
|
|
139
52
|
}
|
|
140
|
-
if (
|
|
141
|
-
changedProperties.has("wallets") ||
|
|
142
|
-
changedProperties.has("walletName") ||
|
|
53
|
+
if (changedProperties.has("walletName") ||
|
|
143
54
|
changedProperties.has("signerName")) {
|
|
144
|
-
(
|
|
145
|
-
const wallet = this.wallets.find(({ name }) => name === this.walletName);
|
|
146
|
-
const signer = wallet?.signers.find(({ name }) => name === this.signerName);
|
|
147
|
-
if (signer && (await signer.signer.isConnected())) {
|
|
148
|
-
this.wallet = wallet;
|
|
149
|
-
this.signer = signer;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
this.wallet = undefined;
|
|
153
|
-
this.signer = undefined;
|
|
154
|
-
}
|
|
155
|
-
})();
|
|
55
|
+
this.refreshSigner();
|
|
156
56
|
}
|
|
157
|
-
|
|
158
|
-
this.prepareSigner();
|
|
159
|
-
}
|
|
160
|
-
this.dispatchEvent(new WillUpdateEvent());
|
|
57
|
+
this.dispatchEvent(new Event("willUpdate"));
|
|
161
58
|
}
|
|
162
|
-
|
|
163
|
-
this.wallets
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
if (!signer) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (await signer.signer.replaceClient(this.client)) {
|
|
170
|
-
this.signer = {
|
|
171
|
-
...signer,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
this.signer = undefined;
|
|
176
|
-
}
|
|
177
|
-
})();
|
|
178
|
-
this.resetListeners.forEach((listener) => listener());
|
|
179
|
-
this.resetListeners = [];
|
|
180
|
-
const name = this.name ??
|
|
181
|
-
document.querySelector("head title").text;
|
|
182
|
-
const icon = this.icon ??
|
|
183
|
-
document.querySelector('link[rel="icon"]').href;
|
|
184
|
-
const preferredNetworks = [
|
|
185
|
-
...(this.preferredNetworks ?? []),
|
|
186
|
-
{
|
|
187
|
-
addressPrefix: "ckb",
|
|
188
|
-
signerType: ccc.SignerType.BTC,
|
|
189
|
-
network: "btc",
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
addressPrefix: "ckt",
|
|
193
|
-
signerType: ccc.SignerType.BTC,
|
|
194
|
-
network: "btcTestnet",
|
|
195
|
-
},
|
|
196
|
-
];
|
|
197
|
-
ccc.JoyId.getJoyIdSigners(this.client, name, icon, preferredNetworks).forEach(({ signer, name }) => {
|
|
198
|
-
this.addSigner("JoyID", name, JOY_ID_SVG, signer);
|
|
199
|
-
});
|
|
200
|
-
const uniSatSigner = ccc.UniSat.getUniSatSigner(this.client, preferredNetworks);
|
|
201
|
-
if (uniSatSigner) {
|
|
202
|
-
this.addSigner("UniSat", "BTC", UNI_SAT_SVG, uniSatSigner);
|
|
203
|
-
}
|
|
204
|
-
ccc.Okx.getOKXBitcoinSigner(this.client, preferredNetworks).forEach((signer) => {
|
|
205
|
-
this.addSigner("OKX Wallet", signer.type, OKX_SVG, signer);
|
|
206
|
-
});
|
|
207
|
-
const nip07Signer = ccc.Nip07.getNip07Signer(this.client);
|
|
208
|
-
if (nip07Signer) {
|
|
209
|
-
this.addSigner("Nostr", "Nostr", NOSTR_SVG, nip07Signer);
|
|
210
|
-
}
|
|
211
|
-
const eip6963Manager = new ccc.Eip6963.SignerFactory(this.client);
|
|
212
|
-
this.resetListeners.push(eip6963Manager.subscribeSigners((signer) => {
|
|
213
|
-
this.addSigner(`${signer.detail.info.name}`, "EVM", signer.detail.info.icon, signer);
|
|
214
|
-
}));
|
|
215
|
-
// === Dummy signers ===
|
|
216
|
-
this.addSigner("MetaMask", "EVM", METAMASK_SVG, new ccc.SignerOpenLink(this.client, ccc.SignerType.EVM, `https://metamask.app.link/dapp/${window.location.href}`));
|
|
217
|
-
[ccc.SignerType.EVM, ccc.SignerType.BTC].forEach((type) => {
|
|
218
|
-
this.addSigner("OKX Wallet", type, OKX_SVG, new ccc.SignerOpenLink(this.client, type, "https://www.okx.com/download?deeplink=" +
|
|
219
|
-
encodeURIComponent("okx://wallet/dapp/url?dappUrl=" +
|
|
220
|
-
encodeURIComponent(window.location.href))));
|
|
221
|
-
});
|
|
222
|
-
this.addSigner("UniSat", ccc.SignerType.BTC, UNI_SAT_SVG, new ccc.SignerOpenLink(this.client, ccc.SignerType.BTC, "https://unisat.io/download"));
|
|
223
|
-
// ===
|
|
59
|
+
async refreshSigner() {
|
|
60
|
+
const wallet = this.signersController.wallets.find(({ name }) => name === this.walletName);
|
|
61
|
+
const signer = wallet?.signers.find(({ name }) => name === this.signerName);
|
|
62
|
+
this.updateSigner(wallet, signer);
|
|
224
63
|
}
|
|
225
|
-
async
|
|
226
|
-
|
|
227
|
-
if (this.signerFilter &&
|
|
228
|
-
!(await this.signerFilter(signerInfo, { name: walletName, icon }))) {
|
|
64
|
+
async updateSigner(wallet, signerInfo) {
|
|
65
|
+
if (signerInfo?.signer === this.signer?.signer) {
|
|
229
66
|
return;
|
|
230
67
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
...wallet,
|
|
241
|
-
signers: signers.length !== 0 ? signers : [signerInfo],
|
|
242
|
-
};
|
|
243
|
-
});
|
|
244
|
-
if (!updated) {
|
|
245
|
-
wallets.push({
|
|
246
|
-
name: walletName,
|
|
247
|
-
icon,
|
|
248
|
-
signers: [signerInfo],
|
|
68
|
+
this.unregisterSignerReplacer?.();
|
|
69
|
+
this.unregisterSignerReplacer = undefined;
|
|
70
|
+
if (signerInfo && (await signerInfo.signer.isConnected())) {
|
|
71
|
+
this.wallet = wallet;
|
|
72
|
+
this.signer = signerInfo;
|
|
73
|
+
this.unregisterSignerReplacer?.();
|
|
74
|
+
this.unregisterSignerReplacer = signerInfo.signer.onReplaced(() => {
|
|
75
|
+
this.signersController.refresh();
|
|
249
76
|
});
|
|
250
77
|
}
|
|
251
|
-
|
|
78
|
+
else {
|
|
79
|
+
this.wallet = undefined;
|
|
80
|
+
this.signer = undefined;
|
|
81
|
+
}
|
|
252
82
|
}
|
|
253
83
|
render() {
|
|
254
|
-
|
|
255
|
-
if (this.scene === Scene.Connected && this.wallet && this.signer) {
|
|
256
|
-
return generateConnectedScene(this.wallet, this.signer, this.recommendAddress, this.internalAddress, this.balance, this.disconnect.bind(this));
|
|
257
|
-
}
|
|
258
|
-
if (this.scene === Scene.SelectingWallets || !this.selectedWallet) {
|
|
259
|
-
return generateWalletsScene(this.wallets, (wallet) => {
|
|
260
|
-
this.selectedWallet = wallet;
|
|
261
|
-
this.scene = Scene.SelectingSigners;
|
|
262
|
-
}, this.signerSelectedHandler);
|
|
263
|
-
}
|
|
264
|
-
if (this.scene === Scene.SelectingSigners || !this.selectedSigner) {
|
|
265
|
-
return generateSignersScene(this.selectedWallet, this.signerSelectedHandler);
|
|
266
|
-
}
|
|
267
|
-
return generateConnectingScene(this.selectedWallet, this.selectedSigner, this.connectingError, this.signerSelectedHandler);
|
|
268
|
-
})();
|
|
269
|
-
const canBack = [Scene.SelectingSigners, Scene.Connecting].includes(this.scene);
|
|
270
|
-
return html ` <div
|
|
84
|
+
return html `<div
|
|
271
85
|
class="background"
|
|
272
86
|
@click=${(event) => {
|
|
273
87
|
if (event.target === event.currentTarget) {
|
|
274
|
-
this.
|
|
88
|
+
this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
|
|
89
|
+
this.bodyRef.value?.onClose?.();
|
|
275
90
|
}
|
|
276
91
|
}}
|
|
92
|
+
@updated=${() => this.updated()}
|
|
277
93
|
>
|
|
278
94
|
<div class="main" ${ref(this.mainRef)}>
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
}}
|
|
301
|
-
/>
|
|
302
|
-
${title}
|
|
303
|
-
<img
|
|
304
|
-
class="close active"
|
|
305
|
-
src=${CLOSE_SVG}
|
|
306
|
-
@click=${this.closedHandler}
|
|
307
|
-
/>
|
|
308
|
-
</div>
|
|
309
|
-
<div class="body" ${ref(this.bodyRef)}>${body}</div>
|
|
95
|
+
${this.wallet && this.signer
|
|
96
|
+
? html `
|
|
97
|
+
<ccc-connected-scene
|
|
98
|
+
.wallet=${this.wallet}
|
|
99
|
+
.signer=${this.signer.signer}
|
|
100
|
+
@disconnect=${() => this.disconnect()}
|
|
101
|
+
${ref(this.bodyRef)}
|
|
102
|
+
></ccc-connected-scene>
|
|
103
|
+
`
|
|
104
|
+
: html `
|
|
105
|
+
<ccc-selecting-scene
|
|
106
|
+
.wallets=${this.signersController.wallets}
|
|
107
|
+
@connected=${({ walletName, signerName }) => {
|
|
108
|
+
this.walletName = walletName;
|
|
109
|
+
this.signerName = signerName;
|
|
110
|
+
this.refreshSigner();
|
|
111
|
+
this.saveConnection();
|
|
112
|
+
}}
|
|
113
|
+
${ref(this.bodyRef)}
|
|
114
|
+
></ccc-selecting-scene>
|
|
115
|
+
`}
|
|
310
116
|
</div>
|
|
311
117
|
</div>`;
|
|
312
118
|
}
|
|
@@ -314,8 +120,7 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
|
|
|
314
120
|
if (!this.mainRef.value) {
|
|
315
121
|
return;
|
|
316
122
|
}
|
|
317
|
-
this.mainRef.value.style.height = `${
|
|
318
|
-
(this.headerRef.value?.clientHeight ?? 0)}px`;
|
|
123
|
+
this.mainRef.value.style.height = `${this.bodyRef.value?.clientHeight ?? 0}px`;
|
|
319
124
|
}
|
|
320
125
|
};
|
|
321
126
|
WebComponentConnector.styles = css `
|
|
@@ -327,62 +132,6 @@ WebComponentConnector.styles = css `
|
|
|
327
132
|
top: 0;
|
|
328
133
|
}
|
|
329
134
|
|
|
330
|
-
button {
|
|
331
|
-
background: none;
|
|
332
|
-
color: inherit;
|
|
333
|
-
border: none;
|
|
334
|
-
padding: 0;
|
|
335
|
-
font: inherit;
|
|
336
|
-
cursor: pointer;
|
|
337
|
-
outline: inherit;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
.text-bold {
|
|
341
|
-
font-weight: bold;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
.text-tip {
|
|
345
|
-
color: var(--tip-color);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.fs-sm {
|
|
349
|
-
font-size: 0.8rem;
|
|
350
|
-
}
|
|
351
|
-
.fs-md {
|
|
352
|
-
font-size: 1rem;
|
|
353
|
-
}
|
|
354
|
-
.fs-lg {
|
|
355
|
-
font-size: 1.2rem;
|
|
356
|
-
}
|
|
357
|
-
.fs-xl {
|
|
358
|
-
font-size: 1.5rem;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
.mb-1 {
|
|
362
|
-
margin-bottom: 0.7rem;
|
|
363
|
-
}
|
|
364
|
-
.mb-2 {
|
|
365
|
-
margin-bottom: 1rem;
|
|
366
|
-
}
|
|
367
|
-
.mt-1 {
|
|
368
|
-
margin-top: 0.7rem;
|
|
369
|
-
}
|
|
370
|
-
.mt-2 {
|
|
371
|
-
margin-top: 1rem;
|
|
372
|
-
}
|
|
373
|
-
.ml-1 {
|
|
374
|
-
margin-left: 0.7rem;
|
|
375
|
-
}
|
|
376
|
-
.ml-2 {
|
|
377
|
-
margin-left: 1em;
|
|
378
|
-
}
|
|
379
|
-
.mr-1 {
|
|
380
|
-
margin-right: 0.7rem;
|
|
381
|
-
}
|
|
382
|
-
.mr-2 {
|
|
383
|
-
margin-right: 1rem;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
135
|
.background {
|
|
387
136
|
width: 100%;
|
|
388
137
|
height: 100%;
|
|
@@ -399,202 +148,22 @@ WebComponentConnector.styles = css `
|
|
|
399
148
|
overflow: hidden;
|
|
400
149
|
transition: height 0.15s ease-out;
|
|
401
150
|
}
|
|
402
|
-
|
|
403
|
-
.header {
|
|
404
|
-
display: flex;
|
|
405
|
-
justify-content: space-between;
|
|
406
|
-
align-items: center;
|
|
407
|
-
padding: 1rem 1.3rem 0.5rem;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
.header-divider {
|
|
411
|
-
padding-bottom: 1rem;
|
|
412
|
-
border-bottom: 1px solid var(--divider);
|
|
413
|
-
margin-bottom: 1rem;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
.close,
|
|
417
|
-
.back {
|
|
418
|
-
width: 0.8rem;
|
|
419
|
-
height: 0.8rem;
|
|
420
|
-
opacity: 0;
|
|
421
|
-
transition: opacity 0.15s ease-in-out;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
.close.active,
|
|
425
|
-
.back.active {
|
|
426
|
-
opacity: 1;
|
|
427
|
-
cursor: pointer;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
.body {
|
|
431
|
-
padding: 0 1.3rem 1.4rem;
|
|
432
|
-
min-width: 20rem;
|
|
433
|
-
display: flex;
|
|
434
|
-
flex-direction: column;
|
|
435
|
-
align-items: center;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
.btn-primary {
|
|
439
|
-
width: 100%;
|
|
440
|
-
display: flex;
|
|
441
|
-
align-items: center;
|
|
442
|
-
justify-content: start;
|
|
443
|
-
padding: 0.75rem 1rem;
|
|
444
|
-
background: var(--btn-primary);
|
|
445
|
-
border-radius: 0.4rem;
|
|
446
|
-
transition: background 0.15s ease-in-out;
|
|
447
|
-
}
|
|
448
|
-
.btn-primary img {
|
|
449
|
-
width: 2rem;
|
|
450
|
-
height: 2rem;
|
|
451
|
-
margin-right: 1rem;
|
|
452
|
-
border-radius: 0.4rem;
|
|
453
|
-
}
|
|
454
|
-
.btn-primary:hover {
|
|
455
|
-
background: var(--btn-primary-hover);
|
|
456
|
-
}
|
|
457
|
-
.btn-primary:disabled {
|
|
458
|
-
cursor: not-allowed;
|
|
459
|
-
}
|
|
460
|
-
.btn-primary:disabled:hover {
|
|
461
|
-
background: var(--btn-primary);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.btn-secondary {
|
|
465
|
-
display: flex;
|
|
466
|
-
align-items: center;
|
|
467
|
-
padding: 0.25rem 1rem;
|
|
468
|
-
background: var(--btn-secondary);
|
|
469
|
-
border-radius: 9999px;
|
|
470
|
-
transition: background 0.15s ease-in-out;
|
|
471
|
-
}
|
|
472
|
-
.btn-secondary img {
|
|
473
|
-
width: 0.8rem;
|
|
474
|
-
height: 0.8rem;
|
|
475
|
-
margin-right: 0.5rem;
|
|
476
|
-
}
|
|
477
|
-
.btn-secondary:hover {
|
|
478
|
-
background: var(--btn-secondary-hover);
|
|
479
|
-
}
|
|
480
|
-
.btn-secondary:disabled {
|
|
481
|
-
cursor: not-allowed;
|
|
482
|
-
}
|
|
483
|
-
.btn-secondary:disabled:hover {
|
|
484
|
-
background: var(--btn-secondary);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
.wallet-icon {
|
|
488
|
-
width: 4rem;
|
|
489
|
-
height: 4rem;
|
|
490
|
-
margin-bottom: 0.5rem;
|
|
491
|
-
border-radius: 0.8rem;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
.connecting-wallet-icon {
|
|
495
|
-
width: 5rem;
|
|
496
|
-
height: 5rem;
|
|
497
|
-
border-radius: 1rem;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
.position-relative {
|
|
501
|
-
position: relative;
|
|
502
|
-
}
|
|
503
|
-
.position-absolute {
|
|
504
|
-
position: absolute;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
.connected-type-icon {
|
|
508
|
-
position: absolute;
|
|
509
|
-
width: 1.5rem;
|
|
510
|
-
height: 1.5rem;
|
|
511
|
-
right: -0.5rem;
|
|
512
|
-
bottom: -0.5rem;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
.text-center {
|
|
516
|
-
text-align: center;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
.cursor-pointer {
|
|
520
|
-
cursor: pointer;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
.flex {
|
|
524
|
-
display: flex;
|
|
525
|
-
}
|
|
526
|
-
.justify-center {
|
|
527
|
-
justify-content: center;
|
|
528
|
-
}
|
|
529
|
-
.justify-between {
|
|
530
|
-
justify-content: space-between;
|
|
531
|
-
}
|
|
532
|
-
.align-center {
|
|
533
|
-
align-items: center;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
.switch-btn-container {
|
|
537
|
-
width: 100%;
|
|
538
|
-
padding: 1rem;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
.switch-line {
|
|
542
|
-
flex: 1;
|
|
543
|
-
height: 1px;
|
|
544
|
-
background-color: var(--divider);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
.switching-status-dot {
|
|
548
|
-
width: 0.5rem;
|
|
549
|
-
height: 0.5rem;
|
|
550
|
-
background: #0f0;
|
|
551
|
-
border-radius: 50%;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
.copy-btn {
|
|
555
|
-
width: 1.5rem;
|
|
556
|
-
height: 1.5rem;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
.copy-btn-sm {
|
|
560
|
-
width: 1rem;
|
|
561
|
-
height: 1rem;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
.sm-chain-logo {
|
|
565
|
-
width: 1.125rem;
|
|
566
|
-
}
|
|
567
151
|
`;
|
|
568
|
-
__decorate([
|
|
569
|
-
state()
|
|
570
|
-
], WebComponentConnector.prototype, "wallets", void 0);
|
|
571
152
|
__decorate([
|
|
572
153
|
property()
|
|
573
|
-
], WebComponentConnector.prototype, "
|
|
154
|
+
], WebComponentConnector.prototype, "name", void 0);
|
|
574
155
|
__decorate([
|
|
575
156
|
property()
|
|
576
|
-
], WebComponentConnector.prototype, "
|
|
157
|
+
], WebComponentConnector.prototype, "icon", void 0);
|
|
577
158
|
__decorate([
|
|
578
159
|
property()
|
|
579
|
-
], WebComponentConnector.prototype, "
|
|
160
|
+
], WebComponentConnector.prototype, "preferredNetworks", void 0);
|
|
580
161
|
__decorate([
|
|
581
162
|
property()
|
|
582
|
-
], WebComponentConnector.prototype, "
|
|
163
|
+
], WebComponentConnector.prototype, "signerFilter", void 0);
|
|
583
164
|
__decorate([
|
|
584
165
|
state()
|
|
585
166
|
], WebComponentConnector.prototype, "client", void 0);
|
|
586
|
-
__decorate([
|
|
587
|
-
state()
|
|
588
|
-
], WebComponentConnector.prototype, "scene", void 0);
|
|
589
|
-
__decorate([
|
|
590
|
-
state()
|
|
591
|
-
], WebComponentConnector.prototype, "selectedWallet", void 0);
|
|
592
|
-
__decorate([
|
|
593
|
-
state()
|
|
594
|
-
], WebComponentConnector.prototype, "selectedSigner", void 0);
|
|
595
|
-
__decorate([
|
|
596
|
-
state()
|
|
597
|
-
], WebComponentConnector.prototype, "connectingError", void 0);
|
|
598
167
|
__decorate([
|
|
599
168
|
state()
|
|
600
169
|
], WebComponentConnector.prototype, "walletName", void 0);
|
|
@@ -609,13 +178,7 @@ __decorate([
|
|
|
609
178
|
], WebComponentConnector.prototype, "signer", void 0);
|
|
610
179
|
__decorate([
|
|
611
180
|
state()
|
|
612
|
-
], WebComponentConnector.prototype, "
|
|
613
|
-
__decorate([
|
|
614
|
-
state()
|
|
615
|
-
], WebComponentConnector.prototype, "internalAddress", void 0);
|
|
616
|
-
__decorate([
|
|
617
|
-
state()
|
|
618
|
-
], WebComponentConnector.prototype, "balance", void 0);
|
|
181
|
+
], WebComponentConnector.prototype, "unregisterSignerReplacer", void 0);
|
|
619
182
|
WebComponentConnector = __decorate([
|
|
620
183
|
customElement("ccc-connector")
|
|
621
184
|
], WebComponentConnector);
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/ccc";
|
|
2
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
3
|
export declare function formatString(str: string | undefined, l?: number, r?: number): string | undefined;
|
|
3
|
-
export declare
|
|
4
|
+
export declare class ConnectedScene extends LitElement {
|
|
5
|
+
wallet?: ccc.Wallet;
|
|
6
|
+
signer?: ccc.Signer;
|
|
7
|
+
private recommendedAddress?;
|
|
8
|
+
private internalAddress?;
|
|
9
|
+
private balance?;
|
|
10
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
11
|
+
render(): import("lit").TemplateResult<1>;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
updated(): void;
|
|
14
|
+
}
|
|
4
15
|
//# sourceMappingURL=connected.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/scenes/connected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/scenes/connected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAM5D,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,CAAC,SAAI,EACL,CAAC,SAAI,GACJ,MAAM,GAAG,SAAS,CAKpB;AAED,qBACa,cAAe,SAAQ,UAAU;IAErC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAG3B,OAAO,CAAC,kBAAkB,CAAC,CAAS;IAEpC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAUzD,MAAM;IAkEN,MAAM,CAAC,MAAM,0BAmGX;IAEF,OAAO;CAGR"}
|