@pollar/react 0.7.1 → 0.8.0

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.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,27 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PollarApplicationConfigContent, PollarLoginOptions, PollarClientConfig, pollarPaths, PollarAdapters, PollarClient, TransactionState, TxBuildBody, WalletId, StellarNetwork, WalletBalanceState, TxHistoryState, PollarAdapter, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, PaymentInstructions, WalletBalanceRecord, SessionInfo, DistributionRulesState, DistributionRule } from '@pollar/core';
2
+ import { PollarApplicationConfigContent, PollarLoginOptions, PollarClientConfig, WalletId, AuthState, pollarPaths, PollarClient, PollarAdapters, OnStorageDegrade, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, StellarNetwork, WalletBalanceState, TxHistoryState, PollarAdapter, KycStatus as KycStatus$1, RampQuote, KycProvider, KycStartResponse, RampDirection, PaymentInstructions, WalletBalanceRecord, SessionInfo, DistributionRulesState, DistributionRule } from '@pollar/core';
3
3
  import { ReactNode } from 'react';
4
4
 
5
5
  type ConfigResponse = pollarPaths['/applications/config']['get']['responses'][200]['content']['application/json'];
6
6
  type PollarConfig = ConfigResponse['content'];
7
7
  type PollarStyles = PollarConfig['styles'];
