@pollar/react 0.7.0 → 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 } 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;
@@ -59,19 +85,49 @@ interface PollarContextValue {
59
85
  openWalletBalanceModal: () => void;
60
86
  openSendModal: () => void;
61
87
  openReceiveModal: () => void;
88
+ openDistributionRulesModal: () => void;
62
89
  adapters?: PollarAdapters;
63
90
  }
64
91
  interface PollarProviderProps {
65
- config: PollarClientConfig;
66
- 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
+ };
67
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;
68
124
  children: ReactNode;
69
125
  }
70
- 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;
71
127
  declare function usePollar(): PollarContextValue;
72
128
 
73
129
  type WrappedAdapter<T extends PollarAdapter> = {
74
- [K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<void>;
130
+ [K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<SubmitOutcome>;
75
131
  };
76
132
  declare function createPollarAdapterHook<T extends PollarAdapter>(key: string): () => WrappedAdapter<T>;
77
133
 
@@ -125,6 +181,11 @@ interface SessionsModalProps {
125
181
  }
126
182
  declare function SessionsModal({ onClose }: SessionsModalProps): react_jsx_runtime.JSX.Element;
127
183
 
184
+ interface DistributionRulesModalProps {
185
+ onClose: () => void;
186
+ }
187
+ declare function DistributionRulesModal({ onClose }: DistributionRulesModalProps): react_jsx_runtime.JSX.Element;
188
+
128
189
  interface LoginModalTemplateProps {
129
190
  theme: string;
130
191
  accentColor: string;
@@ -143,8 +204,9 @@ interface LoginModalTemplateProps {
143
204
  onEmailChange?: (email: string) => void;
144
205
  onEmailSubmit?: () => void;
145
206
  onSocialLogin?: (provider: 'google' | 'github') => void;
146
- onFreighterConnect?: () => void;
147
- onAlbedoConnect?: () => void;
207
+ onWalletConnect: (id: WalletId) => void;
208
+ /** Optional override for the wallet picker view. Defaults to a Freighter+Albedo list. */
209
+ renderWallets?: RenderWalletsSlot;
148
210
  authState: AuthState;
149
211
  codeInputKey?: number;
150
212
  onCodeSubmit?: (code: string) => void;
@@ -152,7 +214,7 @@ interface LoginModalTemplateProps {
152
214
  onCancel: () => void;
153
215
  onRetry: () => void;
154
216
  }
155
- 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;
156
218
 
157
219
  type KycStep = 'select_provider' | 'verifying' | 'polling' | 'done';
158
220
  interface KycModalTemplateProps {
@@ -311,4 +373,17 @@ interface SessionsModalTemplateProps {
311
373
  }
312
374
  declare function SessionsModalTemplate({ theme, accentColor, state, revokingFamilyId, signingOutEverywhere, onRefresh, onRevoke, onLogoutEverywhere, onClose, }: SessionsModalTemplateProps): react_jsx_runtime.JSX.Element;
313
375
 
314
- export { type AuthContextValue, type AuthModalProps, type AuthProviderProps, 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 };
376
+ interface DistributionRulesModalTemplateProps {
377
+ theme: string;
378
+ accentColor: string;
379
+ state: DistributionRulesState;
380
+ claimingId: string | null;
381
+ claimErrors: Record<string, string>;
382
+ claimedIds: Set<string>;
383
+ onRefresh: () => void;
384
+ onClaim: (rule: DistributionRule) => void;
385
+ onClose: () => void;
386
+ }
387
+ declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
388
+
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 };