@solana-mobile/wallet-standard-mobile 0.5.1 → 0.5.3

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.
@@ -21,167 +21,66 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
+ let _solana_mobile_mobile_wallet_adapter_protocol_encoding = require("@solana-mobile/mobile-wallet-adapter-protocol/encoding");
25
+ let _solana_wallet_standard_chains = require("@solana/wallet-standard-chains");
26
+ let _wallet_standard_wallet = require("@wallet-standard/wallet");
27
+ let _solana_mobile_mobile_wallet_adapter_protocol = require("@solana-mobile/mobile-wallet-adapter-protocol");
24
28
  let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
29
+ let _wallet_standard_features = require("@wallet-standard/features");
25
30
  let qrcode = require("qrcode");
26
31
  qrcode = __toESM(qrcode);
27
- let _solana_mobile_mobile_wallet_adapter_protocol = require("@solana-mobile/mobile-wallet-adapter-protocol");
28
- let _wallet_standard_features = require("@wallet-standard/features");
29
- let bs58 = require("bs58");
30
- bs58 = __toESM(bs58);
31
- let _wallet_standard_wallet = require("@wallet-standard/wallet");
32
- let _solana_wallet_standard_chains = require("@solana/wallet-standard-chains");
33
- //#region src/embedded-modal/loadingSpinner.ts
34
- const modalHtml$1 = `
35
- <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
36
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
37
- <div class="mobile-wallet-adapter-embedded-loading-container">
38
- <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
39
- </div>
40
- </div>
41
- `;
42
- const css$6 = `
43
- .mobile-wallet-adapter-embedded-loading-indicator {
44
- display: flex; /* Use flexbox to center content */
45
- justify-content: center; /* Center horizontally */
46
- align-items: start; /* Center vertically */
47
- position: fixed; /* Stay in place */
48
- z-index: 1; /* Sit on top */
49
- left: 0;
50
- top: 0;
51
- width: 100%; /* Full width */
52
- height: 100%; /* Full height */
53
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
54
- overflow-y: auto; /* enable scrolling */
55
- }
56
-
57
- .mobile-wallet-adapter-embedded-loading-container {
58
- display: flex;
59
- margin: auto;
60
- }
61
-
62
- .mobile-wallet-adapter-embedded-loading-animation {
63
- position: relative;
64
- left: -9999px;
65
- width: 10px;
66
- height: 10px;
67
- border-radius: 5px;
68
- background-color: var(--spinner-color);
69
- color: var(--spinner-color);
70
- box-shadow: 9984px 0 0 0 var(--spinner-color),
71
- 9999px 0 0 0 var(--spinner-color),
72
- 10014px 0 0 0 var(--spinner-color);
73
- animation: dot-typing 1.5s infinite linear;
32
+ //#region src/createDefaultAuthorizationCache.ts
33
+ const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
34
+ function createDefaultAuthorizationCache() {
35
+ let storage;
36
+ try {
37
+ storage = window.localStorage;
38
+ } catch {}
39
+ return {
40
+ async clear() {
41
+ if (!storage) return;
42
+ try {
43
+ storage.removeItem(CACHE_KEY);
44
+ } catch {}
45
+ },
46
+ async get() {
47
+ if (!storage) return;
48
+ try {
49
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
50
+ if (parsed && parsed.accounts) {
51
+ const parsedAccounts = parsed.accounts.map((account) => {
52
+ return {
53
+ ...account,
54
+ publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58ToUint8Array)(account.address)
55
+ };
56
+ });
57
+ return {
58
+ ...parsed,
59
+ accounts: parsedAccounts
60
+ };
61
+ } else return parsed || void 0;
62
+ } catch {}
63
+ },
64
+ async set(authorization) {
65
+ if (!storage) return;
66
+ try {
67
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
68
+ } catch {}
69
+ }
70
+ };
74
71
  }
75
-
76
- @keyframes dot-typing {
77
- 0% {
78
- box-shadow: 9984px 0 0 0 var(--spinner-color),
79
- 9999px 0 0 0 var(--spinner-color),
80
- 10014px 0 0 0 var(--spinner-color);
81
- }
82
- 16.667% {
83
- box-shadow: 9984px -10px 0 0 var(--spinner-color),
84
- 9999px 0 0 0 var(--spinner-color),
85
- 10014px 0 0 0 var(--spinner-color);
86
- }
87
- 33.333% {
88
- box-shadow: 9984px 0 0 0 var(--spinner-color),
89
- 9999px 0 0 0 var(--spinner-color),
90
- 10014px 0 0 0 var(--spinner-color);
91
- }
92
- 50% {
93
- box-shadow: 9984px 0 0 0 var(--spinner-color),
94
- 9999px -10px 0 0 var(--spinner-color),
95
- 10014px 0 0 0 var(--spinner-color);
96
- }
97
- 66.667% {
98
- box-shadow: 9984px 0 0 0 var(--spinner-color),
99
- 9999px 0 0 0 var(--spinner-color),
100
- 10014px 0 0 0 var(--spinner-color);
101
- }
102
- 83.333% {
103
- box-shadow: 9984px 0 0 0 var(--spinner-color),
104
- 9999px 0 0 0 var(--spinner-color),
105
- 10014px -10px 0 0 var(--spinner-color);
106
- }
107
- 100% {
108
- box-shadow: 9984px 0 0 0 var(--spinner-color),
109
- 9999px 0 0 0 var(--spinner-color),
110
- 10014px 0 0 0 var(--spinner-color);
111
- }
72
+ //#endregion
73
+ //#region src/createDefaultChainSelector.ts
74
+ function createDefaultChainSelector() {
75
+ return { async select(chains) {
76
+ if (chains.length === 1) return chains[0];
77
+ else if (chains.includes(_solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN)) return _solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN;
78
+ else return chains[0];
79
+ } };
112
80
  }
113
- `;
114
- var EmbeddedLoadingSpinner = class {
115
- #root = null;
116
- #eventListeners = {};
117
- #listenersAttached = false;
118
- dom = null;
119
- constructor() {
120
- this.init = this.init.bind(this);
121
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
122
- }
123
- async init() {
124
- console.log("Injecting modal");
125
- this.#injectHTML();
126
- }
127
- open = () => {
128
- console.debug("Modal open");
129
- this.#attachEventListeners();
130
- if (this.#root) this.#root.style.display = "flex";
131
- };
132
- close = (event = void 0) => {
133
- console.debug("Modal close");
134
- this.#removeEventListeners();
135
- if (this.#root) this.#root.style.display = "none";
136
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
137
- };
138
- addEventListener(event, listener) {
139
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
140
- return () => this.removeEventListener(event, listener);
141
- }
142
- removeEventListener(event, listener) {
143
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
144
- }
145
- #injectHTML() {
146
- if (this.dom) return;
147
- this.#root = document.createElement("div");
148
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
149
- this.#root.innerHTML = modalHtml$1;
150
- this.#root.style.display = "none";
151
- const styles = document.createElement("style");
152
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
153
- styles.textContent = css$6;
154
- const host = document.createElement("div");
155
- this.dom = host.attachShadow({ mode: "closed" });
156
- host.style.setProperty("--spinner-color", "#FFFFFF");
157
- this.dom.appendChild(styles);
158
- this.dom.appendChild(this.#root);
159
- document.body.appendChild(host);
160
- }
161
- #attachEventListeners() {
162
- if (!this.#root || this.#listenersAttached) return;
163
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
164
- this.close(event);
165
- }));
166
- window.addEventListener("load", this.close);
167
- document.addEventListener("keydown", this.#handleKeyDown);
168
- this.#listenersAttached = true;
169
- }
170
- #removeEventListeners() {
171
- if (!this.#listenersAttached) return;
172
- window.removeEventListener("load", this.close);
173
- document.removeEventListener("keydown", this.#handleKeyDown);
174
- if (!this.#root) return;
175
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
176
- this.#listenersAttached = false;
177
- }
178
- #handleKeyDown = (event) => {
179
- if (event.key === "Escape") this.close(event);
180
- };
181
- };
182
81
  //#endregion
183
82
  //#region src/embedded-modal/modal.ts
184
- const modalHtml = `
83
+ const modalHtml$1 = `
185
84
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
186
85
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
187
86
  <div class="mobile-wallet-adapter-embedded-modal-card">
@@ -196,7 +95,7 @@ const modalHtml = `
196
95
  </div>
197
96
  </div>
198
97
  `;
199
- const css$5 = `
98
+ const css$6 = `
200
99
  .mobile-wallet-adapter-embedded-modal-container {
201
100
  display: flex; /* Use flexbox to center content */
202
101
  justify-content: center; /* Center horizontally */
@@ -296,13 +195,13 @@ var EmbeddedModal = class {
296
195
  }
297
196
  this.#root = document.createElement("div");
298
197
  this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
299
- this.#root.innerHTML = modalHtml;
198
+ this.#root.innerHTML = modalHtml$1;
300
199
  this.#root.style.display = "none";
301
200
  const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
302
201
  if (content) content.innerHTML = this.contentHtml;
303
202
  const styles = document.createElement("style");
304
203
  styles.id = "mobile-wallet-adapter-embedded-modal-styles";
305
- styles.textContent = css$5 + this.contentStyles;
204
+ styles.textContent = css$6 + this.contentStyles;
306
205
  const host = document.createElement("div");
307
206
  host.innerHTML = fonts;
308
207
  this.dom = host.attachShadow({ mode: "closed" });
@@ -330,303 +229,124 @@ var EmbeddedModal = class {
330
229
  };
331
230
  };
332
231
  //#endregion
333
- //#region src/embedded-modal/remoteConnectionModal.ts
334
- var RemoteConnectionModal = class extends EmbeddedModal {
335
- contentStyles = css$4;
336
- contentHtml = QRCodeHtml;
337
- async initWithQR(qrCode) {
232
+ //#region src/embedded-modal/errorModal.ts
233
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
234
+ const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = "This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.";
235
+ var ErrorModal = class extends EmbeddedModal {
236
+ contentStyles = css$5;
237
+ contentHtml = ErrorDialogHtml$3;
238
+ initWithError(error) {
338
239
  super.init();
339
- this.populateQRCode(qrCode);
240
+ this.populateError(error);
340
241
  }
341
- async populateQRCode(qrUrl) {
342
- const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
343
- if (qrcodeContainer) {
344
- const qrCodeElement = await qrcode.default.toCanvas(qrUrl, {
345
- width: 200,
346
- margin: 0
347
- });
348
- if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
349
- else qrcodeContainer.appendChild(qrCodeElement);
350
- const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
351
- if (qrPlaceholder) qrPlaceholder.style.display = "none";
352
- } else console.error("QRCode Container not found");
242
+ populateError(error) {
243
+ const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
244
+ const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
245
+ if (errorMessageElement) {
246
+ if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
247
+ case "ERROR_WALLET_NOT_FOUND":
248
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
249
+ if (actionBtn) actionBtn.addEventListener("click", () => {
250
+ window.location.href = "https://solanamobile.com/wallets";
251
+ });
252
+ return;
253
+ case "ERROR_BROWSER_NOT_SUPPORTED":
254
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
255
+ if (actionBtn) actionBtn.style.display = "none";
256
+ return;
257
+ }
258
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
259
+ } else console.log("Failed to locate error dialog element");
353
260
  }
354
261
  };
355
- const QRCodeHtml = `
356
- <div class="mobile-wallet-adapter-embedded-modal-qr-content">
357
- <div>
358
- <svg class="mobile-wallet-adapter-embedded-modal-icon" width="100%" height="100%">
359
- <circle r="52" cx="53" cy="53" fill="#99b3be" stroke="#000000" stroke-width="2"/>
360
- <path d="m 53,82.7305 c -3.3116,0 -6.1361,-1.169 -8.4735,-3.507 -2.338,-2.338 -3.507,-5.1625 -3.507,-8.4735 0,-3.3116 1.169,-6.1364 3.507,-8.4744 2.3374,-2.338 5.1619,-3.507 8.4735,-3.507 3.3116,0 6.1361,1.169 8.4735,3.507 2.338,2.338 3.507,5.1628 3.507,8.4744 0,3.311 -1.169,6.1355 -3.507,8.4735 -2.3374,2.338 -5.1619,3.507 -8.4735,3.507 z m 0.007,-5.25 c 1.8532,0 3.437,-0.6598 4.7512,-1.9793 1.3149,-1.3195 1.9723,-2.9058 1.9723,-4.7591 0,-1.8526 -0.6598,-3.4364 -1.9793,-4.7512 -1.3195,-1.3149 -2.9055,-1.9723 -4.7582,-1.9723 -1.8533,0 -3.437,0.6598 -4.7513,1.9793 -1.3148,1.3195 -1.9722,2.9058 -1.9722,4.7591 0,1.8527 0.6597,3.4364 1.9792,4.7512 1.3195,1.3149 2.9056,1.9723 4.7583,1.9723 z m -28,-33.5729 -3.85,-3.6347 c 4.1195,-4.025 8.8792,-7.1984 14.2791,-9.52 5.4005,-2.3223 11.2551,-3.4834 17.5639,-3.4834 6.3087,0 12.1634,1.1611 17.5639,3.4834 5.3999,2.3216 10.1596,5.495 14.2791,9.52 l -3.85,3.6347 C 77.2999,40.358 73.0684,37.5726 68.2985,35.5514 63.5292,33.5301 58.4296,32.5195 53,32.5195 c -5.4297,0 -10.5292,1.0106 -15.2985,3.0319 -4.7699,2.0212 -9.0014,4.8066 -12.6945,8.3562 z m 44.625,10.8771 c -2.2709,-2.1046 -4.7962,-3.7167 -7.5758,-4.8361 -2.7795,-1.12 -5.7983,-1.68 -9.0562,-1.68 -3.2579,0 -6.2621,0.56 -9.0125,1.68 -2.7504,1.1194 -5.2903,2.7315 -7.6195,4.8361 L 32.5189,51.15 c 2.8355,-2.6028 5.9777,-4.6086 9.4263,-6.0174 3.4481,-1.4087 7.133,-2.1131 11.0548,-2.1131 3.9217,0 7.5979,0.7044 11.0285,2.1131 3.43,1.4088 6.5631,3.4146 9.3992,6.0174 z"/>
361
- </svg>
362
- <div class="mobile-wallet-adapter-embedded-modal-title">Remote Mobile Wallet Adapter</div>
363
- </div>
364
- <div>
365
- <div>
366
- <h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
367
- Open your wallet and scan this code
368
- </h4>
369
- </div>
370
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
371
- <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
372
- </div>
373
- </div>
374
- </div>
375
- <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
376
- <div class="mobile-wallet-adapter-embedded-modal-footer">
377
- <div class="mobile-wallet-adapter-embedded-modal-subtitle">
378
- Follow the instructions on your device. When you're finished, this screen will update.
379
- </div>
380
- <div class="mobile-wallet-adapter-embedded-modal-progress-badge">
381
- <div>
382
- <div class="spinner">
383
- <div class="leftWrapper">
384
- <div class="left">
385
- <div class="circle"></div>
386
- </div>
387
- </div>
388
- <div class="rightWrapper">
389
- <div class="right">
390
- <div class="circle"></div>
391
- </div>
392
- </div>
393
- </div>
394
- </div>
395
- <div>Waiting for scan</div>
396
- </div>
262
+ const ErrorDialogHtml$3 = `
263
+ <svg class="mobile-wallet-adapter-embedded-modal-error-icon" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#000000"><path d="M 280,-80 Q 197,-80 138.5,-138.5 80,-197 80,-280 80,-363 138.5,-421.5 197,-480 280,-480 q 83,0 141.5,58.5 58.5,58.5 58.5,141.5 0,83 -58.5,141.5 Q 363,-80 280,-80 Z M 824,-120 568,-376 Q 556,-389 542.5,-402.5 529,-416 516,-428 q 38,-24 61,-64 23,-40 23,-88 0,-75 -52.5,-127.5 Q 495,-760 420,-760 345,-760 292.5,-707.5 240,-655 240,-580 q 0,6 0.5,11.5 0.5,5.5 1.5,11.5 -18,2 -39.5,8 -21.5,6 -38.5,14 -2,-11 -3,-22 -1,-11 -1,-23 0,-109 75.5,-184.5 Q 311,-840 420,-840 q 109,0 184.5,75.5 75.5,75.5 75.5,184.5 0,43 -13.5,81.5 Q 653,-460 629,-428 l 251,252 z m -615,-61 71,-71 70,71 29,-28 -71,-71 71,-71 -28,-28 -71,71 -71,-71 -28,28 71,71 -71,71 z"/></svg>
264
+ <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
265
+ <div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
266
+ <div>
267
+ <button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
268
+ Find a wallet
269
+ </button>
397
270
  </div>
398
271
  `;
399
- const css$4 = `
400
- .mobile-wallet-adapter-embedded-modal-qr-content {
401
- display: flex;
402
- margin-top: 10px;
403
- padding: 10px;
404
- }
405
-
406
- .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
407
- display: flex;
408
- flex-direction: column;
409
- flex: 2;
410
- margin-top: auto;
411
- margin-right: 30px;
412
- }
413
-
414
- .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
415
- display: flex;
416
- flex-direction: column;
417
- flex: 1;
418
- margin-left: auto;
272
+ const css$5 = `
273
+ .mobile-wallet-adapter-embedded-modal-content {
274
+ text-align: center;
419
275
  }
420
276
 
421
- .mobile-wallet-adapter-embedded-modal-footer {
422
- display: flex;
423
- padding: 10px;
277
+ .mobile-wallet-adapter-embedded-modal-error-icon {
278
+ margin-top: 24px;
424
279
  }
425
280
 
426
- .mobile-wallet-adapter-embedded-modal-icon {}
427
-
428
281
  .mobile-wallet-adapter-embedded-modal-title {
282
+ margin: 18px 100px auto 100px;
429
283
  color: #000000;
430
- font-size: 2.5em;
284
+ font-size: 2.75em;
431
285
  font-weight: 600;
432
286
  }
433
287
 
434
- .mobile-wallet-adapter-embedded-modal-qr-label {
435
- text-align: right;
436
- color: #000000;
437
- }
438
-
439
- .mobile-wallet-adapter-embedded-modal-qr-code-container {
440
- margin-left: auto;
441
- }
442
-
443
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
444
- margin-left: auto;
445
- min-width: 200px;
446
- min-height: 200px;
447
- background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
448
- background-size: 200%;
449
- animation: placeholderAnimate 2.7s linear infinite;
450
- border-radius: 12px;
451
- }
452
-
453
- .mobile-wallet-adapter-embedded-modal-divider {
454
- margin-top: 20px;
455
- padding-left: 10px;
456
- padding-right: 10px;
457
- }
458
-
459
- .mobile-wallet-adapter-embedded-modal-divider hr {
460
- border-top: 1px solid #D9DEDE;
461
- }
462
-
463
288
  .mobile-wallet-adapter-embedded-modal-subtitle {
464
- margin: auto;
465
- margin-right: 60px;
466
- padding: 20px;
467
- color: #6E8286;
289
+ margin: 30px 60px 40px 60px;
290
+ color: #000000;
291
+ font-size: 1.25em;
292
+ font-weight: 400;
468
293
  }
469
294
 
470
- .mobile-wallet-adapter-embedded-modal-progress-badge {
471
- display: flex;
472
- background: #F7F8F8;
295
+ .mobile-wallet-adapter-embedded-modal-error-action {
296
+ display: block;
297
+ width: 100%;
473
298
  height: 56px;
474
- min-width: 200px;
475
- margin: auto;
476
- padding-left: 20px;
477
- padding-right: 20px;
299
+ /*margin-top: 40px;*/
300
+ font-size: 1.25em;
301
+ /*line-height: 24px;*/
302
+ /*letter-spacing: -1%;*/
303
+ background: #000000;
304
+ color: #FFFFFF;
478
305
  border-radius: 18px;
479
- color: #A8B6B8;
480
- align-items: center;
481
- }
482
-
483
- .mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
484
- margin-left: auto;
485
- margin-right: 20px;
486
- }
487
-
488
- .mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
489
- margin-right: auto;
490
306
  }
491
307
 
492
308
  /* Smaller screens */
493
309
  @media all and (max-width: 600px) {
494
- .mobile-wallet-adapter-embedded-modal-card {
495
- text-align: center;
496
- }
497
- .mobile-wallet-adapter-embedded-modal-qr-content {
498
- flex-direction: column;
499
- }
500
- .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
501
- margin: auto;
502
- }
503
- .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
504
- margin: auto;
505
- flex: 2 auto;
506
- }
507
- .mobile-wallet-adapter-embedded-modal-footer {
508
- flex-direction: column;
509
- }
510
- .mobile-wallet-adapter-embedded-modal-icon {
511
- display: none;
512
- }
513
310
  .mobile-wallet-adapter-embedded-modal-title {
514
311
  font-size: 1.5em;
312
+ margin-right: 12px;
313
+ margin-left: 12px;
515
314
  }
516
315
  .mobile-wallet-adapter-embedded-modal-subtitle {
517
- margin-right: unset;
518
- }
519
- .mobile-wallet-adapter-embedded-modal-qr-label {
520
- text-align: center;
521
- }
522
- .mobile-wallet-adapter-embedded-modal-qr-code-container {
523
- margin: auto;
524
- }
525
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
526
- margin: auto;
527
- }
528
- }
529
-
530
- /* QR Placeholder */
531
- @keyframes placeholderAnimate {
532
- 0% { background-position: 200% 0; }
533
- 100% { background-position: -200% 0; }
534
- }
535
-
536
- /* Spinner */
537
- @keyframes spinLeft {
538
- 0% {
539
- transform: rotate(20deg);
540
- }
541
- 50% {
542
- transform: rotate(160deg);
543
- }
544
- 100% {
545
- transform: rotate(20deg);
546
- }
547
- }
548
- @keyframes spinRight {
549
- 0% {
550
- transform: rotate(160deg);
551
- }
552
- 50% {
553
- transform: rotate(20deg);
554
- }
555
- 100% {
556
- transform: rotate(160deg);
557
- }
558
- }
559
- @keyframes spin {
560
- 0% {
561
- transform: rotate(0deg);
562
- }
563
- 100% {
564
- transform: rotate(2520deg);
316
+ margin-right: 12px;
317
+ margin-left: 12px;
565
318
  }
566
319
  }
567
-
568
- .spinner {
569
- position: relative;
570
- width: 1.5em;
571
- height: 1.5em;
572
- margin: auto;
573
- animation: spin 10s linear infinite;
574
- }
575
- .spinner::before {
576
- content: "";
577
- position: absolute;
578
- top: 0;
579
- bottom: 0;
580
- left: 0;
581
- right: 0;
320
+ `;
321
+ //#endregion
322
+ //#region src/createDefaultWalletNotFoundHandler.ts
323
+ async function defaultErrorModalWalletNotFoundHandler() {
324
+ if (typeof window !== "undefined") {
325
+ const userAgent = window.navigator.userAgent.toLowerCase();
326
+ const errorDialog = new ErrorModal();
327
+ if (userAgent.includes("wv")) errorDialog.initWithError({
328
+ name: "SolanaMobileWalletAdapterError",
329
+ code: "ERROR_BROWSER_NOT_SUPPORTED",
330
+ message: ""
331
+ });
332
+ else errorDialog.initWithError({
333
+ name: "SolanaMobileWalletAdapterError",
334
+ code: "ERROR_WALLET_NOT_FOUND",
335
+ message: ""
336
+ });
337
+ errorDialog.open();
338
+ }
582
339
  }
583
- .right, .rightWrapper, .left, .leftWrapper {
584
- position: absolute;
585
- top: 0;
586
- overflow: hidden;
587
- width: .75em;
588
- height: 1.5em;
589
- }
590
- .left, .leftWrapper {
591
- left: 0;
592
- }
593
- .right {
594
- left: -12px;
595
- }
596
- .rightWrapper {
597
- right: 0;
598
- }
599
- .circle {
600
- border: .125em solid #A8B6B8;
601
- width: 1.25em; /* 1.5em - 2*0.125em border */
602
- height: 1.25em; /* 1.5em - 2*0.125em border */
603
- border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
604
- }
605
- .left {
606
- transform-origin: 100% 50%;
607
- animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
608
- }
609
- .right {
610
- transform-origin: 100% 50%;
611
- animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
612
- }
613
- `;
614
- //#endregion
615
- //#region src/icon.ts
616
- const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
617
- //#endregion
618
- //#region src/base64Utils.ts
619
- function fromUint8Array(byteArray) {
620
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
621
- }
622
- function toUint8Array(base64EncodedByteArray) {
623
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
340
+ function createDefaultWalletNotFoundHandler() {
341
+ return async () => {
342
+ defaultErrorModalWalletNotFoundHandler();
343
+ };
624
344
  }
625
345
  //#endregion
626
346
  //#region src/embedded-modal/localConnectionModal.ts
627
347
  var LocalConnectionModal = class extends EmbeddedModal {
628
- contentStyles = css$3;
629
- contentHtml = ErrorDialogHtml$3;
348
+ contentStyles = css$4;
349
+ contentHtml = ErrorDialogHtml$2;
630
350
  initWithCallback(callback) {
631
351
  super.init();
632
352
  this.#prepareLaunchAction(callback);
@@ -641,7 +361,7 @@ var LocalConnectionModal = class extends EmbeddedModal {
641
361
  launchButton?.addEventListener("click", listener);
642
362
  }
643
363
  };
644
- const ErrorDialogHtml$3 = `
364
+ const ErrorDialogHtml$2 = `
645
365
  <svg class="mobile-wallet-adapter-embedded-modal-launch-icon" width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
646
366
  <path d="M21.6 48C7.2 48 0 40.8 0 26.4V21.6C0 7.2 7.2 0 21.6 0H26.4C40.8 0 48 7.2 48 21.6V26.4C48 40.8 40.8 48 26.4 48H21.6Z" fill="#15994E"/>
647
367
  <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
@@ -663,7 +383,7 @@ const ErrorDialogHtml$3 = `
663
383
  </button>
664
384
  </div>
665
385
  `;
666
- const css$3 = `
386
+ const css$4 = `
667
387
  .mobile-wallet-adapter-embedded-modal-close {
668
388
  display: none;
669
389
  }
@@ -701,10 +421,10 @@ const css$3 = `
701
421
  //#endregion
702
422
  //#region src/embedded-modal/loopbackBlockedModal.ts
703
423
  var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
704
- contentStyles = css$2;
424
+ contentStyles = css$3;
705
425
  get contentHtml() {
706
426
  const instructions = getIsPwaLaunchedAsApp() ? "Long press the app icon on your home screen to open site settings" : "Tap the lock or settings icon in the address bar to open site settings";
707
- return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
427
+ return ErrorDialogHtml$1.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
708
428
  }
709
429
  async init() {
710
430
  super.init();
@@ -719,7 +439,7 @@ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
719
439
  launchButton?.addEventListener("click", listener);
720
440
  }
721
441
  };
722
- const ErrorDialogHtml$2 = `
442
+ const ErrorDialogHtml$1 = `
723
443
  <div class="mobile-wallet-adapter-embedded-modal-header">
724
444
  Local Wallet Connection
725
445
  </div>
@@ -772,7 +492,7 @@ const ErrorDialogHtml$2 = `
772
492
  </button>
773
493
  </div>
774
494
  `;
775
- const css$2 = `
495
+ const css$3 = `
776
496
  .mobile-wallet-adapter-embedded-modal-close {
777
497
  display: none;
778
498
  }
@@ -862,8 +582,8 @@ const css$2 = `
862
582
  //#endregion
863
583
  //#region src/embedded-modal/loopbackPermissionModal.ts
864
584
  var LoopbackPermissionModal = class extends EmbeddedModal {
865
- contentStyles = css$1;
866
- contentHtml = ErrorDialogHtml$1;
585
+ contentStyles = css$2;
586
+ contentHtml = ErrorDialogHtml;
867
587
  async init() {
868
588
  super.init();
869
589
  this.#prepareLaunchAction();
@@ -874,13 +594,13 @@ var LoopbackPermissionModal = class extends EmbeddedModal {
874
594
  launchButton?.removeEventListener("click", listener);
875
595
  try {
876
596
  await fetch("http://localhost");
877
- } catch (e) {}
597
+ } catch {}
878
598
  this.close();
879
599
  };
880
600
  launchButton?.addEventListener("click", listener);
881
601
  }
882
602
  };
883
- const ErrorDialogHtml$1 = `
603
+ const ErrorDialogHtml = `
884
604
  <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
885
605
  <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
886
606
  Tap "Allow" on the next screen
@@ -906,7 +626,7 @@ const ErrorDialogHtml$1 = `
906
626
  </button>
907
627
  </div>
908
628
  `;
909
- const css$1 = `
629
+ const css$2 = `
910
630
  .mobile-wallet-adapter-embedded-modal-close {
911
631
  display: none;
912
632
  }
@@ -952,72 +672,507 @@ const css$1 = `
952
672
  margin-left: 12px;
953
673
  }
