@pooflabs/web 0.0.86 → 0.0.88

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-DK28JaJm.esm.js → index-BfsQaxom.esm.js} +3054 -301
  3. package/dist/index-BfsQaxom.esm.js.map +1 -0
  4. package/dist/{index-BQUfNEiY.esm.js → index-CJRFnq6O.esm.js} +476 -103
  5. package/dist/index-CJRFnq6O.esm.js.map +1 -0
  6. package/dist/{index-BHkED2YI.js → index-CTtGbOzo.js} +3054 -300
  7. package/dist/index-CTtGbOzo.js.map +1 -0
  8. package/dist/{index-D-Wbwevj.js → index-CvNX4W0l.js} +2 -2
  9. package/dist/index-CvNX4W0l.js.map +1 -0
  10. package/dist/{index-DUn32Hkh.js → index-DBYgqO9f.js} +3055 -301
  11. package/dist/index-DBYgqO9f.js.map +1 -0
  12. package/dist/index-DpiO7Cpe.esm.js +6 -0
  13. package/dist/index-DpiO7Cpe.esm.js.map +1 -0
  14. package/dist/{index-hEc5_KoM.js → index-Lm0k5Hwv.js} +477 -102
  15. package/dist/index-Lm0k5Hwv.js.map +1 -0
  16. package/dist/{index-Cfp30Jm_.esm.js → index-MF_M5V0O.esm.js} +3055 -300
  17. package/dist/index-MF_M5V0O.esm.js.map +1 -0
  18. package/dist/{index.browser-CbawPvh6.js → index.browser-BCr9Sc8V.js} +506 -1876
  19. package/dist/index.browser-BCr9Sc8V.js.map +1 -0
  20. package/dist/{index.browser-DD8pg_L2.js → index.browser-BxKN5pIs.js} +1223 -2565
  21. package/dist/index.browser-BxKN5pIs.js.map +1 -0
  22. package/dist/{index.browser-DQqKPfDA.esm.js → index.browser-CGZvkfTO.esm.js} +506 -1876
  23. package/dist/index.browser-CGZvkfTO.esm.js.map +1 -0
  24. package/dist/{index.browser-C9gHoUen.esm.js → index.browser-CMijwVwX.esm.js} +1223 -2565
  25. package/dist/index.browser-CMijwVwX.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-7hiNiSyC.js → index.native-FMbSnE7i.js} +44 -61
  29. package/dist/index.native-FMbSnE7i.js.map +1 -0
  30. package/dist/{index.native-BItnSD47.esm.js → index.native-GyqT8Dn5.esm.js} +43 -62
  31. package/dist/index.native-GyqT8Dn5.esm.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-CjvLq_2_.js → phantom-wallet-provider-4_DBhDbx.js} +4 -4
  35. package/dist/{phantom-wallet-provider-CjvLq_2_.js.map → phantom-wallet-provider-4_DBhDbx.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-DE3vit2Z.esm.js → phantom-wallet-provider-BFSfBW0w.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-DE3vit2Z.esm.js.map → phantom-wallet-provider-BFSfBW0w.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-DFZaQPss.js → privy-wallet-provider-DRss_Hua.js} +3 -3
  39. package/dist/privy-wallet-provider-DRss_Hua.js.map +1 -0
  40. package/dist/{privy-wallet-provider-ip2pqo_U.esm.js → privy-wallet-provider-Dl0feuCb.esm.js} +3 -3
  41. package/dist/privy-wallet-provider-Dl0feuCb.esm.js.map +1 -0
  42. package/dist/{solana-mobile-wallet-provider-D7BbSpez.esm.js → solana-mobile-wallet-provider-C5mN8Dxh.esm.js} +437 -45
  43. package/dist/solana-mobile-wallet-provider-C5mN8Dxh.esm.js.map +1 -0
  44. package/dist/{solana-mobile-wallet-provider-DwER68Rz.js → solana-mobile-wallet-provider-CAZs-TkL.js} +437 -45
  45. package/dist/solana-mobile-wallet-provider-CAZs-TkL.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/index-BHkED2YI.js.map +0 -1
  48. package/dist/index-BQUfNEiY.esm.js.map +0 -1
  49. package/dist/index-Cfp30Jm_.esm.js.map +0 -1
  50. package/dist/index-D-Wbwevj.js.map +0 -1
  51. package/dist/index-DK28JaJm.esm.js.map +0 -1
  52. package/dist/index-DKyWaxCB.esm.js +0 -6
  53. package/dist/index-DKyWaxCB.esm.js.map +0 -1
  54. package/dist/index-DUn32Hkh.js.map +0 -1
  55. package/dist/index-hEc5_KoM.js.map +0 -1
  56. package/dist/index.browser-C9gHoUen.esm.js.map +0 -1
  57. package/dist/index.browser-CbawPvh6.js.map +0 -1
  58. package/dist/index.browser-DD8pg_L2.js.map +0 -1
  59. package/dist/index.browser-DQqKPfDA.esm.js.map +0 -1
  60. package/dist/index.native-7hiNiSyC.js.map +0 -1
  61. package/dist/index.native-BItnSD47.esm.js.map +0 -1
  62. package/dist/privy-wallet-provider-DFZaQPss.js.map +0 -1
  63. package/dist/privy-wallet-provider-ip2pqo_U.esm.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-D7BbSpez.esm.js.map +0 -1
  65. package/dist/solana-mobile-wallet-provider-DwER68Rz.js.map +0 -1
@@ -1,4 +1,5 @@
1
- import { d as base58 } from './index.native-BItnSD47.esm.js';
1
+ import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol';
2
+ import { d as base58 } from './index.native-GyqT8Dn5.esm.js';
2
3
  import 'axios';
3
4
  import '@solana/web3.js';
4
5
  import '@coral-xyz/anchor';
@@ -16,788 +17,6 @@ const SolanaSignMessage = 'solana:signMessage';
16
17
  /** Name of the feature. */
17
18
  const SolanaSignTransaction = 'solana:signTransaction';
18
19
 
