@pooflabs/web 0.0.80 → 0.0.81-rc2

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 (82) hide show
  1. package/dist/auth/providers/phantom-wallet-provider.d.ts +20 -0
  2. package/dist/index-Bdcc5821.js +2375 -0
  3. package/dist/index-Bdcc5821.js.map +1 -0
  4. package/dist/{index-BhfNMrC0.js → index-BjlCinic.js} +25 -883
  5. package/dist/index-BjlCinic.js.map +1 -0
  6. package/dist/{index-Db0NqU8R.esm.js → index-Bx_lLXRT.esm.js} +342 -277
  7. package/dist/index-Bx_lLXRT.esm.js.map +1 -0
  8. package/dist/{index-COIUWugk.esm.js → index-CHqM9n4K.esm.js} +24 -881
  9. package/dist/index-CHqM9n4K.esm.js.map +1 -0
  10. package/dist/{index-BVi7fTm2.js → index-CL4JIAAR.js} +24 -882
  11. package/dist/index-CL4JIAAR.js.map +1 -0
  12. package/dist/index-CrOVJFX9.esm.js +2373 -0
  13. package/dist/index-CrOVJFX9.esm.js.map +1 -0
  14. package/dist/{index-BbtYb8sE.esm.js → index-DCo85UGg.esm.js} +23 -882
  15. package/dist/index-DCo85UGg.esm.js.map +1 -0
  16. package/dist/{index-BNyxZ82q.js → index-DHm4usay.js} +342 -276
  17. package/dist/index-DHm4usay.js.map +1 -0
  18. package/dist/{index.browser-BuHl80dp.esm.js → index.browser-7dDfRU5G.esm.js} +1367 -1697
  19. package/dist/index.browser-7dDfRU5G.esm.js.map +1 -0
  20. package/dist/index.browser-Bg_-PAgT.esm.js +1250 -0
  21. package/dist/index.browser-Bg_-PAgT.esm.js.map +1 -0
  22. package/dist/index.browser-C-_FEr5M.esm.js +1134 -0
  23. package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
  24. package/dist/{index.browser-8hyi2LOX.js → index.browser-CmlqbyPr.js} +1367 -1697
  25. package/dist/index.browser-CmlqbyPr.js.map +1 -0
  26. package/dist/index.browser-CxXQ2RhF.js +122 -0
  27. package/dist/index.browser-CxXQ2RhF.js.map +1 -0
  28. package/dist/index.browser-DjEZSiqI.js +1137 -0
  29. package/dist/index.browser-DjEZSiqI.js.map +1 -0
  30. package/dist/index.browser-DuVkpEzB.js +1253 -0
  31. package/dist/index.browser-DuVkpEzB.js.map +1 -0
  32. package/dist/index.browser-xJkO73vw.esm.js +119 -0
  33. package/dist/index.browser-xJkO73vw.esm.js.map +1 -0
  34. package/dist/index.esm.js +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/{index.native-DUnE51Mx.js → index.native-DJA9_K3i.js} +186 -2669
  37. package/dist/index.native-DJA9_K3i.js.map +1 -0
  38. package/dist/{index.native-DuKhZcus.esm.js → index.native-TLhfXfe6.esm.js} +187 -2669
  39. package/dist/index.native-TLhfXfe6.esm.js.map +1 -0
  40. package/dist/index.native.esm.js +1 -1
  41. package/dist/index.native.js +1 -1
  42. package/dist/{phantom-wallet-provider-Cg-srwP4.js → phantom-wallet-provider-BegJFoWW.js} +141 -12
  43. package/dist/{phantom-wallet-provider-Cg-srwP4.js.map → phantom-wallet-provider-BegJFoWW.js.map} +1 -1
  44. package/dist/{phantom-wallet-provider--BJjVUA1.esm.js → phantom-wallet-provider-DzUAMhbm.esm.js} +141 -12
  45. package/dist/{phantom-wallet-provider--BJjVUA1.esm.js.map → phantom-wallet-provider-DzUAMhbm.esm.js.map} +1 -1
  46. package/dist/{privy-wallet-provider-BLcur3Ue.esm.js → privy-wallet-provider-BspbiyOr.esm.js} +3 -3
  47. package/dist/privy-wallet-provider-BspbiyOr.esm.js.map +1 -0
  48. package/dist/{privy-wallet-provider-DpNVyaXa.js → privy-wallet-provider-Du-QHaaG.js} +3 -3
  49. package/dist/privy-wallet-provider-Du-QHaaG.js.map +1 -0
  50. package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js → solana-mobile-wallet-provider-Bh7SBFpQ.esm.js} +53 -4
  51. package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js.map → solana-mobile-wallet-provider-Bh7SBFpQ.esm.js.map} +1 -1
  52. package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js → solana-mobile-wallet-provider-DPp4SYem.js} +53 -4
  53. package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js.map → solana-mobile-wallet-provider-DPp4SYem.js.map} +1 -1
  54. package/package.json +1 -1
  55. package/dist/index-BNyxZ82q.js.map +0 -1
  56. package/dist/index-BVi7fTm2.js.map +0 -1
  57. package/dist/index-BbtYb8sE.esm.js.map +0 -1
  58. package/dist/index-BhfNMrC0.js.map +0 -1
  59. package/dist/index-CKIoDkjJ.esm.js +0 -6
  60. package/dist/index-CKIoDkjJ.esm.js.map +0 -1
  61. package/dist/index-COIUWugk.esm.js.map +0 -1
  62. package/dist/index-CSraUgD6.js +0 -8
  63. package/dist/index-CSraUgD6.js.map +0 -1
  64. package/dist/index-Db0NqU8R.esm.js.map +0 -1
  65. package/dist/index.browser-8hyi2LOX.js.map +0 -1
  66. package/dist/index.browser-B4zXnffD.esm.js +0 -225
  67. package/dist/index.browser-B4zXnffD.esm.js.map +0 -1
  68. package/dist/index.browser-BJ_TdUVA.js +0 -228
  69. package/dist/index.browser-BJ_TdUVA.js.map +0 -1
  70. package/dist/index.browser-BkNaRRVe.js +0 -1222
  71. package/dist/index.browser-BkNaRRVe.js.map +0 -1
  72. package/dist/index.browser-BuHl80dp.esm.js.map +0 -1
  73. package/dist/index.browser-CnbxBj3-.esm.js +0 -1219
  74. package/dist/index.browser-CnbxBj3-.esm.js.map +0 -1
  75. package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
  76. package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
  77. package/dist/index.browser-vuTr40so.js +0 -1008
  78. package/dist/index.browser-vuTr40so.js.map +0 -1
  79. package/dist/index.native-DUnE51Mx.js.map +0 -1
  80. package/dist/index.native-DuKhZcus.esm.js.map +0 -1
  81. package/dist/privy-wallet-provider-BLcur3Ue.esm.js.map +0 -1
  82. package/dist/privy-wallet-provider-DpNVyaXa.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { a as startScenario, S as SolanaMobileWalletAdapterError, b as SolanaMobileWalletAdapterErrorCode, s as startRemoteScenario } from './index.browser-OvGNsMPu.esm.js';
2
- import { g as getDefaultExportFromCjs } from './index-Db0NqU8R.esm.js';
1
+ import { g as getDefaultExportFromCjs } from './index-Bx_lLXRT.esm.js';
2
+ import { s as startRemoteScenario, t as transact } from './index.browser-C-_FEr5M.esm.js';
3
3
  import 'axios';
4
4
  import '@solana/web3.js';
5
5
  import '@coral-xyz/anchor';
@@ -20,142 +20,6 @@ const SolanaSignMessage = 'solana:signMessage';
20
20
  /** Name of the feature. */
21
21
  const SolanaSignTransaction = 'solana:signTransaction';
22
22
 
23
- /** Name of the feature. */
24
- const StandardConnect = 'standard:connect';
25
-
26
- /** Name of the feature. */
27
- const StandardDisconnect = 'standard:disconnect';
28
-
29
- /** Name of the feature. */
30
- const StandardEvents = 'standard:events';
31
-
32
- // base-x encoding / decoding
33
- // Copyright (c) 2018 base-x contributors
34
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
35
- // Distributed under the MIT software license, see the accompanying
36
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
37
- function base (ALPHABET) {
38
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
39
- const BASE_MAP = new Uint8Array(256);
40
- for (let j = 0; j < BASE_MAP.length; j++) {
41
- BASE_MAP[j] = 255;
42
- }
43
- for (let i = 0; i < ALPHABET.length; i++) {
44
- const x = ALPHABET.charAt(i);
45
- const xc = x.charCodeAt(0);
46
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
47
- BASE_MAP[xc] = i;
48
- }
49
- const BASE = ALPHABET.length;
50
- const LEADER = ALPHABET.charAt(0);
51
- const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
52
- const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
53
- function encode (source) {
54
- // eslint-disable-next-line no-empty
55
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
56
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
57
- } else if (Array.isArray(source)) {
58
- source = Uint8Array.from(source);
59
- }
60
- if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
61
- if (source.length === 0) { return '' }
62
- // Skip & count leading zeroes.
63
- let zeroes = 0;
64
- let length = 0;
65
- let pbegin = 0;
66
- const pend = source.length;
67
- while (pbegin !== pend && source[pbegin] === 0) {
68
- pbegin++;
69
- zeroes++;
70
- }
71
- // Allocate enough space in big-endian base58 representation.
72
- const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
73
- const b58 = new Uint8Array(size);
74
- // Process the bytes.
75
- while (pbegin !== pend) {
76
- let carry = source[pbegin];
77
- // Apply "b58 = b58 * 256 + ch".
78
- let i = 0;
79
- for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
80
- carry += (256 * b58[it1]) >>> 0;
81
- b58[it1] = (carry % BASE) >>> 0;
82
- carry = (carry / BASE) >>> 0;
83
- }
84
- if (carry !== 0) { throw new Error('Non-zero carry') }
85
- length = i;
86
- pbegin++;
87
- }
88
- // Skip leading zeroes in base58 result.
89
- let it2 = size - length;
90
- while (it2 !== size && b58[it2] === 0) {
91
- it2++;
92
- }
93
- // Translate the result into a string.
94
- let str = LEADER.repeat(zeroes);
95
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
96
- return str
97
- }
98
- function decodeUnsafe (source) {
99
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
100
- if (source.length === 0) { return new Uint8Array() }
101
- let psz = 0;
102
- // Skip and count leading '1's.
103
- let zeroes = 0;
104
- let length = 0;
105
- while (source[psz] === LEADER) {
106
- zeroes++;
107
- psz++;
108
- }
109
- // Allocate enough space in big-endian base256 representation.
110
- const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
111
- const b256 = new Uint8Array(size);
112
- // Process the characters.
113
- while (psz < source.length) {
114
- // Find code of next character
115
- const charCode = source.charCodeAt(psz);
116
- // Base map can not be indexed using char code
117
- if (charCode > 255) { return }
118
- // Decode character
119
- let carry = BASE_MAP[charCode];
120
- // Invalid character
121
- if (carry === 255) { return }
122
- let i = 0;
123
- for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
124
- carry += (BASE * b256[it3]) >>> 0;
125
- b256[it3] = (carry % 256) >>> 0;
126
- carry = (carry / 256) >>> 0;
127
- }
128
- if (carry !== 0) { throw new Error('Non-zero carry') }
129
- length = i;
130
- psz++;
131
- }
132
- // Skip leading zeroes in b256.
133
- let it4 = size - length;
134
- while (it4 !== size && b256[it4] === 0) {
135
- it4++;
136
- }
137
- const vch = new Uint8Array(zeroes + (size - it4));
138
- let j = zeroes;
139
- while (it4 !== size) {
140
- vch[j++] = b256[it4++];
141
- }
142
- return vch
143
- }
144
- function decode (string) {
145
- const buffer = decodeUnsafe(string);
146
- if (buffer) { return buffer }
147
- throw new Error('Non-base' + BASE + ' character')
148
- }
149
- return {
150
- encode,
151
- decodeUnsafe,
152
- decode
153
- }
154
- }
155
-
156
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
157
- var base58 = base(ALPHABET);
158
-
159
23
  var browser = {};
160
24
 
161
25
  var canPromise;
@@ -3228,239 +3092,200 @@ function requireBrowser () {
3228
3092
  var browserExports = requireBrowser();
3229
3093
  var QRCode = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
3230
3094
 
3231
- var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3232
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3233
- 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");
3234
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3235
- };
3236
- var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3237
- if (kind === "m") throw new TypeError("Private method is not writable");
3238
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3239
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3240
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3241
- };
3242
- var _RegisterWalletEvent_detail;
3243
- /**
3244
- * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
3245
- *
3246
- * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
3247
- * ready to be registered.
3248
- *
3249
- * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
3250
- * the app that the app is ready to register the Wallet.
3251
- *
3252
- * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
3253
- * as the app is ready whether the Wallet loads before or after the app.
3254
- *
3255
- * @param wallet Wallet to register.
3256
- *
3257
- * @group Wallet
3258
- */
3259
- function registerWallet(wallet) {
3260
- const callback = ({ register }) => register(wallet);
3261
- try {
3262
- window.dispatchEvent(new RegisterWalletEvent(callback));
3263
- }
3264
- catch (error) {
3265
- console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
3266
- }
3267
- try {
3268
- window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
3269
- }
3270
- catch (error) {
3271
- console.error('wallet-standard:app-ready event listener could not be added\n', error);
3272
- }
3273
- }
3274
- class RegisterWalletEvent extends Event {
3275
- get detail() {
3276
- return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
3277
- }
3278
- get type() {
3279
- return 'wallet-standard:register-wallet';
3280
- }
3281
- constructor(callback) {
3282
- super('wallet-standard:register-wallet', {
3283
- bubbles: false,
3284
- cancelable: false,
3285
- composed: false,
3286
- });
3287
- _RegisterWalletEvent_detail.set(this, void 0);
3288
- __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
3289
- }
3290
- /** @deprecated */
3291
- preventDefault() {
3292
- throw new Error('preventDefault cannot be called');
3293
- }
3294
- /** @deprecated */
3295
- stopImmediatePropagation() {
3296
- throw new Error('stopImmediatePropagation cannot be called');
3297
- }
3298
- /** @deprecated */
3299
- stopPropagation() {
3300
- throw new Error('stopPropagation cannot be called');
3301
- }
3302
- }
3303
- _RegisterWalletEvent_detail = new WeakMap();
3095
+ /** Name of the feature. */
3096
+ const StandardConnect = 'standard:connect';
3304
3097
 
