@pooflabs/web 0.0.85-rc3 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +43 -0
  2. package/dist/{index-B5qYY4YM.js → index-B-x9RTF7.js} +2 -2
  3. package/dist/index-B-x9RTF7.js.map +1 -0
  4. package/dist/{index-BaKs3A8s.js → index-BKN0IwAx.js} +3054 -300
  5. package/dist/index-BKN0IwAx.js.map +1 -0
  6. package/dist/{index-C4AnWFs_.esm.js → index-BTwX7FYW.esm.js} +425 -119
  7. package/dist/index-BTwX7FYW.esm.js.map +1 -0
  8. package/dist/{index-BzeiIIwF.js → index-DYBdUxnT.js} +3055 -301
  9. package/dist/index-DYBdUxnT.js.map +1 -0
  10. package/dist/{index-bEXLwE7_.js → index-Dj1tZr6X.js} +426 -118
  11. package/dist/index-Dj1tZr6X.js.map +1 -0
  12. package/dist/{index-dqqR5q7b.esm.js → index-DofM-ue2.esm.js} +3054 -301
  13. package/dist/index-DofM-ue2.esm.js.map +1 -0
  14. package/dist/index-_k6pjuwx.esm.js +6 -0
  15. package/dist/index-_k6pjuwx.esm.js.map +1 -0
  16. package/dist/{index-BE-VWSJT.esm.js → index-x7a-wH2l.esm.js} +3055 -300
  17. package/dist/index-x7a-wH2l.esm.js.map +1 -0
  18. package/dist/{index.browser-D8ttddP4.esm.js → index.browser-Cndx2raY.esm.js} +506 -1876
  19. package/dist/index.browser-Cndx2raY.esm.js.map +1 -0
  20. package/dist/{index.browser-CN6obNQM.js → index.browser-D7-FFk3q.js} +506 -1876
  21. package/dist/index.browser-D7-FFk3q.js.map +1 -0
  22. package/dist/{index.browser-CZIJCtms.js → index.browser-DlA-NKvf.js} +1223 -2565
  23. package/dist/index.browser-DlA-NKvf.js.map +1 -0
  24. package/dist/{index.browser-DQIwLToJ.esm.js → index.browser-nVGFrIHK.esm.js} +1223 -2565
  25. package/dist/index.browser-nVGFrIHK.esm.js.map +1 -0
  26. package/dist/index.esm.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/{index.native-DLziTime.esm.js → index.native-19VsREMJ.esm.js} +43 -62
  29. package/dist/index.native-19VsREMJ.esm.js.map +1 -0
  30. package/dist/{index.native-pG1NTZ0f.js → index.native-D8vj3Lbr.js} +44 -61
  31. package/dist/index.native-D8vj3Lbr.js.map +1 -0
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +1 -1
  34. package/dist/{phantom-wallet-provider-zBp7-uEw.js → phantom-wallet-provider-BlZZa_3s.js} +4 -4
  35. package/dist/{phantom-wallet-provider-zBp7-uEw.js.map → phantom-wallet-provider-BlZZa_3s.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-CP6NXRwG.esm.js → phantom-wallet-provider-Bz3qEFzX.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-CP6NXRwG.esm.js.map → phantom-wallet-provider-Bz3qEFzX.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-CoyW5Gdg.js → privy-wallet-provider-CqCgq7uT.js} +3 -3
  39. package/dist/privy-wallet-provider-CqCgq7uT.js.map +1 -0
  40. package/dist/{privy-wallet-provider-CGYvf3-r.esm.js → privy-wallet-provider-DgNFzioA.esm.js} +3 -3
  41. package/dist/privy-wallet-provider-DgNFzioA.esm.js.map +1 -0
  42. package/dist/{solana-mobile-wallet-provider-B8rHfsPN.esm.js → solana-mobile-wallet-provider-EeQsBTdr.esm.js} +385 -60
  43. package/dist/solana-mobile-wallet-provider-EeQsBTdr.esm.js.map +1 -0
  44. package/dist/{solana-mobile-wallet-provider-CN-D_H4l.js → solana-mobile-wallet-provider-VqIGfdMV.js} +385 -60
  45. package/dist/solana-mobile-wallet-provider-VqIGfdMV.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/index-B5qYY4YM.js.map +0 -1
  48. package/dist/index-BE-VWSJT.esm.js.map +0 -1
  49. package/dist/index-BaKs3A8s.js.map +0 -1
  50. package/dist/index-BzeiIIwF.js.map +0 -1
  51. package/dist/index-C4AnWFs_.esm.js.map +0 -1
  52. package/dist/index-TzHXEf3-.esm.js +0 -6
  53. package/dist/index-TzHXEf3-.esm.js.map +0 -1
  54. package/dist/index-bEXLwE7_.js.map +0 -1
  55. package/dist/index-dqqR5q7b.esm.js.map +0 -1
  56. package/dist/index.browser-CN6obNQM.js.map +0 -1
  57. package/dist/index.browser-CZIJCtms.js.map +0 -1
  58. package/dist/index.browser-D8ttddP4.esm.js.map +0 -1
  59. package/dist/index.browser-DQIwLToJ.esm.js.map +0 -1
  60. package/dist/index.native-DLziTime.esm.js.map +0 -1
  61. package/dist/index.native-pG1NTZ0f.js.map +0 -1
  62. package/dist/privy-wallet-provider-CGYvf3-r.esm.js.map +0 -1
  63. package/dist/privy-wallet-provider-CoyW5Gdg.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-B8rHfsPN.esm.js.map +0 -1
  65. package/dist/solana-mobile-wallet-provider-CN-D_H4l.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-bEXLwE7_.js');
3
+ var index = require('./index-Dj1tZr6X.js');
4
+ var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
4
5
  require('axios');
5
6
  require('@solana/web3.js');
6
7
  require('@coral-xyz/anchor');
@@ -18,1010 +19,6 @@ const SolanaSignMessage = 'solana:signMessage';
18
19
  /** Name of the feature. */
19
20
  const SolanaSignTransaction = 'solana:signTransaction';
20
21
 
