@pooflabs/web 0.0.89-rc2 → 0.0.89-rc4

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 (55) hide show
  1. package/dist/auth/hooks/usePoofnetWallet.d.ts +28 -0
  2. package/dist/auth/providers/mock-poofnet-provider.d.ts +10 -25
  3. package/dist/{index-DQhWZskl.esm.js → index-Bop7HFA-.esm.js} +2 -2
  4. package/dist/{index-4JUcdcnk.esm.js.map → index-Bop7HFA-.esm.js.map} +1 -1
  5. package/dist/{index-CXmcQaFm.js → index-CEADZ0na.js} +2 -2
  6. package/dist/{index-CXmcQaFm.js.map → index-CEADZ0na.js.map} +1 -1
  7. package/dist/{index-Cgaz8U9W.esm.js → index-DGOP9-5L.esm.js} +132 -87
  8. package/dist/index-DGOP9-5L.esm.js.map +1 -0
  9. package/dist/{index-BLiaV7Dz.js → index-DHI02_l_.js} +132 -86
  10. package/dist/index-DHI02_l_.js.map +1 -0
  11. package/dist/{index-QJAj_nTx.js → index-DS3Ftep_.js} +2 -2
  12. package/dist/{index-QJAj_nTx.js.map → index-DS3Ftep_.js.map} +1 -1
  13. package/dist/{index-4JUcdcnk.esm.js → index-DZhOa-_D.esm.js} +2 -2
  14. package/dist/{index-DQhWZskl.esm.js.map → index-DZhOa-_D.esm.js.map} +1 -1
  15. package/dist/{index.browser-kQdoMu7Y.esm.js → index.browser-0dewreQm.esm.js} +2 -2
  16. package/dist/{index.browser-kQdoMu7Y.esm.js.map → index.browser-0dewreQm.esm.js.map} +1 -1
  17. package/dist/{index.browser-CG2sQjrd.esm.js → index.browser-B-pUCZgP.esm.js} +2 -2
  18. package/dist/{index.browser-CG2sQjrd.esm.js.map → index.browser-B-pUCZgP.esm.js.map} +1 -1
  19. package/dist/{index.browser-B9NfvmrP.js → index.browser-C9AVHEa4.js} +2 -2
  20. package/dist/{index.browser-B9NfvmrP.js.map → index.browser-C9AVHEa4.js.map} +1 -1
  21. package/dist/{index.browser-UxB-zDuA.js → index.browser-rhFUHjM1.js} +2 -2
  22. package/dist/{index.browser-UxB-zDuA.js.map → index.browser-rhFUHjM1.js.map} +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.esm.js +1 -1
  25. package/dist/index.js +2 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/{index.native-CwpIbypp.esm.js → index.native-CXtxnE1X.esm.js} +114 -85
  28. package/dist/index.native-CXtxnE1X.esm.js.map +1 -0
  29. package/dist/{index.native-Cycwo-3I.js → index.native-DzDWIHgW.js} +114 -84
  30. package/dist/index.native-DzDWIHgW.js.map +1 -0
  31. package/dist/index.native.d.ts +2 -0
  32. package/dist/index.native.esm.js +1 -1
  33. package/dist/index.native.js +2 -1
  34. package/dist/index.native.js.map +1 -1
  35. package/dist/{phantom-wallet-provider-DM-96ILz.esm.js → phantom-wallet-provider-SmsVVBCI.esm.js} +16 -3
  36. package/dist/phantom-wallet-provider-SmsVVBCI.esm.js.map +1 -0
  37. package/dist/{phantom-wallet-provider-BgDhrraw.js → phantom-wallet-provider-mA4Yaf-t.js} +16 -3
  38. package/dist/phantom-wallet-provider-mA4Yaf-t.js.map +1 -0
  39. package/dist/{privy-wallet-provider-C70AIqHI.esm.js → privy-wallet-provider-BNPm2WEZ.esm.js} +3 -3
  40. package/dist/{privy-wallet-provider-C70AIqHI.esm.js.map → privy-wallet-provider-BNPm2WEZ.esm.js.map} +1 -1
  41. package/dist/{privy-wallet-provider-D4IYOUji.js → privy-wallet-provider-CHMc_YjB.js} +3 -3
  42. package/dist/{privy-wallet-provider-D4IYOUji.js.map → privy-wallet-provider-CHMc_YjB.js.map} +1 -1
  43. package/dist/{solana-mobile-wallet-provider-CXXw-pKg.esm.js → solana-mobile-wallet-provider-BMGBQI3W.esm.js} +8 -5
  44. package/dist/solana-mobile-wallet-provider-BMGBQI3W.esm.js.map +1 -0
  45. package/dist/{solana-mobile-wallet-provider-BrjPc7Wd.js → solana-mobile-wallet-provider-DmBKAypM.js} +8 -5
  46. package/dist/solana-mobile-wallet-provider-DmBKAypM.js.map +1 -0
  47. package/package.json +1 -1
  48. package/dist/index-BLiaV7Dz.js.map +0 -1
  49. package/dist/index-Cgaz8U9W.esm.js.map +0 -1
  50. package/dist/index.native-CwpIbypp.esm.js.map +0 -1
  51. package/dist/index.native-Cycwo-3I.js.map +0 -1
  52. package/dist/phantom-wallet-provider-BgDhrraw.js.map +0 -1
  53. package/dist/phantom-wallet-provider-DM-96ILz.esm.js.map +0 -1
  54. package/dist/solana-mobile-wallet-provider-BrjPc7Wd.js.map +0 -1
  55. package/dist/solana-mobile-wallet-provider-CXXw-pKg.esm.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export type { GetOptions as TarobaseGetOptions } from "@pooflabs/core";