19
- function createDecoder(decoder) {
20
- return Object.freeze({
21
- ...decoder,
22
- decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
23
- });
24
- }
25
-
26
- var getBaseXDecoder = (alphabet4) => {
27
- return createDecoder({
28
- read(rawBytes, offset) {
29
- const bytes = offset === 0 || offset <= -rawBytes.byteLength ? rawBytes : rawBytes.slice(offset);
30
- if (bytes.length === 0) return ["", 0];
31
- let trailIndex = bytes.findIndex((n) => n !== 0);
32
- trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
33
- const leadingZeroes = alphabet4[0].repeat(trailIndex);
34
- if (trailIndex === bytes.length) return [leadingZeroes, rawBytes.length];
35
- const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
36
- const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
37
- return [leadingZeroes + tailChars, rawBytes.length];
38
- }
39
- });
40
- };
41
- function getBaseXFromBigInt(value, alphabet4) {
42
- const base = BigInt(alphabet4.length);
43
- const tailChars = [];
44
- while (value > 0n) {
45
- tailChars.unshift(alphabet4[Number(value % base)]);
46
- value /= base;
47
- }
48
- return tailChars.join("");
49
- }
50
-
51
- // src/base58.ts
52
- var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
53
- var getBase58Decoder = () => getBaseXDecoder(alphabet2);
54
-
55
- /** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
56
- const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
57
-
58
- /**
59
- * TODO: docs
60
- */
61
- function createSignInMessageText(input) {
62
- // ${domain} wants you to sign in with your Solana account:
63
- // ${address}
64
- //
65
- // ${statement}
66
- //
67
- // URI: ${uri}
68
- // Version: ${version}
69
- // Chain ID: ${chain}
70
- // Nonce: ${nonce}
71
- // Issued At: ${issued-at}
72
- // Expiration Time: ${expiration-time}
73
- // Not Before: ${not-before}
74
- // Request ID: ${request-id}
75
- // Resources:
76
- // - ${resources[0]}
77
- // - ${resources[1]}
78
- // ...
79
- // - ${resources[n]}
80
- let message = `${input.domain} wants you to sign in with your Solana account:\n`;
81
- message += `${input.address}`;
82
- if (input.statement) {
83
- message += `\n\n${input.statement}`;
84
- }
85
- const fields = [];
86
- if (input.uri) {
87
- fields.push(`URI: ${input.uri}`);
88
- }
89
- if (input.version) {
90
- fields.push(`Version: ${input.version}`);
91
- }
92
- if (input.chainId) {
93
- fields.push(`Chain ID: ${input.chainId}`);
94
- }
95
- if (input.nonce) {
96
- fields.push(`Nonce: ${input.nonce}`);
97
- }
98
- if (input.issuedAt) {
99
- fields.push(`Issued At: ${input.issuedAt}`);
100
- }
101
- if (input.expirationTime) {
102
- fields.push(`Expiration Time: ${input.expirationTime}`);
103
- }
104
- if (input.notBefore) {
105
- fields.push(`Not Before: ${input.notBefore}`);
106
- }
107
- if (input.requestId) {
108
- fields.push(`Request ID: ${input.requestId}`);
109
- }
110
- if (input.resources) {
111
- fields.push(`Resources:`);
112
- for (const resource of input.resources) {
113
- fields.push(`- ${resource}`);
114
- }
115
- }
116
- if (fields.length) {
117
- message += `\n\n${fields.join('\n')}`;
118
- }
119
- return message;
120
- }
121
-
122
- //#region src/errors.ts
123
- const SolanaMobileWalletAdapterErrorCode = {
124
- ERROR_ASSOCIATION_PORT_OUT_OF_RANGE: "ERROR_ASSOCIATION_PORT_OUT_OF_RANGE",
125
- ERROR_REFLECTOR_ID_OUT_OF_RANGE: "ERROR_REFLECTOR_ID_OUT_OF_RANGE",
126
- ERROR_FORBIDDEN_WALLET_BASE_URL: "ERROR_FORBIDDEN_WALLET_BASE_URL",
127
- ERROR_SECURE_CONTEXT_REQUIRED: "ERROR_SECURE_CONTEXT_REQUIRED",
128
- ERROR_SESSION_CLOSED: "ERROR_SESSION_CLOSED",
129
- ERROR_SESSION_TIMEOUT: "ERROR_SESSION_TIMEOUT",
130
- ERROR_WALLET_NOT_FOUND: "ERROR_WALLET_NOT_FOUND",
131
- ERROR_INVALID_PROTOCOL_VERSION: "ERROR_INVALID_PROTOCOL_VERSION",
132
- ERROR_BROWSER_NOT_SUPPORTED: "ERROR_BROWSER_NOT_SUPPORTED",
133
- ERROR_LOOPBACK_ACCESS_BLOCKED: "ERROR_LOOPBACK_ACCESS_BLOCKED",
134
- ERROR_ASSOCIATION_CANCELLED: "ERROR_ASSOCIATION_CANCELLED"
135
- };
136
- var SolanaMobileWalletAdapterError = class extends Error {
137
- data;
138
- code;
139
- constructor(...args) {
140
- const [code, message, data] = args;
141
- super(message);
142
- this.code = code;
143
- this.data = data;
144
- this.name = "SolanaMobileWalletAdapterError";
145
- }
146
- };
147
- var SolanaMobileWalletAdapterProtocolError = class extends Error {
148
- data;
149
- code;
150
- jsonRpcMessageId;
151
- constructor(...args) {
152
- const [jsonRpcMessageId, code, message, data] = args;
153
- super(message);
154
- this.code = code;
155
- this.data = data;
156
- this.jsonRpcMessageId = jsonRpcMessageId;
157
- this.name = "SolanaMobileWalletAdapterProtocolError";
158
- }
159
- };
160
- //#endregion
161
- //#region src/base64Utils.ts
162
- function encode(input) {
163
- return window.btoa(input);
164
- }
165
- function fromUint8Array$1(byteArray, urlsafe) {
166
- const base64 = window.btoa(String.fromCharCode.call(null, ...byteArray));
167
- return base64;
168
- }
169
- function toUint8Array$1(base64EncodedByteArray) {
170
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
171
- }
172
- //#endregion
173
- //#region src/createHelloReq.ts
174
- async function createHelloReq(ecdhPublicKey, associationKeypairPrivateKey) {
175
- const publicKeyBuffer = await crypto.subtle.exportKey("raw", ecdhPublicKey);
176
- const signatureBuffer = await crypto.subtle.sign({
177
- hash: "SHA-256",
178
- name: "ECDSA"
179
- }, associationKeypairPrivateKey, publicKeyBuffer);
180
- const response = new Uint8Array(publicKeyBuffer.byteLength + signatureBuffer.byteLength);
181
- response.set(new Uint8Array(publicKeyBuffer), 0);
182
- response.set(new Uint8Array(signatureBuffer), publicKeyBuffer.byteLength);
183
- return response;
184
- }
185
- //#endregion
186
- //#region src/base58Utils.ts
187
- function fromUint8Array$2(byteArray) {
188
- return getBase58Decoder().decode(byteArray);
189
- }
190
- function base64ToBase58(base64EncodedString) {
191
- return fromUint8Array$2(toUint8Array$1(base64EncodedString));
192
- }
193
- //#endregion
194
- //#region src/createSIWSMessage.ts
195
- function createSIWSMessage(payload) {
196
- return createSignInMessageText(payload);
197
- }
198
- function createSIWSMessageBase64Url(payload) {
199
- return encode(createSIWSMessage(payload)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
200
- }
201
- //#endregion
202
- //#region src/types.ts
203
- const SolanaSignTransactions = "solana:signTransactions";
204
- const SolanaCloneAuthorization = "solana:cloneAuthorization";
205
- //#endregion
206
- //#region src/createMobileWalletProxy.ts
207
- /**
208
- * Creates a {@link MobileWallet} proxy that handles backwards compatibility and API to RPC conversion.
209
- *
210
- * @param protocolVersion the protocol version in use for this session/request
211
- * @param protocolRequestHandler callback function that handles sending the RPC request to the wallet endpoint.
212
- * @returns a {@link MobileWallet} proxy
213
- */
214
- function createMobileWalletProxy(protocolVersion, protocolRequestHandler) {
215
- return new Proxy({}, {
216
- get(target, p) {
217
- if (p === "then") return null;
218
- if (target[p] == null) target[p] = async function(inputParams) {
219
- const { method, params } = handleMobileWalletRequest(p, inputParams, protocolVersion);
220
- const result = await protocolRequestHandler(method, params);
221
- if (method === "authorize" && params.sign_in_payload && !result.sign_in_result) result.sign_in_result = await signInFallback(params.sign_in_payload, result, protocolRequestHandler);
222
- return handleMobileWalletResponse(p, result, protocolVersion);
223
- };
224
- return target[p];
225
- },
226
- defineProperty() {
227
- return false;
228
- },
229
- deleteProperty() {
230
- return false;
231
- }
232
- });
233
- }
234
- /**
235
- * Handles all {@link MobileWallet} API requests and determines the correct MWA RPC method and params to call.
236
- * This handles backwards compatibility, based on the provided @protocolVersion.
237
- *
238
- * @param methodName the name of {@link MobileWallet} method that was called
239
- * @param methodParams the parameters that were passed to the method
240
- * @param protocolVersion the protocol version in use for this session/request
241
- * @returns the RPC request method and params that should be sent to the wallet endpoint
242
- */
243
- function handleMobileWalletRequest(methodName, methodParams, protocolVersion) {
244
- let params = methodParams;
245
- let method = methodName.toString().replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).toLowerCase();
246
- switch (methodName) {
247
- case "authorize": {
248
- const authorizeParams = params;
249
- let { chain } = authorizeParams;
250
- if (protocolVersion === "legacy") {
251
- switch (chain) {
252
- case "solana:testnet":
253
- chain = "testnet";
254
- break;
255
- case "solana:devnet":
256
- chain = "devnet";
257
- break;
258
- case "solana:mainnet":
259
- chain = "mainnet-beta";
260
- break;
261
- default: chain = authorizeParams.cluster;
262
- }
263
- authorizeParams.cluster = chain;
264
- params = authorizeParams;
265
- } else {
266
- switch (chain) {
267
- case "testnet":
268
- case "devnet":
269
- chain = `solana:${chain}`;
270
- break;
271
- case "mainnet-beta":
272
- chain = "solana:mainnet";
273
- break;
274
- }
275
- authorizeParams.chain = chain;
276
- params = authorizeParams;
277
- }
278
- }
279
- case "reauthorize": {
280
- const { auth_token, identity } = params;
281
- if (auth_token) switch (protocolVersion) {
282
- case "legacy":
283
- method = "reauthorize";
284
- params = {
285
- auth_token,
286
- identity
287
- };
288
- break;
289
- default:
290
- method = "authorize";
291
- break;
292
- }
293
- break;
294
- }
295
- }
296
- return {
297
- method,
298
- params
299
- };
300
- }
301
- /**
302
- * Handles all {@link MobileWallet} API responses and modifies the response for backwards compatibility, if needed
303
- *
304
- * @param method the {@link MobileWallet} method that was called
305
- * @param response the original response that was returned by the method call
306
- * @param protocolVersion the protocol version in use for this session/request
307
- * @returns the possibly modified response
308
- */
309
- function handleMobileWalletResponse(method, response, protocolVersion) {
310
- switch (method) {
311
- case "getCapabilities": {
312
- const capabilities = response;
313
- switch (protocolVersion) {
314
- case "legacy": {
315
- const features = [SolanaSignTransactions];
316
- if (capabilities.supports_clone_authorization === true) features.push(SolanaCloneAuthorization);
317
- return {
318
- ...capabilities,
319
- features
320
- };
321
- }
322
- case "v1": return {
323
- ...capabilities,
324
- supports_sign_and_send_transactions: true,
325
- supports_clone_authorization: capabilities.features.includes(SolanaCloneAuthorization)
326
- };
327
- }
328
- }
329
- }
330
- return response;
331
- }
332
- async function signInFallback(signInPayload, authorizationResult, protocolRequestHandler) {
333
- const domain = signInPayload.domain ?? window.location.host;
334
- const address = authorizationResult.accounts[0].address;
335
- const siwsMessage = createSIWSMessageBase64Url({
336
- ...signInPayload,
337
- domain,
338
- address: base64ToBase58(address)
339
- });
340
- const signedPayload = toUint8Array$1((await protocolRequestHandler("sign_messages", {
341
- addresses: [address],
342
- payloads: [siwsMessage]
343
- })).signed_payloads[0]);
344
- const signedMessage = fromUint8Array$1(signedPayload.slice(0, signedPayload.length - 64));
345
- const signature = fromUint8Array$1(signedPayload.slice(signedPayload.length - 64));
346
- return {
347
- address,
348
- signed_message: signedMessage.length == 0 ? siwsMessage : signedMessage,
349
- signature
350
- };
351
- }
352
- function createSequenceNumberVector(sequenceNumber) {
353
- if (sequenceNumber >= 4294967296) throw new Error("Outbound sequence number overflow. The maximum sequence number is 32-bytes.");
354
- const byteArray = /* @__PURE__ */ new ArrayBuffer(4);
355
- new DataView(byteArray).setUint32(0, sequenceNumber, false);
356
- return new Uint8Array(byteArray);
357
- }
358
- //#endregion
359
- //#region src/encryptedMessage.ts
360
- const INITIALIZATION_VECTOR_BYTES = 12;
361
- async function encryptMessage(plaintext, sequenceNumber, sharedSecret) {
362
- const sequenceNumberVector = createSequenceNumberVector(sequenceNumber);
363
- const initializationVector = new Uint8Array(INITIALIZATION_VECTOR_BYTES);
364
- crypto.getRandomValues(initializationVector);
365
- const ciphertext = await crypto.subtle.encrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, new TextEncoder().encode(plaintext));
366
- const response = new Uint8Array(sequenceNumberVector.byteLength + initializationVector.byteLength + ciphertext.byteLength);
367
- response.set(new Uint8Array(sequenceNumberVector), 0);
368
- response.set(new Uint8Array(initializationVector), sequenceNumberVector.byteLength);
369
- response.set(new Uint8Array(ciphertext), sequenceNumberVector.byteLength + initializationVector.byteLength);
370
- return response;
371
- }
372
- async function decryptMessage(message, sharedSecret) {
373
- const sequenceNumberVector = message.slice(0, 4);
374
- const initializationVector = message.slice(4, 4 + INITIALIZATION_VECTOR_BYTES);
375
- const ciphertext = message.slice(4 + INITIALIZATION_VECTOR_BYTES);
376
- const plaintextBuffer = await crypto.subtle.decrypt(getAlgorithmParams(sequenceNumberVector, initializationVector), sharedSecret, ciphertext);
377
- return getUtf8Decoder().decode(plaintextBuffer);
378
- }
379
- function getAlgorithmParams(sequenceNumber, initializationVector) {
380
- return {
381
- additionalData: sequenceNumber,
382
- iv: initializationVector,
383
- name: "AES-GCM",
384
- tagLength: 128
385
- };
386
- }
387
- let _utf8Decoder;
388
- function getUtf8Decoder() {
389
- if (_utf8Decoder === void 0) _utf8Decoder = new TextDecoder("utf-8");
390
- return _utf8Decoder;
391
- }
392
- //#endregion
393
- //#region src/generateAssociationKeypair.ts
394
- async function generateAssociationKeypair() {
395
- return await crypto.subtle.generateKey({
396
- name: "ECDSA",
397
- namedCurve: "P-256"
398
- }, false, ["sign"]);
399
- }
400
- //#endregion
401
- //#region src/generateECDHKeypair.ts
402
- async function generateECDHKeypair() {
403
- return await crypto.subtle.generateKey({
404
- name: "ECDH",
405
- namedCurve: "P-256"
406
- }, false, ["deriveKey", "deriveBits"]);
407
- }
408
- //#endregion
409
- //#region src/arrayBufferToBase64String.ts
410
- function arrayBufferToBase64String(buffer) {
411
- let binary = "";
412
- const bytes = new Uint8Array(buffer);
413
- const len = bytes.byteLength;
414
- for (let ii = 0; ii < len; ii++) binary += String.fromCharCode(bytes[ii]);
415
- return window.btoa(binary);
416
- }
417
- //#endregion
418
- //#region src/associationPort.ts
419
- function getRandomAssociationPort() {
420
- return assertAssociationPort(49152 + Math.floor(Math.random() * 16384));
421
- }
422
- function assertAssociationPort(port) {
423
- 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 });
424
- return port;
425
- }
426
- //#endregion
427
- //#region src/getStringWithURLUnsafeBase64CharactersReplaced.ts
428
- function getStringWithURLUnsafeCharactersReplaced(unsafeBase64EncodedString) {
429
- return unsafeBase64EncodedString.replace(/[/+=]/g, (m) => ({
430
- "/": "_",
431
- "+": "-",
432
- "=": "."
433
- })[m]);
434
- }
435
- //#endregion
436
- //#region src/getAssociateAndroidIntentURL.ts
437
- const INTENT_NAME = "solana-wallet";
438
- function getPathParts(pathString) {
439
- return pathString.replace(/(^\/+|\/+$)/g, "").split("/");
440
- }
441
- function getIntentURL(methodPathname, intentUrlBase) {
442
- let baseUrl = null;
443
- if (intentUrlBase) {
444
- try {
445
- baseUrl = new URL(intentUrlBase);
446
- } catch {}
447
- if (baseUrl?.protocol !== "https:") throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Base URLs supplied by wallets must be valid `https` URLs");
448
- }
449
- baseUrl ||= new URL(`${INTENT_NAME}:/`);
450
- const pathname = methodPathname.startsWith("/") ? methodPathname : [...getPathParts(baseUrl.pathname), ...getPathParts(methodPathname)].join("/");
451
- return new URL(pathname, baseUrl);
452
- }
453
- async function getAssociateAndroidIntentURL(associationPublicKey, putativePort, associationURLBase, protocolVersions = ["v1"]) {
454
- const associationPort = assertAssociationPort(putativePort);
455
- const encodedKey = arrayBufferToBase64String(await crypto.subtle.exportKey("raw", associationPublicKey));
456
- const url = getIntentURL("v1/associate/local", associationURLBase);
457
- url.searchParams.set("association", getStringWithURLUnsafeCharactersReplaced(encodedKey));
458
- url.searchParams.set("port", `${associationPort}`);
459
- protocolVersions.forEach((version) => {
460
- url.searchParams.set("v", version);
461
- });
462
- return url;
463
- }
464
- //#endregion
465
- //#region src/jsonRpcMessage.ts
466
- async function encryptJsonRpcMessage(jsonRpcMessage, sharedSecret) {
467
- const plaintext = JSON.stringify(jsonRpcMessage);
468
- const sequenceNumber = jsonRpcMessage.id;
469
- return encryptMessage(plaintext, sequenceNumber, sharedSecret);
470
- }
471
- async function decryptJsonRpcMessage(message, sharedSecret) {
472
- const plaintext = await decryptMessage(message, sharedSecret);
473
- const jsonRpcMessage = JSON.parse(plaintext);
474
- if (Object.hasOwnProperty.call(jsonRpcMessage, "error")) throw new SolanaMobileWalletAdapterProtocolError(jsonRpcMessage.id, jsonRpcMessage.error.code, jsonRpcMessage.error.message);
475
- return jsonRpcMessage;
476
- }
477
- //#endregion
478
- //#region src/parseHelloRsp.ts
479
- async function parseHelloRsp(payloadBuffer, associationPublicKey, ecdhPrivateKey) {
480
- const [associationPublicKeyBuffer, walletPublicKey] = await Promise.all([crypto.subtle.exportKey("raw", associationPublicKey), crypto.subtle.importKey("raw", payloadBuffer.slice(0, 65), {
481
- name: "ECDH",
482
- namedCurve: "P-256"
483
- }, false, [])]);
484
- const sharedSecret = await crypto.subtle.deriveBits({
485
- name: "ECDH",
486
- public: walletPublicKey
487
- }, ecdhPrivateKey, 256);
488
- const ecdhSecretKey = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveKey"]);
489
- return await crypto.subtle.deriveKey({
490
- name: "HKDF",
491
- hash: "SHA-256",
492
- salt: new Uint8Array(associationPublicKeyBuffer),
493
- info: new Uint8Array()
494
- }, ecdhSecretKey, {
495
- name: "AES-GCM",
496
- length: 128
497
- }, false, ["encrypt", "decrypt"]);
498
- }
499
- //#endregion
500
- //#region src/parseSessionProps.ts
501
- async function parseSessionProps(message, sharedSecret) {
502
- const plaintext = await decryptMessage(message, sharedSecret);
503
- const jsonProperties = JSON.parse(plaintext);
504
- let protocolVersion = "legacy";
505
- if (Object.hasOwnProperty.call(jsonProperties, "v")) switch (jsonProperties.v) {
506
- case 1:
507
- case "1":
508
- case "v1":
509
- protocolVersion = "v1";
510
- break;
511
- case "legacy":
512
- protocolVersion = "legacy";
513
- break;
514
- default: throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_INVALID_PROTOCOL_VERSION, `Unknown/unsupported protocol version: ${jsonProperties.v}`);
515
- }
516
- return { protocol_version: protocolVersion };
517
- }
518
- //#endregion
519
- //#region src/startSession.ts
520
- const Browser = {
521
- Firefox: 0,
522
- Other: 1
523
- };
524
- function assertUnreachable(x) {
525
- return x;
526
- }
527
- function getBrowser() {
528
- return navigator.userAgent.indexOf("Firefox/") !== -1 ? Browser.Firefox : Browser.Other;
529
- }
530
- function getDetectionPromise() {
531
- return new Promise((resolve, reject) => {
532
- function cleanup() {
533
- clearTimeout(timeoutId);
534
- window.removeEventListener("blur", handleBlur);
535
- }
536
- function handleBlur() {
537
- cleanup();
538
- resolve();
539
- }
540
- window.addEventListener("blur", handleBlur);
541
- const timeoutId = setTimeout(() => {
542
- cleanup();
543
- reject();
544
- }, 3e3);
545
- });
546
- }
547
- let _frame = null;
548
- function launchUrlThroughHiddenFrame(url) {
549
- if (_frame == null) {
550
- _frame = document.createElement("iframe");
551
- _frame.style.display = "none";
552
- document.body.appendChild(_frame);
553
- }
554
- _frame.contentWindow.location.href = url.toString();
555
- }
556
- async function launchAssociation(associationUrl) {
557
- if (associationUrl.protocol === "https:") window.location.assign(associationUrl);
558
- else try {
559
- const browser = getBrowser();
560
- switch (browser) {
561
- case Browser.Firefox:
562
- launchUrlThroughHiddenFrame(associationUrl);
563
- break;
564
- case Browser.Other: {
565
- const detectionPromise = getDetectionPromise();
566
- window.location.assign(associationUrl);
567
- await detectionPromise;
568
- break;
569
- }
570
- default: assertUnreachable(browser);
571
- }
572
- } catch {
573
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND, "Found no installed wallet that supports the mobile wallet protocol.");
574
- }
575
- }
576
- async function startSession(associationPublicKey, associationURLBase) {
577
- const randomAssociationPort = getRandomAssociationPort();
578
- await launchAssociation(await getAssociateAndroidIntentURL(associationPublicKey, randomAssociationPort, associationURLBase));
579
- return randomAssociationPort;
580
- }
581
- //#endregion
582
- //#region src/transact.ts
583
- const WEBSOCKET_CONNECTION_CONFIG = {
584
- retryDelayScheduleMs: [
585
- 150,
586
- 150,
587
- 200,
588
- 500,
589
- 500,
590
- 750,
591
- 750,
592
- 1e3
593
- ],
594
- timeoutMs: 3e4
595
- };
596
- const WEBSOCKET_PROTOCOL_BINARY = "com.solana.mobilewalletadapter.v1";
597
- function assertSecureContext() {
598
- 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`).");
599
- }
600
- function assertSecureEndpointSpecificURI(walletUriBase) {
601
- let url;
602
- try {
603
- url = new URL(walletUriBase);
604
- } catch {
605
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Invalid base URL supplied by wallet");
606
- }
607
- if (url.protocol !== "https:") throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_FORBIDDEN_WALLET_BASE_URL, "Base URLs supplied by wallets must be valid `https` URLs");
608
- }
609
- function getSequenceNumberFromByteArray(byteArray) {
610
- return new DataView(byteArray).getUint32(0, false);
611
- }
612
- async function startScenario(config) {
613
- assertSecureContext();
614
- const associationKeypair = await generateAssociationKeypair();
615
- const websocketURL = `ws://localhost:${await startSession(associationKeypair.publicKey, config?.baseUri)}/solana-wallet`;
616
- let connectionStartTime;
617
- const getNextRetryDelayMs = (() => {
618
- const schedule = [...WEBSOCKET_CONNECTION_CONFIG.retryDelayScheduleMs];
619
- return () => schedule.length > 1 ? schedule.shift() : schedule[0];
620
- })();
621
- let nextJsonRpcMessageId = 1;
622
- let lastKnownInboundSequenceNumber = 0;
623
- let state = { __type: "disconnected" };
624
- let socket;
625
- let sessionEstablished = false;
626
- let handleForceClose;
627
- return {
628
- close: () => {
629
- socket.close();
630
- handleForceClose();
631
- },
632
- wallet: new Promise((resolve, reject) => {
633
- const jsonRpcResponsePromises = {};
634
- const handleOpen = async () => {
635
- if (state.__type !== "connecting") {
636
- console.warn(`Expected adapter state to be \`connecting\` at the moment the websocket opens. Got \`${state.__type}\`.`);
637
- return;
638
- }
639
- socket.removeEventListener("open", handleOpen);
640
- const { associationKeypair } = state;
641
- const ecdhKeypair = await generateECDHKeypair();
642
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
643
- state = {
644
- __type: "hello_req_sent",
645
- associationPublicKey: associationKeypair.publicKey,
646
- ecdhPrivateKey: ecdhKeypair.privateKey
647
- };
648
- };
649
- const handleClose = (evt) => {
650
- if (evt.wasClean) state = { __type: "disconnected" };
651
- else reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session dropped unexpectedly (${evt.code}: ${evt.reason}).`, { closeEvent: evt }));
652
- disposeSocket();
653
- };
654
- const handleError = async (_evt) => {
655
- disposeSocket();
656
- if (Date.now() - connectionStartTime >= WEBSOCKET_CONNECTION_CONFIG.timeoutMs) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_TIMEOUT, `Failed to connect to the wallet websocket at ${websocketURL}.`));
657
- else {
658
- await new Promise((resolve) => {
659
- const retryDelayMs = getNextRetryDelayMs();
660
- retryWaitTimeoutId = window.setTimeout(resolve, retryDelayMs);
661
- });
662
- attemptSocketConnection();
663
- }
664
- };
665
- const handleMessage = async (evt) => {
666
- const responseBuffer = await evt.data.arrayBuffer();
667
- switch (state.__type) {
668
- case "connecting": {
669
- if (responseBuffer.byteLength !== 0) throw new Error("Encountered unexpected message while connecting");
670
- const ecdhKeypair = await generateECDHKeypair();
671
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
672
- state = {
673
- __type: "hello_req_sent",
674
- associationPublicKey: associationKeypair.publicKey,
675
- ecdhPrivateKey: ecdhKeypair.privateKey
676
- };
677
- break;
678
- }
679
- case "connected":
680
- try {
681
- const sequenceNumber = getSequenceNumberFromByteArray(responseBuffer.slice(0, 4));
682
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
683
- lastKnownInboundSequenceNumber = sequenceNumber;
684
- const jsonRpcMessage = await decryptJsonRpcMessage(responseBuffer, state.sharedSecret);
685
- const responsePromise = jsonRpcResponsePromises[jsonRpcMessage.id];
686
- delete jsonRpcResponsePromises[jsonRpcMessage.id];
687
- responsePromise.resolve(jsonRpcMessage.result);
688
- } catch (e) {
689
- if (e instanceof SolanaMobileWalletAdapterProtocolError) {
690
- const responsePromise = jsonRpcResponsePromises[e.jsonRpcMessageId];
691
- delete jsonRpcResponsePromises[e.jsonRpcMessageId];
692
- responsePromise.reject(e);
693
- } else throw e;
694
- }
695
- break;
696
- case "hello_req_sent": {
697
- if (responseBuffer.byteLength === 0) {
698
- const ecdhKeypair = await generateECDHKeypair();
699
- socket.send(await createHelloReq(ecdhKeypair.publicKey, associationKeypair.privateKey));
700
- state = {
701
- __type: "hello_req_sent",
702
- associationPublicKey: associationKeypair.publicKey,
703
- ecdhPrivateKey: ecdhKeypair.privateKey
704
- };
705
- break;
706
- }
707
- const sharedSecret = await parseHelloRsp(responseBuffer, state.associationPublicKey, state.ecdhPrivateKey);
708
- const sessionPropertiesBuffer = responseBuffer.slice(65);
709
- const sessionProperties = sessionPropertiesBuffer.byteLength !== 0 ? await (async () => {
710
- const sequenceNumber = getSequenceNumberFromByteArray(sessionPropertiesBuffer.slice(0, 4));
711
- if (sequenceNumber !== lastKnownInboundSequenceNumber + 1) throw new Error("Encrypted message has invalid sequence number");
712
- lastKnownInboundSequenceNumber = sequenceNumber;
713
- return parseSessionProps(sessionPropertiesBuffer, sharedSecret);
714
- })() : { protocol_version: "legacy" };
715
- state = {
716
- __type: "connected",
717
- sharedSecret,
718
- sessionProperties
719
- };
720
- const wallet = createMobileWalletProxy(sessionProperties.protocol_version, async (method, params) => {
721
- const id = nextJsonRpcMessageId++;
722
- socket.send(await encryptJsonRpcMessage({
723
- id,
724
- jsonrpc: "2.0",
725
- method,
726
- params: params ?? {}
727
- }, sharedSecret));
728
- return new Promise((resolve, reject) => {
729
- jsonRpcResponsePromises[id] = {
730
- resolve(result) {
731
- switch (method) {
732
- case "authorize":
733
- case "reauthorize": {
734
- const { wallet_uri_base } = result;
735
- if (wallet_uri_base != null) try {
736
- assertSecureEndpointSpecificURI(wallet_uri_base);
737
- } catch (e) {
738
- reject(e);
739
- return;
740
- }
741
- break;
742
- }
743
- }
744
- resolve(result);
745
- },
746
- reject
747
- };
748
- });
749
- });
750
- sessionEstablished = true;
751
- try {
752
- resolve(wallet);
753
- } catch (e) {
754
- reject(e);
755
- }
756
- break;
757
- }
758
- }
759
- };
760
- handleForceClose = () => {
761
- socket.removeEventListener("message", handleMessage);
762
- disposeSocket();
763
- if (!sessionEstablished) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_SESSION_CLOSED, `The wallet session was closed before connection.`, { closeEvent: new CloseEvent("socket was closed before connection") }));
764
- };
765
- let disposeSocket;
766
- let retryWaitTimeoutId;
767
- const attemptSocketConnection = () => {
768
- if (disposeSocket) disposeSocket();
769
- state = {
770
- __type: "connecting",
771
- associationKeypair
772
- };
773
- if (connectionStartTime === void 0) connectionStartTime = Date.now();
774
- socket = new WebSocket(websocketURL, [WEBSOCKET_PROTOCOL_BINARY]);
775
- socket.addEventListener("open", handleOpen);
776
- socket.addEventListener("close", handleClose);
777
- socket.addEventListener("error", handleError);
778
- socket.addEventListener("message", handleMessage);
779
- disposeSocket = () => {
780
- window.clearTimeout(retryWaitTimeoutId);
781
- socket.removeEventListener("open", handleOpen);
782
- socket.removeEventListener("close", handleClose);
783
- socket.removeEventListener("error", handleError);
784
- socket.removeEventListener("message", handleMessage);
785
- };
786
- };
787
- attemptSocketConnection();
788
- })
789
- };
790
- }
791
-
792
- /** Name of the feature. */
793
- const StandardConnect = 'standard:connect';
794
-
795
- /** Name of the feature. */
796
- const StandardDisconnect = 'standard:disconnect';
797
-
798
- /** Name of the feature. */
799
- const StandardEvents = 'standard:events';
800
-
801
20
  var browser = {};
802
21
 
803
22
  var canPromise;
@@ -3869,1121 +3088,532 @@ function requireBrowser () {
3869
3088
 
3870
3089
  requireBrowser();
3871
3090
 
3872
- //#region src/base64Utils.ts
3873
- function fromUint8Array(byteArray) {
3874
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
3875
- }
3876
- function toUint8Array(base64EncodedByteArray) {
3877
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
3878
- }
3879
- //#endregion
3880
- //#region src/embedded-modal/loadingSpinner.ts
3881
- const modalHtml$1 = `
3882
- <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3883
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
3884
- <div class="mobile-wallet-adapter-embedded-loading-container">
3885
- <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
3886
- </div>
3887
- </div>
3888
- `;
3889
- const css$6 = `
3890
- .mobile-wallet-adapter-embedded-loading-indicator {
3891
- display: flex; /* Use flexbox to center content */
3892
- justify-content: center; /* Center horizontally */
3893
- align-items: start; /* Center vertically */
3894
- position: fixed; /* Stay in place */
3895
- z-index: 1; /* Sit on top */
3896
- left: 0;
3897
- top: 0;
3898
- width: 100%; /* Full width */
3899
- height: 100%; /* Full height */
3900
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
3901
- overflow-y: auto; /* enable scrolling */
3902
- }
3091
+ /** Name of the feature. */
3092
+ const StandardConnect = 'standard:connect';
3903
3093
 
3904
- .mobile-wallet-adapter-embedded-loading-container {
3905
- display: flex;
3906
- margin: auto;
3094
+ /** Name of the feature. */
3095
+ const StandardDisconnect = 'standard:disconnect';
3096
+
3097
+ /** Name of the feature. */
3098
+ const StandardEvents = 'standard:events';
3099
+
3100
+ /** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
3101
+ const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
3102
+
3103
+ /******************************************************************************
3104
+ Copyright (c) Microsoft Corporation.
3105
+
3106
+ Permission to use, copy, modify, and/or distribute this software for any
3107
+ purpose with or without fee is hereby granted.
3108
+
3109
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3110
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3111
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3112
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3113
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3114
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3115
+ PERFORMANCE OF THIS SOFTWARE.
3116
+ ***************************************************************************** */
3117
+
3118
+ function __awaiter(thisArg, _arguments, P, generator) {
3119
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3120
+ return new (P || (P = Promise))(function (resolve, reject) {
3121
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3122
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3123
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3124
+ step((generator = generator.apply(thisArg, [])).next());
3125
+ });
3126
+ }
3127
+
3128
+ function __classPrivateFieldGet$1(receiver, state, kind, f) {
3129
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3130
+ 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");
3131
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3132
+ }
3133
+
3134
+ function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
3135
+ 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");
3136
+ return (state.set(receiver, value)), value;
3907
3137
  }
3908
3138
 
3909
- .mobile-wallet-adapter-embedded-loading-animation {
3910
- position: relative;
3911
- left: -9999px;
3912
- width: 10px;
3913
- height: 10px;
3914
- border-radius: 5px;
3915
- background-color: var(--spinner-color);
3916
- color: var(--spinner-color);
3917
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3918
- 9999px 0 0 0 var(--spinner-color),
3919
- 10014px 0 0 0 var(--spinner-color);
3920
- animation: dot-typing 1.5s infinite linear;
3139
+ const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
3140
+
3141
+ function fromUint8Array(byteArray) {
3142
+ return window.btoa(String.fromCharCode.call(null, ...byteArray));
3143
+ }
3144
+ function toUint8Array(base64EncodedByteArray) {
3145
+ return new Uint8Array(window
3146
+ .atob(base64EncodedByteArray)
3147
+ .split('')
3148
+ .map((c) => c.charCodeAt(0)));
3921
3149
  }
3922
3150
 
3923
- @keyframes dot-typing {
3924
- 0% {
3925
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3926
- 9999px 0 0 0 var(--spinner-color),
3927
- 10014px 0 0 0 var(--spinner-color);
3151
+ 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;
3152
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
3153
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
3154
+ const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
3155
+ class LocalSolanaMobileWalletAdapterWallet {
3156
+ constructor(config) {
3157
+ _LocalSolanaMobileWalletAdapterWallet_instances.add(this);
3158
+ _LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3159
+ _LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3160
+ _LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
3161
+ _LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3162
+ _LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3163
+ _LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
3164
+ _LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
3165
+ _LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
3166
+ _LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
3167
+ /**
3168
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
3169
+ * increment this and use it to make sure that `transact` calls from the previous
3170
+ * 'generation' don't continue to do work and throw exceptions.
3171
+ */
3172
+ _LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
3173
+ _LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
3174
+ _LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
3175
+ _LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
3176
+ _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
3177
+ _LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
3178
+ var _a;
3179
+ ((_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]);
3180
+ return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
3181
+ });
3182
+ _LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
3183
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
3184
+ return { accounts: this.accounts };
3185
+ }
3186
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3187
+ try {
3188
+ if (silent) {
3189
+ const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3190
+ if (cachedAuthorization) {
3191
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
3192
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
3193
+ }
3194
+ else {
3195
+ return { accounts: this.accounts };
3196
+ }
3197
+ }
3198
+ else {
3199
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
3200
+ }
3201
+ }
3202
+ catch (e) {
3203
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3204
+ }
3205
+ finally {
3206
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3207
+ }
3208
+ return { accounts: this.accounts };
3209
+ }));
3210
+ _LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
3211
+ try {
3212
+ const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3213
+ if (cachedAuthorizationResult) {
3214
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3215
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
3216
+ return cachedAuthorizationResult;
3217
+ }
3218
+ const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
3219
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3220
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3221
+ wallet.getCapabilities(),
3222
+ wallet.authorize({
3223
+ chain: selectedChain,
3224
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3225
+ sign_in_payload: signInPayload,
3226
+ })
3227
+ ]);
3228
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3229
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
3230
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3231
+ Promise.all([
3232
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
3233
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3234
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3235
+ ]);
3236
+ return authorization;
3237
+ }));
3238
+ }
3239
+ catch (e) {
3240
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3241
+ }
3242
+ }));
3243
+ _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
3244
+ var _a;
3245
+ const didPublicKeysChange =
3246
+ // Case 1: We started from having no authorization.
3247
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
3248
+ // Case 2: The number of authorized accounts changed.
3249
+ ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
3250
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
3251
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
3252
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
3253
+ if (didPublicKeysChange) {
3254
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3255
+ }
3256
+ }));
3257
+ _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
3258
+ // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
3259
+ const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
3260
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
3261
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
3262
+ SolanaSignTransaction in this.features !== supportsSignTransaction;
3263
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
3264
+ [SolanaSignAndSendTransaction]: {
3265
+ version: '1.0.0',
3266
+ supportedTransactionVersions: ['legacy', 0],
3267
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3268
+ },
3269
+ })), (supportsSignTransaction && {
3270
+ [SolanaSignTransaction]: {
3271
+ version: '1.0.0',
3272
+ supportedTransactionVersions: ['legacy', 0],
3273
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3274
+ },
3275
+ })));
3276
+ if (didCapabilitiesChange) {
3277
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
3278
+ }
3279
+ }));
3280
+ _LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
3281
+ var _b, _c;
3282
+ try {
3283
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3284
+ (_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
3285
+ wallet.authorize({
3286
+ auth_token: authToken,
3287
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3288
+ chain: chain
3289
+ })
3290
+ ]);
3291
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3292
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
3293
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3294
+ Promise.all([
3295
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3296
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3297
+ ]);
3298
+ }
3299
+ catch (e) {
3300
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
3301
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3302
+ }
3303
+ }));
3304
+ _LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
3305
+ var _d;
3306
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3307
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3308
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
3309
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
3310
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3311
+ }));
3312
+ _LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
3313
+ var _e;
3314
+ const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
3315
+ const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
3316
+ const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
3317
+ try {
3318
+ return yield transact(callback, config);
3319
+ }
3320
+ catch (e) {
3321
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
3322
+ yield new Promise(() => { }); // Never resolve.
3323
+ }
3324
+ if (e instanceof Error &&
3325
+ e.name === 'SolanaMobileWalletAdapterError' &&
3326
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
3327
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
3328
+ }
3329
+ throw e;
3330
+ }
3331
+ }));
3332
+ _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
3333
+ if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
3334
+ throw new Error('Wallet not connected');
3335
+ return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
3336
+ });
3337
+ _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
3338
+ return accounts.map((account) => {
3339
+ var _a, _b;
3340
+ const publicKey = toUint8Array(account.address);
3341
+ return {
3342
+ address: base58.encode(publicKey),
3343
+ publicKey,
3344
+ label: account.label,
3345
+ icon: account.icon,
3346
+ chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
3347
+ // TODO: get supported features from getCapabilities API
3348
+ features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
3349
+ };
3350
+ });
3351
+ });
3352
+ _LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
3353
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3354
+ try {
3355
+ const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
3356
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3357
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3358
+ const signedTransactions = (yield wallet.signTransactions({
3359
+ payloads: base64Transactions,
3360
+ })).signed_payloads.map(toUint8Array);
3361
+ return signedTransactions;
3362
+ }));
3363
+ }
3364
+ catch (e) {
3365
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3366
+ }
3367
+ }));
3368
+ _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
3369
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3370
+ try {
3371
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3372
+ const [capabilities, _1] = yield Promise.all([
3373
+ wallet.getCapabilities(),
3374
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
3375
+ ]);
3376
+ if (capabilities.supports_sign_and_send_transactions) {
3377
+ const base64Transaction = fromUint8Array(transaction);
3378
+ const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
3379
+ return signatures[0];
3380
+ }
3381
+ else {
3382
+ throw new Error('connected wallet does not support signAndSendTransaction');
3383
+ }
3384
+ }));
3385
+ }
3386
+ catch (e) {
3387
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3388
+ }
3389
+ }));
3390
+ _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3391
+ const outputs = [];
3392
+ for (const input of inputs) {
3393
+ const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
3394
+ outputs.push({ signature });
3395
+ }
3396
+ return outputs;
3397
+ }));
3398
+ _LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3399
+ return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
3400
+ .map((signedTransaction) => {
3401
+ return { signedTransaction };
3402
+ });
3403
+ }));
3404
+ _LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3405
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3406
+ const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
3407
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
3408
+ try {
3409
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3410
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3411
+ const signedMessages = (yield wallet.signMessages({
3412
+ addresses: addresses,
3413
+ payloads: messages,
3414
+ })).signed_payloads.map(toUint8Array);
3415
+ return signedMessages.map((signedMessage) => {
3416
+ return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
3417
+ });
3418
+ }));
3419
+ }
3420
+ catch (e) {
3421
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3422
+ }
3423
+ }));
3424
+ _LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3425
+ const outputs = [];
3426
+ if (inputs.length > 1) {
3427
+ for (const input of inputs) {
3428
+ outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
3429
+ }
3430
+ }
3431
+ else {
3432
+ return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
3433
+ }
3434
+ return outputs;
3435
+ }));
3436
+ _LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
3437
+ var _f, _g, _h;
3438
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3439
+ try {
3440
+ 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 }));
3441
+ if (!authorizationResult.sign_in_result) {
3442
+ throw new Error("Sign in failed, no sign in result returned by wallet");
3443
+ }
3444
+ const signedInAddress = authorizationResult.sign_in_result.address;
3445
+ const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
3446
+ return {
3447
+ account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
3448
+ address: base58.encode(toUint8Array(signedInAddress))
3449
+ }), { 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 }),
3450
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
3451
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
3452
+ };
3453
+ }
3454
+ catch (e) {
3455
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3456
+ }
3457
+ finally {
3458
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3459
+ }
3460
+ }));
3461
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
3462
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
3463
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
3464
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
3465
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
3466
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
3467
+ // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
3468
+ // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
3469
+ // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
3470
+ // assume both are supported here. The features will be updated based on the actual connected
3471
+ // wallets capabilities during connection regardless, so this is safe.
3472
+ [SolanaSignAndSendTransaction]: {
3473
+ version: '1.0.0',
3474
+ supportedTransactionVersions: ['legacy', 0],
3475
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3476
+ },
3477
+ [SolanaSignTransaction]: {
3478
+ version: '1.0.0',
3479
+ supportedTransactionVersions: ['legacy', 0],
3480
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3481
+ },
3482
+ });
3928
3483
  }