8
+ /**
9
+ * Props passed by `@pollar/react` to a `renderWallets` slot. External wallet
10
+ * picker components receive these and call `onConnect(id)` when the user picks
11
+ * a wallet; `@pollar/react` wraps that into `client.loginWallet(id)`.
12
+ */
13
+ interface RenderWalletsProps {
14
+ /** Wrapper around `client.loginWallet(id)`. */
15
+ onConnect: (id: WalletId) => void;
16
+ /** Current auth state — picker can disable buttons / surface loading. */
17
+ authState: AuthState;
18
+ }
19
+ /**
20
+ * Signature for the `ui.renderWallets` slot on `<PollarProvider>`. When
21
+ * provided, replaces the default Freighter/Albedo buttons in the LoginModal
22
+ * with whatever the slot returns (typically a kit-powered wallet grid).
23
+ */
24
+ type RenderWalletsSlot = (props: RenderWalletsProps) => ReactNode;
8
25
  interface AuthProviderProps {
9
26
  config: PollarClientConfig;
10
27
  children: React.ReactNode;
@@ -39,10 +56,19 @@ interface PollarContextValue {
39
56
  openSessionsModal: () => void;
40
57
  appConfig: PollarConfig;
41
58
  styles: PollarStyles;
59
+ /** UI slot for wallet picker (forwarded from provider props). */
60
+ renderWallets?: RenderWalletsSlot;
42
61
  openTxModal: () => void;
43
62
  tx: TransactionState;
44
- buildTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<void>;
45
- signAndSubmitTx: (unsignedXdr: string) => Promise<void>;
63
+ buildTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<BuildOutcome>;
64
+ signAndSubmitTx: (unsignedXdr: string) => Promise<SubmitOutcome>;
65
+ /** External-wallet only. Custodial flows should use `signAndSubmitTx`. */
66
+ signTx: (unsignedXdr: string) => Promise<SignOutcome>;
67
+ submitTx: (signedXdr: string) => Promise<SubmitOutcome>;
68
+ /** One-shot: build → sign → submit. Drives the same TransactionState flow as the split calls. */
69
+ buildAndSignAndSubmitTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
70
+ /** Alias of `buildAndSignAndSubmitTx`. */
71
+ runTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
46
72
  walletType: WalletId | null;
47
73
  network: StellarNetwork;
48
74
  setNetwork: (network: StellarNetwork) => void;
@@ -63,16 +89,45 @@ interface PollarContextValue {
63
89
  adapters?: PollarAdapters;
64
90
  }
65
91
  interface PollarProviderProps {
66
- config: PollarClientConfig;
67
- styles?: PollarStyles;
92
+ /**
93
+ * Either a pre-built `PollarClient` instance (useful for testing or for
94
+ * reusing the same client outside React) or a `PollarClientConfig` that the
95
+ * provider will use to construct one on mount.
96
+ *
97
+ * The client is locked at first render: changing this prop afterwards is
98
+ * ignored. To swap clients, unmount and remount the provider.
99
+ */
100
+ client: PollarClient | PollarClientConfig;
101
+ /**
102
+ * Local override of the `/applications/config` response. If provided (even
103
+ * `{}`), the remote fetch is skipped and missing fields fall back to the
104
+ * defaults in `LoginModalTemplate`. If `undefined`, the SDK fetches
105
+ * `/applications/config` on mount.
106
+ */
107
+ appConfig?: PollarConfig;
108
+ /** UI customization slots. */
109
+ ui?: {
110
+ /** Replaces the default Freighter/Albedo wallet picker. */
111
+ renderWallets?: RenderWalletsSlot;
112
+ };
68
113
  adapters?: PollarAdapters;
114
+ /**
115
+ * Notified when persistent storage silently degrades to in-memory mode
116
+ * (Safari private browsing quota errors, sandboxed iframes, etc.). Use this
117
+ * to surface a UI hint that the session won't survive a reload, log to
118
+ * telemetry, or fall back to a different storage strategy.
119
+ *
120
+ * Fires at most once per provider lifetime; late mounts get the latched
121
+ * state replayed on subscribe.
122
+ */
123
+ onStorageDegrade?: OnStorageDegrade;
69
124
  children: ReactNode;
70
125
  }
71
- declare function PollarProvider({ config, styles: propStyles, adapters, children }: PollarProviderProps): react_jsx_runtime.JSX.Element;
126
+ declare function PollarProvider({ client, appConfig: appConfigProp, ui, adapters, onStorageDegrade, children, }: PollarProviderProps): react_jsx_runtime.JSX.Element;
72
127
  declare function usePollar(): PollarContextValue;
73
128
 
74
129
  type WrappedAdapter<T extends PollarAdapter> = {
75
- [K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<void>;
130
+ [K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<SubmitOutcome>;
76
131
  };
77
132
  declare function createPollarAdapterHook<T extends PollarAdapter>(key: string): () => WrappedAdapter<T>;
78
133
 
@@ -149,8 +204,9 @@ interface LoginModalTemplateProps {
149
204
  onEmailChange?: (email: string) => void;
150
205
  onEmailSubmit?: () => void;
151
206
  onSocialLogin?: (provider: 'google' | 'github') => void;
152
- onFreighterConnect?: () => void;
153
- onAlbedoConnect?: () => void;
207
+ onWalletConnect: (id: WalletId) => void;
208
+ /** Optional override for the wallet picker view. Defaults to a Freighter+Albedo list. */
209
+ renderWallets?: RenderWalletsSlot;
154
210
  authState: AuthState;
155
211
  codeInputKey?: number;
156
212
  onCodeSubmit?: (code: string) => void;
@@ -158,7 +214,7 @@ interface LoginModalTemplateProps {
158
214
  onCancel: () => void;
159
215
  onRetry: () => void;
160
216
  }
161
- declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, providers, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onFreighterConnect, onAlbedoConnect, authState, codeInputKey, onCodeSubmit, onBack, onCancel, onRetry, }: LoginModalTemplateProps): react_jsx_runtime.JSX.Element;
217
+ declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, providers, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onWalletConnect, renderWallets, authState, codeInputKey, onCodeSubmit, onBack, onCancel, onRetry, }: LoginModalTemplateProps): react_jsx_runtime.JSX.Element;
162
218
 
163
219
  type KycStep = 'select_provider' | 'verifying' | 'polling' | 'done';
164
220
  interface KycModalTemplateProps {
@@ -330,4 +386,4 @@ interface DistributionRulesModalTemplateProps {
330
386
  }
331
387
  declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
332
388
 
333
- export { type AuthContextValue, type AuthModalProps, type AuthProviderProps, DistributionRulesModal, DistributionRulesModalTemplate, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type PollarConfig, PollarProvider, type PollarStyles, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, RouteDisplay, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SessionsState, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, createPollarAdapterHook, usePollar };
389
+ export { type AuthContextValue, type AuthModalProps, type AuthProviderProps, DistributionRulesModal, DistributionRulesModalTemplate, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type PollarConfig, PollarProvider, type PollarStyles, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, type RenderWalletsProps, type RenderWalletsSlot, RouteDisplay, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SessionsState, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, createPollarAdapterHook, usePollar };