3305
- //#region src/base64Utils.ts
3306
- function fromUint8Array(byteArray) {
3307
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
3308
- }
3309
- function toUint8Array(base64EncodedByteArray) {
3310
- return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
3311
- }
3312
- //#endregion
3313
- //#region src/embedded-modal/loadingSpinner.ts
3314
- const modalHtml$1 = `
3315
- <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3316
- <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
3317
- <div class="mobile-wallet-adapter-embedded-loading-container">
3318
- <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
3319
- </div>
3320
- </div>
3321
- `;
3322
- const css$6 = `
3323
- .mobile-wallet-adapter-embedded-loading-indicator {
3324
- display: flex; /* Use flexbox to center content */
3325
- justify-content: center; /* Center horizontally */
3326
- align-items: start; /* Center vertically */
3327
- position: fixed; /* Stay in place */
3328
- z-index: 1; /* Sit on top */
3329
- left: 0;
3330
- top: 0;
3331
- width: 100%; /* Full width */
3332
- height: 100%; /* Full height */
3333
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
3334
- overflow-y: auto; /* enable scrolling */
3335
- }
3098
+ /** Name of the feature. */
3099
+ const StandardDisconnect = 'standard:disconnect';
3336
3100
 
3337
- .mobile-wallet-adapter-embedded-loading-container {
3338
- display: flex;
3339
- margin: auto;
3101
+ /** Name of the feature. */
3102
+ const StandardEvents = 'standard:events';
3103
+
3104
+ var src;
3105
+ var hasRequiredSrc;
3106
+
3107
+ function requireSrc () {
3108
+ if (hasRequiredSrc) return src;
3109
+ hasRequiredSrc = 1;
3110
+ // base-x encoding / decoding
3111
+ // Copyright (c) 2018 base-x contributors
3112
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
3113
+ // Distributed under the MIT software license, see the accompanying
3114
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
3115
+ function base (ALPHABET) {
3116
+ if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
3117
+ var BASE_MAP = new Uint8Array(256);
3118
+ for (var j = 0; j < BASE_MAP.length; j++) {
3119
+ BASE_MAP[j] = 255;
3120
+ }
3121
+ for (var i = 0; i < ALPHABET.length; i++) {
3122
+ var x = ALPHABET.charAt(i);
3123
+ var xc = x.charCodeAt(0);
3124
+ if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
3125
+ BASE_MAP[xc] = i;
3126
+ }
3127
+ var BASE = ALPHABET.length;
3128
+ var LEADER = ALPHABET.charAt(0);
3129
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
3130
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
3131
+ function encode (source) {
3132
+ if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
3133
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
3134
+ } else if (Array.isArray(source)) {
3135
+ source = Uint8Array.from(source);
3136
+ }
3137
+ if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
3138
+ if (source.length === 0) { return '' }
3139
+ // Skip & count leading zeroes.
3140
+ var zeroes = 0;
3141
+ var length = 0;
3142
+ var pbegin = 0;
3143
+ var pend = source.length;
3144
+ while (pbegin !== pend && source[pbegin] === 0) {
3145
+ pbegin++;
3146
+ zeroes++;
3147
+ }
3148
+ // Allocate enough space in big-endian base58 representation.
3149
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
3150
+ var b58 = new Uint8Array(size);
3151
+ // Process the bytes.
3152
+ while (pbegin !== pend) {
3153
+ var carry = source[pbegin];
3154
+ // Apply "b58 = b58 * 256 + ch".
3155
+ var i = 0;
3156
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
3157
+ carry += (256 * b58[it1]) >>> 0;
3158
+ b58[it1] = (carry % BASE) >>> 0;
3159
+ carry = (carry / BASE) >>> 0;
3160
+ }
3161
+ if (carry !== 0) { throw new Error('Non-zero carry') }
3162
+ length = i;
3163
+ pbegin++;
3164
+ }
3165
+ // Skip leading zeroes in base58 result.
3166
+ var it2 = size - length;
3167
+ while (it2 !== size && b58[it2] === 0) {
3168
+ it2++;
3169
+ }
3170
+ // Translate the result into a string.
3171
+ var str = LEADER.repeat(zeroes);
3172
+ for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
3173
+ return str
3174
+ }
3175
+ function decodeUnsafe (source) {
3176
+ if (typeof source !== 'string') { throw new TypeError('Expected String') }
3177
+ if (source.length === 0) { return new Uint8Array() }
3178
+ var psz = 0;
3179
+ // Skip and count leading '1's.
3180
+ var zeroes = 0;
3181
+ var length = 0;
3182
+ while (source[psz] === LEADER) {
3183
+ zeroes++;
3184
+ psz++;
3185
+ }
3186
+ // Allocate enough space in big-endian base256 representation.
3187
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
3188
+ var b256 = new Uint8Array(size);
3189
+ // Process the characters.
3190
+ while (source[psz]) {
3191
+ // Find code of next character
3192
+ var charCode = source.charCodeAt(psz);
3193
+ // Base map can not be indexed using char code
3194
+ if (charCode > 255) { return }
3195
+ // Decode character
3196
+ var carry = BASE_MAP[charCode];
3197
+ // Invalid character
3198
+ if (carry === 255) { return }
3199
+ var i = 0;
3200
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
3201
+ carry += (BASE * b256[it3]) >>> 0;
3202
+ b256[it3] = (carry % 256) >>> 0;
3203
+ carry = (carry / 256) >>> 0;
3204
+ }
3205
+ if (carry !== 0) { throw new Error('Non-zero carry') }
3206
+ length = i;
3207
+ psz++;
3208
+ }
3209
+ // Skip leading zeroes in b256.
3210
+ var it4 = size - length;
3211
+ while (it4 !== size && b256[it4] === 0) {
3212
+ it4++;
3213
+ }
3214
+ var vch = new Uint8Array(zeroes + (size - it4));
3215
+ var j = zeroes;
3216
+ while (it4 !== size) {
3217
+ vch[j++] = b256[it4++];
3218
+ }
3219
+ return vch
3220
+ }
3221
+ function decode (string) {
3222
+ var buffer = decodeUnsafe(string);
3223
+ if (buffer) { return buffer }
3224
+ throw new Error('Non-base' + BASE + ' character')
3225
+ }
3226
+ return {
3227
+ encode: encode,
3228
+ decodeUnsafe: decodeUnsafe,
3229
+ decode: decode
3230
+ }
3231
+ }
3232
+ src = base;
3233
+ return src;
3340
3234
  }
3341
3235
 
3342
- .mobile-wallet-adapter-embedded-loading-animation {
3343
- position: relative;
3344
- left: -9999px;
3345
- width: 10px;
3346
- height: 10px;
3347
- border-radius: 5px;
3348
- background-color: var(--spinner-color);
3349
- color: var(--spinner-color);
3350
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3351
- 9999px 0 0 0 var(--spinner-color),
3352
- 10014px 0 0 0 var(--spinner-color);
3353
- animation: dot-typing 1.5s infinite linear;
3236
+ var bs58;
3237
+ var hasRequiredBs58;
3238
+
3239
+ function requireBs58 () {
3240
+ if (hasRequiredBs58) return bs58;
3241
+ hasRequiredBs58 = 1;
3242
+ const basex = requireSrc();
3243
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
3244
+
3245
+ bs58 = basex(ALPHABET);
3246
+ return bs58;
3354
3247
  }
3355
3248
 
3356
- @keyframes dot-typing {
3357
- 0% {
3358
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3359
- 9999px 0 0 0 var(--spinner-color),
3360
- 10014px 0 0 0 var(--spinner-color);
3361
- }
3362
- 16.667% {
3363
- box-shadow: 9984px -10px 0 0 var(--spinner-color),
3364
- 9999px 0 0 0 var(--spinner-color),
3365
- 10014px 0 0 0 var(--spinner-color);
3366
- }
3367
- 33.333% {
3368
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3369
- 9999px 0 0 0 var(--spinner-color),
3370
- 10014px 0 0 0 var(--spinner-color);
3371
- }
3372
- 50% {
3373
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3374
- 9999px -10px 0 0 var(--spinner-color),
3375
- 10014px 0 0 0 var(--spinner-color);
3376
- }
3377
- 66.667% {
3378
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3379
- 9999px 0 0 0 var(--spinner-color),
3380
- 10014px 0 0 0 var(--spinner-color);
3381
- }
3382
- 83.333% {
3383
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3384
- 9999px 0 0 0 var(--spinner-color),
3385
- 10014px -10px 0 0 var(--spinner-color);
3386
- }
3387
- 100% {
3388
- box-shadow: 9984px 0 0 0 var(--spinner-color),
3389
- 9999px 0 0 0 var(--spinner-color),
3390
- 10014px 0 0 0 var(--spinner-color);
3391
- }
3249
+ var bs58Exports = requireBs58();
3250
+ var base58 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
3251
+
3252
+ /******************************************************************************
3253
+ Copyright (c) Microsoft Corporation.
3254
+
3255
+ Permission to use, copy, modify, and/or distribute this software for any
3256
+ purpose with or without fee is hereby granted.
3257
+
3258
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3259
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3260
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3261
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3262
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3263
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3264
+ PERFORMANCE OF THIS SOFTWARE.
3265
+ ***************************************************************************** */
3266
+
3267
+ function __awaiter(thisArg, _arguments, P, generator) {
3268
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3269
+ return new (P || (P = Promise))(function (resolve, reject) {
3270
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3271
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3272
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3273
+ step((generator = generator.apply(thisArg, [])).next());
3274
+ });
3275
+ }
3276
+
3277
+ function __classPrivateFieldGet$1(receiver, state, kind, f) {
3278
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3279
+ 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");
3280
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3281
+ }
3282
+
3283
+ function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
3284
+ 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");
3285
+ return (state.set(receiver, value)), value;
3392
3286
  }
3393
- `;
3394
- var EmbeddedLoadingSpinner = class {
3395
- #root = null;
3396
- #eventListeners = {};
3397
- #listenersAttached = false;
3398
- dom = null;
3399
- constructor() {
3400
- this.init = this.init.bind(this);
3401
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3402
- }
3403
- async init() {
3404
- console.log("Injecting modal");
3405
- this.#injectHTML();
3406
- }
3407
- open = () => {
3408
- console.debug("Modal open");
3409
- this.#attachEventListeners();
3410
- if (this.#root) this.#root.style.display = "flex";
3411
- };
3412
- close = (event = void 0) => {
3413
- console.debug("Modal close");
3414
- this.#removeEventListeners();
3415
- if (this.#root) this.#root.style.display = "none";
3416
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
3417
- };
3418
- addEventListener(event, listener) {
3419
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3420
- return () => this.removeEventListener(event, listener);
3421
- }
3422
- removeEventListener(event, listener) {
3423
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3424
- }
3425
- #injectHTML() {
3426
- if (this.dom) return;
3427
- this.#root = document.createElement("div");
3428
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3429
- this.#root.innerHTML = modalHtml$1;
3430
- this.#root.style.display = "none";
3431
- const styles = document.createElement("style");
3432
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3433
- styles.textContent = css$6;
3434
- const host = document.createElement("div");
3435
- this.dom = host.attachShadow({ mode: "closed" });
3436
- host.style.setProperty("--spinner-color", "#FFFFFF");
3437
- this.dom.appendChild(styles);
3438
- this.dom.appendChild(this.#root);
3439
- document.body.appendChild(host);
3440
- }
3441
- #attachEventListeners() {
3442
- if (!this.#root || this.#listenersAttached) return;
3443
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
3444
- this.close(event);
3445
- }));
3446
- window.addEventListener("load", this.close);
3447
- document.addEventListener("keydown", this.#handleKeyDown);
3448
- this.#listenersAttached = true;
3449
- }
3450
- #removeEventListeners() {
3451
- if (!this.#listenersAttached) return;
3452
- window.removeEventListener("load", this.close);
3453
- document.removeEventListener("keydown", this.#handleKeyDown);
3454
- if (!this.#root) return;
3455
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3456
- this.#listenersAttached = false;
3457
- }
3458
- #handleKeyDown = (event) => {
3459
- if (event.key === "Escape") this.close(event);
3460
- };
3461
- };
3462
- //#endregion
3463
- //#region src/embedded-modal/modal.ts
3287
+
3288
+ var _EmbeddedModal_instances, _EmbeddedModal_root, _EmbeddedModal_eventListeners, _EmbeddedModal_listenersAttached, _EmbeddedModal_injectHTML, _EmbeddedModal_attachEventListeners, _EmbeddedModal_removeEventListeners, _EmbeddedModal_handleKeyDown;
3464
3289
  const modalHtml = `
3465
3290
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3466
3291
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
@@ -3476,13 +3301,13 @@ const modalHtml = `
3476
3301
  </div>
3477
3302
  </div>
3478
3303
  `;
3479
- const css$5 = `
3304
+ const css$2 = `
3480
3305
  .mobile-wallet-adapter-embedded-modal-container {
3481
3306
  display: flex; /* Use flexbox to center content */
3482
3307
  justify-content: center; /* Center horizontally */
3483
3308
  align-items: center; /* Center vertically */
3484
3309
  position: fixed; /* Stay in place */
3485
- z-index: 2147483647; /* Sit on top */
3310
+ z-index: 1; /* Sit on top */
3486
3311
  left: 0;
3487
3312
  top: 0;
3488
3313
  width: 100%; /* Full width */
@@ -3538,100 +3363,134 @@ const fonts = `
3538
3363
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
3539
3364
  <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
3540
3365
  `;
3541
- var EmbeddedModal = class {
3542
- #root = null;
3543
- #eventListeners = {};
3544
- #listenersAttached = false;
3545
- dom = null;
3546
- constructor() {
3547
- this.init = this.init.bind(this);
3548
- this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3549
- }
3550
- async init() {
3551
- console.log("Injecting modal");
3552
- this.#injectHTML();
3553
- }
3554
- open = () => {
3555
- console.debug("Modal open");
3556
- this.#attachEventListeners();
3557
- if (this.#root) this.#root.style.display = "flex";
3558
- };
3559
- close = (event = void 0) => {
3560
- console.debug("Modal close");
3561
- this.#removeEventListeners();
3562
- if (this.#root) this.#root.style.display = "none";
3563
- this.#eventListeners["close"]?.forEach((listener) => listener(event));
3564
- };
3565
- addEventListener(event, listener) {
3566
- this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3567
- return () => this.removeEventListener(event, listener);
3568
- }
3569
- removeEventListener(event, listener) {
3570
- this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3571
- }
3572
- #injectHTML() {
3573
- if (document.getElementById("mobile-wallet-adapter-embedded-root-ui")) {
3574
- if (!this.#root) this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3575
- return;
3576
- }
3577
- this.#root = document.createElement("div");
3578
- this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3579
- this.#root.innerHTML = modalHtml;
3580
- this.#root.style.display = "none";
3581
- const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
3582
- if (content) content.innerHTML = this.contentHtml;
3583
- const styles = document.createElement("style");
3584
- styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3585
- styles.textContent = css$5 + this.contentStyles;
3586
- const host = document.createElement("div");
3587
- host.innerHTML = fonts;
3588
- this.dom = host.attachShadow({ mode: "closed" });
3589
- this.dom.appendChild(styles);
3590
- this.dom.appendChild(this.#root);
3591
- document.body.appendChild(host);
3592
- }
3593
- #attachEventListeners() {
3594
- if (!this.#root || this.#listenersAttached) return;
3595
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", this.close));
3596
- window.addEventListener("load", this.close);
3597
- document.addEventListener("keydown", this.#handleKeyDown);
3598
- this.#listenersAttached = true;
3599
- }
3600
- #removeEventListeners() {
3601
- if (!this.#listenersAttached) return;
3602
- window.removeEventListener("load", this.close);
3603
- document.removeEventListener("keydown", this.#handleKeyDown);
3604
- if (!this.#root) return;
3605
- [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3606
- this.#listenersAttached = false;
3607
- }
3608
- #handleKeyDown = (event) => {
3609
- if (event.key === "Escape") this.close(event);
3610
- };
3611
- };
3612
- //#endregion
3613
- //#region src/embedded-modal/remoteConnectionModal.ts
3614
- var RemoteConnectionModal = class extends EmbeddedModal {
3615
- contentStyles = css$4;
3616
- contentHtml = QRCodeHtml;
3617
- async initWithQR(qrCode) {
3618
- super.init();
3619
- this.populateQRCode(qrCode);
3620
- }
3621
- async populateQRCode(qrUrl) {
3622
- const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
3623
- if (qrcodeContainer) {
3624
- const qrCodeElement = await QRCode.toCanvas(qrUrl, {
3625
- width: 200,
3626
- margin: 0
3627
- });
3628
- if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3629
- else qrcodeContainer.appendChild(qrCodeElement);
3630
- const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
3631
- if (qrPlaceholder) qrPlaceholder.style.display = "none";
3632
- } else console.error("QRCode Container not found");
3633
- }
3366
+ class EmbeddedModal {
3367
+ constructor() {
3368
+ _EmbeddedModal_instances.add(this);
3369
+ _EmbeddedModal_root.set(this, null);
3370
+ _EmbeddedModal_eventListeners.set(this, {});
3371
+ _EmbeddedModal_listenersAttached.set(this, false);
3372
+ this.dom = null;
3373
+ this.open = () => {
3374
+ console.debug('Modal open');
3375
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_attachEventListeners).call(this);
3376
+ if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3377
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'flex';
3378
+ }
3379
+ };
3380
+ this.close = (event = undefined) => {
3381
+ var _a;
3382
+ console.debug('Modal close');
3383
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_removeEventListeners).call(this);
3384
+ if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3385
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3386
+ }
3387
+ (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")['close']) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
3388
+ };
3389
+ _EmbeddedModal_handleKeyDown.set(this, (event) => {
3390
+ if (event.key === 'Escape')
3391
+ this.close(event);
3392
+ });
3393
+ // Bind methods to ensure `this` context is correct
3394
+ this.init = this.init.bind(this);
3395
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3396
+ }
3397
+ init() {
3398
+ return __awaiter(this, void 0, void 0, function* () {
3399
+ console.log('Injecting modal');
3400
+ __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_injectHTML).call(this);
3401
+ });
3402
+ }
3403
+ addEventListener(event, listener) {
3404
+ var _a;
3405
+ ((_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = [listener]);
3406
+ return () => this.removeEventListener(event, listener);
3407
+ }
3408
+ removeEventListener(event, listener) {
3409
+ var _a;
3410
+ __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
3411
+ }
3412
+ }
3413
+ _EmbeddedModal_root = new WeakMap(), _EmbeddedModal_eventListeners = new WeakMap(), _EmbeddedModal_listenersAttached = new WeakMap(), _EmbeddedModal_handleKeyDown = new WeakMap(), _EmbeddedModal_instances = new WeakSet(), _EmbeddedModal_injectHTML = function _EmbeddedModal_injectHTML() {
3414
+ // Check if the HTML has already been injected
3415
+ if (document.getElementById('mobile-wallet-adapter-embedded-root-ui')) {
3416
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3417
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3418
+ return;
3419
+ }
3420
+ // Create a container for the modal
3421
+ __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.createElement('div'));
3422
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").id = 'mobile-wallet-adapter-embedded-root-ui';
3423
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").innerHTML = modalHtml;
3424
+ __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3425
+ // Add modal content
3426
+ const content = __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelector('.mobile-wallet-adapter-embedded-modal-content');
3427
+ if (content)
3428
+ content.innerHTML = this.contentHtml;
3429
+ // Apply styles
3430
+ const styles = document.createElement('style');
3431
+ styles.id = 'mobile-wallet-adapter-embedded-modal-styles';
3432
+ styles.textContent = css$2 + this.contentStyles;
3433
+ // Create a shadow DOM to encapsulate the modal
3434
+ const host = document.createElement('div');
3435
+ host.innerHTML = fonts;
3436
+ this.dom = host.attachShadow({ mode: 'closed' });
3437
+ this.dom.appendChild(styles);
3438
+ this.dom.appendChild(__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"));
3439
+ // Append the shadow DOM host to the body
3440
+ document.body.appendChild(host);
3441
+ }, _EmbeddedModal_attachEventListeners = function _EmbeddedModal_attachEventListeners() {
3442
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f") || __classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3443
+ return;
3444
+ const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3445
+ closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.addEventListener('click', this.close));
3446
+ window.addEventListener('load', this.close);
3447
+ document.addEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3448
+ __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, true);
3449
+ }, _EmbeddedModal_removeEventListeners = function _EmbeddedModal_removeEventListeners() {
3450
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3451
+ return;
3452
+ window.removeEventListener('load', this.close);
3453
+ document.removeEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3454
+ if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3455
+ return;
3456
+ const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3457
+ closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.removeEventListener('click', this.close));
3458
+ __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, false);
3634
3459
  };
3460
+
3461
+ class RemoteConnectionModal extends EmbeddedModal {
3462
+ constructor() {
3463
+ super(...arguments);
3464
+ this.contentStyles = css$1;
3465
+ this.contentHtml = QRCodeHtml;
3466
+ }
3467
+ initWithQR(qrCode) {
3468
+ const _super = Object.create(null, {
3469
+ init: { get: () => super.init }
3470
+ });
3471
+ return __awaiter(this, void 0, void 0, function* () {
3472
+ _super.init.call(this);
3473
+ this.populateQRCode(qrCode);
3474
+ });
3475
+ }
3476
+ populateQRCode(qrUrl) {
3477
+ var _a;
3478
+ return __awaiter(this, void 0, void 0, function* () {
3479
+ const qrcodeContainer = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-embedded-modal-qr-code-container');
3480
+ if (qrcodeContainer) {
3481
+ const qrCodeElement = yield QRCode.toCanvas(qrUrl, { width: 200, margin: 0 });
3482
+ if (qrcodeContainer.firstElementChild !== null) {
3483
+ qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3484
+ }
3485
+ else
3486
+ qrcodeContainer.appendChild(qrCodeElement);
3487
+ }
3488
+ else {
3489
+ console.error('QRCode Container not found');
3490
+ }
3491
+ });
3492
+ }
3493
+ }
3635
3494
  const QRCodeHtml = `
3636
3495
  <div class="mobile-wallet-adapter-embedded-modal-qr-content">
3637
3496
  <div>
@@ -3647,9 +3506,7 @@ const QRCodeHtml = `
3647
3506
  Open your wallet and scan this code
3648
3507
  </h4>
3649
3508
  </div>
3650
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
3651
- <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
3652
- </div>
3509
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
3653
3510
  </div>
3654
3511
  </div>
3655
3512
  <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
@@ -3676,7 +3533,7 @@ const QRCodeHtml = `
3676
3533
  </div>
3677
3534
  </div>
3678
3535
  `;
3679
- const css$4 = `
3536
+ const css$1 = `
3680
3537
  .mobile-wallet-adapter-embedded-modal-qr-content {
3681
3538
  display: flex;
3682
3539
  margin-top: 10px;
@@ -3720,16 +3577,6 @@ const css$4 = `
3720
3577
  margin-left: auto;
3721
3578
  }
