@pooflabs/web 0.0.84 → 0.0.85-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 (67) hide show
  1. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +47 -20
  2. package/dist/{index-BM6hgCdH.js → index-B1_Q49qQ.js} +2 -2
  3. package/dist/{index-BM6hgCdH.js.map → index-B1_Q49qQ.js.map} +1 -1
  4. package/dist/{index-CH2G5Y9i.esm.js → index-B7tJ8TAn.esm.js} +2 -2
  5. package/dist/{index-CH2G5Y9i.esm.js.map → index-B7tJ8TAn.esm.js.map} +1 -1
  6. package/dist/{index-BPlF6-PQ.js → index-BeFR3-cf.js} +522 -289
  7. package/dist/{index-BPlF6-PQ.js.map → index-BeFR3-cf.js.map} +1 -1
  8. package/dist/index-DbJCCvVN.esm.js +6 -0
  9. package/dist/index-DbJCCvVN.esm.js.map +1 -0
  10. package/dist/{index-CSeN3jbG.js → index-DflG_JAB.js} +3 -3
  11. package/dist/{index-CSeN3jbG.js.map → index-DflG_JAB.js.map} +1 -1
  12. package/dist/{index-Bp4b5LXs.js → index-DyRIXw-l.js} +2 -2
  13. package/dist/index-DyRIXw-l.js.map +1 -0
  14. package/dist/{index-XHbmzFFO.esm.js → index-QukWgaIi.esm.js} +523 -290
  15. package/dist/{index-XHbmzFFO.esm.js.map → index-QukWgaIi.esm.js.map} +1 -1
  16. package/dist/{index-ep10Sw82.esm.js → index-agGmWBn4.esm.js} +3 -3
  17. package/dist/{index-ep10Sw82.esm.js.map → index-agGmWBn4.esm.js.map} +1 -1
  18. package/dist/{index.browser-C1QL04xM.js → index.browser-BJmFjY2f.js} +1006 -15
  19. package/dist/index.browser-BJmFjY2f.js.map +1 -0
  20. package/dist/index.browser-DZtZWdul.js +4994 -0
  21. package/dist/index.browser-DZtZWdul.js.map +1 -0
  22. package/dist/index.browser-lHP9glAW.esm.js +6060 -0
  23. package/dist/index.browser-lHP9glAW.esm.js.map +1 -0
  24. package/dist/{index.browser-Cgj7Hs6n.esm.js → index.browser-p-pgsxxW.esm.js} +836 -916
  25. package/dist/index.browser-p-pgsxxW.esm.js.map +1 -0
  26. package/dist/index.esm.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/{index.native-BmtuyGXs.js → index.native-ANhb4jEB.js} +4 -4
  29. package/dist/{index.native-BmtuyGXs.js.map → index.native-ANhb4jEB.js.map} +1 -1
  30. package/dist/{index.native-X01vlukI.esm.js → index.native-a3mhu9HP.esm.js} +4 -4
  31. package/dist/{index.native-X01vlukI.esm.js.map → index.native-a3mhu9HP.esm.js.map} +1 -1
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +1 -1
  34. package/dist/{phantom-wallet-provider-C_LPU6Ns.js → phantom-wallet-provider-BOdn0D1Q.js} +4 -4
  35. package/dist/{phantom-wallet-provider-C_LPU6Ns.js.map → phantom-wallet-provider-BOdn0D1Q.js.map} +1 -1
  36. package/dist/{phantom-wallet-provider-DRvhBbbR.esm.js → phantom-wallet-provider-Dsza6TBv.esm.js} +4 -4
  37. package/dist/{phantom-wallet-provider-DRvhBbbR.esm.js.map → phantom-wallet-provider-Dsza6TBv.esm.js.map} +1 -1
  38. package/dist/{privy-wallet-provider-DQM8xO38.js → privy-wallet-provider-BlPh3Gn_.js} +3 -3
  39. package/dist/{privy-wallet-provider-DQM8xO38.js.map → privy-wallet-provider-BlPh3Gn_.js.map} +1 -1
  40. package/dist/{privy-wallet-provider-ZGu8q5T5.esm.js → privy-wallet-provider-bwwhkFjL.esm.js} +3 -3
  41. package/dist/{privy-wallet-provider-ZGu8q5T5.esm.js.map → privy-wallet-provider-bwwhkFjL.esm.js.map} +1 -1
  42. package/dist/solana-mobile-wallet-provider-S8yWHG6i.js +841 -0
  43. package/dist/solana-mobile-wallet-provider-S8yWHG6i.js.map +1 -0
  44. package/dist/solana-mobile-wallet-provider-fzLIgJBf.esm.js +820 -0
  45. package/dist/solana-mobile-wallet-provider-fzLIgJBf.esm.js.map +1 -0
  46. package/package.json +2 -1
  47. package/dist/index-Bp4b5LXs.js.map +0 -1
  48. package/dist/index-C80kRxWk.esm.js +0 -6
  49. package/dist/index-C80kRxWk.esm.js.map +0 -1
  50. package/dist/index.browser-BvNsUWjt.js +0 -105
  51. package/dist/index.browser-BvNsUWjt.js.map +0 -1
  52. package/dist/index.browser-BwIqqM4U.js +0 -1099
  53. package/dist/index.browser-BwIqqM4U.js.map +0 -1
  54. package/dist/index.browser-C1QL04xM.js.map +0 -1
  55. package/dist/index.browser-Cgj7Hs6n.esm.js.map +0 -1
  56. package/dist/index.browser-CifFI7Ju.esm.js +0 -1096
  57. package/dist/index.browser-CifFI7Ju.esm.js.map +0 -1
  58. package/dist/index.browser-D8VWPXTZ.esm.js +0 -102
  59. package/dist/index.browser-D8VWPXTZ.esm.js.map +0 -1
  60. package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
  61. package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
  62. package/dist/index.browser-vuTr40so.js +0 -1008
  63. package/dist/index.browser-vuTr40so.js.map +0 -1
  64. package/dist/solana-mobile-wallet-provider-6gNw2_bX.js +0 -608
  65. package/dist/solana-mobile-wallet-provider-6gNw2_bX.js.map +0 -1
  66. package/dist/solana-mobile-wallet-provider-B65A7abd.esm.js +0 -587
  67. package/dist/solana-mobile-wallet-provider-B65A7abd.esm.js.map +0 -1
