@pooflabs/web 0.0.89-rc2 → 0.0.89-rc3

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-Cgaz8U9W.esm.js → index-2wcE74zV.esm.js} +127 -87
  4. package/dist/index-2wcE74zV.esm.js.map +1 -0
  5. package/dist/{index-BLiaV7Dz.js → index-BbyEdrbT.js} +127 -86
  6. package/dist/index-BbyEdrbT.js.map +1 -0
  7. package/dist/{index-CXmcQaFm.js → index-BdtzCA9I.js} +2 -2
  8. package/dist/{index-CXmcQaFm.js.map → index-BdtzCA9I.js.map} +1 -1
  9. package/dist/{index-4JUcdcnk.esm.js → index-BosINgjL.esm.js} +2 -2
  10. package/dist/{index-4JUcdcnk.esm.js.map → index-BosINgjL.esm.js.map} +1 -1
  11. package/dist/{index-QJAj_nTx.js → index-D5KlQpzj.js} +2 -2
  12. package/dist/{index-QJAj_nTx.js.map → index-D5KlQpzj.js.map} +1 -1
  13. package/dist/{index-DQhWZskl.esm.js → index-TCh-Tz3A.esm.js} +2 -2
  14. package/dist/{index-DQhWZskl.esm.js.map → index-TCh-Tz3A.esm.js.map} +1 -1
  15. package/dist/{index.browser-CG2sQjrd.esm.js → index.browser-CQxdFuE2.esm.js} +2 -2
  16. package/dist/{index.browser-CG2sQjrd.esm.js.map → index.browser-CQxdFuE2.esm.js.map} +1 -1
  17. package/dist/{index.browser-kQdoMu7Y.esm.js → index.browser-CkaOa5gJ.esm.js} +2 -2
  18. package/dist/{index.browser-kQdoMu7Y.esm.js.map → index.browser-CkaOa5gJ.esm.js.map} +1 -1
  19. package/dist/{index.browser-B9NfvmrP.js → index.browser-DxjCzf2n.js} +2 -2
  20. package/dist/{index.browser-B9NfvmrP.js.map → index.browser-DxjCzf2n.js.map} +1 -1
  21. package/dist/{index.browser-UxB-zDuA.js → index.browser-dTW8LCID.js} +2 -2
  22. package/dist/{index.browser-UxB-zDuA.js.map → index.browser-dTW8LCID.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-Ch6gsAP_.esm.js} +109 -85
  28. package/dist/index.native-Ch6gsAP_.esm.js.map +1 -0
  29. package/dist/{index.native-Cycwo-3I.js → index.native-K4hpch3o.js} +109 -84
  30. package/dist/index.native-K4hpch3o.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-BgDhrraw.js → phantom-wallet-provider-BOz9oPsO.js} +16 -3
  36. package/dist/phantom-wallet-provider-BOz9oPsO.js.map +1 -0
  37. package/dist/{phantom-wallet-provider-DM-96ILz.esm.js → phantom-wallet-provider-ieVw9iZ_.esm.js} +16 -3
  38. package/dist/phantom-wallet-provider-ieVw9iZ_.esm.js.map +1 -0
  39. package/dist/{privy-wallet-provider-D4IYOUji.js → privy-wallet-provider-BlWvz1R6.js} +3 -3
  40. package/dist/{privy-wallet-provider-D4IYOUji.js.map → privy-wallet-provider-BlWvz1R6.js.map} +1 -1
  41. package/dist/{privy-wallet-provider-C70AIqHI.esm.js → privy-wallet-provider-CVVhV2RP.esm.js} +3 -3
  42. package/dist/{privy-wallet-provider-C70AIqHI.esm.js.map → privy-wallet-provider-CVVhV2RP.esm.js.map} +1 -1
  43. package/dist/{solana-mobile-wallet-provider-BrjPc7Wd.js → solana-mobile-wallet-provider-C8QDeO6I.js} +8 -5
  44. package/dist/solana-mobile-wallet-provider-C8QDeO6I.js.map +1 -0
  45. package/dist/{solana-mobile-wallet-provider-CXXw-pKg.esm.js → solana-mobile-wallet-provider-CHMZajIq.esm.js} +8 -5
  46. package/dist/solana-mobile-wallet-provider-CHMZajIq.esm.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-2wcE74zV.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-BbyEdrbT.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() {
@@ -16980,20 +16986,20 @@ class MockPoofnetProvider {
16980
16986
  const index = Math.min(meta.activeIndex, meta.count - 1);
16981
16987
  this.activeKeypair = await this.deriveKeypair(appId, index);
16982
16988
  const user = await this.mintSession(this.activeKeypair);
16983
- this.showWalletWidget(appId).catch(() => { });
16989
+ activeMockPoofnetInstance = this;
16984
16990
  return user;
16985
16991
  }
16986
16992
  async restoreSession() {
16987
16993
  const session = await WebSessionManager.getSession();
16988
16994
  if (!session)
16989
16995
  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.
16996
+ // Re-derive the active keypair so signMessage works after a reload.
16997
+ // Best-effort — the session itself is authoritative.
16992
16998
  try {
16993
16999
  const appId = await this.getAppId();
16994
17000
  const meta = this.getWalletMeta(appId);
16995
17001
  this.activeKeypair = await this.deriveKeypair(appId, Math.min(meta.activeIndex, Math.max(0, meta.count - 1)));
16996
- this.showWalletWidget(appId).catch(() => { });
17002
+ activeMockPoofnetInstance = this;
16997
17003
  }
16998
17004
  catch ( /* noop */_a) { /* noop */ }
16999
17005
  return { provider: this, address: session.address };
@@ -17002,7 +17008,7 @@ class MockPoofnetProvider {
17002
17008
  WebSessionManager.clearSession();
17003
17009
  setCurrentUser(null);
17004
17010
  this.activeKeypair = null;
17005
- this.removeWalletWidget();
17011
+ activeMockPoofnetInstance = null;
17006
17012
  }
17007
17013
  // ============ Multi-wallet management ============
17008
17014
  /** Switch to (and connect as) an existing mock wallet by index. */
@@ -17017,7 +17023,7 @@ class MockPoofnetProvider {
17017
17023
  WebSessionManager.clearSession();
17018
17024
  this.activeKeypair = await this.deriveKeypair(appId, index);
17019
17025
  const user = await this.mintSession(this.activeKeypair);
17020
- this.showWalletWidget(appId).catch(() => { });
17026
+ activeMockPoofnetInstance = this;
17021
17027
  return user;
17022
17028
  }
17023
17029
  /** Generate a brand-new mock wallet (next index) and connect as it. */
@@ -17026,6 +17032,18 @@ class MockPoofnetProvider {
17026
17032
  const meta = this.getWalletMeta(appId);
17027
17033
  return this.switchWallet(meta.count);
17028
17034
  }
17035
+ /** Wallet list + active index for the wallet UI (usePoofnetWallet hook). */
17036
+ async getWalletState() {
17037
+ const appId = await this.getAppId();
17038
+ const meta = this.getWalletMeta(appId);
17039
+ const count = Math.max(1, meta.count);
17040
+ const wallets = [];
17041
+ for (let i = 0; i < count; i++) {
17042
+ const kp = await this.deriveKeypair(appId, i);
17043
+ wallets.push({ index: i, label: this.labelFor(meta, i), address: kp.publicKey.toBase58() });
17044
+ }
17045
+ return { wallets, activeIndex: Math.min(meta.activeIndex, count - 1) };
17046
+ }
17029
17047
  // ============ AuthProvider interface (offchain-wrapped, mostly inert) ============
17030
17048
  async signMessage(message) {
17031
17049
  if (!this.activeKeypair)
@@ -17058,73 +17076,6 @@ class MockPoofnetProvider {
17058
17076
  async getNativeMethods() {
17059
17077
  return {};
17060
17078
  }
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
17079
  }
17129
17080
 
17130
17081
  /**
@@ -17888,15 +17839,15 @@ function clearIncompatibleSession() {
17888
17839
  // Lazy loaders for web-only providers.
17889
17840
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
17890
17841
  async function loadPrivyWalletProvider() {
17891
- const mod = await import('./privy-wallet-provider-C70AIqHI.esm.js');
17842
+ const mod = await import('./privy-wallet-provider-CVVhV2RP.esm.js');
17892
17843
  return mod.PrivyWalletProvider;
17893
17844
  }
17894
17845
  async function loadPhantomWalletProvider() {
17895
- const mod = await import('./phantom-wallet-provider-DM-96ILz.esm.js');
17846
+ const mod = await import('./phantom-wallet-provider-ieVw9iZ_.esm.js');
17896
17847
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
17897
17848
  }
17898
17849
  async function loadSolanaMobileWalletProvider() {
17899
- const mod = await import('./solana-mobile-wallet-provider-CXXw-pKg.esm.js');
17850
+ const mod = await import('./solana-mobile-wallet-provider-CHMZajIq.esm.js');
17900
17851
  return mod.SolanaMobileWalletProvider;
17901
17852
  }
17902
17853
  async function hotSwapToPrivyProvider(config) {
@@ -18226,17 +18177,17 @@ function setAuthProviderInstance(provider) {
18226
18177
  authProviderInstance = provider;
18227
18178
  }
18228
18179
 
18229
- var _a;
18180
+ var _a$1;
18230
18181
  // Whether we're in a server-side rendering context (no hooks allowed).
18231
18182
  // React Native has no `window` but DOES support hooks.
18232
18183
  // We detect Node SSR specifically via process.versions.node to avoid
18233
18184
  // false positives from Node 21+ which defines `navigator` globally.
18234
- const isSSR = typeof window === 'undefined'
18185
+ const isSSR$1 = typeof window === 'undefined'
18235
18186
  && typeof process !== 'undefined'
18236
- && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18187
+ && !!((_a$1 = process.versions) === null || _a$1 === void 0 ? void 0 : _a$1.node);
18237
18188
  function useAuth() {
18238
18189
  // Provide a fallback so server render doesn't break
18239
- if (isSSR) {
18190
+ if (isSSR$1) {
18240
18191
  return {
18241
18192
  login: async () => undefined,
18242
18193
  logout: async () => undefined,
@@ -18296,6 +18247,79 @@ function useAuth() {
18296
18247
  };
18297
18248
  }
18298
18249
 
18250
+ var _a;
18251
+ const isSSR = typeof window === 'undefined'
18252
+ && typeof process !== 'undefined'
18253
+ && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
18254
+ const EMPTY = {
18255
+ isMock: false,
18256
+ wallets: [],
18257
+ activeIndex: 0,
18258
+ switchWallet: async () => undefined,
18259
+ generateWallet: async () => undefined,
18260
+ refresh: async () => undefined,
18261
+ };
18262
+ /**
18263
+ * Exposes the simulated Poofnet wallet to the app's own wallet UI (e.g. the
18264
+ * template WalletButton). `isMock` is false on mainnet / real-wallet sessions,
18265
+ * so callers can conditionally render the switch/generate controls.
18266
+ *
18267
+ * Reactive: re-reads whenever auth state changes (login / logout / wallet
18268
+ * switch all flow through setCurrentUser → onAuthStateChanged).
18269
+ */
18270
+ function usePoofnetWallet() {
18271
+ if (isSSR)
18272
+ return EMPTY;
18273
+ const [state, setState] = React.useState({
18274
+ isMock: false,
18275
+ wallets: [],
18276
+ activeIndex: 0,
18277
+ });
18278
+ const refresh = React.useCallback(async () => {
18279
+ const provider = getActiveMockPoofnetProvider();
18280
+ if (!provider) {
18281
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18282
+ return;
18283
+ }
18284
+ try {
18285
+ const { wallets, activeIndex } = await provider.getWalletState();
18286
+ setState({ isMock: true, wallets, activeIndex });
18287
+ }
18288
+ catch (_a) {
18289
+ setState({ isMock: false, wallets: [], activeIndex: 0 });
18290
+ }
18291
+ }, []);
18292
+ React.useEffect(() => {
18293
+ refresh();
18294
+ // setCurrentUser (login/logout/switch/generate) notifies these listeners.
18295
+ onAuthStateChanged(() => { refresh(); });
18296
+ // Note: onAuthStateChanged has no unsubscribe yet (same as useAuth) — fine
18297
+ // for a wallet button that mounts once.
18298
+ }, [refresh]);
18299
+ const switchWallet = React.useCallback(async (index) => {
18300
+ const provider = getActiveMockPoofnetProvider();
18301
+ if (provider) {
18302
+ await provider.switchWallet(index);
18303
+ await refresh();
18304
+ }
18305
+ }, [refresh]);
18306
+ const generateWallet = React.useCallback(async () => {
18307
+ const provider = getActiveMockPoofnetProvider();
18308
+ if (provider) {
18309
+ await provider.generateWallet();
18310
+ await refresh();
18311
+ }
18312
+ }, [refresh]);
18313
+ return {
18314
+ isMock: state.isMock,
18315
+ wallets: state.wallets,
18316
+ activeIndex: state.activeIndex,
18317
+ switchWallet,
18318
+ generateWallet,
18319
+ refresh,
18320
+ };
18321
+ }
18322
+
18299
18323
  async function deserializeTransaction(tx) {
18300
18324
  const buf = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'base64');
18301
18325
  if ((buf[0] & 0x80) !== 0) {
@@ -18928,5 +18952,5 @@ class PrivyExpoProvider {
18928
18952
  }
18929
18953
  }
18930
18954
 
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
18955
+ 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 };
18956
+ //# sourceMappingURL=index.native-Ch6gsAP_.esm.js.map