7
7
  export { subscribe } from "@pooflabs/core";
8
8
  export * from "@pooflabs/core";
9
9
  export { useAuth } from "./auth/hooks/useAuth";
10
+ export { usePoofnetWallet } from "./auth/hooks/usePoofnetWallet";
11
+ export type { PoofnetWallet, UsePoofnetWalletResult } from "./auth/hooks/usePoofnetWallet";
10
12
  export { deserializeTransaction } from "./auth/providers/sol/sol-utils";
11
13
  export { getIdToken } from "./utils";
12
14
  export { setPlatform, getPlatform } from "./platform";
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { H as DEFAULT_TEST_ADDRESS, L as InsufficientBalanceError, M as MockAuthProvider, O as OffchainAuthProvider, P as PhantomWalletProvider, K as PrivyExpoProvider, G as PrivyWalletProvider, R as ReactNativeSessionManager, N as ServerSessionManager, S as SolanaMobileWalletProvider, W as WebSessionManager, z as aggregate, Q as buildSetDocumentsTransaction, T as clearCache, U as closeAllSubscriptions, V as convertRemainingAccounts, y as count, X as createSessionWithPrivy, Y as createSessionWithSignature, C as deserializeTransaction, Z as genAuthNonce, _ as genSolanaMessage, k as get, e as getAuthLoading, j as getAuthProvider, $ as getCachedData, h as getConfig, c as getCurrentUser, p as getFiles, D as getIdToken, a0 as getMany, F as getPlatform, i as init, I as isMobileWalletAvailable, l as login, f as logout, d as onAuthLoadingChanged, o as onAuthStateChanged, a1 as reconnectWithNewAuth, a2 as refreshSession, J as registerMobileWalletAdapter, t as runExpression, u as runExpressionMany, r as runQuery, q as runQueryMany, s as set, n as setFile, m as setMany, E as setPlatform, x as signAndSubmitTransaction, v as signMessage, a3 as signSessionCreateMessage, w as signTransaction, A as subscribe, B as useAuth } from './index-Cgaz8U9W.esm.js';
1
+ export { I as DEFAULT_TEST_ADDRESS, N as InsufficientBalanceError, M as MockAuthProvider, O as OffchainAuthProvider, P as PhantomWalletProvider, L as PrivyExpoProvider, H as PrivyWalletProvider, R as ReactNativeSessionManager, Q as ServerSessionManager, S as SolanaMobileWalletProvider, W as WebSessionManager, z as aggregate, T as buildSetDocumentsTransaction, U as clearCache, V as closeAllSubscriptions, X as convertRemainingAccounts, y as count, Y as createSessionWithPrivy, Z as createSessionWithSignature, D as deserializeTransaction, _ as genAuthNonce, $ as genSolanaMessage, k as get, e as getAuthLoading, j as getAuthProvider, a0 as getCachedData, h as getConfig, c as getCurrentUser, p as getFiles, E as getIdToken, a1 as getMany, G as getPlatform, i as init, J as isMobileWalletAvailable, l as login, f as logout, d as onAuthLoadingChanged, o as onAuthStateChanged, a2 as reconnectWithNewAuth, a3 as refreshSession, K as registerMobileWalletAdapter, t as runExpression, u as runExpressionMany, r as runQuery, q as runQueryMany, s as set, n as setFile, m as setMany, F as setPlatform, x as signAndSubmitTransaction, v as signMessage, a4 as signSessionCreateMessage, w as signTransaction, A as subscribe, B as useAuth, C as usePoofnetWallet } from './index-DGOP9-5L.esm.js';
2
2
  import 'axios';