@@ -0,0 +1,820 @@
1
+ import { b as bufferExports } from './index-DbJCCvVN.esm.js';
2
+ import { g as getPlatform, k as setAuthLoading, W as WebSessionManager, s as setCurrentUser, l as genAuthNonce, m as genSolanaMessage, n as createSessionWithSignature, d as base58, e as confirmAndCheckTransaction, c as convertRemainingAccounts, b as buildSetDocumentsTransaction, a as SOLANA_DEVNET_RPC_URL, S as SOLANA_MAINNET_RPC_URL, h as SURFNET_RPC_URL } from './index.native-a3mhu9HP.esm.js';
3
+ import { PublicKey, Connection, VersionedTransaction, VersionedMessage, Transaction } from '@solana/web3.js';
4
+ import * as anchor from '@coral-xyz/anchor';
5
+ import 'axios';
6
+ import 'react';
7
+
8
+ const ED25519_SIGNATURE_LENGTH = 64;
9
+ const STORED_AUTH_METHOD_KEY = 'tarobase_last_auth_method';
10
+ const MWA_AUTH_METHOD = 'mobile-wallet-adapter';
11
+ function findMwaError(e, maxDepth = 5) {
12
+ var _a;
13
+ let cur = e;
14
+ let depth = 0;
15
+ while (cur && depth < maxDepth) {
16
+ if ((cur === null || cur === void 0 ? void 0 : cur.name) === 'SolanaMobileWalletAdapterError' && typeof (cur === null || cur === void 0 ? void 0 : cur.code) === 'string') {
17
+ return { code: cur.code, message: String((_a = cur.message) !== null && _a !== void 0 ? _a : '') };
18
+ }
19
+ cur = cur === null || cur === void 0 ? void 0 : cur.cause;
20
+ depth++;
21
+ }
22
+ return null;
23
+ }
24
+ /**
25
+ * Returns the matched MwaErrorInfo when the error is from an association
26
+ * failure that an automatic retry can recover from (i.e. the wallet exists
27
+ * on-device but the dApp's protocol session didn't complete in time). Returns
28
+ * null for non-retryable errors (user cancel, unknown wallet errors, etc.).
29
+ *
30
+ * Specifically:
31
+ * - ERROR_WALLET_NOT_FOUND: thrown from the protocol's startScenario when
32
+ * it gave up waiting for a wallet to respond. On Seeker this races the
33
+ * first-time-consent UI on the very first authorize.
34
+ * - ERROR_SESSION_TIMEOUT: similar — the protocol's session-establishment
35
+ * timer expired.
36
+ * - ERROR_ASSOCIATION_CANCELLED: shared by user-cancel ("Wallet connection
37
+ * cancelled by user") AND the 30s wallet-standard WALLET_ASSOCIATION_TIMEOUT
38
+ * ("Wallet connection timed out"). Discriminate by message — never retry
39
+ * a user cancel.
40
+ */
41
+ function isMwaAssociationRetryable(e) {
42
+ const info = findMwaError(e);
43
+ if (!info)
44
+ return null;
45
+ if (info.code === 'ERROR_WALLET_NOT_FOUND')
46
+ return info;
47
+ if (info.code === 'ERROR_SESSION_TIMEOUT')
48
+ return info;
49
+ if (info.code === 'ERROR_ASSOCIATION_CANCELLED' && /timed out/i.test(info.message))
50
+ return info;
51
+ return null;
52
+ }
53
+ /**
54
+ * Single-retry wrapper for MWA association failures. Used ONLY for login's
55
+ * `standard:connect` and `solana:signMessage` calls — never for
56
+ * `signAndSendTransaction`/`runTransaction` because retry on a path that
57
+ * may have already submitted a tx can double-send.
58
+ *
59
+ * The retry exists for one specific scenario: on first-time MWA usage from a
60
+ * given origin on Seeker, the protocol's session-establishment timer races
61
+ * Seeker's first-time consent UI. The user reads the consent sheet, taps
62
+ * Connect — but by then the protocol has given up and thrown
63
+ * ERROR_WALLET_NOT_FOUND. The consent itself IS persisted on Seeker though,
64
+ * so a second attempt skips the consent sheet, jumps straight to
65
+ * Verify/Approve, and completes inside the timeout.
66
+ */
67
+ async function withMwaAssociationRetry(label, fn) {
68
+ const t0 = Date.now();
69
+ console.log(`[MWA-DEBUG] ${label} attempt=1 start`);
70
+ try {
71
+ const result = await fn();
72
+ console.log(`[MWA-DEBUG] ${label} attempt=1 ok (${Date.now() - t0}ms)`);
73
+ return result;
74
+ }
75
+ catch (e) {
76
+ const info = findMwaError(e);
77
+ console.log(`[MWA-DEBUG] ${label} attempt=1 err (${Date.now() - t0}ms)`, {
78
+ outer: { name: e === null || e === void 0 ? void 0 : e.name, message: e === null || e === void 0 ? void 0 : e.message },
79
+ mwa: info,
80
+ });
81
+ const retryable = isMwaAssociationRetryable(e);
82
+ if (!retryable)
83
+ throw e;
84
+ // Seeker's consent sheet is a bottom-sheet overlay — Chrome doesn't
85
+ // reliably flip document.visibilityState to 'hidden' while it's open,
86
+ // so visibility-based waits fire too early. Use a fixed delay long
87
+ // enough for Seeker to dismiss its sheet and the OS to release intent
88
+ // state. 2.5s is empirically safe; tune from device traces if needed.
89
+ console.log(`[MWA-DEBUG] ${label} retryable (${retryable.code}); waiting 2500ms before retry`);
90
+ await new Promise(r => setTimeout(r, 2500));
91
+ const t1 = Date.now();
92
+ console.log(`[MWA-DEBUG] ${label} attempt=2 start`);
93
+ try {
94
+ const result = await fn();
95
+ console.log(`[MWA-DEBUG] ${label} attempt=2 ok (${Date.now() - t1}ms)`);
96
+ return result;
97
+ }
98
+ catch (e2) {
99
+ const info2 = findMwaError(e2);
100
+ console.log(`[MWA-DEBUG] ${label} attempt=2 err (${Date.now() - t1}ms)`, {
101
+ outer: { name: e2 === null || e2 === void 0 ? void 0 : e2.name, message: e2 === null || e2 === void 0 ? void 0 : e2.message },
102
+ mwa: info2,
103
+ });
104
+ // Only mask the error with the clean Seeker message when the
105
+ // second failure is also an association-flavored error. If it's
106
+ // a user cancel, wallet rejection, or unknown error, rethrow
107
+ // the original so the host app surfaces the real cause.
108
+ if (isMwaAssociationRetryable(e2)) {
109
+ throw new Error("Couldn't connect to your Seeker wallet. Please try again.");
110
+ }
111
+ throw e2;
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * Normalize a chain string to a wallet-standard Solana chain identifier.
117
+ *
118
+ * Handles three input shapes that all show up in practice:
119
+ * - Bare cluster name from `SolanaMobileWalletConfig.cluster` (e.g. 'devnet').
120
+ * - Prefixed `solana:cluster` (e.g. 'solana:devnet').
121
+ * - Double-prefixed `solana:solana:cluster` (constructor used to wrap cluster
122
+ * with `solana:` blindly; if a caller already passed a prefixed string the
123
+ * result was `solana:solana:devnet`).
124
+ *
125
+ * Wallet-standard Solana chains are exactly:
126
+ * 'solana:mainnet' | 'solana:devnet' | 'solana:testnet' | 'solana:localnet'
127
+ * — `mainnet-beta` is NOT a valid wallet-standard identifier and must be
128
+ * normalized to `solana:mainnet`.
129
+ */
130
+ function mapChainToWalletStandard(input) {
131
+ if (!input)
132
+ return 'solana:mainnet';
133
+ let s = String(input).toLowerCase();
134
+ while (s.startsWith('solana:'))
135
+ s = s.slice('solana:'.length);
136
+ if (s === 'mainnet-beta' || s === 'mainnet')
137
+ return 'solana:mainnet';
138
+ if (s === 'devnet')
139
+ return 'solana:devnet';
140
+ if (s === 'testnet')
141
+ return 'solana:testnet';
142
+ if (s === 'localnet')
143
+ return 'solana:localnet';
144
+ return 'solana:mainnet';
145
+ }
146
+ /**
147
+ * Serialize a Transaction/VersionedTransaction to a Uint8Array wire payload
148
+ * that the wallet-standard `solana:signTransaction` /
149
+ * `solana:signAndSendTransaction` features expect.
150
+ *
151
+ * Legacy transactions must serialize with `requireAllSignatures: false` and
152
+ * `verifySignatures: false` — the wallet hasn't signed yet, and the default
153
+ * `serialize()` would throw "Signature verification failed". Versioned
154
+ * transactions use the default `serialize()` which already permits unsigned
155
+ * payloads. Mirrors the helper at
156
+ * `@solana-mobile/mobile-wallet-adapter-protocol-web3js/lib/esm/index.browser.js:13-18`.
157
+ */
158
+ function txToWireBytes(tx) {
159
+ if ('version' in tx)
160
+ return tx.serialize();
161
+ return tx.serialize({ requireAllSignatures: false, verifySignatures: false });
162
+ }
163
+ /**
164
+ * Deserialize a wire-format transaction returned by the wallet
165
+ * `solana:signTransaction` feature. Mirrors the helper at
166
+ * `@solana-mobile/mobile-wallet-adapter-protocol-web3js/lib/esm/index.browser.js:19-23`
167
+ * so legacy and versioned bytes both round-trip correctly.
168
+ */
169
+ function txFromWireBytes(byteArray) {
170
+ const messageOffset = byteArray[0] * ED25519_SIGNATURE_LENGTH + 1;
171
+ const messageVersion = VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length));
172
+ if (messageVersion === 'legacy') {
173
+ return Transaction.from(byteArray);
174
+ }
175
+ return VersionedTransaction.deserialize(byteArray);
176
+ }
177
+ /**
178
+ * Per-method runtime narrowing of wallet-standard features. The wallet's
179
+ * `.features` type is a union (`signAndSendTransaction` | `signTransaction`),
180
+ * and after authorization the wallet may also narrow `#optionalFeatures`
181
+ * based on actual wallet capabilities. Narrow at the call site so a method
182
+ * that needs only `signMessage` doesn't fail when a wallet lacks
183
+ * `signTransaction`.
184
+ */
185
+ function getSignMessageFeature(wallet) {
186
+ const f = wallet.features;
187
+ const feat = f['solana:signMessage'];
188
+ if (!feat || typeof feat.signMessage !== 'function') {
189
+ throw new Error('Wallet does not support solana:signMessage');
190
+ }
191
+ return feat;
192
+ }
193
+ function getSignTransactionFeature(wallet) {
194
+ const f = wallet.features;
195
+ const feat = f['solana:signTransaction'];
196
+ if (!feat || typeof feat.signTransaction !== 'function') {
197
+ throw new Error('Wallet does not support solana:signTransaction');
198
+ }
199
+ return feat;
200
+ }
201
+ function getSignAndSendTransactionFeature(wallet) {
202
+ const f = wallet.features;
203
+ const feat = f['solana:signAndSendTransaction'];
204
+ if (!feat || typeof feat.signAndSendTransaction !== 'function') {
205
+ throw new Error('Wallet does not support solana:signAndSendTransaction');
206
+ }
207
+ return feat;
208
+ }
209
+ function getConnectFeature(wallet) {
210
+ const f = wallet.features;
211
+ const feat = f['standard:connect'];
212
+ if (!feat || typeof feat.connect !== 'function') {
213
+ throw new Error('Wallet does not support standard:connect');
214
+ }
215
+ return feat;
216
+ }
217
+ function getDisconnectFeature(wallet) {
218
+ const f = wallet.features;
219
+ const feat = f['standard:disconnect'];
220
+ return feat && typeof feat.disconnect === 'function' ? feat : null;
221
+ }
222
+ function writeAuthMethod(method) {
223
+ try {
224
+ if (method === null) {
225
+ getPlatform().storage.removeItem(STORED_AUTH_METHOD_KEY);
226
+ }
227
+ else {
228
+ getPlatform().storage.setItem(STORED_AUTH_METHOD_KEY, method);
229
+ }
230
+ }
231
+ catch (_a) {
232
+ // storage may be unavailable
233
+ }
234
+ }
235
+ function readAuthMethod() {
236
+ try {
237
+ return getPlatform().storage.getItem(STORED_AUTH_METHOD_KEY);
238
+ }
239
+ catch (_a) {
240
+ return null;
241
+ }
242
+ }
243
+ /**
244
+ * SolanaMobileWalletProvider implements the AuthProvider interface using
245
+ * Solana Mobile's wallet-standard wrapper (`LocalSolanaMobileWalletAdapterWallet`).
246
+ *
247
+ * Why wallet-standard and not the raw MWA protocol: as of
248
+ * `@solana-mobile/wallet-standard-mobile@0.5.0+`, the wallet's internal
249
+ * `#transact` calls `checkLocalNetworkAccessPermission()` before opening the
250
+ * localhost WebSocket. That helper renders a three-stage UX flow Solana
251
+ * Mobile designed specifically to defuse Chrome's Local Network Access
252
+ * permission dialog (which renders with disabled buttons on Android Chrome,
253
+ * the source of the long-running Seeker MWA bug):
254
+ *
255
+ * 1. "Allow connections to your wallet" informational modal.
256
+ * 2. Chrome's permission prompt (interactive because it's spawned as a
257
+ * fresh user gesture from step 1).
258
+ * 3. "Ready to connect!" success modal.
259
+ *
260
+ * `checkLocalNetworkAccessPermission` is internal to the library — it's not
261
+ * exported. The only way to invoke it is to go through the wallet's
262
+ * `standard:connect` / `solana:sign*` features, which is what this provider
263
+ * does.
264
+ *
265
+ * Notes on UX: login uses two wallet popups in succession — `standard:connect`
266
+ * (authorize) and `solana:signMessage` (sign the Tarobase nonce). The
267
+ * previous implementation combined both inside a single `transact` callback;
268
+ * splitting them is the cost of going through wallet-standard, and is
269
+ * acceptable given the alternative was broken on Seeker.
270
+ */
271
+ class SolanaMobileWalletProvider {
272
+ constructor(networkUrl = null, config = {}) {
273
+ /** LocalSolanaMobileWalletAdapterWallet, lazy-constructed in ensureWallet(). */
274
+ this.wallet = null;
275
+ this.networkUrl = networkUrl;
276
+ this.config = config;
277
+ if (typeof window === 'undefined') {
278
+ throw new Error('SolanaMobileWalletProvider can only be instantiated in a browser environment');
279
+ }
280
+ if (SolanaMobileWalletProvider.instance) {
281
+ return SolanaMobileWalletProvider.instance;
282
+ }
283
+ this.appIdentity = config.appIdentity || {
284
+ name: 'TaroBase App',
285
+ uri: getPlatform().getLocationOrigin(),
286
+ };
287
+ this.cluster = config.cluster || 'mainnet-beta';
288
+ SolanaMobileWalletProvider.instance = this;
289
+ }
290
+ static getInstance(networkUrl, config) {
291
+ if (!SolanaMobileWalletProvider.instance) {
292
+ new SolanaMobileWalletProvider(networkUrl, config);
293
+ }
294
+ return SolanaMobileWalletProvider.instance;
295
+ }
296
+ /** Lazy-construct LocalSolanaMobileWalletAdapterWallet on first need. */
297
+ async ensureWallet() {
298
+ if (this.wallet)
299
+ return this.wallet;
300
+ const mod = await import('./index.browser-p-pgsxxW.esm.js');
301
+ const chain = mapChainToWalletStandard(this.cluster);
302
+ this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
303
+ appIdentity: this.appIdentity,
304
+ authorizationCache: mod.createDefaultAuthorizationCache(),
305
+ chains: [chain],
306
+ chainSelector: mod.createDefaultChainSelector(),
307
+ // Suppress the default "We can't find a wallet" modal — that
308
+ // modal is misleading when ERROR_WALLET_NOT_FOUND fires during
309
+ // a first-time-consent race on Seeker (the wallet IS installed,
310
+ // the protocol just gave up before the user finished consenting).
311
+ // login()'s withMwaAssociationRetry handles this case; on second
312
+ // failure it surfaces a clean error message to the host app.
313
+ onWalletNotFound: async () => {
314
+ console.warn('[MWA-DEBUG] ensureWallet onWalletNotFound (suppressed)');
315
+ },
316
+ });
317
+ return this.wallet;
318
+ }
319
+ /**
320
+ * Ensure the wallet has an active authorization. After a Tarobase session
321
+ * is restored from storage on cold-start, `wallet.accounts` is empty until
322
+ * we silently reconnect from the AuthorizationCache. If the cache is also
323
+ * empty, fall back to interactive `login()` (which surfaces the three-stage
324
+ * Solana Mobile LNA flow + wallet popups).
325
+ *
326
+ * Returns the wallet-standard `WalletAccount` to use for sign operations.
327
+ */
328
+ async ensureAuthorized() {
329
+ const wallet = await this.ensureWallet();
330
+ if (wallet.accounts.length === 0) {
331
+ try {
332
+ const connectFeat = getConnectFeature(wallet);
333
+ await connectFeat.connect({ silent: true });
334
+ }
335
+ catch (e) {
336
+ console.warn('[SolanaMobileWallet] silent connect failed:', e === null || e === void 0 ? void 0 : e.message);
337
+ }
338
+ }
339
+ if (wallet.accounts.length === 0) {
340
+ const user = await this.login();
341
+ if (!user)
342
+ throw new Error('MWA not connected');
343
+ }
344
+ return wallet.accounts[0];
345
+ }
346
+ /** Returns the active wallet-standard chain identifier (e.g. 'solana:mainnet'). */
347
+ getChain() {
348
+ return mapChainToWalletStandard(this.cluster);
349
+ }
350
+ async login() {
351
+ var _a, _b, _c, _d, _e;
352
+ setAuthLoading(true);
353
+ // Mark the auth method early so a concurrent Phantom auto-create-session
354
+ // effect (see phantom-wallet-provider) sees 'mobile-wallet-adapter'
355
+ // during our slow connect/sign roundtrip and backs off. Capture the
356
+ // previous value so we can restore it if login fails.
357
+ const prevAuthMethod = readAuthMethod();
358
+ writeAuthMethod(MWA_AUTH_METHOD);
359
+ try {
360
+ const wallet = await this.ensureWallet();
361
+ // Quick-check: wallet may already have authorization (e.g. from a
362
+ // previous in-page login) and a matching Tarobase session — skip
363
+ // popups in that case.
364
+ if (wallet.accounts.length > 0) {
365
+ const accountPubkey = new PublicKey(wallet.accounts[0].publicKey);
366
+ const base58Addr = accountPubkey.toBase58();
367
+ const existingSession = await WebSessionManager.getSession();
368
+ if (existingSession && existingSession.address === base58Addr) {
369
+ const user = { provider: this, address: base58Addr };
370
+ setCurrentUser(user);
371
+ return user;
372
+ }
373
+ }
374
+ // Pre-fetch nonce while the wallet popup is not yet open.
375
+ const nonce = await genAuthNonce();
376
+ // Wallet popup #1: standard:connect performs MWA authorize. This
377
+ // is where wallet-standard's checkLocalNetworkAccessPermission()
378
+ // fires the three-stage LNA UX (info modal → permission prompt →
379
+ // success modal) before opening the localhost WebSocket.
380
+ //
381
+ // Wrap with single-retry: on a Seeker origin's first MWA usage,
382
+ // the protocol's session-establishment timer often races Seeker's
383
+ // first-time consent UI and throws ERROR_WALLET_NOT_FOUND before
384
+ // the user finishes tapping. The retry hits Seeker's cached
385
+ // consent on the second pass and completes quickly. See
386
+ // withMwaAssociationRetry for details.
387
+ const connectFeat = getConnectFeature(wallet);
388
+ const { accounts } = await withMwaAssociationRetry('login:connect', () => connectFeat.connect());
389
+ if (!accounts || accounts.length === 0) {
390
+ throw new Error('MWA returned no accounts');
391
+ }
392
+ const account = accounts[0];
393
+ const accountPubkey = new PublicKey(account.publicKey);
394
+ const base58Addr = accountPubkey.toBase58();
395
+ // If we happen to already have a matching Tarobase session, reuse it.
396
+ const existingSession = await WebSessionManager.getSession();
397
+ if (existingSession && existingSession.address === base58Addr) {
398
+ const user = { provider: this, address: base58Addr };
399
+ setCurrentUser(user);
400
+ return user;
401
+ }
402
+ // Wallet popup #2: sign the Tarobase nonce message. Wrap with the
403
+ // same retry for defense in depth — by now Seeker has cached the
404
+ // consent so this rarely hits the retry path, but if the
405
+ // protocol's session timer fires here too we recover transparently.
406
+ const messageText = await genSolanaMessage(base58Addr, nonce);
407
+ const messageBytes = getPlatform().textEncode(messageText);
408
+ const signMessageFeat = getSignMessageFeature(wallet);
409
+ const signResults = await withMwaAssociationRetry('login:signMessage', () => signMessageFeat.signMessage({ account, message: messageBytes }));
410
+ if (!signResults || signResults.length === 0) {
411
+ throw new Error('MWA returned no signature');
412
+ }
413
+ const { signature: sigBytes } = signResults[0];
414
+ const signatureBase64 = bufferExports.Buffer.from(sigBytes).toString('base64');
415
+ // Create Tarobase session on the server.
416
+ const createSessionResult = await createSessionWithSignature(base58Addr, messageText, signatureBase64);
417
+ await WebSessionManager.storeSession(base58Addr, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
418
+ // Auth-method marker is already 'mobile-wallet-adapter' from above.
419
+ const user = { provider: this, address: base58Addr };
420
+ setCurrentUser(user);
421
+ return user;
422
+ }
423
+ catch (error) {
424
+ // Restore the previous auth-method marker since this login attempt failed.
425
+ writeAuthMethod(prevAuthMethod);
426
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
427
+ ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('user rejected')) ||
428
+ ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('user denied')) ||
429
+ ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user cancelled')) ||
430
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user canceled')) ||
431
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user declined'));
432
+ if (!isUserRejection) {
433
+ console.error('[SolanaMobileWallet] Login failed:', error);
434
+ }
435
+ throw error;
436
+ }
437
+ finally {
438
+ setAuthLoading(false);
439
+ }
440
+ }
441
+ async restoreSession() {
442
+ const session = await WebSessionManager.getSession();
443
+ if (session) {
444
+ return { provider: this, address: session.address };
445
+ }
446
+ return null;
447
+ }
448
+ async logout() {
449
+ try {
450
+ const wallet = await this.ensureWallet();
451
+ const disconnectFeat = getDisconnectFeature(wallet);
452
+ if (disconnectFeat) {
453
+ // Disconnect clears the AuthorizationCache and resets
454
+ // wallet.#authorization internally (no LNA dialog).
455
+ await disconnectFeat.disconnect();
456
+ }
457
+ }
458
+ catch (error) {
459
+ console.error('[SolanaMobileWallet] Disconnect error:', error);
460
+ }
461
+ WebSessionManager.clearSession();
462
+ // Clear the auth-method marker so Phantom auto-create is unblocked
463
+ // for any subsequent fresh login on this device.
464
+ writeAuthMethod(null);
465
+ setCurrentUser(null);
466
+ }
467
+ async signMessage(message) {
468
+ var _a, _b;
469
+ const account = await this.ensureAuthorized();
470
+ const wallet = await this.ensureWallet();
471
+ try {
472
+ const signMessageFeat = getSignMessageFeature(wallet);
473
+ const messageBytes = getPlatform().textEncode(message);
474
+ const results = await signMessageFeat.signMessage({ account, message: messageBytes });
475
+ if (!results || results.length === 0) {
476
+ throw new Error('MWA returned no signature');
477
+ }
478
+ const { signature: sigBytes } = results[0];
479
+ return bufferExports.Buffer.from(sigBytes).toString('base64');
480
+ }
481
+ catch (error) {
482
+ if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
483
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
484
+ await this.logout();
485
+ throw new Error('Wallet connection lost. Please reconnect.');
486
+ }
487
+ throw new Error(`Failed to sign message: ${error.message}`);
488
+ }
489
+ }
490
+ async signTransaction(transaction) {
491
+ var _a, _b;
492
+ const account = await this.ensureAuthorized();
493
+ const connectedPubkey = new PublicKey(account.publicKey);
494
+ const wallet = await this.ensureWallet();
495
+ const chain = this.getChain();
496
+ // Preserve existing prep: fill missing blockhash / fee payer so call
497
+ // sites that build a tx without these fields don't regress.
498
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
499
+ if (isLegacyTransaction) {
500
+ const legacyTx = transaction;
501
+ if (!legacyTx.recentBlockhash) {
502
+ const conn = new Connection(this.getRpcUrl(), 'confirmed');
503
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
504
+ legacyTx.recentBlockhash = blockhash;
505
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
506
+ }
507
+ if (!legacyTx.feePayer) {
508
+ legacyTx.feePayer = connectedPubkey;
509
+ }
510
+ }
511
+ else {
512
+ const versionedTx = transaction;
513
+ if (!versionedTx.message.recentBlockhash) {
514
+ const conn = new Connection(this.getRpcUrl(), 'confirmed');
515
+ const { blockhash } = await conn.getLatestBlockhash('confirmed');
516
+ versionedTx.message.recentBlockhash = blockhash;
517
+ }
518
+ }
519
+ try {
520
+ const signTxFeat = getSignTransactionFeature(wallet);
521
+ const wireBytes = txToWireBytes(transaction);
522
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
523
+ if (!results || results.length === 0) {
524
+ throw new Error('MWA returned no signed transaction');
525
+ }
526
+ const { signedTransaction: signedBytes } = results[0];
527
+ return txFromWireBytes(new Uint8Array(signedBytes));
528
+ }
529
+ catch (error) {
530
+ if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
531
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
532
+ await this.logout();
533
+ throw new Error('Wallet connection lost. Please reconnect.');
534
+ }
535
+ throw new Error(`Failed to sign transaction: ${error.message}`);
536
+ }
537
+ }
538
+ async signAndSubmitTransaction(transaction, feePayer) {
539
+ var _a, _b, _c, _d, _e, _f;
540
+ const account = await this.ensureAuthorized();
541
+ const connectedPubkey = new PublicKey(account.publicKey);
542
+ const wallet = await this.ensureWallet();
543
+ const chain = this.getChain();
544
+ const rpcUrl = this.getRpcUrl();
545
+ const connection = new Connection(rpcUrl, 'confirmed');
546
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
547
+ try {
548
+ // Preserve existing prep: refresh blockhash and set fee payer.
549
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
550
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
551
+ if (isLegacyTransaction) {
552
+ const legacyTx = transaction;
553
+ legacyTx.recentBlockhash = blockhash;
554
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
555
+ if (!legacyTx.feePayer) {
556
+ legacyTx.feePayer = feePayer !== null && feePayer !== void 0 ? feePayer : connectedPubkey;
557
+ }
558
+ }
559
+ else {
560
+ const versionedTx = transaction;
561
+ versionedTx.message.recentBlockhash = blockhash;
562
+ }
563
+ if (isSurfnet) {
564
+ // Surfnet: sign locally via wallet-standard, submit manually
565
+ // to the Surfnet RPC. Don't route through signAndSendTransaction
566
+ // because the wallet would submit to its own RPC.
567
+ const signTxFeat = getSignTransactionFeature(wallet);
568
+ const wireBytes = txToWireBytes(transaction);
569
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
570
+ if (!results || results.length === 0) {
571
+ throw new Error('MWA returned no signed transaction');
572
+ }
573
+ const { signedTransaction: signedBytes } = results[0];
574
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
575
+ const signature = await connection.sendRawTransaction(signedTx.serialize(), {
576
+ preflightCommitment: 'confirmed',
577
+ });
578
+ const confirmation = await connection.confirmTransaction({
579
+ signature,
580
+ blockhash,
581
+ lastValidBlockHeight,
582
+ }, 'confirmed');
583
+ if (confirmation.value.err) {
584
+ throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
585
+ }
586
+ return signature;
587
+ }
588
+ // Non-Surfnet: wallet signs and submits to its own RPC.
589
+ const signSendFeat = getSignAndSendTransactionFeature(wallet);
590
+ const wireBytes = txToWireBytes(transaction);
591
+ const results = await signSendFeat.signAndSendTransaction({
592
+ account,
593
+ transaction: wireBytes,
594
+ chain,
595
+ options: { commitment: 'confirmed' },
596
+ });
597
+ if (!results || results.length === 0) {
598
+ throw new Error('MWA returned no signature');
599
+ }
600
+ const { signature: sigBytes } = results[0];
601
+ const signature = base58.encode(sigBytes);
602
+ await confirmAndCheckTransaction(connection, signature);
603
+ return signature;
604
+ }
605
+ catch (error) {
606
+ if (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('not connected')) || ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('not authorized')) ||
607
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
608
+ await this.logout();
609
+ throw new Error('Wallet connection lost. Please reconnect.');
610
+ }
611
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
612
+ ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user rejected')) ||
613
+ ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user denied')) ||
614
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user cancelled')) ||
615
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user canceled'));
616
+ if (!isUserRejection) {
617
+ console.error('[SolanaMobileWallet] Transaction failed:', error);
618
+ }
619
+ throw new Error(`Failed to execute transaction: ${error.message}`);
620
+ }
621
+ }
622
+ async runTransaction(_evmTransactionData, solTransactionData, options) {
623
+ var _a, _b, _c, _d, _e, _f, _g, _h;
624
+ if (!solTransactionData) {
625
+ throw new Error('Solana transaction data is required for mobile wallet');
626
+ }
627
+ const account = await this.ensureAuthorized();
628
+ const connectedPubkey = new PublicKey(account.publicKey);
629
+ const wallet = await this.ensureWallet();
630
+ const chain = this.getChain();
631
+ const rpcUrl = this.getRpcUrl(solTransactionData.network);
632
+ const connection = new Connection(rpcUrl, 'confirmed');
633
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
634
+ try {
635
+ const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
636
+ let app_id = solTransactionData.appId;
637
+ if (typeof window !== 'undefined' && window.CUSTOM_TAROBASE_APP_ID_HEADER) {
638
+ app_id = window.CUSTOM_TAROBASE_APP_ID_HEADER;
639
+ }
640
+ if (!app_id) {
641
+ throw new Error('App ID is required');
642
+ }
643
+ // Mock wallet adapter for Anchor — only publicKey is read during build.
644
+ const mockWalletAdapter = {
645
+ publicKey: connectedPubkey,
646
+ signTransaction: async (tx) => tx,
647
+ signAllTransactions: async (txs) => txs,
648
+ };
649
+ const anchorProvider = new anchor.AnchorProvider(connection, mockWalletAdapter, anchor.AnchorProvider.defaultOptions());
650
+ const finalDeduped = [];
651
+ for (const acc of remainingAccounts) {
652
+ const existing = finalDeduped.find((d) => d.pubkey.equals(acc.pubkey));
653
+ if (existing) {
654
+ existing.isSigner = existing.isSigner || acc.isSigner;
655
+ existing.isWritable = existing.isWritable || acc.isWritable;
656
+ }
657
+ else {
658
+ finalDeduped.push(acc);
659
+ }
660
+ }
661
+ let tx;
662
+ if (solTransactionData.signedTransaction) {
663
+ // Server has co-signed a CPI attestation. Do NOT mutate its
664
+ // blockhash — that would invalidate the server's signature.
665
+ tx = VersionedTransaction.deserialize(bufferExports.Buffer.from(solTransactionData.signedTransaction, 'base64'));
666
+ }
667
+ else {
668
+ const result = await buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, connectedPubkey, {
669
+ app_id,
670
+ documents: solTransactionData.txArgs[0].setDocumentData,
671
+ delete_paths: solTransactionData.txArgs[0].deletePaths,
672
+ txData: solTransactionData.txArgs[0].txData
673
+ }, finalDeduped, solTransactionData.lutKey, solTransactionData.preInstructions, false, solTransactionData.additionalLutAddresses);
674
+ tx = result.tx;
675
+ }
676
+ // Sign-only branch — sign the tx but don't submit.
677
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
678
+ const signTxFeat = getSignTransactionFeature(wallet);
679
+ const wireBytes = txToWireBytes(tx);
680
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
681
+ if (!results || results.length === 0) {
682
+ throw new Error('MWA returned no signed transaction');
683
+ }
684
+ const { signedTransaction: signedBytes } = results[0];
685
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
686
+ return {
687
+ signedTransaction: signedTx,
688
+ blockNumber: 0,
689
+ gasUsed: '0',
690
+ data: ''
691
+ };
692
+ }
693
+ if (isSurfnet) {
694
+ // Surfnet: sign locally via wallet-standard, submit manually.
695
+ const signTxFeat = getSignTransactionFeature(wallet);
696
+ const wireBytes = txToWireBytes(tx);
697
+ const results = await signTxFeat.signTransaction({ account, transaction: wireBytes, chain });
698
+ if (!results || results.length === 0) {
699
+ throw new Error('MWA returned no signed transaction');
700
+ }
701
+ const { signedTransaction: signedBytes } = results[0];
702
+ const signedTx = txFromWireBytes(new Uint8Array(signedBytes));
703
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
704
+ const signature = await connection.sendRawTransaction(signedTx.serialize(), {
705
+ preflightCommitment: 'confirmed',
706
+ });
707
+ const confirmation = await connection.confirmTransaction({
708
+ signature,
709
+ blockhash,
710
+ lastValidBlockHeight,
711
+ }, 'confirmed');
712
+ if (confirmation.value.err) {
713
+ throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
714
+ }
715
+ const txInfo = await connection.getParsedTransaction(signature, {
716
+ maxSupportedTransactionVersion: 0,
717
+ commitment: 'confirmed',
718
+ });
719
+ return {
720
+ transactionSignature: signature,
721
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
722
+ gasUsed: ((_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.fee.toString()) || '0',
723
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
724
+ };
725
+ }
726
+ // Non-Surfnet: wallet signs and submits to its own RPC.
727
+ const signSendFeat = getSignAndSendTransactionFeature(wallet);
728
+ const wireBytes = txToWireBytes(tx);
729
+ const results = await signSendFeat.signAndSendTransaction({
730
+ account,
731
+ transaction: wireBytes,
732
+ chain,
733
+ options: { commitment: 'confirmed' },
734
+ });
735
+ if (!results || results.length === 0) {
736
+ throw new Error('MWA returned no signature');
737
+ }
738
+ const { signature: sigBytes } = results[0];
739
+ const signature = base58.encode(sigBytes);
740
+ const txInfo = await confirmAndCheckTransaction(connection, signature);
741
+ return {
742
+ transactionSignature: signature,
743
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
744
+ gasUsed: ((_b = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _b === void 0 ? void 0 : _b.fee.toString()) || '0',
745
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
746
+ };
747
+ }
748
+ catch (error) {
749
+ if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('not authorized')) ||
750
+ (error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHORIZATION_FAILED') {
751
+ await this.logout();
752
+ throw new Error('Wallet connection lost. Please reconnect.');
753
+ }
754
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
755
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
756
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
757
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
758
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
759
+ if (!isUserRejection) {
760
+ console.error('[SolanaMobileWallet] Transaction failed:', error);
761
+ }
762
+ throw new Error(`Failed to execute transaction: ${error.message}`);
763
+ }
764
+ }
765
+ async getNativeMethods() {
766
+ var _a, _b, _c;
767
+ // Synchronous-ish state read; tolerate the wallet being unauthorized
768
+ // (return nulls). Don't trigger ensureAuthorized() here — callers that
769
+ // need the wallet active should sign through one of the sign methods.
770
+ const wallet = this.wallet;
771
+ if (!wallet) {
772
+ return {
773
+ authToken: null,
774
+ walletUriBase: null,
775
+ publicKey: null,
776
+ base64Address: null,
777
+ wallet: null,
778
+ currentAuthorization: null,
779
+ };
780
+ }
781
+ const acct = (_a = wallet.accounts) === null || _a === void 0 ? void 0 : _a[0];
782
+ const auth = wallet.currentAuthorization;
783
+ let publicKey = null;
784
+ let base64Address = null;
785
+ if (acct) {
786
+ publicKey = new PublicKey(acct.publicKey);
787
+ base64Address = btoa(String.fromCharCode(...acct.publicKey));
788
+ }
789
+ return {
790
+ authToken: (_b = auth === null || auth === void 0 ? void 0 : auth.auth_token) !== null && _b !== void 0 ? _b : null,
791
+ walletUriBase: (_c = auth === null || auth === void 0 ? void 0 : auth.wallet_uri_base) !== null && _c !== void 0 ? _c : null,
792
+ publicKey,
793
+ base64Address,
794
+ wallet,
795
+ currentAuthorization: auth !== null && auth !== void 0 ? auth : null,
796
+ };
797
+ }
798
+ /* ----------------------------------------------------------- *
799
+ * Private Helpers
800
+ * ----------------------------------------------------------- */
801
+ getRpcUrl(network) {
802
+ if (this.networkUrl) {
803
+ return this.networkUrl;
804
+ }
805
+ if (network === 'solana_devnet') {
806
+ return SOLANA_DEVNET_RPC_URL;
807
+ }
808
+ else if (network === 'solana_mainnet') {
809
+ return SOLANA_MAINNET_RPC_URL;
810
+ }
811
+ else if (network === 'surfnet') {
812
+ return SURFNET_RPC_URL;
813
+ }
814
+ return SOLANA_MAINNET_RPC_URL;
815
+ }
816
+ }
817
+ SolanaMobileWalletProvider.instance = null;
818
+
819
+ export { SolanaMobileWalletProvider };
820
+ //# sourceMappingURL=solana-mobile-wallet-provider-fzLIgJBf.esm.js.map