21
- function createDecoder(decoder) {
22
- return Object.freeze({
23
- ...decoder,
24
- decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
25
- });
26
- }
27
-
28
- var getBaseXDecoder = (alphabet4) => {
29
- return createDecoder({
30
- read(rawBytes, offset) {
31
- const bytes = offset === 0 || offset <= -rawBytes.byteLength ? rawBytes : rawBytes.slice(offset);
32
- if (bytes.length === 0) return ["", 0];
33
- let trailIndex = bytes.findIndex((n) => n !== 0);
34
- trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
35
- const leadingZeroes = alphabet4[0].repeat(trailIndex);
36
- if (trailIndex === bytes.length) return [leadingZeroes, rawBytes.length];
37
- const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
38
- const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
39
- return [leadingZeroes + tailChars, rawBytes.length];
40
- }
41
- });
42
- };
43
- function getBaseXFromBigInt(value, alphabet4) {
44
- const base = BigInt(alphabet4.length);
45
- const tailChars = [];
46
- while (value > 0n) {
47
- tailChars.unshift(alphabet4[Number(value % base)]);
48
- value /= base;
49
- }
50
- return tailChars.join("");
51
- }
52
-
53
- // src/base58.ts
54
- var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
55
- var getBase58Decoder = () => getBaseXDecoder(alphabet2);
56
-
57
- /** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
58
- const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
59
-
60
- /**
61
- * TODO: docs
62
- */
63
- function createSignInMessageText(input) {
64
- // ${domain} wants you to sign in with your Solana account:
65
- // ${address}
66
- //
67
- // ${statement}
68
- //
69
- // URI: ${uri}
70
- // Version: ${version}
71
- // Chain ID: ${chain}
72
- // Nonce: ${nonce}
73
- // Issued At: ${issued-at}
74
- // Expiration Time: ${expiration-time}
75
- // Not Before: ${not-before}
76
- // Request ID: ${request-id}
77
- // Resources:
78
- // - ${resources[0]}
79
- // - ${resources[1]}
80
- // ...
81
- // - ${resources[n]}
82
- let message = `${input.domain} wants you to sign in with your Solana account:\n`;
83
- message += `${input.address}`;
84
- if (input.statement) {
85
- message += `\n\n${input.statement}`;
86
- }
87
- const fields = [];
88
- if (input.uri) {
89
- fields.push(`URI: ${input.uri}`);
90
- }
91
- if (input.version) {
92
- fields.push(`Version: ${input.version}`);
93
- }
94
- if (input.chainId) {
95
- fields.push(`Chain ID: ${input.chainId}`);
96
- }
97
- if (input.nonce) {
98
- fields.push(`Nonce: ${input.nonce}`);
99
- }
100
- if (input.issuedAt) {
101
- fields.push(`Issued At: ${input.issuedAt}`);
102
- }
103
- if (input.expirationTime) {
104
- fields.push(`Expiration Time: ${input.expirationTime}`);
105
- }
106
- if (input.notBefore) {
107
- fields.push(`Not Before: ${input.notBefore}`);
108
- }
109
- if (input.requestId) {
110
- fields.push(`Request ID: ${input.requestId}`);
111
- }
112
- if (input.resources) {
113
- fields.push(`Resources:`);
114
- for (const resource of input.resources) {
115
- fields.push(`- ${resource}`);
116
- }
117
- }
118
- if (fields.length) {
119
- message += `\n\n${fields.join('\n')}`;
120
- }
121
- return message;
122
- }
123
-
124
- //#region src/errors.ts
125
- const SolanaMobileWalletAdapterErrorCode = {
126
- ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE",
127
- ERROR_REFLECTOR_ID_OUT_OF_RANGE: "ERROR_REFLECTOR_ID_OUT_OF_RANGE",
128
- ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL",
129
- ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED",
130
- ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED",
131
- ERROR_SESSION_TIMEOUT: "ERROR_SESSION_TIMEOUT",
132
- ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND",
133
- ERROR_INVALID_PROTOCOL_VERSION: "ERROR_INVALID_PROTOCOL_VERSION",
134
- ERROR_BROWSER_NOT_SUPPORTED: "ERROR_BROWSER_NOT_SUPPORTED",
135
- ERROR_LOOPBACK_ACCESS_BLOCKED: "ERROR_LOOPBACK_ACCESS_BLOCKED",
136
- ERROR_ASSOCIATION_CANCELLED: "ERROR_ASSOCIATION_CANCELLED"
137
- };
138
- var SolanaMobileWalletAdapterError = class extends Error {
139
- data;
140
- code;
141
- constructor(...args) {
142
- const [code, message, data] = args;
143
- super(message);
144
- this.code = code;
145
- this.data = data;
146
- this.name = "SolanaMobileWalletAdapterError";
147
- }
148
- };
149
- var SolanaMobileWalletAdapterProtocolError = class extends Error {
150
- data;
151
- code;
152
- jsonRpcMessageId;
153
- constructor(...args) {
154
- const [jsonRpcMessageId, code, message, data] = args;
155
- super(message);
156
- this.code = code;
157
- this.data = data;
158
- this.jsonRpcMessageId = jsonRpcMessageId;
159
- this.name = "SolanaMobileWalletAdapterProtocolError";
160
- }
161
- };
162
- //#endregion
163
- //#region src/base64Utils.ts
164
- function encode(input) {
165
- return window.btoa(input);
166
- }
167
- function fromUint8Array$1(byteArray, urlsafe) {
168
- const base64 = window.btoa(String.fromCharCode.call(null, ...byteArray));
169
- if (urlsafe) return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
170
- else return base64;
171
- }
172
- function toUint8Array$1(base64EncodedByteArray) {
173
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
174
- }
175
- //#endregion
176
- //#region src/createHelloReq.ts
177
- async function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
178
- const publicKeyBuffer = await crypto.subtle.exportKey("raw", ecdhPublicKey);
179
- const signatureBuffer = await crypto.subtle.sign({
180
- hash: "SHA-256",
181
- name: "ECDSA"
182
- }, associationKeypairPrivateKey, publicKeyBuffer);
183
- const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
184
- response.set(new Uint8Array(publicKeyBuffer), 0);
185
- response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
186
- return response;
187
- }
188
- //#endregion
189
- //#region src/base58Utils.ts
190
- function fromUint8Array$2(byteArray) {
191
- return getBase58Decoder().decode(byteArray);
192
- }
193
- function base64ToBase58(base64EncodedString) {
194
- return fromUint8Array$2(toUint8Array$1(base64EncodedString));
195
- }
196
- //#endregion
197
- //#region src/createSIWSMessage.ts
198
- function createSIWSMessage(payload) {
199
- return createSignInMessageText(payload);
200
- }
201
- function createSIWSMessageBase64Url(payload) {
202
- return encode(createSIWSMessage(payload)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
203
- }
204
- //#endregion
205
- //#region src/types.ts
206
- const SolanaSignTransactions = "solana:signTransactions";
207
- const SolanaCloneAuthorization = "solana:cloneAuthorization";
208
- //#endregion
209
- //#region src/createMobileWalletProxy.ts
210
- /**
211
- * Creates a {@link MobileWallet} proxy that handles backwards compatibility and API to RPC conversion.
212
- *
213
- * @param protocolVersion the protocol version in use for this session/request
214
- * @param protocolRequestHandler callback function that handles sending the RPC request to the wallet endpoint.
215
- * @returns a {@link MobileWallet} proxy
216
- */
217
- function createMobileWalletProxy(protocolVersion, protocolRequestHandler) {
218
- return new Proxy({}, {
219
- get(target, p) {
220
- if (p === "then") return null;
221
- if (target[p] == null) target[p] = async function(inputParams) {
222
- const { method, params } = handleMobileWalletRequest(p, inputParams, protocolVersion);
223
- const result = await protocolRequestHandler(method, params);
224
- if (method === "authorize" && params.sign_in_payload && !result.sign_in_result) result.sign_in_result = await signInFallback(params.sign_in_payload, result, protocolRequestHandler);
225
- return handleMobileWalletResponse(p, result, protocolVersion);
226
- };
227
- return target[p];
228
- },
229
- defineProperty() {
230
- return false;
231
- },
232
- deleteProperty() {
233
- return false;
234
- }
235
- });
236
- }
237
- /**
238
- * Handles all {@link MobileWallet} API requests and determines the correct MWA RPC method and params to call.
239
- * This handles backwards compatibility, based on the provided @protocolVersion.
240
- *
241
- * @param methodName the name of {@link MobileWallet} method that was called
242
- * @param methodParams the parameters that were passed to the method
243
- * @param protocolVersion the protocol version in use for this session/request
244
- * @returns the RPC request method and params that should be sent to the wallet endpoint
245
- */
246
- function handleMobileWalletRequest(methodName, methodParams, protocolVersion) {
247
- let params = methodParams;
248
- let method = methodName.toString().replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).toLowerCase();
249
- switch (methodName) {
250
- case "authorize": {
251
- const authorizeParams = params;
252
- let { chain } = authorizeParams;
253
- if (protocolVersion === "legacy") {
254
- switch (chain) {
255
- case "solana:testnet":
256
- chain = "testnet";
257
- break;
258
- case "solana:devnet":
259
- chain = "devnet";
260
- break;
261
- case "solana:mainnet":
262
- chain = "mainnet-beta";
263
- break;
264
- default: chain = authorizeParams.cluster;
265
- }
266
- authorizeParams.cluster = chain;
267
- params = authorizeParams;
268
- } else {
269
- switch (chain) {
270
- case "testnet":
271
- case "devnet":
272
- chain = `solana:${chain}`;
273
- break;
274
- case "mainnet-beta":
275
- chain = "solana:mainnet";
276
- break;
277
- }
278
- authorizeParams.chain = chain;
279
- params = authorizeParams;
280
- }
281
- }
282
- case "reauthorize": {
283
- const { auth_token, identity } = params;
284
- if (auth_token) switch (protocolVersion) {
285
- case "legacy":
286
- method = "reauthorize";
287
- params = {
288
- auth_token,
289
- identity
290
- };
291
- break;
292
- default:
293
- method = "authorize";
294
- break;
295
- }
296
- break;
297
- }
298
- }
299
- return {
300
- method,
301
- params
302
- };
303
- }
304
- /**
305
- * Handles all {@link MobileWallet} API responses and modifies the response for backwards compatibility, if needed
306
- *
307
- * @param method the {@link MobileWallet} method that was called
308
- * @param response the original response that was returned by the method call
309
- * @param protocolVersion the protocol version in use for this session/request
310
- * @returns the possibly modified response
311
- */
312
- function handleMobileWalletResponse(method, response, protocolVersion) {
313
- switch (method) {
314
- case "getCapabilities": {
315
- const capabilities = response;
316
- switch (protocolVersion) {
317
- case "legacy": {
318
- const features = [SolanaSignTransactions];
319
- if (capabilities.supports_clone_authorization === true) features.push(SolanaCloneAuthorization);
320
- return {
321
- ...capabilities,
322
- features
323
- };
324
- }
325
- case "v1": return {
326
- ...capabilities,
327
- supports_sign_and_send_transactions: true,
328
- supports_clone_authorization: capabilities.features.includes(SolanaCloneAuthorization)
329
- };
330
- }
331
- }
332
- }
333
- return response;
334
- }
335
- async function signInFallback(signInPayload, authorizationResult, protocolRequestHandler) {
336
- const domain = signInPayload.domain ?? window.location.host;
337
- const address = authorizationResult.accounts[0].address;
338
- const siwsMessage = createSIWSMessageBase64Url({
339
- ...signInPayload,
340
- domain,
341
- address: base64ToBase58(address)
342
- });
343
- const signedPayload = toUint8Array$1((await protocolRequestHandler("sign_messages", {
344
- addresses: [address],
345
- payloads: [siwsMessage]
346
- })).signed_payloads[0]);
347
- const signedMessage = fromUint8Array$1(signedPayload.slice(0, signedPayload.length - 64));
348
- const signature = fromUint8Array$1(signedPayload.slice(signedPayload.length - 64));
349
- return {
350
- address,
351
- signed_message: signedMessage.length == 0 ? siwsMessage : signedMessage,
352
- signature
353
- };
354
- }
355
- function createSequenceNumberVector(sequenceNumber) {
356
- if (sequenceNumber >= 4294967296) throw new Error("Outbound sequence number overflow. The maximum sequence number is 32-bytes.");
357
- const byteArray = /* @__PURE__ */ new ArrayBuffer(4);
358
- new DataView(byteArray).setUint32(0, sequenceNumber, false);
359
- return new Uint8Array(byteArray);
360
- }
361
- //#endregion
362
- //#region src/encryptedMessage.ts
363
- const INITIALIZATION_VECTOR_BYTES = 12;
364
- async function encryptMessage(plaintext, sequenceNumber, sharedSecret) {
365
- const sequenceNumberVector = createSequenceNumberVector(sequenceNumber);
366
- const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
367
- crypto.getRandomValues(initializationVector);
368
- const ciphertext = await crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
369
- const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
370
- response.set(new Uint8Array(sequenceNumberVector), 0);
371
- response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
372
- response.set(new Uint8Array(ciphertext), sequenceNumberVector.byteLength + initializationVector.byteLength);
373
- return response;
374
- }
375
- async function decryptMessage(message, sharedSecret) {
376
- const sequenceNumberVector = message.slice(0, 4);
377
- const initializationVector = message.slice(4, 4 + INITIALIZATION_VECTOR_BYTES);
378
- const ciphertext = message.slice(4 + INITIALIZATION_VECTOR_BYTES);
379
- const plaintextBuffer = await crypto.subtle.decrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, ciphertext);
380
- return getUtf8Decoder().decode(plaintextBuffer);
381
- }
382
- function getAlgorithmParams(sequenceNumber, initializationVector) {
383
- return {
384
- additionalData: sequenceNumber,
385
- iv: initializationVector,
386
- name: "AES-GCM",
387
- tagLength: 128
388
- };
389
- }
390
- let _utf8Decoder;
391
- function getUtf8Decoder() {
392
- if (_utf8Decoder === void 0) _utf8Decoder = new TextDecoder("utf-8");
393
- return _utf8Decoder;
394
- }
395
- //#endregion
396
- //#region src/generateAssociationKeypair.ts
397
- async function generateAssociationKeypair() {
398
- return await crypto.subtle.generateKey({
399
- name: "ECDSA",
400
- namedCurve: "P-256"
401
- }, false, ["sign"]);
402
- }
403
- //#endregion
404
- //#region src/generateECDHKeypair.ts
405
- async function generateECDHKeypair() {
406
- return await crypto.subtle.generateKey({
407
- name: "ECDH",
408
- namedCurve: "P-256"
409
- }, false, ["deriveKey", "deriveBits"]);
410
- }
411
- //#endregion
412
- //#region src/arrayBufferToBase64String.ts
413
- function arrayBufferToBase64String(buffer) {
414
- let binary = "";
415
- const bytes = new Uint8Array(buffer);
416
- const len = bytes.byteLength;
417
- for (let ii = 0; ii < len; ii++) binary += String.fromCharCode(bytes[ii]);
418
- return window.btoa(binary);
419
- }
420
- //#endregion
421
- //#region src/associationPort.ts
422
- function getRandomAssociationPort() {
423
- return assertAssociationPort(49152 + Math.floor(Math.random() * 16384));
424
- }
425
- function assertAssociationPort(port) {
426
- if (port < 49152 || port > 65535) throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE, `Association port number must be between 49152 and 65535. ${port} given.`, { port });
427
- return port;
428
- }
429
- //#endregion
430
- //#region src/getStringWithURLUnsafeBase64CharactersReplaced.ts
431
- function getStringWithURLUnsafeCharactersReplaced(unsafeBase64EncodedString) {
432
- return unsafeBase64EncodedString.replace(/[/+=]/g, (m) => ({
433
- "/": "_",
434
- "+": "-",
435
- "=": "."
436
- })[m]);
437
- }
438
- //#endregion
439
- //#region src/getAssociateAndroidIntentURL.ts
440
- const INTENT_NAME = "solana-wallet";
441
- function getPathParts(pathString) {
442
- return pathString.replace(/(^\/+|\/+$)/g, "").split("/");
443
- }
444
- function getIntentURL(methodPathname, intentUrlBase) {
445
- let baseUrl = null;
446
- if (intentUrlBase) {
447
- try {
448
- baseUrl = new URL(intentUrlBase);
449
- } catch {}
450
- if (baseUrl?.protocol !== "https:") throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Base URLs supplied by wallets must be valid `https` URLs");
451
- }
452
- baseUrl ||= new URL(`${INTENT_NAME}:/`);
453
- const pathname = methodPathname.startsWith("/") ? methodPathname : [...getPathParts(baseUrl.pathname), ...getPathParts(methodPathname)].join("/");
454
- return new URL(pathname, baseUrl);
455
- }
456
- async function getAssociateAndroidIntentURL(associationPublicKey, putativePort, associationURLBase, protocolVersions = ["v1"]) {
457
- const associationPort = assertAssociationPort(putativePort);
458
- const encodedKey = arrayBufferToBase64String(await crypto.subtle.exportKey("raw", associationPublicKey));
459
- const url = getIntentURL("v1/associate/local", associationURLBase);
460
- url.searchParams.set("association", getStringWithURLUnsafeCharactersReplaced(encodedKey));
461
- url.searchParams.set("port", `${associationPort}`);
462
- protocolVersions.forEach((version) => {
463
- url.searchParams.set("v", version);
464
- });
465
- return url;
466
- }
467
- async function getRemoteAssociateAndroidIntentURL(associationPublicKey, hostAuthority, reflectorId, associationURLBase, protocolVersions = ["v1"]) {
468
- const encodedKey = arrayBufferToBase64String(await crypto.subtle.exportKey("raw", associationPublicKey));
469
- const url = getIntentURL("v1/associate/remote", associationURLBase);
470
- url.searchParams.set("association", getStringWithURLUnsafeCharactersReplaced(encodedKey));
471
- url.searchParams.set("reflector", `${hostAuthority}`);
472
- url.searchParams.set("id", `${fromUint8Array$1(reflectorId, true)}`);
473
- protocolVersions.forEach((version) => {
474
- url.searchParams.set("v", version);
475
- });
476
- return url;
477
- }
478
- //#endregion
479
- //#region src/jsonRpcMessage.ts
480
- async function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
481
- const plaintext = JSON.stringify(jsonRpcMessage);
482
- const sequenceNumber = jsonRpcMessage.id;
483
- return encryptMessage(plaintext, sequenceNumber, sharedSecret);
484
- }
485
- async function decryptJsonRpcMessage(message, sharedSecret) {
486
- const plaintext = await decryptMessage(message, sharedSecret);
487
- const jsonRpcMessage = JSON.parse(plaintext);
488
- if (Object.hasOwnProperty.call(jsonRpcMessage, "error")) throw new SolanaMobileWalletAdapterProtocolError(jsonRpcMessage.id, jsonRpcMessage.error.code, jsonRpcMessage.error.message);
489
- return jsonRpcMessage;
490
- }
491
- //#endregion
492
- //#region src/parseHelloRsp.ts
493
- async function parseHelloRsp(payloadBuffer, associationPublicKey, ecdhPrivateKey) {
494
- const [associationPublicKeyBuffer, walletPublicKey] = await Promise.all([crypto.subtle.exportKey("raw", associationPublicKey), crypto.subtle.importKey("raw", payloadBuffer.slice(0, 65), {
495
- name: "ECDH",
496
- namedCurve: "P-256"
497
- }, false, [])]);
498
- const sharedSecret = await crypto.subtle.deriveBits({
499
- name: "ECDH",
500
- public: walletPublicKey
501
- }, ecdhPrivateKey, 256);
502
- const ecdhSecretKey = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveKey"]);
503
- return await crypto.subtle.deriveKey({
504
- name: "HKDF",
505
- hash: "SHA-256",
506
- salt: new Uint8Array(associationPublicKeyBuffer),
507
- info: new Uint8Array()
508
- }, ecdhSecretKey, {
509
- name: "AES-GCM",
510
- length: 128
511
- }, false, ["encrypt", "decrypt"]);
512
- }
513
- //#endregion
514
- //#region src/parseSessionProps.ts
515
- async function parseSessionProps(message, sharedSecret) {
516
- const plaintext = await decryptMessage(message, sharedSecret);
517
- const jsonProperties = JSON.parse(plaintext);
518
- let protocolVersion = "legacy";
519
- if (Object.hasOwnProperty.call(jsonProperties, "v")) switch (jsonProperties.v) {
520
- case 1:
521
- case "1":
522
- case "v1":
523
- protocolVersion = "v1";
524
- break;
525
- case "legacy":
526
- protocolVersion = "legacy";
527
- break;
528
- default: throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_INVALID_PROTOCOL_VERSION, `Unknown/unsupported protocol version: ${jsonProperties.v}`);
529
- }
530
- return { protocol_version: protocolVersion };
531
- }
532
- //#endregion
533
- //#region src/startSession.ts
534
- const Browser = {
535
- Firefox: 0,
536
- Other: 1
537
- };
538
- function assertUnreachable(x) {
539
- return x;
540
- }
541
- function getBrowser() {
542
- return navigator.userAgent.indexOf("Firefox/") !== -1 ? Browser.Firefox : Browser.Other;
543
- }
544
- function getDetectionPromise() {
545
- return new Promise((resolve, reject) => {
546
- function cleanup() {
547
- clearTimeout(timeoutId);
548
- window.removeEventListener("blur", handleBlur);
549
- }
550
- function handleBlur() {
551
- cleanup();
552
- resolve();
553
- }
554
- window.addEventListener("blur", handleBlur);
555
- const timeoutId = setTimeout(() => {
556
- cleanup();
557
- reject();
558
- }, 3e3);
559
- });
560
- }
561
- let _frame = null;
562
- function launchUrlThroughHiddenFrame(url) {
563
- if (_frame == null) {
564
- _frame = document.createElement("iframe");
565
- _frame.style.display = "none";
566
- document.body.appendChild(_frame);
567
- }
568
- _frame.contentWindow.location.href = url.toString();
569
- }
570
- async function launchAssociation(associationUrl) {
571
- if (associationUrl.protocol === "https:") window.location.assign(associationUrl);
572
- else try {
573
- const browser = getBrowser();
574
- switch (browser) {
575
- case Browser.Firefox:
576
- launchUrlThroughHiddenFrame(associationUrl);
577
- break;
578
- case Browser.Other: {
579
- const detectionPromise = getDetectionPromise();
580
- window.location.assign(associationUrl);
581
- await detectionPromise;
582
- break;
583
- }
584
- default: assertUnreachable(browser);
585
- }
586
- } catch {
587
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND, "Found no installed wallet that supports the mobile wallet protocol.");
588
- }
589
- }
590
- async function startSession(associationPublicKey, associationURLBase) {
591
- const randomAssociationPort = getRandomAssociationPort();
592
- await launchAssociation(await getAssociateAndroidIntentURL(associationPublicKey, randomAssociationPort, associationURLBase));
593
- return randomAssociationPort;
594
- }
595
- //#endregion
596
- //#region src/transact.ts
597
- const WEBSOCKET_CONNECTION_CONFIG = {
598
- retryDelayScheduleMs: [
599
- 150,
600
- 150,
601
- 200,
602
- 500,
603
- 500,
604
- 750,
605
- 750,
606
- 1e3
607
- ],
608
- timeoutMs: 3e4
609
- };
610
- const WEBSOCKET_PROTOCOL_BINARY = "com.solana.mobilewalletadapter.v1";
611
- const WEBSOCKET_PROTOCOL_BASE64 = "com.solana.mobilewalletadapter.v1.base64";
612
- function assertSecureContext() {
613
- if (typeof window === "undefined" || window.isSecureContext !== true) throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SECURE_CONTEXT_REQUIRED, "The mobile wallet adapter protocol must be used in a secure context (`https`).");
614
- }
615
- function assertSecureEndpointSpecificURI(walletUriBase) {
616
- let url;
617
- try {
618
- url = new URL(walletUriBase);
619
- } catch {
620
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Invalid base URL supplied by wallet");
621
- }
622
- if (url.protocol !== "https:") throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Base URLs supplied by wallets must be valid `https` URLs");
623
- }
624
- function getSequenceNumberFromByteArray(byteArray) {
625
- return new DataView(byteArray).getUint32(0, false);
626
- }
627
- function decodeVarLong(byteArray) {
628
- const bytes = new Uint8Array(byteArray);
629
- const l = byteArray.byteLength;
630
- const limit = 10;
631
- let value = 0, offset = 0, b;
632
- do {
633
- if (offset >= l || offset > limit) throw new RangeError("Failed to decode varint");
634
- b = bytes[offset++];
635
- value |= (b & 127) << 7 * offset;
636
- } while (b >= 128);
637
- return {
638
- value,
639
- offset
640
- };
641
- }
642
- function getReflectorIdFromByteArray(byteArray) {
643
- const { value: length, offset } = decodeVarLong(byteArray);
644
- return new Uint8Array(byteArray.slice(offset, offset + length));
645
- }
646
- async function startScenario(config) {
647
- assertSecureContext();
648
- const associationKeypair = await generateAssociationKeypair();
649
- const websocketURL = `ws://localhost:${await startSession(associationKeypair.publicKey, config?.baseUri)}/solana-wallet`;
650
- let connectionStartTime;
651
- const getNextRetryDelayMs = (() => {
652
- const schedule = [...WEBSOCKET_CONNECTION_CONFIG.retryDelayScheduleMs];
653
- return () => schedule.length > 1 ? schedule.shift() : schedule[0];
654
- })();
655
- let nextJsonRpcMessageId = 1;
656
- let lastKnownInboundSequenceNumber = 0;
657
- let state = { __type: "disconnected" };
658
- let socket;
659
- let sessionEstablished = false;
660
- let handleForceClose;
661
- return {
662
- close: () => {
663
- socket.close();
664
- handleForceClose();
665
- },
666
- wallet: new Promise((resolve, reject) => {
667
- const jsonRpcResponsePromises = {};
668
- const handleOpen = async () => {
669
- if (state.__type !== "connecting") {
670
- console.warn(`Expected adapter state to be \`connecting\` at the moment the websocket opens. Got \`${state.__type}\`.`);
671
- return;
672
- }
673
- socket.removeEventListener("open", handleOpen);
674
- const { associationKeypair } = state;
675
- const ecdhKeypair = await generateECDHKeypair();
676
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
677
- state = {
678
- __type: "hello_req_sent",
679
- associationPublicKey: associationKeypair.publicKey,
680
- ecdhPrivateKey: ecdhKeypair.privateKey
681
- };
682
- };
683
- const handleClose = (evt) => {
684
- if (evt.wasClean) state = { __type: "disconnected" };
685
- else reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session dropped unexpectedly (${evt.code}: ${evt.reason}).`, { closeEvent: evt }));
686
- disposeSocket();
687
- };
688
- const handleError = async (_evt) => {
689
- disposeSocket();
690
- if (Date.now() - connectionStartTime >= WEBSOCKET_CONNECTION_CONFIG.timeoutMs) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_TIMEOUT, `Failed to connect to the wallet websocket at ${websocketURL}.`));
691
- else {
692
- await new Promise((resolve) => {
693
- const retryDelayMs = getNextRetryDelayMs();
694
- retryWaitTimeoutId = window.setTimeout(resolve, retryDelayMs);
695
- });
696
- attemptSocketConnection();
697
- }
698
- };
699
- const handleMessage = async (evt) => {
700
- const responseBuffer = await evt.data.arrayBuffer();
701
- switch (state.__type) {
702
- case "connecting": {
703
- if (responseBuffer.byteLength !== 0) throw new Error("Encountered unexpected message while connecting");
704
- const ecdhKeypair = await generateECDHKeypair();
705
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
706
- state = {
707
- __type: "hello_req_sent",
708
- associationPublicKey: associationKeypair.publicKey,
709
- ecdhPrivateKey: ecdhKeypair.privateKey
710
- };
711
- break;
712
- }
713
- case "connected":
714
- try {
715
- const sequenceNumber = getSequenceNumberFromByteArray(responseBuffer.slice(0, 4));
716
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
717
- lastKnownInboundSequenceNumber = sequenceNumber;
718
- const jsonRpcMessage = await decryptJsonRpcMessage(responseBuffer, state.sharedSecret);
719
- const responsePromise = jsonRpcResponsePromises[jsonRpcMessage.id];
720
- delete jsonRpcResponsePromises[jsonRpcMessage.id];
721
- responsePromise.resolve(jsonRpcMessage.result);
722
- } catch (e) {
723
- if (e instanceof SolanaMobileWalletAdapterProtocolError) {
724
- const responsePromise = jsonRpcResponsePromises[e.jsonRpcMessageId];
725
- delete jsonRpcResponsePromises[e.jsonRpcMessageId];
726
- responsePromise.reject(e);
727
- } else throw e;
728
- }
729
- break;
730
- case "hello_req_sent": {
731
- if (responseBuffer.byteLength === 0) {
732
- const ecdhKeypair = await generateECDHKeypair();
733
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
734
- state = {
735
- __type: "hello_req_sent",
736
- associationPublicKey: associationKeypair.publicKey,
737
- ecdhPrivateKey: ecdhKeypair.privateKey
738
- };
739
- break;
740
- }
741
- const sharedSecret = await parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
742
- const sessionPropertiesBuffer = responseBuffer.slice(65);
743
- const sessionProperties = sessionPropertiesBuffer.byteLength !== 0 ? await (async () => {
744
- const sequenceNumber = getSequenceNumberFromByteArray(sessionPropertiesBuffer.slice(0, 4));
745
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
746
- lastKnownInboundSequenceNumber = sequenceNumber;
747
- return parseSessionProps(sessionPropertiesBuffer, sharedSecret);
748
- })() : { protocol_version: "legacy" };
749
- state = {
750
- __type: "connected",
751
- sharedSecret,
752
- sessionProperties
753
- };
754
- const wallet = createMobileWalletProxy(sessionProperties.protocol_version, async (method, params) => {
755
- const id = nextJsonRpcMessageId++;
756
- socket.send(await encryptJsonRpcMessage({
757
- id,
758
- jsonrpc: "2.0",
759
- method,
760
- params: params ?? {}
761
- }, sharedSecret));
762
- return new Promise((resolve, reject) => {
763
- jsonRpcResponsePromises[id] = {
764
- resolve(result) {
765
- switch (method) {
766
- case "authorize":
767
- case "reauthorize": {
768
- const { wallet_uri_base } = result;
769
- if (wallet_uri_base != null) try {
770
- assertSecureEndpointSpecificURI(wallet_uri_base);
771
- } catch (e) {
772
- reject(e);
773
- return;
774
- }
775
- break;
776
- }
777
- }
778
- resolve(result);
779
- },
780
- reject
781
- };
782
- });
783
- });
784
- sessionEstablished = true;
785
- try {
786
- resolve(wallet);
787
- } catch (e) {
788
- reject(e);
789
- }
790
- break;
791
- }
792
- }
793
- };
794
- handleForceClose = () => {
795
- socket.removeEventListener("message", handleMessage);
796
- disposeSocket();
797
- if (!sessionEstablished) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session was closed before connection.`, { closeEvent: new CloseEvent("socket was closed before connection") }));
798
- };
799
- let disposeSocket;
800
- let retryWaitTimeoutId;
801
- const attemptSocketConnection = () => {
802
- if (disposeSocket) disposeSocket();
803
- state = {
804
- __type: "connecting",
805
- associationKeypair
806
- };
807
- if (connectionStartTime === void 0) connectionStartTime = Date.now();
808
- socket = new WebSocket(websocketURL, [WEBSOCKET_PROTOCOL_BINARY]);
809
- socket.addEventListener("open", handleOpen);
810
- socket.addEventListener("close", handleClose);
811
- socket.addEventListener("error", handleError);
812
- socket.addEventListener("message", handleMessage);
813
- disposeSocket = () => {
814
- window.clearTimeout(retryWaitTimeoutId);
815
- socket.removeEventListener("open", handleOpen);
816
- socket.removeEventListener("close", handleClose);
817
- socket.removeEventListener("error", handleError);
818
- socket.removeEventListener("message", handleMessage);
819
- };
820
- };
821
- attemptSocketConnection();
822
- })
823
- };
824
- }
825
- async function startRemoteScenario(config) {
826
- assertSecureContext();
827
- const associationKeypair = await generateAssociationKeypair();
828
- const websocketURL = `wss://${config?.remoteHostAuthority}/reflect`;
829
- let connectionStartTime;
830
- const getNextRetryDelayMs = (() => {
831
- const schedule = [...WEBSOCKET_CONNECTION_CONFIG.retryDelayScheduleMs];
832
- return () => schedule.length > 1 ? schedule.shift() : schedule[0];
833
- })();
834
- let nextJsonRpcMessageId = 1;
835
- let lastKnownInboundSequenceNumber = 0;
836
- let encoding;
837
- let state = { __type: "disconnected" };
838
- let socket;
839
- let disposeSocket;
840
- const decodeBytes = async (evt) => {
841
- if (encoding == "base64") return toUint8Array$1(await evt.data).buffer;
842
- else return await evt.data.arrayBuffer();
843
- };
844
- const associationUrl = await new Promise((resolve, reject) => {
845
- const handleOpen = async () => {
846
- if (state.__type !== "connecting") {
847
- console.warn(`Expected adapter state to be \`connecting\` at the moment the websocket opens. Got \`${state.__type}\`.`);
848
- return;
849
- }
850
- if (socket.protocol.includes(WEBSOCKET_PROTOCOL_BASE64)) encoding = "base64";
851
- else encoding = "binary";
852
- socket.removeEventListener("open", handleOpen);
853
- };
854
- const handleClose = (evt) => {
855
- if (evt.wasClean) state = { __type: "disconnected" };
856
- else reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session dropped unexpectedly (${evt.code}: ${evt.reason}).`, { closeEvent: evt }));
857
- disposeSocket();
858
- };
859
- const handleError = async (_evt) => {
860
- disposeSocket();
861
- if (Date.now() - connectionStartTime >= WEBSOCKET_CONNECTION_CONFIG.timeoutMs) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_TIMEOUT, `Failed to connect to the wallet websocket at ${websocketURL}.`));
862
- else {
863
- await new Promise((resolve) => {
864
- const retryDelayMs = getNextRetryDelayMs();
865
- retryWaitTimeoutId = window.setTimeout(resolve, retryDelayMs);
866
- });
867
- attemptSocketConnection();
868
- }
869
- };
870
- const handleReflectorIdMessage = async (evt) => {
871
- const responseBuffer = await decodeBytes(evt);
872
- if (state.__type === "connecting") {
873
- if (responseBuffer.byteLength == 0) throw new Error("Encountered unexpected message while connecting");
874
- const reflectorId = getReflectorIdFromByteArray(responseBuffer);
875
- state = {
876
- __type: "reflector_id_received",
877
- reflectorId
878
- };
879
- const associationUrl = await getRemoteAssociateAndroidIntentURL(associationKeypair.publicKey, config.remoteHostAuthority, reflectorId, config?.baseUri);
880
- socket.removeEventListener("message", handleReflectorIdMessage);
881
- resolve(associationUrl);
882
- }
883
- };
884
- let retryWaitTimeoutId;
885
- const attemptSocketConnection = () => {
886
- if (disposeSocket) disposeSocket();
887
- state = {
888
- __type: "connecting",
889
- associationKeypair
890
- };
891
- if (connectionStartTime === void 0) connectionStartTime = Date.now();
892
- socket = new WebSocket(websocketURL, [WEBSOCKET_PROTOCOL_BINARY, WEBSOCKET_PROTOCOL_BASE64]);
893
- socket.addEventListener("open", handleOpen);
894
- socket.addEventListener("close", handleClose);
895
- socket.addEventListener("error", handleError);
896
- socket.addEventListener("message", handleReflectorIdMessage);
897
- disposeSocket = () => {
898
- window.clearTimeout(retryWaitTimeoutId);
899
- socket.removeEventListener("open", handleOpen);
900
- socket.removeEventListener("close", handleClose);
901
- socket.removeEventListener("error", handleError);
902
- socket.removeEventListener("message", handleReflectorIdMessage);
903
- };
904
- };
905
- attemptSocketConnection();
906
- });
907
- let sessionEstablished = false;
908
- let handleClose;
909
- return {
910
- associationUrl,
911
- close: () => {
912
- socket.close();
913
- handleClose();
914
- },
915
- wallet: new Promise((resolve, reject) => {
916
- const jsonRpcResponsePromises = {};
917
- const handleMessage = async (evt) => {
918
- const responseBuffer = await decodeBytes(evt);
919
- switch (state.__type) {
920
- case "reflector_id_received": {
921
- if (responseBuffer.byteLength !== 0) throw new Error("Encountered unexpected message while awaiting reflection");
922
- const ecdhKeypair = await generateECDHKeypair();
923
- const binaryMsg = await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey);
924
- if (encoding == "base64") socket.send(fromUint8Array$1(binaryMsg));
925
- else socket.send(binaryMsg);
926
- state = {
927
- __type: "hello_req_sent",
928
- associationPublicKey: associationKeypair.publicKey,
929
- ecdhPrivateKey: ecdhKeypair.privateKey
930
- };
931
- break;
932
- }
933
- case "connected":
934
- try {
935
- const sequenceNumber = getSequenceNumberFromByteArray(responseBuffer.slice(0, 4));
936
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
937
- lastKnownInboundSequenceNumber = sequenceNumber;
938
- const jsonRpcMessage = await decryptJsonRpcMessage(responseBuffer, state.sharedSecret);
939
- const responsePromise = jsonRpcResponsePromises[jsonRpcMessage.id];
940
- delete jsonRpcResponsePromises[jsonRpcMessage.id];
941
- responsePromise.resolve(jsonRpcMessage.result);
942
- } catch (e) {
943
- if (e instanceof SolanaMobileWalletAdapterProtocolError) {
944
- const responsePromise = jsonRpcResponsePromises[e.jsonRpcMessageId];
945
- delete jsonRpcResponsePromises[e.jsonRpcMessageId];
946
- responsePromise.reject(e);
947
- } else throw e;
948
- }
949
- break;
950
- case "hello_req_sent": {
951
- const sharedSecret = await parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
952
- const sessionPropertiesBuffer = responseBuffer.slice(65);
953
- const sessionProperties = sessionPropertiesBuffer.byteLength !== 0 ? await (async () => {
954
- const sequenceNumber = getSequenceNumberFromByteArray(sessionPropertiesBuffer.slice(0, 4));
955
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
956
- lastKnownInboundSequenceNumber = sequenceNumber;
957
- return parseSessionProps(sessionPropertiesBuffer, sharedSecret);
958
- })() : { protocol_version: "legacy" };
959
- state = {
960
- __type: "connected",
961
- sharedSecret,
962
- sessionProperties
963
- };
964
- const wallet = createMobileWalletProxy(sessionProperties.protocol_version, async (method, params) => {
965
- const id = nextJsonRpcMessageId++;
966
- const binaryMsg = await encryptJsonRpcMessage({
967
- id,
968
- jsonrpc: "2.0",
969
- method,
970
- params: params ?? {}
971
- }, sharedSecret);
972
- if (encoding == "base64") socket.send(fromUint8Array$1(binaryMsg));
973
- else socket.send(binaryMsg);
974
- return new Promise((resolve, reject) => {
975
- jsonRpcResponsePromises[id] = {
976
- resolve(result) {
977
- switch (method) {
978
- case "authorize":
979
- case "reauthorize": {
980
- const { wallet_uri_base } = result;
981
- if (wallet_uri_base != null) try {
982
- assertSecureEndpointSpecificURI(wallet_uri_base);
983
- } catch (e) {
984
- reject(e);
985
- return;
986
- }
987
- break;
988
- }
989
- }
990
- resolve(result);
991
- },
992
- reject
993
- };
994
- });
995
- });
996
- sessionEstablished = true;
997
- try {
998
- resolve(wallet);
999
- } catch (e) {
1000
- reject(e);
1001
- }
1002
- break;
1003
- }
1004
- }
1005
- };
1006
- socket.addEventListener("message", handleMessage);
1007
- handleClose = () => {
1008
- socket.removeEventListener("message", handleMessage);
1009
- disposeSocket();
1010
- if (!sessionEstablished) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session was closed before connection.`, { closeEvent: new CloseEvent("socket was closed before connection") }));
1011
- };
1012
- })
1013
- };
1014
- }
1015
-
1016
- /** Name of the feature. */
1017
- const StandardConnect = 'standard:connect';
1018
-
1019
- /** Name of the feature. */
1020
- const StandardDisconnect = 'standard:disconnect';
1021
-
1022
- /** Name of the feature. */
1023
- const StandardEvents = 'standard:events';
1024
-
1025
22
  var browser = {};