954
674
  }
955
- `;
956
- //#endregion
957
- //#region src/getIsSupported.ts
958
- function getIsLocalAssociationSupported() {
959
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
675
+ `;
676
+ //#endregion
677
+ //#region src/getIsSupported.ts
678
+ function getIsLocalAssociationSupported() {
679
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
680
+ }
681
+ function getIsRemoteAssociationSupported() {
682
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
683
+ }
684
+ function isWebView(userAgentString) {
685
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
686
+ }
687
+ function isSolanaMobileWebShell(userAgentString) {
688
+ return userAgentString.includes("Solana Mobile Web Shell");
689
+ }
690
+ function getIsPwaLaunchedAsApp() {
691
+ const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
692
+ if (typeof window == "undefined") return isAndroidTwa;
693
+ const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
694
+ const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
695
+ const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
696
+ return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
697
+ }
698
+ async function checkLocalNetworkAccessPermission() {
699
+ if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
700
+ try {
701
+ const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
702
+ if (lnaPermission.state === "granted") return;
703
+ else if (lnaPermission.state === "denied") {
704
+ const modal = new LoopbackPermissionBlockedModal();
705
+ modal.init();
706
+ modal.open();
707
+ throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
708
+ } else if (lnaPermission.state === "prompt") {
709
+ const modal = new LoopbackPermissionModal();
710
+ if (await new Promise((resolve, reject) => {
711
+ modal.addEventListener("close", (event) => {
712
+ if (event) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
713
+ });
714
+ lnaPermission.onchange = () => {
715
+ lnaPermission.onchange = null;
716
+ resolve(lnaPermission.state);
717
+ };
718
+ modal.init();
719
+ modal.open();
720
+ }) === "granted") {
721
+ const modal = new LocalConnectionModal();
722
+ await new Promise((resolve, reject) => {
723
+ modal.addEventListener("close", (event) => {
724
+ if (event) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
725
+ });
726
+ modal.initWithCallback(async () => {
727
+ resolve(true);
728
+ });
729
+ modal.open();
730
+ });
731
+ return;
732
+ } else return await checkLocalNetworkAccessPermission();
733
+ }
734
+ throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
735
+ } catch (e) {
736
+ if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
737
+ if (e instanceof _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError) throw e;
738
+ throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
739
+ }
740
+ }
741
+ //#endregion
742
+ //#region src/embedded-modal/loadingSpinner.ts
743
+ const modalHtml = `
744
+ <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
745
+ <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
746
+ <div class="mobile-wallet-adapter-embedded-loading-container">
747
+ <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
748
+ </div>
749
+ </div>
750
+ `;
751
+ const css$1 = `
752
+ .mobile-wallet-adapter-embedded-loading-indicator {
753
+ display: flex; /* Use flexbox to center content */
754
+ justify-content: center; /* Center horizontally */
755
+ align-items: start; /* Center vertically */
756
+ position: fixed; /* Stay in place */
757
+ z-index: 1; /* Sit on top */
758
+ left: 0;
759
+ top: 0;
760
+ width: 100%; /* Full width */
761
+ height: 100%; /* Full height */
762
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
763
+ overflow-y: auto; /* enable scrolling */
764
+ }
765
+
766
+ .mobile-wallet-adapter-embedded-loading-container {
767
+ display: flex;
768
+ margin: auto;
769
+ }
770
+
771
+ .mobile-wallet-adapter-embedded-loading-animation {
772
+ position: relative;
773
+ left: -9999px;
774
+ width: 10px;
775
+ height: 10px;
776
+ border-radius: 5px;
777
+ background-color: var(--spinner-color);
778
+ color: var(--spinner-color);
779
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
780
+ 9999px 0 0 0 var(--spinner-color),
781
+ 10014px 0 0 0 var(--spinner-color);
782
+ animation: dot-typing 1.5s infinite linear;
783
+ }
784
+
785
+ @keyframes dot-typing {
786
+ 0% {
787
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
788
+ 9999px 0 0 0 var(--spinner-color),
789
+ 10014px 0 0 0 var(--spinner-color);
790
+ }
791
+ 16.667% {
792
+ box-shadow: 9984px -10px 0 0 var(--spinner-color),
793
+ 9999px 0 0 0 var(--spinner-color),
794
+ 10014px 0 0 0 var(--spinner-color);
795
+ }
796
+ 33.333% {
797
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
798
+ 9999px 0 0 0 var(--spinner-color),
799
+ 10014px 0 0 0 var(--spinner-color);
800
+ }
801
+ 50% {
802
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
803
+ 9999px -10px 0 0 var(--spinner-color),
804
+ 10014px 0 0 0 var(--spinner-color);
805
+ }
806
+ 66.667% {
807
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
808
+ 9999px 0 0 0 var(--spinner-color),
809
+ 10014px 0 0 0 var(--spinner-color);
810
+ }
811
+ 83.333% {
812
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
813
+ 9999px 0 0 0 var(--spinner-color),
814
+ 10014px -10px 0 0 var(--spinner-color);
815
+ }
816
+ 100% {
817
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
818
+ 9999px 0 0 0 var(--spinner-color),
819
+ 10014px 0 0 0 var(--spinner-color);
820
+ }
821
+ }
822
+ `;
823
+ var EmbeddedLoadingSpinner = class {
824
+ #root = null;
825
+ #eventListeners = {};
826
+ #listenersAttached = false;
827
+ dom = null;
828
+ constructor() {
829
+ this.init = this.init.bind(this);
830
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
831
+ }
832
+ async init() {
833
+ console.log("Injecting modal");
834
+ this.#injectHTML();
835
+ }
836
+ open = () => {
837
+ console.debug("Modal open");
838
+ this.#attachEventListeners();
839
+ if (this.#root) this.#root.style.display = "flex";
840
+ };
841
+ close = (event = void 0) => {
842
+ console.debug("Modal close");
843
+ this.#removeEventListeners();
844
+ if (this.#root) this.#root.style.display = "none";
845
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
846
+ };
847
+ addEventListener(event, listener) {
848
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
849
+ return () => this.removeEventListener(event, listener);
850
+ }
851
+ removeEventListener(event, listener) {
852
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
853
+ }
854
+ #injectHTML() {
855
+ if (this.dom) return;
856
+ this.#root = document.createElement("div");
857
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
858
+ this.#root.innerHTML = modalHtml;
859
+ this.#root.style.display = "none";
860
+ const styles = document.createElement("style");
861
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
862
+ styles.textContent = css$1;
863
+ const host = document.createElement("div");
864
+ this.dom = host.attachShadow({ mode: "closed" });
865
+ host.style.setProperty("--spinner-color", "#FFFFFF");
866
+ this.dom.appendChild(styles);
867
+ this.dom.appendChild(this.#root);
868
+ document.body.appendChild(host);
869
+ }
870
+ #attachEventListeners() {
871
+ if (!this.#root || this.#listenersAttached) return;
872
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
873
+ this.close(event);
874
+ }));
875
+ window.addEventListener("load", this.close);
876
+ document.addEventListener("keydown", this.#handleKeyDown);
877
+ this.#listenersAttached = true;
878
+ }
879
+ #removeEventListeners() {
880
+ if (!this.#listenersAttached) return;
881
+ window.removeEventListener("load", this.close);
882
+ document.removeEventListener("keydown", this.#handleKeyDown);
883
+ if (!this.#root) return;
884
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
885
+ this.#listenersAttached = false;
886
+ }
887
+ #handleKeyDown = (event) => {
888
+ if (event.key === "Escape") this.close(event);
889
+ };
890
+ };
891
+ //#endregion
892
+ //#region src/embedded-modal/remoteConnectionModal.ts
893
+ var RemoteConnectionModal = class extends EmbeddedModal {
894
+ contentStyles = css;
895
+ contentHtml = QRCodeHtml;
896
+ async initWithQR(qrCode) {
897
+ super.init();
898
+ this.populateQRCode(qrCode);
899
+ }
900
+ async populateQRCode(qrUrl) {
901
+ const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
902
+ if (qrcodeContainer) {
903
+ const qrCodeElement = await qrcode.default.toCanvas(qrUrl, {
904
+ width: 200,
905
+ margin: 0
906
+ });
907
+ if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
908
+ else qrcodeContainer.appendChild(qrCodeElement);
909
+ const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
910
+ if (qrPlaceholder) qrPlaceholder.style.display = "none";
911
+ } else console.error("QRCode Container not found");
912
+ }
913
+ };
914
+ const QRCodeHtml = `
915
+ <div class="mobile-wallet-adapter-embedded-modal-qr-content">
916
+ <div>
917
+ <svg class="mobile-wallet-adapter-embedded-modal-icon" width="100%" height="100%">
918
+ <circle r="52" cx="53" cy="53" fill="#99b3be" stroke="#000000" stroke-width="2"/>
919
+ <path d="m 53,82.7305 c -3.3116,0 -6.1361,-1.169 -8.4735,-3.507 -2.338,-2.338 -3.507,-5.1625 -3.507,-8.4735 0,-3.3116 1.169,-6.1364 3.507,-8.4744 2.3374,-2.338 5.1619,-3.507 8.4735,-3.507 3.3116,0 6.1361,1.169 8.4735,3.507 2.338,2.338 3.507,5.1628 3.507,8.4744 0,3.311 -1.169,6.1355 -3.507,8.4735 -2.3374,2.338 -5.1619,3.507 -8.4735,3.507 z m 0.007,-5.25 c 1.8532,0 3.437,-0.6598 4.7512,-1.9793 1.3149,-1.3195 1.9723,-2.9058 1.9723,-4.7591 0,-1.8526 -0.6598,-3.4364 -1.9793,-4.7512 -1.3195,-1.3149 -2.9055,-1.9723 -4.7582,-1.9723 -1.8533,0 -3.437,0.6598 -4.7513,1.9793 -1.3148,1.3195 -1.9722,2.9058 -1.9722,4.7591 0,1.8527 0.6597,3.4364 1.9792,4.7512 1.3195,1.3149 2.9056,1.9723 4.7583,1.9723 z m -28,-33.5729 -3.85,-3.6347 c 4.1195,-4.025 8.8792,-7.1984 14.2791,-9.52 5.4005,-2.3223 11.2551,-3.4834 17.5639,-3.4834 6.3087,0 12.1634,1.1611 17.5639,3.4834 5.3999,2.3216 10.1596,5.495 14.2791,9.52 l -3.85,3.6347 C 77.2999,40.358 73.0684,37.5726 68.2985,35.5514 63.5292,33.5301 58.4296,32.5195 53,32.5195 c -5.4297,0 -10.5292,1.0106 -15.2985,3.0319 -4.7699,2.0212 -9.0014,4.8066 -12.6945,8.3562 z m 44.625,10.8771 c -2.2709,-2.1046 -4.7962,-3.7167 -7.5758,-4.8361 -2.7795,-1.12 -5.7983,-1.68 -9.0562,-1.68 -3.2579,0 -6.2621,0.56 -9.0125,1.68 -2.7504,1.1194 -5.2903,2.7315 -7.6195,4.8361 L 32.5189,51.15 c 2.8355,-2.6028 5.9777,-4.6086 9.4263,-6.0174 3.4481,-1.4087 7.133,-2.1131 11.0548,-2.1131 3.9217,0 7.5979,0.7044 11.0285,2.1131 3.43,1.4088 6.5631,3.4146 9.3992,6.0174 z"/>
920
+ </svg>
921
+ <div class="mobile-wallet-adapter-embedded-modal-title">Remote Mobile Wallet Adapter</div>
922
+ </div>
923
+ <div>
924
+ <div>
925
+ <h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
926
+ Open your wallet and scan this code
927
+ </h4>
928
+ </div>
929
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
930
+ <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
931
+ </div>
932
+ </div>
933
+ </div>
934
+ <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
935
+ <div class="mobile-wallet-adapter-embedded-modal-footer">
936
+ <div class="mobile-wallet-adapter-embedded-modal-subtitle">
937
+ Follow the instructions on your device. When you're finished, this screen will update.
938
+ </div>
939
+ <div class="mobile-wallet-adapter-embedded-modal-progress-badge">
940
+ <div>
941
+ <div class="spinner">
942
+ <div class="leftWrapper">
943
+ <div class="left">
944
+ <div class="circle"></div>
945
+ </div>
946
+ </div>
947
+ <div class="rightWrapper">
948
+ <div class="right">
949
+ <div class="circle"></div>
950
+ </div>
951
+ </div>
952
+ </div>
953
+ </div>
954
+ <div>Waiting for scan</div>
955
+ </div>
956
+ </div>
957
+ `;
958
+ const css = `
959
+ .mobile-wallet-adapter-embedded-modal-qr-content {
960
+ display: flex;
961
+ margin-top: 10px;
962
+ padding: 10px;
963
+ }
964
+
965
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
966
+ display: flex;
967
+ flex-direction: column;
968
+ flex: 2;
969
+ margin-top: auto;
970
+ margin-right: 30px;
971
+ }
972
+
973
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
974
+ display: flex;
975
+ flex-direction: column;
976
+ flex: 1;
977
+ margin-left: auto;
978
+ }
979
+
980
+ .mobile-wallet-adapter-embedded-modal-footer {
981
+ display: flex;
982
+ padding: 10px;
983
+ }
984
+
985
+ .mobile-wallet-adapter-embedded-modal-icon {}
986
+
987
+ .mobile-wallet-adapter-embedded-modal-title {
988
+ color: #000000;
989
+ font-size: 2.5em;
990
+ font-weight: 600;
991
+ }
992
+
993
+ .mobile-wallet-adapter-embedded-modal-qr-label {
994
+ text-align: right;
995
+ color: #000000;
996
+ }
997
+
998
+ .mobile-wallet-adapter-embedded-modal-qr-code-container {
999
+ margin-left: auto;
1000
+ }
1001
+
1002
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
1003
+ margin-left: auto;
1004
+ min-width: 200px;
1005
+ min-height: 200px;
1006
+ background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
1007
+ background-size: 200%;
1008
+ animation: placeholderAnimate 2.7s linear infinite;
1009
+ border-radius: 12px;
1010
+ }
1011
+
1012
+ .mobile-wallet-adapter-embedded-modal-divider {
1013
+ margin-top: 20px;
1014
+ padding-left: 10px;
1015
+ padding-right: 10px;
1016
+ }
1017
+
1018
+ .mobile-wallet-adapter-embedded-modal-divider hr {
1019
+ border-top: 1px solid #D9DEDE;
1020
+ }
1021
+
1022
+ .mobile-wallet-adapter-embedded-modal-subtitle {
1023
+ margin: auto;
1024
+ margin-right: 60px;
1025
+ padding: 20px;
1026
+ color: #6E8286;
1027
+ }
1028
+
1029
+ .mobile-wallet-adapter-embedded-modal-progress-badge {
1030
+ display: flex;
1031
+ background: #F7F8F8;
1032
+ height: 56px;
1033
+ min-width: 200px;
1034
+ margin: auto;
1035
+ padding-left: 20px;
1036
+ padding-right: 20px;
1037
+ border-radius: 18px;
1038
+ color: #A8B6B8;
1039
+ align-items: center;
1040
+ }
1041
+
1042
+ .mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
1043
+ margin-left: auto;
1044
+ margin-right: 20px;
1045
+ }
1046
+
1047
+ .mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
1048
+ margin-right: auto;
1049
+ }
1050
+
1051
+ /* Smaller screens */
1052
+ @media all and (max-width: 600px) {
1053
+ .mobile-wallet-adapter-embedded-modal-card {
1054
+ text-align: center;
1055
+ }
1056
+ .mobile-wallet-adapter-embedded-modal-qr-content {
1057
+ flex-direction: column;
1058
+ }
1059
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
1060
+ margin: auto;
1061
+ }
1062
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
1063
+ margin: auto;
1064
+ flex: 2 auto;
1065
+ }
1066
+ .mobile-wallet-adapter-embedded-modal-footer {
1067
+ flex-direction: column;
1068
+ }
1069
+ .mobile-wallet-adapter-embedded-modal-icon {
1070
+ display: none;
1071
+ }
1072
+ .mobile-wallet-adapter-embedded-modal-title {
1073
+ font-size: 1.5em;
1074
+ }
1075
+ .mobile-wallet-adapter-embedded-modal-subtitle {
1076
+ margin-right: unset;
1077
+ }
1078
+ .mobile-wallet-adapter-embedded-modal-qr-label {
1079
+ text-align: center;
1080
+ }
1081
+ .mobile-wallet-adapter-embedded-modal-qr-code-container {
1082
+ margin: auto;
1083
+ }
1084
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
1085
+ margin: auto;
1086
+ }
1087
+ }
1088
+
1089
+ /* QR Placeholder */
1090
+ @keyframes placeholderAnimate {
1091
+ 0% { background-position: 200% 0; }
1092
+ 100% { background-position: -200% 0; }
1093
+ }
1094
+
1095
+ /* Spinner */
1096
+ @keyframes spinLeft {
1097
+ 0% {
1098
+ transform: rotate(20deg);
1099
+ }
1100
+ 50% {
1101
+ transform: rotate(160deg);
1102
+ }
1103
+ 100% {
1104
+ transform: rotate(20deg);
1105
+ }
1106
+ }
1107
+ @keyframes spinRight {
1108
+ 0% {
1109
+ transform: rotate(160deg);
1110
+ }
1111
+ 50% {
1112
+ transform: rotate(20deg);
1113
+ }
1114
+ 100% {
1115
+ transform: rotate(160deg);
1116
+ }
1117
+ }
1118
+ @keyframes spin {
1119
+ 0% {
1120
+ transform: rotate(0deg);
1121
+ }
1122
+ 100% {
1123
+ transform: rotate(2520deg);
1124
+ }
1125
+ }
1126
+
1127
+ .spinner {
1128
+ position: relative;
1129
+ width: 1.5em;
1130
+ height: 1.5em;
1131
+ margin: auto;
1132
+ animation: spin 10s linear infinite;
1133
+ }
1134
+ .spinner::before {
1135
+ content: "";
1136
+ position: absolute;
1137
+ top: 0;
1138
+ bottom: 0;
1139
+ left: 0;
1140
+ right: 0;
1141
+ }
1142
+ .right, .rightWrapper, .left, .leftWrapper {
1143
+ position: absolute;
1144
+ top: 0;
1145
+ overflow: hidden;
1146
+ width: .75em;
1147
+ height: 1.5em;
960
1148
  }
961
- function getIsRemoteAssociationSupported() {
962
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1149
+ .left, .leftWrapper {
1150
+ left: 0;
963
1151
  }
964
- function isWebView(userAgentString) {
965
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1152
+ .right {
1153
+ left: -12px;
966
1154
  }
967
- function isSolanaMobileWebShell(userAgentString) {
968
- return userAgentString.includes("Solana Mobile Web Shell");
1155
+ .rightWrapper {
1156
+ right: 0;
969
1157
  }
970
- function getIsPwaLaunchedAsApp() {
971
- const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
972
- if (typeof window == "undefined") return isAndroidTwa;
973
- const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
974
- const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
975
- const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
976
- return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
1158
+ .circle {
1159
+ border: .125em solid #A8B6B8;
1160
+ width: 1.25em; /* 1.5em - 2*0.125em border */
1161
+ height: 1.25em; /* 1.5em - 2*0.125em border */
1162
+ border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
977
1163
  }
978
- async function checkLocalNetworkAccessPermission() {
979
- if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
980
- try {
981
- let lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
982
- if (lnaPermission.state === "granted") return;
983
- else if (lnaPermission.state === "denied") {
984
- const modal = new LoopbackPermissionBlockedModal();
985
- modal.init();
986
- modal.open();
987
- throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
988
- } else if (lnaPermission.state === "prompt") {
989
- const modal = new LoopbackPermissionModal();
990
- if (await new Promise((resolve, reject) => {
991
- modal.addEventListener("close", (event) => {
992
- if (event) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
993
- });
994
- lnaPermission.onchange = () => {
995
- lnaPermission.onchange = null;
996
- resolve(lnaPermission.state);
997
- };
998
- modal.init();
999
- modal.open();
1000
- }) === "granted") {
1001
- const modal = new LocalConnectionModal();
1002
- await new Promise((resolve, reject) => {
1003
- modal.addEventListener("close", (event) => {
1004
- if (event) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
1005
- });
1006
- modal.initWithCallback(async () => {
1007
- resolve(true);
1008
- });
1009
- modal.open();
1010
- });
1011
- return;
1012
- } else return await checkLocalNetworkAccessPermission();
1013
- }
1014
- throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
1015
- } catch (e) {
1016
- if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
1017
- if (e instanceof _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError) throw e;
1018
- throw new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
1019
- }
1164
+ .left {
1165
+ transform-origin: 100% 50%;
1166
+ animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
1167
+ }
1168
+ .right {
1169
+ transform-origin: 100% 50%;
1170
+ animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
1020
1171
  }
1172
+ `;
1173
+ //#endregion
1174
+ //#region src/icon.ts
1175
+ const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
1021
1176
  //#endregion
1022
1177
  //#region src/wallet.ts
1023
1178
  const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
@@ -1030,6 +1185,9 @@ const DEFAULT_FEATURES = [
1030
1185
  _solana_wallet_standard_features.SolanaSignIn
1031
1186
  ];
1032
1187
  const WALLET_ASSOCIATION_TIMEOUT = 3e4;
1188
+ function getErrorMessage(error) {
1189
+ return error instanceof Error ? error.message : "Unknown error";
1190
+ }
1033
1191
  var LocalSolanaMobileWalletAdapterWallet = class {
1034
1192
  #listeners = {};
1035
1193
  #version = "1.0.0";
@@ -1146,7 +1304,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1146
1304
  } else return { accounts: this.accounts };
1147
1305
  } else await this.#performAuthorization();
