@solana-mobile/wallet-standard-mobile 0.5.2 → 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,170 +21,61 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
24
+ let _react_native_async_storage_async_storage = require("@react-native-async-storage/async-storage");
25
+ _react_native_async_storage_async_storage = __toESM(_react_native_async_storage_async_storage);
26
+ let _solana_mobile_mobile_wallet_adapter_protocol_encoding = require("@solana-mobile/mobile-wallet-adapter-protocol/encoding");
27
+ let _solana_wallet_standard_chains = require("@solana/wallet-standard-chains");
28
+ let _wallet_standard_wallet = require("@wallet-standard/wallet");
25
29
  let _solana_mobile_mobile_wallet_adapter_protocol = require("@solana-mobile/mobile-wallet-adapter-protocol");
30
+ let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
26
31
  let _wallet_standard_features = require("@wallet-standard/features");
27
- let bs58 = require("bs58");
28
- bs58 = __toESM(bs58);
29
- let js_base64 = require("js-base64");
30
32
  let qrcode = require("qrcode");
31
33
  qrcode = __toESM(qrcode);
32
- let _wallet_standard_wallet = require("@wallet-standard/wallet");
33
- let _react_native_async_storage_async_storage = require("@react-native-async-storage/async-storage");
34
- _react_native_async_storage_async_storage = __toESM(_react_native_async_storage_async_storage);
35
- let _solana_wallet_standard_chains = require("@solana/wallet-standard-chains");
36
- //#region src/embedded-modal/loadingSpinner.ts
37
- const modalHtml$1 = `
38
- <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
39
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
40
- <div class="mobile-wallet-adapter-embedded-loading-container">
41
- <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
42
- </div>
43
- </div>
44
- `;
45
- const css$6 = `
46
- .mobile-wallet-adapter-embedded-loading-indicator {
47
- display: flex; /* Use flexbox to center content */
48
- justify-content: center; /* Center horizontally */
49
- align-items: start; /* Center vertically */
50
- position: fixed; /* Stay in place */
51
- z-index: 1; /* Sit on top */
52
- left: 0;
53
- top: 0;
54
- width: 100%; /* Full width */
55
- height: 100%; /* Full height */
56
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
57
- overflow-y: auto; /* enable scrolling */
58
- }
59
-
60
- .mobile-wallet-adapter-embedded-loading-container {
61
- display: flex;
62
- margin: auto;
63
- }
64
-
65
- .mobile-wallet-adapter-embedded-loading-animation {
66
- position: relative;
67
- left: -9999px;
68
- width: 10px;
69
- height: 10px;
70
- border-radius: 5px;
71
- background-color: var(--spinner-color);
72
- color: var(--spinner-color);
73
- box-shadow: 9984px 0 0 0 var(--spinner-color),
74
- 9999px 0 0 0 var(--spinner-color),
75
- 10014px 0 0 0 var(--spinner-color);
76
- animation: dot-typing 1.5s infinite linear;
34
+ //#region src/__forks__/react-native/createDefaultAuthorizationCache.ts
35
+ const CACHE_KEY = "SolanaMobileWalletAdapterWalletStandardDefaultAuthorizationCache";
36
+ function createDefaultAuthorizationCache() {
37
+ return {
38
+ async clear() {
39
+ try {
40
+ await _react_native_async_storage_async_storage.default.removeItem(CACHE_KEY);
41
+ } catch {}
42
+ },
43
+ async get() {
44
+ try {
45
+ const parsed = JSON.parse(await _react_native_async_storage_async_storage.default.getItem(CACHE_KEY));
46
+ if (parsed && parsed.accounts) {
47
+ const parsedAccounts = parsed.accounts.map((account) => {
48
+ return {
49
+ ...account,
50
+ publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58ToUint8Array)(account.address)
51
+ };
52
+ });
53
+ return {
54
+ ...parsed,
55
+ accounts: parsedAccounts
56
+ };
57
+ } else return parsed || void 0;
58
+ } catch {}
59
+ },
60
+ async set(authorizationResult) {
61
+ try {
62
+ await _react_native_async_storage_async_storage.default.setItem(CACHE_KEY, JSON.stringify(authorizationResult));
63
+ } catch {}
64
+ }
65
+ };
77
66
  }
78
-
79
- @keyframes dot-typing {
80
- 0% {
81
- box-shadow: 9984px 0 0 0 var(--spinner-color),
82
- 9999px 0 0 0 var(--spinner-color),
83
- 10014px 0 0 0 var(--spinner-color);
84
- }
85
- 16.667% {
86
- box-shadow: 9984px -10px 0 0 var(--spinner-color),
87
- 9999px 0 0 0 var(--spinner-color),
88
- 10014px 0 0 0 var(--spinner-color);
89
- }
90
- 33.333% {
91
- box-shadow: 9984px 0 0 0 var(--spinner-color),
92
- 9999px 0 0 0 var(--spinner-color),
93
- 10014px 0 0 0 var(--spinner-color);
94
- }
95
- 50% {
96
- box-shadow: 9984px 0 0 0 var(--spinner-color),
97
- 9999px -10px 0 0 var(--spinner-color),
98
- 10014px 0 0 0 var(--spinner-color);
99
- }
100
- 66.667% {
101
- box-shadow: 9984px 0 0 0 var(--spinner-color),
102
- 9999px 0 0 0 var(--spinner-color),
103
- 10014px 0 0 0 var(--spinner-color);
104
- }
105
- 83.333% {
106
- box-shadow: 9984px 0 0 0 var(--spinner-color),
107
- 9999px 0 0 0 var(--spinner-color),
108
- 10014px -10px 0 0 var(--spinner-color);
109
- }
110
- 100% {
111
- box-shadow: 9984px 0 0 0 var(--spinner-color),
112
- 9999px 0 0 0 var(--spinner-color),
113
- 10014px 0 0 0 var(--spinner-color);
114
- }
67
+ //#endregion
68
+ //#region src/createDefaultChainSelector.ts
69
+ function createDefaultChainSelector() {
70
+ return { async select(chains) {
71
+ if (chains.length === 1) return chains[0];
72
+ else if (chains.includes(_solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN)) return _solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN;
73
+ else return chains[0];
74
+ } };
115
75
  }
116
- `;
117
- var EmbeddedLoadingSpinner = class {
118
- #root = null;
119
- #eventListeners = {};
120
- #listenersAttached = false;
121
- dom = null;
122
- constructor() {
123
- this.init = this.init.bind(this);
124
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
125
- }
126
- async init() {
127
- console.log("Injecting modal");
128
- this.#injectHTML();
129
- }
130
- open = () => {
131
- console.debug("Modal open");
132
- this.#attachEventListeners();
133
- if (this.#root) this.#root.style.display = "flex";
134
- };
135
- close = (event = void 0) => {
136
- console.debug("Modal close");
137
- this.#removeEventListeners();
138
- if (this.#root) this.#root.style.display = "none";
139
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
140
- };
141
- addEventListener(event, listener) {
142
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
143
- return () => this.removeEventListener(event, listener);
144
- }
145
- removeEventListener(event, listener) {
146
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
147
- }
148
- #injectHTML() {
149
- if (this.dom) return;
150
- this.#root = document.createElement("div");
151
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
152
- this.#root.innerHTML = modalHtml$1;
153
- this.#root.style.display = "none";
154
- const styles = document.createElement("style");
155
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
156
- styles.textContent = css$6;
157
- const host = document.createElement("div");
158
- this.dom = host.attachShadow({ mode: "closed" });
159
- host.style.setProperty("--spinner-color", "#FFFFFF");
160
- this.dom.appendChild(styles);
161
- this.dom.appendChild(this.#root);
162
- document.body.appendChild(host);
163
- }
164
- #attachEventListeners() {
165
- if (!this.#root || this.#listenersAttached) return;
166
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
167
- this.close(event);
168
- }));
169
- window.addEventListener("load", this.close);
170
- document.addEventListener("keydown", this.#handleKeyDown);
171
- this.#listenersAttached = true;
172
- }
173
- #removeEventListeners() {
174
- if (!this.#listenersAttached) return;
175
- window.removeEventListener("load", this.close);
176
- document.removeEventListener("keydown", this.#handleKeyDown);
177
- if (!this.#root) return;
178
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
179
- this.#listenersAttached = false;
180
- }
181
- #handleKeyDown = (event) => {
182
- if (event.key === "Escape") this.close(event);
183
- };
184
- };
185
76
  //#endregion
186
77
  //#region src/embedded-modal/modal.ts
187
- const modalHtml = `
78
+ const modalHtml$1 = `
188
79
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
189
80
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
190
81
  <div class="mobile-wallet-adapter-embedded-modal-card">
@@ -199,7 +90,7 @@ const modalHtml = `
199
90
  </div>
200
91
  </div>
201
92
  `;
202
- const css$5 = `
93
+ const css$6 = `
203
94
  .mobile-wallet-adapter-embedded-modal-container {
204
95
  display: flex; /* Use flexbox to center content */
205
96
  justify-content: center; /* Center horizontally */
@@ -299,13 +190,13 @@ var EmbeddedModal = class {
299
190
  }
300
191
  this.#root = document.createElement("div");
301
192
  this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
302
- this.#root.innerHTML = modalHtml;
193
+ this.#root.innerHTML = modalHtml$1;
303
194
  this.#root.style.display = "none";
304
195
  const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
305
196
  if (content) content.innerHTML = this.contentHtml;
306
197
  const styles = document.createElement("style");
307
198
  styles.id = "mobile-wallet-adapter-embedded-modal-styles";
308
- styles.textContent = css$5 + this.contentStyles;
199
+ styles.textContent = css$6 + this.contentStyles;
309
200
  const host = document.createElement("div");
310
201
  host.innerHTML = fonts;
311
202
  this.dom = host.attachShadow({ mode: "closed" });
@@ -333,292 +224,124 @@ var EmbeddedModal = class {
333
224
  };
334
225
  };
335
226
  //#endregion
336
- //#region src/embedded-modal/remoteConnectionModal.ts
337
- var RemoteConnectionModal = class extends EmbeddedModal {
338
- contentStyles = css$4;
339
- contentHtml = QRCodeHtml;
340
- async initWithQR(qrCode) {
227
+ //#region src/embedded-modal/errorModal.ts
228
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
229
+ 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.";
230
+ var ErrorModal = class extends EmbeddedModal {
231
+ contentStyles = css$5;
232
+ contentHtml = ErrorDialogHtml$3;
233
+ initWithError(error) {
341
234
  super.init();
342
- this.populateQRCode(qrCode);
235
+ this.populateError(error);
343
236
  }
344
- async populateQRCode(qrUrl) {
345
- const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
346
- if (qrcodeContainer) {
347
- const qrCodeElement = await qrcode.default.toCanvas(qrUrl, {
348
- width: 200,
349
- margin: 0
350
- });
351
- if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
352
- else qrcodeContainer.appendChild(qrCodeElement);
353
- const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
354
- if (qrPlaceholder) qrPlaceholder.style.display = "none";
355
- } else console.error("QRCode Container not found");
237
+ populateError(error) {
238
+ const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
239
+ const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
240
+ if (errorMessageElement) {
241
+ if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
242
+ case "ERROR_WALLET_NOT_FOUND":
243
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
244
+ if (actionBtn) actionBtn.addEventListener("click", () => {
245
+ window.location.href = "https://solanamobile.com/wallets";
246
+ });
247
+ return;
248
+ case "ERROR_BROWSER_NOT_SUPPORTED":
249
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
250
+ if (actionBtn) actionBtn.style.display = "none";
251
+ return;
252
+ }
253
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
254
+ } else console.log("Failed to locate error dialog element");
356
255
  }
357
256
  };
358
- const QRCodeHtml = `
359
- <div class="mobile-wallet-adapter-embedded-modal-qr-content">
360
- <div>
361
- <svg class="mobile-wallet-adapter-embedded-modal-icon" width="100%" height="100%">
362
- <circle r="52" cx="53" cy="53" fill="#99b3be" stroke="#000000" stroke-width="2"/>
363
- <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"/>
364
- </svg>
365
- <div class="mobile-wallet-adapter-embedded-modal-title">Remote Mobile Wallet Adapter</div>
366
- </div>
367
- <div>
368
- <div>
369
- <h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
370
- Open your wallet and scan this code
371
- </h4>
372
- </div>
373
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
374
- <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
375
- </div>
376
- </div>
377
- </div>
378
- <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
379
- <div class="mobile-wallet-adapter-embedded-modal-footer">
380
- <div class="mobile-wallet-adapter-embedded-modal-subtitle">
381
- Follow the instructions on your device. When you're finished, this screen will update.
382
- </div>
383
- <div class="mobile-wallet-adapter-embedded-modal-progress-badge">
384
- <div>
385
- <div class="spinner">
386
- <div class="leftWrapper">
387
- <div class="left">
388
- <div class="circle"></div>
389
- </div>
390
- </div>
391
- <div class="rightWrapper">
392
- <div class="right">
393
- <div class="circle"></div>
394
- </div>
395
- </div>
396
- </div>
397
- </div>
398
- <div>Waiting for scan</div>
399
- </div>
257
+ const ErrorDialogHtml$3 = `
258
+ <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>
259
+ <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
260
+ <div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
261
+ <div>
262
+ <button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
263
+ Find a wallet
264
+ </button>
400
265
  </div>
401
266
  `;
402
- const css$4 = `
403
- .mobile-wallet-adapter-embedded-modal-qr-content {
404
- display: flex;
405
- margin-top: 10px;
406
- padding: 10px;
407
- }
408
-
409
- .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
410
- display: flex;
411
- flex-direction: column;
412
- flex: 2;
413
- margin-top: auto;
414
- margin-right: 30px;
415
- }
416
-
417
- .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
418
- display: flex;
419
- flex-direction: column;
420
- flex: 1;
421
- margin-left: auto;
267
+ const css$5 = `
268
+ .mobile-wallet-adapter-embedded-modal-content {
269
+ text-align: center;
422
270
  }
423
271
 
424
- .mobile-wallet-adapter-embedded-modal-footer {
425
- display: flex;
426
- padding: 10px;
272
+ .mobile-wallet-adapter-embedded-modal-error-icon {
273
+ margin-top: 24px;
427
274
  }
428
275
 
429
- .mobile-wallet-adapter-embedded-modal-icon {}
430
-
431
276
  .mobile-wallet-adapter-embedded-modal-title {
277
+ margin: 18px 100px auto 100px;
432
278
  color: #000000;
433
- font-size: 2.5em;
279
+ font-size: 2.75em;
434
280
  font-weight: 600;
435
281
  }
436
282
 
437
- .mobile-wallet-adapter-embedded-modal-qr-label {
438
- text-align: right;
439
- color: #000000;
440
- }
441
-
442
- .mobile-wallet-adapter-embedded-modal-qr-code-container {
443
- margin-left: auto;
444
- }
445
-
446
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
447
- margin-left: auto;
448
- min-width: 200px;
449
- min-height: 200px;
450
- background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
451
- background-size: 200%;
452
- animation: placeholderAnimate 2.7s linear infinite;
453
- border-radius: 12px;
454
- }
455
-
456
- .mobile-wallet-adapter-embedded-modal-divider {
457
- margin-top: 20px;
458
- padding-left: 10px;
459
- padding-right: 10px;
460
- }
461
-
462
- .mobile-wallet-adapter-embedded-modal-divider hr {
463
- border-top: 1px solid #D9DEDE;
464
- }
465
-
466
283
  .mobile-wallet-adapter-embedded-modal-subtitle {
467
- margin: auto;
468
- margin-right: 60px;
469
- padding: 20px;
470
- color: #6E8286;
284
+ margin: 30px 60px 40px 60px;
285
+ color: #000000;
286
+ font-size: 1.25em;
287
+ font-weight: 400;
471
288
  }
472
289
 
473
- .mobile-wallet-adapter-embedded-modal-progress-badge {
474
- display: flex;
475
- background: #F7F8F8;
290
+ .mobile-wallet-adapter-embedded-modal-error-action {
291
+ display: block;
292
+ width: 100%;
476
293
  height: 56px;
477
- min-width: 200px;
478
- margin: auto;
479
- padding-left: 20px;
480
- padding-right: 20px;
294
+ /*margin-top: 40px;*/
295
+ font-size: 1.25em;
296
+ /*line-height: 24px;*/
297
+ /*letter-spacing: -1%;*/
298
+ background: #000000;
299
+ color: #FFFFFF;
481
300
  border-radius: 18px;
482
- color: #A8B6B8;
483
- align-items: center;
484
- }
485
-
486
- .mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
487
- margin-left: auto;
488
- margin-right: 20px;
489
- }
490
-
491
- .mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
492
- margin-right: auto;
493
301
  }
494
302
 
495
303
  /* Smaller screens */
496
304
  @media all and (max-width: 600px) {
497
- .mobile-wallet-adapter-embedded-modal-card {
498
- text-align: center;
499
- }
500
- .mobile-wallet-adapter-embedded-modal-qr-content {
501
- flex-direction: column;
502
- }
503
- .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
504
- margin: auto;
505
- }
506
- .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
507
- margin: auto;
508
- flex: 2 auto;
509
- }
510
- .mobile-wallet-adapter-embedded-modal-footer {
511
- flex-direction: column;
512
- }
513
- .mobile-wallet-adapter-embedded-modal-icon {
514
- display: none;
515
- }
516
305
  .mobile-wallet-adapter-embedded-modal-title {
517
306
  font-size: 1.5em;
307
+ margin-right: 12px;
308
+ margin-left: 12px;
518
309
  }
519
310
  .mobile-wallet-adapter-embedded-modal-subtitle {
520
- margin-right: unset;
521
- }
522
- .mobile-wallet-adapter-embedded-modal-qr-label {
523
- text-align: center;
524
- }
525
- .mobile-wallet-adapter-embedded-modal-qr-code-container {
526
- margin: auto;
527
- }
528
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
529
- margin: auto;
530
- }
531
- }
532
-
533
- /* QR Placeholder */
534
- @keyframes placeholderAnimate {
535
- 0% { background-position: 200% 0; }
536
- 100% { background-position: -200% 0; }
537
- }
538
-
539
- /* Spinner */
540
- @keyframes spinLeft {
541
- 0% {
542
- transform: rotate(20deg);
543
- }
544
- 50% {
545
- transform: rotate(160deg);
546
- }
547
- 100% {
548
- transform: rotate(20deg);
549
- }
550
- }
551
- @keyframes spinRight {
552
- 0% {
553
- transform: rotate(160deg);
554
- }
555
- 50% {
556
- transform: rotate(20deg);
557
- }
558
- 100% {
559
- transform: rotate(160deg);
560
- }
561
- }
562
- @keyframes spin {
563
- 0% {
564
- transform: rotate(0deg);
565
- }
566
- 100% {
567
- transform: rotate(2520deg);
311
+ margin-right: 12px;
312
+ margin-left: 12px;
568
313
  }
569
314
  }
570
-
571
- .spinner {
572
- position: relative;
573
- width: 1.5em;
574
- height: 1.5em;
575
- margin: auto;
576
- animation: spin 10s linear infinite;
577
- }
578
- .spinner::before {
579
- content: "";
580
- position: absolute;
581
- top: 0;
582
- bottom: 0;
583
- left: 0;
584
- right: 0;
585
- }
586
- .right, .rightWrapper, .left, .leftWrapper {
587
- position: absolute;
588
- top: 0;
589
- overflow: hidden;
590
- width: .75em;
591
- height: 1.5em;
592
- }
593
- .left, .leftWrapper {
594
- left: 0;
595
- }
596
- .right {
597
- left: -12px;
598
- }
599
- .rightWrapper {
600
- right: 0;
601
- }
602
- .circle {
603
- border: .125em solid #A8B6B8;
604
- width: 1.25em; /* 1.5em - 2*0.125em border */
605
- height: 1.25em; /* 1.5em - 2*0.125em border */
606
- border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
607
- }
608
- .left {
609
- transform-origin: 100% 50%;
610
- animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
611
- }
612
- .right {
613
- transform-origin: 100% 50%;
614
- animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
615
- }
616
315
  `;
617
316
  //#endregion
618
- //#region src/embedded-modal/localConnectionModal.ts
619
- var LocalConnectionModal = class extends EmbeddedModal {
620
- contentStyles = css$3;
621
- contentHtml = ErrorDialogHtml$3;
317
+ //#region src/createDefaultWalletNotFoundHandler.ts
318
+ async function defaultErrorModalWalletNotFoundHandler() {
319
+ if (typeof window !== "undefined") {
320
+ const userAgent = window.navigator.userAgent.toLowerCase();
321
+ const errorDialog = new ErrorModal();
322
+ if (userAgent.includes("wv")) errorDialog.initWithError({
323
+ name: "SolanaMobileWalletAdapterError",
324
+ code: "ERROR_BROWSER_NOT_SUPPORTED",
325
+ message: ""
326
+ });
327
+ else errorDialog.initWithError({
328
+ name: "SolanaMobileWalletAdapterError",
329
+ code: "ERROR_WALLET_NOT_FOUND",
330
+ message: ""
331
+ });
332
+ errorDialog.open();
333
+ }
334
+ }
335
+ function createDefaultWalletNotFoundHandler() {
336
+ return async () => {
337
+ defaultErrorModalWalletNotFoundHandler();
338
+ };
339
+ }
340
+ //#endregion
341
+ //#region src/embedded-modal/localConnectionModal.ts
342
+ var LocalConnectionModal = class extends EmbeddedModal {
343
+ contentStyles = css$4;
344
+ contentHtml = ErrorDialogHtml$2;
622
345
  initWithCallback(callback) {
623
346
  super.init();
624
347
  this.#prepareLaunchAction(callback);
@@ -633,7 +356,7 @@ var LocalConnectionModal = class extends EmbeddedModal {
633
356
  launchButton?.addEventListener("click", listener);
634
357
  }
635
358
  };
636
- const ErrorDialogHtml$3 = `
359
+ const ErrorDialogHtml$2 = `
637
360
  <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">
638
361
  <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"/>
639
362
  <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
@@ -655,7 +378,7 @@ const ErrorDialogHtml$3 = `
655
378
  </button>
656
379
  </div>
657
380
  `;
658
- const css$3 = `
381
+ const css$4 = `
659
382
  .mobile-wallet-adapter-embedded-modal-close {
660
383
  display: none;
661
384
  }
@@ -693,10 +416,10 @@ const css$3 = `
693
416
  //#endregion
694
417
  //#region src/embedded-modal/loopbackBlockedModal.ts
695
418
  var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
696
- contentStyles = css$2;
419
+ contentStyles = css$3;
697
420
  get contentHtml() {
698
421
  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";
699
- return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
422
+ return ErrorDialogHtml$1.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
700
423
  }
701
424
  async init() {
702
425
  super.init();
@@ -711,7 +434,7 @@ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
711
434
  launchButton?.addEventListener("click", listener);
712
435
  }
713
436
  };
714
- const ErrorDialogHtml$2 = `
437
+ const ErrorDialogHtml$1 = `
715
438
  <div class="mobile-wallet-adapter-embedded-modal-header">
716
439
  Local Wallet Connection
717
440
  </div>
@@ -764,7 +487,7 @@ const ErrorDialogHtml$2 = `
764
487
  </button>
765
488
  </div>
766
489
  `;
767
- const css$2 = `
490
+ const css$3 = `
768
491
  .mobile-wallet-adapter-embedded-modal-close {
769
492
  display: none;
770
493
  }
@@ -854,8 +577,8 @@ const css$2 = `
854
577
  //#endregion
855
578
  //#region src/embedded-modal/loopbackPermissionModal.ts
856
579
  var LoopbackPermissionModal = class extends EmbeddedModal {
857
- contentStyles = css$1;
858
- contentHtml = ErrorDialogHtml$1;
580
+ contentStyles = css$2;
581
+ contentHtml = ErrorDialogHtml;
859
582
  async init() {
860
583
  super.init();
861
584
  this.#prepareLaunchAction();
@@ -872,7 +595,7 @@ var LoopbackPermissionModal = class extends EmbeddedModal {
872
595
  launchButton?.addEventListener("click", listener);
873
596
  }
874
597
  };
875
- const ErrorDialogHtml$1 = `
598
+ const ErrorDialogHtml = `
876
599
  <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
877
600
  <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
878
601
  Tap "Allow" on the next screen
@@ -898,7 +621,7 @@ const ErrorDialogHtml$1 = `
898
621
  </button>
899
622
  </div>
900
623
  `;
901
- const css$1 = `
624
+ const css$2 = `
902
625
  .mobile-wallet-adapter-embedded-modal-close {
903
626
  display: none;
904
627
  }
@@ -932,84 +655,516 @@ const css$1 = `
932
655
  color: #FFFFFF;
933
656
  border-radius: 18px;
934
657
  }
935
- /* Smaller screens */
936
- @media all and (max-width: 600px) {
937
- .mobile-wallet-adapter-embedded-modal-title {
938
- font-size: 1.5em;
939
- margin-right: 12px;
940
- margin-left: 12px;
941
- }
942
- .mobile-wallet-adapter-embedded-modal-subtitle {
943
- margin-right: 12px;
944
- margin-left: 12px;
945
- }
658
+ /* Smaller screens */
659
+ @media all and (max-width: 600px) {
660
+ .mobile-wallet-adapter-embedded-modal-title {
661
+ font-size: 1.5em;
662
+ margin-right: 12px;
663
+ margin-left: 12px;
664
+ }
665
+ .mobile-wallet-adapter-embedded-modal-subtitle {
666
+ margin-right: 12px;
667
+ margin-left: 12px;
668
+ }
669
+ }
670
+ `;
671
+ //#endregion
672
+ //#region src/getIsSupported.ts
673
+ function getIsLocalAssociationSupported() {
674
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
675
+ }
676
+ function getIsRemoteAssociationSupported() {
677
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
678
+ }
679
+ function isWebView(userAgentString) {
680
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
681
+ }
682
+ function isSolanaMobileWebShell(userAgentString) {
683
+ return userAgentString.includes("Solana Mobile Web Shell");
684
+ }
685
+ function getIsPwaLaunchedAsApp() {
686
+ const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
687
+ if (typeof window == "undefined") return isAndroidTwa;
688
+ const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
689
+ const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
690
+ const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
691
+ return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
692
+ }
693
+ async function checkLocalNetworkAccessPermission() {
694
+ if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
695
+ try {
696
+ const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
697
+ if (lnaPermission.state === "granted") return;
698
+ else if (lnaPermission.state === "denied") {
699
+ const modal = new LoopbackPermissionBlockedModal();
700
+ modal.init();
701
+ modal.open();
702
+ 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");
703
+ } else if (lnaPermission.state === "prompt") {
704
+ const modal = new LoopbackPermissionModal();
705
+ if (await new Promise((resolve, reject) => {
706
+ modal.addEventListener("close", (event) => {
707
+ 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 }));
708
+ });
709
+ lnaPermission.onchange = () => {
710
+ lnaPermission.onchange = null;
711
+ resolve(lnaPermission.state);
712
+ };
713
+ modal.init();
714
+ modal.open();
715
+ }) === "granted") {
716
+ const modal = new LocalConnectionModal();
717
+ await new Promise((resolve, reject) => {
718
+ modal.addEventListener("close", (event) => {
719
+ 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 }));
720
+ });
721
+ modal.initWithCallback(async () => {
722
+ resolve(true);
723
+ });
724
+ modal.open();
725
+ });
726
+ return;
727
+ } else return await checkLocalNetworkAccessPermission();
728
+ }
729
+ 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");
730
+ } catch (e) {
731
+ if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
732
+ if (e instanceof _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError) throw e;
733
+ 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");
734
+ }
735
+ }
736
+ //#endregion
737
+ //#region src/embedded-modal/loadingSpinner.ts
738
+ const modalHtml = `
739
+ <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
740
+ <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
741
+ <div class="mobile-wallet-adapter-embedded-loading-container">
742
+ <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
743
+ </div>
744
+ </div>
745
+ `;
746
+ const css$1 = `
747
+ .mobile-wallet-adapter-embedded-loading-indicator {
748
+ display: flex; /* Use flexbox to center content */
749
+ justify-content: center; /* Center horizontally */
750
+ align-items: start; /* Center vertically */
751
+ position: fixed; /* Stay in place */
752
+ z-index: 1; /* Sit on top */
753
+ left: 0;
754
+ top: 0;
755
+ width: 100%; /* Full width */
756
+ height: 100%; /* Full height */
757
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
758
+ overflow-y: auto; /* enable scrolling */
759
+ }
760
+
761
+ .mobile-wallet-adapter-embedded-loading-container {
762
+ display: flex;
763
+ margin: auto;
764
+ }
765
+
766
+ .mobile-wallet-adapter-embedded-loading-animation {
767
+ position: relative;
768
+ left: -9999px;
769
+ width: 10px;
770
+ height: 10px;
771
+ border-radius: 5px;
772
+ background-color: var(--spinner-color);
773
+ color: var(--spinner-color);
774
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
775
+ 9999px 0 0 0 var(--spinner-color),
776
+ 10014px 0 0 0 var(--spinner-color);
777
+ animation: dot-typing 1.5s infinite linear;
778
+ }
779
+
780
+ @keyframes dot-typing {
781
+ 0% {
782
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
783
+ 9999px 0 0 0 var(--spinner-color),
784
+ 10014px 0 0 0 var(--spinner-color);
785
+ }
786
+ 16.667% {
787
+ box-shadow: 9984px -10px 0 0 var(--spinner-color),
788
+ 9999px 0 0 0 var(--spinner-color),
789
+ 10014px 0 0 0 var(--spinner-color);
790
+ }
791
+ 33.333% {
792
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
793
+ 9999px 0 0 0 var(--spinner-color),
794
+ 10014px 0 0 0 var(--spinner-color);
795
+ }
796
+ 50% {
797
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
798
+ 9999px -10px 0 0 var(--spinner-color),
799
+ 10014px 0 0 0 var(--spinner-color);
800
+ }
801
+ 66.667% {
802
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
803
+ 9999px 0 0 0 var(--spinner-color),
804
+ 10014px 0 0 0 var(--spinner-color);
805
+ }
806
+ 83.333% {
807
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
808
+ 9999px 0 0 0 var(--spinner-color),
809
+ 10014px -10px 0 0 var(--spinner-color);
810
+ }
811
+ 100% {
812
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
813
+ 9999px 0 0 0 var(--spinner-color),
814
+ 10014px 0 0 0 var(--spinner-color);
815
+ }
816
+ }
817
+ `;
818
+ var EmbeddedLoadingSpinner = class {
819
+ #root = null;
820
+ #eventListeners = {};
821
+ #listenersAttached = false;
822
+ dom = null;
823
+ constructor() {
824
+ this.init = this.init.bind(this);
825
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
826
+ }
827
+ async init() {
828
+ console.log("Injecting modal");
829
+ this.#injectHTML();
830
+ }
831
+ open = () => {
832
+ console.debug("Modal open");
833
+ this.#attachEventListeners();
834
+ if (this.#root) this.#root.style.display = "flex";
835
+ };
836
+ close = (event = void 0) => {
837
+ console.debug("Modal close");
838
+ this.#removeEventListeners();
839
+ if (this.#root) this.#root.style.display = "none";
840
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
841
+ };
842
+ addEventListener(event, listener) {
843
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
844
+ return () => this.removeEventListener(event, listener);
845
+ }
846
+ removeEventListener(event, listener) {
847
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
848
+ }
849
+ #injectHTML() {
850
+ if (this.dom) return;
851
+ this.#root = document.createElement("div");
852
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
853
+ this.#root.innerHTML = modalHtml;
854
+ this.#root.style.display = "none";
855
+ const styles = document.createElement("style");
856
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
857
+ styles.textContent = css$1;
858
+ const host = document.createElement("div");
859
+ this.dom = host.attachShadow({ mode: "closed" });
860
+ host.style.setProperty("--spinner-color", "#FFFFFF");
861
+ this.dom.appendChild(styles);
862
+ this.dom.appendChild(this.#root);
863
+ document.body.appendChild(host);
864
+ }
865
+ #attachEventListeners() {
866
+ if (!this.#root || this.#listenersAttached) return;
867
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
868
+ this.close(event);
869
+ }));
870
+ window.addEventListener("load", this.close);
871
+ document.addEventListener("keydown", this.#handleKeyDown);
872
+ this.#listenersAttached = true;
873
+ }
874
+ #removeEventListeners() {
875
+ if (!this.#listenersAttached) return;
876
+ window.removeEventListener("load", this.close);
877
+ document.removeEventListener("keydown", this.#handleKeyDown);
878
+ if (!this.#root) return;
879
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
880
+ this.#listenersAttached = false;
881
+ }
882
+ #handleKeyDown = (event) => {
883
+ if (event.key === "Escape") this.close(event);
884
+ };
885
+ };
886
+ //#endregion
887
+ //#region src/embedded-modal/remoteConnectionModal.ts
888
+ var RemoteConnectionModal = class extends EmbeddedModal {
889
+ contentStyles = css;
890
+ contentHtml = QRCodeHtml;
891
+ async initWithQR(qrCode) {
892
+ super.init();
893
+ this.populateQRCode(qrCode);
894
+ }
895
+ async populateQRCode(qrUrl) {
896
+ const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
897
+ if (qrcodeContainer) {
898
+ const qrCodeElement = await qrcode.default.toCanvas(qrUrl, {
899
+ width: 200,
900
+ margin: 0
901
+ });
902
+ if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
903
+ else qrcodeContainer.appendChild(qrCodeElement);
904
+ const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
905
+ if (qrPlaceholder) qrPlaceholder.style.display = "none";
906
+ } else console.error("QRCode Container not found");
907
+ }
908
+ };
909
+ const QRCodeHtml = `
910
+ <div class="mobile-wallet-adapter-embedded-modal-qr-content">
911
+ <div>
912
+ <svg class="mobile-wallet-adapter-embedded-modal-icon" width="100%" height="100%">
913
+ <circle r="52" cx="53" cy="53" fill="#99b3be" stroke="#000000" stroke-width="2"/>
914
+ <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"/>
915
+ </svg>
916
+ <div class="mobile-wallet-adapter-embedded-modal-title">Remote Mobile Wallet Adapter</div>
917
+ </div>
918
+ <div>
919
+ <div>
920
+ <h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
921
+ Open your wallet and scan this code
922
+ </h4>
923
+ </div>
924
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
925
+ <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
926
+ </div>
927
+ </div>
928
+ </div>
929
+ <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
930
+ <div class="mobile-wallet-adapter-embedded-modal-footer">
931
+ <div class="mobile-wallet-adapter-embedded-modal-subtitle">
932
+ Follow the instructions on your device. When you're finished, this screen will update.
933
+ </div>
934
+ <div class="mobile-wallet-adapter-embedded-modal-progress-badge">
935
+ <div>
936
+ <div class="spinner">
937
+ <div class="leftWrapper">
938
+ <div class="left">
939
+ <div class="circle"></div>
940
+ </div>
941
+ </div>
942
+ <div class="rightWrapper">
943
+ <div class="right">
944
+ <div class="circle"></div>
945
+ </div>
946
+ </div>
947
+ </div>
948
+ </div>
949
+ <div>Waiting for scan</div>
950
+ </div>
951
+ </div>
952
+ `;
953
+ const css = `
954
+ .mobile-wallet-adapter-embedded-modal-qr-content {
955
+ display: flex;
956
+ margin-top: 10px;
957
+ padding: 10px;
958
+ }
959
+
960
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
961
+ display: flex;
962
+ flex-direction: column;
963
+ flex: 2;
964
+ margin-top: auto;
965
+ margin-right: 30px;
966
+ }
967
+
968
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
969
+ display: flex;
970
+ flex-direction: column;
971
+ flex: 1;
972
+ margin-left: auto;
973
+ }
974
+
975
+ .mobile-wallet-adapter-embedded-modal-footer {
976
+ display: flex;
977
+ padding: 10px;
978
+ }
979
+
980
+ .mobile-wallet-adapter-embedded-modal-icon {}
981
+
982
+ .mobile-wallet-adapter-embedded-modal-title {
983
+ color: #000000;
984
+ font-size: 2.5em;
985
+ font-weight: 600;
986
+ }
987
+
988
+ .mobile-wallet-adapter-embedded-modal-qr-label {
989
+ text-align: right;
990
+ color: #000000;
991
+ }
992
+
993
+ .mobile-wallet-adapter-embedded-modal-qr-code-container {
994
+ margin-left: auto;
995
+ }
996
+
997
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
998
+ margin-left: auto;
999
+ min-width: 200px;
1000
+ min-height: 200px;
1001
+ background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
1002
+ background-size: 200%;
1003
+ animation: placeholderAnimate 2.7s linear infinite;
1004
+ border-radius: 12px;
1005
+ }
1006
+
1007
+ .mobile-wallet-adapter-embedded-modal-divider {
1008
+ margin-top: 20px;
1009
+ padding-left: 10px;
1010
+ padding-right: 10px;
1011
+ }
1012
+
1013
+ .mobile-wallet-adapter-embedded-modal-divider hr {
1014
+ border-top: 1px solid #D9DEDE;
1015
+ }
1016
+
1017
+ .mobile-wallet-adapter-embedded-modal-subtitle {
1018
+ margin: auto;
1019
+ margin-right: 60px;
1020
+ padding: 20px;
1021
+ color: #6E8286;
1022
+ }
1023
+
1024
+ .mobile-wallet-adapter-embedded-modal-progress-badge {
1025
+ display: flex;
1026
+ background: #F7F8F8;
1027
+ height: 56px;
1028
+ min-width: 200px;
1029
+ margin: auto;
1030
+ padding-left: 20px;
1031
+ padding-right: 20px;
1032
+ border-radius: 18px;
1033
+ color: #A8B6B8;
1034
+ align-items: center;
1035
+ }
1036
+
1037
+ .mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
1038
+ margin-left: auto;
1039
+ margin-right: 20px;
1040
+ }
1041
+
1042
+ .mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
1043
+ margin-right: auto;
1044
+ }
1045
+
1046
+ /* Smaller screens */
1047
+ @media all and (max-width: 600px) {
1048
+ .mobile-wallet-adapter-embedded-modal-card {
1049
+ text-align: center;
1050
+ }
1051
+ .mobile-wallet-adapter-embedded-modal-qr-content {
1052
+ flex-direction: column;
1053
+ }
1054
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
1055
+ margin: auto;
1056
+ }
1057
+ .mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
1058
+ margin: auto;
1059
+ flex: 2 auto;
1060
+ }
1061
+ .mobile-wallet-adapter-embedded-modal-footer {
1062
+ flex-direction: column;
1063
+ }
1064
+ .mobile-wallet-adapter-embedded-modal-icon {
1065
+ display: none;
1066
+ }
1067
+ .mobile-wallet-adapter-embedded-modal-title {
1068
+ font-size: 1.5em;
1069
+ }
1070
+ .mobile-wallet-adapter-embedded-modal-subtitle {
1071
+ margin-right: unset;
1072
+ }
1073
+ .mobile-wallet-adapter-embedded-modal-qr-label {
1074
+ text-align: center;
1075
+ }
1076
+ .mobile-wallet-adapter-embedded-modal-qr-code-container {
1077
+ margin: auto;
1078
+ }
1079
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
1080
+ margin: auto;
1081
+ }
1082
+ }
1083
+
1084
+ /* QR Placeholder */
1085
+ @keyframes placeholderAnimate {
1086
+ 0% { background-position: 200% 0; }
1087
+ 100% { background-position: -200% 0; }
1088
+ }
1089
+
1090
+ /* Spinner */
1091
+ @keyframes spinLeft {
1092
+ 0% {
1093
+ transform: rotate(20deg);
1094
+ }
1095
+ 50% {
1096
+ transform: rotate(160deg);
1097
+ }
1098
+ 100% {
1099
+ transform: rotate(20deg);
1100
+ }
1101
+ }
1102
+ @keyframes spinRight {
1103
+ 0% {
1104
+ transform: rotate(160deg);
1105
+ }
1106
+ 50% {
1107
+ transform: rotate(20deg);
1108
+ }
1109
+ 100% {
1110
+ transform: rotate(160deg);
1111
+ }
1112
+ }
1113
+ @keyframes spin {
1114
+ 0% {
1115
+ transform: rotate(0deg);
1116
+ }
1117
+ 100% {
1118
+ transform: rotate(2520deg);
1119
+ }
1120
+ }
1121
+
1122
+ .spinner {
1123
+ position: relative;
1124
+ width: 1.5em;
1125
+ height: 1.5em;
1126
+ margin: auto;
1127
+ animation: spin 10s linear infinite;
1128
+ }
1129
+ .spinner::before {
1130
+ content: "";
1131
+ position: absolute;
1132
+ top: 0;
1133
+ bottom: 0;
1134
+ left: 0;
1135
+ right: 0;
1136
+ }
1137
+ .right, .rightWrapper, .left, .leftWrapper {
1138
+ position: absolute;
1139
+ top: 0;
1140
+ overflow: hidden;
1141
+ width: .75em;
1142
+ height: 1.5em;
946
1143
  }
947
- `;
948
- //#endregion
949
- //#region src/getIsSupported.ts
950
- function getIsLocalAssociationSupported() {
951
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
1144
+ .left, .leftWrapper {
1145
+ left: 0;
952
1146
  }
953
- function getIsRemoteAssociationSupported() {
954
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1147
+ .right {
1148
+ left: -12px;
955
1149
  }
956
- function isWebView(userAgentString) {
957
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1150
+ .rightWrapper {
1151
+ right: 0;
958
1152
  }
959
- function isSolanaMobileWebShell(userAgentString) {
960
- return userAgentString.includes("Solana Mobile Web Shell");
1153
+ .circle {
1154
+ border: .125em solid #A8B6B8;
1155
+ width: 1.25em; /* 1.5em - 2*0.125em border */
1156
+ height: 1.25em; /* 1.5em - 2*0.125em border */
1157
+ border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
961
1158
  }
962
- function getIsPwaLaunchedAsApp() {
963
- const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
964
- if (typeof window == "undefined") return isAndroidTwa;
965
- const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
966
- const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
967
- const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
968
- return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
1159
+ .left {
1160
+ transform-origin: 100% 50%;
1161
+ animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
969
1162
  }
970
- async function checkLocalNetworkAccessPermission() {
971
- if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
972
- try {
973
- const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
974
- if (lnaPermission.state === "granted") return;
975
- else if (lnaPermission.state === "denied") {
976
- const modal = new LoopbackPermissionBlockedModal();
977
- modal.init();
978
- modal.open();
979
- 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");
980
- } else if (lnaPermission.state === "prompt") {
981
- const modal = new LoopbackPermissionModal();
982
- if (await new Promise((resolve, reject) => {
983
- modal.addEventListener("close", (event) => {
984
- 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 }));
985
- });
986
- lnaPermission.onchange = () => {
987
- lnaPermission.onchange = null;
988
- resolve(lnaPermission.state);
989
- };
990
- modal.init();
991
- modal.open();
992
- }) === "granted") {
993
- const modal = new LocalConnectionModal();
994
- await new Promise((resolve, reject) => {
995
- modal.addEventListener("close", (event) => {
996
- 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 }));
997
- });
998
- modal.initWithCallback(async () => {
999
- resolve(true);
1000
- });
1001
- modal.open();
1002
- });
1003
- return;
1004
- } else return await checkLocalNetworkAccessPermission();
1005
- }
1006
- 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");
1007
- } catch (e) {
1008
- if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
1009
- if (e instanceof _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError) throw e;
1010
- 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");
1011
- }
1163
+ .right {
1164
+ transform-origin: 100% 50%;
1165
+ animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
1012
1166
  }
1167
+ `;
1013
1168
  //#endregion
1014
1169
  //#region src/icon.ts
1015
1170
  const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
@@ -1275,9 +1430,9 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1275
1430
  };
1276
1431
  #accountsToWalletStandardAccounts = (accounts) => {
1277
1432
  return accounts.map((account) => {
1278
- const publicKey = (0, js_base64.toUint8Array)(account.address);
1433
+ const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
1279
1434
  return {
1280
- address: bs58.default.encode(publicKey),
1435
+ address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
1281
1436
  publicKey,
1282
1437
  label: account.label,
1283
1438
  icon: account.icon,
@@ -1290,11 +1445,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1290
1445
  const { authToken, chain } = this.#assertIsAuthorized();
1291
1446
  try {
1292
1447
  const base64Transactions = transactions.map((tx) => {
1293
- return (0, js_base64.fromUint8Array)(tx);
1448
+ return (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(tx);
1294
1449
  });
1295
1450
  return await this.#transact(async (wallet) => {
1296
1451
  await this.#performReauthorization(wallet, authToken, chain);
1297
- return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(js_base64.toUint8Array);
1452
+ return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array);
1298
1453
  });
1299
1454
  } catch (e) {
1300
1455
  throw new Error(getErrorMessage(e), { cause: e });
@@ -1306,11 +1461,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1306
1461
  return await this.#transact(async (wallet) => {
1307
1462
  const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1308
1463
  if (capabilities.supports_sign_and_send_transactions) {
1309
- const base64Transaction = (0, js_base64.fromUint8Array)(transaction);
1464
+ const base64Transaction = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction);
1310
1465
  return (await wallet.signAndSendTransactions({
1311
1466
  ...options,
1312
1467
  payloads: [base64Transaction]
1313
- })).signatures.map(js_base64.toUint8Array)[0];
1468
+ })).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
1314
1469
  } else throw new Error("connected wallet does not support signAndSendTransaction");
1315
1470
  });
1316
1471
  } catch (e) {
@@ -1332,15 +1487,15 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1332
1487
  };
1333
1488
  #signMessage = async (...inputs) => {
1334
1489
  const { authToken, chain } = this.#assertIsAuthorized();
1335
- const addresses = inputs.map(({ account }) => (0, js_base64.fromUint8Array)(new Uint8Array(account.publicKey)));
1336
- const messages = inputs.map(({ message }) => (0, js_base64.fromUint8Array)(message));
1490
+ const addresses = inputs.map(({ account }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(new Uint8Array(account.publicKey)));
1491
+ const messages = inputs.map(({ message }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(message));
1337
1492
  try {
1338
1493
  return await this.#transact(async (wallet) => {
1339
1494
  await this.#performReauthorization(wallet, authToken, chain);
1340
1495
  return (await wallet.signMessages({
1341
1496
  addresses,
1342
1497
  payloads: messages
1343
- })).signed_payloads.map(js_base64.toUint8Array).map((signedMessage) => {
1498
+ })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
1344
1499
  return {
1345
1500
  signedMessage,
1346
1501
  signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
@@ -1369,13 +1524,13 @@ var LocalSolanaMobileWalletAdapterWallet = class {
1369
1524
  const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
1370
1525
  return {
1371
1526
  account: {
1372
- ...signedInAccount ?? { address: bs58.default.encode((0, js_base64.toUint8Array)(signedInAddress)) },
1373
- publicKey: (0, js_base64.toUint8Array)(signedInAddress),
1527
+ ...signedInAccount ?? { address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)((0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress)) },
1528
+ publicKey: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress),
1374
1529
  chains: signedInAccount?.chains ?? this.#chains,
1375
1530
  features: signedInAccount?.features ?? authorizationResult.capabilities.features
1376
1531
  },
1377
- signedMessage: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signed_message),
1378
- signature: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signature)
1532
+ signedMessage: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signed_message),
1533
+ signature: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signature)
1379
1534
  };
1380
1535
  } catch (e) {
1381
1536
  throw new Error(getErrorMessage(e), { cause: e });
@@ -1628,9 +1783,9 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1628
1783
  };
1629
1784
  #accountsToWalletStandardAccounts = (accounts) => {
1630
1785
  return accounts.map((account) => {
1631
- const publicKey = (0, js_base64.toUint8Array)(account.address);
1786
+ const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
1632
1787
  return {
1633
- address: bs58.default.encode(publicKey),
1788
+ address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
1634
1789
  publicKey,
1635
1790
  label: account.label,
1636
1791
  icon: account.icon,
@@ -1644,7 +1799,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1644
1799
  try {
1645
1800
  return await this.#transact(async (wallet) => {
1646
1801
  await this.#performReauthorization(wallet, authToken, chain);
1647
- return (await wallet.signTransactions({ payloads: transactions.map(js_base64.fromUint8Array) })).signed_payloads.map(js_base64.toUint8Array);
1802
+ 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
1803
  });
1649
1804
  } catch (e) {
1650
1805
  throw new Error(getErrorMessage(e), { cause: e });
@@ -1657,8 +1812,8 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1657
1812
  const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
1658
1813
  if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
1659
1814
  ...options,
1660
- payloads: [(0, js_base64.fromUint8Array)(transaction)]
1661
- })).signatures.map(js_base64.toUint8Array)[0];
1815
+ payloads: [(0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction)]
1816
+ })).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
1662
1817
  else throw new Error("connected wallet does not support signAndSendTransaction");
1663
1818
  });
1664
1819
  } catch (e) {
@@ -1680,15 +1835,15 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1680
1835
  };
1681
1836
  #signMessage = async (...inputs) => {
1682
1837
  const { authToken, chain } = this.#assertIsAuthorized();
1683
- const addresses = inputs.map(({ account }) => (0, js_base64.fromUint8Array)(new Uint8Array(account.publicKey)));
1684
- const messages = inputs.map(({ message }) => (0, js_base64.fromUint8Array)(message));
1838
+ const addresses = inputs.map(({ account }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(new Uint8Array(account.publicKey)));
1839
+ const messages = inputs.map(({ message }) => (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(message));
1685
1840
  try {
1686
1841
  return await this.#transact(async (wallet) => {
1687
1842
  await this.#performReauthorization(wallet, authToken, chain);
1688
1843
  return (await wallet.signMessages({
1689
1844
  addresses,
1690
1845
  payloads: messages
1691
- })).signed_payloads.map(js_base64.toUint8Array).map((signedMessage) => {
1846
+ })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
1692
1847
  return {
1693
1848
  signedMessage,
1694
1849
  signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
@@ -1717,13 +1872,13 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
1717
1872
  const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
1718
1873
  return {
1719
1874
  account: {
1720
- ...signedInAccount ?? { address: bs58.default.encode((0, js_base64.toUint8Array)(signedInAddress)) },
1721
- publicKey: (0, js_base64.toUint8Array)(signedInAddress),
1875
+ ...signedInAccount ?? { address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)((0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress)) },
1876
+ publicKey: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(signedInAddress),
1722
1877
  chains: signedInAccount?.chains ?? this.#chains,
1723
1878
  features: signedInAccount?.features ?? authorizationResult.capabilities.features
1724
1879
  },
1725
- signedMessage: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signed_message),
1726
- signature: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signature)
1880
+ signedMessage: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signed_message),
1881
+ signature: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(authorizationResult.sign_in_result.signature)
1727
1882
  };
1728
1883
  } catch (e) {
1729
1884
  throw new Error(getErrorMessage(e), { cause: e });
@@ -1751,163 +1906,6 @@ function registerMwa(config) {
1751
1906
  }));
1752
1907
  }
1753
1908
  //#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/__forks__/react-native/createDefaultAuthorizationCache.ts
1869
- const CACHE_KEY = "SolanaMobileWalletAdapterWalletStandardDefaultAuthorizationCache";
1870
- function createDefaultAuthorizationCache() {
1871
- return {
1872
- async clear() {
1873
- try {
1874
- await _react_native_async_storage_async_storage.default.removeItem(CACHE_KEY);
1875
- } catch {}
1876
- },
1877
- async get() {
1878
- try {
1879
- const parsed = JSON.parse(await _react_native_async_storage_async_storage.default.getItem(CACHE_KEY));
1880
- if (parsed && parsed.accounts) {
1881
- const parsedAccounts = parsed.accounts.map((account) => {
1882
- return {
1883
- ...account,
1884
- publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : bs58.default.decode(account.address)
1885
- };
1886
- });
1887
- return {
1888
- ...parsed,
1889
- accounts: parsedAccounts
1890
- };
1891
- } else return parsed || void 0;
1892
- } catch {}
1893
- },
1894
- async set(authorizationResult) {
1895
- try {
1896
- await _react_native_async_storage_async_storage.default.setItem(CACHE_KEY, JSON.stringify(authorizationResult));
1897
- } catch {}
1898
- }
1899
- };
1900
- }
1901
- //#endregion
1902
- //#region src/createDefaultChainSelector.ts
1903
- function createDefaultChainSelector() {
1904
- return { async select(chains) {
1905
- if (chains.length === 1) return chains[0];
1906
- else if (chains.includes(_solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN)) return _solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN;
1907
- else return chains[0];
1908
- } };
1909
- }
1910
- //#endregion
1911
1909
  exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
1912
1910
  exports.RemoteSolanaMobileWalletAdapterWallet = RemoteSolanaMobileWalletAdapterWallet;
1913
1911
  exports.SolanaMobileWalletAdapterRemoteWalletName = SolanaMobileWalletAdapterRemoteWalletName;