3929
- 16.667% {
3930
- box-shadow: 9984px -10px 0 0 var(--spinner-color),
3931
- 9999px 0 0 0 var(--spinner-color),
3932
- 10014px 0 0 0 var(--spinner-color);
3484
+ get version() {
3485
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
3933
3486
  }
3934
- 33.333% {
3935
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3936
- 9999px 0 0 0 var(--spinner-color),
3937
- 10014px 0 0 0 var(--spinner-color);
3487
+ get name() {
3488
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
3938
3489
  }
3939
- 50% {
3940
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3941
- 9999px -10px 0 0 var(--spinner-color),
3942
- 10014px 0 0 0 var(--spinner-color);
3490
+ get url() {
3491
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
3943
3492
  }
3944
- 66.667% {
3945
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3946
- 9999px 0 0 0 var(--spinner-color),
3947
- 10014px 0 0 0 var(--spinner-color);
3493
+ get icon() {
3494
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
3948
3495
  }
3949
- 83.333% {
3950
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3951
- 9999px 0 0 0 var(--spinner-color),
3952
- 10014px -10px 0 0 var(--spinner-color);
3496
+ get chains() {
3497
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
3953
3498
  }
3954
- 100% {
3955
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3956
- 9999px 0 0 0 var(--spinner-color),
3957
- 10014px 0 0 0 var(--spinner-color);
3499
+ get features() {
3500
+ return Object.assign({ [StandardConnect]: {
3501
+ version: '1.0.0',
3502
+ connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
3503
+ }, [StandardDisconnect]: {
3504
+ version: '1.0.0',
3505
+ disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
3506
+ }, [StandardEvents]: {
3507
+ version: '1.0.0',
3508
+ on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
3509
+ }, [SolanaSignMessage]: {
3510
+ version: '1.0.0',
3511
+ signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
3512
+ }, [SolanaSignIn]: {
3513
+ version: '1.0.0',
3514
+ signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
3515
+ } }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
3958
3516
  }
3959
- }
3960
- `;
3961
- var EmbeddedLoadingSpinner = class {
3962
- #root = null;
3963
- #eventListeners = {};
3964
- #listenersAttached = false;
3965
- dom = null;
3966
- constructor() {
3967
- this.init = this.init.bind(this);
3968
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3969
- }
3970
- async init() {
3971
- console.log("Injecting modal");
3972
- this.#injectHTML();
3973
- }
3974
- open = () => {
3975
- console.debug("Modal open");
3976
- this.#attachEventListeners();
3977
- if (this.#root) this.#root.style.display = "flex";
3978
- };
3979
- close = (event = void 0) => {
3980
- console.debug("Modal close");
3981
- this.#removeEventListeners();
3982
- if (this.#root) this.#root.style.display = "none";
3983
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
3984
- };
3985
- addEventListener(event, listener) {
3986
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3987
- return () => this.removeEventListener(event, listener);
3988
- }
3989
- removeEventListener(event, listener) {
3990
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3991
- }
3992
- #injectHTML() {
3993
- if (this.dom) return;
3994
- this.#root = document.createElement("div");
3995
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3996
- this.#root.innerHTML = modalHtml$1;
3997
- this.#root.style.display = "none";
3998
- const styles = document.createElement("style");
3999
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
4000
- styles.textContent = css$6;
4001
- const host = document.createElement("div");
4002
- this.dom = host.attachShadow({ mode: "closed" });
4003
- host.style.setProperty("--spinner-color", "#FFFFFF");
4004
- this.dom.appendChild(styles);
4005
- this.dom.appendChild(this.#root);
4006
- document.body.appendChild(host);
4007
- }
4008
- #attachEventListeners() {
4009
- if (!this.#root || this.#listenersAttached) return;
4010
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
4011
- this.close(event);
4012
- }));
4013
- window.addEventListener("load", this.close);
4014
- document.addEventListener("keydown", this.#handleKeyDown);
4015
- this.#listenersAttached = true;
4016
- }
4017
- #removeEventListeners() {
4018
- if (!this.#listenersAttached) return;
4019
- window.removeEventListener("load", this.close);
4020
- document.removeEventListener("keydown", this.#handleKeyDown);
4021
- if (!this.#root) return;
4022
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
4023
- this.#listenersAttached = false;
4024
- }
4025
- #handleKeyDown = (event) => {
4026
- if (event.key === "Escape") this.close(event);
4027
- };
4028
- };
4029
- //#endregion
4030
- //#region src/embedded-modal/modal.ts
4031
- const modalHtml = `
4032
- <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
4033
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
4034
- <div class="mobile-wallet-adapter-embedded-modal-card">
4035
- <div>
4036
- <button data-modal-close class="mobile-wallet-adapter-embedded-modal-close">
4037
- <svg width="14" height="14">
4038
- <path d="M 6.7125,8.3036995 1.9082,13.108199 c -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 C 0.1056,12.896899 0,12.631699 0,12.312499 c 0,-0.3192 0.1056,-0.5844 0.3167,-0.7958 L 5.1212,6.7124995 0.3167,1.9082 C 0.1056,1.6969 0,1.4317 0,1.1125 0,0.7933 0.1056,0.5281 0.3167,0.3167 0.5281,0.1056 0.7933,0 1.1125,0 1.4317,0 1.6969,0.1056 1.9082,0.3167 L 6.7125,5.1212 11.5167,0.3167 C 11.7281,0.1056 11.9933,0 12.3125,0 c 0.3192,0 0.5844,0.1056 0.7957,0.3167 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 L 8.3037001,6.7124995 13.1082,11.516699 c 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 z" />
4039
- </svg>
4040
- </button>
4041
- </div>
4042
- <div class="mobile-wallet-adapter-embedded-modal-content"></div>
4043
- </div>
4044
- </div>
4045
- `;
4046
- const css$5 = `
4047
- .mobile-wallet-adapter-embedded-modal-container {
4048
- display: flex; /* Use flexbox to center content */
4049
- justify-content: center; /* Center horizontally */
4050
- align-items: center; /* Center vertically */
4051
- position: fixed; /* Stay in place */
4052
- z-index: 2147483647; /* Sit on top */
4053
- left: 0;
4054
- top: 0;
4055
- width: 100%; /* Full width */
4056
- height: 100%; /* Full height */
4057
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
4058
- overflow-y: auto; /* enable scrolling */
4059
- }
4060
-
4061
- .mobile-wallet-adapter-embedded-modal-card {
4062
- display: flex;
4063
- flex-direction: column;
4064
- margin: auto 20px;
4065
- max-width: 780px;
4066
- padding: 20px;
4067
- border-radius: 24px;
4068
- background: #ffffff;
4069
- font-family: "Inter Tight", "PT Sans", Calibri, sans-serif;
4070
- transform: translateY(-200%);
4071
- animation: slide-in 0.5s forwards;
4072
- }
4073
-
4074
- @keyframes slide-in {
4075
- 100% { transform: translateY(0%); }
4076
- }
4077
-
4078
- .mobile-wallet-adapter-embedded-modal-close {
4079
- display: flex;
4080
- align-items: center;
4081
- justify-content: center;
4082
- width: 32px;
4083
- height: 32px;
4084
- cursor: pointer;
4085
- background: #e4e9e9;
4086
- border: none;
4087
- border-radius: 50%;
4088
- }
4089
-
4090
- .mobile-wallet-adapter-embedded-modal-close:focus-visible {
4091
- outline-color: red;
4092
- }
4093
-
4094
- .mobile-wallet-adapter-embedded-modal-close svg {
4095
- fill: #546266;
4096
- transition: fill 200ms ease 0s;
4097
- }
4098
-
4099
- .mobile-wallet-adapter-embedded-modal-close:hover svg {
4100
- fill: #fff;
4101
- }
4102
- `;
4103
- const fonts = `
4104
- <link rel="preconnect" href="https://fonts.googleapis.com">
4105
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
4106
- <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
4107
- `;
4108
- var EmbeddedModal = class {
4109
- #root = null;
4110
- #eventListeners = {};
4111
- #listenersAttached = false;
4112
- dom = null;
4113
- constructor() {
4114
- this.init = this.init.bind(this);
4115
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
4116
- }
4117
- async init() {
4118
- console.log("Injecting modal");
4119
- this.#injectHTML();
4120
- }
4121
- open = () => {
4122
- console.debug("Modal open");
4123
- this.#attachEventListeners();
4124
- if (this.#root) this.#root.style.display = "flex";
4125
- };
4126
- close = (event = void 0) => {
4127
- console.debug("Modal close");
4128
- this.#removeEventListeners();
4129
- if (this.#root) this.#root.style.display = "none";
4130
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
4131
- };
4132
- addEventListener(event, listener) {
4133
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
4134
- return () => this.removeEventListener(event, listener);
4135
- }
4136
- removeEventListener(event, listener) {
4137
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
4138
- }
4139
- #injectHTML() {
4140
- if (document.getElementById("mobile-wallet-adapter-embedded-root-ui")) {
4141
- if (!this.#root) this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
4142
- return;
4143
- }
4144
- this.#root = document.createElement("div");
4145
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
4146
- this.#root.innerHTML = modalHtml;
4147
- this.#root.style.display = "none";
4148
- const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
4149
- if (content) content.innerHTML = this.contentHtml;
4150
- const styles = document.createElement("style");
4151
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
4152
- styles.textContent = css$5 + this.contentStyles;
4153
- const host = document.createElement("div");
4154
- host.innerHTML = fonts;
4155
- this.dom = host.attachShadow({ mode: "closed" });
4156
- this.dom.appendChild(styles);
4157
- this.dom.appendChild(this.#root);
4158
- document.body.appendChild(host);
4159
- }
4160
- #attachEventListeners() {
4161
- if (!this.#root || this.#listenersAttached) return;
4162
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", this.close));
4163
- window.addEventListener("load", this.close);
4164
- document.addEventListener("keydown", this.#handleKeyDown);
4165
- this.#listenersAttached = true;
4166
- }
4167
- #removeEventListeners() {
4168
- if (!this.#listenersAttached) return;
4169
- window.removeEventListener("load", this.close);
4170
- document.removeEventListener("keydown", this.#handleKeyDown);
4171
- if (!this.#root) return;
4172
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
4173
- this.#listenersAttached = false;
4174
- }
4175
- #handleKeyDown = (event) => {
4176
- if (event.key === "Escape") this.close(event);
4177
- };
4178
- };
4179
- //#endregion
4180
- //#region src/embedded-modal/localConnectionModal.ts
4181
- var LocalConnectionModal = class extends EmbeddedModal {
4182
- contentStyles = css$3;
4183
- contentHtml = ErrorDialogHtml$3;
4184
- initWithCallback(callback) {
4185
- super.init();
4186
- this.#prepareLaunchAction(callback);
4187
- }
4188
- #prepareLaunchAction(callback) {
4189
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4190
- const listener = async () => {
4191
- launchButton?.removeEventListener("click", listener);
4192
- this.close();
4193
- callback();
4194
- };
4195
- launchButton?.addEventListener("click", listener);
4196
- }
4197
- };
4198
- const ErrorDialogHtml$3 = `
4199
- <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">
4200
- <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"/>
4201
- <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4202
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4203
- </mask>
4204
- <g mask="url(#mask0_189_522)">
4205
- <mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4206
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4207
- </mask>
4208
- <g mask="url(#mask1_189_522)">
4209
- <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"/>
4210
- </g>
4211
- </g>
4212
- </svg>
4213
- <div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
4214
- <div>
4215
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4216
- Connect Wallet
4217
- </button>
4218
- </div>
4219
- `;
4220
- const css$3 = `
4221
- .mobile-wallet-adapter-embedded-modal-close {
4222
- display: none;
4223
- }
4224
- .mobile-wallet-adapter-embedded-modal-content {
4225
- text-align: center;
4226
- min-width: 300px;
4227
- }
4228
- .mobile-wallet-adapter-embedded-modal-launch-icon {
4229
- margin-top: 24px;
4230
- }
4231
- .mobile-wallet-adapter-embedded-modal-title {
4232
- margin: 18px 100px 30px 100px;
4233
- color: #000000;
4234
- font-size: 2.75em;
4235
- font-weight: 600;
4236
- }
4237
- .mobile-wallet-adapter-embedded-modal-launch-action {
4238
- display: block;
4239
- width: 100%;
4240
- height: 56px;
4241
- font-size: 1.25em;
4242
- background: #000000;
4243
- color: #FFFFFF;
4244
- border-radius: 18px;
4245
- }
4246
- /* Smaller screens */
4247
- @media all and (max-width: 600px) {
4248
- .mobile-wallet-adapter-embedded-modal-title {
4249
- font-size: 1.5em;
4250
- margin-right: 12px;
4251
- margin-left: 12px;
3517
+ get accounts() {
3518
+ var _a, _b;
3519
+ return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4252
3520
  }
4253
- }
4254
- `;
4255
- //#endregion
4256
- //#region src/embedded-modal/loopbackBlockedModal.ts
4257
- var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
4258
- contentStyles = css$2;
4259
- get contentHtml() {
4260
- 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";
4261
- return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
4262
- }
4263
- async init() {
4264
- super.init();
4265
- this.#prepareLaunchAction();
4266
- }
4267
- #prepareLaunchAction() {
4268
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4269
- const listener = async (event) => {
4270
- launchButton?.removeEventListener("click", listener);
4271
- this.close(event);
4272
- };
4273
- launchButton?.addEventListener("click", listener);
4274
- }
4275
- };
4276
- const ErrorDialogHtml$2 = `
4277
- <div class="mobile-wallet-adapter-embedded-modal-header">
4278
- Local Wallet Connection
4279
- </div>
4280
- <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
4281
- <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"/>
4282
- <mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
4283
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
4284
- </mask>
4285
- <g mask="url(#mask0_147_1364)">
4286
- <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"/>
4287
- </g>
4288
- </svg>
4289
- <div class="mobile-wallet-adapter-embedded-modal-title">
4290
- Your wallet connection is blocked
4291
- </div>
4292
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4293
- Visit site settings in the address bar and allow "Apps on Device".
4294
- </div>
4295
-
4296
- <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
4297
- <div class="mobile-wallet-adapter-embedded-modal-footer">
4298
- <div class="mobile-wallet-adapter-embedded-modal-details">
4299
- <!-- Clickable header (label associated with the checkbox) -->
4300
- <label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
4301
- <!-- Hidden checkbox to track state -->
4302
- <input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
4303
- <span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
4304
- See details
4305
- </span>
4306
- <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">
4307
- <mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
4308
- <rect width="24" height="24" fill="#D9D9D9"/>
4309
- </mask>
4310
- <g mask="url(#mask0_147_1382)">
4311
- <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"/>
4312
- </g>
4313
- </svg>
4314
- </label>
4315
-
4316
- <!-- Content to show/hide -->
4317
- <ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
4318
- <li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
4319
- <li>Allow "Apps on Device"</li>
4320
- </ul>
4321
- </div>
4322
- </div>
4323
- <div>
4324
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4325
- Got it
4326
- </button>
4327
- </div>
4328
- `;
4329
- const css$2 = `
4330
- .mobile-wallet-adapter-embedded-modal-close {
4331
- display: none;
4332
- }
4333
- .mobile-wallet-adapter-embedded-modal-content {
4334
- text-align: center;
4335
- }
4336
- .mobile-wallet-adapter-embedded-modal-header {
4337
- margin: 18px auto 30px auto;
4338
- color: #7D9093;
4339
- font-size: 1.0em;
4340
- font-weight: 500;
4341
- }
4342
- .mobile-wallet-adapter-embedded-modal-title {
4343
- margin: 18px 100px auto 100px;
4344
- color: #000000;
4345
- font-size: 2.75em;
4346
- font-weight: 600;
4347
- }
4348
- .mobile-wallet-adapter-embedded-modal-subtitle {
4349
- margin: 12px 60px 30px 60px;
4350
- color: #7D9093;
4351
- font-size: 1.25em;
4352
- font-weight: 400;
4353
- }
4354
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header {
4355
- display: flex;
4356
- flex-direction: row;
4357
- justify-content: space-between;
4358
- margin: 10px auto 10px auto;
4359
- color: #000000;
4360
- font-size: 1.5em;
4361
- font-weight: 600;
4362
- cursor: pointer; /* Show pointer on hover */
4363
- transition: background 0.2s ease; /* Smooth background change */
4364
- }
4365
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4366
- transition: rotate 0.3s ease;
4367
- }
4368
- .mobile-wallet-adapter-embedded-modal-details-collapsible-input {
4369
- display: none; /* Hide the checkbox */
4370
- }
4371
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4372
- margin: 0px auto 40px auto;
4373
- max-height: 0px; /* Collapse content */
4374
- overflow: hidden; /* Hide overflow when collapsed */
4375
- transition: max-height 0.3s ease; /* Smooth transition */
4376
- }
4377
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
4378
- margin: 20px auto;
4379
- color: #000000;
4380
- font-size: 1.25em;
4381
- font-weight: 400;
4382
- text-align: left;
4383
- }
4384
- /* When checkbox is checked, show content */
4385
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4386
- max-height: 300px;
4387
- }
4388
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4389
- rotate: 180deg;
4390
- }
4391
- .mobile-wallet-adapter-embedded-modal-launch-action {
4392
- display: block;
4393
- width: 100%;
4394
- height: 56px;
4395
- /*margin-top: 40px;*/
4396
- font-size: 1.25em;
4397
- /*line-height: 24px;*/
4398
- /*letter-spacing: -1%;*/
4399
- background: #000000;
4400
- color: #FFFFFF;
4401
- border-radius: 18px;
4402
- }
4403
- /* Smaller screens */
4404
- @media all and (max-width: 600px) {
4405
- .mobile-wallet-adapter-embedded-modal-title {
4406
- font-size: 1.75em;
4407
- margin-right: 12px;
4408
- margin-left: 12px;
3521
+ get connected() {
3522
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4409
3523
  }
4410
- .mobile-wallet-adapter-embedded-modal-subtitle {
4411
- margin-right: 12px;
4412
- margin-left: 12px;
3524
+ get isAuthorized() {
3525
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4413
3526
  }
4414
- }
4415
- `;
4416
- //#endregion
4417
- //#region src/embedded-modal/loopbackPermissionModal.ts
4418
- var LoopbackPermissionModal = class extends EmbeddedModal {
4419
- contentStyles = css$1;
4420
- contentHtml = ErrorDialogHtml$1;
4421
- async init() {
4422
- super.init();
4423
- this.#prepareLaunchAction();
4424
- }
4425
- #prepareLaunchAction() {
4426
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4427
- const listener = async () => {
4428
- launchButton?.removeEventListener("click", listener);
4429
- try {
4430
- await fetch("http://localhost");
4431
- } catch {}
4432
- this.close();
4433
- };
4434
- launchButton?.addEventListener("click", listener);
4435
- }
4436
- };
4437
- const ErrorDialogHtml$1 = `
4438
- <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
4439
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4440
- Tap "Allow" on the next screen
4441
- </div>
4442
- <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">
4443
- <rect width="281" height="83" rx="22" fill="#F0F3F5"/>
4444
- <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"/>
4445
- <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"/>
4446
- <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"/>
4447
- <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"/>
4448
- <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"/>
4449
- <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"/>
4450
- <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"/>
4451
- <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"/>
4452
- <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"/>
4453
- <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"/>
4454
- <rect x="18" y="17" width="246" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4455
- <rect x="18" y="33" width="82" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4456
- </svg>
4457
- <div>
4458
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4459
- Continue to Allow
4460
- </button>
4461
- </div>
4462
- `;
4463
- const css$1 = `
4464
- .mobile-wallet-adapter-embedded-modal-close {
4465
- display: none;
4466
- }
4467
- .mobile-wallet-adapter-embedded-modal-content {
4468
- text-align: center;
4469
- }
4470
- .mobile-wallet-adapter-embedded-modal-title {
4471
- margin: 18px 100px auto 100px;
4472
- color: #000000;
4473
- font-size: 2.75em;
4474
- font-weight: 600;
4475
- }
4476
- .mobile-wallet-adapter-embedded-modal-subtitle {
4477
- margin: 20px 60px 40px 60px;
4478
- color: #7D9093;
4479
- font-size: 1.25em;
4480
- font-weight: 400;
4481
- }
4482
- .mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
4483
- width: 90%;
4484
- height: auto;
4485
- margin: 0 auto 30px auto;
4486
- display: block;
4487
- }
4488
- .mobile-wallet-adapter-embedded-modal-launch-action {
4489
- display: block;
4490
- width: 100%;
4491
- height: 56px;
4492
- font-size: 1.25em;
4493
- background: #000000;
4494
- color: #FFFFFF;
4495
- border-radius: 18px;
4496
- }
4497
- /* Smaller screens */
4498
- @media all and (max-width: 600px) {
4499
- .mobile-wallet-adapter-embedded-modal-title {
4500
- font-size: 1.5em;
4501
- margin-right: 12px;
4502
- margin-left: 12px;
3527
+ get currentAuthorization() {
3528
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4503
3529
  }
4504
- .mobile-wallet-adapter-embedded-modal-subtitle {
4505
- margin-right: 12px;
4506
- margin-left: 12px;
3530
+ get cachedAuthorizationResult() {
3531
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4507
3532
  }
4508
3533
  }
4509
- `;
4510
- function isSolanaMobileWebShell(userAgentString) {
4511
- return userAgentString.includes("Solana Mobile Web Shell");
4512
- }
4513
- function getIsPwaLaunchedAsApp() {
4514
- const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
4515
- if (typeof window == "undefined") return isAndroidTwa;
4516
- const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
4517
- const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
4518
- const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
4519
- return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
4520
- }
4521
- async function checkLocalNetworkAccessPermission() {
4522
- if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
4523
- try {
4524
- const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
4525
- if (lnaPermission.state === "granted") return;
4526
- else if (lnaPermission.state === "denied") {
4527
- const modal = new LoopbackPermissionBlockedModal();
4528
- modal.init();
4529
- modal.open();
4530
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
4531
- } else if (lnaPermission.state === "prompt") {
4532
- const modal = new LoopbackPermissionModal();
4533
- if (await new Promise((resolve, reject) => {
4534
- modal.addEventListener("close", (event) => {
4535
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4536
- });
4537
- lnaPermission.onchange = () => {
4538
- lnaPermission.onchange = null;
4539
- resolve(lnaPermission.state);
4540
- };
4541
- modal.init();
4542
- modal.open();
4543
- }) === "granted") {
4544
- const modal = new LocalConnectionModal();
4545
- await new Promise((resolve, reject) => {
4546
- modal.addEventListener("close", (event) => {
4547
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4548
- });
4549
- modal.initWithCallback(async () => {
4550
- resolve(true);
4551
- });
4552
- modal.open();
4553
- });
4554
- return;
4555
- } else return await checkLocalNetworkAccessPermission();
4556
- }
4557
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
4558
- } catch (e) {
4559
- if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
4560
- if (e instanceof SolanaMobileWalletAdapterError) throw e;
4561
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
4562
- }
4563
- }
4564
- //#endregion
4565
- //#region src/icon.ts
4566
- const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
4567
- //#endregion
4568
- //#region src/wallet.ts
4569
- const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
4570
- const SIGNATURE_LENGTH_IN_BYTES = 64;
4571
- const DEFAULT_FEATURES = [
4572
- SolanaSignAndSendTransaction,
4573
- SolanaSignTransaction,
4574
- SolanaSignMessage,
4575
- SolanaSignIn
4576
- ];
4577
- const WALLET_ASSOCIATION_TIMEOUT = 3e4;
4578
- function getErrorMessage(error) {
4579
- return error instanceof Error ? error.message : "Unknown error";
4580
- }
4581
- var LocalSolanaMobileWalletAdapterWallet = class {
4582
- #listeners = {};
4583
- #version = "1.0.0";
4584
- #name = SolanaMobileWalletAdapterWalletName;
4585
- #url = "https://solanamobile.com/wallets";
4586
- #icon = icon;
4587
- #appIdentity;
4588
- #authorization;
4589
- #authorizationCache;
4590
- #connecting = false;
4591
- /**
4592
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4593
- * increment this and use it to make sure that `transact` calls from the previous
4594
- * 'generation' don't continue to do work and throw exceptions.
4595
- */
4596
- #connectionGeneration = 0;
4597
- #chains = [];
4598
- #chainSelector;
4599
- #optionalFeatures;
4600
- #onWalletNotFound;
4601
- get version() {
4602
- return this.#version;
4603
- }
4604
- get name() {
4605
- return this.#name;
4606
- }
4607
- get url() {
4608
- return this.#url;
4609
- }
4610
- get icon() {
4611
- return this.#icon;
4612
- }
4613
- get chains() {
4614
- return this.#chains;
4615
- }
4616
- get features() {
4617
- return {
4618
- [StandardConnect]: {
4619
- version: "1.0.0",
4620
- connect: this.#connect
4621
- },
4622
- [StandardDisconnect]: {
4623
- version: "1.0.0",
4624
- disconnect: this.#disconnect
4625
- },
4626
- [StandardEvents]: {
4627
- version: "1.0.0",
4628
- on: this.#on
4629
- },
4630
- [SolanaSignMessage]: {
4631
- version: "1.0.0",
4632
- signMessage: this.#signMessage
4633
- },
4634
- [SolanaSignIn]: {
4635
- version: "1.0.0",
4636
- signIn: this.#signIn
4637
- },
4638
- ...this.#optionalFeatures
4639
- };
4640
- }
4641
- get accounts() {
4642
- return this.#authorization?.accounts ?? [];
4643
- }
4644
- constructor(config) {
4645
- this.#authorizationCache = config.authorizationCache;
4646
- this.#appIdentity = config.appIdentity;
4647
- this.#chains = config.chains;
4648
- this.#chainSelector = config.chainSelector;
4649
- this.#onWalletNotFound = config.onWalletNotFound;
4650
- this.#optionalFeatures = {
4651
- [SolanaSignAndSendTransaction]: {
4652
- version: "1.0.0",
4653
- supportedTransactionVersions: ["legacy", 0],
4654
- signAndSendTransaction: this.#signAndSendTransaction
4655
- },
4656
- [SolanaSignTransaction]: {
4657
- version: "1.0.0",
4658
- supportedTransactionVersions: ["legacy", 0],
4659
- signTransaction: this.#signTransaction
4660
- }
4661
- };
4662
- }
4663
- get connected() {
4664
- return !!this.#authorization;
4665
- }
4666
- get isAuthorized() {
4667
- return !!this.#authorization;
4668
- }
4669
- get currentAuthorization() {
4670
- return this.#authorization;
4671
- }
4672
- get cachedAuthorizationResult() {
4673
- return this.#authorizationCache.get();
4674
- }
4675
- #on = (event, listener) => {
4676
- this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4677
- return () => this.#off(event, listener);
4678
- };
4679
- #emit(event, ...args) {
4680
- this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4681
- }
4682
- #off(event, listener) {
4683
- this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4684
- }
4685
- #connect = async ({ silent } = {}) => {
4686
- if (this.#connecting || this.connected) return { accounts: this.accounts };
4687
- this.#connecting = true;
4688
- try {
4689
- if (silent) {
4690
- const cachedAuthorization = await this.#authorizationCache.get();
4691
- if (cachedAuthorization) {
4692
- await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
4693
- await this.#handleAuthorizationResult(cachedAuthorization);
4694
- } else return { accounts: this.accounts };
4695
- } else await this.#performAuthorization();
4696
- } catch (e) {
4697
- throw new Error(getErrorMessage(e), { cause: e });
4698
- } finally {
4699
- this.#connecting = false;
4700
- }
4701
- return { accounts: this.accounts };
4702
- };
4703
- #performAuthorization = async (signInPayload) => {
4704
- try {
4705
- const cachedAuthorizationResult = await this.#authorizationCache.get();
4706
- if (cachedAuthorizationResult) {
4707
- this.#handleAuthorizationResult(cachedAuthorizationResult);
4708
- return cachedAuthorizationResult;
4709
- }
4710
- const selectedChain = await this.#chainSelector.select(this.#chains);
4711
- return await this.#transact(async (wallet) => {
4712
- const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4713
- chain: selectedChain,
4714
- identity: this.#appIdentity,
4715
- sign_in_payload: signInPayload
4716
- })]);
4717
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4718
- const authorization = {
4719
- ...mwaAuthorizationResult,
4720
- accounts,
4721
- chain: selectedChain,
4722
- capabilities
4723
- };
4724
- Promise.all([
4725
- this.#handleWalletCapabilitiesResult(capabilities),
4726
- this.#authorizationCache.set(authorization),
4727
- this.#handleAuthorizationResult(authorization)
4728
- ]);
4729
- return authorization;
4730
- });
4731
- } catch (e) {
4732
- throw new Error(getErrorMessage(e), { cause: e });
4733
- }
4734
- };
4735
- #handleAuthorizationResult = async (authorization) => {
4736
- const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4737
- this.#authorization = authorization;
4738
- if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4739
- };
4740
- #handleWalletCapabilitiesResult = async (capabilities) => {
4741
- const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4742
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
4743
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4744
- this.#optionalFeatures = {
4745
- ...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
4746
- version: "1.0.0",
4747
- supportedTransactionVersions: ["legacy", 0],
4748
- signAndSendTransaction: this.#signAndSendTransaction
4749
- } },
4750
- ...supportsSignTransaction && { [SolanaSignTransaction]: {
4751
- version: "1.0.0",
4752
- supportedTransactionVersions: ["legacy", 0],
4753
- signTransaction: this.#signTransaction
4754
- } }
4755
- };
4756
- if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4757
- };
4758
- #performReauthorization = async (wallet, authToken, chain) => {
4759
- try {
4760
- const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4761
- auth_token: authToken,
4762
- identity: this.#appIdentity,
4763
- chain
4764
- })]);
4765
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4766
- const authorization = {
4767
- ...mwaAuthorizationResult,
4768
- accounts,
4769
- chain,
4770
- capabilities
4771
- };
4772
- Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4773
- } catch (e) {
4774
- this.#disconnect();
4775
- throw new Error(getErrorMessage(e), { cause: e });
4776
- }
4777
- };
4778
- #disconnect = async () => {
4779
- this.#authorizationCache.clear();
4780
- this.#connecting = false;
4781
- this.#connectionGeneration++;
4782
- this.#authorization = void 0;
4783
- this.#emit("change", { accounts: this.accounts });
4784
- };
4785
- #transact = async (callback) => {
4786
- const walletUriBase = this.#authorization?.wallet_uri_base;
4787
- const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
4788
- const currentConnectionGeneration = this.#connectionGeneration;
4789
- const loadingSpinner = new EmbeddedLoadingSpinner();
4790
- try {
4791
- let associating = true;
4792
- let timeout = void 0;
4793
- const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
4794
- loadingSpinner.init();
4795
- const { wallet, close } = await startScenario(config);
4796
- associating = false;
4797
- loadingSpinner.addEventListener("close", (event) => {
4798
- if (event) close();
4799
- });
4800
- loadingSpinner.open();
4801
- const result = await callback(await wallet);
4802
- loadingSpinner.close();
4803
- close();
4804
- return result;
4805
- }), new Promise((_, reject) => {
4806
- timeout = setTimeout(() => {
4807
- if (associating) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
4808
- }, WALLET_ASSOCIATION_TIMEOUT);
4809
- })]);
4810
- clearTimeout(timeout);
4811
- return result;
4812
- } catch (e) {
4813
- loadingSpinner.close();
4814
- if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4815
- if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4816
- throw e;
4817
- }
4818
- };
4819
- #assertIsAuthorized = () => {
4820
- if (!this.#authorization) throw new Error("Wallet not connected");
4821
- return {
4822
- authToken: this.#authorization.auth_token,
4823
- chain: this.#authorization.chain
4824
- };
4825
- };
4826
- #accountsToWalletStandardAccounts = (accounts) => {
4827
- return accounts.map((account) => {
4828
- const publicKey = toUint8Array(account.address);
4829
- return {
4830
- address: base58.encode(publicKey),
4831
- publicKey,
4832
- label: account.label,
4833
- icon: account.icon,
4834
- chains: account.chains ?? this.#chains,
4835
- features: account.features ?? DEFAULT_FEATURES
4836
- };
4837
- });
4838
- };
4839
- #performSignTransactions = async (transactions) => {
4840
- const { authToken, chain } = this.#assertIsAuthorized();
4841
- try {
4842
- const base64Transactions = transactions.map((tx) => {
4843
- return fromUint8Array(tx);
4844
- });
4845
- return await this.#transact(async (wallet) => {
4846
- await this.#performReauthorization(wallet, authToken, chain);
4847
- return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
4848
- });
4849
- } catch (e) {
4850
- throw new Error(getErrorMessage(e), { cause: e });
4851
- }
4852
- };
4853
- #performSignAndSendTransaction = async (transaction, options) => {
4854
- const { authToken, chain } = this.#assertIsAuthorized();
4855
- try {
4856
- return await this.#transact(async (wallet) => {
4857
- const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4858
- if (capabilities.supports_sign_and_send_transactions) {
4859
- const base64Transaction = fromUint8Array(transaction);
4860
- return (await wallet.signAndSendTransactions({
4861
- ...options,
4862
- payloads: [base64Transaction]
4863
- })).signatures.map(toUint8Array)[0];
4864
- } else throw new Error("connected wallet does not support signAndSendTransaction");
4865
- });
4866
- } catch (e) {
4867
- throw new Error(getErrorMessage(e), { cause: e });
4868
- }
4869
- };
4870
- #signAndSendTransaction = async (...inputs) => {
4871
- const outputs = [];
4872
- for (const input of inputs) {
4873
- const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4874
- outputs.push({ signature });
4875
- }
4876
- return outputs;
4877
- };
4878
- #signTransaction = async (...inputs) => {
4879
- return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4880
- return { signedTransaction };
4881
- });
4882
- };
4883
- #signMessage = async (...inputs) => {
4884
- const { authToken, chain } = this.#assertIsAuthorized();
4885
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4886
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4887
- try {
4888
- return await this.#transact(async (wallet) => {
4889
- await this.#performReauthorization(wallet, authToken, chain);
4890
- return (await wallet.signMessages({
4891
- addresses,
4892
- payloads: messages
4893
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4894
- return {
4895
- signedMessage,
4896
- signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4897
- };
4898
- });
4899
- });
4900
- } catch (e) {
4901
- throw new Error(getErrorMessage(e), { cause: e });
4902
- }
4903
- };
4904
- #signIn = async (...inputs) => {
4905
- const outputs = [];
4906
- if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4907
- else return [await this.#performSignIn(inputs[0])];
4908
- return outputs;
4909
- };
4910
- #performSignIn = async (input) => {
4911
- this.#connecting = true;
4912
- try {
4913
- const authorizationResult = await this.#performAuthorization({
4914
- ...input,
4915
- domain: input?.domain ?? window.location.host
4916
- });
4917
- if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4918
- const signedInAddress = authorizationResult.sign_in_result.address;
4919
- const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4920
- return {
4921
- account: {
4922
- ...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
4923
- publicKey: toUint8Array(signedInAddress),
4924
- chains: signedInAccount?.chains ?? this.#chains,
4925
- features: signedInAccount?.features ?? authorizationResult.capabilities.features
4926
- },
4927
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4928
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4929
- };
4930
- } catch (e) {
4931
- throw new Error(getErrorMessage(e), { cause: e });
4932
- } finally {
4933
- this.#connecting = false;
4934
- }
4935
- };
3534
+ _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) {
3535
+ var _a;
3536
+ // eslint-disable-next-line prefer-spread
3537
+ (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
3538
+ }, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
3539
+ var _a;
3540
+ __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);
4936
3541
  };
4937
- //#endregion
4938
- //#region src/createDefaultAuthorizationCache.ts
4939
- const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
3542
+
3543
+ const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
4940
3544
  function createDefaultAuthorizationCache() {
4941
- let storage;
4942
- try {
4943
- storage = window.localStorage;
4944
- } catch {}
4945
- return {
4946
- async clear() {
4947
- if (!storage) return;
4948
- try {
4949
- storage.removeItem(CACHE_KEY);
4950
- } catch {}
4951
- },
4952
- async get() {
4953
- if (!storage) return;
4954
- try {
4955
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
4956
- if (parsed && parsed.accounts) {
4957
- const parsedAccounts = parsed.accounts.map((account) => {
4958
- return {
4959
- ...account,
4960
- publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : base58.decode(account.address)
4961
- };
4962
- });
4963
- return {
4964
- ...parsed,
4965
- accounts: parsedAccounts
4966
- };
4967
- } else return parsed || void 0;
4968
- } catch {}
4969
- },
4970
- async set(authorization) {
4971
- if (!storage) return;
4972
- try {
4973
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
4974
- } catch {}
4975
- }
4976
- };
3545
+ let storage;
3546
+ try {
3547
+ storage = window.localStorage;
3548
+ // eslint-disable-next-line no-empty
3549
+ }
3550
+ catch (_a) { }
3551
+ return {
3552
+ clear() {
3553
+ return __awaiter(this, void 0, void 0, function* () {
3554
+ if (!storage) {
3555
+ return;
3556
+ }
3557
+ try {
3558
+ storage.removeItem(CACHE_KEY);
3559
+ // eslint-disable-next-line no-empty
3560
+ }
3561
+ catch (_a) { }
3562
+ });
3563
+ },
3564
+ get() {
3565
+ return __awaiter(this, void 0, void 0, function* () {
3566
+ if (!storage) {
3567
+ return;
3568
+ }
3569
+ try {
3570
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
3571
+ if (parsed && parsed.accounts) {
3572
+ const parsedAccounts = parsed.accounts.map((account) => {
3573
+ return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
3574
+ ? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
3575
+ : base58.decode(account.address) });
3576
+ });
3577
+ return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
3578
+ }
3579
+ else
3580
+ return parsed || undefined;
3581
+ // eslint-disable-next-line no-empty
3582
+ }
3583
+ catch (_a) { }
3584
+ });
3585
+ },
3586
+ set(authorization) {
3587
+ return __awaiter(this, void 0, void 0, function* () {
3588
+ if (!storage) {
3589
+ return;
3590
+ }
3591
+ try {
3592
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
3593
+ // eslint-disable-next-line no-empty
3594
+ }
3595
+ catch (_a) { }
3596
+ });
3597
+ },
3598
+ };
4977
3599
  }
4978
- //#endregion
4979
- //#region src/createDefaultChainSelector.ts
3600
+
4980
3601
  function createDefaultChainSelector() {
4981
- return { async select(chains) {
4982
- if (chains.length === 1) return chains[0];
4983
- else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
4984
- else return chains[0];
4985
- } };
3602
+ return {
3603
+ select(chains) {
3604
+ return __awaiter(this, void 0, void 0, function* () {
3605
+ if (chains.length === 1) {
3606
+ return chains[0];
3607
+ }
3608
+ else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
3609
+ return SOLANA_MAINNET_CHAIN;
3610
+ }
3611
+ else
3612
+ return chains[0];
3613
+ });
3614
+ },
3615
+ };
4986
3616
  }
4987
3617
 
4988
3618
  export { LocalSolanaMobileWalletAdapterWallet, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationCache, createDefaultChainSelector };
4989
- //# sourceMappingURL=index.browser-DQqKPfDA.esm.js.map
3619
+ //# sourceMappingURL=index.browser-CGZvkfTO.esm.js.map