3722
3579
 
3723
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3724
- margin-left: auto;
3725
- min-width: 200px;
3726
- min-height: 200px;
3727
- background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
3728
- background-size: 200%;
3729
- animation: placeholderAnimate 2.7s linear infinite;
3730
- border-radius: 12px;
3731
- }
3732
-
3733
3580
  .mobile-wallet-adapter-embedded-modal-divider {
3734
3581
  margin-top: 20px;
3735
3582
  padding-left: 10px;
@@ -3802,15 +3649,6 @@ const css$4 = `
3802
3649
  .mobile-wallet-adapter-embedded-modal-qr-code-container {
3803
3650
  margin: auto;
3804
3651
  }
3805
- .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3806
- margin: auto;
3807
- }
3808
- }
3809
-
3810
- /* QR Placeholder */
3811
- @keyframes placeholderAnimate {
3812
- 0% { background-position: 200% 0; }
3813
- 100% { background-position: -200% 0; }
3814
3652
  }
3815
3653
 
3816
3654
  /* Spinner */
@@ -3891,1173 +3729,962 @@ const css$4 = `
3891
3729
  animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
3892
3730
  }
3893
3731
  `;
3894
- //#endregion
3895
- //#region src/embedded-modal/localConnectionModal.ts
3896
- var LocalConnectionModal = class extends EmbeddedModal {
3897
- contentStyles = css$3;
3898
- contentHtml = ErrorDialogHtml$3;
3899
- initWithCallback(callback) {
3900
- super.init();
3901
- this.#prepareLaunchAction(callback);
3902
- }
3903
- #prepareLaunchAction(callback) {
3904
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3905
- const listener = async () => {
3906
- launchButton?.removeEventListener("click", listener);
3907
- this.close();
3908
- callback();
3909
- };
3910
- launchButton?.addEventListener("click", listener);
3911
- }
3912
- };
3913
- const ErrorDialogHtml$3 = `
3914
- <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">
3915
- <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"/>
3916
- <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3917
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3918
- </mask>
3919
- <g mask="url(#mask0_189_522)">
3920
- <mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3921
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3922
- </mask>
3923
- <g mask="url(#mask1_189_522)">
3924
- <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"/>
3925
- </g>
3926
- </g>
3927
- </svg>
3928
- <div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
3929
- <div>
3930
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
3931
- Connect Wallet
3932
- </button>
3933
- </div>
3934
- `;
3935
- const css$3 = `
3936
- .mobile-wallet-adapter-embedded-modal-close {
3937
- display: none;
3938
- }
3939
- .mobile-wallet-adapter-embedded-modal-content {
3940
- text-align: center;
3941
- min-width: 300px;
3942
- }
3943
- .mobile-wallet-adapter-embedded-modal-launch-icon {
3944
- margin-top: 24px;
3945
- }
3946
- .mobile-wallet-adapter-embedded-modal-title {
3947
- margin: 18px 100px 30px 100px;
3948
- color: #000000;
3949
- font-size: 2.75em;
3950
- font-weight: 600;
3732
+
3733
+ const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
3734
+
3735
+ function fromUint8Array(byteArray) {
3736
+ return window.btoa(String.fromCharCode.call(null, ...byteArray));
3951
3737
  }
3952
- .mobile-wallet-adapter-embedded-modal-launch-action {
3953
- display: block;
3954
- width: 100%;
3955
- height: 56px;
3956
- font-size: 1.25em;
3957
- background: #000000;
3958
- color: #FFFFFF;
3959
- border-radius: 18px;
3738
+ function toUint8Array(base64EncodedByteArray) {
3739
+ return new Uint8Array(window
3740
+ .atob(base64EncodedByteArray)
3741
+ .split('')
3742
+ .map((c) => c.charCodeAt(0)));
3960
3743
  }
3961
- /* Smaller screens */
3962
- @media all and (max-width: 600px) {
3963
- .mobile-wallet-adapter-embedded-modal-title {
3964
- font-size: 1.5em;
3965
- margin-right: 12px;
3966
- margin-left: 12px;
3744
+
3745
+ var _LocalSolanaMobileWalletAdapterWallet_instances, _LocalSolanaMobileWalletAdapterWallet_listeners, _LocalSolanaMobileWalletAdapterWallet_version, _LocalSolanaMobileWalletAdapterWallet_name, _LocalSolanaMobileWalletAdapterWallet_url, _LocalSolanaMobileWalletAdapterWallet_icon, _LocalSolanaMobileWalletAdapterWallet_appIdentity, _LocalSolanaMobileWalletAdapterWallet_authorization, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, _LocalSolanaMobileWalletAdapterWallet_connecting, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, _LocalSolanaMobileWalletAdapterWallet_chains, _LocalSolanaMobileWalletAdapterWallet_chainSelector, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, _LocalSolanaMobileWalletAdapterWallet_on, _LocalSolanaMobileWalletAdapterWallet_emit, _LocalSolanaMobileWalletAdapterWallet_off, _LocalSolanaMobileWalletAdapterWallet_connect, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, _LocalSolanaMobileWalletAdapterWallet_disconnect, _LocalSolanaMobileWalletAdapterWallet_transact, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signTransaction, _LocalSolanaMobileWalletAdapterWallet_signMessage, _LocalSolanaMobileWalletAdapterWallet_signIn, _LocalSolanaMobileWalletAdapterWallet_performSignIn, _RemoteSolanaMobileWalletAdapterWallet_instances, _RemoteSolanaMobileWalletAdapterWallet_listeners, _RemoteSolanaMobileWalletAdapterWallet_version, _RemoteSolanaMobileWalletAdapterWallet_name, _RemoteSolanaMobileWalletAdapterWallet_url, _RemoteSolanaMobileWalletAdapterWallet_icon, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, _RemoteSolanaMobileWalletAdapterWallet_authorization, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, _RemoteSolanaMobileWalletAdapterWallet_connecting, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, _RemoteSolanaMobileWalletAdapterWallet_chains, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, _RemoteSolanaMobileWalletAdapterWallet_session, _RemoteSolanaMobileWalletAdapterWallet_on, _RemoteSolanaMobileWalletAdapterWallet_emit, _RemoteSolanaMobileWalletAdapterWallet_off, _RemoteSolanaMobileWalletAdapterWallet_connect, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, _RemoteSolanaMobileWalletAdapterWallet_disconnect, _RemoteSolanaMobileWalletAdapterWallet_transact, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, _RemoteSolanaMobileWalletAdapterWallet_signMessage, _RemoteSolanaMobileWalletAdapterWallet_signIn, _RemoteSolanaMobileWalletAdapterWallet_performSignIn;
3746
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
3747
+ const SolanaMobileWalletAdapterRemoteWalletName = 'Remote Mobile Wallet Adapter';
3748
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
3749
+ const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
3750
+ class LocalSolanaMobileWalletAdapterWallet {
3751
+ constructor(config) {
3752
+ _LocalSolanaMobileWalletAdapterWallet_instances.add(this);
3753
+ _LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3754
+ _LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3755
+ _LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
3756
+ _LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3757
+ _LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3758
+ _LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
3759
+ _LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
3760
+ _LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
3761
+ _LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
3762
+ /**
3763
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
3764
+ * increment this and use it to make sure that `transact` calls from the previous
3765
+ * 'generation' don't continue to do work and throw exceptions.
3766
+ */
3767
+ _LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
3768
+ _LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
3769
+ _LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
3770
+ _LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
3771
+ _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
3772
+ _LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
3773
+ var _a;
3774
+ ((_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]);
3775
+ return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
3776
+ });
3777
+ _LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
3778
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
3779
+ return { accounts: this.accounts };
3780
+ }
3781
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3782
+ try {
3783
+ if (silent) {
3784
+ const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3785
+ if (cachedAuthorization) {
3786
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
3787
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
3788
+ }
3789
+ else {
3790
+ return { accounts: this.accounts };
3791
+ }
3792
+ }
3793
+ else {
3794
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
3795
+ }
3796
+ }
3797
+ catch (e) {
3798
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3799
+ }
3800
+ finally {
3801
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3802
+ }
3803
+ return { accounts: this.accounts };
3804
+ }));
3805
+ _LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
3806
+ try {
3807
+ const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3808
+ if (cachedAuthorizationResult) {
3809
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3810
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
3811
+ return cachedAuthorizationResult;
3812
+ }
3813
+ const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
3814
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3815
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3816
+ wallet.getCapabilities(),
3817
+ wallet.authorize({
3818
+ chain: selectedChain,
3819
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3820
+ sign_in_payload: signInPayload,
3821
+ })
3822
+ ]);
3823
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3824
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
3825
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3826
+ Promise.all([
3827
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
3828
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3829
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3830
+ ]);
3831
+ return authorization;
3832
+ }));
3833
+ }
3834
+ catch (e) {
3835
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3836
+ }
3837
+ }));
3838
+ _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
3839
+ var _a;
3840
+ const didPublicKeysChange =
3841
+ // Case 1: We started from having no authorization.
3842
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
3843
+ // Case 2: The number of authorized accounts changed.
3844
+ ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
3845
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
3846
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
3847
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
3848
+ if (didPublicKeysChange) {
3849
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3850
+ }
3851
+ }));
3852
+ _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
3853
+ // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
3854
+ const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
3855
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
3856
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
3857
+ SolanaSignTransaction in this.features !== supportsSignTransaction;
3858
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
3859
+ [SolanaSignAndSendTransaction]: {
3860
+ version: '1.0.0',
3861
+ supportedTransactionVersions: ['legacy', 0],
3862
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3863
+ },
3864
+ })), (supportsSignTransaction && {
3865
+ [SolanaSignTransaction]: {
3866
+ version: '1.0.0',
3867
+ supportedTransactionVersions: ['legacy', 0],
3868
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3869
+ },
3870
+ })));
3871
+ if (didCapabilitiesChange) {
3872
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
3873
+ }
3874
+ }));
3875
+ _LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
3876
+ var _b, _c;
3877
+ try {
3878
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3879
+ (_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
3880
+ wallet.authorize({
3881
+ auth_token: authToken,
3882
+ identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3883
+ chain: chain
3884
+ })
3885
+ ]);
3886
+ const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3887
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
3888
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3889
+ Promise.all([
3890
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3891
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3892
+ ]);
3893
+ }
3894
+ catch (e) {
3895
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
3896
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3897
+ }
3898
+ }));
3899
+ _LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
3900
+ var _d;
3901
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3902
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3903
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
3904
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
3905
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3906
+ }));
3907
+ _LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
3908
+ var _e;
3909
+ const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
3910
+ const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
3911
+ const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
3912
+ try {
3913
+ return yield transact(callback, config);
3914
+ }
3915
+ catch (e) {
3916
+ if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
3917
+ yield new Promise(() => { }); // Never resolve.
3918
+ }
3919
+ if (e instanceof Error &&
3920
+ e.name === 'SolanaMobileWalletAdapterError' &&
3921
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
3922
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
3923
+ }
3924
+ throw e;
3925
+ }
3926
+ }));
3927
+ _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
3928
+ if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
3929
+ throw new Error('Wallet not connected');
3930
+ return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
3931
+ });
3932
+ _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
3933
+ return accounts.map((account) => {
3934
+ var _a, _b;
3935
+ const publicKey = toUint8Array(account.address);
3936
+ return {
3937
+ address: base58.encode(publicKey),
3938
+ publicKey,
3939
+ label: account.label,
3940
+ icon: account.icon,
3941
+ chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
3942
+ // TODO: get supported features from getCapabilities API
3943
+ features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
3944
+ };
3945
+ });
3946
+ });
3947
+ _LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
3948
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3949
+ try {
3950
+ const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
3951
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3952
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3953
+ const signedTransactions = (yield wallet.signTransactions({
3954
+ payloads: base64Transactions,
3955
+ })).signed_payloads.map(toUint8Array);
3956
+ return signedTransactions;
3957
+ }));
3958
+ }
3959
+ catch (e) {
3960
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3961
+ }
3962
+ }));
3963
+ _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
3964
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3965
+ try {
3966
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3967
+ const [capabilities, _1] = yield Promise.all([
3968
+ wallet.getCapabilities(),
3969
+ __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
3970
+ ]);
3971
+ if (capabilities.supports_sign_and_send_transactions) {
3972
+ const base64Transaction = fromUint8Array(transaction);
3973
+ const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
3974
+ return signatures[0];
3975
+ }
3976
+ else {
3977
+ throw new Error('connected wallet does not support signAndSendTransaction');
3978
+ }
3979
+ }));
3980
+ }
3981
+ catch (e) {
3982
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
3983
+ }
3984
+ }));
3985
+ _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3986
+ const outputs = [];
3987
+ for (const input of inputs) {
3988
+ const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
3989
+ outputs.push({ signature });
3990
+ }
3991
+ return outputs;
3992
+ }));
3993
+ _LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3994
+ return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
3995
+ .map((signedTransaction) => {
3996
+ return { signedTransaction };
3997
+ });
3998
+ }));
3999
+ _LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4000
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4001
+ const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4002
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4003
+ try {
4004
+ return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4005
+ yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4006
+ const signedMessages = (yield wallet.signMessages({
4007
+ addresses: addresses,
4008
+ payloads: messages,
4009
+ })).signed_payloads.map(toUint8Array);
4010
+ return signedMessages.map((signedMessage) => {
4011
+ return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4012
+ });
4013
+ }));
4014
+ }
4015
+ catch (e) {
4016
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4017
+ }
4018
+ }));
4019
+ _LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4020
+ const outputs = [];
4021
+ if (inputs.length > 1) {
4022
+ for (const input of inputs) {
4023
+ outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4024
+ }
4025
+ }
4026
+ else {
4027
+ return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4028
+ }
4029
+ return outputs;
4030
+ }));
4031
+ _LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4032
+ var _f, _g, _h;
4033
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
4034
+ try {
4035
+ 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 }));
4036
+ if (!authorizationResult.sign_in_result) {
4037
+ throw new Error("Sign in failed, no sign in result returned by wallet");
4038
+ }
4039
+ const signedInAddress = authorizationResult.sign_in_result.address;
4040
+ const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4041
+ return {
4042
+ account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4043
+ address: base58.encode(toUint8Array(signedInAddress))
4044
+ }), { 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 }),
4045
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4046
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4047
+ };
4048
+ }
4049
+ catch (e) {
4050
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4051
+ }
4052
+ finally {
4053
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
4054
+ }
4055
+ }));
4056
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4057
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4058
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
4059
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4060
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4061
+ __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
4062
+ // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4063
+ // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4064
+ // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4065
+ // assume both are supported here. The features will be updated based on the actual connected
4066
+ // wallets capabilities during connection regardless, so this is safe.
4067
+ [SolanaSignAndSendTransaction]: {
4068
+ version: '1.0.0',
4069
+ supportedTransactionVersions: ['legacy', 0],
4070
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4071
+ },
4072
+ [SolanaSignTransaction]: {
4073
+ version: '1.0.0',
4074
+ supportedTransactionVersions: ['legacy', 0],
4075
+ signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4076
+ },
4077
+ });
3967
4078
  }
