@mysten-incubation/dev-wallet 0.5.1 → 0.6.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +7 -4
  3. package/dist/client/connected-apps.d.mts +35 -0
  4. package/dist/client/connected-apps.d.mts.map +1 -0
  5. package/dist/client/connected-apps.mjs +50 -0
  6. package/dist/client/connected-apps.mjs.map +1 -0
  7. package/dist/client/dev-wallet-client.mjs +1 -1
  8. package/dist/client/dev-wallet-client.mjs.map +1 -1
  9. package/dist/client/index.d.mts +2 -1
  10. package/dist/client/index.mjs +2 -1
  11. package/dist/client/request-handler.d.mts +7 -0
  12. package/dist/client/request-handler.d.mts.map +1 -1
  13. package/dist/client/request-handler.mjs +17 -2
  14. package/dist/client/request-handler.mjs.map +1 -1
  15. package/dist/standalone/assets/{in-memory-adapter-Ban2kRYS.js → in-memory-adapter-uuWG4K4k.js} +1 -1
  16. package/dist/standalone/assets/main-CKYv0eR6.js +7 -0
  17. package/dist/standalone/assets/{webcrypto-adapter-Ddqn-RAu.js → webcrypto-adapter-5ShaPc_M.js} +1 -1
  18. package/dist/standalone/bookmarklet.js +1 -1
  19. package/dist/standalone/index.html +1 -1
  20. package/dist/ui/dev-wallet-balances.d.mts.map +1 -1
  21. package/dist/ui/dev-wallet-balances.mjs +20 -13
  22. package/dist/ui/dev-wallet-balances.mjs.map +1 -1
  23. package/dist/ui/dev-wallet-connect-guide.d.mts +29 -0
  24. package/dist/ui/dev-wallet-connect-guide.d.mts.map +1 -0
  25. package/dist/ui/dev-wallet-connect-guide.mjs +386 -0
  26. package/dist/ui/dev-wallet-connect-guide.mjs.map +1 -0
  27. package/dist/ui/dev-wallet-connected-apps.d.mts +27 -0
  28. package/dist/ui/dev-wallet-connected-apps.d.mts.map +1 -0
  29. package/dist/ui/dev-wallet-connected-apps.mjs +164 -0
  30. package/dist/ui/dev-wallet-connected-apps.mjs.map +1 -0
  31. package/dist/ui/dev-wallet-panel.d.mts.map +1 -1
  32. package/dist/ui/dev-wallet-panel.mjs +0 -9
  33. package/dist/ui/dev-wallet-panel.mjs.map +1 -1
  34. package/dist/ui/dev-wallet-settings.d.mts +8 -2
  35. package/dist/ui/dev-wallet-settings.d.mts.map +1 -1
  36. package/dist/ui/dev-wallet-settings.mjs +86 -171
  37. package/dist/ui/dev-wallet-settings.mjs.map +1 -1
  38. package/dist/ui/dev-wallet-standalone.d.mts +7 -2
  39. package/dist/ui/dev-wallet-standalone.d.mts.map +1 -1
  40. package/dist/ui/dev-wallet-standalone.mjs +68 -222
  41. package/dist/ui/dev-wallet-standalone.mjs.map +1 -1
  42. package/dist/ui/index.d.mts +3 -1
  43. package/dist/ui/index.mjs +3 -1
  44. package/dist/ui/wallet-controller.mjs +15 -3
  45. package/dist/ui/wallet-controller.mjs.map +1 -1
  46. package/dist/wallet/dev-wallet.d.mts +15 -3
  47. package/dist/wallet/dev-wallet.d.mts.map +1 -1
  48. package/dist/wallet/dev-wallet.mjs +94 -30
  49. package/dist/wallet/dev-wallet.mjs.map +1 -1
  50. package/dist/wallet/persisted.mjs +20 -0
  51. package/dist/wallet/persisted.mjs.map +1 -0
  52. package/package.json +6 -6
  53. package/src/app/main.ts +6 -2
  54. package/src/client/connected-apps.ts +79 -0
  55. package/src/client/dev-wallet-client.ts +2 -1
  56. package/src/client/index.ts +2 -0
  57. package/src/client/request-handler.ts +24 -1
  58. package/src/ui/dev-wallet-balances.ts +25 -13
  59. package/src/ui/dev-wallet-connect-guide.ts +428 -0
  60. package/src/ui/dev-wallet-connected-apps.ts +191 -0
  61. package/src/ui/dev-wallet-panel.ts +0 -9
  62. package/src/ui/dev-wallet-settings.ts +101 -179
  63. package/src/ui/dev-wallet-standalone.ts +80 -231
  64. package/src/ui/index.ts +2 -0
  65. package/src/ui/wallet-controller.ts +23 -3
  66. package/src/wallet/dev-wallet.ts +130 -39
  67. package/src/wallet/persisted.ts +24 -0
  68. package/dist/standalone/assets/main-xfzarPod.js +0 -7