1148
1306
  } catch (e) {
1149
- throw new Error(e instanceof Error && e.message || "Unknown error");
1307
+ throw new Error(getErrorMessage(e), { cause: e });
1150
1308
  } finally {
1151
1309
  this.#connecting = false;
1152
1310
  }
@@ -1181,7 +1339,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1181
1339
  return authorization;
1182
1340
  });
1183
1341
  } catch (e) {
1184
- throw new Error(e instanceof Error && e.message || "Unknown error");
1342
+ throw new Error(getErrorMessage(e), { cause: e });
1185
1343
  }
1186
1344
  };
1187
1345
  #handleAuthorizationResult = async (authorization) => {
@@ -1224,7 +1382,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1224
1382
  Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
1225
1383
  } catch (e) {
1226
1384
  this.#disconnect();
1227
- throw new Error(e instanceof Error && e.message || "Unknown error");
1385
+ throw new Error(getErrorMessage(e), { cause: e });
1228
1386
  }
1229
1387
  };
1230
1388
  #disconnect = async () => {
@@ -1240,10 +1398,12 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1240
1398
  const currentConnectionGeneration = this.#connectionGeneration;
1241
1399
  const loadingSpinner = new EmbeddedLoadingSpinner();
1242
1400
  try {
1401
+ let associating = true;
1243
1402
  let timeout = void 0;
1244
1403
  const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
1245
1404
  loadingSpinner.init();
1246
1405
  const { wallet, close } = await (0, _solana_mobile_mobile_wallet_adapter_protocol.startScenario)(config);
1406
+ associating = false;
1247
1407
  loadingSpinner.addEventListener("close", (event) => {
1248
1408
  if (event) close();
1249
1409
  });
@@ -1254,7 +1414,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1254
1414
  return result;
1255
1415
  }), new Promise((_, reject) => {
1256
1416
  timeout = setTimeout(() => {
1257
- reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
1417
+ if (associating) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
1258
1418
  }, WALLET_ASSOCIATION_TIMEOUT);
1259
1419
  })]);