1026
23
 
1027
24
  var canPromise;
@@ -4094,239 +3091,55 @@ function requireBrowser () {
4094
3091
  var browserExports = requireBrowser();
4095
3092
  var QRCode = /*@__PURE__*/index.getDefaultExportFromCjs(browserExports);
4096
3093
 
4097
- var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4098
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4099
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4100
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4101
- };
4102
- var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4103
- if (kind === "m") throw new TypeError("Private method is not writable");
4104
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4105
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
4106
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4107
- };
4108
- var _RegisterWalletEvent_detail;
4109
- /**
4110
- * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
4111
- *
4112
- * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
4113
- * ready to be registered.
4114
- *
4115
- * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
4116
- * the app that the app is ready to register the Wallet.
4117
- *
4118
- * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
4119
- * as the app is ready whether the Wallet loads before or after the app.
4120
- *
4121
- * @param wallet Wallet to register.
4122
- *
4123
- * @group Wallet
4124
- */
4125
- function registerWallet(wallet) {
4126
- const callback = ({ register }) => register(wallet);
4127
- try {
4128
- window.dispatchEvent(new RegisterWalletEvent(callback));
4129
- }
4130
- catch (error) {
4131
- console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
4132
- }
4133
- try {
4134
- window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
4135
- }
4136
- catch (error) {
4137
- console.error('wallet-standard:app-ready event listener could not be added\n', error);
4138
- }
4139
- }
4140
- class RegisterWalletEvent extends Event {
4141
- get detail() {
4142
- return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
4143
- }
4144
- get type() {
4145
- return 'wallet-standard:register-wallet';
4146
- }
4147
- constructor(callback) {
4148
- super('wallet-standard:register-wallet', {
4149
- bubbles: false,
4150
- cancelable: false,
4151
- composed: false,
4152
- });
4153
- _RegisterWalletEvent_detail.set(this, void 0);
4154
- __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
4155
- }
4156
- /** @deprecated */
4157
- preventDefault() {
4158
- throw new Error('preventDefault cannot be called');
4159
- }
4160
- /** @deprecated */
4161
- stopImmediatePropagation() {
4162
- throw new Error('stopImmediatePropagation cannot be called');
4163
- }
4164
- /** @deprecated */
4165
- stopPropagation() {
4166
- throw new Error('stopPropagation cannot be called');
4167
- }
4168
- }
4169
- _RegisterWalletEvent_detail = new WeakMap();
3094
+ /** Name of the feature. */
3095
+ const StandardConnect = 'standard:connect';
4170
3096
 
4171
- //#region src/base64Utils.ts
4172
- function fromUint8Array(byteArray) {
4173
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
4174
- }
4175
- function toUint8Array(base64EncodedByteArray) {
4176
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
4177
- }
4178
- //#endregion
4179
- //#region src/embedded-modal/loadingSpinner.ts
4180
- const modalHtml$1 = `
4181
- <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
4182
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
4183
- <div class="mobile-wallet-adapter-embedded-loading-container">
4184
- <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
4185
- </div>
4186
- </div>
4187
- `;
4188
- const css$6 = `
4189
- .mobile-wallet-adapter-embedded-loading-indicator {
4190
- display: flex; /* Use flexbox to center content */
4191
- justify-content: center; /* Center horizontally */
4192
- align-items: start; /* Center vertically */
4193
- position: fixed; /* Stay in place */
4194
- z-index: 1; /* Sit on top */
4195
- left: 0;
4196
- top: 0;
4197
- width: 100%; /* Full width */
4198
- height: 100%; /* Full height */
4199
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
4200
- overflow-y: auto; /* enable scrolling */
4201
- }
3097
+ /** Name of the feature. */
3098
+ const StandardDisconnect = 'standard:disconnect';
4202
3099
 
4203
- .mobile-wallet-adapter-embedded-loading-container {
4204
- display: flex;
4205
- margin: auto;
4206
- }
3100
+ /** Name of the feature. */
3101
+ const StandardEvents = 'standard:events';
4207
3102
 
4208
- .mobile-wallet-adapter-embedded-loading-animation {
4209
- position: relative;
4210
- left: -9999px;
4211
- width: 10px;
4212
- height: 10px;
4213
- border-radius: 5px;
4214
- background-color: var(--spinner-color);
4215
- color: var(--spinner-color);
4216
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4217
- 9999px 0 0 0 var(--spinner-color),
4218
- 10014px 0 0 0 var(--spinner-color);
4219
- animation: dot-typing 1.5s infinite linear;
4220
- }
3103
+ /** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
3104
+ const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
4221
3105
 
4222
- @keyframes dot-typing {
4223
- 0% {
4224
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4225
- 9999px 0 0 0 var(--spinner-color),
4226
- 10014px 0 0 0 var(--spinner-color);
4227
- }
4228
- 16.667% {
4229
- box-shadow: 9984px -10px 0 0 var(--spinner-color),
4230
- 9999px 0 0 0 var(--spinner-color),
4231
- 10014px 0 0 0 var(--spinner-color);
4232
- }
4233
- 33.333% {
4234
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4235
- 9999px 0 0 0 var(--spinner-color),
4236
- 10014px 0 0 0 var(--spinner-color);
4237
- }
4238
- 50% {
4239
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4240
- 9999px -10px 0 0 var(--spinner-color),
4241
- 10014px 0 0 0 var(--spinner-color);
4242
- }
4243
- 66.667% {
4244
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4245
- 9999px 0 0 0 var(--spinner-color),
4246
- 10014px 0 0 0 var(--spinner-color);
4247
- }
4248
- 83.333% {
4249
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4250
- 9999px 0 0 0 var(--spinner-color),
4251
- 10014px -10px 0 0 var(--spinner-color);
4252
- }
4253
- 100% {
4254
- box-shadow: 9984px 0 0 0 var(--spinner-color),
4255
- 9999px 0 0 0 var(--spinner-color),
4256
- 10014px 0 0 0 var(--spinner-color);
4257
- }
3106
+ /******************************************************************************
3107
+ Copyright (c) Microsoft Corporation.
3108
+
3109
+ Permission to use, copy, modify, and/or distribute this software for any
3110
+ purpose with or without fee is hereby granted.
3111
+
3112
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3113
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3114
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3115
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3116
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3117
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3118
+ PERFORMANCE OF THIS SOFTWARE.
3119
+ ***************************************************************************** */
3120
+
3121
+ function __awaiter(thisArg, _arguments, P, generator) {
3122
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3123
+ return new (P || (P = Promise))(function (resolve, reject) {
3124
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3125
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3126
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3127
+ step((generator = generator.apply(thisArg, [])).next());
3128
+ });
3129
+ }
3130
+
3131
+ function __classPrivateFieldGet$1(receiver, state, kind, f) {
3132
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3133
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3134
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3135
+ }
3136
+
3137
+ function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
3138
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3139
+ return (state.set(receiver, value)), value;
4258
3140
  }
4259
- `;
4260
- var EmbeddedLoadingSpinner = class {
4261
- #root = null;
4262
- #eventListeners = {};
4263
- #listenersAttached = false;
4264
- dom = null;
4265
- constructor() {
4266
- this.init = this.init.bind(this);
4267
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
4268
- }
4269
- async init() {
4270
- console.log("Injecting modal");
4271
- this.#injectHTML();
4272
- }
4273
- open = () => {
4274
- console.debug("Modal open");
4275
- this.#attachEventListeners();
4276
- if (this.#root) this.#root.style.display = "flex";
4277
- };
4278
- close = (event = void 0) => {
4279
- console.debug("Modal close");
4280
- this.#removeEventListeners();
4281
- if (this.#root) this.#root.style.display = "none";
4282
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
4283
- };
4284
- addEventListener(event, listener) {
4285
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
4286
- return () => this.removeEventListener(event, listener);
4287
- }
4288
- removeEventListener(event, listener) {
4289
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
4290
- }
4291
- #injectHTML() {
4292
- if (this.dom) return;
4293
- this.#root = document.createElement("div");
4294
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
4295
- this.#root.innerHTML = modalHtml$1;
4296
- this.#root.style.display = "none";
4297
- const styles = document.createElement("style");
4298
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
4299
- styles.textContent = css$6;
4300
- const host = document.createElement("div");
4301
- this.dom = host.attachShadow({ mode: "closed" });
4302
- host.style.setProperty("--spinner-color", "#FFFFFF");
4303
- this.dom.appendChild(styles);
4304
- this.dom.appendChild(this.#root);
4305
- document.body.appendChild(host);
4306
- }
4307
- #attachEventListeners() {
4308
- if (!this.#root || this.#listenersAttached) return;
4309
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
4310
- this.close(event);
4311
- }));
4312
- window.addEventListener("load", this.close);
4313
- document.addEventListener("keydown", this.#handleKeyDown);
4314
- this.#listenersAttached = true;
4315
- }
4316
- #removeEventListeners() {
4317
- if (!this.#listenersAttached) return;
4318
- window.removeEventListener("load", this.close);
4319
- document.removeEventListener("keydown", this.#handleKeyDown);
4320
- if (!this.#root) return;
4321
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
4322
- this.#listenersAttached = false;
4323
- }
4324
- #handleKeyDown = (event) => {
4325
- if (event.key === "Escape") this.close(event);
4326
- };
4327
- };
4328
- //#endregion
4329
- //#region src/embedded-modal/modal.ts
3141
+
3142
+ var _EmbeddedModal_instances, _EmbeddedModal_root, _EmbeddedModal_eventListeners, _EmbeddedModal_listenersAttached, _EmbeddedModal_injectHTML, _EmbeddedModal_attachEventListeners, _EmbeddedModal_removeEventListeners, _EmbeddedModal_handleKeyDown;
4330
3143
  const modalHtml = `
4331
3144
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
4332
3145
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
@@ -4342,13 +3155,13 @@ const modalHtml = `
4342
3155
  </div>
4343
3156
  </div>
4344
3157
  `;
4345
- const css$5 = `
3158
+ const css$2 = `
4346
3159
  .mobile-wallet-adapter-embedded-modal-container {
4347
3160
  display: flex; /* Use flexbox to center content */
4348
3161
  justify-content: center; /* Center horizontally */
4349
3162
  align-items: center; /* Center vertically */
4350
3163
  position: fixed; /* Stay in place */
4351
- z-index: 2147483647; /* Sit on top */
3164
+ z-index: 1; /* Sit on top */
4352
3165
  left: 0;
4353
3166
  top: 0;
4354
3167
  width: 100%; /* Full width */
@@ -4404,100 +3217,134 @@ const fonts = `
4404
3217
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
4405
3218
  <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
4406
3219
  `;
4407
- var EmbeddedModal = class {
4408
- #root = null;
4409
- #eventListeners = {};
4410
- #listenersAttached = false;
4411
- dom = null;
4412
- constructor() {
4413
- this.init = this.init.bind(this);
4414
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
4415
- }
4416
- async init() {
4417
- console.log("Injecting modal");
4418
- this.#injectHTML();
4419
- }
4420
- open = () => {
4421
- console.debug("Modal open");
4422
- this.#attachEventListeners();
4423
- if (this.#root) this.#root.style.display = "flex";
4424
- };
4425
- close = (event = void 0) => {
4426
- console.debug("Modal close");
4427
- this.#removeEventListeners();
4428
- if (this.#root) this.#root.style.display = "none";
4429
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
4430
- };
4431
- addEventListener(event, listener) {
4432
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
4433
- return () => this.removeEventListener(event, listener);
4434
- }
4435
- removeEventListener(event, listener) {
4436
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
4437
- }
4438
- #injectHTML() {
4439
- if (document.getElementById("mobile-wallet-adapter-embedded-root-ui")) {
4440
- if (!this.#root) this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
4441
- return;
4442
- }
4443
- this.#root = document.createElement("div");
4444
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
4445
- this.#root.innerHTML = modalHtml;
4446
- this.#root.style.display = "none";
4447
- const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
4448
- if (content) content.innerHTML = this.contentHtml;
4449
- const styles = document.createElement("style");
4450
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
4451
- styles.textContent = css$5 + this.contentStyles;
4452
- const host = document.createElement("div");
4453
- host.innerHTML = fonts;
4454
- this.dom = host.attachShadow({ mode: "closed" });
4455
- this.dom.appendChild(styles);
4456
- this.dom.appendChild(this.#root);
4457
- document.body.appendChild(host);
4458
- }
4459
- #attachEventListeners() {
4460
- if (!this.#root || this.#listenersAttached) return;
4461
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", this.close));
4462
- window.addEventListener("load", this.close);
4463
- document.addEventListener("keydown", this.#handleKeyDown);
4464
- this.#listenersAttached = true;
4465
- }
4466
- #removeEventListeners() {
4467
- if (!this.#listenersAttached) return;
4468
- window.removeEventListener("load", this.close);
4469
- document.removeEventListener("keydown", this.#handleKeyDown);
4470
- if (!this.#root) return;
4471
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
4472
- this.#listenersAttached = false;
4473
- }
4474
- #handleKeyDown = (event) => {
4475
- if (event.key === "Escape") this.close(event);
4476
- };
4477
- };
4478
- //#endregion
4479
- //#region src/embedded-modal/remoteConnectionModal.ts
4480
- var RemoteConnectionModal = class extends EmbeddedModal {
4481
- contentStyles = css$4;
4482
- contentHtml = QRCodeHtml;
4483
- async initWithQR(qrCode) {
4484
- super.init();
4485
- this.populateQRCode(qrCode);
4486
- }
4487
- async populateQRCode(qrUrl) {
4488
- const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
4489
- if (qrcodeContainer) {
4490
- const qrCodeElement = await QRCode.toCanvas(qrUrl, {
4491
- width: 200,
4492
- margin: 0
4493
- });
4494
- if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
4495
- else qrcodeContainer.appendChild(qrCodeElement);
4496
- const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
4497
- if (qrPlaceholder) qrPlaceholder.style.display = "none";
4498
- } else console.error("QRCode Container not found");
4499
- }
3220
+ class EmbeddedModal {
3221
+ constructor() {
3222
+ _EmbeddedModal_instances.add(this);
3223
+ _EmbeddedModal_root.set(this, null);
3224
+ _EmbeddedModal_eventListeners.set(this, {});
3225
+ _EmbeddedModal_listenersAttached.set(this, false);
3226
+ this.dom = null;
3227
+ this.open = () => {
3228
+ console.debug('Modal open');
3229
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_attachEventListeners).call(this);
3230
+ if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3231
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'flex';
3232
+ }
3233
+ };
3234
+ this.close = (event = undefined) => {
3235
+ var _a;
3236
+ console.debug('Modal close');
3237
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_removeEventListeners).call(this);
3238
+ if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3239
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3240
+ }
3241
+ (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")['close']) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
3242
+ };
3243
+ _EmbeddedModal_handleKeyDown.set(this, (event) => {
3244
+ if (event.key === 'Escape')
3245
+ this.close(event);
3246
+ });
3247
+ // Bind methods to ensure `this` context is correct
3248
+ this.init = this.init.bind(this);
3249
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3250
+ }
3251
+ init() {
3252
+ return __awaiter(this, void 0, void 0, function* () {
3253
+ console.log('Injecting modal');
3254
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_injectHTML).call(this);
3255
+ });
3256
+ }
3257
+ addEventListener(event, listener) {
3258
+ var _a;
3259
+ ((_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = [listener]);
3260
+ return () => this.removeEventListener(event, listener);
3261
+ }
3262
+ removeEventListener(event, listener) {
3263
+ var _a;
3264
+ __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
3265
+ }
3266
+ }
3267
+ _EmbeddedModal_root = new WeakMap(), _EmbeddedModal_eventListeners = new WeakMap(), _EmbeddedModal_listenersAttached = new WeakMap(), _EmbeddedModal_handleKeyDown = new WeakMap(), _EmbeddedModal_instances = new WeakSet(), _EmbeddedModal_injectHTML = function _EmbeddedModal_injectHTML() {
3268
+ // Check if the HTML has already been injected
3269
+ if (document.getElementById('mobile-wallet-adapter-embedded-root-ui')) {
3270
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3271
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3272
+ return;
3273
+ }
3274
+ // Create a container for the modal
3275
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.createElement('div'));
3276
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").id = 'mobile-wallet-adapter-embedded-root-ui';
3277
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").innerHTML = modalHtml;
3278
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3279
+ // Add modal content
3280
+ const content = __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelector('.mobile-wallet-adapter-embedded-modal-content');
3281
+ if (content)
3282
+ content.innerHTML = this.contentHtml;
3283
+ // Apply styles
3284
+ const styles = document.createElement('style');
3285
+ styles.id = 'mobile-wallet-adapter-embedded-modal-styles';
3286
+ styles.textContent = css$2 + this.contentStyles;
3287
+ // Create a shadow DOM to encapsulate the modal
3288
+ const host = document.createElement('div');
3289
+ host.innerHTML = fonts;
3290
+ this.dom = host.attachShadow({ mode: 'closed' });
3291
+ this.dom.appendChild(styles);
3292
+ this.dom.appendChild(__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"));
3293
+ // Append the shadow DOM host to the body
3294
+ document.body.appendChild(host);
3295
+ }, _EmbeddedModal_attachEventListeners = function _EmbeddedModal_attachEventListeners() {
3296
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f") || __classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3297
+ return;
3298
+ const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3299
+ closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.addEventListener('click', this.close));
3300
+ window.addEventListener('load', this.close);
3301
+ document.addEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3302
+ __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, true);
3303
+ }, _EmbeddedModal_removeEventListeners = function _EmbeddedModal_removeEventListeners() {
3304
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3305
+ return;
3306
+ window.removeEventListener('load', this.close);
3307
+ document.removeEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3308
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3309
+ return;
3310
+ const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3311
+ closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.removeEventListener('click', this.close));
3312
+ __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, false);
4500
3313
  };
3314
+
3315
+ class RemoteConnectionModal extends EmbeddedModal {
3316
+ constructor() {
3317
+ super(...arguments);
3318
+ this.contentStyles = css$1;
3319
+ this.contentHtml = QRCodeHtml;
3320
+ }
3321
+ initWithQR(qrCode) {
3322
+ const _super = Object.create(null, {
3323
+ init: { get: () => super.init }
3324
+ });
3325
+ return __awaiter(this, void 0, void 0, function* () {
3326
+ _super.init.call(this);
3327
+ this.populateQRCode(qrCode);
3328
+ });
3329
+ }
3330
+ populateQRCode(qrUrl) {
3331
+ var _a;
3332
+ return __awaiter(this, void 0, void 0, function* () {
3333
+ const qrcodeContainer = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-embedded-modal-qr-code-container');
3334
+ if (qrcodeContainer) {
3335
+ const qrCodeElement = yield QRCode.toCanvas(qrUrl, { width: 200, margin: 0 });
3336
+ if (qrcodeContainer.firstElementChild !== null) {
3337
+ qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3338
+ }
3339
+ else
3340
+ qrcodeContainer.appendChild(qrCodeElement);
3341
+ }
3342
+ else {
3343
+ console.error('QRCode Container not found');
3344
+ }
3345
+ });
3346
+ }
3347
+ }
4501
3348
  const QRCodeHtml = `
4502
3349
  <div class="mobile-wallet-adapter-embedded-modal-qr-content">
4503
3350
  <div>
@@ -4513,9 +3360,7 @@ const QRCodeHtml = `
4513
3360
  Open your wallet and scan this code
4514
3361
  </h4>
4515
3362
  </div>
4516
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
4517
- <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
4518
- </div>
3363
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
4519
3364
  </div>
4520
3365
  </div>
4521
3366
  <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
@@ -4542,7 +3387,7 @@ const QRCodeHtml = `
4542
3387
  </div>
4543
3388
  </div>
4544
3389
  `;
4545
- const css$4 = `
3390
+ const css$1 = `
4546
3391
  .mobile-wallet-adapter-embedded-modal-qr-content {
4547
3392
  display: flex;
4548
3393
  margin-top: 10px;
@@ -4586,16 +3431,6 @@ const css$4 = `
4586
3431
  margin-left: auto;
4587
3432
  }
