@pooflabs/web 0.0.73 → 0.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/auth/index.d.ts +4 -5
  2. package/dist/auth/providers/mock-auth-provider.d.ts +3 -3
  3. package/dist/auth/providers/privy-expo-provider.d.ts +105 -0
  4. package/dist/{index-BFJJZKXQ.js → index-BHYrnHi6.js} +357 -7
  5. package/dist/index-BHYrnHi6.js.map +1 -0
  6. package/dist/index-BcDe_euX.js +15928 -0
  7. package/dist/index-BcDe_euX.js.map +1 -0
  8. package/dist/index-Bdcc5821.js +2375 -0
  9. package/dist/index-Bdcc5821.js.map +1 -0
  10. package/dist/{index-TfCOBCez.esm.js → index-BqDvUK9s.esm.js} +352 -2
  11. package/dist/index-BqDvUK9s.esm.js.map +1 -0
  12. package/dist/index-CMeewi-G.js +21553 -0
  13. package/dist/index-CMeewi-G.js.map +1 -0
  14. package/dist/index-CrOVJFX9.esm.js +2373 -0
  15. package/dist/index-CrOVJFX9.esm.js.map +1 -0
  16. package/dist/index-Dho2J3X6.esm.js +21477 -0
  17. package/dist/index-Dho2J3X6.esm.js.map +1 -0
  18. package/dist/index-_vhjpl1l.esm.js +15887 -0
  19. package/dist/index-_vhjpl1l.esm.js.map +1 -0
  20. package/dist/{index.browser-ChrwVq76.esm.js → index.browser-Br0p4bjw.esm.js} +2 -3
  21. package/dist/{index.browser-ChrwVq76.esm.js.map → index.browser-Br0p4bjw.esm.js.map} +1 -1
  22. package/dist/{index.browser-BuIgwfvv.esm.js → index.browser-Btm3sRKb.esm.js} +2 -3
  23. package/dist/{index.browser-BuIgwfvv.esm.js.map → index.browser-Btm3sRKb.esm.js.map} +1 -1
  24. package/dist/{index.browser-wsb8xknL.js → index.browser-BzHjnrpD.js} +2 -3
  25. package/dist/{index.browser-wsb8xknL.js.map → index.browser-BzHjnrpD.js.map} +1 -1
  26. package/dist/index.browser-CGfjPfzM.esm.js +1468 -0
  27. package/dist/index.browser-CGfjPfzM.esm.js.map +1 -0
  28. package/dist/{index.browser-BO1XxDi0.js → index.browser-Dapjfbl6.js} +2 -3
  29. package/dist/{index.browser-BO1XxDi0.js.map → index.browser-Dapjfbl6.js.map} +1 -1
  30. package/dist/index.browser-JX3F6oPV.js +1471 -0
  31. package/dist/index.browser-JX3F6oPV.js.map +1 -0
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.esm.js +1 -2
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/index.js +6 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.native-BB7er4-z.esm.js +13269 -0
  38. package/dist/index.native-BB7er4-z.esm.js.map +1 -0
  39. package/dist/index.native-DcKDTqvq.js +13348 -0
  40. package/dist/index.native-DcKDTqvq.js.map +1 -0
  41. package/dist/index.native.d.ts +24 -0
  42. package/dist/index.native.esm.js +6 -0
  43. package/dist/index.native.esm.js.map +1 -0
  44. package/dist/index.native.js +59 -0
  45. package/dist/index.native.js.map +1 -0
  46. package/dist/phantom-wallet-provider-DHok8ui3.esm.js +1307 -0
  47. package/dist/phantom-wallet-provider-DHok8ui3.esm.js.map +1 -0
  48. package/dist/phantom-wallet-provider-DMxFAUC4.js +1328 -0
  49. package/dist/phantom-wallet-provider-DMxFAUC4.js.map +1 -0
  50. package/dist/platform.d.ts +81 -0
  51. package/dist/privy-wallet-provider-Bhvw0t1d.js +3942 -0
  52. package/dist/privy-wallet-provider-Bhvw0t1d.js.map +1 -0
  53. package/dist/privy-wallet-provider-CFuoQYuv.esm.js +3921 -0
  54. package/dist/privy-wallet-provider-CFuoQYuv.esm.js.map +1 -0
  55. package/dist/solana-mobile-wallet-provider-BpQghAgC.esm.js +558 -0
  56. package/dist/solana-mobile-wallet-provider-BpQghAgC.esm.js.map +1 -0
  57. package/dist/solana-mobile-wallet-provider-D8b5y-By.js +579 -0
  58. package/dist/solana-mobile-wallet-provider-D8b5y-By.js.map +1 -0
  59. package/package.json +19 -3
  60. package/dist/index-BFJJZKXQ.js.map +0 -1
  61. package/dist/index-BV8MOXXy.js +0 -36033
  62. package/dist/index-BV8MOXXy.js.map +0 -1
  63. package/dist/index-D0yz-P8G.esm.js +0 -35962
  64. package/dist/index-D0yz-P8G.esm.js.map +0 -1
  65. package/dist/index-TfCOBCez.esm.js.map +0 -1