1260
1420
  clearTimeout(timeout);
@@ -1275,9 +1435,9 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1275
1435
  };
1276
1436
  #accountsToWalletStandardAccounts = (accounts) => {
1277
1437
  return accounts.map((account) => {
1278
- const publicKey = toUint8Array(account.address);
1438
+ const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
1279
1439
  return {
1280
- address: bs58.default.encode(publicKey),
1440
+ address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
1281
1441
  publicKey,
1282
1442
  label: account.label,
1283
1443
  icon: account.icon,
@@ -1290,31 +1450,31 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1290
1450
  const { authToken, chain } = this.#assertIsAuthorized();
1291
1451
  try {
1292
1452
  const base64Transactions = transactions.map((tx) => {
1293
- return fromUint8Array(tx);
1453
+ return (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(tx);
1294
1454
  });
1295
1455
  return await this.#transact(async (wallet) => {
1296
1456
  await this.#performReauthorization(wallet, authToken, chain);
1297
- return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
1457
+ return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array);
1298
1458
  });
1299
1459
  } catch (e) {
1300
- throw new Error(e instanceof Error && e.message || "Unknown error");
1460
+ throw new Error(getErrorMessage(e), { cause: e });
1301
1461
  }
1302
1462
  };
1303
1463
  #performSignAndSendTransaction = async (transaction, options) => {