3968
- }
3969
- `;
3970
- //#endregion
3971
- //#region src/embedded-modal/loopbackBlockedModal.ts
3972
- var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
3973
- contentStyles = css$2;
3974
- get contentHtml() {
3975
- 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";
3976
- return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
3977
- }
3978
- async init() {
3979
- super.init();
3980
- this.#prepareLaunchAction();
3981
- }
3982
- #prepareLaunchAction() {
3983
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3984
- const listener = async (event) => {
3985
- launchButton?.removeEventListener("click", listener);
3986
- this.close(event);
3987
- };
3988
- launchButton?.addEventListener("click", listener);
3989
- }
3990
- };
3991
- const ErrorDialogHtml$2 = `
3992
- <div class="mobile-wallet-adapter-embedded-modal-header">
3993
- Local Wallet Connection
3994
- </div>
3995
- <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3996
- <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"/>
3997
- <mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3998
- <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3999
- </mask>
4000
- <g mask="url(#mask0_147_1364)">
4001
- <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"/>
4002
- </g>
4003
- </svg>
4004
- <div class="mobile-wallet-adapter-embedded-modal-title">
4005
- Your wallet connection is blocked
4006
- </div>
4007
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4008
- Visit site settings in the address bar and allow "Apps on Device".
4009
- </div>
4010
-
4011
- <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
4012
- <div class="mobile-wallet-adapter-embedded-modal-footer">
4013
- <div class="mobile-wallet-adapter-embedded-modal-details">
4014
- <!-- Clickable header (label associated with the checkbox) -->
4015
- <label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
4016
- <!-- Hidden checkbox to track state -->
4017
- <input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
4018
- <span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
4019
- See details
4020
- </span>
4021
- <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">
4022
- <mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
4023
- <rect width="24" height="24" fill="#D9D9D9"/>
4024
- </mask>
4025
- <g mask="url(#mask0_147_1382)">
4026
- <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"/>
4027
- </g>
4028
- </svg>
4029
- </label>
4030
-
4031
- <!-- Content to show/hide -->
4032
- <ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
4033
- <li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
4034
- <li>Allow "Apps on Device"</li>
4035
- </ul>
4036
- </div>
4037
- </div>
4038
- <div>
4039
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4040
- Got it
4041
- </button>
4042
- </div>
4043
- `;
4044
- const css$2 = `
4045
- .mobile-wallet-adapter-embedded-modal-close {
4046
- display: none;
4047
- }
4048
- .mobile-wallet-adapter-embedded-modal-content {
4049
- text-align: center;
4050
- }
4051
- .mobile-wallet-adapter-embedded-modal-header {
4052
- margin: 18px auto 30px auto;
4053
- color: #7D9093;
4054
- font-size: 1.0em;
4055
- font-weight: 500;
4056
- }
4057
- .mobile-wallet-adapter-embedded-modal-title {
4058
- margin: 18px 100px auto 100px;
4059
- color: #000000;
4060
- font-size: 2.75em;
4061
- font-weight: 600;
4062
- }
4063
- .mobile-wallet-adapter-embedded-modal-subtitle {
4064
- margin: 12px 60px 30px 60px;
4065
- color: #7D9093;
4066
- font-size: 1.25em;
4067
- font-weight: 400;
4068
- }
4069
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header {
4070
- display: flex;
4071
- flex-direction: row;
4072
- justify-content: space-between;
4073
- margin: 10px auto 10px auto;
4074
- color: #000000;
4075
- font-size: 1.5em;
4076
- font-weight: 600;
4077
- cursor: pointer; /* Show pointer on hover */
4078
- transition: background 0.2s ease; /* Smooth background change */
4079
- }
4080
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4081
- transition: rotate 0.3s ease;
4082
- }
4083
- .mobile-wallet-adapter-embedded-modal-details-collapsible-input {
4084
- display: none; /* Hide the checkbox */
4085
- }
4086
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4087
- margin: 0px auto 40px auto;
4088
- max-height: 0px; /* Collapse content */
4089
- overflow: hidden; /* Hide overflow when collapsed */
4090
- transition: max-height 0.3s ease; /* Smooth transition */
4091
- }
4092
- .mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
4093
- margin: 20px auto;
4094
- color: #000000;
4095
- font-size: 1.25em;
4096
- font-weight: 400;
4097
- text-align: left;
4098
- }
4099
- /* When checkbox is checked, show content */
4100
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
4101
- max-height: 300px;
4102
- }
4103
- .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
4104
- rotate: 180deg;
4105
- }
4106
- .mobile-wallet-adapter-embedded-modal-launch-action {
4107
- display: block;
4108
- width: 100%;
4109
- height: 56px;
4110
- /*margin-top: 40px;*/
4111
- font-size: 1.25em;
4112
- /*line-height: 24px;*/
4113
- /*letter-spacing: -1%;*/
4114
- background: #000000;
4115
- color: #FFFFFF;
4116
- border-radius: 18px;
4117
- }
4118
- /* Smaller screens */
4119
- @media all and (max-width: 600px) {
4120
- .mobile-wallet-adapter-embedded-modal-title {
4121
- font-size: 1.75em;
4122
- margin-right: 12px;
4123
- margin-left: 12px;
4079
+ get version() {
4080
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
4124
4081
  }
4125
- .mobile-wallet-adapter-embedded-modal-subtitle {
4126
- margin-right: 12px;
4127
- margin-left: 12px;
4082
+ get name() {
4083
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
4084
+ }
4085
+ get url() {
4086
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
4087
+ }
4088
+ get icon() {
4089
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
4090
+ }
4091
+ get chains() {
4092
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
4093
+ }
4094
+ get features() {
4095
+ return Object.assign({ [StandardConnect]: {
4096
+ version: '1.0.0',
4097
+ connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
4098
+ }, [StandardDisconnect]: {
4099
+ version: '1.0.0',
4100
+ disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
4101
+ }, [StandardEvents]: {
4102
+ version: '1.0.0',
4103
+ on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
4104
+ }, [SolanaSignMessage]: {
4105
+ version: '1.0.0',
4106
+ signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
4107
+ }, [SolanaSignIn]: {
4108
+ version: '1.0.0',
4109
+ signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
4110
+ } }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4111
+ }
4112
+ get accounts() {
4113
+ var _a, _b;
4114
+ return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4115
+ }
4116
+ get connected() {
4117
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4118
+ }
4119
+ get isAuthorized() {
4120
+ return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4121
+ }
4122
+ get currentAuthorization() {
4123
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4124
+ }
4125
+ get cachedAuthorizationResult() {
4126
+ return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4128
4127
  }
4129
4128
  }
4130
- `;
4131
- //#endregion
4132
- //#region src/embedded-modal/loopbackPermissionModal.ts
4133
- var LoopbackPermissionModal = class extends EmbeddedModal {
4134
- contentStyles = css$1;
4135
- contentHtml = ErrorDialogHtml$1;
4136
- async init() {
4137
- super.init();
4138
- this.#prepareLaunchAction();
4139
- }
4140
- #prepareLaunchAction() {
4141
- const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4142
- const listener = async () => {
4143
- launchButton?.removeEventListener("click", listener);
4144
- try {
4145
- await fetch("http://localhost");
4146
- } catch {}
4147
- this.close();
4148
- };
4149
- launchButton?.addEventListener("click", listener);
4150
- }
4129
+ _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) {
4130
+ var _a;
4131
+ // eslint-disable-next-line prefer-spread
4132
+ (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4133
+ }, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
4134
+ var _a;
4135
+ __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);
4151
4136
  };
4152
- const ErrorDialogHtml$1 = `
4153
- <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
4154
- <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4155
- Tap "Allow" on the next screen
4156
- </div>
4157
- <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">
4158
- <rect width="281" height="83" rx="22" fill="#F0F3F5"/>
4159
- <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"/>
4160
- <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"/>
4161
- <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"/>
4162
- <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"/>
4163
- <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"/>
4164
- <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"/>
4165
- <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"/>
4166
- <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"/>
4167
- <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"/>
4168
- <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"/>
4169
- <rect x="18" y="17" width="246" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4170
- <rect x="18" y="33" width="82" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4171
- </svg>
4172
- <div>
4173
- <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4174
- Continue to Allow
4175
- </button>
4176
- </div>
4177
- `;
4178
- const css$1 = `
4179
- .mobile-wallet-adapter-embedded-modal-close {
4180
- display: none;
4181
- }
4182
- .mobile-wallet-adapter-embedded-modal-content {
4183
- text-align: center;
4184
- }
4185
- .mobile-wallet-adapter-embedded-modal-title {
4186
- margin: 18px 100px auto 100px;
4187
- color: #000000;
4188
- font-size: 2.75em;
4189
- font-weight: 600;
4190
- }
4191
- .mobile-wallet-adapter-embedded-modal-subtitle {
4192
- margin: 20px 60px 40px 60px;
4193
- color: #7D9093;
4194
- font-size: 1.25em;
4195
- font-weight: 400;
4196
- }
4197
- .mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
4198
- width: 90%;
4199
- height: auto;
4200
- margin: 0 auto 30px auto;
4201
- display: block;
4137
+ class RemoteSolanaMobileWalletAdapterWallet {
4138
+ constructor(config) {
4139
+ _RemoteSolanaMobileWalletAdapterWallet_instances.add(this);
4140
+ _RemoteSolanaMobileWalletAdapterWallet_listeners.set(this, {});
4141
+ _RemoteSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
4142
+ _RemoteSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterRemoteWalletName);
4143
+ _RemoteSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
4144
+ _RemoteSolanaMobileWalletAdapterWallet_icon.set(this, icon);
4145
+ _RemoteSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
4146
+ _RemoteSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
4147
+ _RemoteSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
4148
+ _RemoteSolanaMobileWalletAdapterWallet_connecting.set(this, false);
4149
+ /**
4150
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4151
+ * increment this and use it to make sure that `transact` calls from the previous
4152
+ * 'generation' don't continue to do work and throw exceptions.
4153
+ */
4154
+ _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
4155
+ _RemoteSolanaMobileWalletAdapterWallet_chains.set(this, []);
4156
+ _RemoteSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
4157
+ _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
4158
+ _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
4159
+ _RemoteSolanaMobileWalletAdapterWallet_hostAuthority.set(this, void 0);
4160
+ _RemoteSolanaMobileWalletAdapterWallet_session.set(this, void 0);
4161
+ _RemoteSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
4162
+ var _a;
4163
+ ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
4164
+ return () => __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
4165
+ });
4166
+ _RemoteSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
4167
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
4168
+ return { accounts: this.accounts };
4169
+ }
4170
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4171
+ try {
4172
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
4173
+ }
4174
+ catch (e) {
4175
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4176
+ }
4177
+ finally {
4178
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4179
+ }
4180
+ return { accounts: this.accounts };
4181
+ }));
4182
+ _RemoteSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
4183
+ try {
4184
+ const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4185
+ if (cachedAuthorizationResult) {
4186
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4187
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
4188
+ return cachedAuthorizationResult;
4189
+ }
4190
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f"))
4191
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
4192
+ const selectedChain = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"));
4193
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4194
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4195
+ wallet.getCapabilities(),
4196
+ wallet.authorize({
4197
+ chain: selectedChain,
4198
+ identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4199
+ sign_in_payload: signInPayload,
4200
+ })
4201
+ ]);
4202
+ const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4203
+ const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
4204
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4205
+ Promise.all([
4206
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
4207
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorizationResult),
4208
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorizationResult),
4209
+ ]);
4210
+ return authorizationResult;
4211
+ }));
4212
+ }
4213
+ catch (e) {
4214
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4215
+ }
4216
+ }));
4217
+ _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
4218
+ var _a;
4219
+ const didPublicKeysChange =
4220
+ // Case 1: We started from having no authorization.
4221
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
4222
+ // Case 2: The number of authorized accounts changed.
4223
+ ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
4224
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
4225
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4226
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, authorization);
4227
+ if (didPublicKeysChange) {
4228
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4229
+ }
4230
+ }));
4231
+ _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
4232
+ // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
4233
+ const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
4234
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions ||
4235
+ capabilities.features.includes('solana:signAndSendTransaction');
4236
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
4237
+ SolanaSignTransaction in this.features !== supportsSignTransaction;
4238
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, (supportsSignAndSendTransaction && {
4239
+ [SolanaSignAndSendTransaction]: {
4240
+ version: '1.0.0',
4241
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4242
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4243
+ },
4244
+ })), (supportsSignTransaction && {
4245
+ [SolanaSignTransaction]: {
4246
+ version: '1.0.0',
4247
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4248
+ signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4249
+ },
4250
+ })));
4251
+ if (didCapabilitiesChange) {
4252
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
4253
+ }
4254
+ }));
4255
+ _RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
4256
+ var _b, _c;
4257
+ try {
4258
+ const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4259
+ (_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
4260
+ wallet.authorize({
4261
+ auth_token: authToken,
4262
+ identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4263
+ chain: chain
4264
+ })
4265
+ ]);
4266
+ const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4267
+ const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
4268
+ // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4269
+ Promise.all([
4270
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
4271
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
4272
+ ]);
4273
+ }
4274
+ catch (e) {
4275
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
4276
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4277
+ }
4278
+ }));
4279
+ _RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
4280
+ var _d;
4281
+ var _e;
4282
+ (_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
4283
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4284
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4285
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e));
4286
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined);
4287
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined);
4288
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4289
+ }));
4290
+ _RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
4291
+ var _f;
4292
+ const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
4293
+ const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
4294
+ const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
4295
+ const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
4296
+ const modal = new RemoteConnectionModal();
4297
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) {
4298
+ return callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4299
+ }
4300
+ try {
4301
+ const { associationUrl, close, wallet } = yield startRemoteScenario(remoteConfig);
4302
+ const removeCloseListener = modal.addEventListener('close', (event) => {
4303
+ if (event)
4304
+ close();
4305
+ });
4306
+ modal.initWithQR(associationUrl.toString());
4307
+ modal.open();
4308
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, { close, wallet: yield wallet }, "f");
4309
+ removeCloseListener();
4310
+ modal.close();
4311
+ return yield callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4312
+ }
4313
+ catch (e) {
4314
+ modal.close();
4315
+ if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
4316
+ yield new Promise(() => { }); // Never resolve.
4317
+ }
4318
+ if (e instanceof Error &&
4319
+ e.name === 'SolanaMobileWalletAdapterError' &&
4320
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
4321
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
4322
+ }
4323
+ throw e;
4324
+ }
4325
+ }));
4326
+ _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
4327
+ if (!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f"))
4328
+ throw new Error('Wallet not connected');
4329
+ return { authToken: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").chain };
4330
+ });
4331
+ _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
4332
+ return accounts.map((account) => {
4333
+ var _a, _b;
4334
+ const publicKey = toUint8Array(account.address);
4335
+ return {
4336
+ address: base58.encode(publicKey),
4337
+ publicKey,
4338
+ label: account.label,
4339
+ icon: account.icon,
4340
+ chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"),
4341
+ // TODO: get supported features from getCapabilities API
4342
+ features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
4343
+ };
4344
+ });
4345
+ });
4346
+ _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
4347
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4348
+ try {
4349
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4350
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4351
+ const signedTransactions = (yield wallet.signTransactions({
4352
+ payloads: transactions.map(fromUint8Array),
4353
+ })).signed_payloads.map(toUint8Array);
4354
+ return signedTransactions;
4355
+ }));
4356
+ }
4357
+ catch (e) {
4358
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4359
+ }
4360
+ }));
4361
+ _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
4362
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4363
+ try {
4364
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4365
+ const [capabilities, _1] = yield Promise.all([
4366
+ wallet.getCapabilities(),
4367
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
4368
+ ]);
4369
+ if (capabilities.supports_sign_and_send_transactions) {
4370
+ const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [fromUint8Array(transaction)] }))).signatures.map(toUint8Array);
4371
+ return signatures[0];
4372
+ }
4373
+ else {
4374
+ throw new Error('connected wallet does not support signAndSendTransaction');
4375
+ }
4376
+ }));
4377
+ }
4378
+ catch (e) {
4379
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4380
+ }
4381
+ }));
4382
+ _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4383
+ const outputs = [];
4384
+ for (const input of inputs) {
4385
+ const signature = (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options));
4386
+ outputs.push({ signature });
4387
+ }
4388
+ return outputs;
4389
+ }));
4390
+ _RemoteSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4391
+ return (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
4392
+ .map((signedTransaction) => {
4393
+ return { signedTransaction };
4394
+ });
4395
+ }));
4396
+ _RemoteSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4397
+ const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4398
+ const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4399
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4400
+ try {
4401
+ return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4402
+ yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4403
+ const signedMessages = (yield wallet.signMessages({
4404
+ addresses: addresses,
4405
+ payloads: messages,
4406
+ })).signed_payloads.map(toUint8Array);
4407
+ return signedMessages.map((signedMessage) => {
4408
+ return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4409
+ });
4410
+ }));
4411
+ }
4412
+ catch (e) {
4413
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4414
+ }
4415
+ }));
4416
+ _RemoteSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4417
+ const outputs = [];
4418
+ if (inputs.length > 1) {
4419
+ for (const input of inputs) {
4420
+ outputs.push(yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4421
+ }
4422
+ }
4423
+ else {
4424
+ return [yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4425
+ }
4426
+ return outputs;
4427
+ }));
4428
+ _RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4429
+ var _g, _h, _j;
4430
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4431
+ try {
4432
+ const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
4433
+ if (!authorizationResult.sign_in_result) {
4434
+ throw new Error("Sign in failed, no sign in result returned by wallet");
4435
+ }
4436
+ const signedInAddress = authorizationResult.sign_in_result.address;
4437
+ const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4438
+ return {
4439
+ account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4440
+ address: base58.encode(toUint8Array(signedInAddress))
4441
+ }), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
4442
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4443
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4444
+ };
4445
+ }
4446
+ catch (e) {
4447
+ throw new Error((e instanceof Error && e.message) || 'Unknown error');
4448
+ }
4449
+ finally {
4450
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4451
+ }
4452
+ }));
4453
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4454
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4455
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, config.chains);
4456
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4457
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority);
4458
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4459
+ __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
4460
+ // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4461
+ // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4462
+ // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4463
+ // assume both are supported here. The features will be updated based on the actual connected
4464
+ // wallets capabilities during connection regardless, so this is safe.
4465
+ [SolanaSignAndSendTransaction]: {
4466
+ version: '1.0.0',
4467
+ supportedTransactionVersions: ['legacy', 0],
4468
+ signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4469
+ },
4470
+ [SolanaSignTransaction]: {
4471
+ version: '1.0.0',
4472
+ supportedTransactionVersions: ['legacy', 0],
4473
+ signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4474
+ },
4475
+ });
4476
+ }
4477
+ get version() {
4478
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_version, "f");
4479
+ }
4480
+ get name() {
4481
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_name, "f");
4482
+ }
4483
+ get url() {
4484
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_url, "f");
4485
+ }
4486
+ get icon() {
4487
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_icon, "f");
4488
+ }
4489
+ get chains() {
4490
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f");
4491
+ }
4492
+ get features() {
4493
+ return Object.assign({ [StandardConnect]: {
4494
+ version: '1.0.0',
4495
+ connect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connect, "f"),
4496
+ }, [StandardDisconnect]: {
4497
+ version: '1.0.0',
4498
+ disconnect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f"),
4499
+ }, [StandardEvents]: {
4500
+ version: '1.0.0',
4501
+ on: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_on, "f"),
4502
+ }, [SolanaSignMessage]: {
4503
+ version: '1.0.0',
4504
+ signMessage: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signMessage, "f"),
4505
+ }, [SolanaSignIn]: {
4506
+ version: '1.0.0',
4507
+ signIn: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signIn, "f"),
4508
+ } }, __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4509
+ }
4510
+ get accounts() {
4511
+ var _a, _b;
4512
+ return (_b = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4513
+ }
4514
+ get connected() {
4515
+ return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f") && !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4516
+ }
4517
+ get isAuthorized() {
4518
+ return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4519
+ }
4520
+ get currentAuthorization() {
4521
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4522
+ }
4523
+ get cachedAuthorizationResult() {
4524
+ return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4525
+ }
4202
4526
  }