3
3
  import '@solana/web3.js';
4
4
  import '@coral-xyz/anchor';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BLiaV7Dz.js');
3
+ var index = require('./index-DHI02_l_.js');
4
4
  require('axios');
5
5
  require('@solana/web3.js');
6
6
  require('@coral-xyz/anchor');
@@ -63,4 +63,5 @@ exports.signSessionCreateMessage = index.signSessionCreateMessage;
63
63
  exports.signTransaction = index.signTransaction;
64
64
  exports.subscribe = index.subscribe;
65
65
  exports.useAuth = index.useAuth;
66
+ exports.usePoofnetWallet = index.usePoofnetWallet;
66
67
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -16874,13 +16874,19 @@ const AUTH_METHOD = 'poofnet-mock';
16874
16874
  * wrapped by OffchainAuthProvider so transaction mocking is unchanged. Mainnet
16875
16875
  * never touches this class.
16876
16876
  */
16877
+ /**
16878
+ * The active MockPoofnetProvider instance while mock-connected. Exposed so the
16879
+ * usePoofnetWallet() hook (and thus the app's own wallet UI, e.g. WalletButton)
16880
+ * can list/switch/generate mock wallets. Null when not mock-connected.
16881
+ */
16882
+ let activeMockPoofnetInstance = null;
16883
+ function getActiveMockPoofnetProvider() {
16884
+ return activeMockPoofnetInstance;
16885
+ }
16877
16886
  class MockPoofnetProvider {
16878
16887
  constructor() {
16879
16888
  /** The keypair for the currently-connected mock wallet (re-derived on login/switch/restore). */
16880
16889
  this.activeKeypair = null;
16881
- /** Floating wallet widget root (web only). */
16882
- this.widgetEl = null;
16883
- this.widgetExpanded = false;
16884
16890
  }
16885
16891
  // ============ Identity / derivation ============
16886
16892
  getDeviceId() {
@@ -16979,21 +16985,24 @@ class MockPoofnetProvider {
16979
16985
  }
16980
16986
  const index = Math.min(meta.activeIndex, meta.count - 1);
16981
16987
  this.activeKeypair = await this.deriveKeypair(appId, index);
16988
+ // Set the singleton BEFORE mintSession — mintSession calls setCurrentUser,
16989
+ // which fires onAuthStateChanged → usePoofnetWallet.refresh(); that refresh
16990
+ // must see this instance (else isMock is false until a reload).
16991
+ activeMockPoofnetInstance = this;
16982
16992
  const user = await this.mintSession(this.activeKeypair);
16983
- this.showWalletWidget(appId).catch(() => { });
16984
16993
  return user;
16985
16994
  }
16986
16995
  async restoreSession() {
16987
16996
  const session = await WebSessionManager.getSession();
16988
16997
  if (!session)
16989
16998
  return null;
16990
- // Re-derive the active keypair so signMessage works after a reload, and
16991
- // re-show the widget. Best-effort — the session itself is authoritative.
16999
+ // Re-derive the active keypair so signMessage works after a reload.
17000
+ // Best-effort — the session itself is authoritative.
16992
17001
  try {
16993
17002
  const appId = await this.getAppId();
16994
17003
  const meta = this.getWalletMeta(appId);
16995
17004
  this.activeKeypair = await this.deriveKeypair(appId, Math.min(meta.activeIndex, Math.max(0, meta.count - 1)));
16996
- this.showWalletWidget(appId).catch(() => { });
17005
+ activeMockPoofnetInstance = this;
16997
17006
  }
16998
17007
  catch ( /* noop */_a) { /* noop */ }
16999
17008
  return { provider: this, address: session.address };
@@ -17002,7 +17011,7 @@ class MockPoofnetProvider {
17002
17011
  WebSessionManager.clearSession();
17003
17012
  setCurrentUser(null);
17004
17013
  this.activeKeypair = null;
17005
- this.removeWalletWidget();
17014
+ activeMockPoofnetInstance = null;
17006
17015
  }
17007
17016
  // ============ Multi-wallet management ============
17008
17017
  /** Switch to (and connect as) an existing mock wallet by index. */
@@ -17016,8 +17025,10 @@ class MockPoofnetProvider {
17016
17025
  // Drop the old session, mint a fresh one for the selected wallet.
17017
17026
  WebSessionManager.clearSession();
17018
17027
  this.activeKeypair = await this.deriveKeypair(appId, index);
17028
+ // Set the singleton before mintSession (see login) so the refresh that
17029
+ // mintSession's setCurrentUser triggers observes the active instance.
17030
+ activeMockPoofnetInstance = this;
17019
17031
  const user = await this.mintSession(this.activeKeypair);
17020
- this.showWalletWidget(appId).catch(() => { });
17021
17032
  return user;
17022
17033
  }
17023
17034
  /** Generate a brand-new mock wallet (next index) and connect as it. */
@@ -17026,6 +17037,18 @@ class MockPoofnetProvider {
17026
17037
  const meta = this.getWalletMeta(appId);
17027
17038
  return this.switchWallet(meta.count);
17028
17039
  }
17040
+ /** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
17041
+ async getWalletState() {
17042
+ const appId = await this.getAppId();
17043
+ const meta = this.getWalletMeta(appId);
17044
+ const count = Math.max(1, meta.count);
17045
+ const wallets = [];
17046
+ for (let i = 0; i < count; i++) {
17047
+ const kp = await this.deriveKeypair(appId, i);
17048
+ wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17049
+ }
17050
+ return { wallets, activeIndex: Math.min(meta.activeIndex, count - 1) };
17051
+ }
17029
17052
  // ============ AuthProvider interface (offchain-wrapped, mostly inert) ============
17030
17053
  async signMessage(message) {
17031
17054
  if (!this.activeKeypair)
@@ -17058,73 +17081,6 @@ class MockPoofnetProvider {
17058
17081
  async getNativeMethods() {
17059
17082
  return {};
17060
17083
  }
17061
- // ============ Floating wallet widget (web only) ============
17062
- async showWalletWidget(appId) {
17063
- if (!getPlatform().hasDOM || typeof document === 'undefined')
17064
- return;
17065
- const meta = this.getWalletMeta(appId);
17066
- // Derive addresses for every wallet so the dropdown can show them.
17067
- const wallets = [];
17068
- for (let i = 0; i < meta.count; i++) {
17069
- const kp = await this.deriveKeypair(appId, i);
17070
- wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17071
- }
17072
- const active = wallets[Math.min(meta.activeIndex, wallets.length - 1)] || wallets[0];
17073
- if (!active)
17074
- return;
17075
- if (!this.widgetEl) {
17076
- this.widgetEl = document.createElement('div');
17077
- this.widgetEl.id = 'poofnet-wallet-widget';
17078
- document.body.appendChild(this.widgetEl);
17079
- }
17080
- const short = (a) => `${a.slice(0, 4)}…${a.slice(-4)}`;
17081
- const rows = wallets.map((w) => `
17082
- <button data-poofnet-switch="${w.index}" style="display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;padding:8px 10px;background:${w.index === active.index ? 'rgba(153,69,255,0.18)' : 'transparent'};border:none;border-radius:8px;color:#fff;font-size:13px;cursor:pointer;text-align:left;">
17083
- <span style="display:flex;flex-direction:column;"><span style="font-weight:600;">${w.label}</span><span style="opacity:0.55;font-size:11px;font-family:monospace;">${short(w.address)}</span></span>
17084
- ${w.index === active.index ? '<span style="color:#9945FF;">●</span>' : ''}
17085
- </button>`).join('');
17086
- this.widgetEl.innerHTML = `
17087
- <div style="position:fixed;bottom:16px;right:16px;z-index:2147483600;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;">
17088
- ${this.widgetExpanded ? `
17089
- <div style="margin-bottom:8px;width:240px;background:#161618;border:1px solid #2a2a2e;border-radius:12px;padding:8px;box-shadow:0 8px 32px rgba(0,0,0,0.5);">
17090
- <div style="padding:6px 10px 8px;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;color:#9945FF;font-weight:700;">Poofnet · Simulated</div>
17091
- <div style="max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:2px;">${rows}</div>
17092
- <button data-poofnet-generate="1" style="margin-top:6px;width:100%;padding:8px 10px;background:rgba(153,69,255,0.12);border:1px dashed #9945FF;border-radius:8px;color:#c8a4ff;font-size:13px;font-weight:600;cursor:pointer;">+ Generate new wallet</button>
17093
- </div>` : ''}
17094
- <button data-poofnet-toggle="1" style="display:flex;align-items:center;gap:8px;padding:8px 12px;background:#161618;border:1px solid #2a2a2e;border-radius:999px;color:#fff;font-size:13px;cursor:pointer;box-shadow:0 4px 16px rgba(0,0,0,0.4);">
17095
- <span style="width:8px;height:8px;border-radius:50%;background:#9945FF;box-shadow:0 0 8px #9945FF;"></span>
17096
- <span style="font-weight:600;">${active.label}</span>
17097
- <span style="opacity:0.55;font-family:monospace;font-size:12px;">${short(active.address)}</span>
17098
- <span style="opacity:0.5;transform:rotate(${this.widgetExpanded ? '180deg' : '0deg'});">▾</span>
17099
- </button>
17100
- </div>`;
17101
- // Wire handlers (re-bound each render).
17102
- const toggle = this.widgetEl.querySelector('[data-poofnet-toggle]');
17103
- if (toggle)
17104
- toggle.onclick = () => { this.widgetExpanded = !this.widgetExpanded; this.showWalletWidget(appId).catch(() => { }); };
17105
- this.widgetEl.querySelectorAll('[data-poofnet-switch]').forEach((btn) => {
17106
- btn.onclick = async () => {
17107
- const idx = parseInt(btn.getAttribute('data-poofnet-switch'), 10);
17108
- this.widgetExpanded = false;
17109
- if (idx !== active.index)
17110
- await this.switchWallet(idx);
17111
- else
17112
- this.showWalletWidget(appId).catch(() => { });
17113
- };
17114
- });
17115
- const gen = this.widgetEl.querySelector('[data-poofnet-generate]');
17116
- if (gen)
17117
- gen.onclick = async () => { this.widgetExpanded = false; await this.generateWallet(); };
17118
- }
17119
- removeWalletWidget() {
17120
- try {
17121
- if (this.widgetEl && this.widgetEl.parentNode)
17122
- this.widgetEl.parentNode.removeChild(this.widgetEl);
17123
- }
17124
- catch ( /* noop */_a) { /* noop */ }
17125
- this.widgetEl = null;
17126
- this.widgetExpanded = false;
17127
- }
17128
17084
  }