1304
1464
  const { authToken, chain } = this.#assertIsAuthorized();
1305
1465
  try {
1306
1466
  return await this.#transact(async (wallet) => {
1307
- const [capabilities, _1] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1467
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1308
1468
  if (capabilities.supports_sign_and_send_transactions) {
1309
- const base64Transaction = fromUint8Array(transaction);
1469
+ const base64Transaction = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction);
1310
1470
  return (await wallet.signAndSendTransactions({
1311
1471
  ...options,
1312
1472
  payloads: [base64Transaction]
1313
- })).signatures.map(toUint8Array)[0];
1473
+ })).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
1314
1474
  } else throw new Error("connected wallet does not support signAndSendTransaction");
1315
1475
  });
1316
1476
  } catch (e) {
1317
- throw new Error(e instanceof Error && e.message || "Unknown error");
1477
+ throw new Error(getErrorMessage(e), { cause: e });
1318
1478
  }
1319
1479
  };
1320
1480
  #signAndSendTransaction = async (...inputs) => {
@@ -1332,15 +1492,15 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1332
1492
  };
1333
1493
  #signMessage = async (...inputs) => {
1334
1494
  const { authToken, chain } = this.#assertIsAuthorized();
1335
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
1336
- const messages = inputs.map(({ message }) => fromUint8Array(message));
1495
+ const addresses = inputs.map(({ account }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(new Uint8Array(account.publicKey)));
1496
+ const messages = inputs.map(({ message }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(message));
1337
1497
  try {
1338
1498
  return await this.#transact(async (wallet) => {
1339
1499
  await this.#performReauthorization(wallet, authToken, chain);
1340
1500
  return (await wallet.signMessages({
1341
1501
  addresses,
1342
1502
  payloads: messages
1343
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
1503
+ })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
1344
1504
  return {
1345
1505
  signedMessage,
1346
1506
  signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
@@ -1348,7 +1508,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1348
1508
  });
1349
1509
  });
1350
1510
  } catch (e) {
1351
- throw new Error(e instanceof Error && e.message || "Unknown error");
1511
+ throw new Error(getErrorMessage(e), { cause: e });
1352
1512
  }
