@pollar/react 0.9.0 → 0.10.0-rc.10
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/README.md +23 -47
- package/dist/index.css +43 -12
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +101 -37
- package/dist/index.d.ts +101 -37
- package/dist/index.js +1021 -364
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1021 -366
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export { SessionsState } from '@pollar/core';
|
|
2
|
+
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapQuoteParams, SwapQuote, PollarAdapter, WalletId, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
3
|
+
export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
type ConfigResponse = pollarPaths['/applications/config']['get']['responses'][200]['content']['application/json'];
|
|
7
7
|
type PollarConfig = ConfigResponse['content'];
|
|
8
8
|
type PollarStyles = PollarConfig['styles'];
|
|
9
|
-
/**
|
|
10
|
-
* Props passed by `@pollar/react` to a `renderWallets` slot. External wallet
|
|
11
|
-
* picker components receive these and call `onConnect(id)` when the user picks
|
|
12
|
-
* a wallet; `@pollar/react` wraps that into `client.loginWallet(id)`.
|
|
13
|
-
*/
|
|
14
|
-
interface RenderWalletsProps {
|
|
15
|
-
/** Wrapper around `client.loginWallet(id)`. */
|
|
16
|
-
onConnect: (id: WalletId) => void;
|
|
17
|
-
/** Current auth state — picker can disable buttons / surface loading. */
|
|
18
|
-
authState: AuthState;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Signature for the `ui.renderWallets` slot on `<PollarProvider>`. When
|
|
22
|
-
* provided, replaces the default Freighter/Albedo buttons in the LoginModal
|
|
23
|
-
* with whatever the slot returns (typically a kit-powered wallet grid).
|
|
24
|
-
*/
|
|
25
|
-
type RenderWalletsSlot = (props: RenderWalletsProps) => ReactNode;
|
|
26
9
|
interface LoginButtonProps {
|
|
27
10
|
onSuccess?: () => void;
|
|
28
11
|
onError?: (error: Error) => void;
|
|
@@ -36,7 +19,14 @@ interface AuthModalProps {
|
|
|
36
19
|
}
|
|
37
20
|
|
|
38
21
|
interface PollarContextValue {
|
|
39
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The authenticated user's wallet as a discriminated union over `custody`
|
|
24
|
+
* (`internal` | `smart` | `external`), or `null` when unauthenticated. Every
|
|
25
|
+
* field is meaningful for any login method — `custody` is always present and
|
|
26
|
+
* strictly determines the shape of `provider`. Use `wallet.address` for the
|
|
27
|
+
* on-chain address and `wallet.provider` for the wallet/login provider.
|
|
28
|
+
*/
|
|
29
|
+
wallet: WalletInfo | null;
|
|
40
30
|
getClient: () => PollarClient;
|
|
41
31
|
openLoginModal: () => void;
|
|
42
32
|
isAuthenticated: boolean;
|
|
@@ -53,8 +43,6 @@ interface PollarContextValue {
|
|
|
53
43
|
openSessionsModal: () => void;
|
|
54
44
|
appConfig: PollarConfig;
|
|
55
45
|
styles: PollarStyles;
|
|
56
|
-
/** UI slot for wallet picker (forwarded from provider props). */
|
|
57
|
-
renderWallets?: RenderWalletsSlot;
|
|
58
46
|
openTxModal: () => void;
|
|
59
47
|
tx: TransactionState;
|
|
60
48
|
buildTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<BuildOutcome>;
|
|
@@ -66,7 +54,6 @@ interface PollarContextValue {
|
|
|
66
54
|
buildAndSignAndSubmitTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
67
55
|
/** Alias of `buildAndSignAndSubmitTx`. */
|
|
68
56
|
runTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
69
|
-
walletType: WalletId | null;
|
|
70
57
|
network: StellarNetwork;
|
|
71
58
|
setNetwork: (network: StellarNetwork) => void;
|
|
72
59
|
walletBalance: WalletBalanceState;
|
|
@@ -104,6 +91,20 @@ interface PollarContextValue {
|
|
|
104
91
|
openWalletBalanceModal: () => void;
|
|
105
92
|
openSendModal: () => void;
|
|
106
93
|
openReceiveModal: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Quote an asset-to-asset swap across the requested venue(s). Read-only;
|
|
96
|
+
* returns quotes ranked best-first. Mirrors {@link PollarClient.getSwapQuote}.
|
|
97
|
+
*/
|
|
98
|
+
getSwapQuote: (params: SwapQuoteParams) => Promise<SwapQuote[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Execute a swap from a quote (establishes the buy-asset trustline first when
|
|
101
|
+
* needed). Drives the transaction state machine. Mirrors {@link PollarClient.swap}.
|
|
102
|
+
*/
|
|
103
|
+
swap: (quote: SwapQuote, opts?: {
|
|
104
|
+
autoTrustline?: boolean;
|
|
105
|
+
}) => Promise<SubmitOutcome>;
|
|
106
|
+
/** Open the swap modal. */
|
|
107
|
+
openSwapModal: () => void;
|
|
107
108
|
openDistributionRulesModal: () => void;
|
|
108
109
|
adapters?: PollarAdapters;
|
|
109
110
|
}
|
|
@@ -124,11 +125,6 @@ interface PollarProviderProps {
|
|
|
124
125
|
* `/applications/config` on mount.
|
|
125
126
|
*/
|
|
126
127
|
appConfig?: PollarConfig;
|
|
127
|
-
/** UI customization slots. */
|
|
128
|
-
ui?: {
|
|
129
|
-
/** Replaces the default Freighter/Albedo wallet picker. */
|
|
130
|
-
renderWallets?: RenderWalletsSlot;
|
|
131
|
-
};
|
|
132
128
|
adapters?: PollarAdapters;
|
|
133
129
|
/**
|
|
134
130
|
* Notified when persistent storage silently degrades to in-memory mode
|
|
@@ -142,7 +138,7 @@ interface PollarProviderProps {
|
|
|
142
138
|
onStorageDegrade?: OnStorageDegrade;
|
|
143
139
|
children: ReactNode;
|
|
144
140
|
}
|
|
145
|
-
declare function PollarProvider({ client, appConfig: appConfigProp,
|
|
141
|
+
declare function PollarProvider({ client, appConfig: appConfigProp, adapters, onStorageDegrade, children, }: PollarProviderProps): react_jsx_runtime.JSX.Element;
|
|
146
142
|
declare function usePollar(): PollarContextValue;
|
|
147
143
|
|
|
148
144
|
type WrappedAdapter<T extends PollarAdapter> = {
|
|
@@ -221,6 +217,11 @@ interface SendModalProps {
|
|
|
221
217
|
}
|
|
222
218
|
declare function SendModal({ onClose }: SendModalProps): react_jsx_runtime.JSX.Element;
|
|
223
219
|
|
|
220
|
+
interface SwapModalProps {
|
|
221
|
+
onClose: () => void;
|
|
222
|
+
}
|
|
223
|
+
declare function SwapModal({ onClose }: SwapModalProps): react_jsx_runtime.JSX.Element;
|
|
224
|
+
|
|
224
225
|
interface ReceiveModalProps {
|
|
225
226
|
onClose: () => void;
|
|
226
227
|
}
|
|
@@ -236,6 +237,14 @@ interface DistributionRulesModalProps {
|
|
|
236
237
|
}
|
|
237
238
|
declare function DistributionRulesModal({ onClose }: DistributionRulesModalProps): react_jsx_runtime.JSX.Element;
|
|
238
239
|
|
|
240
|
+
type WalletAdapterEntry = {
|
|
241
|
+
id: WalletId;
|
|
242
|
+
meta: {
|
|
243
|
+
label: string;
|
|
244
|
+
iconUrl?: string;
|
|
245
|
+
group?: string;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
239
248
|
interface LoginModalTemplateProps {
|
|
240
249
|
theme: string;
|
|
241
250
|
accentColor: string;
|
|
@@ -252,6 +261,8 @@ interface LoginModalTemplateProps {
|
|
|
252
261
|
github: boolean;
|
|
253
262
|
apple: boolean;
|
|
254
263
|
};
|
|
264
|
+
/** Registered wallet adapters to render as buttons (Freighter, Albedo, Privy, …). */
|
|
265
|
+
walletAdapters: WalletAdapterEntry[];
|
|
255
266
|
appName: string;
|
|
256
267
|
email?: string;
|
|
257
268
|
onEmailChange?: (email: string) => void;
|
|
@@ -262,8 +273,6 @@ interface LoginModalTemplateProps {
|
|
|
262
273
|
onLoginSmartWallet?: () => void;
|
|
263
274
|
/** Create a new passkey + smart wallet (new user). */
|
|
264
275
|
onCreateSmartWallet?: () => void;
|
|
265
|
-
/** Optional override for the wallet picker view. Defaults to a Freighter+Albedo list. */
|
|
266
|
-
renderWallets?: RenderWalletsSlot;
|
|
267
276
|
authState: AuthState;
|
|
268
277
|
codeInputKey?: number;
|
|
269
278
|
onCodeSubmit?: (code: string) => void;
|
|
@@ -271,7 +280,7 @@ interface LoginModalTemplateProps {
|
|
|
271
280
|
onCancel: () => void;
|
|
272
281
|
onRetry: () => void;
|
|
273
282
|
}
|
|
274
|
-
declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, smartWallet, providers, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onWalletConnect, onLoginSmartWallet, onCreateSmartWallet,
|
|
283
|
+
declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, smartWallet, providers, walletAdapters, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onWalletConnect, onLoginSmartWallet, onCreateSmartWallet, authState, codeInputKey, onCodeSubmit, onBack, onCancel, onRetry, }: LoginModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
275
284
|
|
|
276
285
|
type KycStep = 'select_provider' | 'verifying' | 'polling' | 'done';
|
|
277
286
|
interface KycModalTemplateProps {
|
|
@@ -289,7 +298,7 @@ interface KycModalTemplateProps {
|
|
|
289
298
|
}
|
|
290
299
|
declare function KycModalTemplate({ theme, accentColor, step, providers, selectedProvider, session, kycStatus, isLoading, onSelectProvider, onDoneVerifying, onClose, }: KycModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
291
300
|
|
|
292
|
-
type RampStep = 'input' | 'loading_quote' | 'select_route' | '
|
|
301
|
+
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'status' | 'error';
|
|
293
302
|
interface RampWidgetTemplateProps {
|
|
294
303
|
theme: string;
|
|
295
304
|
accentColor: string;
|
|
@@ -299,18 +308,26 @@ interface RampWidgetTemplateProps {
|
|
|
299
308
|
currency: string;
|
|
300
309
|
country: string;
|
|
301
310
|
quotes: RampQuote[];
|
|
302
|
-
paymentInstructions: PaymentInstructions | null;
|
|
303
311
|
isLoading: boolean;
|
|
312
|
+
provider: string;
|
|
313
|
+
txStatus: RampTxStatus | null;
|
|
314
|
+
kycUrl: string | null;
|
|
315
|
+
stellarTxHash: string | null;
|
|
316
|
+
canComplete: boolean;
|
|
317
|
+
completing: boolean;
|
|
318
|
+
errorMsg: string | null;
|
|
304
319
|
onDirectionChange: (d: RampDirection) => void;
|
|
305
320
|
onAmountChange: (v: string) => void;
|
|
306
321
|
onCurrencyChange: (v: string) => void;
|
|
307
322
|
onCountryChange: (v: string) => void;
|
|
308
323
|
onFindRoute: () => void;
|
|
309
324
|
onSelectQuote: (q: RampQuote) => void;
|
|
310
|
-
|
|
325
|
+
onOpenKyc: () => void;
|
|
326
|
+
onCompleteWithdraw: () => void;
|
|
327
|
+
onRetry: () => void;
|
|
311
328
|
onClose: () => void;
|
|
312
329
|
}
|
|
313
|
-
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, quotes,
|
|
330
|
+
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, canComplete, completing, errorMsg, onDirectionChange, onAmountChange, onCurrencyChange, onCountryChange, onFindRoute, onSelectQuote, onOpenKyc, onCompleteWithdraw, onRetry, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
|
|
314
331
|
|
|
315
332
|
interface TransactionModalTemplateProps {
|
|
316
333
|
theme: string;
|
|
@@ -411,6 +428,53 @@ interface SendModalTemplateProps {
|
|
|
411
428
|
}
|
|
412
429
|
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
413
430
|
|
|
431
|
+
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
432
|
+
interface SwapAssetOption {
|
|
433
|
+
ref: SwapQuoteParams['sellAsset'];
|
|
434
|
+
code: string;
|
|
435
|
+
issuer?: string | undefined;
|
|
436
|
+
available?: string | undefined;
|
|
437
|
+
enabledInApp?: boolean | undefined;
|
|
438
|
+
}
|
|
439
|
+
interface SwapModalTemplateProps {
|
|
440
|
+
theme: string;
|
|
441
|
+
accentColor: string;
|
|
442
|
+
step: 'form' | 'tx';
|
|
443
|
+
txTitle: string;
|
|
444
|
+
sellOptions: SwapAssetOption[];
|
|
445
|
+
buyOptions: SwapAssetOption[];
|
|
446
|
+
selectedSell: SwapAssetOption | null;
|
|
447
|
+
selectedBuy: SwapAssetOption | null;
|
|
448
|
+
amount: string;
|
|
449
|
+
provider: SwapProvider;
|
|
450
|
+
providers: SwapProvider[];
|
|
451
|
+
quote: SwapQuote | null;
|
|
452
|
+
quoteLoading: boolean;
|
|
453
|
+
quoteError: string;
|
|
454
|
+
formError: string;
|
|
455
|
+
isLoadingData: boolean;
|
|
456
|
+
smartUnsupported: boolean;
|
|
457
|
+
transaction: TransactionState;
|
|
458
|
+
showXdr: boolean;
|
|
459
|
+
copied: boolean;
|
|
460
|
+
explorerUrl: string | null;
|
|
461
|
+
walletType?: WalletId | null | undefined;
|
|
462
|
+
showBack: boolean;
|
|
463
|
+
isInProgress: boolean;
|
|
464
|
+
onClose: () => void;
|
|
465
|
+
onBack: () => void;
|
|
466
|
+
onSelectSell: (o: SwapAssetOption) => void;
|
|
467
|
+
onSelectBuy: (o: SwapAssetOption) => void;
|
|
468
|
+
onAmountChange: (value: string) => void;
|
|
469
|
+
onProviderChange: (p: SwapProvider) => void;
|
|
470
|
+
onSwap: () => void;
|
|
471
|
+
onToggleXdr: () => void;
|
|
472
|
+
onCopyHash: () => void;
|
|
473
|
+
onRetry: () => void;
|
|
474
|
+
onDone: () => void;
|
|
475
|
+
}
|
|
476
|
+
declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOptions, buyOptions, selectedSell, selectedBuy, amount, provider, providers, quote, quoteLoading, quoteError, formError, isLoadingData, smartUnsupported, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onSelectSell, onSelectBuy, onAmountChange, onProviderChange, onSwap, onToggleXdr, onCopyHash, onRetry, onDone, }: SwapModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
477
|
+
|
|
414
478
|
interface ReceiveModalTemplateProps {
|
|
415
479
|
theme: string;
|
|
416
480
|
accentColor: string;
|
|
@@ -447,4 +511,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
447
511
|
}
|
|
448
512
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
449
513
|
|
|
450
|
-
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type PollarConfig, PollarProvider, type PollarStyles, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps,
|
|
514
|
+
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, 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 SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, createPollarAdapterHook, usePollar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export { SessionsState } from '@pollar/core';
|
|
2
|
+
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapQuoteParams, SwapQuote, PollarAdapter, WalletId, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
3
|
+
export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
type ConfigResponse = pollarPaths['/applications/config']['get']['responses'][200]['content']['application/json'];
|
|
7
7
|
type PollarConfig = ConfigResponse['content'];
|
|
8
8
|
type PollarStyles = PollarConfig['styles'];
|
|
9
|
-
/**
|
|
10
|
-
* Props passed by `@pollar/react` to a `renderWallets` slot. External wallet
|
|
11
|
-
* picker components receive these and call `onConnect(id)` when the user picks
|
|
12
|
-
* a wallet; `@pollar/react` wraps that into `client.loginWallet(id)`.
|
|
13
|
-
*/
|
|
14
|
-
interface RenderWalletsProps {
|
|
15
|
-
/** Wrapper around `client.loginWallet(id)`. */
|
|
16
|
-
onConnect: (id: WalletId) => void;
|
|
17
|
-
/** Current auth state — picker can disable buttons / surface loading. */
|
|
18
|
-
authState: AuthState;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Signature for the `ui.renderWallets` slot on `<PollarProvider>`. When
|
|
22
|
-
* provided, replaces the default Freighter/Albedo buttons in the LoginModal
|
|
23
|
-
* with whatever the slot returns (typically a kit-powered wallet grid).
|
|
24
|
-
*/
|
|
25
|
-
type RenderWalletsSlot = (props: RenderWalletsProps) => ReactNode;
|
|
26
9
|
interface LoginButtonProps {
|
|
27
10
|
onSuccess?: () => void;
|
|
28
11
|
onError?: (error: Error) => void;
|
|
@@ -36,7 +19,14 @@ interface AuthModalProps {
|
|
|
36
19
|
}
|
|
37
20
|
|
|
38
21
|
interface PollarContextValue {
|
|
39
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The authenticated user's wallet as a discriminated union over `custody`
|
|
24
|
+
* (`internal` | `smart` | `external`), or `null` when unauthenticated. Every
|
|
25
|
+
* field is meaningful for any login method — `custody` is always present and
|
|
26
|
+
* strictly determines the shape of `provider`. Use `wallet.address` for the
|
|
27
|
+
* on-chain address and `wallet.provider` for the wallet/login provider.
|
|
28
|
+
*/
|
|
29
|
+
wallet: WalletInfo | null;
|
|
40
30
|
getClient: () => PollarClient;
|
|
41
31
|
openLoginModal: () => void;
|
|
42
32
|
isAuthenticated: boolean;
|
|
@@ -53,8 +43,6 @@ interface PollarContextValue {
|
|
|
53
43
|
openSessionsModal: () => void;
|
|
54
44
|
appConfig: PollarConfig;
|
|
55
45
|
styles: PollarStyles;
|
|
56
|
-
/** UI slot for wallet picker (forwarded from provider props). */
|
|
57
|
-
renderWallets?: RenderWalletsSlot;
|
|
58
46
|
openTxModal: () => void;
|
|
59
47
|
tx: TransactionState;
|
|
60
48
|
buildTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<BuildOutcome>;
|
|
@@ -66,7 +54,6 @@ interface PollarContextValue {
|
|
|
66
54
|
buildAndSignAndSubmitTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
67
55
|
/** Alias of `buildAndSignAndSubmitTx`. */
|
|
68
56
|
runTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
69
|
-
walletType: WalletId | null;
|
|
70
57
|
network: StellarNetwork;
|
|
71
58
|
setNetwork: (network: StellarNetwork) => void;
|
|
72
59
|
walletBalance: WalletBalanceState;
|
|
@@ -104,6 +91,20 @@ interface PollarContextValue {
|
|
|
104
91
|
openWalletBalanceModal: () => void;
|
|
105
92
|
openSendModal: () => void;
|
|
106
93
|
openReceiveModal: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Quote an asset-to-asset swap across the requested venue(s). Read-only;
|
|
96
|
+
* returns quotes ranked best-first. Mirrors {@link PollarClient.getSwapQuote}.
|
|
97
|
+
*/
|
|
98
|
+
getSwapQuote: (params: SwapQuoteParams) => Promise<SwapQuote[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Execute a swap from a quote (establishes the buy-asset trustline first when
|
|
101
|
+
* needed). Drives the transaction state machine. Mirrors {@link PollarClient.swap}.
|
|
102
|
+
*/
|
|
103
|
+
swap: (quote: SwapQuote, opts?: {
|
|
104
|
+
autoTrustline?: boolean;
|
|
105
|
+
}) => Promise<SubmitOutcome>;
|
|
106
|
+
/** Open the swap modal. */
|
|
107
|
+
openSwapModal: () => void;
|
|
107
108
|
openDistributionRulesModal: () => void;
|
|
108
109
|
adapters?: PollarAdapters;
|
|
109
110
|
}
|
|
@@ -124,11 +125,6 @@ interface PollarProviderProps {
|
|
|
124
125
|
* `/applications/config` on mount.
|
|
125
126
|
*/
|
|
126
127
|
appConfig?: PollarConfig;
|
|
127
|
-
/** UI customization slots. */
|
|
128
|
-
ui?: {
|
|
129
|
-
/** Replaces the default Freighter/Albedo wallet picker. */
|
|
130
|
-
renderWallets?: RenderWalletsSlot;
|
|
131
|
-
};
|
|
132
128
|
adapters?: PollarAdapters;
|
|
133
129
|
/**
|
|
134
130
|
* Notified when persistent storage silently degrades to in-memory mode
|
|
@@ -142,7 +138,7 @@ interface PollarProviderProps {
|
|
|
142
138
|
onStorageDegrade?: OnStorageDegrade;
|
|
143
139
|
children: ReactNode;
|
|
144
140
|
}
|
|
145
|
-
declare function PollarProvider({ client, appConfig: appConfigProp,
|
|
141
|
+
declare function PollarProvider({ client, appConfig: appConfigProp, adapters, onStorageDegrade, children, }: PollarProviderProps): react_jsx_runtime.JSX.Element;
|
|
146
142
|
declare function usePollar(): PollarContextValue;
|
|
147
143
|
|
|
148
144
|
type WrappedAdapter<T extends PollarAdapter> = {
|
|
@@ -221,6 +217,11 @@ interface SendModalProps {
|
|
|
221
217
|
}
|
|
222
218
|
declare function SendModal({ onClose }: SendModalProps): react_jsx_runtime.JSX.Element;
|
|
223
219
|
|
|
220
|
+
interface SwapModalProps {
|
|
221
|
+
onClose: () => void;
|
|
222
|
+
}
|
|
223
|
+
declare function SwapModal({ onClose }: SwapModalProps): react_jsx_runtime.JSX.Element;
|
|
224
|
+
|
|
224
225
|
interface ReceiveModalProps {
|
|
225
226
|
onClose: () => void;
|
|
226
227
|
}
|
|
@@ -236,6 +237,14 @@ interface DistributionRulesModalProps {
|
|
|
236
237
|
}
|
|
237
238
|
declare function DistributionRulesModal({ onClose }: DistributionRulesModalProps): react_jsx_runtime.JSX.Element;
|
|
238
239
|
|
|
240
|
+
type WalletAdapterEntry = {
|
|
241
|
+
id: WalletId;
|
|
242
|
+
meta: {
|
|
243
|
+
label: string;
|
|
244
|
+
iconUrl?: string;
|
|
245
|
+
group?: string;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
239
248
|
interface LoginModalTemplateProps {
|
|
240
249
|
theme: string;
|
|
241
250
|
accentColor: string;
|
|
@@ -252,6 +261,8 @@ interface LoginModalTemplateProps {
|
|
|
252
261
|
github: boolean;
|
|
253
262
|
apple: boolean;
|
|
254
263
|
};
|
|
264
|
+
/** Registered wallet adapters to render as buttons (Freighter, Albedo, Privy, …). */
|
|
265
|
+
walletAdapters: WalletAdapterEntry[];
|
|
255
266
|
appName: string;
|
|
256
267
|
email?: string;
|
|
257
268
|
onEmailChange?: (email: string) => void;
|
|
@@ -262,8 +273,6 @@ interface LoginModalTemplateProps {
|
|
|
262
273
|
onLoginSmartWallet?: () => void;
|
|
263
274
|
/** Create a new passkey + smart wallet (new user). */
|
|
264
275
|
onCreateSmartWallet?: () => void;
|
|
265
|
-
/** Optional override for the wallet picker view. Defaults to a Freighter+Albedo list. */
|
|
266
|
-
renderWallets?: RenderWalletsSlot;
|
|
267
276
|
authState: AuthState;
|
|
268
277
|
codeInputKey?: number;
|
|
269
278
|
onCodeSubmit?: (code: string) => void;
|
|
@@ -271,7 +280,7 @@ interface LoginModalTemplateProps {
|
|
|
271
280
|
onCancel: () => void;
|
|
272
281
|
onRetry: () => void;
|
|
273
282
|
}
|
|
274
|
-
declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, smartWallet, providers, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onWalletConnect, onLoginSmartWallet, onCreateSmartWallet,
|
|
283
|
+
declare function LoginModalTemplate({ theme, accentColor, logoUrl, emailEnabled, embeddedWallets, smartWallet, providers, walletAdapters, appName, email, onEmailChange, onEmailSubmit, onSocialLogin, onWalletConnect, onLoginSmartWallet, onCreateSmartWallet, authState, codeInputKey, onCodeSubmit, onBack, onCancel, onRetry, }: LoginModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
275
284
|
|
|
276
285
|
type KycStep = 'select_provider' | 'verifying' | 'polling' | 'done';
|
|
277
286
|
interface KycModalTemplateProps {
|
|
@@ -289,7 +298,7 @@ interface KycModalTemplateProps {
|
|
|
289
298
|
}
|
|
290
299
|
declare function KycModalTemplate({ theme, accentColor, step, providers, selectedProvider, session, kycStatus, isLoading, onSelectProvider, onDoneVerifying, onClose, }: KycModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
291
300
|
|
|
292
|
-
type RampStep = 'input' | 'loading_quote' | 'select_route' | '
|
|
301
|
+
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'status' | 'error';
|
|
293
302
|
interface RampWidgetTemplateProps {
|
|
294
303
|
theme: string;
|
|
295
304
|
accentColor: string;
|
|
@@ -299,18 +308,26 @@ interface RampWidgetTemplateProps {
|
|
|
299
308
|
currency: string;
|
|
300
309
|
country: string;
|
|
301
310
|
quotes: RampQuote[];
|
|
302
|
-
paymentInstructions: PaymentInstructions | null;
|
|
303
311
|
isLoading: boolean;
|
|
312
|
+
provider: string;
|
|
313
|
+
txStatus: RampTxStatus | null;
|
|
314
|
+
kycUrl: string | null;
|
|
315
|
+
stellarTxHash: string | null;
|
|
316
|
+
canComplete: boolean;
|
|
317
|
+
completing: boolean;
|
|
318
|
+
errorMsg: string | null;
|
|
304
319
|
onDirectionChange: (d: RampDirection) => void;
|
|
305
320
|
onAmountChange: (v: string) => void;
|
|
306
321
|
onCurrencyChange: (v: string) => void;
|
|
307
322
|
onCountryChange: (v: string) => void;
|
|
308
323
|
onFindRoute: () => void;
|
|
309
324
|
onSelectQuote: (q: RampQuote) => void;
|
|
310
|
-
|
|
325
|
+
onOpenKyc: () => void;
|
|
326
|
+
onCompleteWithdraw: () => void;
|
|
327
|
+
onRetry: () => void;
|
|
311
328
|
onClose: () => void;
|
|
312
329
|
}
|
|
313
|
-
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, quotes,
|
|
330
|
+
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, canComplete, completing, errorMsg, onDirectionChange, onAmountChange, onCurrencyChange, onCountryChange, onFindRoute, onSelectQuote, onOpenKyc, onCompleteWithdraw, onRetry, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
|
|
314
331
|
|
|
315
332
|
interface TransactionModalTemplateProps {
|
|
316
333
|
theme: string;
|
|
@@ -411,6 +428,53 @@ interface SendModalTemplateProps {
|
|
|
411
428
|
}
|
|
412
429
|
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
413
430
|
|
|
431
|
+
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
432
|
+
interface SwapAssetOption {
|
|
433
|
+
ref: SwapQuoteParams['sellAsset'];
|
|
434
|
+
code: string;
|
|
435
|
+
issuer?: string | undefined;
|
|
436
|
+
available?: string | undefined;
|
|
437
|
+
enabledInApp?: boolean | undefined;
|
|
438
|
+
}
|
|
439
|
+
interface SwapModalTemplateProps {
|
|
440
|
+
theme: string;
|
|
441
|
+
accentColor: string;
|
|
442
|
+
step: 'form' | 'tx';
|
|
443
|
+
txTitle: string;
|
|
444
|
+
sellOptions: SwapAssetOption[];
|
|
445
|
+
buyOptions: SwapAssetOption[];
|
|
446
|
+
selectedSell: SwapAssetOption | null;
|
|
447
|
+
selectedBuy: SwapAssetOption | null;
|
|
448
|
+
amount: string;
|
|
449
|
+
provider: SwapProvider;
|
|
450
|
+
providers: SwapProvider[];
|
|
451
|
+
quote: SwapQuote | null;
|
|
452
|
+
quoteLoading: boolean;
|
|
453
|
+
quoteError: string;
|
|
454
|
+
formError: string;
|
|
455
|
+
isLoadingData: boolean;
|
|
456
|
+
smartUnsupported: boolean;
|
|
457
|
+
transaction: TransactionState;
|
|
458
|
+
showXdr: boolean;
|
|
459
|
+
copied: boolean;
|
|
460
|
+
explorerUrl: string | null;
|
|
461
|
+
walletType?: WalletId | null | undefined;
|
|
462
|
+
showBack: boolean;
|
|
463
|
+
isInProgress: boolean;
|
|
464
|
+
onClose: () => void;
|
|
465
|
+
onBack: () => void;
|
|
466
|
+
onSelectSell: (o: SwapAssetOption) => void;
|
|
467
|
+
onSelectBuy: (o: SwapAssetOption) => void;
|
|
468
|
+
onAmountChange: (value: string) => void;
|
|
469
|
+
onProviderChange: (p: SwapProvider) => void;
|
|
470
|
+
onSwap: () => void;
|
|
471
|
+
onToggleXdr: () => void;
|
|
472
|
+
onCopyHash: () => void;
|
|
473
|
+
onRetry: () => void;
|
|
474
|
+
onDone: () => void;
|
|
475
|
+
}
|
|
476
|
+
declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOptions, buyOptions, selectedSell, selectedBuy, amount, provider, providers, quote, quoteLoading, quoteError, formError, isLoadingData, smartUnsupported, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onSelectSell, onSelectBuy, onAmountChange, onProviderChange, onSwap, onToggleXdr, onCopyHash, onRetry, onDone, }: SwapModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
477
|
+
|
|
414
478
|
interface ReceiveModalTemplateProps {
|
|
415
479
|
theme: string;
|
|
416
480
|
accentColor: string;
|
|
@@ -447,4 +511,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
447
511
|
}
|
|
448
512
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
449
513
|
|
|
450
|
-
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type PollarConfig, PollarProvider, type PollarStyles, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps,
|
|
514
|
+
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, 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 SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, createPollarAdapterHook, usePollar };
|