4588
3433
 
4589
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
4590
- margin-left: auto;
4591
- min-width: 200px;
4592
- min-height: 200px;
4593
- background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
4594
- background-size: 200%;
4595
- animation: placeholderAnimate 2.7s linear infinite;
4596
- border-radius: 12px;
4597
- }
4598
-
4599
3434
  .mobile-wallet-adapter-embedded-modal-divider {
4600
3435
  margin-top: 20px;
4601
3436
  padding-left: 10px;
@@ -4668,15 +3503,6 @@ const css$4 = `
4668
3503
  .mobile-wallet-adapter-embedded-modal-qr-code-container {
4669
3504
  margin: auto;
4670
3505
  }
4671
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
4672
- margin: auto;
4673
- }
4674
- }
4675
-
4676
- /* QR Placeholder */
4677
- @keyframes placeholderAnimate {
4678
- 0% { background-position: 200% 0; }
4679
- 100% { background-position: -200% 0; }
4680
3506
  }
4681
3507
 
4682
3508
  /* Spinner */
@@ -4757,1173 +3583,962 @@ const css$4 = `
4757
3583
  animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
4758
3584
  }
4759
3585
  `;
4760
- //#endregion
4761
- //#region src/embedded-modal/localConnectionModal.ts
4762
- var LocalConnectionModal = class extends EmbeddedModal {
4763
- contentStyles = css$3;
4764
- contentHtml = ErrorDialogHtml$3;
4765
- initWithCallback(callback) {
4766
- super.init();
4767
- this.#prepareLaunchAction(callback);
4768
- }
4769
- #prepareLaunchAction(callback) {
4770
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4771
- const listener = async () => {
4772
- launchButton?.removeEventListener("click", listener);
4773
- this.close();
4774
- callback();
4775
- };
4776
- launchButton?.addEventListener("click", listener);
4777
- }
4778
- };
4779
- const ErrorDialogHtml$3 = `
4780
- <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">
4781
- <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"/>
4782
- <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4783
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4784
- </mask>
4785
- <g mask="url(#mask0_189_522)">
4786
- <mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4787
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4788
- </mask>
4789
- <g mask="url(#mask1_189_522)">
4790
- <path d="M22.1092 26.1208L19.4498 23.4615C19.1736 23.1851 18.8253 23.0468 18.4048 23.0468C17.9846 23.0468 17.6363 23.1851 17.3598 23.4615C17.0836 23.7377 16.9468 24.0861 16.9495 24.5065C16.9522 24.9267 17.0916 25.275 17.3678 25.5512L21.0405 29.2238C21.3463 29.5276 21.7031 29.6795 22.1108 29.6795C22.5184 29.6795 22.8742 29.5276 23.1782 29.2238L30.5918 21.8098C30.8683 21.5336 31.0065 21.1867 31.0065 20.7692C31.0065 20.3514 30.8683 20.0044 30.5918 19.7282C30.3156 19.4517 29.9673 19.3135 29.5468 19.3135C29.1266 19.3135 28.7784 19.4517 28.5022 19.7282L22.1092 26.1208ZM23.9998 37.6042C22.113 37.6042 20.3425 37.2473 18.6885 36.5335C17.0343 35.8197 15.5954 34.8512 14.3718 33.6278C13.1485 32.4043 12.18 30.9654 11.4662 29.3112C10.7524 27.6572 10.3955 25.8867 10.3955 23.9998C10.3955 22.113 10.7524 20.3425 11.4662 18.6885C12.18 17.0343 13.1485 15.5954 14.3718 14.3718C15.5954 13.1485 17.0343 12.18 18.6885 11.4662C20.3425 10.7524 22.113 10.3955 23.9998 10.3955C25.8867 10.3955 27.6572 10.7524 29.3112 11.4662C30.9654 12.18 32.4043 13.1485 33.6278 14.3718C34.8512 15.5954 35.8197 17.0343 36.5335 18.6885C37.2473 20.3425 37.6042 22.113 37.6042 23.9998C37.6042 25.8867 37.2473 27.6572 36.5335 29.3112C35.8197 30.9654 34.8512 32.4043 33.6278 33.6278C32.4043 34.8512 30.9654 35.8197 29.3112 36.5335C27.6572 37.2473 25.8867 37.6042 23.9998 37.6042Z" fill="white"/>
4791
- </g>
4792
- </g>
4793
- </svg>
4794
- <div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
4795
- <div>
4796
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4797
- Connect Wallet
4798
- </button>
4799
- </div>
4800
- `;
4801
- const css$3 = `
4802
- .mobile-wallet-adapter-embedded-modal-close {
4803
- display: none;
4804
- }
4805
- .mobile-wallet-adapter-embedded-modal-content {
4806
- text-align: center;
4807
- min-width: 300px;
4808
- }
4809
- .mobile-wallet-adapter-embedded-modal-launch-icon {
4810
- margin-top: 24px;
4811
- }
4812
- .mobile-wallet-adapter-embedded-modal-title {
4813
- margin: 18px 100px 30px 100px;
4814
- color: #000000;
4815
- font-size: 2.75em;
4816
- font-weight: 600;
3586
+
3587
+ const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
3588
+
3589
+ function fromUint8Array(byteArray) {
3590
+ return window.btoa(String.fromCharCode.call(null, ...byteArray));
4817
3591
  }
4818
- .mobile-wallet-adapter-embedded-modal-launch-action {
4819
- display: block;
4820
- width: 100%;
4821
- height: 56px;
4822
- font-size: 1.25em;
4823
- background: #000000;
4824
- color: #FFFFFF;
4825
- border-radius: 18px;
3592
+ function toUint8Array(base64EncodedByteArray) {
3593
+ return new Uint8Array(window
3594
+ .atob(base64EncodedByteArray)
3595
+ .split('')
3596
+ .map((c) => c.charCodeAt(0)));
4826
3597
  }
4827
- /* Smaller screens */
4828
- @media all and (max-width: 600px) {
4829
- .mobile-wallet-adapter-embedded-modal-title {
4830
- font-size: 1.5em;
4831
- margin-right: 12px;
4832
- margin-left: 12px;
3598
+
3599
+ var _LocalSolanaMobileWalletAdapterWallet_instances, _LocalSolanaMobileWalletAdapterWallet_listeners, _LocalSolanaMobileWalletAdapterWallet_version, _LocalSolanaMobileWalletAdapterWallet_name, _LocalSolanaMobileWalletAdapterWallet_url, _LocalSolanaMobileWalletAdapterWallet_icon, _LocalSolanaMobileWalletAdapterWallet_appIdentity, _LocalSolanaMobileWalletAdapterWallet_authorization, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, _LocalSolanaMobileWalletAdapterWallet_connecting, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, _LocalSolanaMobileWalletAdapterWallet_chains, _LocalSolanaMobileWalletAdapterWallet_chainSelector, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, _LocalSolanaMobileWalletAdapterWallet_on, _LocalSolanaMobileWalletAdapterWallet_emit, _LocalSolanaMobileWalletAdapterWallet_off, _LocalSolanaMobileWalletAdapterWallet_connect, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, _LocalSolanaMobileWalletAdapterWallet_disconnect, _LocalSolanaMobileWalletAdapterWallet_transact, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signTransaction, _LocalSolanaMobileWalletAdapterWallet_signMessage, _LocalSolanaMobileWalletAdapterWallet_signIn, _LocalSolanaMobileWalletAdapterWallet_performSignIn, _RemoteSolanaMobileWalletAdapterWallet_instances, _RemoteSolanaMobileWalletAdapterWallet_listeners, _RemoteSolanaMobileWalletAdapterWallet_version, _RemoteSolanaMobileWalletAdapterWallet_name, _RemoteSolanaMobileWalletAdapterWallet_url, _RemoteSolanaMobileWalletAdapterWallet_icon, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, _RemoteSolanaMobileWalletAdapterWallet_authorization, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, _RemoteSolanaMobileWalletAdapterWallet_connecting, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, _RemoteSolanaMobileWalletAdapterWallet_chains, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, _RemoteSolanaMobileWalletAdapterWallet_session, _RemoteSolanaMobileWalletAdapterWallet_on, _RemoteSolanaMobileWalletAdapterWallet_emit, _RemoteSolanaMobileWalletAdapterWallet_off, _RemoteSolanaMobileWalletAdapterWallet_connect, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, _RemoteSolanaMobileWalletAdapterWallet_disconnect, _RemoteSolanaMobileWalletAdapterWallet_transact, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, _RemoteSolanaMobileWalletAdapterWallet_signMessage, _RemoteSolanaMobileWalletAdapterWallet_signIn, _RemoteSolanaMobileWalletAdapterWallet_performSignIn;
3600
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
3601
+ const SolanaMobileWalletAdapterRemoteWalletName = 'Remote Mobile Wallet Adapter';
3602
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
3603
+ const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
3604
+ class LocalSolanaMobileWalletAdapterWallet {
3605
+ constructor(config) {
3606
+ _LocalSolanaMobileWalletAdapterWallet_instances.add(this);
3607
+ _LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3608
+ _LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3609
+ _LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
3610
+ _LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3611
+ _LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3612
+ _LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
3613
+ _LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
3614
+ _LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
3615
+ _LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
3616
+ /**
3617
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
3618
+ * increment this and use it to make sure that `transact` calls from the previous
3619
+ * 'generation' don't continue to do work and throw exceptions.
3620
+ */
3621
+ _LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
3622
+ _LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
3623
+ _LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
3624
+ _LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
3625
+ _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
3626
+ _LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
3627
+ var _a;
3628
+ ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
3629
+ return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
3630
+ });
3631
+ _LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
3632
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
3633
+ return { accounts: this.accounts };
3634
+ }
3635
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3636
+ try {
3637
+ if (silent) {
3638
+ const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3639
+ if (cachedAuthorization) {
3640
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
3641
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
3642
+ }
3643
+ else {
3644
+ return { accounts: this.accounts };
3645
+ }
3646
+ }
3647
+ else {
3648
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
3649
+ }
3650
+ }
3651
+ catch (e) {
3652
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3653
+ }
3654
+ finally {
3655
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3656
+ }
3657
+ return { accounts: this.accounts };
3658
+ }));
3659
+ _LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
3660
+ try {
3661
+ const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3662
+ if (cachedAuthorizationResult) {
3663
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3664
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
3665
+ return cachedAuthorizationResult;
3666
+ }
3667
+ const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
3668
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3669
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3670
+ wallet.getCapabilities(),
3671
+ wallet.authorize({
3672
+ chain: selectedChain,
3673
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3674
+ sign_in_payload: signInPayload,
3675
+ })
3676
+ ]);
3677
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3678
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
3679
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3680
+ Promise.all([
3681
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
3682
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3683
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3684
+ ]);
3685
+ return authorization;
3686
+ }));
3687
+ }
3688
+ catch (e) {
3689
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3690
+ }
3691
+ }));
3692
+ _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
3693
+ var _a;
3694
+ const didPublicKeysChange =
3695
+ // Case 1: We started from having no authorization.
3696
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
3697
+ // Case 2: The number of authorized accounts changed.
3698
+ ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
3699
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
3700
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
3701
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
3702
+ if (didPublicKeysChange) {
3703
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3704
+ }
3705
+ }));
3706
+ _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
3707
+ // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
3708
+ const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
3709
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
3710
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
3711
+ SolanaSignTransaction in this.features !== supportsSignTransaction;
3712
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
3713
+ [SolanaSignAndSendTransaction]: {
3714
+ version: '1.0.0',
3715
+ supportedTransactionVersions: ['legacy', 0],
3716
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3717
+ },
3718
+ })), (supportsSignTransaction && {
3719
+ [SolanaSignTransaction]: {
3720
+ version: '1.0.0',
3721
+ supportedTransactionVersions: ['legacy', 0],
3722
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3723
+ },
3724
+ })));
3725
+ if (didCapabilitiesChange) {
3726
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
3727
+ }
3728
+ }));
3729
+ _LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
3730
+ var _b, _c;
3731
+ try {
3732
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3733
+ (_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
3734
+ wallet.authorize({
3735
+ auth_token: authToken,
3736
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3737
+ chain: chain
3738
+ })
3739
+ ]);
3740
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3741
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
3742
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3743
+ Promise.all([
3744
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3745
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3746
+ ]);
3747
+ }
3748
+ catch (e) {
3749
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
3750
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3751
+ }
3752
+ }));
3753
+ _LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
3754
+ var _d;
3755
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3756
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3757
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
3758
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
3759
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3760
+ }));
3761
+ _LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
3762
+ var _e;
3763
+ const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
3764
+ const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
3765
+ const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
3766
+ try {
3767
+ return yield mobileWalletAdapterProtocol.transact(callback, config);
3768
+ }
3769
+ catch (e) {
3770
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
3771
+ yield new Promise(() => { }); // Never resolve.
3772
+ }
3773
+ if (e instanceof Error &&
3774
+ e.name === 'SolanaMobileWalletAdapterError' &&
3775
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
3776
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
3777
+ }
3778
+ throw e;
3779
+ }
3780
+ }));
3781
+ _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
3782
+ if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
3783
+ throw new Error('Wallet not connected');
3784
+ return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
3785
+ });
3786
+ _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
3787
+ return accounts.map((account) => {
3788
+ var _a, _b;
3789
+ const publicKey = toUint8Array(account.address);
3790
+ return {
3791
+ address: index.base58.encode(publicKey),
3792
+ publicKey,
3793
+ label: account.label,
3794
+ icon: account.icon,
3795
+ chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
3796
+ // TODO: get supported features from getCapabilities API
3797
+ features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
3798
+ };
3799
+ });
3800
+ });
3801
+ _LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
3802
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3803
+ try {
3804
+ const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
3805
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3806
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3807
+ const signedTransactions = (yield wallet.signTransactions({
3808
+ payloads: base64Transactions,
3809
+ })).signed_payloads.map(toUint8Array);
3810
+ return signedTransactions;
3811
+ }));
3812
+ }
3813
+ catch (e) {
3814
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3815
+ }
3816
+ }));
3817
+ _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
3818
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3819
+ try {
3820
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3821
+ const [capabilities, _1] = yield Promise.all([
3822
+ wallet.getCapabilities(),
3823
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
3824
+ ]);
3825
+ if (capabilities.supports_sign_and_send_transactions) {
3826
+ const base64Transaction = fromUint8Array(transaction);
3827
+ const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
3828
+ return signatures[0];
3829
+ }
3830
+ else {
3831
+ throw new Error('connected wallet does not support signAndSendTransaction');
3832
+ }
3833
+ }));
3834
+ }
3835
+ catch (e) {
3836
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3837
+ }
3838
+ }));
3839
+ _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3840
+ const outputs = [];
3841
+ for (const input of inputs) {
3842
+ const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
3843
+ outputs.push({ signature });
3844
+ }
3845
+ return outputs;
3846
+ }));
3847
+ _LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3848
+ return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
3849
+ .map((signedTransaction) => {
3850
+ return { signedTransaction };
3851
+ });
3852
+ }));
3853
+ _LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3854
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3855
+ const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
3856
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
3857
+ try {
3858
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3859
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3860
+ const signedMessages = (yield wallet.signMessages({
3861
+ addresses: addresses,
3862
+ payloads: messages,
3863
+ })).signed_payloads.map(toUint8Array);
3864
+ return signedMessages.map((signedMessage) => {
3865
+ return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
3866
+ });
3867
+ }));
3868
+ }
3869
+ catch (e) {
3870
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3871
+ }
3872
+ }));
3873
+ _LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3874
+ const outputs = [];
3875
+ if (inputs.length > 1) {
3876
+ for (const input of inputs) {
3877
+ outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
3878
+ }
3879
+ }
3880
+ else {
3881
+ return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
3882
+ }
3883
+ return outputs;
3884
+ }));
3885
+ _LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
3886
+ var _f, _g, _h;
3887
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3888
+ try {
3889
+ const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_f = input === null || input === void 0 ? void 0 : input.domain) !== null && _f !== void 0 ? _f : window.location.host }));
3890
+ if (!authorizationResult.sign_in_result) {
3891
+ throw new Error("Sign in failed, no sign in result returned by wallet");
3892
+ }
3893
+ const signedInAddress = authorizationResult.sign_in_result.address;
3894
+ const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
3895
+ return {
3896
+ account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
3897
+ address: index.base58.encode(toUint8Array(signedInAddress))
3898
+ }), { publicKey: toUint8Array(signedInAddress), chains: (_g = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _g !== void 0 ? _g : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"), features: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _h !== void 0 ? _h : authorizationResult.capabilities.features }),
3899
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
3900
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
3901
+ };
3902
+ }
3903
+ catch (e) {
3904
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3905
+ }
3906
+ finally {
3907
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3908
+ }
3909
+ }));
3910
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
3911
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
3912
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
3913
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
3914
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
3915
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
3916
+ // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
3917
+ // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
3918
+ // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
3919
+ // assume both are supported here. The features will be updated based on the actual connected
3920
+ // wallets capabilities during connection regardless, so this is safe.
3921
+ [SolanaSignAndSendTransaction]: {
3922
+ version: '1.0.0',
3923
+ supportedTransactionVersions: ['legacy', 0],
3924
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3925
+ },
3926
+ [SolanaSignTransaction]: {
3927
+ version: '1.0.0',
3928
+ supportedTransactionVersions: ['legacy', 0],
3929
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3930
+ },
3931
+ });
3932
+ }
3933
+ get version() {
3934
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
3935
+ }
3936
+ get name() {
3937
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
3938
+ }
3939
+ get url() {
3940
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
3941
+ }
3942
+ get icon() {
3943
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
3944
+ }
3945
+ get chains() {
3946
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
3947
+ }
3948
+ get features() {
3949
+ return Object.assign({ [StandardConnect]: {
3950
+ version: '1.0.0',
3951
+ connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
3952
+ }, [StandardDisconnect]: {
3953
+ version: '1.0.0',
3954
+ disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
3955
+ }, [StandardEvents]: {
3956
+ version: '1.0.0',
3957
+ on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
3958
+ }, [SolanaSignMessage]: {
3959
+ version: '1.0.0',
3960
+ signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
3961
+ }, [SolanaSignIn]: {
3962
+ version: '1.0.0',
3963
+ signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
3964
+ } }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
3965
+ }
3966
+ get accounts() {
3967
+ var _a, _b;
3968
+ return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
3969
+ }
3970
+ get connected() {
3971
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
3972
+ }
3973
+ get isAuthorized() {
3974
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
3975
+ }
3976
+ get currentAuthorization() {
3977
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
3978
+ }
3979
+ get cachedAuthorizationResult() {
3980
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4833
3981
  }
4834
3982
  }