1353
1513
  };
1354
1514
  #signIn = async (...inputs) => {
@@ -1369,16 +1529,16 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1369
1529
  const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
1370
1530
  return {
1371
1531
  account: {
1372
- ...signedInAccount ?? { address: bs58.default.encode(toUint8Array(signedInAddress)) },
1373
- publicKey: toUint8Array(signedInAddress),
1532
+ ...signedInAccount ?? { address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)((0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress)) },
1533
+ publicKey: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress),
1374
1534
  chains: signedInAccount?.chains ?? this.#chains,
1375
1535
  features: signedInAccount?.features ?? authorizationResult.capabilities.features
1376
1536
  },
1377
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
1378
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
1537
+ signedMessage: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signed_message),
1538
+ signature: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signature)
1379
1539
  };
1380
1540
  } catch (e) {
1381
- throw new Error(e instanceof Error && e.message || "Unknown error");
1541
+ throw new Error(getErrorMessage(e), { cause: e });
1382
1542
  } finally {
1383
1543
  this.#connecting = false;
1384
1544
  }
@@ -1491,13 +1651,13 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1491
1651
  #off(event, listener) {
1492
1652
  this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
1493
1653
  }
1494
- #connect = async ({ silent } = {}) => {
1654
+ #connect = async (_input = {}) => {
1495
1655
  if (this.#connecting || this.connected) return { accounts: this.accounts };
1496
1656
  this.#connecting = true;
1497
1657
  try {
1498
1658
  await this.#performAuthorization();
1499
1659
  } catch (e) {
1500
- throw new Error(e instanceof Error && e.message || "Unknown error");
1660
+ throw new Error(getErrorMessage(e), { cause: e });
1501
1661
  } finally {
1502
1662
  this.#connecting = false;
1503
1663
  }
@@ -1533,7 +1693,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1533
1693
  return authorizationResult;
1534
1694
  });
