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