4835
- `;
4836
- //#endregion
4837
- //#region src/embedded-modal/loopbackBlockedModal.ts
4838
- var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
4839
- contentStyles = css$2;
4840
- get contentHtml() {
4841
- 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";
4842
- return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
4843
- }
4844
- async init() {
4845
- super.init();
4846
- this.#prepareLaunchAction();
4847
- }
4848
- #prepareLaunchAction() {
4849
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4850
- const listener = async (event) => {
4851
- launchButton?.removeEventListener("click", listener);
4852
- this.close(event);
4853
- };
4854
- launchButton?.addEventListener("click", listener);
4855
- }
3983
+ _LocalSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_version = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_name = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_url = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_on = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _LocalSolanaMobileWalletAdapterWallet_emit = function _LocalSolanaMobileWalletAdapterWallet_emit(event, ...args) {
3984
+ var _a;
3985
+ // eslint-disable-next-line prefer-spread
3986
+ (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
3987
+ }, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
3988
+ var _a;
3989
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
4856
3990
  };
4857
- const ErrorDialogHtml$2 = `
4858
- <div class="mobile-wallet-adapter-embedded-modal-header">
4859
- Local Wallet Connection
4860
- </div>
4861
- <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
4862
- <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="#ED1515"/>
4863
- <mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4864
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4865
- </mask>
4866
- <g mask="url(#mask0_147_1364)">
4867
- <path d="M20.1398 36.2705C19.7363 36.2705 19.3508 36.1945 18.9835 36.0425C18.6162 35.8907 18.2916 35.674 18.0098 35.3922L12.6072 29.9895C12.3254 29.7077 12.1086 29.3832 11.9568 29.0158C11.8048 28.6485 11.7288 28.2631 11.7288 27.8595V20.1395C11.7288 19.736 11.8048 19.3505 11.9568 18.9832C12.1086 18.6158 12.3254 18.2913 12.6072 18.0095L18.0098 12.6068C18.2916 12.3251 18.6162 12.1083 18.9835 11.9565C19.3508 11.8045 19.7363 11.7285 20.1398 11.7285H27.8598C28.2634 11.7285 28.6488 11.8045 29.0162 11.9565C29.3835 12.1083 29.708 12.3251 29.9898 12.6068L35.3925 18.0095C35.6743 18.2913 35.891 18.6158 36.0428 18.9832C36.1948 19.3505 36.2708 19.736 36.2708 20.1395V27.8595C36.2708 28.2631 36.1948 28.6485 36.0428 29.0158C35.891 29.3832 35.6743 29.7077 35.3925 29.9895L29.9898 35.3922C29.708 35.674 29.3835 35.8907 29.0162 36.0425C28.6488 36.1945 28.2634 36.2705 27.8598 36.2705H20.1398ZM20.1732 33.2372H27.8265L33.2375 27.8262V20.1728L27.8265 14.7618H20.1732L14.7622 20.1728V27.8262L20.1732 33.2372ZM23.9998 25.9538L26.7868 28.7408C27.0473 29.0013 27.3729 29.1302 27.7638 29.1275C28.1549 29.1248 28.4807 28.9933 28.7412 28.7328C29.0016 28.4724 29.1318 28.1466 29.1318 27.7555C29.1318 27.3646 29.0016 27.039 28.7412 26.7785L25.9542 23.9995L28.7412 21.2125C29.0016 20.9521 29.1318 20.6264 29.1318 20.2355C29.1318 19.8444 29.0016 19.5186 28.7412 19.2582C28.4807 18.9977 28.1549 18.8675 27.7638 18.8675C27.3729 18.8675 27.0473 18.9977 26.7868 19.2582L23.9998 22.0452L21.2128 19.2582C20.9524 18.9977 20.628 18.8675 20.2398 18.8675C19.8514 18.8675 19.5269 18.9977 19.2665 19.2582C19.006 19.5186 18.8758 19.8444 18.8758 20.2355C18.8758 20.6264 19.006 20.9521 19.2665 21.2125L22.0455 23.9995L19.2585 26.7865C18.998 27.047 18.8692 27.3713 18.8718 27.7595C18.8745 28.148 19.006 28.4724 19.2665 28.7328C19.5269 28.9933 19.8527 29.1235 20.2438 29.1235C20.6347 29.1235 20.9604 28.9933 21.2208 28.7328L23.9998 25.9538Z" fill="black"/>
4868
- </g>
4869
- </svg>
4870
- <div class="mobile-wallet-adapter-embedded-modal-title">
4871
- Your wallet connection is blocked
4872
- </div>
4873
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4874
- Visit site settings in the address bar and allow "Apps on Device".
4875
- </div>
4876
-
4877
- <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
4878
- <div class="mobile-wallet-adapter-embedded-modal-footer">
4879
- <div class="mobile-wallet-adapter-embedded-modal-details">
4880
- <!-- Clickable header (label associated with the checkbox) -->
4881
- <label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
4882
- <!-- Hidden checkbox to track state -->
4883
- <input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
4884
- <span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
4885
- See details
4886
- </span>
4887
- <svg class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4888
- <mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
4889
- <rect width="24" height="24" fill="#D9D9D9"/>
4890
- </mask>
4891
- <g mask="url(#mask0_147_1382)">
4892
- <path d="M11.9999 17.0811C11.8506 17.0811 11.7087 17.0563 11.5741 17.0067C11.4395 16.957 11.3162 16.8762 11.2042 16.7643L6.57924 12.1393C6.36801 11.9281 6.26656 11.667 6.27489 11.3561C6.28322 11.0453 6.39301 10.7842 6.60424 10.573C6.81547 10.3618 7.08069 10.2561 7.39989 10.2561C7.71909 10.2561 7.9843 10.3618 8.19554 10.573L11.9999 14.3773L15.8292 10.548C16.0405 10.3368 16.3015 10.2353 16.6124 10.2436C16.9233 10.252 17.1843 10.3618 17.3955 10.573C17.6068 10.7842 17.7124 11.0494 17.7124 11.3686C17.7124 11.6878 17.6068 11.9531 17.3955 12.1643L12.7955 16.7643C12.6836 16.8762 12.5603 16.957 12.4257 17.0067C12.2911 17.0563 12.1492 17.0811 11.9999 17.0811Z" fill="black"/>
4893
- </g>
4894
- </svg>
4895
- </label>
4896
-
4897
- <!-- Content to show/hide -->
4898
- <ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
4899
- <li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
4900
- <li>Allow "Apps on Device"</li>
4901
- </ul>
4902
- </div>
4903
- </div>
4904
- <div>
4905
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4906
- Got it
4907
- </button>
4908
- </div>
4909
- `;
4910
- const css$2 = `
4911
- .mobile-wallet-adapter-embedded-modal-close {
4912
- display: none;
4913
- }
4914
- .mobile-wallet-adapter-embedded-modal-content {
4915
- text-align: center;
4916
- }
4917
- .mobile-wallet-adapter-embedded-modal-header {
4918
- margin: 18px auto 30px auto;
4919
- color: #7D9093;
4920
- font-size: 1.0em;
4921
- font-weight: 500;
4922
- }
4923
- .mobile-wallet-adapter-embedded-modal-title {
4924
- margin: 18px 100px auto 100px;
4925
- color: #000000;
4926
- font-size: 2.75em;
4927
- font-weight: 600;
4928
- }
4929
- .mobile-wallet-adapter-embedded-modal-subtitle {
4930
- margin: 12px 60px 30px 60px;
4931
- color: #7D9093;
4932
- font-size: 1.25em;
4933
- font-weight: 400;
4934
- }
4935
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header {
4936
- display: flex;
4937
- flex-direction: row;
4938
- justify-content: space-between;
4939
- margin: 10px auto 10px auto;
4940
- color: #000000;
4941
- font-size: 1.5em;
4942
- font-weight: 600;
4943
- cursor: pointer; /* Show pointer on hover */
4944
- transition: background 0.2s ease; /* Smooth background change */
4945
- }
4946
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4947
- transition: rotate 0.3s ease;
4948
- }
4949
- .mobile-wallet-adapter-embedded-modal-details-collapsible-input {
4950
- display: none; /* Hide the checkbox */
4951
- }
4952
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4953
- margin: 0px auto 40px auto;
4954
- max-height: 0px; /* Collapse content */
4955
- overflow: hidden; /* Hide overflow when collapsed */
4956
- transition: max-height 0.3s ease; /* Smooth transition */
4957
- }
4958
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
4959
- margin: 20px auto;
4960
- color: #000000;
4961
- font-size: 1.25em;
4962
- font-weight: 400;
4963
- text-align: left;
4964
- }
4965
- /* When checkbox is checked, show content */
4966
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4967
- max-height: 300px;
4968
- }
4969
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4970
- rotate: 180deg;
4971
- }
4972
- .mobile-wallet-adapter-embedded-modal-launch-action {
4973
- display: block;
4974
- width: 100%;
4975
- height: 56px;
4976
- /*margin-top: 40px;*/
4977
- font-size: 1.25em;
4978
- /*line-height: 24px;*/
4979
- /*letter-spacing: -1%;*/
4980
- background: #000000;
4981
- color: #FFFFFF;
4982
- border-radius: 18px;
4983
- }
4984
- /* Smaller screens */
4985
- @media all and (max-width: 600px) {
4986
- .mobile-wallet-adapter-embedded-modal-title {
4987
- font-size: 1.75em;
4988
- margin-right: 12px;
4989
- margin-left: 12px;
3991
+ class RemoteSolanaMobileWalletAdapterWallet {
3992
+ constructor(config) {
3993
+ _RemoteSolanaMobileWalletAdapterWallet_instances.add(this);
3994
+ _RemoteSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3995
+ _RemoteSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3996
+ _RemoteSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterRemoteWalletName);
3997
+ _RemoteSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3998
+ _RemoteSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3999
+ _RemoteSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
4000
+ _RemoteSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
4001
+ _RemoteSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
4002
+ _RemoteSolanaMobileWalletAdapterWallet_connecting.set(this, false);
4003
+ /**
4004
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4005
+ * increment this and use it to make sure that `transact` calls from the previous
4006
+ * 'generation' don't continue to do work and throw exceptions.
4007
+ */
4008
+ _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
4009
+ _RemoteSolanaMobileWalletAdapterWallet_chains.set(this, []);
4010
+ _RemoteSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
4011
+ _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
4012
+ _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
4013
+ _RemoteSolanaMobileWalletAdapterWallet_hostAuthority.set(this, void 0);
4014
+ _RemoteSolanaMobileWalletAdapterWallet_session.set(this, void 0);
4015
+ _RemoteSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
4016
+ var _a;
4017
+ ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
4018
+ return () => __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
4019
+ });
4020
+ _RemoteSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
4021
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
4022
+ return { accounts: this.accounts };
4023
+ }
4024
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4025
+ try {
4026
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
4027
+ }
4028
+ catch (e) {
4029
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4030
+ }
4031
+ finally {
4032
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4033
+ }
4034
+ return { accounts: this.accounts };
4035
+ }));
4036
+ _RemoteSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
4037
+ try {
4038
+ const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4039
+ if (cachedAuthorizationResult) {
4040
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4041
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
4042
+ return cachedAuthorizationResult;
4043
+ }
4044
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f"))
4045
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
4046
+ const selectedChain = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"));
4047
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4048
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4049
+ wallet.getCapabilities(),
4050
+ wallet.authorize({
4051
+ chain: selectedChain,
4052
+ identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4053
+ sign_in_payload: signInPayload,
4054
+ })
4055
+ ]);
4056
+ const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4057
+ const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
4058
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4059
+ Promise.all([
4060
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
4061
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorizationResult),
4062
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorizationResult),
4063
+ ]);
4064
+ return authorizationResult;
4065
+ }));
4066
+ }
4067
+ catch (e) {
4068
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4069
+ }
4070
+ }));
4071
+ _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
4072
+ var _a;
4073
+ const didPublicKeysChange =
4074
+ // Case 1: We started from having no authorization.
4075
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
4076
+ // Case 2: The number of authorized accounts changed.
4077
+ ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
4078
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
4079
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4080
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, authorization);
4081
+ if (didPublicKeysChange) {
4082
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4083
+ }
4084
+ }));
4085
+ _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
4086
+ // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
4087
+ const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
4088
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions ||
4089
+ capabilities.features.includes('solana:signAndSendTransaction');
4090
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
4091
+ SolanaSignTransaction in this.features !== supportsSignTransaction;
4092
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, (supportsSignAndSendTransaction && {
4093
+ [SolanaSignAndSendTransaction]: {
4094
+ version: '1.0.0',
4095
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4096
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4097
+ },
4098
+ })), (supportsSignTransaction && {
4099
+ [SolanaSignTransaction]: {
4100
+ version: '1.0.0',
4101
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4102
+ signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4103
+ },
4104
+ })));
4105
+ if (didCapabilitiesChange) {
4106
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
4107
+ }
4108
+ }));
4109
+ _RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
4110
+ var _b, _c;
4111
+ try {
4112
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4113
+ (_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
4114
+ wallet.authorize({
4115
+ auth_token: authToken,
4116
+ identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4117
+ chain: chain
4118
+ })
4119
+ ]);
4120
+ const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4121
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
4122
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4123
+ Promise.all([
4124
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
4125
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
4126
+ ]);
4127
+ }
4128
+ catch (e) {
4129
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
4130
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4131
+ }
4132
+ }));
4133
+ _RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
4134
+ var _d;
4135
+ var _e;
4136
+ (_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
4137
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4138
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4139
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e));
4140
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined);
4141
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined);
4142
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4143
+ }));
4144
+ _RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
4145
+ var _f;
4146
+ const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
4147
+ const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
4148
+ const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
4149
+ const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
4150
+ const modal = new RemoteConnectionModal();
4151
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) {
4152
+ return callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4153
+ }
4154
+ try {
4155
+ const { associationUrl, close, wallet } = yield mobileWalletAdapterProtocol.startRemoteScenario(remoteConfig);
4156
+ const removeCloseListener = modal.addEventListener('close', (event) => {
4157
+ if (event)
4158
+ close();
4159
+ });
4160
+ modal.initWithQR(associationUrl.toString());
4161
+ modal.open();
4162
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, { close, wallet: yield wallet }, "f");
4163
+ removeCloseListener();
4164
+ modal.close();
4165
+ return yield callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4166
+ }
4167
+ catch (e) {
4168
+ modal.close();
4169
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
4170
+ yield new Promise(() => { }); // Never resolve.
4171
+ }
4172
+ if (e instanceof Error &&
4173
+ e.name === 'SolanaMobileWalletAdapterError' &&
4174
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
4175
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
4176
+ }
4177
+ throw e;
4178
+ }
4179
+ }));
4180
+ _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
4181
+ if (!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f"))
4182
+ throw new Error('Wallet not connected');
4183
+ return { authToken: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").chain };
4184
+ });
4185
+ _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
4186
+ return accounts.map((account) => {
4187
+ var _a, _b;
4188
+ const publicKey = toUint8Array(account.address);
4189
+ return {
4190
+ address: index.base58.encode(publicKey),
4191
+ publicKey,
4192
+ label: account.label,
4193
+ icon: account.icon,
4194
+ chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"),
4195
+ // TODO: get supported features from getCapabilities API
4196
+ features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
4197
+ };
4198
+ });
4199
+ });
4200
+ _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
4201
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4202
+ try {
4203
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4204
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4205
+ const signedTransactions = (yield wallet.signTransactions({
4206
+ payloads: transactions.map(fromUint8Array),
4207
+ })).signed_payloads.map(toUint8Array);
4208
+ return signedTransactions;
4209
+ }));
4210
+ }
4211
+ catch (e) {
4212
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4213
+ }
4214
+ }));
4215
+ _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
4216
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4217
+ try {
4218
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4219
+ const [capabilities, _1] = yield Promise.all([
4220
+ wallet.getCapabilities(),
4221
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
4222
+ ]);
4223
+ if (capabilities.supports_sign_and_send_transactions) {
4224
+ const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [fromUint8Array(transaction)] }))).signatures.map(toUint8Array);
4225
+ return signatures[0];
4226
+ }
4227
+ else {
4228
+ throw new Error('connected wallet does not support signAndSendTransaction');
4229
+ }
4230
+ }));
4231
+ }
4232
+ catch (e) {
4233
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4234
+ }
4235
+ }));
4236
+ _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4237
+ const outputs = [];
4238
+ for (const input of inputs) {
4239
+ const signature = (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options));
4240
+ outputs.push({ signature });
4241
+ }
4242
+ return outputs;
4243
+ }));
4244
+ _RemoteSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4245
+ return (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
4246
+ .map((signedTransaction) => {
4247
+ return { signedTransaction };
4248
+ });
4249
+ }));
4250
+ _RemoteSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4251
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4252
+ const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4253
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4254
+ try {
4255
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4256
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4257
+ const signedMessages = (yield wallet.signMessages({
4258
+ addresses: addresses,
4259
+ payloads: messages,
4260
+ })).signed_payloads.map(toUint8Array);
4261
+ return signedMessages.map((signedMessage) => {
4262
+ return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4263
+ });
4264
+ }));
4265
+ }
4266
+ catch (e) {
4267
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4268
+ }
4269
+ }));
4270
+ _RemoteSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4271
+ const outputs = [];
4272
+ if (inputs.length > 1) {
4273
+ for (const input of inputs) {
4274
+ outputs.push(yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4275
+ }
4276
+ }
4277
+ else {
4278
+ return [yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4279
+ }
4280
+ return outputs;
4281
+ }));
4282
+ _RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4283
+ var _g, _h, _j;
4284
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4285
+ try {
4286
+ const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
4287
+ if (!authorizationResult.sign_in_result) {
4288
+ throw new Error("Sign in failed, no sign in result returned by wallet");
4289
+ }
4290
+ const signedInAddress = authorizationResult.sign_in_result.address;
4291
+ const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4292
+ return {
4293
+ account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4294
+ address: index.base58.encode(toUint8Array(signedInAddress))
4295
+ }), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
4296
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4297
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4298
+ };
4299
+ }
4300
+ catch (e) {
4301
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4302
+ }
4303
+ finally {
4304
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4305
+ }
4306
+ }));
4307
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4308
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4309
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, config.chains);
4310
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4311
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority);
4312
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4313
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
4314
+ // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4315
+ // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4316
+ // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4317
+ // assume both are supported here. The features will be updated based on the actual connected
4318
+ // wallets capabilities during connection regardless, so this is safe.
4319
+ [SolanaSignAndSendTransaction]: {
4320
+ version: '1.0.0',
4321
+ supportedTransactionVersions: ['legacy', 0],
4322
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4323
+ },
4324
+ [SolanaSignTransaction]: {
4325
+ version: '1.0.0',
4326
+ supportedTransactionVersions: ['legacy', 0],
4327
+ signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4328
+ },
4329
+ });
4990
4330
  }