@@ -1,14 +1,19 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { css, html, LitElement } from 'lit';
4
+ import { css, html, LitElement, nothing } from 'lit';
5
5
  import { customElement, property } from 'lit/decorators.js';
6
6
 
7
7
  import type { DevWallet } from '../wallet/dev-wallet.js';
8
+ import type { ConnectedAppsStore } from '../client/connected-apps.js';
9
+ import './dev-wallet-connect-guide.js';
10
+ import './dev-wallet-connected-apps.js';
8
11
  import { connectDialogStyles, sharedStyles } from './styles.js';
9
12
  import type { CoinRecord } from './utils.js';
10
13
  import { WalletController } from './wallet-controller.js';
11
14
 
15
+ const DOCS_URL = 'https://ts-sdks-incubation.vercel.app/dev-wallet';
16
+
12
17
  @customElement('dev-wallet-standalone')
13
18
  export class DevWalletStandalone extends LitElement {
14
19
  static override styles = [
@@ -29,147 +34,65 @@ export class DevWalletStandalone extends LitElement {
29
34
  background-position: -1px -1px;
30
35
  }
31
36
 
37
+ /* Wallet centered: connect help on the left, connected apps on the right. */
32
38
  .standalone-layout {
33
39
  width: 100%;
34
- max-width: 1220px;
35
- min-height: calc(100vh - 48px);
36
40
  margin: 0 auto;
37
41
  padding: 24px 0;
38
42
  display: grid;
39
- grid-template-columns: minmax(240px, 1fr) 480px minmax(260px, 1fr);
40
- gap: 20px;
43
+ grid-template-columns: minmax(0, 1fr) 480px minmax(0, 1fr);
44
+ gap: 36px;
41
45
  align-items: start;
42
46
  }
43
47
 
44
- .rail {
45
- min-width: 0;
46
- display: flex;
47
- flex-direction: column;
48
- gap: 16px;
49
- padding-top: 6px;
50
- }
51
-
52
- .wordmark {
53
- display: flex;
54
- align-items: center;
55
- gap: 10px;
56
- }
57
-
58
- .logo-mark {
59
- width: 28px;
60
- height: 28px;
61
- border-radius: 9px;
62
- display: inline-flex;
63
- align-items: center;
64
- justify-content: center;
65
- color: var(--dev-wallet-primary-foreground);
66
- background:
67
- radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.5), transparent 24px),
68
- linear-gradient(135deg, var(--dev-wallet-primary), var(--dev-wallet-teal));
69
- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
70
- }
71
-
72
- .logo-mark svg {
73
- width: 18px;
74
- height: 18px;
75
- }
76
-
77
- .wordmark-title {
78
- display: flex;
79
- flex-direction: column;
80
- line-height: 1.1;
48
+ .card {
49
+ grid-column: 2;
81
50
  }
82
51
 
83
- .wordmark-title strong {
84
- font-size: 16px;
85
- font-weight: var(--dev-wallet-font-weight-semibold);
52
+ .rail-left {
53
+ grid-column: 1;
54
+ justify-self: end;
55
+ width: 100%;
86
56
  }
87
57
 
88
- .version {
89
- font-family: var(--dev-wallet-font-mono);
90
- font-size: 9px;
91
- letter-spacing: 0.12em;
92
- text-transform: uppercase;
93
- color: var(--dev-wallet-text-3);
58
+ .rail-right {
59
+ grid-column: 3;
94
60
  }
95
61
 
96
- .rail-section {
62
+ .rail {
63
+ max-width: 348px;
64
+ min-width: 0;
97
65
  display: flex;
98
66
  flex-direction: column;
99
- gap: 8px;
100
- }
101
-
102
- .rail-title {
103
- font-family: var(--dev-wallet-font-mono);
104
- font-size: 10px;
105
- font-weight: var(--dev-wallet-font-weight-medium);
106
- letter-spacing: 0.14em;
107
- text-transform: uppercase;
108
- color: var(--dev-wallet-text-3);
109
- }
110
-
111
- .code {
112
- margin: 0;
113
- overflow: auto;
114
- white-space: pre;
115
- padding: 10px 12px;
116
- border-radius: var(--dev-wallet-radius);
117
- border: 1px solid var(--dev-wallet-border);
118
- background: var(--dev-wallet-bg-0);
119
- color: var(--dev-wallet-foreground);
120
- font-family: var(--dev-wallet-font-mono);
121
- font-size: 11.5px;
67
+ gap: 24px;
68
+ padding-top: 8px;
69
+ font-size: 12px;
122
70
  line-height: 1.55;
71
+ color: var(--dev-wallet-muted-foreground);
123
72
  }
124
73
 
125
- .status-list {
74
+ .about {
75
+ padding-top: 16px;
76
+ border-top: 1px solid var(--dev-wallet-border);
126
77
  display: flex;
127
78
  flex-direction: column;
128
79
  gap: 6px;
80
+ font-size: 11px;
81
+ color: var(--dev-wallet-text-3);
129
82
  }
130
83
 
131
- .status-row {
132
- display: flex;
133
- align-items: center;
134
- gap: 8px;
135
- min-width: 0;
136
- padding: 8px 10px;
137
- border-radius: var(--dev-wallet-radius-lg);
138
- border: 1px solid var(--dev-wallet-border);
139
- background: color-mix(in srgb, var(--dev-wallet-bg-1) 88%, transparent);
140
- }
141
-
142
- .status-dot {
143
- width: 7px;
144
- height: 7px;
145
- border-radius: 999px;
146
- background: var(--dev-wallet-status-connected);
147
- flex-shrink: 0;
148
- }
149
-
150
- .status-dot.mute {
151
- background: var(--dev-wallet-text-3);
152
- }
153
-
154
- .status-copy {
155
- min-width: 0;
156
- display: flex;
157
- flex-direction: column;
158
- gap: 1px;
84
+ .about code {
85
+ font-family: var(--dev-wallet-font-mono);
86
+ font-size: 10.5px;
87
+ color: var(--dev-wallet-muted-foreground);
159
88
  }
160
89
 
161
- .status-copy strong {
162
- font-size: 12px;
163
- font-weight: var(--dev-wallet-font-weight-medium);
90
+ .about a {
91
+ color: var(--dev-wallet-muted-foreground);
164
92
  }
165
93
 
166
- .status-copy span {
167
- font-family: var(--dev-wallet-font-mono);
168
- font-size: 10.5px;
169
- color: var(--dev-wallet-text-3);
170
- overflow: hidden;
171
- text-overflow: ellipsis;
172
- white-space: nowrap;
94
+ .about a:hover {
95
+ color: var(--dev-wallet-foreground);
173
96
  }
174
97
 
175
98
  .card {
@@ -208,19 +131,6 @@ export class DevWalletStandalone extends LitElement {
208
131
  margin-left: auto;
209
132
  }
210
133
 
211
- .status-dot {
212
- width: 8px;
213
- height: 8px;
214
- border-radius: 50%;
215
- background: var(--dev-wallet-status-connected);
216
- }
217
-
218
- .status-text {
219
- font-family: var(--dev-wallet-font-mono);
220
- font-size: 10.5px;
221
- color: var(--dev-wallet-muted-foreground);
222
- }
223
-
224
134
  .card-body {
225
135
  overflow-y: auto;
226
136
  flex: 1;
@@ -237,12 +147,18 @@ export class DevWalletStandalone extends LitElement {
237
147
  border-bottom: 0;
238
148
  }
239
149
 
240
- @media (max-width: 1020px) {
150
+ /* Too narrow to keep the wallet centered with the aside beside it:
151
+ hide the aside. The Settings tab carries the same connect guide. */
152
+ @media (max-width: 1240px) {
241
153
  .standalone-layout {
242
154
  grid-template-columns: minmax(0, 480px);
243
155
  justify-content: center;
244
156
  }
245
157
 
158
+ .card {
159
+ grid-column: 1;
160
+ }
161
+
246
162
  .rail {
247
163
  display: none;
248
164
  }
@@ -254,7 +170,6 @@ export class DevWalletStandalone extends LitElement {
254
170
  }
255
171
 
256
172
  .standalone-layout {
257
- min-height: calc(100vh - 24px);
258
173
  padding: 0;
259
174
  }
260
175
 
@@ -269,9 +184,10 @@ export class DevWalletStandalone extends LitElement {
269
184
  @property({ attribute: false })
270
185
  wallet: DevWallet | null = null;
271
186
 
272
- /** When set, the settings tab shows a bookmarklet section pointing to this origin. */
187
+ /** Origin this wallet is served from. Drives the bookmarklet, console
188
+ * script, and dApp Kit snippet. Defaults to the page's own origin. */
273
189
  @property({ type: String })
274
- bookmarkletOrigin = '';
190
+ walletOrigin = globalThis.location?.origin ?? '';
275
191
 
276
192
  /** Optional pre-seeded coin metadata. Pass the generated `coins`
277
193
  * constant from devstack codegen to skip per-coin RPC fetches in the
@@ -279,14 +195,22 @@ export class DevWalletStandalone extends LitElement {
279
195
  @property({ attribute: false })
280
196
  coins: CoinRecord | null = null;
281
197
 
198
+ /** Connected-dApps store shared with the signing popup. Pass the same
199
+ * store to `parseWalletRequest` so Disconnect takes effect. */
200
+ @property({ attribute: false })
201
+ connectedApps: ConnectedAppsStore | null = null;
202
+
282
203
  #ctrl = new WalletController(this);
283
204
 
284
205
  override willUpdate(changedProperties: Map<string, unknown>) {
285
206
  if (changedProperties.has('wallet')) {
286
207
  this.#ctrl.wallet = this.wallet;
287
208
  }
288
- if (changedProperties.has('bookmarkletOrigin')) {
289
- this.#ctrl.bookmarkletOrigin = this.bookmarkletOrigin;
209
+ if (changedProperties.has('walletOrigin')) {
210
+ this.#ctrl.walletOrigin = this.walletOrigin;
211
+ }
212
+ if (changedProperties.has('connectedApps')) {
213
+ this.#ctrl.connectedApps = this.connectedApps;
290
214
  }
291
215
  if (changedProperties.has('coins')) {
292
216
  this.#ctrl.coins = this.coins;
@@ -305,116 +229,41 @@ export class DevWalletStandalone extends LitElement {
305
229
  override render() {
306
230
  return html`
307
231
  <div class="standalone-layout">
308
- <aside class="rail">${this.#renderLeftRail()}</aside>
309
- <div class="card" part="card">
232
+ <aside class="rail rail-left">
233
+ <dev-wallet-connect-guide .origin=${this.walletOrigin}></dev-wallet-connect-guide>
234
+ ${this.#renderAbout()}
235
+ </aside>
236
+ <main class="card" part="card">
310
237
  <div class="card-header">
311
- <span class="logo-mark">${this.#walletIcon}</span>
312
- <span class="wordmark-title">
313
- <span class="card-title">${this.wallet?.name ?? 'Dev Wallet'}</span>
314
- <span class="version">v0.1.0</span>
315
- </span>
316
- <div class="header-right">
317
- ${this.#ctrl.renderNetworkBadge()}
318
- <span class="status-dot"></span>
319
- <span class="status-text">Running</span>
320
- </div>
238
+ <span class="card-title">${this.wallet?.name ?? 'Dev Wallet'}</span>
239
+ <div class="header-right">${this.#ctrl.renderNetworkBadge()}</div>
321
240
  </div>
322
241
  ${this.#ctrl.renderTabBar()}
323
242
  <div class="card-body">${this.#ctrl.renderTabContent()}</div>
324
- </div>
325
- <aside class="rail">${this.#renderRightRail()}</aside>
243
+ </main>
244
+ <aside class="rail rail-right">
245
+ <dev-wallet-connected-apps .store=${this.connectedApps}></dev-wallet-connected-apps>
246
+ </aside>
326
247
  </div>
327
248
  ${this.#ctrl.renderSigningModal()} ${this.#ctrl.renderConnectPicker()}
328
249
  `;
329
250
  }
330
251
 
331
- #renderLeftRail() {
332
- const origin = this.bookmarkletOrigin || globalThis.location?.origin || 'http://localhost:5174';
333
- const quickStart = `npx @mysten-incubation/dev-wallet serve\n${origin}`;
334
- const clientSnippet = `createDAppKit({
335
- walletInitializers: [
336
- devWalletClientInitializer({
337
- origin: '${origin}'
338
- })
339
- ]
340
- })`;
341
- const embeddingSnippet = `createDAppKit({
342
- networks: ['devnet'],
343
- walletInitializers: [
344
- devWalletInitializer({
345
- adapters: [
346
- new WebCryptoSignerAdapter()
347
- ],
348
- autoConnect: true,
349
- mountUI: true
350
- })
351
- ]
352
- })`;
353
- return html`
354
- <div class="wordmark">
355
- <span class="logo-mark">${this.#walletIcon}</span>
356
- <span class="wordmark-title">
357
- <strong>Dev Wallet</strong>
358
- <span class="version">v0.1.0</span>
359
- </span>
360
- </div>
361
- <div class="rail-section">
362
- <div class="rail-title">Quick Start</div>
363
- <pre class="code">${quickStart}</pre>
364
- </div>
365
- <div class="rail-section">
366
- <div class="rail-title">Embed Wallet</div>
367
- <pre class="code">${embeddingSnippet}</pre>
368
- </div>
369
- <div class="rail-section">
370
- <div class="rail-title">Standalone Client</div>
371
- <pre class="code">${clientSnippet}</pre>
372
- </div>
373
- <div class="rail-section">
374
- <div class="rail-title">Bookmarklet Endpoint</div>
375
- <pre class="code">${origin}/bookmarklet.js</pre>
376
- </div>
377
- `;
378
- }
379
-
380
- #renderRightRail() {
381
- const activeNetwork = this.wallet?.activeNetwork ?? 'devnet';
382
- const networkUrl = this.wallet?.networkUrls[activeNetwork] ?? 'client configured by dApp Kit';
383
- const accountCount = this.wallet?.accounts.length ?? 0;
384
- const adapterCount = this.wallet?.adapters.length ?? 0;
385
- const adapterNames =
386
- this.wallet?.adapters.map((adapter) => adapter.name).join(', ') ?? 'No adapters';
252
+ #renderAbout() {
253
+ const isLocal = /^https?:\/\/(localhost|127\.0\.0\.1)(:|$)/.test(this.walletOrigin);
387
254
  return html`
388
- <div class="rail-section">
389
- <div class="rail-title">Wallet Status</div>
390
- <div class="status-list">
391
- <div class="status-row">
392
- <span class="status-dot"></span>
393
- <span class="status-copy">
394
- <strong>Network: ${activeNetwork}</strong>
395
- <span>${networkUrl}</span>
396
- </span>
397
- </div>
398
- <div class="status-row">
399
- <span class="status-dot mute"></span>
400
- <span class="status-copy">
401
- <strong>${accountCount} account(s)</strong>
402
- <span>${adapterCount} adapter(s): ${adapterNames}</span>
403
- </span>
404
- </div>
405
- </div>
406
- </div>
255
+ <footer class="about">
256
+ <span>Keys are stored in this browser only. Don't hold real funds here.</span>
257
+ ${isLocal
258
+ ? nothing
259
+ : html`<span>
260
+ For your <code>sui</code> CLI keys or localnet, run it locally:
261
+ <code>npx @mysten-incubation/dev-wallet serve</code>
262
+ </span>`}
263
+ <a href=${DOCS_URL} target="_blank" rel="noopener noreferrer">Documentation ↗</a>
264
+ </footer>
407
265
  `;
408
266
  }
409
-
410
- get #walletIcon() {
411
- return html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
412
- <rect x="2" y="6" width="20" height="14" rx="2.5" />
413
- <path d="M2 10h20" />
414
- <rect x="15" y="12" width="5" height="4" rx="1" />
415
- <circle cx="17.5" cy="14" r="0.5" fill="currentColor" stroke="none" />
416
- </svg>`;
417
- }
418
267
  }
419
268
 
420
269
  declare global {
package/src/ui/index.ts CHANGED
@@ -5,6 +5,8 @@ export { DevWalletPanel } from './dev-wallet-panel.js';
5
5
  export { DevWalletAccounts } from './dev-wallet-accounts.js';
6
6
  export { DevWalletBalances } from './dev-wallet-balances.js';
7
7
  export { DevWalletConnect } from './dev-wallet-connect.js';
8
+ export { DevWalletConnectGuide } from './dev-wallet-connect-guide.js';
9
+ export { DevWalletConnectedApps } from './dev-wallet-connected-apps.js';
8
10
  export { DevWalletNewAccount } from './dev-wallet-new-account.js';
9
11
  export { DevWalletObjects } from './dev-wallet-objects.js';
10
12
  export { DevWalletPopup } from './dev-wallet-popup.js';
@@ -7,6 +7,7 @@ import { html, nothing } from 'lit';
7
7
  import type { ReactiveController, ReactiveControllerHost } from 'lit';
8
8
 
9
9
  import type { ForkRelay } from '../adapters/fork-relay.js';
10
+ import type { ConnectedAppsStore } from '../client/connected-apps.js';
10
11
  import { getNetworkFromChain } from '../wallet/constants.js';
11
12
  import type {
12
13
  DevWallet,
@@ -41,7 +42,11 @@ export class WalletController implements ReactiveController {
41
42
  activeAccountIndex = 0;
42
43
  pendingRequest: PendingSigningRequest | null = null;
43
44
  pendingConnect: PendingConnectRequest | null = null;
44
- bookmarkletOrigin = '';
45
+ /** Origin of a standalone/hosted wallet. When set, Settings leads with the
46
+ * connect guide (bookmarklet + dApp Kit snippet). */
47
+ walletOrigin = '';
48
+ /** Connected-dApps store for a standalone wallet; listed in Settings. */
49
+ connectedApps: ConnectedAppsStore | null = null;
45
50
  /** Pre-seeded coin metadata (typically the generated `coins` constant from
46
51
  * devstack codegen). Forwarded to `<dev-wallet-balances>` and the
47
52
  * signing modal so they can skip per-coin RPC waterfalls. */
@@ -58,6 +63,7 @@ export class WalletController implements ReactiveController {
58
63
  forkUpstream = '';
59
64
 
60
65
  #wallet: DevWallet | null = null;
66
+ #networkKey = '';
61
67
  #unsubscribeEvents: (() => void) | null = null;
62
68
  #unsubscribeRequests: (() => void) | null = null;
63
69
  #unsubscribeConnect: (() => void) | null = null;
@@ -103,11 +109,23 @@ export class WalletController implements ReactiveController {
103
109
  newAccounts.length !== this.accounts.length ||
104
110
  newAccounts.some((a, i) => a.address !== this.accounts[i]?.address);
105
111
  const pendingChanged = newPending !== this.pendingRequest;
112
+ // Network switches and network add/remove only emit `change`; without
113
+ // this the badge, balances client, and faucet stay on the old network.
114
+ const networkKey = `${this.#wallet.activeNetwork}|${this.#wallet.availableNetworks.join(',')}`;
115
+ const networkChanged = networkKey !== this.#networkKey;
116
+ this.#networkKey = networkKey;
106
117
 
107
- if (!accountsChanged && !pendingChanged) return;
118
+ if (!accountsChanged && !pendingChanged && !networkChanged) return;
108
119
 
109
120
  if (accountsChanged) {
121
+ const hadAccounts = this.accounts.length > 0;
110
122
  this.accounts = [...newAccounts];
123
+ // Restore the persisted active account once accounts first load.
124
+ const persisted = this.#wallet.activeAccount;
125
+ const restored = persisted ? newAccounts.findIndex((a) => a.address === persisted) : -1;
126
+ if (!hadAccounts && restored !== -1) {
127
+ this.activeAccountIndex = restored;
128
+ }
111
129
  // Clamp activeAccountIndex when accounts shrink
112
130
  if (this.activeAccountIndex >= newAccounts.length && newAccounts.length > 0) {
113
131
  this.activeAccountIndex = newAccounts.length - 1;
@@ -177,6 +195,7 @@ export class WalletController implements ReactiveController {
177
195
  const index = this.accounts.findIndex((a) => a.address === e.detail.account.address);
178
196
  if (index !== -1) {
179
197
  this.activeAccountIndex = index;
198
+ this.#wallet?.setActiveAccount(e.detail.account.address);
180
199
  this.host.requestUpdate();
181
200
  }
182
201
  }
@@ -263,7 +282,8 @@ export class WalletController implements ReactiveController {
263
282
  .accounts=${this.accounts}
264
283
  .adapters=${this.#wallet ? [...this.#wallet.adapters] : []}
265
284
  .activeAddress=${this.activeAddress}
266
- .bookmarkletOrigin=${this.bookmarkletOrigin}
285
+ .walletOrigin=${this.walletOrigin}
286
+ .connectedApps=${this.connectedApps}
267
287
  @account-selected=${(e: CustomEvent) => this.handleAccountSelected(e)}
268
288
  ></dev-wallet-settings>
269
289
  `;