@@ -0,0 +1,1307 @@
1
+ import { b as bufferExports } from './index-CrOVJFX9.esm.js';
2
+ import { W as WebSessionManager, c as convertRemainingAccounts, b as buildSetDocumentsTransaction, e as confirmAndCheckTransaction, s as setCurrentUser, a as SOLANA_DEVNET_RPC_URL, S as SOLANA_MAINNET_RPC_URL, h as SURFNET_RPC_URL, i as detectMobile, j as detectAndroid, k as setAuthLoading, l as genAuthNonce, m as genSolanaMessage, n as createSessionWithSignature, g as getPlatform } from './index.native-BB7er4-z.esm.js';
3
+ import { Connection, PublicKey, VersionedTransaction } from '@solana/web3.js';
4
+ import * as anchor from '@coral-xyz/anchor';
5
+ import 'axios';
6
+ import 'react';
7
+
8
+ const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink', 'phantom'];
9
+ // Dynamically import React and Phantom SDK - only when needed
10
+ let React;
11
+ let ReactDOM;
12
+ let phantomReactSdk;
13
+ let sdkLoaded = false;
14
+ let loadingPromise = null;
15
+ // Lazy load React and Phantom dependencies only when PhantomWalletProvider is instantiated
16
+ // Uses dynamic import() to ensure code splitting and prevent side effects
17
+ async function loadDependencies() {
18
+ if (sdkLoaded)
19
+ return;
20
+ if (typeof window === 'undefined')
21
+ return;
22
+ // Prevent multiple concurrent loads
23
+ if (loadingPromise)
24
+ return loadingPromise;
25
+ loadingPromise = (async () => {
26
+ const [reactModule, reactDomModule, phantomModule] = await Promise.all([
27
+ import('react'),
28
+ import('react-dom/client'),
29
+ import('./index-_vhjpl1l.esm.js')
30
+ ]);
31
+ // Extract default export from ESM module namespace
32
+ // Dynamic import() returns { default: Module, ...exports }, not the module directly
33
+ React = reactModule.default || reactModule;
34
+ ReactDOM = reactDomModule.default || reactDomModule;
35
+ phantomReactSdk = phantomModule;
36
+ sdkLoaded = true;
37
+ })();
38
+ return loadingPromise;
39
+ }
40
+ class PhantomWalletProvider {
41
+ constructor(networkUrl = null, config = {}) {
42
+ this.containerElement = null;
43
+ this.root = null;
44
+ this.phantomMethods = null;
45
+ this.resolvedProviders = ['injected'];
46
+ this.pendingLogin = null;
47
+ this.loginInProgress = false;
48
+ this.autoLoginInProgress = false;
49
+ this.initPromise = null;
50
+ /** Callback to swap to a Privy provider when the user clicks "Log in with email" */
51
+ this.onSwitchToPrivy = null;
52
+ /** Callback to swap to a Mobile Wallet Adapter provider when the user clicks "Connect Mobile Wallet" */
53
+ this.onSwitchToMWA = null;
54
+ this.networkUrl = networkUrl;
55
+ this.config = config;
56
+ if (typeof window === 'undefined') {
57
+ throw new Error('PhantomWalletProvider can only be instantiated in a browser environment');
58
+ }
59
+ // Singleton pattern - reuse existing instance
60
+ if (PhantomWalletProvider.instance) {
61
+ return PhantomWalletProvider.instance;
62
+ }
63
+ // Resolve providers from config (doesn't need SDK)
64
+ this.resolveProviders();
65
+ // Start async initialization (load SDK and initialize React component)
66
+ this.initPromise = this.initializeAsync();
67
+ PhantomWalletProvider.instance = this;
68
+ }
69
+ async initializeAsync() {
70
+ // Lazy load dependencies only when actually instantiating
71
+ await loadDependencies();
72
+ // Initialize React component
73
+ this.initialize();
74
+ }
75
+ /**
76
+ * Check if social login providers are configured (non-injected providers).
77
+ */
78
+ hasSocialProviders() {
79
+ return this.resolvedProviders.some(p => p !== 'injected');
80
+ }
81
+ static getInstance(networkUrl, config) {
82
+ if (!PhantomWalletProvider.instance) {
83
+ new PhantomWalletProvider(networkUrl, config);
84
+ }
85
+ return PhantomWalletProvider.instance;
86
+ }
87
+ resolveProviders() {
88
+ if (this.config.providers && this.config.providers.length > 0) {
89
+ const configProviders = this.config.providers;
90
+ this.resolvedProviders = configProviders.filter((p) => VALID_PROVIDERS.includes(p));
91
+ if (this.resolvedProviders.length === 0) {
92
+ this.resolvedProviders = ['injected'];
93
+ }
94
+ }
95
+ else if (this.config.appId) {
96
+ this.resolvedProviders = ['injected', 'google', 'apple', 'deeplink'];
97
+ }
98
+ else {
99
+ this.resolvedProviders = ['injected'];
100
+ }
101
+ // When Privy handles social logins, strip them from Phantom
102
+ if (this.config.enablePrivyFallback) {
103
+ this.resolvedProviders = this.resolvedProviders.filter(p => p !== 'google' && p !== 'apple');
104
+ }
105
+ }
106
+ /**
107
+ * Patch the Phantom extension's provider to gracefully handle `phantom_getFeatures`
108
+ * instead of throwing. Privy's SDK probes this method to check feature support,
109
+ * but the extension doesn't implement it, causing noisy console errors.
110
+ */
111
+ patchPhantomGetFeatures() {
112
+ var _a;
113
+ try {
114
+ const provider = (_a = window.phantom) === null || _a === void 0 ? void 0 : _a.solana;
115
+ if (!(provider === null || provider === void 0 ? void 0 : provider.request) || provider.__featuresPatched)
116
+ return;
117
+ const originalRequest = provider.request.bind(provider);
118
+ provider.request = async (args) => {
119
+ if ((args === null || args === void 0 ? void 0 : args.method) === 'phantom_getFeatures') {
120
+ return { features: {} };
121
+ }
122
+ return originalRequest(args);
123
+ };
124
+ provider.__featuresPatched = true;
125
+ }
126
+ catch (_b) {
127
+ // Phantom extension not present — nothing to patch
128
+ }
129
+ }
130
+ initialize() {
131
+ if (this.containerElement)
132
+ return;
133
+ // Suppress "phantom_getFeatures isn't implemented" errors from Privy probing
134
+ // the Phantom extension for features it doesn't support yet.
135
+ this.patchPhantomGetFeatures();
136
+ // Remove any existing Phantom providers
137
+ const existingProviders = document.querySelectorAll('[data-phantom-provider]');
138
+ existingProviders.forEach(el => el.remove());
139
+ this.containerElement = document.createElement('div');
140
+ this.containerElement.setAttribute('data-phantom-provider', 'true');
141
+ // Keep Phantom UI above host overlays while avoiding global click-capture.
142
+ this.containerElement.style.position = 'fixed';
143
+ this.containerElement.style.zIndex = '2147483647';
144
+ // Full-viewport overlay for custom modal; pointer-events: none lets
145
+ // clicks pass through to page except where the modal sets 'auto'
146
+ this.containerElement.style.inset = '0';
147
+ this.containerElement.style.pointerEvents = 'none';
148
+ document.body.appendChild(this.containerElement);
149
+ const that = this;
150
+ const { PhantomProvider: ReactPhantomProvider, usePhantom, useConnect, useDisconnect, useModal, useSolana, useDiscoveredWallets, AddressType, darkTheme, lightTheme } = phantomReactSdk;
151
+ // The SDK expects providers as an array of strings: 'injected' | 'google' | 'apple' | 'phantom' | 'deeplink'
152
+ // Ensure we have a valid non-empty array
153
+ const sdkProviders = this.resolvedProviders.length > 0 ? [...this.resolvedProviders] : ['injected'];
154
+ // Inner component that uses hooks
155
+ const PhantomHooksComponent = () => {
156
+ var _a, _b;
157
+ const phantom = usePhantom();
158
+ const { connect, error: connectError } = useConnect();
159
+ const { disconnect, isDisconnecting } = useDisconnect();
160
+ const modal = useModal();
161
+ const solanaHook = useSolana();
162
+ const { solana } = solanaHook;
163
+ const [showWalletModal, setShowWalletModal] = React.useState(false);
164
+ const [hoveredBtn, setHoveredBtn] = React.useState(null);
165
+ // Discover all available wallets via Wallet Standard + EIP-6963
166
+ const { wallets: discoveredWallets } = useDiscoveredWallets();
167
+ const isMobile = detectMobile();
168
+ const hasPhantomInjected = discoveredWallets.some((w) => w.id === 'phantom');
169
+ const showDeeplink = isMobile && sdkProviders.includes('deeplink') && !hasPhantomInjected;
170
+ // Track previous modal state to detect closes
171
+ const prevModalOpen = React.useRef(false);
172
+ // Track when modal was closed because user selected a wallet (not dismissed)
173
+ const walletClickedRef = React.useRef(false);
174
+ // Set up effect to expose methods to the class
175
+ React.useEffect(() => {
176
+ if (phantom) {
177
+ that.phantomMethods = {
178
+ ready: !phantom.isLoading,
179
+ isConnected: phantom.isConnected,
180
+ addresses: phantom.addresses || [],
181
+ user: phantom.user,
182
+ connect: async () => {
183
+ return await connect();
184
+ },
185
+ disconnect: async () => {
186
+ await disconnect();
187
+ },
188
+ isDisconnecting,
189
+ openModal: () => modal.open(),
190
+ closeModal: () => modal.close(),
191
+ isModalOpen: modal.isOpened,
192
+ connectError,
193
+ showCustomModal: () => setShowWalletModal(true),
194
+ hideCustomModal: () => setShowWalletModal(false),
195
+ solana: solana && solanaHook.isAvailable ? {
196
+ // Wrap methods to preserve 'this' context - direct references lose binding
197
+ signMessage: (message) => solana.signMessage(message),
198
+ signTransaction: (tx) => solana.signTransaction(tx),
199
+ signAllTransactions: (txs) => solana.signAllTransactions(txs),
200
+ signAndSendTransaction: (tx) => solana.signAndSendTransaction(tx),
201
+ getPublicKey: () => solana.getPublicKey(),
202
+ isAvailable: solanaHook.isAvailable,
203
+ connected: solana.connected,
204
+ connect: (options) => solana.connect(options),
205
+ } : null,
206
+ };
207
+ }
208
+ }, [phantom, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, connect, disconnect, isDisconnecting, modal, modal.isOpened, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable, connectError]);
209
+ // Auto-login: If connected but no Tarobase session, try to create one.
210
+ // This handles social login callbacks where user returns from OAuth already connected.
211
+ React.useEffect(() => {
212
+ const autoCreateSession = async () => {
213
+ var _a;
214
+ // Only proceed when SDK is ready, connected, has addresses, and not already in a login flow
215
+ if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || (phantom === null || phantom === void 0 ? void 0 : phantom.isLoading) || that.loginInProgress || that.autoLoginInProgress || that.pendingLogin) {
216
+ return;
217
+ }
218
+ // Need solana to be available AND connected for signing
219
+ if (!solana || !solanaHook.isAvailable || !solana.connected) {
220
+ return;
221
+ }
222
+ // Find Solana address
223
+ const solAddress = (_a = phantom.addresses) === null || _a === void 0 ? void 0 : _a.find((addr) => addr.addressType === AddressType.solana);
224
+ if (!solAddress) {
225
+ return;
226
+ }
227
+ const publicKey = solAddress.address;
228
+ // Check if we already have a valid session for this address
229
+ const existingSession = await WebSessionManager.getSession();
230
+ if (existingSession && existingSession.address === publicKey) {
231
+ // Already have a valid session, just set user
232
+ setCurrentUser({ provider: that, address: publicKey });
233
+ return;
234
+ }
235
+ // No valid session - try to create one automatically
236
+ that.autoLoginInProgress = true;
237
+ setAuthLoading(true);
238
+ try {
239
+ const nonce = await genAuthNonce();
240
+ const messageText = await genSolanaMessage(publicKey, nonce);
241
+ // signMessage returns { signature: Uint8Array, publicKey: string }
242
+ const signResult = await solana.signMessage(messageText);
243
+ // Convert Uint8Array signature to base64 string
244
+ const signatureBytes = signResult.signature;
245
+ const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
246
+ const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
247
+ await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
248
+ // Mark auth method so clearIncompatibleSession() doesn't wipe this session
249
+ try {
250
+ getPlatform().storage.setItem('tarobase_last_auth_method', 'phantom');
251
+ }
252
+ catch (_b) { }
253
+ setCurrentUser({ provider: that, address: publicKey });
254
+ }
255
+ catch (error) {
256
+ // User rejected signing or other error - disconnect fully
257
+ try {
258
+ await disconnect();
259
+ }
260
+ catch (e) {
261
+ // Ignore disconnect errors
262
+ }
263
+ }
264
+ finally {
265
+ that.autoLoginInProgress = false;
266
+ setAuthLoading(false);
267
+ }
268
+ };
269
+ autoCreateSession();
270
+ }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable, disconnect]);
271
+ // Suppress SDK modal if it opens during custom modal login flow
272
+ React.useEffect(() => {
273
+ if (modal.isOpened && that.loginInProgress) {
274
+ modal.close();
275
+ }
276
+ }, [modal.isOpened]);
277
+ // Handle modal close without connection
278
+ React.useEffect(() => {
279
+ // Detect when modal was open and is now closed
280
+ if (prevModalOpen.current && !showWalletModal && !modal.isOpened) {
281
+ if (walletClickedRef.current) {
282
+ // Modal closed because user selected a wallet — don't reject
283
+ walletClickedRef.current = false;
284
+ }
285
+ else if (that.loginInProgress && that.pendingLogin && !(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected)) {
286
+ // User dismissed modal without connecting
287
+ that.pendingLogin.reject(new Error('User cancelled login'));
288
+ that.pendingLogin = null;
289
+ that.loginInProgress = false;
290
+ }
291
+ }
292
+ prevModalOpen.current = showWalletModal || modal.isOpened;
293
+ }, [showWalletModal, modal.isOpened, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected]);
294
+ // Handle connection errors
295
+ React.useEffect(() => {
296
+ if (connectError && that.pendingLogin) {
297
+ that.pendingLogin.reject(connectError);
298
+ that.pendingLogin = null;
299
+ that.loginInProgress = false;
300
+ }
301
+ }, [connectError]);
302
+ // Handle connection success
303
+ React.useEffect(() => {
304
+ const handleConnectionSuccess = async () => {
305
+ var _a;
306
+ // All conditions must be met for login to proceed
307
+ if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || !((_a = phantom === null || phantom === void 0 ? void 0 : phantom.addresses) === null || _a === void 0 ? void 0 : _a.length) || !that.pendingLogin || !that.loginInProgress) {
308
+ return;
309
+ }
310
+ // Solana must be available AND connected for signing
311
+ // If not ready yet, just return - this effect will re-run when solana.connected changes
312
+ if (!solana || !solanaHook.isAvailable || !solana.connected) {
313
+ return;
314
+ }
315
+ try {
316
+ // Immediately set loginInProgress to false to prevent double execution
317
+ // if the effect runs again before async operations complete
318
+ that.loginInProgress = false;
319
+ // Find Solana address
320
+ const solAddress = phantom.addresses.find((addr) => addr.addressType === AddressType.solana);
321
+ if (!solAddress) {
322
+ that.pendingLogin.reject(new Error('No Solana address returned'));
323
+ that.pendingLogin = null;
324
+ return;
325
+ }
326
+ const publicKey = solAddress.address;
327
+ // Check if we already have a valid session
328
+ const existingSession = await WebSessionManager.getSession();
329
+ if (existingSession && existingSession.address === publicKey) {
330
+ const user = { provider: that, address: publicKey };
331
+ setCurrentUser(user);
332
+ that.pendingLogin.resolve(user);
333
+ that.pendingLogin = null;
334
+ return;
335
+ }
336
+ // Create new session with signature
337
+ const nonce = await genAuthNonce();
338
+ const messageText = await genSolanaMessage(publicKey, nonce);
339
+ // signMessage returns { signature: Uint8Array, publicKey: string }
340
+ const signResult = await solana.signMessage(messageText);
341
+ // Convert Uint8Array signature to base64 string
342
+ const signatureBytes = signResult.signature;
343
+ const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
344
+ const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
345
+ await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
346
+ // Mark auth method so clearIncompatibleSession() doesn't wipe this session
347
+ try {
348
+ getPlatform().storage.setItem('tarobase_last_auth_method', 'phantom');
349
+ }
350
+ catch (_b) { }
351
+ const user = { provider: that, address: publicKey };
352
+ setCurrentUser(user);
353
+ that.pendingLogin.resolve(user);
354
+ that.pendingLogin = null;
355
+ }
356
+ catch (error) {
357
+ // Disconnect Phantom since login failed - don't leave in half-connected state
358
+ try {
359
+ await disconnect();
360
+ }
361
+ catch (e) {
362
+ // Ignore disconnect errors
363
+ }
364
+ if (that.pendingLogin) {
365
+ that.pendingLogin.reject(error);
366
+ that.pendingLogin = null;
367
+ that.loginInProgress = false;
368
+ }
369
+ }
370
+ };
371
+ handleConnectionSuccess();
372
+ }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable]);
373
+ // --- Custom wallet modal handlers ---
374
+ const handleWalletClick = async (options) => {
375
+ walletClickedRef.current = true;
376
+ setShowWalletModal(false);
377
+ try {
378
+ if (options === null || options === void 0 ? void 0 : options.walletId) {
379
+ await connect({ provider: 'injected', walletId: options.walletId });
380
+ }
381
+ else if (options === null || options === void 0 ? void 0 : options.provider) {
382
+ await connect({ provider: options.provider });
383
+ }
384
+ else {
385
+ await connect();
386
+ }
387
+ }
388
+ catch (err) {
389
+ // connectError effect handles this
390
+ }
391
+ };
392
+ const handleEmailClick = async () => {
393
+ that.loginInProgress = false;
394
+ walletClickedRef.current = true;
395
+ setShowWalletModal(false);
396
+ if (that.onSwitchToPrivy) {
397
+ try {
398
+ const privyProvider = await that.onSwitchToPrivy();
399
+ const user = await privyProvider.login();
400
+ if (that.pendingLogin && user) {
401
+ that.pendingLogin.resolve(user);
402
+ that.pendingLogin = null;
403
+ }
404
+ else if (that.pendingLogin) {
405
+ that.pendingLogin.reject(new Error('User cancelled login'));
406
+ that.pendingLogin = null;
407
+ }
408
+ }
409
+ catch (error) {
410
+ if (that.pendingLogin) {
411
+ that.pendingLogin.reject(error);
412
+ that.pendingLogin = null;
413
+ }
414
+ }
415
+ }
416
+ };
417
+ const handleMobileWalletClick = async () => {
418
+ that.loginInProgress = false;
419
+ walletClickedRef.current = true;
420
+ setShowWalletModal(false);
421
+ if (that.onSwitchToMWA) {
422
+ try {
423
+ const mwaProvider = await that.onSwitchToMWA();
424
+ const user = await mwaProvider.login();
425
+ if (that.pendingLogin && user) {
426
+ that.pendingLogin.resolve(user);
427
+ that.pendingLogin = null;
428
+ }
429
+ else if (that.pendingLogin) {
430
+ that.pendingLogin.reject(new Error('User cancelled login'));
431
+ that.pendingLogin = null;
432
+ }
433
+ }
434
+ catch (error) {
435
+ if (that.pendingLogin) {
436
+ that.pendingLogin.reject(error);
437
+ that.pendingLogin = null;
438
+ }
439
+ }
440
+ }
441
+ };
442
+ const handleCloseModal = () => {
443
+ setShowWalletModal(false);
444
+ if (that.loginInProgress && that.pendingLogin && !(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected)) {
445
+ that.pendingLogin.reject(new Error('User cancelled login'));
446
+ that.pendingLogin = null;
447
+ that.loginInProgress = false;
448
+ }
449
+ };
450
+ // --- Custom wallet modal ---
451
+ if (!showWalletModal) {
452
+ return null;
453
+ }
454
+ const theme = that.config.theme === 'light' ? lightTheme : darkTheme;
455
+ const bgColor = ((_a = theme === null || theme === void 0 ? void 0 : theme.background) === null || _a === void 0 ? void 0 : _a.primary) || (that.config.theme === 'light' ? '#FFFFFF' : '#1A1A2E');
456
+ const textColor = ((_b = theme === null || theme === void 0 ? void 0 : theme.text) === null || _b === void 0 ? void 0 : _b.primary) || (that.config.theme === 'light' ? '#000000' : '#FFFFFF');
457
+ const btnBg = 'rgba(152,151,156,0.1)';
458
+ const btnHoverBg = 'rgba(152,151,156,0.15)';
459
+ const fontFamily = '"SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif';
460
+ const buttonStyle = (id) => ({
461
+ display: 'flex',
462
+ alignItems: 'center',
463
+ justifyContent: 'center',
464
+ gap: '12px',
465
+ width: '100%',
466
+ height: '56px',
467
+ padding: '12px 16px',
468
+ border: 'none',
469
+ borderRadius: '16px',
470
+ backgroundColor: hoveredBtn === id ? btnHoverBg : btnBg,
471
+ color: textColor,
472
+ fontFamily,
473
+ fontSize: '14px',
474
+ fontWeight: '600',
475
+ lineHeight: '17px',
476
+ letterSpacing: '-0.14px',
477
+ cursor: 'pointer',
478
+ transition: 'background-color 0.2s',
479
+ });
480
+ const walletButtons = [];
481
+ // Google OAuth button — shown when 'google' is in resolved providers
482
+ if (sdkProviders.includes('google')) {
483
+ walletButtons.push(React.createElement('button', {
484
+ key: 'google-oauth',
485
+ style: buttonStyle('google-oauth'),
486
+ onClick: () => handleWalletClick({ provider: 'google' }),
487
+ onMouseEnter: () => setHoveredBtn('google-oauth'),
488
+ onMouseLeave: () => setHoveredBtn(null),
489
+ }, React.createElement('svg', {
490
+ width: '20', height: '20', viewBox: '0 0 24 24',
491
+ style: { flexShrink: '0' },
492
+ }, React.createElement('path', {
493
+ d: 'M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z',
494
+ fill: '#4285F4',
495
+ }), React.createElement('path', {
496
+ d: 'M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z',
497
+ fill: '#34A853',
498
+ }), React.createElement('path', {
499
+ d: 'M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A11.96 11.96 0 0 0 1 12c0 1.94.46 3.77 1.18 5.41l3.66-2.84z',
500
+ fill: '#FBBC05',
501
+ }), React.createElement('path', {
502
+ d: 'M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z',
503
+ fill: '#EA4335',
504
+ })), 'Continue with Google'));
505
+ }
506
+ // Apple OAuth button — shown when 'apple' is in resolved providers
507
+ if (sdkProviders.includes('apple')) {
508
+ walletButtons.push(React.createElement('button', {
509
+ key: 'apple-oauth',
510
+ style: buttonStyle('apple-oauth'),
511
+ onClick: () => handleWalletClick({ provider: 'apple' }),
512
+ onMouseEnter: () => setHoveredBtn('apple-oauth'),
513
+ onMouseLeave: () => setHoveredBtn(null),
514
+ }, React.createElement('svg', {
515
+ width: '20', height: '20', viewBox: '0 0 24 24',
516
+ fill: textColor,
517
+ style: { flexShrink: '0' },
518
+ }, React.createElement('path', {
519
+ d: 'M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z',
520
+ })), 'Continue with Apple'));
521
+ }
522
+ // Fallback icon for Phantom — uses the official SVG path from @phantom/wallet-sdk-ui
523
+ // (SDK intentionally leaves wallet.icon empty for Phantom, expecting its own UI to render it)
524
+ const PHANTOM_ICON = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHJ4PSI2IiBmaWxsPSIjQUI5RkYyIi8+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNCw0KSI+PHBhdGggZD0iTTIuMzY2NTUgMTguMzI3MUM0LjkxODcxIDE4LjMyNzEgNi44MzY3IDE2LjEwNzYgNy45ODEzMSAxNC4zNTM3QzcuODQyMSAxNC43NDE3IDcuNzY0NzYgMTUuMTI5OCA3Ljc2NDc2IDE1LjUwMjNDNy43NjQ3NiAxNi41MjY3IDguMzUyNTMgMTcuMjU2MiA5LjUxMjYgMTcuMjU2MkMxMS4xMDU4IDE3LjI1NjIgMTIuODA3MiAxNS44NTkzIDEzLjY4ODkgMTQuMzUzN0MxMy42MjcgMTQuNTcxIDEzLjU5NjEgMTQuNzcyOCAxMy41OTYxIDE0Ljk1OUMxMy41OTYxIDE1LjY3MyAxMy45OTgyIDE2LjEyMzEgMTQuODE4IDE2LjEyMzFDMTcuNDAxMSAxNi4xMjMxIDE5Ljk5OTcgMTEuNTQ0NCAxOS45OTk3IDcuNTM5ODdDMTkuOTk5NyA0LjQyMDExIDE4LjQyMiAxLjY3Mjg1IDE0LjQ2MjIgMS42NzI4NUM3LjUwMTgxIDEuNjcyODUgMCAxMC4xNzg1IDAgMTUuNjczQzAgMTcuODMwNSAxLjE2MDA3IDE4LjMyNzEgMi4zNjY1NSAxOC4zMjcxWk0xMi4wNjQ4IDcuMTk4NDFDMTIuMDY0OCA2LjQyMjM1IDEyLjQ5NzkgNS44NzkxIDEzLjEzMiA1Ljg3OTFDMTMuNzUwNyA1Ljg3OTEgMTQuMTgzOCA2LjQyMjM1IDE0LjE4MzggNy4xOTg0MUMxNC4xODM4IDcuOTc0NDcgMTMuNzUwNyA4LjUzMzIzIDEzLjEzMiA4LjUzMzIzQzEyLjQ5NzkgOC41MzMyMyAxMi4wNjQ4IDcuOTc0NDcgMTIuMDY0OCA3LjE5ODQxWk0xNS4zNzQ4IDcuMTk4NDFDMTUuMzc0OCA2LjQyMjM1IDE1LjgwNzkgNS44NzkxIDE2LjQ0MjEgNS44NzkxQzE3LjA2MDggNS44NzkxIDE3LjQ5MzkgNi40MjIzNSAxNy40OTM5IDcuMTk4NDFDMTcuNDkzOSA3Ljk3NDQ3IDE3LjA2MDggOC41MzMyMyAxNi40NDIxIDguNTMzMjNDMTUuODA3OSA4LjUzMzIzIDE1LjM3NDggNy45NzQ0NyAxNS4zNzQ4IDcuMTk4NDFaIiBmaWxsPSJ3aGl0ZSIvPjwvZz48L3N2Zz4=';
525
+ // Show all discovered injected wallets (Phantom, Solflare, Jupiter, etc.)
526
+ if (sdkProviders.includes('injected')) {
527
+ for (const wallet of discoveredWallets) {
528
+ const walletKey = `wallet-${wallet.id}`;
529
+ const iconSrc = wallet.icon || (wallet.id === 'phantom' ? PHANTOM_ICON : null);
530
+ walletButtons.push(React.createElement('button', {
531
+ key: walletKey,
532
+ style: buttonStyle(walletKey),
533
+ onClick: () => handleWalletClick({ walletId: wallet.id }),
534
+ onMouseEnter: () => setHoveredBtn(walletKey),
535
+ onMouseLeave: () => setHoveredBtn(null),
536
+ }, iconSrc
537
+ ? React.createElement('img', {
538
+ src: iconSrc,
539
+ alt: wallet.name,
540
+ style: { width: '28px', height: '28px', borderRadius: '6px' },
541
+ })
542
+ : null, wallet.name));
543
+ }
544
+ }
545
+ if (showDeeplink) {
546
+ walletButtons.push(React.createElement('button', {
547
+ key: 'phantom-deeplink',
548
+ style: buttonStyle('phantom-deeplink'),
549
+ onClick: () => handleWalletClick({ provider: 'deeplink' }),
550
+ onMouseEnter: () => setHoveredBtn('phantom-deeplink'),
551
+ onMouseLeave: () => setHoveredBtn(null),
552
+ }, React.createElement('img', {
553
+ src: PHANTOM_ICON,
554
+ alt: 'Phantom',
555
+ style: { width: '28px', height: '28px', borderRadius: '6px' },
556
+ }), 'Open Phantom app'));
557
+ }
558
+ // Mobile Wallet Adapter button — shown on Android when MWA callback is available
559
+ const isAndroid = detectAndroid();
560
+ if (isAndroid && that.onSwitchToMWA) {
561
+ walletButtons.push(React.createElement('button', {
562
+ key: 'mobile-wallet',
563
+ style: buttonStyle('mobile-wallet'),
564
+ onClick: handleMobileWalletClick,
565
+ onMouseEnter: () => setHoveredBtn('mobile-wallet'),
566
+ onMouseLeave: () => setHoveredBtn(null),
567
+ },
568
+ // Mobile wallet icon (phone with wallet)
569
+ React.createElement('svg', {
570
+ width: '20', height: '20', viewBox: '0 0 24 24', fill: 'none',
571
+ style: { flexShrink: '0' },
572
+ },
573
+ // Phone outline
574
+ React.createElement('rect', {
575
+ x: '5', y: '2', width: '14', height: '20', rx: '2',
576
+ stroke: textColor, strokeWidth: '2', fill: 'none',
577
+ }),
578
+ // Screen line
579
+ React.createElement('line', {
580
+ x1: '5', y1: '6', x2: '19', y2: '6',
581
+ stroke: textColor, strokeWidth: '1.5',
582
+ }),
583
+ // Wallet/shield checkmark
584
+ React.createElement('path', {
585
+ d: 'M9.5 12.5l2 2 3.5-3.5',
586
+ stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
587
+ })), 'Connect Mobile Wallet'));
588
+ }
589
+ // Email button — only when Privy fallback is enabled
590
+ if (that.config.enablePrivyFallback) {
591
+ walletButtons.push(React.createElement('button', {
592
+ key: 'email-login',
593
+ style: buttonStyle('email-login'),
594
+ onClick: handleEmailClick,
595
+ onMouseEnter: () => setHoveredBtn('email-login'),
596
+ onMouseLeave: () => setHoveredBtn(null),
597
+ },
598
+ // Email icon
599
+ React.createElement('svg', {
600
+ width: '20', height: '20', viewBox: '0 0 24 24', fill: 'none',
601
+ style: { flexShrink: '0' },
602
+ }, React.createElement('path', {
603
+ d: 'M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z',
604
+ stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
605
+ }), React.createElement('path', {
606
+ d: 'M22 6l-10 7L2 6',
607
+ stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
608
+ })), 'Log in with email'));
609
+ }
610
+ // Render custom modal
611
+ return React.createElement('div', {
612
+ // Overlay
613
+ style: {
614
+ position: 'fixed',
615
+ top: '0',
616
+ left: '0',
617
+ right: '0',
618
+ bottom: '0',
619
+ backgroundColor: 'rgba(0,0,0,0.5)',
620
+ display: 'flex',
621
+ alignItems: 'center',
622
+ justifyContent: 'center',
623
+ zIndex: 2147483647,
624
+ pointerEvents: 'auto',
625
+ },
626
+ onClick: (e) => {
627
+ if (e.target === e.currentTarget)
628
+ handleCloseModal();
629
+ },
630
+ onMouseDown: (e) => {
631
+ e.stopPropagation();
632
+ },
633
+ onPointerDown: (e) => {
634
+ e.stopPropagation();
635
+ },
636
+ },
637
+ // Card
638
+ React.createElement('div', {
639
+ style: {
640
+ backgroundColor: bgColor,
641
+ borderRadius: '24px',
642
+ width: '360px',
643
+ maxWidth: '90vw',
644
+ padding: '24px',
645
+ position: 'relative',
646
+ boxShadow: '0 20px 60px rgba(0,0,0,0.3)',
647
+ pointerEvents: 'auto',
648
+ },
649
+ onMouseDown: (e) => {
650
+ e.stopPropagation();
651
+ },
652
+ onPointerDown: (e) => {
653
+ e.stopPropagation();
654
+ },
655
+ },
656
+ // Close button (X)
657
+ React.createElement('button', {
658
+ onClick: handleCloseModal,
659
+ style: {
660
+ position: 'absolute',
661
+ top: '16px',
662
+ right: '16px',
663
+ background: 'none',
664
+ border: 'none',
665
+ cursor: 'pointer',
666
+ padding: '4px',
667
+ display: 'flex',
668
+ alignItems: 'center',
669
+ justifyContent: 'center',
670
+ },
671
+ }, React.createElement('svg', {
672
+ width: '14', height: '14', viewBox: '0 0 14 14', fill: 'none',
673
+ }, React.createElement('path', {
674
+ d: 'M13 1L1 13M1 1l12 12',
675
+ stroke: textColor, strokeWidth: '2', strokeLinecap: 'round',
676
+ }))),
677
+ // App icon (if provided)
678
+ that.config.appIcon ? React.createElement('div', {
679
+ style: { display: 'flex', justifyContent: 'center', marginBottom: '16px' },
680
+ }, React.createElement('img', {
681
+ src: that.config.appIcon,
682
+ alt: that.config.appName || 'App',
683
+ style: { width: '48px', height: '48px', borderRadius: '12px' },
684
+ })) : null,
685
+ // Title
686
+ React.createElement('div', {
687
+ style: {
688
+ color: textColor,
689
+ fontFamily,
690
+ fontSize: '18px',
691
+ fontWeight: '600',
692
+ textAlign: 'center',
693
+ marginBottom: '24px',
694
+ },
695
+ }, 'Connect Wallet'),
696
+ // Wallet buttons
697
+ React.createElement('div', {
698
+ style: {
699
+ display: 'flex',
700
+ flexDirection: 'column',
701
+ gap: '8px',
702
+ },
703
+ }, ...walletButtons)));
704
+ };
705
+ // Wrapper component with PhantomProvider
706
+ const PhantomProviderWrapper = () => {
707
+ // Build SDK config
708
+ const sdkConfig = React.useMemo(() => {
709
+ var _a;
710
+ const config = {
711
+ providers: sdkProviders,
712
+ addressTypes: [AddressType.solana],
713
+ autoConnect: (_a = that.config.autoConnect) !== null && _a !== void 0 ? _a : true,
714
+ };
715
+ if (that.config.appId) {
716
+ config.appId = that.config.appId;
717
+ }
718
+ return config;
719
+ }, []);
720
+ const theme = that.config.theme === 'light' ? lightTheme : darkTheme;
721
+ return React.createElement(ReactPhantomProvider, {
722
+ config: sdkConfig,
723
+ theme: theme,
724
+ appName: that.config.appName || 'App',
725
+ appIcon: that.config.appIcon,
726
+ }, React.createElement(PhantomHooksComponent));
727
+ };
728
+ this.root = ReactDOM.createRoot(this.containerElement);
729
+ this.root.render(React.createElement(PhantomProviderWrapper));
730
+ }
731
+ async ensureReady() {
732
+ // Wait for async initialization to complete first
733
+ if (this.initPromise) {
734
+ await this.initPromise;
735
+ }
736
+ // Wait for SDK to be ready
737
+ await new Promise((resolve) => {
738
+ const check = () => {
739
+ var _a;
740
+ if ((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.ready) {
741
+ resolve();
742
+ }
743
+ else {
744
+ setTimeout(check, 100);
745
+ }
746
+ };
747
+ check();
748
+ });
749
+ }
750
+ async ensureSolanaReady() {
751
+ var _a;
752
+ await this.ensureReady();
753
+ // If connected at the Phantom level, ensure solana methods are ready
754
+ if ((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) {
755
+ const timeoutMs = 10000; // 10 second timeout
756
+ const startTime = Date.now();
757
+ // First, wait for solana to be available
758
+ await new Promise((resolve, reject) => {
759
+ const check = () => {
760
+ var _a, _b;
761
+ if ((_b = (_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.solana) === null || _b === void 0 ? void 0 : _b.isAvailable) {
762
+ resolve();
763
+ }
764
+ else if (Date.now() - startTime > timeoutMs) {
765
+ reject(new Error('Timeout waiting for Solana provider to be available'));
766
+ }
767
+ else {
768
+ setTimeout(check, 100);
769
+ }
770
+ };
771
+ check();
772
+ });
773
+ // Now check if the solana provider is connected, if not try to reconnect
774
+ // Note: We check our wrapper's `connected` which may be stale, but this is just
775
+ // an optimization to skip reconnect if we know we're already connected.
776
+ // The actual signing methods use the SDK's bound methods which check live state.
777
+ if (!this.phantomMethods.solana.connected) {
778
+ console.log('Solana provider not connected, attempting to reconnect...');
779
+ try {
780
+ // onlyIfTrusted: true means it will reconnect silently if previously approved
781
+ // If not trusted, it will throw and we'll catch it below
782
+ await this.phantomMethods.solana.connect({ onlyIfTrusted: true });
783
+ console.log('Solana provider reconnected successfully');
784
+ }
785
+ catch (error) {
786
+ // If onlyIfTrusted fails, the user may need to re-approve via modal
787
+ console.error('Failed to reconnect solana provider (silent reconnect failed):', error === null || error === void 0 ? void 0 : error.message);
788
+ throw new Error('Failed to reconnect Solana provider. Please try logging in again.');
789
+ }
790
+ }
791
+ // Note: We don't do a final connected check here because our wrapper's `connected`
792
+ // is a snapshot that won't update until React re-renders. If connect() succeeded,
793
+ // the SDK is connected and signing will work.
794
+ }
795
+ }
796
+ /**
797
+ * Get the list of available (configured) providers for this wallet.
798
+ */
799
+ getAvailableProviders() {
800
+ return [...this.resolvedProviders];
801
+ }
802
+ /**
803
+ * Login using the Phantom connect modal.
804
+ * When enablePrivyFallback is true, a custom modal is rendered with discovered
805
+ * wallets and a "Log in with email" button instead of the SDK's built-in modal.
806
+ */
807
+ async login() {
808
+ var _a, _b;
809
+ await this.ensureReady();
810
+ // Check if already connected with valid session
811
+ if (((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) && ((_b = this.phantomMethods.addresses) === null || _b === void 0 ? void 0 : _b.length) > 0) {
812
+ const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
813
+ if (solAddress) {
814
+ const session = await WebSessionManager.getSession();
815
+ if (session && session.address === solAddress.address) {
816
+ const user = { provider: this, address: solAddress.address };
817
+ setCurrentUser(user);
818
+ return user;
819
+ }
820
+ }
821
+ }
822
+ // If already pending, wait for it
823
+ if (this.pendingLogin) {
824
+ return new Promise((resolve, reject) => {
825
+ this.pendingLogin.resolve = resolve;
826
+ this.pendingLogin.reject = reject;
827
+ });
828
+ }
829
+ return new Promise((resolve, reject) => {
830
+ this.pendingLogin = { resolve, reject };
831
+ this.loginInProgress = true;
832
+ // Always use our custom wallet modal
833
+ this.phantomMethods.showCustomModal();
834
+ // Safety timeout
835
+ setTimeout(() => {
836
+ if (this.pendingLogin) {
837
+ this.pendingLogin.reject(new Error('Login timed out'));
838
+ this.pendingLogin = null;
839
+ this.loginInProgress = false;
840
+ }
841
+ }, 180000);
842
+ });
843
+ }
844
+ async restoreSession() {
845
+ await this.ensureReady();
846
+ const session = await WebSessionManager.getSession();
847
+ if (session) {
848
+ return { provider: this, address: session.address };
849
+ }
850
+ return null;
851
+ }
852
+ async address() {
853
+ var _a, _b, _c, _d;
854
+ await this.ensureReady();
855
+ if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) || !((_b = this.phantomMethods.addresses) === null || _b === void 0 ? void 0 : _b.length)) {
856
+ // Try to connect first
857
+ const user = await this.login();
858
+ if (!user)
859
+ return null;
860
+ }
861
+ const solAddress = (_d = (_c = this.phantomMethods) === null || _c === void 0 ? void 0 : _c.addresses) === null || _d === void 0 ? void 0 : _d.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
862
+ return (solAddress === null || solAddress === void 0 ? void 0 : solAddress.address) || null;
863
+ }
864
+ async runTransaction(_evmTransactionData, solTransactionData, options) {
865
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
866
+ if (!solTransactionData) {
867
+ throw new Error("Solana transaction data is required for Phantom wallet");
868
+ }
869
+ try {
870
+ await this.ensureSolanaReady();
871
+ }
872
+ catch (error) {
873
+ console.error('Solana provider reconnection failed, logging out:', error.message);
874
+ await this.logout();
875
+ throw new Error('Wallet connection lost. Please reconnect.');
876
+ }
877
+ if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
878
+ const user = await this.login();
879
+ if (!user) {
880
+ throw new Error('Failed to connect wallet');
881
+ }
882
+ try {
883
+ await this.ensureSolanaReady();
884
+ }
885
+ catch (error) {
886
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
887
+ await this.logout();
888
+ throw new Error('Wallet connection lost. Please reconnect.');
889
+ }
890
+ }
891
+ if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
892
+ throw new Error('Solana signing not available');
893
+ }
894
+ const rpcUrl = this.getRpcUrl(solTransactionData.network);
895
+ const connection = new Connection(rpcUrl, 'confirmed');
896
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
897
+ try {
898
+ const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
899
+ let app_id = solTransactionData.appId;
900
+ if (typeof window !== 'undefined' && window.CUSTOM_TAROBASE_APP_ID_HEADER) {
901
+ app_id = window.CUSTOM_TAROBASE_APP_ID_HEADER;
902
+ }
903
+ if (!app_id) {
904
+ throw new Error("App ID is required");
905
+ }
906
+ // Get address
907
+ const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
908
+ if (!solAddress) {
909
+ throw new Error('Failed to get Solana address');
910
+ }
911
+ const publicKey = new PublicKey(solAddress.address);
912
+ // Create wallet adapter using SDK methods
913
+ const solana = this.phantomMethods.solana;
914
+ const walletAdapter = {
915
+ publicKey,
916
+ signTransaction: async (tx) => {
917
+ return await solana.signTransaction(tx);
918
+ },
919
+ signAllTransactions: async (txs) => {
920
+ return await solana.signAllTransactions(txs);
921
+ }
922
+ };
923
+ const anchorProvider = new anchor.AnchorProvider(connection, walletAdapter, anchor.AnchorProvider.defaultOptions());
924
+ const finalDeduped = [];
925
+ for (const acc of remainingAccounts) {
926
+ const existing = finalDeduped.find((d) => d.pubkey.equals(acc.pubkey));
927
+ if (existing) {
928
+ existing.isSigner = existing.isSigner || acc.isSigner;
929
+ existing.isWritable = existing.isWritable || acc.isWritable;
930
+ }
931
+ else {
932
+ finalDeduped.push(acc);
933
+ }
934
+ }
935
+ // When the server has co-signed a transaction (CPI attestation),
936
+ // deserialize it and just add the wallet signature instead of
937
+ // building from components.
938
+ let tx;
939
+ if (solTransactionData.signedTransaction) {
940
+ tx = VersionedTransaction.deserialize(bufferExports.Buffer.from(solTransactionData.signedTransaction, 'base64'));
941
+ }
942
+ else {
943
+ const result = await buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, publicKey, {
944
+ app_id,
945
+ documents: solTransactionData.txArgs[0].setDocumentData,
946
+ delete_paths: solTransactionData.txArgs[0].deletePaths,
947
+ txData: solTransactionData.txArgs[0].txData
948
+ }, finalDeduped, solTransactionData.lutKey, solTransactionData.preInstructions, false, solTransactionData.additionalLutAddresses);
949
+ tx = result.tx;
950
+ }
951
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
952
+ const signedTx = await walletAdapter.signTransaction(tx);
953
+ return {
954
+ signedTransaction: signedTx,
955
+ blockNumber: 0,
956
+ gasUsed: "0",
957
+ data: ""
958
+ };
959
+ }
960
+ // Keep manual submission on surfnet, use Phantom's recommended signAndSend for other networks.
961
+ if (isSurfnet) {
962
+ const signedTx = await walletAdapter.signTransaction(tx);
963
+ const { signature, txInfo } = await this.submitSignedTransaction(signedTx, connection);
964
+ return {
965
+ transactionSignature: signature,
966
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
967
+ gasUsed: ((_c = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _c === void 0 ? void 0 : _c.fee.toString()) || '0',
968
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
969
+ };
970
+ }
971
+ const signature = await this.signAndSendViaPhantom(tx);
972
+ const txInfo = await confirmAndCheckTransaction(connection, signature);
973
+ return {
974
+ transactionSignature: signature,
975
+ blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
976
+ gasUsed: ((_d = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _d === void 0 ? void 0 : _d.fee.toString()) || '0',
977
+ data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
978
+ };
979
+ }
980
+ catch (error) {
981
+ // Check if this is a connection error - if so, log out
982
+ if (((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.includes('not connected')) || ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.includes('connect first'))) {
983
+ console.error('Solana provider connection lost during transaction, logging out');
984
+ await this.logout();
985
+ throw new Error('Wallet connection lost. Please reconnect.');
986
+ }
987
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
988
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user rejected')) ||
989
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user denied')) ||
990
+ ((_j = error === null || error === void 0 ? void 0 : error.message) === null || _j === void 0 ? void 0 : _j.toLowerCase().includes('user cancelled')) ||
991
+ ((_k = error === null || error === void 0 ? void 0 : error.message) === null || _k === void 0 ? void 0 : _k.toLowerCase().includes('user canceled'));
992
+ if (!isUserRejection) {
993
+ console.error('Failed to execute transaction', error);
994
+ }
995
+ throw new Error(`Failed to execute transaction: ${error.message}`);
996
+ }
997
+ }
998
+ /**
999
+ * Signs a Solana transaction without submitting it.
1000
+ *
1001
+ * This method handles blockhash automatically if not set - you do NOT need to
1002
+ * set recentBlockhash on the transaction before calling this method.
1003
+ * The network/RPC URL is derived from the provider's configuration (set during initialization).
1004
+ *
1005
+ * @param transaction - The transaction to sign (Transaction or VersionedTransaction)
1006
+ * @returns The signed transaction
1007
+ */
1008
+ async signTransaction(transaction) {
1009
+ var _a, _b, _c, _d;
1010
+ try {
1011
+ await this.ensureSolanaReady();
1012
+ }
1013
+ catch (error) {
1014
+ // Reconnection failed - log user out and throw
1015
+ console.error('Solana provider reconnection failed, logging out:', error.message);
1016
+ await this.logout();
1017
+ throw new Error('Wallet connection lost. Please reconnect.');
1018
+ }
1019
+ if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
1020
+ const user = await this.login();
1021
+ if (!user) {
1022
+ throw new Error('Failed to connect wallet');
1023
+ }
1024
+ try {
1025
+ await this.ensureSolanaReady();
1026
+ }
1027
+ catch (error) {
1028
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
1029
+ await this.logout();
1030
+ throw new Error('Wallet connection lost. Please reconnect.');
1031
+ }
1032
+ }
1033
+ if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
1034
+ throw new Error('Solana signing not available');
1035
+ }
1036
+ // Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
1037
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
1038
+ // Ensure blockhash is set before signing
1039
+ if (isLegacyTransaction) {
1040
+ const legacyTx = transaction;
1041
+ if (!legacyTx.recentBlockhash) {
1042
+ const rpcUrl = this.getRpcUrl();
1043
+ const connection = new Connection(rpcUrl, 'confirmed');
1044
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
1045
+ legacyTx.recentBlockhash = blockhash;
1046
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
1047
+ }
1048
+ // Set feePayer if not already set
1049
+ if (!legacyTx.feePayer) {
1050
+ const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
1051
+ if (solAddress) {
1052
+ legacyTx.feePayer = new PublicKey(solAddress.address);
1053
+ }
1054
+ }
1055
+ }
1056
+ else {
1057
+ // VersionedTransaction
1058
+ const versionedTx = transaction;
1059
+ if (!versionedTx.message.recentBlockhash) {
1060
+ const rpcUrl = this.getRpcUrl();
1061
+ const connection = new Connection(rpcUrl, 'confirmed');
1062
+ const { blockhash } = await connection.getLatestBlockhash('confirmed');
1063
+ versionedTx.message.recentBlockhash = blockhash;
1064
+ }
1065
+ }
1066
+ try {
1067
+ return await this.phantomMethods.solana.signTransaction(transaction);
1068
+ }
1069
+ catch (error) {
1070
+ // Check if this is a connection error - if so, log out
1071
+ 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('connect first'))) {
1072
+ console.error('Solana provider connection lost during signing, logging out');
1073
+ await this.logout();
1074
+ throw new Error('Wallet connection lost. Please reconnect.');
1075
+ }
1076
+ throw new Error(`Failed to sign transaction: ${error.message}`);
1077
+ }
1078
+ }
1079
+ /**
1080
+ * Signs and submits a Solana transaction to the network.
1081
+ *
1082
+ * This method handles blockhash and transaction confirmation automatically - you do NOT need to
1083
+ * set recentBlockhash or lastValidBlockHeight on the transaction before calling this method.
1084
+ * The network/RPC URL is derived from the provider's configuration (set during initialization).
1085
+ *
1086
+ * @param transaction - The transaction to sign and submit (Transaction or VersionedTransaction)
1087
+ * @param feePayer - Optional fee payer public key. If not provided and the transaction doesn't
1088
+ * already have a feePayer set, the connected wallet address will be used.
1089
+ * Useful for co-signing scenarios where a different account pays the fees.
1090
+ * @returns The transaction signature
1091
+ */
1092
+ async signAndSubmitTransaction(transaction, feePayer) {
1093
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1094
+ try {
1095
+ await this.ensureSolanaReady();
1096
+ }
1097
+ catch (error) {
1098
+ console.error('Solana provider reconnection failed, logging out:', error.message);
1099
+ await this.logout();
1100
+ throw new Error('Wallet connection lost. Please reconnect.');
1101
+ }
1102
+ if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
1103
+ const user = await this.login();
1104
+ if (!user) {
1105
+ throw new Error('Failed to connect wallet');
1106
+ }
1107
+ try {
1108
+ await this.ensureSolanaReady();
1109
+ }
1110
+ catch (error) {
1111
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
1112
+ await this.logout();
1113
+ throw new Error('Wallet connection lost. Please reconnect.');
1114
+ }
1115
+ }
1116
+ if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
1117
+ throw new Error('Solana signing not available');
1118
+ }
1119
+ const rpcUrl = this.getRpcUrl();
1120
+ const connection = new Connection(rpcUrl, 'confirmed');
1121
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
1122
+ try {
1123
+ // Get fresh blockhash and set it on the transaction before signing
1124
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
1125
+ // Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
1126
+ const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
1127
+ if (isLegacyTransaction) {
1128
+ const legacyTx = transaction;
1129
+ legacyTx.recentBlockhash = blockhash;
1130
+ legacyTx.lastValidBlockHeight = lastValidBlockHeight;
1131
+ // Set feePayer if not already set
1132
+ if (!legacyTx.feePayer) {
1133
+ if (feePayer) {
1134
+ legacyTx.feePayer = feePayer;
1135
+ }
1136
+ else {
1137
+ // Use connected wallet address as feePayer
1138
+ const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
1139
+ if (solAddress) {
1140
+ legacyTx.feePayer = new PublicKey(solAddress.address);
1141
+ }
1142
+ }
1143
+ }
1144
+ }
1145
+ else {
1146
+ // VersionedTransaction
1147
+ const versionedTx = transaction;
1148
+ versionedTx.message.recentBlockhash = blockhash;
1149
+ // Note: VersionedTransaction feePayer is set in the message at creation time
1150
+ // and cannot be modified after creation
1151
+ }
1152
+ // Keep manual submission on surfnet, use Phantom's recommended signAndSend for other networks.
1153
+ if (isSurfnet) {
1154
+ const signedTx = await this.phantomMethods.solana.signTransaction(transaction);
1155
+ const { signature } = await this.submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight);
1156
+ return signature;
1157
+ }
1158
+ const signature = await this.signAndSendViaPhantom(transaction);
1159
+ await confirmAndCheckTransaction(connection, signature);
1160
+ return signature;
1161
+ }
1162
+ catch (error) {
1163
+ // Check if this is a connection error - if so, log out
1164
+ 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('connect first'))) {
1165
+ console.error('Solana provider connection lost during transaction, logging out');
1166
+ await this.logout();
1167
+ throw new Error('Wallet connection lost. Please reconnect.');
1168
+ }
1169
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
1170
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
1171
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
1172
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
1173
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
1174
+ if (!isUserRejection) {
1175
+ console.error('Failed to execute transaction', error);
1176
+ }
1177
+ throw new Error(`Failed to execute transaction: ${error.message}`);
1178
+ }
1179
+ }
1180
+ async signMessage(message) {
1181
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1182
+ try {
1183
+ await this.ensureSolanaReady();
1184
+ }
1185
+ catch (error) {
1186
+ // Reconnection failed - log user out and throw
1187
+ console.error('Solana provider reconnection failed, logging out:', error.message);
1188
+ await this.logout();
1189
+ throw new Error('Wallet connection lost. Please reconnect.');
1190
+ }
1191
+ if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
1192
+ const user = await this.login();
1193
+ if (!user) {
1194
+ throw new Error('Failed to connect wallet');
1195
+ }
1196
+ try {
1197
+ await this.ensureSolanaReady();
1198
+ }
1199
+ catch (error) {
1200
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
1201
+ await this.logout();
1202
+ throw new Error('Wallet connection lost. Please reconnect.');
1203
+ }
1204
+ }
1205
+ if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
1206
+ throw new Error('Solana signing not available');
1207
+ }
1208
+ try {
1209
+ // signMessage returns { signature: Uint8Array, publicKey: string }
1210
+ const result = await this.phantomMethods.solana.signMessage(message);
1211
+ return bufferExports.Buffer.from(result.signature).toString('base64');
1212
+ }
1213
+ catch (error) {
1214
+ // Check if this is a connection error - if so, log out
1215
+ 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('connect first'))) {
1216
+ console.error('Solana provider connection lost during signing, logging out');
1217
+ await this.logout();
1218
+ throw new Error('Wallet connection lost. Please reconnect.');
1219
+ }
1220
+ const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
1221
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
1222
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
1223
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
1224
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
1225
+ if (!isUserRejection) {
1226
+ console.error('Failed to sign message', error);
1227
+ }
1228
+ throw new Error('Failed to sign message');
1229
+ }
1230
+ }
1231
+ async logout() {
1232
+ var _a;
1233
+ await this.ensureReady();
1234
+ try {
1235
+ if ((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) {
1236
+ await this.phantomMethods.disconnect();
1237
+ }
1238
+ }
1239
+ catch (error) {
1240
+ console.error('Failed to disconnect from Phantom wallet', error);
1241
+ }
1242
+ // Always clear local state
1243
+ WebSessionManager.clearSession();
1244
+ setCurrentUser(null);
1245
+ }
1246
+ async getNativeMethods() {
1247
+ await this.ensureReady();
1248
+ return this.phantomMethods;
1249
+ }
1250
+ /* ----------------------------------------------------------- *
1251
+ * Private Helpers
1252
+ * ----------------------------------------------------------- */
1253
+ getRpcUrl(network) {
1254
+ if (this.networkUrl) {
1255
+ return this.networkUrl;
1256
+ }
1257
+ if (network === 'solana_devnet') {
1258
+ return SOLANA_DEVNET_RPC_URL;
1259
+ }
1260
+ else if (network === 'solana_mainnet') {
1261
+ return SOLANA_MAINNET_RPC_URL;
1262
+ }
1263
+ else if (network === 'surfnet') {
1264
+ return SURFNET_RPC_URL;
1265
+ }
1266
+ return SOLANA_MAINNET_RPC_URL; // default to mainnet
1267
+ }
1268
+ async signAndSendViaPhantom(transaction) {
1269
+ var _a, _b, _c;
1270
+ const result = await ((_b = (_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.solana) === null || _b === void 0 ? void 0 : _b.signAndSendTransaction(transaction));
1271
+ const signature = (_c = result === null || result === void 0 ? void 0 : result.signature) !== null && _c !== void 0 ? _c : result === null || result === void 0 ? void 0 : result.hash;
1272
+ if (!signature) {
1273
+ throw new Error('Phantom did not return a transaction signature');
1274
+ }
1275
+ return signature;
1276
+ }
1277
+ async submitSignedTransaction(signedTx, connection) {
1278
+ // Get fresh blockhash for confirmation
1279
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
1280
+ return this.submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight);
1281
+ }
1282
+ async submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight) {
1283
+ // Submit the transaction
1284
+ const signature = await connection.sendRawTransaction(signedTx.serialize(), {
1285
+ preflightCommitment: 'confirmed'
1286
+ });
1287
+ // Confirm using blockhash strategy (same as runTransaction)
1288
+ const confirmation = await connection.confirmTransaction({
1289
+ signature,
1290
+ blockhash,
1291
+ lastValidBlockHeight,
1292
+ }, 'confirmed');
1293
+ if (confirmation.value.err) {
1294
+ throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
1295
+ }
1296
+ // Get transaction info
1297
+ const txInfo = await connection.getParsedTransaction(signature, {
1298
+ maxSupportedTransactionVersion: 0,
1299
+ commitment: 'confirmed'
1300
+ });
1301
+ return { signature, txInfo };
1302
+ }
1303
+ }
1304
+ PhantomWalletProvider.instance = null;
1305
+
1306
+ export { PhantomWalletProvider };
1307
+ //# sourceMappingURL=phantom-wallet-provider-DHok8ui3.esm.js.map