4991
- .mobile-wallet-adapter-embedded-modal-subtitle {
4992
- margin-right: 12px;
4993
- margin-left: 12px;
4331
+ get version() {
4332
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_version, "f");
4333
+ }
4334
+ get name() {
4335
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_name, "f");
4336
+ }
4337
+ get url() {
4338
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_url, "f");
4339
+ }
4340
+ get icon() {
4341
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_icon, "f");
4342
+ }
4343
+ get chains() {
4344
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f");
4345
+ }
4346
+ get features() {
4347
+ return Object.assign({ [StandardConnect]: {
4348
+ version: '1.0.0',
4349
+ connect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connect, "f"),
4350
+ }, [StandardDisconnect]: {
4351
+ version: '1.0.0',
4352
+ disconnect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f"),
4353
+ }, [StandardEvents]: {
4354
+ version: '1.0.0',
4355
+ on: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_on, "f"),
4356
+ }, [SolanaSignMessage]: {
4357
+ version: '1.0.0',
4358
+ signMessage: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signMessage, "f"),
4359
+ }, [SolanaSignIn]: {
4360
+ version: '1.0.0',
4361
+ signIn: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signIn, "f"),
4362
+ } }, __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4363
+ }
4364
+ get accounts() {
4365
+ var _a, _b;
4366
+ return (_b = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4367
+ }
4368
+ get connected() {
4369
+ return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f") && !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4370
+ }
4371
+ get isAuthorized() {
4372
+ return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4373
+ }
4374
+ get currentAuthorization() {
4375
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4376
+ }
4377
+ get cachedAuthorizationResult() {
4378
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4994
4379
  }
4995
4380
  }
4996
- `;
4997
- //#endregion
4998
- //#region src/embedded-modal/loopbackPermissionModal.ts
4999
- var LoopbackPermissionModal = class extends EmbeddedModal {
5000
- contentStyles = css$1;
5001
- contentHtml = ErrorDialogHtml$1;
5002
- async init() {
5003
- super.init();
5004
- this.#prepareLaunchAction();
5005
- }
5006
- #prepareLaunchAction() {
5007
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
5008
- const listener = async () => {
5009
- launchButton?.removeEventListener("click", listener);
5010
- try {
5011
- await fetch("http://localhost");
5012
- } catch {}
5013
- this.close();
5014
- };
5015
- launchButton?.addEventListener("click", listener);
5016
- }
4381
+ _RemoteSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_version = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_name = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_url = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_hostAuthority = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_session = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_on = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _RemoteSolanaMobileWalletAdapterWallet_emit = function _RemoteSolanaMobileWalletAdapterWallet_emit(event, ...args) {
4382
+ var _a;
4383
+ // eslint-disable-next-line prefer-spread
4384
+ (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4385
+ }, _RemoteSolanaMobileWalletAdapterWallet_off = function _RemoteSolanaMobileWalletAdapterWallet_off(event, listener) {
4386
+ var _a;
4387
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
5017
4388
  };
5018
- const ErrorDialogHtml$1 = `
5019
- <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
5020
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
5021
- Tap "Allow" on the next screen
5022
- </div>
5023
- <svg class="mobile-wallet-adapter-embedded-modal-permission-prompt-mock" xmlns="http://www.w3.org/2000/svg" width="281" height="83" viewBox="0 0 281 83" fill="none">
5024
- <rect width="281" height="83" rx="22" fill="#F0F3F5"/>
5025
- <path d="M254.194 64L252.626 56.657H254.047L254.866 61.452L254.985 62.278H255.02L255.146 61.452L255.993 57.497H257.4L258.254 61.431L258.373 62.278H258.415L258.534 61.431L259.346 56.657H260.718L259.143 64H257.673L256.826 59.961L256.693 59.093H256.651L256.511 59.961L255.664 64H254.194Z" fill="black"/>
5026
- <path d="M248.837 64.231C248.147 64.231 247.54 64.07 247.017 63.748C246.495 63.426 246.086 62.978 245.792 62.404C245.498 61.83 245.351 61.1673 245.351 60.416V60.241C245.351 59.4897 245.498 58.827 245.792 58.253C246.086 57.679 246.495 57.2333 247.017 56.916C247.54 56.594 248.147 56.433 248.837 56.433C249.528 56.433 250.135 56.594 250.657 56.916C251.18 57.2333 251.588 57.679 251.882 58.253C252.176 58.827 252.323 59.4897 252.323 60.241V60.416C252.323 61.1673 252.176 61.83 251.882 62.404C251.588 62.978 251.18 63.426 250.657 63.748C250.135 64.07 249.528 64.231 248.837 64.231ZM248.837 62.824C249.43 62.824 249.897 62.607 250.237 62.173C250.583 61.7343 250.755 61.1417 250.755 60.395V60.262C250.755 59.5107 250.583 58.918 250.237 58.484C249.897 58.05 249.43 57.833 248.837 57.833C248.249 57.833 247.783 58.05 247.437 58.484C247.092 58.918 246.919 59.5107 246.919 60.262V60.395C246.919 61.1417 247.092 61.7343 247.437 62.173C247.783 62.607 248.249 62.824 248.837 62.824Z" fill="black"/>
5027
- <path d="M242.298 64.231C241.467 64.231 240.814 63.993 240.338 63.517C239.866 63.0364 239.631 62.3737 239.631 61.529V53.78H241.178V61.389C241.178 62.3317 241.591 62.803 242.417 62.803C242.65 62.803 242.865 62.7587 243.061 62.67C243.257 62.5814 243.464 62.4367 243.684 62.236L244.538 63.377C244.225 63.6664 243.884 63.881 243.516 64.021C243.152 64.161 242.746 64.231 242.298 64.231ZM237.51 55.061V53.78H240.611V55.061H237.51Z" fill="black"/>
5028
- <path d="M234.463 64.231C233.633 64.231 232.979 63.993 232.503 63.517C232.032 63.0364 231.796 62.3737 231.796 61.529V53.78H233.343V61.389C233.343 62.3317 233.756 62.803 234.582 62.803C234.816 62.803 235.03 62.7587 235.226 62.67C235.422 62.5814 235.63 62.4367 235.849 62.236L236.703 63.377C236.391 63.6664 236.05 63.881 235.681 64.021C235.317 64.161 234.911 64.231 234.463 64.231ZM229.675 55.061V53.78H232.776V55.061H229.675Z" fill="black"/>
5029
- <path d="M221.442 64L224.557 53.976H226.132L229.233 64H227.581L225.642 56.972L225.341 55.761H225.299L225.005 56.972L223.073 64H221.442ZM222.835 61.634L223.255 60.29H227.371L227.805 61.634H222.835Z" fill="black"/>
5030
- <path d="M178.261 64L175.034 60.066V60.024L178.121 56.657H180.011L176.504 60.423V59.632L180.165 64H178.261ZM173.543 64V53.78H175.097V64H173.543Z" fill="#7D9093" fill-opacity="0.5"/>
5031
- <path d="M169.306 64.224C168.588 64.224 167.958 64.0653 167.416 63.748C166.88 63.426 166.462 62.9803 166.163 62.411C165.865 61.837 165.715 61.1673 165.715 60.402V60.248C165.715 59.4873 165.862 58.8223 166.156 58.253C166.45 57.679 166.863 57.2333 167.395 56.916C167.927 56.594 168.546 56.433 169.25 56.433C169.978 56.433 170.59 56.6056 171.084 56.951C171.579 57.2917 171.955 57.777 172.211 58.407L170.874 58.995C170.72 58.6123 170.508 58.323 170.237 58.127C169.967 57.9263 169.633 57.826 169.236 57.826C168.63 57.826 168.149 58.0383 167.794 58.463C167.444 58.883 167.269 59.4616 167.269 60.199V60.465C167.269 61.1837 167.454 61.7577 167.822 62.187C168.196 62.6163 168.69 62.831 169.306 62.831C169.712 62.831 170.06 62.733 170.349 62.537C170.639 62.341 170.877 62.0423 171.063 61.641L172.379 62.285C172.188 62.6957 171.941 63.0457 171.637 63.335C171.334 63.6243 170.986 63.846 170.594 64C170.202 64.1493 169.773 64.224 169.306 64.224Z" fill="#7D9093" fill-opacity="0.5"/>
5032
- <path d="M161.003 64.231C160.312 64.231 159.706 64.07 159.183 63.748C158.66 63.426 158.252 62.978 157.958 62.404C157.664 61.83 157.517 61.1673 157.517 60.416V60.241C157.517 59.4897 157.664 58.827 157.958 58.253C158.252 57.679 158.66 57.2333 159.183 56.916C159.706 56.594 160.312 56.433 161.003 56.433C161.694 56.433 162.3 56.594 162.823 56.916C163.346 57.2333 163.754 57.679 164.048 58.253C164.342 58.827 164.489 59.4897 164.489 60.241V60.416C164.489 61.1673 164.342 61.83 164.048 62.404C163.754 62.978 163.346 63.426 162.823 63.748C162.3 64.07 161.694 64.231 161.003 64.231ZM161.003 62.824C161.596 62.824 162.062 62.607 162.403 62.173C162.748 61.7343 162.921 61.1417 162.921 60.395V60.262C162.921 59.5107 162.748 58.918 162.403 58.484C162.062 58.05 161.596 57.833 161.003 57.833C160.415 57.833 159.948 58.05 159.603 58.484C159.258 58.918 159.085 59.5107 159.085 60.262V60.395C159.085 61.1417 159.258 61.7343 159.603 62.173C159.948 62.607 160.415 62.824 161.003 62.824Z" fill="#7D9093" fill-opacity="0.5"/>
5033
- <path d="M154.463 64.231C153.633 64.231 152.979 63.993 152.503 63.517C152.032 63.0364 151.796 62.3737 151.796 61.529V53.78H153.343V61.389C153.343 62.3317 153.756 62.803 154.582 62.803C154.816 62.803 155.03 62.7587 155.226 62.67C155.422 62.5814 155.63 62.4367 155.849 62.236L156.703 63.377C156.391 63.6664 156.05 63.881 155.681 64.021C155.317 64.161 154.911 64.231 154.463 64.231ZM149.675 55.061V53.78H152.776V55.061H149.675Z" fill="#7D9093" fill-opacity="0.5"/>
5034
- <path d="M142.24 64V53.976H145.544C146.421 53.976 147.112 54.1953 147.616 54.634C148.12 55.0726 148.372 55.6583 148.372 56.391V56.566C148.372 57.0886 148.246 57.5366 147.994 57.91C147.742 58.2833 147.38 58.5586 146.909 58.736V58.792C147.492 58.9226 147.947 59.2003 148.274 59.625C148.605 60.045 148.771 60.5606 148.771 61.172V61.361C148.771 61.893 148.645 62.3573 148.393 62.754C148.145 63.1506 147.795 63.4586 147.343 63.678C146.895 63.8926 146.365 64 145.754 64H142.24ZM143.794 62.656H145.572C146.085 62.656 146.482 62.5253 146.762 62.264C147.042 62.0026 147.182 61.6293 147.182 61.144V60.99C147.182 60.5046 147.037 60.1313 146.748 59.87C146.463 59.604 146.05 59.471 145.509 59.471H143.36V58.183H145.32C145.791 58.183 146.153 58.064 146.405 57.826C146.657 57.588 146.783 57.2496 146.783 56.811V56.685C146.783 56.2416 146.657 55.9033 146.405 55.67C146.157 55.4366 145.796 55.32 145.32 55.32H143.794V62.656Z" fill="#7D9093" fill-opacity="0.5"/>
5035
- <rect x="18" y="17" width="246" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
5036
- <rect x="18" y="33" width="82" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
5037
- </svg>
5038
- <div>
5039
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
5040
- Continue to Allow
5041
- </button>
5042
- </div>
5043
- `;
5044
- const css$1 = `
5045
- .mobile-wallet-adapter-embedded-modal-close {
5046
- display: none;
5047
- }
5048
- .mobile-wallet-adapter-embedded-modal-content {
5049
- text-align: center;
5050
- }
5051
- .mobile-wallet-adapter-embedded-modal-title {
5052
- margin: 18px 100px auto 100px;
5053
- color: #000000;
5054
- font-size: 2.75em;
5055
- font-weight: 600;
5056
- }
5057
- .mobile-wallet-adapter-embedded-modal-subtitle {
5058
- margin: 20px 60px 40px 60px;
5059
- color: #7D9093;
5060
- font-size: 1.25em;
5061
- font-weight: 400;
5062
- }
5063
- .mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
5064
- width: 90%;
5065
- height: auto;
5066
- margin: 0 auto 30px auto;
5067
- display: block;
5068
- }
5069
- .mobile-wallet-adapter-embedded-modal-launch-action {
5070
- display: block;
5071
- width: 100%;
5072
- height: 56px;
5073
- font-size: 1.25em;
5074
- background: #000000;
5075
- color: #FFFFFF;
5076
- border-radius: 18px;
4389
+
4390
+ var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
4391
+ if (kind === "m") throw new TypeError("Private method is not writable");
4392
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4393
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
4394
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4395
+ };
4396
+ var __classPrivateFieldGet = function (receiver, state, kind, f) {
4397
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4398
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4399
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4400
+ };
4401
+ var _RegisterWalletEvent_detail;
4402
+ /**
4403
+ * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
4404
+ *
4405
+ * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
4406
+ * ready to be registered.
4407
+ *
4408
+ * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
4409
+ * the app that the app is ready to register the Wallet.
4410
+ *
4411
+ * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
4412
+ * as the app is ready whether the Wallet loads before or after the app.
4413
+ *
4414
+ * @param wallet Wallet to register.
4415
+ *
4416
+ * @group Wallet
4417
+ */
4418
+ function registerWallet(wallet) {
4419
+ const callback = ({ register }) => register(wallet);
4420
+ try {
4421
+ window.dispatchEvent(new RegisterWalletEvent(callback));
4422
+ }
4423
+ catch (error) {
4424
+ console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
4425
+ }
4426
+ try {
4427
+ window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
4428
+ }
4429
+ catch (error) {
4430
+ console.error('wallet-standard:app-ready event listener could not be added\n', error);
4431
+ }
5077
4432
  }