17129
17085
 
17130
17086
  /**
@@ -17888,15 +17844,15 @@ function clearIncompatibleSession() {
17888
17844
  // Lazy loaders for web-only providers.
17889
17845
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
17890
17846
  async function loadPrivyWalletProvider() {
17891
- const mod = await import('./privy-wallet-provider-C70AIqHI.esm.js');
17847
+ const mod = await import('./privy-wallet-provider-BNPm2WEZ.esm.js');
17892
17848
  return mod.PrivyWalletProvider;
17893
17849
  }
17894
17850
  async function loadPhantomWalletProvider() {
17895
- const mod = await import('./phantom-wallet-provider-DM-96ILz.esm.js');
17851
+ const mod = await import('./phantom-wallet-provider-SmsVVBCI.esm.js');
17896
17852
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
17897
17853
  }
17898
17854
  async function loadSolanaMobileWalletProvider() {
17899
- const mod = await import('./solana-mobile-wallet-provider-CXXw-pKg.esm.js');
17855
+ const mod = await import('./solana-mobile-wallet-provider-BMGBQI3W.esm.js');
17900
17856
  return mod.SolanaMobileWalletProvider;
17901
17857
  }
17902
17858
  async function hotSwapToPrivyProvider(config) {
@@ -18226,17 +18182,17 @@ function setAuthProviderInstance(provider) {
18226
18182
  authProviderInstance = provider;
18227
18183
  }
18228
18184
 
18229
- var _a;
18185
+ var _a$1;
18230
18186
  // Whether we're in a server-side rendering context (no hooks allowed).
18231
18187
  // React Native has no `window` but DOES support hooks.
18232
18188
  // We detect Node SSR specifically via process.versions.node to avoid
18233
18189
  // false positives from Node 21+ which defines `navigator` globally.
18234
- const isSSR = typeof window === 'undefined'
18190
+ const isSSR$1 = typeof window === 'undefined'
18235
18191
  && typeof process !== 'undefined'
18236
- && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18192
+ && !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
18237
18193
  function useAuth() {
18238
18194
  // Provide a fallback so server render doesn't break
18239
- if (isSSR) {
18195
+ if (isSSR$1) {
18240
18196
  return {
18241
18197
  login: async () => undefined,
18242
18198
  logout: async () => undefined,
@@ -18296,6 +18252,79 @@ function useAuth() {
18296
18252
  };
18297
18253
  }
18298
18254
 
18255
+ var _a;
18256
+ const isSSR = typeof window === 'undefined'
18257
+ && typeof process !== 'undefined'
18258
+ && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18259
+ const EMPTY = {
18260
+ isMock: false,
18261
+ wallets: [],
18262
+ activeIndex: 0,
18263
+ switchWallet: async () => undefined,
18264
+ generateWallet: async () => undefined,
18265
+ refresh: async () => undefined,
18266
+ };
18267
+ /**
18268
+ * Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
18269
+ * template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
18270
+ * so callers can conditionally render the switch/generate controls.
18271
+ *
18272
+ * Reactive: re-reads whenever auth state changes (login / logout / wallet
18273
+ * switch all flow through setCurrentUser → onAuthStateChanged).
18274
+ */
18275
+ function usePoofnetWallet() {
18276
+ if (isSSR)
18277
+ return EMPTY;
18278
+ const [state, setState] = React.useState({
18279
+ isMock: false,
18280
+ wallets: [],
18281
+ activeIndex: 0,
18282
+ });
18283
+ const refresh = React.useCallback(async () => {
18284
+ const provider = getActiveMockPoofnetProvider();
18285
+ if (!provider) {
18286
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18287
+ return;
18288
+ }
18289
+ try {
18290
+ const { wallets, activeIndex } = await provider.getWalletState();
18291
+ setState({ isMock: true, wallets, activeIndex });
18292
+ }
18293
+ catch (_a) {
18294
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18295
+ }
18296
+ }, []);
18297
+ React.useEffect(() => {
18298
+ refresh();
18299
+ // setCurrentUser (login/logout/switch/generate) notifies these listeners.
18300
+ onAuthStateChanged(() => { refresh(); });
18301
+ // Note: onAuthStateChanged has no unsubscribe yet (same as useAuth) — fine
18302
+ // for a wallet button that mounts once.
18303
+ }, [refresh]);
18304
+ const switchWallet = React.useCallback(async (index) => {
18305
+ const provider = getActiveMockPoofnetProvider();
18306
+ if (provider) {
18307
+ await provider.switchWallet(index);
18308
+ await refresh();
18309
+ }
18310
+ }, [refresh]);
18311
+ const generateWallet = React.useCallback(async () => {
18312
+ const provider = getActiveMockPoofnetProvider();
18313
+ if (provider) {
18314
+ await provider.generateWallet();
18315
+ await refresh();
18316
+ }
18317
+ }, [refresh]);
18318
+ return {
18319
+ isMock: state.isMock,
18320
+ wallets: state.wallets,
18321
+ activeIndex: state.activeIndex,
18322
+ switchWallet,
18323
+ generateWallet,
18324
+ refresh,
18325
+ };
18326
+ }
18327
+
18299
18328
  async function deserializeTransaction(tx) {
18300
18329
  const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
18301
18330
  if ((buf[0] & 0x80) !== 0) {
@@ -18928,5 +18957,5 @@ class PrivyExpoProvider {
18928
18957
  }
18929
18958
  }
18930
18959
 
18931
- export { ReactNativeSessionManager as $, getAuthProvider as A, get as B, set as C, setMany as D, setFile as E, getFiles as F, runQuery as G, runQueryMany as H, runExpression as I, runExpressionMany as J, signMessage as K, signTransaction as L, signAndSubmitTransaction as M, count as N, aggregate as O, subscribe as P, useAuth as Q, deserializeTransaction as R, SOLANA_MAINNET_RPC_URL as S, getIdToken as T, setPlatform as U, MockAuthProvider as V, WebSessionManager as W, DEFAULT_TEST_ADDRESS as X, OffchainAuthProvider as Y, PrivyExpoProvider as Z, InsufficientBalanceError as _, SOLANA_DEVNET_RPC_URL as a, ServerSessionManager as a0, clearCache as a1, closeAllSubscriptions as a2, getCachedData as a3, getMany as a4, reconnectWithNewAuth as a5, refreshSession as a6, signSessionCreateMessage as a7, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, base58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, bufferExports as h, index as i, SURFNET_RPC_URL$1 as j, detectMobile as k, detectAndroid as l, setAuthLoading as m, genAuthNonce as n, genSolanaMessage as o, createSessionWithSignature as p, getDefaultExportFromCjs$1 as q, init as r, setCurrentUser as s, getCurrentUser as t, onAuthStateChanged as u, onAuthLoadingChanged as v, getAuthLoading as w, login as x, logout as y, getConfig as z };
18932
- //# sourceMappingURL=index.native-CwpIbypp.esm.js.map
18960
+ export { InsufficientBalanceError as $, getAuthProvider as A, get as B, set as C, setMany as D, setFile as E, getFiles as F, runQuery as G, runQueryMany as H, runExpression as I, runExpressionMany as J, signMessage as K, signTransaction as L, signAndSubmitTransaction as M, count as N, aggregate as O, subscribe as P, useAuth as Q, usePoofnetWallet as R, SOLANA_MAINNET_RPC_URL as S, deserializeTransaction as T, getIdToken as U, setPlatform as V, WebSessionManager as W, MockAuthProvider as X, DEFAULT_TEST_ADDRESS as Y, OffchainAuthProvider as Z, PrivyExpoProvider as _, SOLANA_DEVNET_RPC_URL as a, ReactNativeSessionManager as a0, ServerSessionManager as a1, clearCache as a2, closeAllSubscriptions as a3, getCachedData as a4, getMany as a5, reconnectWithNewAuth as a6, refreshSession as a7, signSessionCreateMessage as a8, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, base58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, bufferExports as h, index as i, SURFNET_RPC_URL$1 as j, detectMobile as k, detectAndroid as l, setAuthLoading as m, genAuthNonce as n, genSolanaMessage as o, createSessionWithSignature as p, getDefaultExportFromCjs$1 as q, init as r, setCurrentUser as s, getCurrentUser as t, onAuthStateChanged as u, onAuthLoadingChanged as v, getAuthLoading as w, login as x, logout as y, getConfig as z };
18961
+ //# sourceMappingURL=index.native-CXtxnE1X.esm.js.map