@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.
- package/lib/cjs/index.browser.js +665 -674
- package/lib/cjs/index.browser.js.map +1 -1
- package/lib/cjs/index.js +665 -674
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/index.native.js +674 -676
- package/lib/cjs/index.native.js.map +1 -1
- package/lib/esm/index.browser.js +665 -673
- package/lib/esm/index.browser.js.map +1 -1
- package/lib/esm/index.js +665 -673
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +10 -10
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +2 -4
package/lib/cjs/index.js
CHANGED
|
@@ -21,175 +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
|
|
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");
|
|
25
27
|
let _solana_mobile_mobile_wallet_adapter_protocol = require("@solana-mobile/mobile-wallet-adapter-protocol");
|
|
28
|
+
let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
|
|
26
29
|
let _wallet_standard_features = require("@wallet-standard/features");
|
|
27
|
-
let bs58 = require("bs58");
|
|
28
|
-
bs58 = __toESM(bs58);
|
|
29
30
|
let qrcode = require("qrcode");
|
|
30
31
|
qrcode = __toESM(qrcode);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
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
|
+
};
|
|
39
71
|
}
|
|
40
72
|
//#endregion
|
|
41
|
-
//#region src/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</div>
|
|
49
|
-
`;
|
|
50
|
-
const css$6 = `
|
|
51
|
-
.mobile-wallet-adapter-embedded-loading-indicator {
|
|
52
|
-
display: flex; /* Use flexbox to center content */
|
|
53
|
-
justify-content: center; /* Center horizontally */
|
|
54
|
-
align-items: start; /* Center vertically */
|
|
55
|
-
position: fixed; /* Stay in place */
|
|
56
|
-
z-index: 1; /* Sit on top */
|
|
57
|
-
left: 0;
|
|
58
|
-
top: 0;
|
|
59
|
-
width: 100%; /* Full width */
|
|
60
|
-
height: 100%; /* Full height */
|
|
61
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
62
|
-
overflow-y: auto; /* enable scrolling */
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.mobile-wallet-adapter-embedded-loading-container {
|
|
66
|
-
display: flex;
|
|
67
|
-
margin: auto;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.mobile-wallet-adapter-embedded-loading-animation {
|
|
71
|
-
position: relative;
|
|
72
|
-
left: -9999px;
|
|
73
|
-
width: 10px;
|
|
74
|
-
height: 10px;
|
|
75
|
-
border-radius: 5px;
|
|
76
|
-
background-color: var(--spinner-color);
|
|
77
|
-
color: var(--spinner-color);
|
|
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
|
-
animation: dot-typing 1.5s infinite linear;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@keyframes dot-typing {
|
|
85
|
-
0% {
|
|
86
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
87
|
-
9999px 0 0 0 var(--spinner-color),
|
|
88
|
-
10014px 0 0 0 var(--spinner-color);
|
|
89
|
-
}
|
|
90
|
-
16.667% {
|
|
91
|
-
box-shadow: 9984px -10px 0 0 var(--spinner-color),
|
|
92
|
-
9999px 0 0 0 var(--spinner-color),
|
|
93
|
-
10014px 0 0 0 var(--spinner-color);
|
|
94
|
-
}
|
|
95
|
-
33.333% {
|
|
96
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
97
|
-
9999px 0 0 0 var(--spinner-color),
|
|
98
|
-
10014px 0 0 0 var(--spinner-color);
|
|
99
|
-
}
|
|
100
|
-
50% {
|
|
101
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
102
|
-
9999px -10px 0 0 var(--spinner-color),
|
|
103
|
-
10014px 0 0 0 var(--spinner-color);
|
|
104
|
-
}
|
|
105
|
-
66.667% {
|
|
106
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
107
|
-
9999px 0 0 0 var(--spinner-color),
|
|
108
|
-
10014px 0 0 0 var(--spinner-color);
|
|
109
|
-
}
|
|
110
|
-
83.333% {
|
|
111
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
112
|
-
9999px 0 0 0 var(--spinner-color),
|
|
113
|
-
10014px -10px 0 0 var(--spinner-color);
|
|
114
|
-
}
|
|
115
|
-
100% {
|
|
116
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
117
|
-
9999px 0 0 0 var(--spinner-color),
|
|
118
|
-
10014px 0 0 0 var(--spinner-color);
|
|
119
|
-
}
|
|
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
|
+
} };
|
|
120
80
|
}
|
|
121
|
-
`;
|
|
122
|
-
var EmbeddedLoadingSpinner = class {
|
|
123
|
-
#root = null;
|
|
124
|
-
#eventListeners = {};
|
|
125
|
-
#listenersAttached = false;
|
|
126
|
-
dom = null;
|
|
127
|
-
constructor() {
|
|
128
|
-
this.init = this.init.bind(this);
|
|
129
|
-
this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
|
|
130
|
-
}
|
|
131
|
-
async init() {
|
|
132
|
-
console.log("Injecting modal");
|
|
133
|
-
this.#injectHTML();
|
|
134
|
-
}
|
|
135
|
-
open = () => {
|
|
136
|
-
console.debug("Modal open");
|
|
137
|
-
this.#attachEventListeners();
|
|
138
|
-
if (this.#root) this.#root.style.display = "flex";
|
|
139
|
-
};
|
|
140
|
-
close = (event = void 0) => {
|
|
141
|
-
console.debug("Modal close");
|
|
142
|
-
this.#removeEventListeners();
|
|
143
|
-
if (this.#root) this.#root.style.display = "none";
|
|
144
|
-
this.#eventListeners["close"]?.forEach((listener) => listener(event));
|
|
145
|
-
};
|
|
146
|
-
addEventListener(event, listener) {
|
|
147
|
-
this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
|
|
148
|
-
return () => this.removeEventListener(event, listener);
|
|
149
|
-
}
|
|
150
|
-
removeEventListener(event, listener) {
|
|
151
|
-
this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
152
|
-
}
|
|
153
|
-
#injectHTML() {
|
|
154
|
-
if (this.dom) return;
|
|
155
|
-
this.#root = document.createElement("div");
|
|
156
|
-
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
157
|
-
this.#root.innerHTML = modalHtml$1;
|
|
158
|
-
this.#root.style.display = "none";
|
|
159
|
-
const styles = document.createElement("style");
|
|
160
|
-
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
161
|
-
styles.textContent = css$6;
|
|
162
|
-
const host = document.createElement("div");
|
|
163
|
-
this.dom = host.attachShadow({ mode: "closed" });
|
|
164
|
-
host.style.setProperty("--spinner-color", "#FFFFFF");
|
|
165
|
-
this.dom.appendChild(styles);
|
|
166
|
-
this.dom.appendChild(this.#root);
|
|
167
|
-
document.body.appendChild(host);
|
|
168
|
-
}
|
|
169
|
-
#attachEventListeners() {
|
|
170
|
-
if (!this.#root || this.#listenersAttached) return;
|
|
171
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
|
|
172
|
-
this.close(event);
|
|
173
|
-
}));
|
|
174
|
-
window.addEventListener("load", this.close);
|
|
175
|
-
document.addEventListener("keydown", this.#handleKeyDown);
|
|
176
|
-
this.#listenersAttached = true;
|
|
177
|
-
}
|
|
178
|
-
#removeEventListeners() {
|
|
179
|
-
if (!this.#listenersAttached) return;
|
|
180
|
-
window.removeEventListener("load", this.close);
|
|
181
|
-
document.removeEventListener("keydown", this.#handleKeyDown);
|
|
182
|
-
if (!this.#root) return;
|
|
183
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
|
|
184
|
-
this.#listenersAttached = false;
|
|
185
|
-
}
|
|
186
|
-
#handleKeyDown = (event) => {
|
|
187
|
-
if (event.key === "Escape") this.close(event);
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
81
|
//#endregion
|
|
191
82
|
//#region src/embedded-modal/modal.ts
|
|
192
|
-
const modalHtml = `
|
|
83
|
+
const modalHtml$1 = `
|
|
193
84
|
<div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
194
85
|
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
195
86
|
<div class="mobile-wallet-adapter-embedded-modal-card">
|
|
@@ -204,7 +95,7 @@ const modalHtml = `
|
|
|
204
95
|
</div>
|
|
205
96
|
</div>
|
|
206
97
|
`;
|
|
207
|
-
const css$
|
|
98
|
+
const css$6 = `
|
|
208
99
|
.mobile-wallet-adapter-embedded-modal-container {
|
|
209
100
|
display: flex; /* Use flexbox to center content */
|
|
210
101
|
justify-content: center; /* Center horizontally */
|
|
@@ -304,13 +195,13 @@ var EmbeddedModal = class {
|
|
|
304
195
|
}
|
|
305
196
|
this.#root = document.createElement("div");
|
|
306
197
|
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
307
|
-
this.#root.innerHTML = modalHtml;
|
|
198
|
+
this.#root.innerHTML = modalHtml$1;
|
|
308
199
|
this.#root.style.display = "none";
|
|
309
200
|
const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
|
|
310
201
|
if (content) content.innerHTML = this.contentHtml;
|
|
311
202
|
const styles = document.createElement("style");
|
|
312
203
|
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
313
|
-
styles.textContent = css$
|
|
204
|
+
styles.textContent = css$6 + this.contentStyles;
|
|
314
205
|
const host = document.createElement("div");
|
|
315
206
|
host.innerHTML = fonts;
|
|
316
207
|
this.dom = host.attachShadow({ mode: "closed" });
|
|
@@ -338,292 +229,124 @@ var EmbeddedModal = class {
|
|
|
338
229
|
};
|
|
339
230
|
};
|
|
340
231
|
//#endregion
|
|
341
|
-
//#region src/embedded-modal/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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) {
|
|
346
239
|
super.init();
|
|
347
|
-
this.
|
|
240
|
+
this.populateError(error);
|
|
348
241
|
}
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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");
|
|
361
260
|
}
|
|
362
261
|
};
|
|
363
|
-
const
|
|
364
|
-
<
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
</div>
|
|
372
|
-
<div>
|
|
373
|
-
<div>
|
|
374
|
-
<h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
|
|
375
|
-
Open your wallet and scan this code
|
|
376
|
-
</h4>
|
|
377
|
-
</div>
|
|
378
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
|
|
379
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
|
|
380
|
-
</div>
|
|
381
|
-
</div>
|
|
382
|
-
</div>
|
|
383
|
-
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
384
|
-
<div class="mobile-wallet-adapter-embedded-modal-footer">
|
|
385
|
-
<div class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
386
|
-
Follow the instructions on your device. When you're finished, this screen will update.
|
|
387
|
-
</div>
|
|
388
|
-
<div class="mobile-wallet-adapter-embedded-modal-progress-badge">
|
|
389
|
-
<div>
|
|
390
|
-
<div class="spinner">
|
|
391
|
-
<div class="leftWrapper">
|
|
392
|
-
<div class="left">
|
|
393
|
-
<div class="circle"></div>
|
|
394
|
-
</div>
|
|
395
|
-
</div>
|
|
396
|
-
<div class="rightWrapper">
|
|
397
|
-
<div class="right">
|
|
398
|
-
<div class="circle"></div>
|
|
399
|
-
</div>
|
|
400
|
-
</div>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
<div>Waiting for scan</div>
|
|
404
|
-
</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>
|
|
405
270
|
</div>
|
|
406
271
|
`;
|
|
407
|
-
const css$
|
|
408
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
409
|
-
|
|
410
|
-
margin-top: 10px;
|
|
411
|
-
padding: 10px;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
|
|
415
|
-
display: flex;
|
|
416
|
-
flex-direction: column;
|
|
417
|
-
flex: 2;
|
|
418
|
-
margin-top: auto;
|
|
419
|
-
margin-right: 30px;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
423
|
-
display: flex;
|
|
424
|
-
flex-direction: column;
|
|
425
|
-
flex: 1;
|
|
426
|
-
margin-left: auto;
|
|
272
|
+
const css$5 = `
|
|
273
|
+
.mobile-wallet-adapter-embedded-modal-content {
|
|
274
|
+
text-align: center;
|
|
427
275
|
}
|
|
428
276
|
|
|
429
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
430
|
-
|
|
431
|
-
padding: 10px;
|
|
277
|
+
.mobile-wallet-adapter-embedded-modal-error-icon {
|
|
278
|
+
margin-top: 24px;
|
|
432
279
|
}
|
|
433
280
|
|
|
434
|
-
.mobile-wallet-adapter-embedded-modal-icon {}
|
|
435
|
-
|
|
436
281
|
.mobile-wallet-adapter-embedded-modal-title {
|
|
282
|
+
margin: 18px 100px auto 100px;
|
|
437
283
|
color: #000000;
|
|
438
|
-
font-size: 2.
|
|
284
|
+
font-size: 2.75em;
|
|
439
285
|
font-weight: 600;
|
|
440
286
|
}
|
|
441
287
|
|
|
442
|
-
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
443
|
-
text-align: right;
|
|
444
|
-
color: #000000;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
448
|
-
margin-left: auto;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
452
|
-
margin-left: auto;
|
|
453
|
-
min-width: 200px;
|
|
454
|
-
min-height: 200px;
|
|
455
|
-
background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
|
|
456
|
-
background-size: 200%;
|
|
457
|
-
animation: placeholderAnimate 2.7s linear infinite;
|
|
458
|
-
border-radius: 12px;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
.mobile-wallet-adapter-embedded-modal-divider {
|
|
462
|
-
margin-top: 20px;
|
|
463
|
-
padding-left: 10px;
|
|
464
|
-
padding-right: 10px;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
.mobile-wallet-adapter-embedded-modal-divider hr {
|
|
468
|
-
border-top: 1px solid #D9DEDE;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
288
|
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
472
|
-
margin:
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
289
|
+
margin: 30px 60px 40px 60px;
|
|
290
|
+
color: #000000;
|
|
291
|
+
font-size: 1.25em;
|
|
292
|
+
font-weight: 400;
|
|
476
293
|
}
|
|
477
294
|
|
|
478
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
479
|
-
display:
|
|
480
|
-
|
|
295
|
+
.mobile-wallet-adapter-embedded-modal-error-action {
|
|
296
|
+
display: block;
|
|
297
|
+
width: 100%;
|
|
481
298
|
height: 56px;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
299
|
+
/*margin-top: 40px;*/
|
|
300
|
+
font-size: 1.25em;
|
|
301
|
+
/*line-height: 24px;*/
|
|
302
|
+
/*letter-spacing: -1%;*/
|
|
303
|
+
background: #000000;
|
|
304
|
+
color: #FFFFFF;
|
|
486
305
|
border-radius: 18px;
|
|
487
|
-
color: #A8B6B8;
|
|
488
|
-
align-items: center;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
.mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
|
|
492
|
-
margin-left: auto;
|
|
493
|
-
margin-right: 20px;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
|
|
497
|
-
margin-right: auto;
|
|
498
306
|
}
|
|
499
307
|
|
|
500
308
|
/* Smaller screens */
|
|
501
309
|
@media all and (max-width: 600px) {
|
|
502
|
-
.mobile-wallet-adapter-embedded-modal-card {
|
|
503
|
-
text-align: center;
|
|
504
|
-
}
|
|
505
|
-
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
506
|
-
flex-direction: column;
|
|
507
|
-
}
|
|
508
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
|
|
509
|
-
margin: auto;
|
|
510
|
-
}
|
|
511
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
512
|
-
margin: auto;
|
|
513
|
-
flex: 2 auto;
|
|
514
|
-
}
|
|
515
|
-
.mobile-wallet-adapter-embedded-modal-footer {
|
|
516
|
-
flex-direction: column;
|
|
517
|
-
}
|
|
518
|
-
.mobile-wallet-adapter-embedded-modal-icon {
|
|
519
|
-
display: none;
|
|
520
|
-
}
|
|
521
310
|
.mobile-wallet-adapter-embedded-modal-title {
|
|
522
311
|
font-size: 1.5em;
|
|
312
|
+
margin-right: 12px;
|
|
313
|
+
margin-left: 12px;
|
|
523
314
|
}
|
|
524
315
|
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
525
|
-
margin-right:
|
|
526
|
-
|
|
527
|
-
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
528
|
-
text-align: center;
|
|
529
|
-
}
|
|
530
|
-
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
531
|
-
margin: auto;
|
|
532
|
-
}
|
|
533
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
534
|
-
margin: auto;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/* QR Placeholder */
|
|
539
|
-
@keyframes placeholderAnimate {
|
|
540
|
-
0% { background-position: 200% 0; }
|
|
541
|
-
100% { background-position: -200% 0; }
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/* Spinner */
|
|
545
|
-
@keyframes spinLeft {
|
|
546
|
-
0% {
|
|
547
|
-
transform: rotate(20deg);
|
|
548
|
-
}
|
|
549
|
-
50% {
|
|
550
|
-
transform: rotate(160deg);
|
|
551
|
-
}
|
|
552
|
-
100% {
|
|
553
|
-
transform: rotate(20deg);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
@keyframes spinRight {
|
|
557
|
-
0% {
|
|
558
|
-
transform: rotate(160deg);
|
|
559
|
-
}
|
|
560
|
-
50% {
|
|
561
|
-
transform: rotate(20deg);
|
|
562
|
-
}
|
|
563
|
-
100% {
|
|
564
|
-
transform: rotate(160deg);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
@keyframes spin {
|
|
568
|
-
0% {
|
|
569
|
-
transform: rotate(0deg);
|
|
570
|
-
}
|
|
571
|
-
100% {
|
|
572
|
-
transform: rotate(2520deg);
|
|
316
|
+
margin-right: 12px;
|
|
317
|
+
margin-left: 12px;
|
|
573
318
|
}
|
|
574
319
|
}
|
|
575
|
-
|
|
576
|
-
.spinner {
|
|
577
|
-
position: relative;
|
|
578
|
-
width: 1.5em;
|
|
579
|
-
height: 1.5em;
|
|
580
|
-
margin: auto;
|
|
581
|
-
animation: spin 10s linear infinite;
|
|
582
|
-
}
|
|
583
|
-
.spinner::before {
|
|
584
|
-
content: "";
|
|
585
|
-
position: absolute;
|
|
586
|
-
top: 0;
|
|
587
|
-
bottom: 0;
|
|
588
|
-
left: 0;
|
|
589
|
-
right: 0;
|
|
590
|
-
}
|
|
591
|
-
.right, .rightWrapper, .left, .leftWrapper {
|
|
592
|
-
position: absolute;
|
|
593
|
-
top: 0;
|
|
594
|
-
overflow: hidden;
|
|
595
|
-
width: .75em;
|
|
596
|
-
height: 1.5em;
|
|
597
|
-
}
|
|
598
|
-
.left, .leftWrapper {
|
|
599
|
-
left: 0;
|
|
600
|
-
}
|
|
601
|
-
.right {
|
|
602
|
-
left: -12px;
|
|
603
|
-
}
|
|
604
|
-
.rightWrapper {
|
|
605
|
-
right: 0;
|
|
606
|
-
}
|
|
607
|
-
.circle {
|
|
608
|
-
border: .125em solid #A8B6B8;
|
|
609
|
-
width: 1.25em; /* 1.5em - 2*0.125em border */
|
|
610
|
-
height: 1.25em; /* 1.5em - 2*0.125em border */
|
|
611
|
-
border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
|
|
612
|
-
}
|
|
613
|
-
.left {
|
|
614
|
-
transform-origin: 100% 50%;
|
|
615
|
-
animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
616
|
-
}
|
|
617
|
-
.right {
|
|
618
|
-
transform-origin: 100% 50%;
|
|
619
|
-
animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
620
|
-
}
|
|
621
320
|
`;
|
|
622
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
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function createDefaultWalletNotFoundHandler() {
|
|
341
|
+
return async () => {
|
|
342
|
+
defaultErrorModalWalletNotFoundHandler();
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
623
346
|
//#region src/embedded-modal/localConnectionModal.ts
|
|
624
347
|
var LocalConnectionModal = class extends EmbeddedModal {
|
|
625
|
-
contentStyles = css$
|
|
626
|
-
contentHtml = ErrorDialogHtml$
|
|
348
|
+
contentStyles = css$4;
|
|
349
|
+
contentHtml = ErrorDialogHtml$2;
|
|
627
350
|
initWithCallback(callback) {
|
|
628
351
|
super.init();
|
|
629
352
|
this.#prepareLaunchAction(callback);
|
|
@@ -638,7 +361,7 @@ var LocalConnectionModal = class extends EmbeddedModal {
|
|
|
638
361
|
launchButton?.addEventListener("click", listener);
|
|
639
362
|
}
|
|
640
363
|
};
|
|
641
|
-
const ErrorDialogHtml$
|
|
364
|
+
const ErrorDialogHtml$2 = `
|
|
642
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">
|
|
643
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"/>
|
|
644
367
|
<mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
@@ -660,7 +383,7 @@ const ErrorDialogHtml$3 = `
|
|
|
660
383
|
</button>
|
|
661
384
|
</div>
|
|
662
385
|
`;
|
|
663
|
-
const css$
|
|
386
|
+
const css$4 = `
|
|
664
387
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
665
388
|
display: none;
|
|
666
389
|
}
|
|
@@ -698,10 +421,10 @@ const css$3 = `
|
|
|
698
421
|
//#endregion
|
|
699
422
|
//#region src/embedded-modal/loopbackBlockedModal.ts
|
|
700
423
|
var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
|
|
701
|
-
contentStyles = css$
|
|
424
|
+
contentStyles = css$3;
|
|
702
425
|
get contentHtml() {
|
|
703
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";
|
|
704
|
-
return ErrorDialogHtml$
|
|
427
|
+
return ErrorDialogHtml$1.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
|
|
705
428
|
}
|
|
706
429
|
async init() {
|
|
707
430
|
super.init();
|
|
@@ -716,7 +439,7 @@ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
|
|
|
716
439
|
launchButton?.addEventListener("click", listener);
|
|
717
440
|
}
|
|
718
441
|
};
|
|
719
|
-
const ErrorDialogHtml$
|
|
442
|
+
const ErrorDialogHtml$1 = `
|
|
720
443
|
<div class="mobile-wallet-adapter-embedded-modal-header">
|
|
721
444
|
Local Wallet Connection
|
|
722
445
|
</div>
|
|
@@ -769,7 +492,7 @@ const ErrorDialogHtml$2 = `
|
|
|
769
492
|
</button>
|
|
770
493
|
</div>
|
|
771
494
|
`;
|
|
772
|
-
const css$
|
|
495
|
+
const css$3 = `
|
|
773
496
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
774
497
|
display: none;
|
|
775
498
|
}
|
|
@@ -859,8 +582,8 @@ const css$2 = `
|
|
|
859
582
|
//#endregion
|
|
860
583
|
//#region src/embedded-modal/loopbackPermissionModal.ts
|
|
861
584
|
var LoopbackPermissionModal = class extends EmbeddedModal {
|
|
862
|
-
contentStyles = css$
|
|
863
|
-
contentHtml = ErrorDialogHtml
|
|
585
|
+
contentStyles = css$2;
|
|
586
|
+
contentHtml = ErrorDialogHtml;
|
|
864
587
|
async init() {
|
|
865
588
|
super.init();
|
|
866
589
|
this.#prepareLaunchAction();
|
|
@@ -877,7 +600,7 @@ var LoopbackPermissionModal = class extends EmbeddedModal {
|
|
|
877
600
|
launchButton?.addEventListener("click", listener);
|
|
878
601
|
}
|
|
879
602
|
};
|
|
880
|
-
const ErrorDialogHtml
|
|
603
|
+
const ErrorDialogHtml = `
|
|
881
604
|
<div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
|
|
882
605
|
<div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
883
606
|
Tap "Allow" on the next screen
|
|
@@ -903,7 +626,7 @@ const ErrorDialogHtml$1 = `
|
|
|
903
626
|
</button>
|
|
904
627
|
</div>
|
|
905
628
|
`;
|
|
906
|
-
const css$
|
|
629
|
+
const css$2 = `
|
|
907
630
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
908
631
|
display: none;
|
|
909
632
|
}
|
|
@@ -949,72 +672,504 @@ const css$1 = `
|
|
|
949
672
|
margin-left: 12px;
|
|
950
673
|
}
|
|
951
674
|
}
|
|
952
|
-
`;
|
|
953
|
-
//#endregion
|
|
954
|
-
//#region src/getIsSupported.ts
|
|
955
|
-
function getIsLocalAssociationSupported() {
|
|
956
|
-
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;
|
|
957
1141
|
}
|
|
958
|
-
|
|
959
|
-
|
|
1142
|
+
.right, .rightWrapper, .left, .leftWrapper {
|
|
1143
|
+
position: absolute;
|
|
1144
|
+
top: 0;
|
|
1145
|
+
overflow: hidden;
|
|
1146
|
+
width: .75em;
|
|
1147
|
+
height: 1.5em;
|
|
960
1148
|
}
|
|
961
|
-
|
|
962
|
-
|
|
1149
|
+
.left, .leftWrapper {
|
|
1150
|
+
left: 0;
|
|
963
1151
|
}
|
|
964
|
-
|
|
965
|
-
|
|
1152
|
+
.right {
|
|
1153
|
+
left: -12px;
|
|
966
1154
|
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
if (typeof window == "undefined") return isAndroidTwa;
|
|
970
|
-
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
971
|
-
const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
|
|
972
|
-
const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
|
|
973
|
-
return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
|
|
1155
|
+
.rightWrapper {
|
|
1156
|
+
right: 0;
|
|
974
1157
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
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");
|
|
985
|
-
} else if (lnaPermission.state === "prompt") {
|
|
986
|
-
const modal = new LoopbackPermissionModal();
|
|
987
|
-
if (await new Promise((resolve, reject) => {
|
|
988
|
-
modal.addEventListener("close", (event) => {
|
|
989
|
-
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 }));
|
|
990
|
-
});
|
|
991
|
-
lnaPermission.onchange = () => {
|
|
992
|
-
lnaPermission.onchange = null;
|
|
993
|
-
resolve(lnaPermission.state);
|
|
994
|
-
};
|
|
995
|
-
modal.init();
|
|
996
|
-
modal.open();
|
|
997
|
-
}) === "granted") {
|
|
998
|
-
const modal = new LocalConnectionModal();
|
|
999
|
-
await new Promise((resolve, reject) => {
|
|
1000
|
-
modal.addEventListener("close", (event) => {
|
|
1001
|
-
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 }));
|
|
1002
|
-
});
|
|
1003
|
-
modal.initWithCallback(async () => {
|
|
1004
|
-
resolve(true);
|
|
1005
|
-
});
|
|
1006
|
-
modal.open();
|
|
1007
|
-
});
|
|
1008
|
-
return;
|
|
1009
|
-
} else return await checkLocalNetworkAccessPermission();
|
|
1010
|
-
}
|
|
1011
|
-
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");
|
|
1012
|
-
} catch (e) {
|
|
1013
|
-
if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
|
|
1014
|
-
if (e instanceof _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError) throw e;
|
|
1015
|
-
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");
|
|
1016
|
-
}
|
|
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 */
|
|
1163
|
+
}
|
|
1164
|
+
.left {
|
|
1165
|
+
transform-origin: 100% 50%;
|
|
1166
|
+
animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
1017
1167
|
}
|
|
1168
|
+
.right {
|
|
1169
|
+
transform-origin: 100% 50%;
|
|
1170
|
+
animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
1171
|
+
}
|
|
1172
|
+
`;
|
|
1018
1173
|
//#endregion
|
|
1019
1174
|
//#region src/icon.ts
|
|
1020
1175
|
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
@@ -1280,9 +1435,9 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1280
1435
|
};
|
|
1281
1436
|
#accountsToWalletStandardAccounts = (accounts) => {
|
|
1282
1437
|
return accounts.map((account) => {
|
|
1283
|
-
const publicKey =
|
|
1438
|
+
const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
|
|
1284
1439
|
return {
|
|
1285
|
-
address:
|
|
1440
|
+
address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
|
|
1286
1441
|
publicKey,
|
|
1287
1442
|
label: account.label,
|
|
1288
1443
|
icon: account.icon,
|
|
@@ -1295,11 +1450,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1295
1450
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
1296
1451
|
try {
|
|
1297
1452
|
const base64Transactions = transactions.map((tx) => {
|
|
1298
|
-
return
|
|
1453
|
+
return (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(tx);
|
|
1299
1454
|
});
|
|
1300
1455
|
return await this.#transact(async (wallet) => {
|
|
1301
1456
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
1302
|
-
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(
|
|
1457
|
+
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array);
|
|
1303
1458
|
});
|
|
1304
1459
|
} catch (e) {
|
|
1305
1460
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -1311,11 +1466,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1311
1466
|
return await this.#transact(async (wallet) => {
|
|
1312
1467
|
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
1313
1468
|
if (capabilities.supports_sign_and_send_transactions) {
|
|
1314
|
-
const base64Transaction =
|
|
1469
|
+
const base64Transaction = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction);
|
|
1315
1470
|
return (await wallet.signAndSendTransactions({
|
|
1316
1471
|
...options,
|
|
1317
1472
|
payloads: [base64Transaction]
|
|
1318
|
-
})).signatures.map(
|
|
1473
|
+
})).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
|
|
1319
1474
|
} else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
1320
1475
|
});
|
|
1321
1476
|
} catch (e) {
|
|
@@ -1337,15 +1492,15 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1337
1492
|
};
|
|
1338
1493
|
#signMessage = async (...inputs) => {
|
|
1339
1494
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
1340
|
-
const addresses = inputs.map(({ account }) =>
|
|
1341
|
-
const messages = inputs.map(({ 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));
|
|
1342
1497
|
try {
|
|
1343
1498
|
return await this.#transact(async (wallet) => {
|
|
1344
1499
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
1345
1500
|
return (await wallet.signMessages({
|
|
1346
1501
|
addresses,
|
|
1347
1502
|
payloads: messages
|
|
1348
|
-
})).signed_payloads.map(
|
|
1503
|
+
})).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
|
|
1349
1504
|
return {
|
|
1350
1505
|
signedMessage,
|
|
1351
1506
|
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
@@ -1374,13 +1529,13 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1374
1529
|
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
1375
1530
|
return {
|
|
1376
1531
|
account: {
|
|
1377
|
-
...signedInAccount ?? { address:
|
|
1378
|
-
publicKey:
|
|
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),
|
|
1379
1534
|
chains: signedInAccount?.chains ?? this.#chains,
|
|
1380
1535
|
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
1381
1536
|
},
|
|
1382
|
-
signedMessage:
|
|
1383
|
-
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)
|
|
1384
1539
|
};
|
|
1385
1540
|
} catch (e) {
|
|
1386
1541
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -1633,9 +1788,9 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1633
1788
|
};
|
|
1634
1789
|
#accountsToWalletStandardAccounts = (accounts) => {
|
|
1635
1790
|
return accounts.map((account) => {
|
|
1636
|
-
const publicKey =
|
|
1791
|
+
const publicKey = (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)(account.address);
|
|
1637
1792
|
return {
|
|
1638
|
-
address:
|
|
1793
|
+
address: (0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base58FromUint8Array)(publicKey),
|
|
1639
1794
|
publicKey,
|
|
1640
1795
|
label: account.label,
|
|
1641
1796
|
icon: account.icon,
|
|
@@ -1649,7 +1804,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1649
1804
|
try {
|
|
1650
1805
|
return await this.#transact(async (wallet) => {
|
|
1651
1806
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
1652
|
-
return (await wallet.signTransactions({ payloads: transactions.map(
|
|
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);
|
|
1653
1808
|
});
|
|
1654
1809
|
} catch (e) {
|
|
1655
1810
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -1662,8 +1817,8 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1662
1817
|
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
1663
1818
|
if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
|
|
1664
1819
|
...options,
|
|
1665
|
-
payloads: [
|
|
1666
|
-
})).signatures.map(
|
|
1820
|
+
payloads: [(0, _solana_mobile_mobile_wallet_adapter_protocol_encoding.base64FromUint8Array)(transaction)]
|
|
1821
|
+
})).signatures.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array)[0];
|
|
1667
1822
|
else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
1668
1823
|
});
|
|
1669
1824
|
} catch (e) {
|
|
@@ -1685,15 +1840,15 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1685
1840
|
};
|
|
1686
1841
|
#signMessage = async (...inputs) => {
|
|
1687
1842
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
1688
|
-
const addresses = inputs.map(({ account }) =>
|
|
1689
|
-
const messages = inputs.map(({ 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));
|
|
1690
1845
|
try {
|
|
1691
1846
|
return await this.#transact(async (wallet) => {
|
|
1692
1847
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
1693
1848
|
return (await wallet.signMessages({
|
|
1694
1849
|
addresses,
|
|
1695
1850
|
payloads: messages
|
|
1696
|
-
})).signed_payloads.map(
|
|
1851
|
+
})).signed_payloads.map(_solana_mobile_mobile_wallet_adapter_protocol_encoding.base64ToUint8Array).map((signedMessage) => {
|
|
1697
1852
|
return {
|
|
1698
1853
|
signedMessage,
|
|
1699
1854
|
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
@@ -1722,13 +1877,13 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1722
1877
|
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
1723
1878
|
return {
|
|
1724
1879
|
account: {
|
|
1725
|
-
...signedInAccount ?? { address:
|
|
1726
|
-
publicKey:
|
|
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),
|
|
1727
1882
|
chains: signedInAccount?.chains ?? this.#chains,
|
|
1728
1883
|
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
1729
1884
|
},
|
|
1730
|
-
signedMessage:
|
|
1731
|
-
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)
|
|
1732
1887
|
};
|
|
1733
1888
|
} catch (e) {
|
|
1734
1889
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -1756,170 +1911,6 @@ function registerMwa(config) {
|
|
|
1756
1911
|
}));
|
|
1757
1912
|
}
|
|
1758
1913
|
//#endregion
|
|
1759
|
-
//#region src/embedded-modal/errorModal.ts
|
|
1760
|
-
const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
|
|
1761
|
-
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.";
|
|
1762
|
-
var ErrorModal = class extends EmbeddedModal {
|
|
1763
|
-
contentStyles = css;
|
|
1764
|
-
contentHtml = ErrorDialogHtml;
|
|
1765
|
-
initWithError(error) {
|
|
1766
|
-
super.init();
|
|
1767
|
-
this.populateError(error);
|
|
1768
|
-
}
|
|
1769
|
-
populateError(error) {
|
|
1770
|
-
const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
|
|
1771
|
-
const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
|
|
1772
|
-
if (errorMessageElement) {
|
|
1773
|
-
if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
|
|
1774
|
-
case "ERROR_WALLET_NOT_FOUND":
|
|
1775
|
-
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
1776
|
-
if (actionBtn) actionBtn.addEventListener("click", () => {
|
|
1777
|
-
window.location.href = "https://solanamobile.com/wallets";
|
|
1778
|
-
});
|
|
1779
|
-
return;
|
|
1780
|
-
case "ERROR_BROWSER_NOT_SUPPORTED":
|
|
1781
|
-
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
1782
|
-
if (actionBtn) actionBtn.style.display = "none";
|
|
1783
|
-
return;
|
|
1784
|
-
}
|
|
1785
|
-
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
1786
|
-
} else console.log("Failed to locate error dialog element");
|
|
1787
|
-
}
|
|
1788
|
-
};
|
|
1789
|
-
const ErrorDialogHtml = `
|
|
1790
|
-
<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>
|
|
1791
|
-
<div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
|
|
1792
|
-
<div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
|
|
1793
|
-
<div>
|
|
1794
|
-
<button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
|
|
1795
|
-
Find a wallet
|
|
1796
|
-
</button>
|
|
1797
|
-
</div>
|
|
1798
|
-
`;
|
|
1799
|
-
const css = `
|
|
1800
|
-
.mobile-wallet-adapter-embedded-modal-content {
|
|
1801
|
-
text-align: center;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
.mobile-wallet-adapter-embedded-modal-error-icon {
|
|
1805
|
-
margin-top: 24px;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
1809
|
-
margin: 18px 100px auto 100px;
|
|
1810
|
-
color: #000000;
|
|
1811
|
-
font-size: 2.75em;
|
|
1812
|
-
font-weight: 600;
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
1816
|
-
margin: 30px 60px 40px 60px;
|
|
1817
|
-
color: #000000;
|
|
1818
|
-
font-size: 1.25em;
|
|
1819
|
-
font-weight: 400;
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
.mobile-wallet-adapter-embedded-modal-error-action {
|
|
1823
|
-
display: block;
|
|
1824
|
-
width: 100%;
|
|
1825
|
-
height: 56px;
|
|
1826
|
-
/*margin-top: 40px;*/
|
|
1827
|
-
font-size: 1.25em;
|
|
1828
|
-
/*line-height: 24px;*/
|
|
1829
|
-
/*letter-spacing: -1%;*/
|
|
1830
|
-
background: #000000;
|
|
1831
|
-
color: #FFFFFF;
|
|
1832
|
-
border-radius: 18px;
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
/* Smaller screens */
|
|
1836
|
-
@media all and (max-width: 600px) {
|
|
1837
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
1838
|
-
font-size: 1.5em;
|
|
1839
|
-
margin-right: 12px;
|
|
1840
|
-
margin-left: 12px;
|
|
1841
|
-
}
|
|
1842
|
-
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
1843
|
-
margin-right: 12px;
|
|
1844
|
-
margin-left: 12px;
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
`;
|
|
1848
|
-
//#endregion
|
|
1849
|
-
//#region src/createDefaultWalletNotFoundHandler.ts
|
|
1850
|
-
async function defaultErrorModalWalletNotFoundHandler() {
|
|
1851
|
-
if (typeof window !== "undefined") {
|
|
1852
|
-
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
1853
|
-
const errorDialog = new ErrorModal();
|
|
1854
|
-
if (userAgent.includes("wv")) errorDialog.initWithError({
|
|
1855
|
-
name: "SolanaMobileWalletAdapterError",
|
|
1856
|
-
code: "ERROR_BROWSER_NOT_SUPPORTED",
|
|
1857
|
-
message: ""
|
|
1858
|
-
});
|
|
1859
|
-
else errorDialog.initWithError({
|
|
1860
|
-
name: "SolanaMobileWalletAdapterError",
|
|
1861
|
-
code: "ERROR_WALLET_NOT_FOUND",
|
|
1862
|
-
message: ""
|
|
1863
|
-
});
|
|
1864
|
-
errorDialog.open();
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
function createDefaultWalletNotFoundHandler() {
|
|
1868
|
-
return async () => {
|
|
1869
|
-
defaultErrorModalWalletNotFoundHandler();
|
|
1870
|
-
};
|
|
1871
|
-
}
|
|
1872
|
-
//#endregion
|
|
1873
|
-
//#region src/createDefaultAuthorizationCache.ts
|
|
1874
|
-
const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
|
|
1875
|
-
function createDefaultAuthorizationCache() {
|
|
1876
|
-
let storage;
|
|
1877
|
-
try {
|
|
1878
|
-
storage = window.localStorage;
|
|
1879
|
-
} catch {}
|
|
1880
|
-
return {
|
|
1881
|
-
async clear() {
|
|
1882
|
-
if (!storage) return;
|
|
1883
|
-
try {
|
|
1884
|
-
storage.removeItem(CACHE_KEY);
|
|
1885
|
-
} catch {}
|
|
1886
|
-
},
|
|
1887
|
-
async get() {
|
|
1888
|
-
if (!storage) return;
|
|
1889
|
-
try {
|
|
1890
|
-
const parsed = JSON.parse(storage.getItem(CACHE_KEY));
|
|
1891
|
-
if (parsed && parsed.accounts) {
|
|
1892
|
-
const parsedAccounts = parsed.accounts.map((account) => {
|
|
1893
|
-
return {
|
|
1894
|
-
...account,
|
|
1895
|
-
publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : bs58.default.decode(account.address)
|
|
1896
|
-
};
|
|
1897
|
-
});
|
|
1898
|
-
return {
|
|
1899
|
-
...parsed,
|
|
1900
|
-
accounts: parsedAccounts
|
|
1901
|
-
};
|
|
1902
|
-
} else return parsed || void 0;
|
|
1903
|
-
} catch {}
|
|
1904
|
-
},
|
|
1905
|
-
async set(authorization) {
|
|
1906
|
-
if (!storage) return;
|
|
1907
|
-
try {
|
|
1908
|
-
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
1909
|
-
} catch {}
|
|
1910
|
-
}
|
|
1911
|
-
};
|
|
1912
|
-
}
|
|
1913
|
-
//#endregion
|
|
1914
|
-
//#region src/createDefaultChainSelector.ts
|
|
1915
|
-
function createDefaultChainSelector() {
|
|
1916
|
-
return { async select(chains) {
|
|
1917
|
-
if (chains.length === 1) return chains[0];
|
|
1918
|
-
else if (chains.includes(_solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN)) return _solana_wallet_standard_chains.SOLANA_MAINNET_CHAIN;
|
|
1919
|
-
else return chains[0];
|
|
1920
|
-
} };
|
|
1921
|
-
}
|
|
1922
|
-
//#endregion
|
|
1923
1914
|
exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
|
|
1924
1915
|
exports.RemoteSolanaMobileWalletAdapterWallet = RemoteSolanaMobileWalletAdapterWallet;
|
|
1925
1916
|
exports.SolanaMobileWalletAdapterRemoteWalletName = SolanaMobileWalletAdapterRemoteWalletName;
|