5078
- /* Smaller screens */
5079
- @media all and (max-width: 600px) {
5080
- .mobile-wallet-adapter-embedded-modal-title {
5081
- font-size: 1.5em;
5082
- margin-right: 12px;
5083
- margin-left: 12px;
4433
+ class RegisterWalletEvent extends Event {
4434
+ constructor(callback) {
4435
+ super('wallet-standard:register-wallet', {
4436
+ bubbles: false,
4437
+ cancelable: false,
4438
+ composed: false,
4439
+ });
4440
+ _RegisterWalletEvent_detail.set(this, void 0);
4441
+ __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
5084
4442
  }
5085
- .mobile-wallet-adapter-embedded-modal-subtitle {
5086
- margin-right: 12px;
5087
- margin-left: 12px;
4443
+ get detail() {
4444
+ return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
4445
+ }
4446
+ get type() {
4447
+ return 'wallet-standard:register-wallet';
4448
+ }
4449
+ /** @deprecated */
4450
+ preventDefault() {
4451
+ throw new Error('preventDefault cannot be called');
4452
+ }
4453
+ /** @deprecated */
4454
+ stopImmediatePropagation() {
4455
+ throw new Error('stopImmediatePropagation cannot be called');
4456
+ }
4457
+ /** @deprecated */
4458
+ stopPropagation() {
4459
+ throw new Error('stopPropagation cannot be called');
5088
4460
  }
5089
4461
  }
5090
- `;
5091
- //#endregion
5092
- //#region src/getIsSupported.ts
4462
+ _RegisterWalletEvent_detail = new WeakMap();
4463
+
5093
4464
  function getIsLocalAssociationSupported() {
5094
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
4465
+ return (typeof window !== 'undefined' &&
4466
+ window.isSecureContext &&
4467
+ typeof document !== 'undefined' &&
4468
+ /android/i.test(navigator.userAgent));
5095
4469
  }
5096
4470
  function getIsRemoteAssociationSupported() {
5097
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
4471
+ return (typeof window !== 'undefined' &&
4472
+ window.isSecureContext &&
4473
+ typeof document !== 'undefined' &&
4474
+ !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
5098
4475
  }
4476
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
4477
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
5099
4478
  function isWebView(userAgentString) {
5100
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4479
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
5101
4480
  }
5102
- function isSolanaMobileWebShell(userAgentString) {
5103
- return userAgentString.includes("Solana Mobile Web Shell");
5104
- }
5105
- function getIsPwaLaunchedAsApp() {
5106
- const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
5107
- if (typeof window == "undefined") return isAndroidTwa;
5108
- const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
5109
- const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
5110
- const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
5111
- return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
5112
- }
5113
- async function checkLocalNetworkAccessPermission() {
5114
- if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
5115
- try {
5116
- const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
5117
- if (lnaPermission.state === "granted") return;
5118
- else if (lnaPermission.state === "denied") {
5119
- const modal = new LoopbackPermissionBlockedModal();
5120
- modal.init();
5121
- modal.open();
5122
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
5123
- } else if (lnaPermission.state === "prompt") {
5124
- const modal = new LoopbackPermissionModal();
5125
- if (await new Promise((resolve, reject) => {
5126
- modal.addEventListener("close", (event) => {
5127
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
5128
- });
5129
- lnaPermission.onchange = () => {
5130
- lnaPermission.onchange = null;
5131
- resolve(lnaPermission.state);
5132
- };
5133
- modal.init();
5134
- modal.open();
5135
- }) === "granted") {
5136
- const modal = new LocalConnectionModal();
5137
- await new Promise((resolve, reject) => {
5138
- modal.addEventListener("close", (event) => {
5139
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
5140
- });
5141
- modal.initWithCallback(async () => {
5142
- resolve(true);
5143
- });
5144
- modal.open();
5145
- });
5146
- return;
5147
- } else return await checkLocalNetworkAccessPermission();
5148
- }
5149
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
5150
- } catch (e) {
5151
- if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
5152
- if (e instanceof SolanaMobileWalletAdapterError) throw e;
5153
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
5154
- }
5155
- }
5156
- //#endregion
5157
- //#region src/icon.ts
5158
- const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
5159
- //#endregion
5160
- //#region src/wallet.ts
5161
- const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
5162
- const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
5163
- const SIGNATURE_LENGTH_IN_BYTES = 64;
5164
- const DEFAULT_FEATURES = [
5165
- SolanaSignAndSendTransaction,
5166
- SolanaSignTransaction,
5167
- SolanaSignMessage,
5168
- SolanaSignIn
5169
- ];
5170
- const WALLET_ASSOCIATION_TIMEOUT = 3e4;
5171
- function getErrorMessage(error) {
5172
- return error instanceof Error ? error.message : "Unknown error";
5173
- }
5174
- var LocalSolanaMobileWalletAdapterWallet = class {
5175
- #listeners = {};
5176
- #version = "1.0.0";
5177
- #name = SolanaMobileWalletAdapterWalletName;
5178
- #url = "https://solanamobile.com/wallets";
5179
- #icon = icon;
5180
- #appIdentity;
5181
- #authorization;
5182
- #authorizationCache;
5183
- #connecting = false;
5184
- /**
5185
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
5186
- * increment this and use it to make sure that `transact` calls from the previous
5187
- * 'generation' don't continue to do work and throw exceptions.
5188
- */
5189
- #connectionGeneration = 0;
5190
- #chains = [];
5191
- #chainSelector;
5192
- #optionalFeatures;
5193
- #onWalletNotFound;
5194
- get version() {
5195
- return this.#version;
5196
- }
5197
- get name() {
5198
- return this.#name;
5199
- }
5200
- get url() {
5201
- return this.#url;
5202
- }
5203
- get icon() {
5204
- return this.#icon;
5205
- }
5206
- get chains() {
5207
- return this.#chains;
5208
- }
5209
- get features() {
5210
- return {
5211
- [StandardConnect]: {
5212
- version: "1.0.0",
5213
- connect: this.#connect
5214
- },
5215
- [StandardDisconnect]: {
5216
- version: "1.0.0",
5217
- disconnect: this.#disconnect
5218
- },
5219
- [StandardEvents]: {
5220
- version: "1.0.0",
5221
- on: this.#on
5222
- },
5223
- [SolanaSignMessage]: {
5224
- version: "1.0.0",
5225
- signMessage: this.#signMessage
5226
- },
5227
- [SolanaSignIn]: {
5228
- version: "1.0.0",
5229
- signIn: this.#signIn
5230
- },
5231
- ...this.#optionalFeatures
5232
- };
5233
- }
5234
- get accounts() {
5235
- return this.#authorization?.accounts ?? [];
5236
- }
5237
- constructor(config) {
5238
- this.#authorizationCache = config.authorizationCache;
5239
- this.#appIdentity = config.appIdentity;
5240
- this.#chains = config.chains;
5241
- this.#chainSelector = config.chainSelector;
5242
- this.#onWalletNotFound = config.onWalletNotFound;
5243
- this.#optionalFeatures = {
5244
- [SolanaSignAndSendTransaction]: {
5245
- version: "1.0.0",
5246
- supportedTransactionVersions: ["legacy", 0],
5247
- signAndSendTransaction: this.#signAndSendTransaction
5248
- },
5249
- [SolanaSignTransaction]: {
5250
- version: "1.0.0",
5251
- supportedTransactionVersions: ["legacy", 0],
5252
- signTransaction: this.#signTransaction
5253
- }
5254
- };
5255
- }
5256
- get connected() {
5257
- return !!this.#authorization;
5258
- }
5259
- get isAuthorized() {
5260
- return !!this.#authorization;
5261
- }
5262
- get currentAuthorization() {
5263
- return this.#authorization;
5264
- }
5265
- get cachedAuthorizationResult() {
5266
- return this.#authorizationCache.get();
5267
- }
5268
- #on = (event, listener) => {
5269
- this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
5270
- return () => this.#off(event, listener);
5271
- };
5272
- #emit(event, ...args) {
5273
- this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
5274
- }
5275
- #off(event, listener) {
5276
- this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
5277
- }
5278
- #connect = async ({ silent } = {}) => {
5279
- if (this.#connecting || this.connected) return { accounts: this.accounts };
5280
- this.#connecting = true;
5281
- try {
5282
- if (silent) {
5283
- const cachedAuthorization = await this.#authorizationCache.get();
5284
- if (cachedAuthorization) {
5285
- await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
5286
- await this.#handleAuthorizationResult(cachedAuthorization);
5287
- } else return { accounts: this.accounts };
5288
- } else await this.#performAuthorization();
5289
- } catch (e) {
5290
- throw new Error(getErrorMessage(e), { cause: e });
5291
- } finally {
5292
- this.#connecting = false;
5293
- }
5294
- return { accounts: this.accounts };
5295
- };
5296
- #performAuthorization = async (signInPayload) => {
5297
- try {
5298
- const cachedAuthorizationResult = await this.#authorizationCache.get();
5299
- if (cachedAuthorizationResult) {
5300
- this.#handleAuthorizationResult(cachedAuthorizationResult);
5301
- return cachedAuthorizationResult;
5302
- }
5303
- const selectedChain = await this.#chainSelector.select(this.#chains);
5304
- return await this.#transact(async (wallet) => {
5305
- const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
5306
- chain: selectedChain,
5307
- identity: this.#appIdentity,
5308
- sign_in_payload: signInPayload
5309
- })]);
5310
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
5311
- const authorization = {
5312
- ...mwaAuthorizationResult,
5313
- accounts,
5314
- chain: selectedChain,
5315
- capabilities
5316
- };
5317
- Promise.all([
5318
- this.#handleWalletCapabilitiesResult(capabilities),
5319
- this.#authorizationCache.set(authorization),
5320
- this.#handleAuthorizationResult(authorization)
5321
- ]);
5322
- return authorization;
5323
- });
5324
- } catch (e) {
5325
- throw new Error(getErrorMessage(e), { cause: e });
5326
- }
5327
- };
5328
- #handleAuthorizationResult = async (authorization) => {
5329
- const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
5330
- this.#authorization = authorization;
5331
- if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
5332
- };
5333
- #handleWalletCapabilitiesResult = async (capabilities) => {
5334
- const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
5335
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
5336
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
5337
- this.#optionalFeatures = {
5338
- ...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
5339
- version: "1.0.0",
5340
- supportedTransactionVersions: ["legacy", 0],
5341
- signAndSendTransaction: this.#signAndSendTransaction
5342
- } },
5343
- ...supportsSignTransaction && { [SolanaSignTransaction]: {
5344
- version: "1.0.0",
5345
- supportedTransactionVersions: ["legacy", 0],
5346
- signTransaction: this.#signTransaction
5347
- } }
5348
- };
5349
- if (didCapabilitiesChange) this.#emit("change", { features: this.features });
5350
- };
5351
- #performReauthorization = async (wallet, authToken, chain) => {
5352
- try {
5353
- const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
5354
- auth_token: authToken,
5355
- identity: this.#appIdentity,
5356
- chain
5357
- })]);
5358
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
5359
- const authorization = {
5360
- ...mwaAuthorizationResult,
5361
- accounts,
5362
- chain,
5363
- capabilities
5364
- };
5365
- Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
5366
- } catch (e) {
5367
- this.#disconnect();
5368
- throw new Error(getErrorMessage(e), { cause: e });
5369
- }
5370
- };
5371
- #disconnect = async () => {
5372
- this.#authorizationCache.clear();
5373
- this.#connecting = false;
5374
- this.#connectionGeneration++;
5375
- this.#authorization = void 0;
5376
- this.#emit("change", { accounts: this.accounts });
5377
- };
5378
- #transact = async (callback) => {
5379
- const walletUriBase = this.#authorization?.wallet_uri_base;
5380
- const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
5381
- const currentConnectionGeneration = this.#connectionGeneration;
5382
- const loadingSpinner = new EmbeddedLoadingSpinner();
5383
- try {
5384
- let associating = true;
5385
- let timeout = void 0;
5386
- const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
5387
- loadingSpinner.init();
5388
- const { wallet, close } = await startScenario(config);
5389
- associating = false;
5390
- loadingSpinner.addEventListener("close", (event) => {
5391
- if (event) close();
5392
- });
5393
- loadingSpinner.open();
5394
- const result = await callback(await wallet);
5395
- loadingSpinner.close();
5396
- close();
5397
- return result;
5398
- }), new Promise((_, reject) => {
5399
- timeout = setTimeout(() => {
5400
- if (associating) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
5401
- }, WALLET_ASSOCIATION_TIMEOUT);
5402
- })]);
5403
- clearTimeout(timeout);
5404
- return result;
5405
- } catch (e) {
5406
- loadingSpinner.close();
5407
- if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
5408
- if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
5409
- throw e;
5410
- }
5411
- };
5412
- #assertIsAuthorized = () => {
5413
- if (!this.#authorization) throw new Error("Wallet not connected");
5414
- return {
5415
- authToken: this.#authorization.auth_token,
5416
- chain: this.#authorization.chain
5417
- };
5418
- };
5419
- #accountsToWalletStandardAccounts = (accounts) => {
5420
- return accounts.map((account) => {
5421
- const publicKey = toUint8Array(account.address);
5422
- return {
5423
- address: index.base58.encode(publicKey),
5424
- publicKey,
5425
- label: account.label,
5426
- icon: account.icon,
5427
- chains: account.chains ?? this.#chains,
5428
- features: account.features ?? DEFAULT_FEATURES
5429
- };
5430
- });
5431
- };
5432
- #performSignTransactions = async (transactions) => {
5433
- const { authToken, chain } = this.#assertIsAuthorized();
5434
- try {
5435
- const base64Transactions = transactions.map((tx) => {
5436
- return fromUint8Array(tx);
5437
- });
5438
- return await this.#transact(async (wallet) => {
5439
- await this.#performReauthorization(wallet, authToken, chain);
5440
- return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
5441
- });
5442
- } catch (e) {
5443
- throw new Error(getErrorMessage(e), { cause: e });
5444
- }
5445
- };
5446
- #performSignAndSendTransaction = async (transaction, options) => {
5447
- const { authToken, chain } = this.#assertIsAuthorized();
5448
- try {
5449
- return await this.#transact(async (wallet) => {
5450
- const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
5451
- if (capabilities.supports_sign_and_send_transactions) {
5452
- const base64Transaction = fromUint8Array(transaction);
5453
- return (await wallet.signAndSendTransactions({
5454
- ...options,
5455
- payloads: [base64Transaction]
5456
- })).signatures.map(toUint8Array)[0];
5457
- } else throw new Error("connected wallet does not support signAndSendTransaction");
5458
- });
5459
- } catch (e) {
5460
- throw new Error(getErrorMessage(e), { cause: e });
5461
- }
5462
- };
5463
- #signAndSendTransaction = async (...inputs) => {
5464
- const outputs = [];
5465
- for (const input of inputs) {
5466
- const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
5467
- outputs.push({ signature });
5468
- }
5469
- return outputs;
5470
- };
5471
- #signTransaction = async (...inputs) => {
5472
- return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
5473
- return { signedTransaction };
5474
- });
5475
- };
5476
- #signMessage = async (...inputs) => {
5477
- const { authToken, chain } = this.#assertIsAuthorized();
5478
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
5479
- const messages = inputs.map(({ message }) => fromUint8Array(message));
5480
- try {
5481
- return await this.#transact(async (wallet) => {
5482
- await this.#performReauthorization(wallet, authToken, chain);
5483
- return (await wallet.signMessages({
5484
- addresses,
5485
- payloads: messages
5486
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
5487
- return {
5488
- signedMessage,
5489
- signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
5490
- };
5491
- });
5492
- });
5493
- } catch (e) {
5494
- throw new Error(getErrorMessage(e), { cause: e });
5495
- }
5496
- };
5497
- #signIn = async (...inputs) => {
5498
- const outputs = [];
5499
- if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
5500
- else return [await this.#performSignIn(inputs[0])];
5501
- return outputs;
5502
- };
5503
- #performSignIn = async (input) => {
5504
- this.#connecting = true;
5505
- try {
5506
- const authorizationResult = await this.#performAuthorization({
5507
- ...input,
5508
- domain: input?.domain ?? window.location.host
5509
- });
5510
- if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
5511
- const signedInAddress = authorizationResult.sign_in_result.address;
5512
- const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
5513
- return {
5514
- account: {
5515
- ...signedInAccount ?? { address: index.base58.encode(toUint8Array(signedInAddress)) },
5516
- publicKey: toUint8Array(signedInAddress),
5517
- chains: signedInAccount?.chains ?? this.#chains,
5518
- features: signedInAccount?.features ?? authorizationResult.capabilities.features
5519
- },
5520
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
5521
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
5522
- };
5523
- } catch (e) {
5524
- throw new Error(getErrorMessage(e), { cause: e });
5525
- } finally {
5526
- this.#connecting = false;
5527
- }
5528
- };
5529
- };
5530
- var RemoteSolanaMobileWalletAdapterWallet = class {
5531
- #listeners = {};
5532
- #version = "1.0.0";
5533
- #name = SolanaMobileWalletAdapterRemoteWalletName;
5534
- #url = "https://solanamobile.com/wallets";
5535
- #icon = icon;
5536
- #appIdentity;
5537
- #authorization;
5538
- #authorizationCache;
5539
- #connecting = false;
5540
- /**
5541
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
5542
- * increment this and use it to make sure that `transact` calls from the previous
5543
- * 'generation' don't continue to do work and throw exceptions.
5544
- */
5545
- #connectionGeneration = 0;
5546
- #chains = [];
5547
- #chainSelector;
5548
- #optionalFeatures;
5549
- #onWalletNotFound;
5550
- #hostAuthority;
5551
- #session;
5552
- get version() {
5553
- return this.#version;
5554
- }
5555
- get name() {
5556
- return this.#name;
5557
- }
5558
- get url() {
5559
- return this.#url;
5560
- }
5561
- get icon() {
5562
- return this.#icon;
5563
- }
5564
- get chains() {
5565
- return this.#chains;
5566
- }
5567
- get features() {
5568
- return {
5569
- [StandardConnect]: {
5570
- version: "1.0.0",
5571
- connect: this.#connect
5572
- },
5573
- [StandardDisconnect]: {
5574
- version: "1.0.0",
5575
- disconnect: this.#disconnect
5576
- },
5577
- [StandardEvents]: {
5578
- version: "1.0.0",
5579
- on: this.#on
5580
- },
5581
- [SolanaSignMessage]: {
5582
- version: "1.0.0",
5583
- signMessage: this.#signMessage
5584
- },
5585
- [SolanaSignIn]: {
5586
- version: "1.0.0",
5587
- signIn: this.#signIn
5588
- },
5589
- ...this.#optionalFeatures
5590
- };
5591
- }
5592
- get accounts() {
5593
- return this.#authorization?.accounts ?? [];
5594
- }
5595
- constructor(config) {
5596
- this.#authorizationCache = config.authorizationCache;
5597
- this.#appIdentity = config.appIdentity;
5598
- this.#chains = config.chains;
5599
- this.#chainSelector = config.chainSelector;
5600
- this.#hostAuthority = config.remoteHostAuthority;
5601
- this.#onWalletNotFound = config.onWalletNotFound;
5602
- this.#optionalFeatures = {
5603
- [SolanaSignAndSendTransaction]: {
5604
- version: "1.0.0",
5605
- supportedTransactionVersions: ["legacy", 0],
5606
- signAndSendTransaction: this.#signAndSendTransaction
5607
- },
5608
- [SolanaSignTransaction]: {
5609
- version: "1.0.0",
5610
- supportedTransactionVersions: ["legacy", 0],
5611
- signTransaction: this.#signTransaction
5612
- }
5613
- };
5614
- }
5615
- get connected() {
5616
- return !!this.#session && !!this.#authorization;
5617
- }
5618
- get isAuthorized() {
5619
- return !!this.#authorization;
5620
- }
5621
- get currentAuthorization() {
5622
- return this.#authorization;
5623
- }
5624
- get cachedAuthorizationResult() {
5625
- return this.#authorizationCache.get();
5626
- }
5627
- #on = (event, listener) => {
5628
- this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
5629
- return () => this.#off(event, listener);
5630
- };
5631
- #emit(event, ...args) {
5632
- this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
5633
- }
5634
- #off(event, listener) {
5635
- this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
5636
- }
5637
- #connect = async (_input = {}) => {
5638
- if (this.#connecting || this.connected) return { accounts: this.accounts };
5639
- this.#connecting = true;
5640
- try {
5641
- await this.#performAuthorization();
5642
- } catch (e) {
5643
- throw new Error(getErrorMessage(e), { cause: e });
5644
- } finally {
5645
- this.#connecting = false;
5646
- }
5647
- return { accounts: this.accounts };
5648
- };
5649
- #performAuthorization = async (signInPayload) => {
5650
- try {
5651
- const cachedAuthorizationResult = await this.#authorizationCache.get();
5652
- if (cachedAuthorizationResult) {
5653
- this.#handleAuthorizationResult(cachedAuthorizationResult);
5654
- return cachedAuthorizationResult;
5655
- }
5656
- if (this.#session) this.#session = void 0;
5657
- const selectedChain = await this.#chainSelector.select(this.#chains);
5658
- return await this.#transact(async (wallet) => {
5659
- const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
5660
- chain: selectedChain,
5661
- identity: this.#appIdentity,
5662
- sign_in_payload: signInPayload
5663
- })]);
5664
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
5665
- const authorizationResult = {
5666
- ...mwaAuthorizationResult,
5667
- accounts,
5668
- chain: selectedChain,
5669
- capabilities
5670
- };
5671
- Promise.all([
5672
- this.#handleWalletCapabilitiesResult(capabilities),
5673
- this.#authorizationCache.set(authorizationResult),
5674
- this.#handleAuthorizationResult(authorizationResult)
5675
- ]);
5676
- return authorizationResult;
5677
- });
5678
- } catch (e) {
5679
- throw new Error(getErrorMessage(e), { cause: e });
5680
- }
5681
- };
5682
- #handleAuthorizationResult = async (authorization) => {
5683
- const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
5684
- this.#authorization = authorization;
5685
- if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
5686
- };
5687
- #handleWalletCapabilitiesResult = async (capabilities) => {
5688
- const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
5689
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
5690
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
5691
- this.#optionalFeatures = {
5692
- ...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
5693
- version: "1.0.0",
5694
- supportedTransactionVersions: capabilities.supported_transaction_versions,
5695
- signAndSendTransaction: this.#signAndSendTransaction
5696
- } },
5697
- ...supportsSignTransaction && { [SolanaSignTransaction]: {
5698
- version: "1.0.0",
5699
- supportedTransactionVersions: capabilities.supported_transaction_versions,
5700
- signTransaction: this.#signTransaction
5701
- } }
5702
- };
5703
- if (didCapabilitiesChange) this.#emit("change", { features: this.features });
5704
- };
5705
- #performReauthorization = async (wallet, authToken, chain) => {
5706
- try {
5707
- const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
5708
- auth_token: authToken,
5709
- identity: this.#appIdentity,
5710
- chain
5711
- })]);
5712
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
5713
- const authorization = {
5714
- ...mwaAuthorizationResult,
5715
- accounts,
5716
- chain,
5717
- capabilities
5718
- };
5719
- Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
5720
- } catch (e) {
5721
- this.#disconnect();
5722
- throw new Error(getErrorMessage(e), { cause: e });
5723
- }
5724
- };
5725
- #disconnect = async () => {
5726
- this.#session?.close();
5727
- this.#authorizationCache.clear();
5728
- this.#connecting = false;
5729
- this.#connectionGeneration++;
5730
- this.#authorization = void 0;
5731
- this.#session = void 0;
5732
- this.#emit("change", { accounts: this.accounts });
5733
- };
5734
- #transact = async (callback) => {
5735
- const walletUriBase = this.#authorization?.wallet_uri_base;
5736
- const remoteConfig = {
5737
- ...walletUriBase ? { baseUri: walletUriBase } : void 0,
5738
- remoteHostAuthority: this.#hostAuthority
5739
- };
5740
- const currentConnectionGeneration = this.#connectionGeneration;
5741
- const modal = new RemoteConnectionModal();
5742
- if (this.#session) return callback(this.#session.wallet);
5743
- try {
5744
- modal.init();
5745
- modal.open();
5746
- const { associationUrl, close, wallet } = await startRemoteScenario(remoteConfig);
5747
- const removeCloseListener = modal.addEventListener("close", (event) => {
5748
- if (event) close();
5749
- });
5750
- modal.populateQRCode(associationUrl.toString());
5751
- this.#session = {
5752
- close,
5753
- wallet: await wallet
5754
- };
5755
- removeCloseListener();
5756
- modal.close();
5757
- return await callback(this.#session.wallet);
5758
- } catch (e) {
5759
- modal.close();
5760
- if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
5761
- if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
5762
- throw e;
5763
- }
5764
- };
5765
- #assertIsAuthorized = () => {
5766
- if (!this.#authorization) throw new Error("Wallet not connected");
5767
- return {
5768
- authToken: this.#authorization.auth_token,
5769
- chain: this.#authorization.chain
5770
- };
5771
- };
5772
- #accountsToWalletStandardAccounts = (accounts) => {
5773
- return accounts.map((account) => {
5774
- const publicKey = toUint8Array(account.address);
5775
- return {
5776
- address: index.base58.encode(publicKey),
5777
- publicKey,
5778
- label: account.label,
5779
- icon: account.icon,
5780
- chains: account.chains ?? this.#chains,
5781
- features: account.features ?? DEFAULT_FEATURES
5782
- };
5783
- });
5784
- };
5785
- #performSignTransactions = async (transactions) => {
5786
- const { authToken, chain } = this.#assertIsAuthorized();
5787
- try {
5788
- return await this.#transact(async (wallet) => {
5789
- await this.#performReauthorization(wallet, authToken, chain);
5790
- return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
5791
- });
5792
- } catch (e) {
5793
- throw new Error(getErrorMessage(e), { cause: e });
5794
- }
5795
- };
5796
- #performSignAndSendTransaction = async (transaction, options) => {
5797
- const { authToken, chain } = this.#assertIsAuthorized();
5798
- try {
5799
- return await this.#transact(async (wallet) => {
5800
- const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
5801
- if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
5802
- ...options,
5803
- payloads: [fromUint8Array(transaction)]
5804
- })).signatures.map(toUint8Array)[0];
5805
- else throw new Error("connected wallet does not support signAndSendTransaction");
5806
- });
5807
- } catch (e) {
5808
- throw new Error(getErrorMessage(e), { cause: e });
5809
- }
5810
- };
5811
- #signAndSendTransaction = async (...inputs) => {
5812
- const outputs = [];
5813
- for (const input of inputs) {
5814
- const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
5815
- outputs.push({ signature });
5816
- }
5817
- return outputs;
5818
- };
5819
- #signTransaction = async (...inputs) => {
5820
- return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
5821
- return { signedTransaction };
5822
- });
5823
- };
5824
- #signMessage = async (...inputs) => {
5825
- const { authToken, chain } = this.#assertIsAuthorized();
5826
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
5827
- const messages = inputs.map(({ message }) => fromUint8Array(message));
5828
- try {
5829
- return await this.#transact(async (wallet) => {
5830
- await this.#performReauthorization(wallet, authToken, chain);
5831
- return (await wallet.signMessages({
5832
- addresses,
5833
- payloads: messages
5834
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
5835
- return {
5836
- signedMessage,
5837
- signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
5838
- };
5839
- });
5840
- });
5841
- } catch (e) {
5842
- throw new Error(getErrorMessage(e), { cause: e });
5843
- }
5844
- };
5845
- #signIn = async (...inputs) => {
5846
- const outputs = [];
5847
- if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
5848
- else return [await this.#performSignIn(inputs[0])];
5849
- return outputs;
5850
- };
5851
- #performSignIn = async (input) => {
5852
- this.#connecting = true;
5853
- try {
5854
- const authorizationResult = await this.#performAuthorization({
5855
- ...input,
5856
- domain: input?.domain ?? window.location.host
5857
- });
5858
- if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
5859
- const signedInAddress = authorizationResult.sign_in_result.address;
5860
- const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
5861
- return {
5862
- account: {
5863
- ...signedInAccount ?? { address: index.base58.encode(toUint8Array(signedInAddress)) },
5864
- publicKey: toUint8Array(signedInAddress),
5865
- chains: signedInAccount?.chains ?? this.#chains,
5866
- features: signedInAccount?.features ?? authorizationResult.capabilities.features
5867
- },
5868
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
5869
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
5870
- };
5871
- } catch (e) {
5872
- throw new Error(getErrorMessage(e), { cause: e });
5873
- } finally {
5874
- this.#connecting = false;
5875
- }
5876
- };
5877
- };
5878
- //#endregion
5879
- //#region src/initialize.ts
4481
+
5880
4482
  function registerMwa(config) {
5881
- if (typeof window === "undefined") {
5882
- console.warn(`MWA not registered: no window object`);
5883
- return;
5884
- }
5885
- if (!window.isSecureContext) {
5886
- console.warn(`MWA not registered: secure context required (https)`);
5887
- return;
5888
- }
5889
- const userAgent = navigator.userAgent;
5890
- if (getIsLocalAssociationSupported() && (!isWebView(userAgent) || isSolanaMobileWebShell(userAgent))) registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
5891
- else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== void 0) registerWallet(new RemoteSolanaMobileWalletAdapterWallet({
5892
- ...config,
5893
- remoteHostAuthority: config.remoteHostAuthority
5894
- }));
4483
+ if (typeof window === 'undefined') {
4484
+ console.warn(`MWA not registered: no window object`);
4485
+ return;
4486
+ }
4487
+ if (!window.isSecureContext) {
4488
+ console.warn(`MWA not registered: secure context required (https)`);
4489
+ return;
4490
+ }
4491
+ // Local association technically is possible in a webview, but we prevent registration
4492
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
4493
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
4494
+ registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4495
+ }
4496
+ else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
4497
+ registerWallet(new RemoteSolanaMobileWalletAdapterWallet(Object.assign(Object.assign({}, config), { remoteHostAuthority: config.remoteHostAuthority })));
4498
+ }
4499
+ else ;
4500
+ }
4501
+
4502
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = 'To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.';
4503
+ 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.';
4504
+ class ErrorModal extends EmbeddedModal {
4505
+ constructor() {
4506
+ super(...arguments);
4507
+ this.contentStyles = css;
4508
+ this.contentHtml = ErrorDialogHtml;
4509
+ }
4510
+ initWithError(error) {
4511
+ super.init();
4512
+ this.populateError(error);
4513
+ }
4514
+ populateError(error) {
4515
+ var _a, _b;
4516
+ const errorMessageElement = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-error-message');
4517
+ const actionBtn = (_b = this.dom) === null || _b === void 0 ? void 0 : _b.getElementById('mobile-wallet-adapter-error-action');
4518
+ if (errorMessageElement) {
4519
+ if (error.name === 'SolanaMobileWalletAdapterError') {
4520
+ switch (error.code) {
4521
+ case 'ERROR_WALLET_NOT_FOUND':
4522
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4523
+ if (actionBtn)
4524
+ actionBtn.addEventListener('click', () => {
4525
+ window.location.href = 'https://solanamobile.com/wallets';
4526
+ });
4527
+ return;
4528
+ case 'ERROR_BROWSER_NOT_SUPPORTED':
4529
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4530
+ if (actionBtn)
4531
+ actionBtn.style.display = 'none';
4532
+ return;
4533
+ }
4534
+ }
4535
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4536
+ }
4537
+ else {
4538
+ console.log('Failed to locate error dialog element');
4539
+ }
4540
+ }
5895
4541
  }
5896
- //#endregion
5897
- //#region src/embedded-modal/errorModal.ts
5898
- const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
5899
- 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.";
5900
- var ErrorModal = class extends EmbeddedModal {
5901
- contentStyles = css;
5902
- contentHtml = ErrorDialogHtml;
5903
- initWithError(error) {
5904
- super.init();
5905
- this.populateError(error);
5906
- }
5907
- populateError(error) {
5908
- const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
5909
- const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
5910
- if (errorMessageElement) {
5911
- if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
5912
- case "ERROR_WALLET_NOT_FOUND":
5913
- errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
5914
- if (actionBtn) actionBtn.addEventListener("click", () => {
5915
- window.location.href = "https://solanamobile.com/wallets";
5916
- });
5917
- return;
5918
- case "ERROR_BROWSER_NOT_SUPPORTED":
5919
- errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
5920
- if (actionBtn) actionBtn.style.display = "none";
5921
- return;
5922
- }
5923
- errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
5924
- } else console.log("Failed to locate error dialog element");
5925
- }
5926
- };
5927
4542
  const ErrorDialogHtml = `
5928
4543
  <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>
5929
4544
  <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
@@ -5983,79 +4598,122 @@ const css = `
5983
4598
  }
5984
4599
  }
5985
4600
  `;
5986
- //#endregion
5987
- //#region src/createDefaultWalletNotFoundHandler.ts
5988
- async function defaultErrorModalWalletNotFoundHandler() {
5989
- if (typeof window !== "undefined") {
5990
- const userAgent = window.navigator.userAgent.toLowerCase();
5991
- const errorDialog = new ErrorModal();
5992
- if (userAgent.includes("wv")) errorDialog.initWithError({
5993
- name: "SolanaMobileWalletAdapterError",
5994
- code: "ERROR_BROWSER_NOT_SUPPORTED",
5995
- message: ""
5996
- });
5997
- else errorDialog.initWithError({
5998
- name: "SolanaMobileWalletAdapterError",
5999
- code: "ERROR_WALLET_NOT_FOUND",
6000
- message: ""
6001
- });
6002
- errorDialog.open();
6003
- }
4601
+
4602
+ function defaultErrorModalWalletNotFoundHandler() {
4603
+ return __awaiter(this, void 0, void 0, function* () {
4604
+ if (typeof window !== 'undefined') {
4605
+ const userAgent = window.navigator.userAgent.toLowerCase();
4606
+ const errorDialog = new ErrorModal();
4607
+ if (userAgent.includes('wv')) { // Android WebView
4608
+ // MWA is not supported in this browser so we inform the user
4609
+ // errorDialog.initWithError(
4610
+ // new SolanaMobileWalletAdapterError(
4611
+ // SolanaMobileWalletAdapterErrorCode.ERROR_BROWSER_NOT_SUPPORTED,
4612
+ // ''
4613
+ // )
4614
+ // );
4615
+ // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4616
+ errorDialog.initWithError({
4617
+ name: 'SolanaMobileWalletAdapterError',
4618
+ code: 'ERROR_BROWSER_NOT_SUPPORTED',
4619
+ message: ''
4620
+ });
4621
+ }
4622
+ else { // Browser, user does not have a wallet installed.
4623
+ // errorDialog.initWithError(
4624
+ // new SolanaMobileWalletAdapterError(
4625
+ // SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND,
4626
+ // ''
4627
+ // )
4628
+ // );
4629
+ // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4630
+ errorDialog.initWithError({
4631
+ name: 'SolanaMobileWalletAdapterError',
4632
+ code: 'ERROR_WALLET_NOT_FOUND',
4633
+ message: ''
4634
+ });
4635
+ }
4636
+ errorDialog.open();
4637
+ }
4638
+ });
6004
4639
  }
6005
4640
  function createDefaultWalletNotFoundHandler() {
6006
- return async () => {
6007
- defaultErrorModalWalletNotFoundHandler();
6008
- };
4641
+ return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
6009
4642
  }
6010
- //#endregion
6011
- //#region src/createDefaultAuthorizationCache.ts
6012
- const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
4643
+
4644
+ const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
6013
4645
  function createDefaultAuthorizationCache() {
6014
- let storage;
6015
- try {
6016
- storage = window.localStorage;
6017
- } catch {}
6018
- return {
6019
- async clear() {
6020
- if (!storage) return;
6021
- try {
6022
- storage.removeItem(CACHE_KEY);
6023
- } catch {}
6024
- },
6025
- async get() {
6026
- if (!storage) return;
6027
- try {
6028
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
6029
- if (parsed && parsed.accounts) {
6030
- const parsedAccounts = parsed.accounts.map((account) => {
6031
- return {
6032
- ...account,
6033
- publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : index.base58.decode(account.address)
6034
- };
6035
- });
6036
- return {
6037
- ...parsed,
6038
- accounts: parsedAccounts
6039
- };
6040
- } else return parsed || void 0;
6041
- } catch {}
6042
- },
6043
- async set(authorization) {
6044
- if (!storage) return;
6045
- try {
6046
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
6047
- } catch {}
6048
- }
6049
- };
4646
+ let storage;
4647
+ try {
4648
+ storage = window.localStorage;
4649
+ // eslint-disable-next-line no-empty
4650
+ }
4651
+ catch (_a) { }
4652
+ return {
4653
+ clear() {
4654
+ return __awaiter(this, void 0, void 0, function* () {
4655
+ if (!storage) {
4656
+ return;
4657
+ }
4658
+ try {
4659
+ storage.removeItem(CACHE_KEY);
4660
+ // eslint-disable-next-line no-empty
4661
+ }
4662
+ catch (_a) { }
4663
+ });
4664
+ },
4665
+ get() {
4666
+ return __awaiter(this, void 0, void 0, function* () {
4667
+ if (!storage) {
4668
+ return;
4669
+ }
4670
+ try {
4671
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
4672
+ if (parsed && parsed.accounts) {
4673
+ const parsedAccounts = parsed.accounts.map((account) => {
4674
+ return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
4675
+ ? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
4676
+ : index.base58.decode(account.address) });
4677
+ });
4678
+ return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
4679
+ }
4680
+ else
4681
+ return parsed || undefined;
4682
+ // eslint-disable-next-line no-empty
4683
+ }
4684
+ catch (_a) { }
4685
+ });
4686
+ },
4687
+ set(authorization) {
4688
+ return __awaiter(this, void 0, void 0, function* () {
4689
+ if (!storage) {
4690
+ return;
4691
+ }
4692
+ try {
4693
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
4694
+ // eslint-disable-next-line no-empty
4695
+ }
4696
+ catch (_a) { }
4697
+ });
4698
+ },
4699
+ };
6050
4700
  }
6051
- //#endregion
6052
- //#region src/createDefaultChainSelector.ts
4701
+
6053
4702
  function createDefaultChainSelector() {
6054
- return { async select(chains) {
6055
- if (chains.length === 1) return chains[0];
6056
- else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
6057
- else return chains[0];
6058
- } };
4703
+ return {
4704
+ select(chains) {
4705
+ return __awaiter(this, void 0, void 0, function* () {
4706
+ if (chains.length === 1) {
4707
+ return chains[0];
4708
+ }
4709
+ else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
4710
+ return SOLANA_MAINNET_CHAIN;
4711
+ }
4712
+ else
4713
+ return chains[0];
4714
+ });
4715
+ },
4716
+ };
6059
4717
  }
6060
4718
 
6061
4719
  exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
@@ -6067,4 +4725,4 @@ exports.createDefaultChainSelector = createDefaultChainSelector;
6067
4725
  exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
6068
4726
  exports.defaultErrorModalWalletNotFoundHandler = defaultErrorModalWalletNotFoundHandler;
6069
4727
  exports.registerMwa = registerMwa;
6070
- //# sourceMappingURL=index.browser-CZIJCtms.js.map
4728
+ //# sourceMappingURL=index.browser-DlA-NKvf.js.map