1535
1695
  } catch (e) {
1536
- throw new Error(e instanceof Error && e.message || "Unknown error");
1696
+ throw new Error(getErrorMessage(e), { cause: e });
1537
1697
  }
1538
1698
  };
1539
1699
  #handleAuthorizationResult = async (authorization) => {
@@ -1576,7 +1736,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1576
1736
  Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
1577
1737
  } catch (e) {
1578
1738
  this.#disconnect();
1579
- throw new Error(e instanceof Error && e.message || "Unknown error");
1739
+ throw new Error(getErrorMessage(e), { cause: e });
1580
1740
  }
1581
1741
  };
1582
1742
  #disconnect = async () => {
@@ -1628,9 +1788,9 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1628
1788
  };
1629
1789
  #accountsToWalletStandardAccounts = (accounts) => {
1630
1790
  return accounts.map((account) => {
1631
- const publicKey = toUint8Array(account.address);
1791
+ const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
1632
1792
  return {
1633
- address: bs58.default.encode(publicKey),
1793
+ address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
1634
1794
  publicKey,
1635
1795
  label: account.label,
1636
1796
  icon: account.icon,
@@ -1644,25 +1804,25 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1644
1804
  try {
1645
1805
  return await this.#transact(async (wallet) => {
1646
1806
  await this.#performReauthorization(wallet, authToken, chain);
1647
- return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
1807
+ return (await wallet.signTransactions({ payloads: transactions.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array) })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array);
1648
1808
  });
1649
1809
  } catch (e) {
1650
- throw new Error(e instanceof Error && e.message || "Unknown error");
1810
+ throw new Error(getErrorMessage(e), { cause: e });
1651
1811
  }
1652
1812
  };
1653
1813
  #performSignAndSendTransaction = async (transaction, options) => {
1654
1814
  const { authToken, chain } = this.#assertIsAuthorized();
1655
1815
  try {
1656
1816
  return await this.#transact(async (wallet) => {
1657
- const [capabilities, _1] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1817
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1658
1818
  if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
1659
1819
  ...options,
1660
- payloads: [fromUint8Array(transaction)]
1661
- })).signatures.map(toUint8Array)[0];
1820
+ payloads: [(0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction)]
1821
+ })).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
1662
1822
  else throw new Error("connected wallet does not support signAndSendTransaction");
1663
1823
  });
1664
1824
  } catch (e) {
1665
- throw new Error(e instanceof Error && e.message || "Unknown error");
1825
+ throw new Error(getErrorMessage(e), { cause: e });
1666
1826
  }
1667
1827
  };
1668
1828
  #signAndSendTransaction = async (...inputs) => {
@@ -1680,15 +1840,15 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1680
1840
  };
1681
1841
  #signMessage = async (...inputs) => {
1682
1842
  const { authToken, chain } = this.#assertIsAuthorized();