4203
- .mobile-wallet-adapter-embedded-modal-launch-action {
4204
- display: block;
4205
- width: 100%;
4206
- height: 56px;
4207
- font-size: 1.25em;
4208
- background: #000000;
4209
- color: #FFFFFF;
4210
- border-radius: 18px;
4527
+ _RemoteSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_version = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_name = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_url = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_hostAuthority = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_session = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_on = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _RemoteSolanaMobileWalletAdapterWallet_emit = function _RemoteSolanaMobileWalletAdapterWallet_emit(event, ...args) {
4528
+ var _a;
4529
+ // eslint-disable-next-line prefer-spread
4530
+ (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4531
+ }, _RemoteSolanaMobileWalletAdapterWallet_off = function _RemoteSolanaMobileWalletAdapterWallet_off(event, listener) {
4532
+ var _a;
4533
+ __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
4534
+ };
4535
+
4536
+ var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
4537
+ if (kind === "m") throw new TypeError("Private method is not writable");
4538
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4539
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
4540
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4541
+ };
4542
+ var __classPrivateFieldGet = function (receiver, state, kind, f) {
4543
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4544
+ 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");
4545
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4546
+ };
4547
+ var _RegisterWalletEvent_detail;
4548
+ /**
4549
+ * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
4550
+ *
4551
+ * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
4552
+ * ready to be registered.
4553
+ *
4554
+ * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
4555
+ * the app that the app is ready to register the Wallet.
4556
+ *
4557
+ * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
4558
+ * as the app is ready whether the Wallet loads before or after the app.
4559
+ *
4560
+ * @param wallet Wallet to register.
4561
+ *
4562
+ * @group Wallet
4563
+ */
4564
+ function registerWallet(wallet) {
4565
+ const callback = ({ register }) => register(wallet);
4566
+ try {
4567
+ window.dispatchEvent(new RegisterWalletEvent(callback));
4568
+ }
4569
+ catch (error) {
4570
+ console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
4571
+ }
4572
+ try {
4573
+ window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
4574
+ }
4575
+ catch (error) {
4576
+ console.error('wallet-standard:app-ready event listener could not be added\n', error);
4577
+ }
4211
4578
  }
4212
- /* Smaller screens */
4213
- @media all and (max-width: 600px) {
4214
- .mobile-wallet-adapter-embedded-modal-title {
4215
- font-size: 1.5em;
4216
- margin-right: 12px;
4217
- margin-left: 12px;
4579
+ class RegisterWalletEvent extends Event {
4580
+ constructor(callback) {
4581
+ super('wallet-standard:register-wallet', {
4582
+ bubbles: false,
4583
+ cancelable: false,
4584
+ composed: false,
4585
+ });
4586
+ _RegisterWalletEvent_detail.set(this, void 0);
4587
+ __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
4218
4588
  }
4219
- .mobile-wallet-adapter-embedded-modal-subtitle {
4220
- margin-right: 12px;
4221
- margin-left: 12px;
4589
+ get detail() {
4590
+ return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
4591
+ }
4592
+ get type() {
4593
+ return 'wallet-standard:register-wallet';
4594
+ }
4595
+ /** @deprecated */
4596
+ preventDefault() {
4597
+ throw new Error('preventDefault cannot be called');
4598
+ }
4599
+ /** @deprecated */
4600
+ stopImmediatePropagation() {
4601
+ throw new Error('stopImmediatePropagation cannot be called');
4602
+ }
4603
+ /** @deprecated */
4604
+ stopPropagation() {
4605
+ throw new Error('stopPropagation cannot be called');
4222
4606
  }
4223
4607
  }
4224
- `;
4225
- //#endregion
4226
- //#region src/getIsSupported.ts
4608
+ _RegisterWalletEvent_detail = new WeakMap();
4609
+
4227
4610
  function getIsLocalAssociationSupported() {
4228
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
4611
+ return (typeof window !== 'undefined' &&
4612
+ window.isSecureContext &&
4613
+ typeof document !== 'undefined' &&
4614
+ /android/i.test(navigator.userAgent));
4229
4615
  }
4230
4616
  function getIsRemoteAssociationSupported() {
4231
- return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
4617
+ return (typeof window !== 'undefined' &&
4618
+ window.isSecureContext &&
4619
+ typeof document !== 'undefined' &&
4620
+ !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
4232
4621
  }
4622
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
4623
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
4233
4624
  function isWebView(userAgentString) {
4234
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4235
- }
4236
- function isSolanaMobileWebShell(userAgentString) {
4237
- return userAgentString.includes("Solana Mobile Web Shell");
4238
- }
4239
- function getIsPwaLaunchedAsApp() {
4240
- const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
4241
- if (typeof window == "undefined") return isAndroidTwa;
4242
- const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
4243
- const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
4244
- const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
4245
- return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
4246
- }
4247
- async function checkLocalNetworkAccessPermission() {
4248
- if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
4249
- try {
4250
- const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
4251
- if (lnaPermission.state === "granted") return;
4252
- else if (lnaPermission.state === "denied") {
4253
- const modal = new LoopbackPermissionBlockedModal();
4254
- modal.init();
4255
- modal.open();
4256
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
4257
- } else if (lnaPermission.state === "prompt") {
4258
- const modal = new LoopbackPermissionModal();
4259
- if (await new Promise((resolve, reject) => {
4260
- modal.addEventListener("close", (event) => {
4261
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4262
- });
4263
- lnaPermission.onchange = () => {
4264
- lnaPermission.onchange = null;
4265
- resolve(lnaPermission.state);
4266
- };
4267
- modal.init();
4268
- modal.open();
4269
- }) === "granted") {
4270
- const modal = new LocalConnectionModal();
4271
- await new Promise((resolve, reject) => {
4272
- modal.addEventListener("close", (event) => {
4273
- if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4274
- });
4275
- modal.initWithCallback(async () => {
4276
- resolve(true);
4277
- });
4278
- modal.open();
4279
- });
4280
- return;
4281
- } else return await checkLocalNetworkAccessPermission();
4282
- }
4283
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
4284
- } catch (e) {
4285
- if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
4286
- if (e instanceof SolanaMobileWalletAdapterError) throw e;
4287
- throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
4288
- }
4289
- }
4290
- //#endregion
4291
- //#region src/icon.ts
4292
- const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
4293
- //#endregion
4294
- //#region src/wallet.ts
4295
- const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
4296
- const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
4297
- const SIGNATURE_LENGTH_IN_BYTES = 64;
4298
- const DEFAULT_FEATURES = [
4299
- SolanaSignAndSendTransaction,
4300
- SolanaSignTransaction,
4301
- SolanaSignMessage,
4302
- SolanaSignIn
4303
- ];
4304
- const WALLET_ASSOCIATION_TIMEOUT = 3e4;
4305
- function getErrorMessage(error) {
4306
- return error instanceof Error ? error.message : "Unknown error";
4625
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4307
4626
  }
4308
- var LocalSolanaMobileWalletAdapterWallet = class {
4309
- #listeners = {};
4310
- #version = "1.0.0";
4311
- #name = SolanaMobileWalletAdapterWalletName;
4312
- #url = "https://solanamobile.com/wallets";
4313
- #icon = icon;
4314
- #appIdentity;
4315
- #authorization;
4316
- #authorizationCache;
4317
- #connecting = false;
4318
- /**
4319
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4320
- * increment this and use it to make sure that `transact` calls from the previous
4321
- * 'generation' don't continue to do work and throw exceptions.
4322
- */
4323
- #connectionGeneration = 0;
4324
- #chains = [];
4325
- #chainSelector;
4326
- #optionalFeatures;
4327
- #onWalletNotFound;
4328
- get version() {
4329
- return this.#version;
4330
- }
4331
- get name() {
4332
- return this.#name;
4333
- }
4334
- get url() {
4335
- return this.#url;
4336
- }
4337
- get icon() {
4338
- return this.#icon;
4339
- }
4340
- get chains() {
4341
- return this.#chains;
4342
- }
4343
- get features() {
4344
- return {
4345
- [StandardConnect]: {
4346
- version: "1.0.0",
4347
- connect: this.#connect
4348
- },
4349
- [StandardDisconnect]: {
4350
- version: "1.0.0",
4351
- disconnect: this.#disconnect
4352
- },
4353
- [StandardEvents]: {
4354
- version: "1.0.0",
4355
- on: this.#on
4356
- },
4357
- [SolanaSignMessage]: {
4358
- version: "1.0.0",
4359
- signMessage: this.#signMessage
4360
- },
4361
- [SolanaSignIn]: {
4362
- version: "1.0.0",
4363
- signIn: this.#signIn
4364
- },
4365
- ...this.#optionalFeatures
4366
- };
4367
- }
4368
- get accounts() {
4369
- return this.#authorization?.accounts ?? [];
4370
- }
4371
- constructor(config) {
4372
- this.#authorizationCache = config.authorizationCache;
4373
- this.#appIdentity = config.appIdentity;
4374
- this.#chains = config.chains;
4375
- this.#chainSelector = config.chainSelector;
4376
- this.#onWalletNotFound = config.onWalletNotFound;
4377
- this.#optionalFeatures = {
4378
- [SolanaSignAndSendTransaction]: {
4379
- version: "1.0.0",
4380
- supportedTransactionVersions: ["legacy", 0],
4381
- signAndSendTransaction: this.#signAndSendTransaction
4382
- },
4383
- [SolanaSignTransaction]: {
4384
- version: "1.0.0",
4385
- supportedTransactionVersions: ["legacy", 0],
4386
- signTransaction: this.#signTransaction
4387
- }
4388
- };
4389
- }
4390
- get connected() {
4391
- return !!this.#authorization;
4392
- }
4393
- get isAuthorized() {
4394
- return !!this.#authorization;
4395
- }
4396
- get currentAuthorization() {
4397
- return this.#authorization;
4398
- }
4399
- get cachedAuthorizationResult() {
4400
- return this.#authorizationCache.get();
4401
- }
4402
- #on = (event, listener) => {
4403
- this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4404
- return () => this.#off(event, listener);
4405
- };
4406
- #emit(event, ...args) {
4407
- this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4408
- }
4409
- #off(event, listener) {
4410
- this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4411
- }
4412
- #connect = async ({ silent } = {}) => {
4413
- if (this.#connecting || this.connected) return { accounts: this.accounts };
4414
- this.#connecting = true;
4415
- try {
4416
- if (silent) {
4417
- const cachedAuthorization = await this.#authorizationCache.get();
4418
- if (cachedAuthorization) {
4419
- await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
4420
- await this.#handleAuthorizationResult(cachedAuthorization);
4421
- } else return { accounts: this.accounts };
4422
- } else await this.#performAuthorization();
4423
- } catch (e) {
4424
- throw new Error(getErrorMessage(e), { cause: e });
4425
- } finally {
4426
- this.#connecting = false;
4427
- }
4428
- return { accounts: this.accounts };
4429
- };
4430
- #performAuthorization = async (signInPayload) => {
4431
- try {
4432
- const cachedAuthorizationResult = await this.#authorizationCache.get();
4433
- if (cachedAuthorizationResult) {
4434
- this.#handleAuthorizationResult(cachedAuthorizationResult);
4435
- return cachedAuthorizationResult;
4436
- }
4437
- const selectedChain = await this.#chainSelector.select(this.#chains);
4438
- return await this.#transact(async (wallet) => {
4439
- const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4440
- chain: selectedChain,
4441
- identity: this.#appIdentity,
4442
- sign_in_payload: signInPayload
4443
- })]);
4444
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4445
- const authorization = {
4446
- ...mwaAuthorizationResult,
4447
- accounts,
4448
- chain: selectedChain,
4449
- capabilities
4450
- };
4451
- Promise.all([
4452
- this.#handleWalletCapabilitiesResult(capabilities),
4453
- this.#authorizationCache.set(authorization),
4454
- this.#handleAuthorizationResult(authorization)
4455
- ]);
4456
- return authorization;
4457
- });
4458
- } catch (e) {
4459
- throw new Error(getErrorMessage(e), { cause: e });
4460
- }
4461
- };
4462
- #handleAuthorizationResult = async (authorization) => {
4463
- const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4464
- this.#authorization = authorization;
4465
- if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4466
- };
4467
- #handleWalletCapabilitiesResult = async (capabilities) => {
4468
- const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4469
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
4470
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4471
- this.#optionalFeatures = {
4472
- ...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
4473
- version: "1.0.0",
4474
- supportedTransactionVersions: ["legacy", 0],
4475
- signAndSendTransaction: this.#signAndSendTransaction
4476
- } },
4477
- ...supportsSignTransaction && { [SolanaSignTransaction]: {
4478
- version: "1.0.0",
4479
- supportedTransactionVersions: ["legacy", 0],
4480
- signTransaction: this.#signTransaction
4481
- } }
4482
- };
4483
- if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4484
- };
4485
- #performReauthorization = async (wallet, authToken, chain) => {
4486
- try {
4487
- const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4488
- auth_token: authToken,
4489
- identity: this.#appIdentity,
4490
- chain
4491
- })]);
4492
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4493
- const authorization = {
4494
- ...mwaAuthorizationResult,
4495
- accounts,
4496
- chain,
4497
- capabilities
4498
- };
4499
- Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4500
- } catch (e) {
4501
- this.#disconnect();
4502
- throw new Error(getErrorMessage(e), { cause: e });
4503
- }
4504
- };
4505
- #disconnect = async () => {
4506
- this.#authorizationCache.clear();
4507
- this.#connecting = false;
4508
- this.#connectionGeneration++;
4509
- this.#authorization = void 0;
4510
- this.#emit("change", { accounts: this.accounts });
4511
- };
4512
- #transact = async (callback) => {
4513
- const walletUriBase = this.#authorization?.wallet_uri_base;
4514
- const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
4515
- const currentConnectionGeneration = this.#connectionGeneration;
4516
- const loadingSpinner = new EmbeddedLoadingSpinner();
4517
- try {
4518
- let associating = true;
4519
- let timeout = void 0;
4520
- const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
4521
- loadingSpinner.init();
4522
- const { wallet, close } = await startScenario(config);
4523
- associating = false;
4524
- loadingSpinner.addEventListener("close", (event) => {
4525
- if (event) close();
4526
- });
4527
- loadingSpinner.open();
4528
- const result = await callback(await wallet);
4529
- loadingSpinner.close();
4530
- close();
4531
- return result;
4532
- }), new Promise((_, reject) => {
4533
- timeout = setTimeout(() => {
4534
- if (associating) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
4535
- }, WALLET_ASSOCIATION_TIMEOUT);
4536
- })]);
4537
- clearTimeout(timeout);
4538
- return result;
4539
- } catch (e) {
4540
- loadingSpinner.close();
4541
- if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4542
- if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4543
- throw e;
4544
- }
4545
- };
4546
- #assertIsAuthorized = () => {
4547
- if (!this.#authorization) throw new Error("Wallet not connected");
4548
- return {
4549
- authToken: this.#authorization.auth_token,
4550
- chain: this.#authorization.chain
4551
- };
4552
- };
4553
- #accountsToWalletStandardAccounts = (accounts) => {
4554
- return accounts.map((account) => {
4555
- const publicKey = toUint8Array(account.address);
4556
- return {
4557
- address: base58.encode(publicKey),
4558
- publicKey,
4559
- label: account.label,
4560
- icon: account.icon,
4561
- chains: account.chains ?? this.#chains,
4562
- features: account.features ?? DEFAULT_FEATURES
4563
- };
4564
- });
4565
- };
4566
- #performSignTransactions = async (transactions) => {
4567
- const { authToken, chain } = this.#assertIsAuthorized();
4568
- try {
4569
- const base64Transactions = transactions.map((tx) => {
4570
- return fromUint8Array(tx);
4571
- });
4572
- return await this.#transact(async (wallet) => {
4573
- await this.#performReauthorization(wallet, authToken, chain);
4574
- return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
4575
- });
4576
- } catch (e) {
4577
- throw new Error(getErrorMessage(e), { cause: e });
4578
- }
4579
- };
4580
- #performSignAndSendTransaction = async (transaction, options) => {
4581
- const { authToken, chain } = this.#assertIsAuthorized();
4582
- try {
4583
- return await this.#transact(async (wallet) => {
4584
- const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4585
- if (capabilities.supports_sign_and_send_transactions) {
4586
- const base64Transaction = fromUint8Array(transaction);
4587
- return (await wallet.signAndSendTransactions({
4588
- ...options,
4589
- payloads: [base64Transaction]
4590
- })).signatures.map(toUint8Array)[0];
4591
- } else throw new Error("connected wallet does not support signAndSendTransaction");
4592
- });
4593
- } catch (e) {
4594
- throw new Error(getErrorMessage(e), { cause: e });
4595
- }
4596
- };
4597
- #signAndSendTransaction = async (...inputs) => {
4598
- const outputs = [];
4599
- for (const input of inputs) {
4600
- const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4601
- outputs.push({ signature });
4602
- }
4603
- return outputs;
4604
- };
4605
- #signTransaction = async (...inputs) => {
4606
- return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4607
- return { signedTransaction };
4608
- });
4609
- };
4610
- #signMessage = async (...inputs) => {
4611
- const { authToken, chain } = this.#assertIsAuthorized();
4612
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4613
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4614
- try {
4615
- return await this.#transact(async (wallet) => {
4616
- await this.#performReauthorization(wallet, authToken, chain);
4617
- return (await wallet.signMessages({
4618
- addresses,
4619
- payloads: messages
4620
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4621
- return {
4622
- signedMessage,
4623
- signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4624
- };
4625
- });
4626
- });
4627
- } catch (e) {
4628
- throw new Error(getErrorMessage(e), { cause: e });
4629
- }
4630
- };
4631
- #signIn = async (...inputs) => {
4632
- const outputs = [];
4633
- if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4634
- else return [await this.#performSignIn(inputs[0])];
4635
- return outputs;
4636
- };
4637
- #performSignIn = async (input) => {
4638
- this.#connecting = true;
4639
- try {
4640
- const authorizationResult = await this.#performAuthorization({
4641
- ...input,
4642
- domain: input?.domain ?? window.location.host
4643
- });
4644
- if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4645
- const signedInAddress = authorizationResult.sign_in_result.address;
4646
- const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4647
- return {
4648
- account: {
4649
- ...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
4650
- publicKey: toUint8Array(signedInAddress),
4651
- chains: signedInAccount?.chains ?? this.#chains,
4652
- features: signedInAccount?.features ?? authorizationResult.capabilities.features
4653
- },
4654
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4655
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4656
- };
4657
- } catch (e) {
4658
- throw new Error(getErrorMessage(e), { cause: e });
4659
- } finally {
4660
- this.#connecting = false;
4661
- }
4662
- };
4663
- };
4664
- var RemoteSolanaMobileWalletAdapterWallet = class {
4665
- #listeners = {};
4666
- #version = "1.0.0";
4667
- #name = SolanaMobileWalletAdapterRemoteWalletName;
4668
- #url = "https://solanamobile.com/wallets";
4669
- #icon = icon;
4670
- #appIdentity;
4671
- #authorization;
4672
- #authorizationCache;
4673
- #connecting = false;
4674
- /**
4675
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4676
- * increment this and use it to make sure that `transact` calls from the previous
4677
- * 'generation' don't continue to do work and throw exceptions.
4678
- */
4679
- #connectionGeneration = 0;
4680
- #chains = [];
4681
- #chainSelector;
4682
- #optionalFeatures;
4683
- #onWalletNotFound;
4684
- #hostAuthority;
4685
- #session;
4686
- get version() {
4687
- return this.#version;
4688
- }
4689
- get name() {
4690
- return this.#name;
4691
- }
4692
- get url() {
4693
- return this.#url;
4694
- }
4695
- get icon() {
4696
- return this.#icon;
4697
- }
4698
- get chains() {
4699
- return this.#chains;
4700
- }
4701
- get features() {
4702
- return {
4703
- [StandardConnect]: {
4704
- version: "1.0.0",
4705
- connect: this.#connect
4706
- },
4707
- [StandardDisconnect]: {
4708
- version: "1.0.0",
4709
- disconnect: this.#disconnect
4710
- },
4711
- [StandardEvents]: {
4712
- version: "1.0.0",
4713
- on: this.#on
4714
- },
4715
- [SolanaSignMessage]: {
4716
- version: "1.0.0",
4717
- signMessage: this.#signMessage
4718
- },
4719
- [SolanaSignIn]: {
4720
- version: "1.0.0",
4721
- signIn: this.#signIn
4722
- },
4723
- ...this.#optionalFeatures
4724
- };
4725
- }
4726
- get accounts() {
4727
- return this.#authorization?.accounts ?? [];
4728
- }
4729
- constructor(config) {
4730
- this.#authorizationCache = config.authorizationCache;
4731
- this.#appIdentity = config.appIdentity;
4732
- this.#chains = config.chains;
4733
- this.#chainSelector = config.chainSelector;
4734
- this.#hostAuthority = config.remoteHostAuthority;
4735
- this.#onWalletNotFound = config.onWalletNotFound;
4736
- this.#optionalFeatures = {
4737
- [SolanaSignAndSendTransaction]: {
4738
- version: "1.0.0",
4739
- supportedTransactionVersions: ["legacy", 0],
4740
- signAndSendTransaction: this.#signAndSendTransaction
4741
- },
4742
- [SolanaSignTransaction]: {
4743
- version: "1.0.0",
4744
- supportedTransactionVersions: ["legacy", 0],
4745
- signTransaction: this.#signTransaction
4746
- }
4747
- };
4748
- }
4749
- get connected() {
4750
- return !!this.#session && !!this.#authorization;
4751
- }
4752
- get isAuthorized() {
4753
- return !!this.#authorization;
4754
- }
4755
- get currentAuthorization() {
4756
- return this.#authorization;
4757
- }
4758
- get cachedAuthorizationResult() {
4759
- return this.#authorizationCache.get();
4760
- }
4761
- #on = (event, listener) => {
4762
- this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4763
- return () => this.#off(event, listener);
4764
- };
4765
- #emit(event, ...args) {
4766
- this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4767
- }
4768
- #off(event, listener) {
4769
- this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4770
- }
4771
- #connect = async (_input = {}) => {
4772
- if (this.#connecting || this.connected) return { accounts: this.accounts };
4773
- this.#connecting = true;
4774
- try {
4775
- await this.#performAuthorization();
4776
- } catch (e) {
4777
- throw new Error(getErrorMessage(e), { cause: e });
4778
- } finally {
4779
- this.#connecting = false;
4780
- }
4781
- return { accounts: this.accounts };
4782
- };
4783
- #performAuthorization = async (signInPayload) => {
4784
- try {
4785
- const cachedAuthorizationResult = await this.#authorizationCache.get();
4786
- if (cachedAuthorizationResult) {
4787
- this.#handleAuthorizationResult(cachedAuthorizationResult);
4788
- return cachedAuthorizationResult;
4789
- }
4790
- if (this.#session) this.#session = void 0;
4791
- const selectedChain = await this.#chainSelector.select(this.#chains);
4792
- return await this.#transact(async (wallet) => {
4793
- const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4794
- chain: selectedChain,
4795
- identity: this.#appIdentity,
4796
- sign_in_payload: signInPayload
4797
- })]);
4798
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4799
- const authorizationResult = {
4800
- ...mwaAuthorizationResult,
4801
- accounts,
4802
- chain: selectedChain,
4803
- capabilities
4804
- };
4805
- Promise.all([
4806
- this.#handleWalletCapabilitiesResult(capabilities),
4807
- this.#authorizationCache.set(authorizationResult),
4808
- this.#handleAuthorizationResult(authorizationResult)
4809
- ]);
4810
- return authorizationResult;
4811
- });
4812
- } catch (e) {
4813
- throw new Error(getErrorMessage(e), { cause: e });
4814
- }
4815
- };
4816
- #handleAuthorizationResult = async (authorization) => {
4817
- const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4818
- this.#authorization = authorization;
4819
- if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4820
- };
4821
- #handleWalletCapabilitiesResult = async (capabilities) => {
4822
- const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4823
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
4824
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4825
- this.#optionalFeatures = {
4826
- ...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
4827
- version: "1.0.0",
4828
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4829
- signAndSendTransaction: this.#signAndSendTransaction
4830
- } },
4831
- ...supportsSignTransaction && { [SolanaSignTransaction]: {
4832
- version: "1.0.0",
4833
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4834
- signTransaction: this.#signTransaction
4835
- } }
4836
- };
4837
- if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4838
- };
4839
- #performReauthorization = async (wallet, authToken, chain) => {
4840
- try {
4841
- const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4842
- auth_token: authToken,
4843
- identity: this.#appIdentity,
4844
- chain
4845
- })]);
4846
- const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4847
- const authorization = {
4848
- ...mwaAuthorizationResult,
4849
- accounts,
4850
- chain,
4851
- capabilities
4852
- };
4853
- Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4854
- } catch (e) {
4855
- this.#disconnect();
4856
- throw new Error(getErrorMessage(e), { cause: e });
4857
- }
4858
- };
4859
- #disconnect = async () => {
4860
- this.#session?.close();
4861
- this.#authorizationCache.clear();
4862
- this.#connecting = false;
4863
- this.#connectionGeneration++;
4864
- this.#authorization = void 0;
4865
- this.#session = void 0;
4866
- this.#emit("change", { accounts: this.accounts });
4867
- };
4868
- #transact = async (callback) => {
4869
- const walletUriBase = this.#authorization?.wallet_uri_base;
4870
- const remoteConfig = {
4871
- ...walletUriBase ? { baseUri: walletUriBase } : void 0,
4872
- remoteHostAuthority: this.#hostAuthority
4873
- };
4874
- const currentConnectionGeneration = this.#connectionGeneration;
4875
- const modal = new RemoteConnectionModal();
4876
- if (this.#session) return callback(this.#session.wallet);
4877
- try {
4878
- modal.init();
4879
- modal.open();
4880
- const { associationUrl, close, wallet } = await startRemoteScenario(remoteConfig);
4881
- const removeCloseListener = modal.addEventListener("close", (event) => {
4882
- if (event) close();
4883
- });
4884
- modal.populateQRCode(associationUrl.toString());
4885
- this.#session = {
4886
- close,
4887
- wallet: await wallet
4888
- };
4889
- removeCloseListener();
4890
- modal.close();
4891
- return await callback(this.#session.wallet);
4892
- } catch (e) {
4893
- modal.close();
4894
- if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4895
- if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4896
- throw e;
4897
- }
4898
- };
4899
- #assertIsAuthorized = () => {
4900
- if (!this.#authorization) throw new Error("Wallet not connected");
4901
- return {
4902
- authToken: this.#authorization.auth_token,
4903
- chain: this.#authorization.chain
4904
- };
4905
- };
4906
- #accountsToWalletStandardAccounts = (accounts) => {
4907
- return accounts.map((account) => {
4908
- const publicKey = toUint8Array(account.address);
4909
- return {
4910
- address: base58.encode(publicKey),
4911
- publicKey,
4912
- label: account.label,
4913
- icon: account.icon,
4914
- chains: account.chains ?? this.#chains,
4915
- features: account.features ?? DEFAULT_FEATURES
4916
- };
4917
- });
4918
- };
4919
- #performSignTransactions = async (transactions) => {
4920
- const { authToken, chain } = this.#assertIsAuthorized();
4921
- try {
4922
- return await this.#transact(async (wallet) => {
4923
- await this.#performReauthorization(wallet, authToken, chain);
4924
- return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
4925
- });
4926
- } catch (e) {
4927
- throw new Error(getErrorMessage(e), { cause: e });
4928
- }
4929
- };
4930
- #performSignAndSendTransaction = async (transaction, options) => {
4931
- const { authToken, chain } = this.#assertIsAuthorized();
4932
- try {
4933
- return await this.#transact(async (wallet) => {
4934
- const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4935
- if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
4936
- ...options,
4937
- payloads: [fromUint8Array(transaction)]
4938
- })).signatures.map(toUint8Array)[0];
4939
- else throw new Error("connected wallet does not support signAndSendTransaction");
4940
- });
4941
- } catch (e) {
4942
- throw new Error(getErrorMessage(e), { cause: e });
4943
- }
4944
- };
4945
- #signAndSendTransaction = async (...inputs) => {
4946
- const outputs = [];
4947
- for (const input of inputs) {
4948
- const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4949
- outputs.push({ signature });
4950
- }
4951
- return outputs;
4952
- };
4953
- #signTransaction = async (...inputs) => {
4954
- return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4955
- return { signedTransaction };
4956
- });
4957
- };
4958
- #signMessage = async (...inputs) => {
4959
- const { authToken, chain } = this.#assertIsAuthorized();
4960
- const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4961
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4962
- try {
4963
- return await this.#transact(async (wallet) => {
4964
- await this.#performReauthorization(wallet, authToken, chain);
4965
- return (await wallet.signMessages({
4966
- addresses,
4967
- payloads: messages
4968
- })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4969
- return {
4970
- signedMessage,
4971
- signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4972
- };
4973
- });
4974
- });
4975
- } catch (e) {
4976
- throw new Error(getErrorMessage(e), { cause: e });
4977
- }
4978
- };
4979
- #signIn = async (...inputs) => {
4980
- const outputs = [];
4981
- if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4982
- else return [await this.#performSignIn(inputs[0])];
4983
- return outputs;
4984
- };
4985
- #performSignIn = async (input) => {
4986
- this.#connecting = true;
4987
- try {
4988
- const authorizationResult = await this.#performAuthorization({
4989
- ...input,
4990
- domain: input?.domain ?? window.location.host
4991
- });
4992
- if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4993
- const signedInAddress = authorizationResult.sign_in_result.address;
4994
- const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4995
- return {
4996
- account: {
4997
- ...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
4998
- publicKey: toUint8Array(signedInAddress),
4999
- chains: signedInAccount?.chains ?? this.#chains,
5000
- features: signedInAccount?.features ?? authorizationResult.capabilities.features
5001
- },
5002
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
5003
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
5004
- };
5005
- } catch (e) {
5006
- throw new Error(getErrorMessage(e), { cause: e });
5007
- } finally {
5008
- this.#connecting = false;
5009
- }
5010
- };
5011
- };
5012
- //#endregion
5013
- //#region src/initialize.ts
4627
+
5014
4628
  function registerMwa(config) {
5015
- if (typeof window === "undefined") {
5016
- console.warn(`MWA not registered: no window object`);
5017
- return;
5018
- }
5019
- if (!window.isSecureContext) {
5020
- console.warn(`MWA not registered: secure context required (https)`);
5021
- return;
5022
- }
5023
- const userAgent = navigator.userAgent;
5024
- if (getIsLocalAssociationSupported() && (!isWebView(userAgent) || isSolanaMobileWebShell(userAgent))) registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
5025
- else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== void 0) registerWallet(new RemoteSolanaMobileWalletAdapterWallet({
5026
- ...config,
5027
- remoteHostAuthority: config.remoteHostAuthority
5028
- }));
4629
+ if (typeof window === 'undefined') {
4630
+ console.warn(`MWA not registered: no window object`);
4631
+ return;
4632
+ }
4633
+ if (!window.isSecureContext) {
4634
+ console.warn(`MWA not registered: secure context required (https)`);
4635
+ return;
4636
+ }
4637
+ // Local association technically is possible in a webview, but we prevent registration
4638
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
4639
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
4640
+ registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4641
+ }
4642
+ else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
4643
+ registerWallet(new RemoteSolanaMobileWalletAdapterWallet(Object.assign(Object.assign({}, config), { remoteHostAuthority: config.remoteHostAuthority })));
4644
+ }
4645
+ else ;
4646
+ }
4647
+
4648
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = 'To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.';
4649
+ const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = 'This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.';
4650
+ class ErrorModal extends EmbeddedModal {
4651
+ constructor() {
4652
+ super(...arguments);
4653
+ this.contentStyles = css;
4654
+ this.contentHtml = ErrorDialogHtml;
4655
+ }
4656
+ initWithError(error) {
4657
+ super.init();
4658
+ this.populateError(error);
4659
+ }
4660
+ populateError(error) {
4661
+ var _a, _b;
4662
+ const errorMessageElement = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-error-message');
4663
+ const actionBtn = (_b = this.dom) === null || _b === void 0 ? void 0 : _b.getElementById('mobile-wallet-adapter-error-action');
4664
+ if (errorMessageElement) {
4665
+ if (error.name === 'SolanaMobileWalletAdapterError') {
4666
+ switch (error.code) {
4667
+ case 'ERROR_WALLET_NOT_FOUND':
4668
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4669
+ if (actionBtn)
4670
+ actionBtn.addEventListener('click', () => {
4671
+ window.location.href = 'https://solanamobile.com/wallets';
4672
+ });
4673
+ return;
4674
+ case 'ERROR_BROWSER_NOT_SUPPORTED':
4675
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4676
+ if (actionBtn)
4677
+ actionBtn.style.display = 'none';
4678
+ return;
4679
+ }
4680
+ }
4681
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4682
+ }
4683
+ else {
4684
+ console.log('Failed to locate error dialog element');
4685
+ }
4686
+ }
5029
4687
  }
5030
- //#endregion
5031
- //#region src/embedded-modal/errorModal.ts
5032
- const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
5033
- const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = "This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.";
5034
- var ErrorModal = class extends EmbeddedModal {
5035
- contentStyles = css;
5036
- contentHtml = ErrorDialogHtml;
5037
- initWithError(error) {
5038
- super.init();
5039
- this.populateError(error);
5040
- }
5041
- populateError(error) {
5042
- const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
5043
- const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
5044
- if (errorMessageElement) {
5045
- if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
5046
- case "ERROR_WALLET_NOT_FOUND":
5047
- errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
5048
- if (actionBtn) actionBtn.addEventListener("click", () => {
5049
- window.location.href = "https://solanamobile.com/wallets";
5050
- });
5051
- return;
5052
- case "ERROR_BROWSER_NOT_SUPPORTED":
5053
- errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
5054
- if (actionBtn) actionBtn.style.display = "none";
5055
- return;
5056
- }
5057
- errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
5058
- } else console.log("Failed to locate error dialog element");
5059
- }
5060
- };
5061
4688
  const ErrorDialogHtml = `
5062
4689
  <svg class="mobile-wallet-adapter-embedded-modal-error-icon" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#000000"><path d="M 280,-80 Q 197,-80 138.5,-138.5 80,-197 80,-280 80,-363 138.5,-421.5 197,-480 280,-480 q 83,0 141.5,58.5 58.5,58.5 58.5,141.5 0,83 -58.5,141.5 Q 363,-80 280,-80 Z M 824,-120 568,-376 Q 556,-389 542.5,-402.5 529,-416 516,-428 q 38,-24 61,-64 23,-40 23,-88 0,-75 -52.5,-127.5 Q 495,-760 420,-760 345,-760 292.5,-707.5 240,-655 240,-580 q 0,6 0.5,11.5 0.5,5.5 1.5,11.5 -18,2 -39.5,8 -21.5,6 -38.5,14 -2,-11 -3,-22 -1,-11 -1,-23 0,-109 75.5,-184.5 Q 311,-840 420,-840 q 109,0 184.5,75.5 75.5,75.5 75.5,184.5 0,43 -13.5,81.5 Q 653,-460 629,-428 l 251,252 z m -615,-61 71,-71 70,71 29,-28 -71,-71 71,-71 -28,-28 -71,71 -71,-71 -28,28 71,71 -71,71 z"/></svg>
5063
4690
  <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
@@ -5117,80 +4744,123 @@ const css = `
5117
4744
  }
5118
4745
  }
5119
4746
  `;
5120
- //#endregion
5121
- //#region src/createDefaultWalletNotFoundHandler.ts
5122
- async function defaultErrorModalWalletNotFoundHandler() {
5123
- if (typeof window !== "undefined") {
5124
- const userAgent = window.navigator.userAgent.toLowerCase();
5125
- const errorDialog = new ErrorModal();
5126
- if (userAgent.includes("wv")) errorDialog.initWithError({
5127
- name: "SolanaMobileWalletAdapterError",
5128
- code: "ERROR_BROWSER_NOT_SUPPORTED",
5129
- message: ""
5130
- });
5131
- else errorDialog.initWithError({
5132
- name: "SolanaMobileWalletAdapterError",
5133
- code: "ERROR_WALLET_NOT_FOUND",
5134
- message: ""
5135
- });
5136
- errorDialog.open();
5137
- }
4747
+
4748
+ function defaultErrorModalWalletNotFoundHandler() {
4749
+ return __awaiter(this, void 0, void 0, function* () {
4750
+ if (typeof window !== 'undefined') {
4751
+ const userAgent = window.navigator.userAgent.toLowerCase();
4752
+ const errorDialog = new ErrorModal();
4753
+ if (userAgent.includes('wv')) { // Android WebView
4754
+ // MWA is not supported in this browser so we inform the user
4755
+ // errorDialog.initWithError(
4756
+ // new SolanaMobileWalletAdapterError(
4757
+ // SolanaMobileWalletAdapterErrorCode.ERROR_BROWSER_NOT_SUPPORTED,
4758
+ // ''
4759
+ // )
4760
+ // );
4761
+ // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4762
+ errorDialog.initWithError({
4763
+ name: 'SolanaMobileWalletAdapterError',
4764
+ code: 'ERROR_BROWSER_NOT_SUPPORTED',
4765
+ message: ''
4766
+ });
4767
+ }
4768
+ else { // Browser, user does not have a wallet installed.
4769
+ // errorDialog.initWithError(
4770
+ // new SolanaMobileWalletAdapterError(
4771
+ // SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND,
4772
+ // ''
4773
+ // )
4774
+ // );
4775
+ // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4776
+ errorDialog.initWithError({
4777
+ name: 'SolanaMobileWalletAdapterError',
4778
+ code: 'ERROR_WALLET_NOT_FOUND',
4779
+ message: ''
4780
+ });
4781
+ }
4782
+ errorDialog.open();
4783
+ }
4784
+ });
5138
4785
  }
5139
4786
  function createDefaultWalletNotFoundHandler() {
5140
- return async () => {
5141
- defaultErrorModalWalletNotFoundHandler();
5142
- };
4787
+ return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
5143
4788
  }
5144
- //#endregion
5145
- //#region src/createDefaultAuthorizationCache.ts
5146
- const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
4789
+
4790
+ const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
5147
4791
  function createDefaultAuthorizationCache() {
5148
- let storage;
5149
- try {
5150
- storage = window.localStorage;
5151
- } catch {}
5152
- return {
5153
- async clear() {
5154
- if (!storage) return;
5155
- try {
5156
- storage.removeItem(CACHE_KEY);
5157
- } catch {}
5158
- },
5159
- async get() {
5160
- if (!storage) return;
5161
- try {
5162
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
5163
- if (parsed && parsed.accounts) {
5164
- const parsedAccounts = parsed.accounts.map((account) => {
5165
- return {
5166
- ...account,
5167
- publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : base58.decode(account.address)
5168
- };
5169
- });
5170
- return {
5171
- ...parsed,
5172
- accounts: parsedAccounts
5173
- };
5174
- } else return parsed || void 0;
5175
- } catch {}
5176
- },
5177
- async set(authorization) {
5178
- if (!storage) return;
5179
- try {
5180
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
5181
- } catch {}
5182
- }
5183
- };
4792
+ let storage;
4793
+ try {
4794
+ storage = window.localStorage;
4795
+ // eslint-disable-next-line no-empty
4796
+ }
4797
+ catch (_a) { }
4798
+ return {
4799
+ clear() {
4800
+ return __awaiter(this, void 0, void 0, function* () {
4801
+ if (!storage) {
4802
+ return;
4803
+ }
4804
+ try {
4805
+ storage.removeItem(CACHE_KEY);
4806
+ // eslint-disable-next-line no-empty
4807
+ }
4808
+ catch (_a) { }
4809
+ });
4810
+ },
4811
+ get() {
4812
+ return __awaiter(this, void 0, void 0, function* () {
4813
+ if (!storage) {
4814
+ return;
4815
+ }
4816
+ try {
4817
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
4818
+ if (parsed && parsed.accounts) {
4819
+ const parsedAccounts = parsed.accounts.map((account) => {
4820
+ return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
4821
+ ? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
4822
+ : base58.decode(account.address) });
4823
+ });
4824
+ return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
4825
+ }
4826
+ else
4827
+ return parsed || undefined;
4828
+ // eslint-disable-next-line no-empty
4829
+ }
4830
+ catch (_a) { }
4831
+ });
4832
+ },
4833
+ set(authorization) {
4834
+ return __awaiter(this, void 0, void 0, function* () {
4835
+ if (!storage) {
4836
+ return;
4837
+ }
4838
+ try {
4839
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
4840
+ // eslint-disable-next-line no-empty
4841
+ }
4842
+ catch (_a) { }
4843
+ });
4844
+ },
4845
+ };
5184
4846
  }
5185
- //#endregion
5186
- //#region src/createDefaultChainSelector.ts
4847
+
5187
4848
  function createDefaultChainSelector() {
5188
- return { async select(chains) {
5189
- if (chains.length === 1) return chains[0];
5190
- else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
5191
- else return chains[0];
5192
- } };
4849
+ return {
4850
+ select(chains) {
4851
+ return __awaiter(this, void 0, void 0, function* () {
4852
+ if (chains.length === 1) {
4853
+ return chains[0];
4854
+ }
4855
+ else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
4856
+ return SOLANA_MAINNET_CHAIN;
4857
+ }
4858
+ else
4859
+ return chains[0];
4860
+ });
4861
+ },
4862
+ };
5193
4863
  }
5194
4864
 
5195
4865
  export { LocalSolanaMobileWalletAdapterWallet, RemoteSolanaMobileWalletAdapterWallet, SolanaMobileWalletAdapterRemoteWalletName, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationCache, createDefaultChainSelector, createDefaultWalletNotFoundHandler, defaultErrorModalWalletNotFoundHandler, registerMwa };
5196
- //# sourceMappingURL=index.browser-BuHl80dp.esm.js.map
4866
+ //# sourceMappingURL=index.browser-7dDfRU5G.esm.js.map