1683
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
1684
- const messages = inputs.map(({ message }) => fromUint8Array(message));
1843
+ const addresses = inputs.map(({ account }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(new Uint8Array(account.publicKey)));
1844
+ const messages = inputs.map(({ message }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(message));
1685
1845
  try {
1686
1846
  return await this.#transact(async (wallet) => {
1687
1847
  await this.#performReauthorization(wallet, authToken, chain);
1688
1848
  return (await wallet.signMessages({
1689
1849
  addresses,
1690
1850
  payloads: messages
1691
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
1851
+ })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
1692
1852
  return {
1693
1853
  signedMessage,
1694
1854
  signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
@@ -1696,7 +1856,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1696
1856
  });
1697
1857
  });
1698
1858
  } catch (e) {
1699
- throw new Error(e instanceof Error && e.message || "Unknown error");
1859
+ throw new Error(getErrorMessage(e), { cause: e });
1700
1860
  }
1701
1861
  };
1702
1862
  #signIn = async (...inputs) => {
@@ -1717,16 +1877,16 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1717
1877
  const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
1718
1878
  return {
1719
1879
  account: {
1720
- ...signedInAccount ?? { address: bs58.default.encode(toUint8Array(signedInAddress)) },
1721
- publicKey: toUint8Array(signedInAddress),
1880
+ ...signedInAccount ?? { address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)((0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress)) },
1881
+ publicKey: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress),
1722
1882
  chains: signedInAccount?.chains ?? this.#chains,
1723
1883
  features: signedInAccount?.features ?? authorizationResult.capabilities.features
1724
1884
  },
1725
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
1726
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
1885
+ signedMessage: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signed_message),
1886
+ signature: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signature)
1727
1887
  };
1728
1888
  } catch (e) {
1729
- throw new Error(e instanceof Error && e.message || "Unknown error");
1889
+ throw new Error(getErrorMessage(e), { cause: e });
1730
1890
  } finally {
1731
1891
  this.#connecting = false;
1732
1892
  }
@@ -1751,170 +1911,6 @@ function registerMwa(config) {
1751
1911
  }));
1752
1912
  }
1753
1913
  //#endregion
1754
- //#region src/embedded-modal/errorModal.ts
1755
- const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
1756
- const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = "This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.";
1757
- var ErrorModal = class extends EmbeddedModal {
1758
- contentStyles = css;
1759
- contentHtml = ErrorDialogHtml;
1760
- initWithError(error) {
1761
- super.init();
1762
- this.populateError(error);
1763
- }
1764
- populateError(error) {
1765
- const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
1766
- const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
1767
- if (errorMessageElement) {
1768
- if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
1769
- case "ERROR_WALLET_NOT_FOUND":
1770
- errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
1771
- if (actionBtn) actionBtn.addEventListener("click", () => {
1772
- window.location.href = "https://solanamobile.com/wallets";
1773
- });
1774
- return;
1775
- case "ERROR_BROWSER_NOT_SUPPORTED":
1776
- errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
1777
- if (actionBtn) actionBtn.style.display = "none";
1778
- return;
1779
- }
1780
- errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
1781
- } else console.log("Failed to locate error dialog element");
1782
- }
1783
- };
1784
- const ErrorDialogHtml = `
1785
- <svg class="mobile-wallet-adapter-embedded-modal-error-icon" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#000000"><path d="M 280,-80 Q 197,-80 138.5,-138.5 80,-197 80,-280 80,-363 138.5,-421.5 197,-480 280,-480 q 83,0 141.5,58.5 58.5,58.5 58.5,141.5 0,83 -58.5,141.5 Q 363,-80 280,-80 Z M 824,-120 568,-376 Q 556,-389 542.5,-402.5 529,-416 516,-428 q 38,-24 61,-64 23,-40 23,-88 0,-75 -52.5,-127.5 Q 495,-760 420,-760 345,-760 292.5,-707.5 240,-655 240,-580 q 0,6 0.5,11.5 0.5,5.5 1.5,11.5 -18,2 -39.5,8 -21.5,6 -38.5,14 -2,-11 -3,-22 -1,-11 -1,-23 0,-109 75.5,-184.5 Q 311,-840 420,-840 q 109,0 184.5,75.5 75.5,75.5 75.5,184.5 0,43 -13.5,81.5 Q 653,-460 629,-428 l 251,252 z m -615,-61 71,-71 70,71 29,-28 -71,-71 71,-71 -28,-28 -71,71 -71,-71 -28,28 71,71 -71,71 z"/></svg>
1786
- <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
1787
- <div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
1788
- <div>
1789
- <button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
1790
- Find a wallet
1791
- </button>
1792
- </div>
1793
- `;
1794
- const css = `
1795
- .mobile-wallet-adapter-embedded-modal-content {
1796
- text-align: center;
1797
- }
1798
-
1799
- .mobile-wallet-adapter-embedded-modal-error-icon {
1800
- margin-top: 24px;
1801
- }
1802
-
1803
- .mobile-wallet-adapter-embedded-modal-title {
1804
- margin: 18px 100px auto 100px;
1805
- color: #000000;
1806
- font-size: 2.75em;
1807
- font-weight: 600;
1808
- }
1809
-
1810
- .mobile-wallet-adapter-embedded-modal-subtitle {
1811
- margin: 30px 60px 40px 60px;
1812
- color: #000000;
1813
- font-size: 1.25em;
1814
- font-weight: 400;
1815
- }
1816
-
1817
- .mobile-wallet-adapter-embedded-modal-error-action {
1818
- display: block;
1819
- width: 100%;
1820
- height: 56px;
1821
- /*margin-top: 40px;*/
1822
- font-size: 1.25em;
1823
- /*line-height: 24px;*/
1824
- /*letter-spacing: -1%;*/
1825
- background: #000000;
1826
- color: #FFFFFF;
1827
- border-radius: 18px;
1828
- }
1829
-
1830
- /* Smaller screens */
1831
- @media all and (max-width: 600px) {
1832
- .mobile-wallet-adapter-embedded-modal-title {
1833
- font-size: 1.5em;
1834
- margin-right: 12px;
1835
- margin-left: 12px;
1836
- }
1837
- .mobile-wallet-adapter-embedded-modal-subtitle {
1838
- margin-right: 12px;
1839
- margin-left: 12px;
1840
- }
1841
- }
1842
- `;
1843
- //#endregion
1844
- //#region src/createDefaultWalletNotFoundHandler.ts
1845
- async function defaultErrorModalWalletNotFoundHandler() {
1846
- if (typeof window !== "undefined") {
1847
- const userAgent = window.navigator.userAgent.toLowerCase();
1848
- const errorDialog = new ErrorModal();
1849
- if (userAgent.includes("wv")) errorDialog.initWithError({
1850
- name: "SolanaMobileWalletAdapterError",
1851
- code: "ERROR_BROWSER_NOT_SUPPORTED",
1852
- message: ""
1853
- });
1854
- else errorDialog.initWithError({
1855
- name: "SolanaMobileWalletAdapterError",
1856
- code: "ERROR_WALLET_NOT_FOUND",
1857
- message: ""
1858
- });
1859
- errorDialog.open();
1860
- }
1861
- }
1862
- function createDefaultWalletNotFoundHandler() {
1863
- return async () => {
1864
- defaultErrorModalWalletNotFoundHandler();
1865
- };
1866
- }
1867
- //#endregion
1868
- //#region src/createDefaultAuthorizationCache.ts
1869
- const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
1870
- function createDefaultAuthorizationCache() {
1871
- let storage;
1872
- try {
1873
- storage = window.localStorage;
1874
- } catch {}
1875
- return {
1876
- async clear() {
1877
- if (!storage) return;
1878
- try {
1879
- storage.removeItem(CACHE_KEY);
1880
- } catch {}
1881
- },
1882
- async get() {
1883
- if (!storage) return;
1884
- try {
1885
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
1886
- if (parsed && parsed.accounts) {
1887
- const parsedAccounts = parsed.accounts.map((account) => {
1888
- return {
1889
- ...account,
1890
- publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : bs58.default.decode(account.address)
1891
- };
1892
- });
1893
- return {
1894
- ...parsed,
1895
- accounts: parsedAccounts
1896
- };
1897
- } else return parsed || void 0;
1898
- } catch {}
1899
- },
1900
- async set(authorization) {
1901
- if (!storage) return;
1902
- try {
1903
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
1904
- } catch {}
1905
- }
1906
- };
1907
- }
1908
- //#endregion
1909
- //#region src/createDefaultChainSelector.ts
1910
- function createDefaultChainSelector() {
1911
- return { async select(chains) {
1912
- if (chains.length === 1) return chains[0];
1913
- else if (chains.includes(_solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN)) return _solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN;
1914
- else return chains[0];
1915
- } };
1916
- }
1917
- //#endregion
1918
1914
  exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
1919
1915
  exports.RemoteSolanaMobileWalletAdapterWallet = RemoteSolanaMobileWalletAdapterWallet;
1920
1916
  exports.SolanaMobileWalletAdapterRemoteWalletName = SolanaMobileWalletAdapterRemoteWalletName;