@pollar/react 0.11.1-rc.3 → 0.11.1
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 +92 -28
- package/dist/index.css +173 -124
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +143 -14
- package/dist/index.d.ts +143 -14
- package/dist/index.js +308 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +306 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, WalletId, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
2
|
+
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, WalletId, WalletChain, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
3
3
|
export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
@@ -27,6 +27,13 @@ interface PollarContextValue {
|
|
|
27
27
|
* on-chain address and `wallet.provider` for the wallet/login provider.
|
|
28
28
|
*/
|
|
29
29
|
wallet: WalletInfo | null;
|
|
30
|
+
/**
|
|
31
|
+
* Every wallet the user holds, one per chain — a superset of {@link wallet},
|
|
32
|
+
* with `chain` populated. `[]` when unauthenticated. Drives the network
|
|
33
|
+
* selector in the Send / Wallet Balance / Assets modals: each entry is a
|
|
34
|
+
* network the user can switch to, and the first one is the default.
|
|
35
|
+
*/
|
|
36
|
+
wallets: WalletInfo[];
|
|
30
37
|
getClient: () => PollarClient;
|
|
31
38
|
openLoginModal: () => void;
|
|
32
39
|
isAuthenticated: boolean;
|
|
@@ -63,6 +70,12 @@ interface PollarContextValue {
|
|
|
63
70
|
buildAndSignAndSubmitTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
64
71
|
/** Alias of `buildAndSignAndSubmitTx`. */
|
|
65
72
|
runTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
73
|
+
/**
|
|
74
|
+
* Send a payment on any chain the user holds a wallet on. Stellar keeps the
|
|
75
|
+
* split flow (so external adapters and passkeys still work); a chain whose
|
|
76
|
+
* signature expires goes through one server-side call and is custodial-only.
|
|
77
|
+
*/
|
|
78
|
+
sendPayment: (params: SendPaymentParams) => Promise<SubmitOutcome>;
|
|
66
79
|
network: StellarNetwork;
|
|
67
80
|
setNetwork: (network: StellarNetwork) => void;
|
|
68
81
|
walletBalance: WalletBalanceState;
|
|
@@ -76,16 +89,17 @@ interface PollarContextValue {
|
|
|
76
89
|
refreshAssets: () => Promise<void>;
|
|
77
90
|
/**
|
|
78
91
|
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an
|
|
79
|
-
* asset.
|
|
80
|
-
*
|
|
81
|
-
* {@link PollarClient.setTrustline}.
|
|
92
|
+
* asset. Sponsorship is derived automatically from the app's dashboard config
|
|
93
|
+
* (the app covers the reserve + fee when eligible); pass `skipSponsorship` to
|
|
94
|
+
* force the user's own wallet to pay. Mirrors {@link PollarClient.setTrustline}.
|
|
82
95
|
*/
|
|
83
96
|
setTrustline: (asset: {
|
|
84
97
|
code: string;
|
|
85
98
|
issuer: string;
|
|
86
99
|
}, opts?: {
|
|
87
100
|
limit?: string;
|
|
88
|
-
|
|
101
|
+
/** Force self-pay even when the app would sponsor the trustline. */
|
|
102
|
+
skipSponsorship?: boolean;
|
|
89
103
|
}) => Promise<TrustlineOutcome>;
|
|
90
104
|
/** Open the enabled-assets / trustline-state modal. */
|
|
91
105
|
openEnabledAssetsModal: () => void;
|
|
@@ -165,10 +179,29 @@ interface PollarProviderProps {
|
|
|
165
179
|
*/
|
|
166
180
|
client: PollarClient | PollarClientConfig;
|
|
167
181
|
/**
|
|
168
|
-
* Local
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
182
|
+
* Local REPLACEMENT for the `/applications/config` response, not a patch over
|
|
183
|
+
* it. Passing anything at all skips the remote fetch entirely; what you pass
|
|
184
|
+
* is used verbatim and is never merged with the server's answer, so there is
|
|
185
|
+
* no "fill in the fields I left out".
|
|
186
|
+
*
|
|
187
|
+
* `styles` may be partial (every field in it is optional), but `application`
|
|
188
|
+
* may not: `name`, `network` and `chains` are all required by the type. If you
|
|
189
|
+
* bypass the type anyway (plain JS, or a cast), each missing field lands on a
|
|
190
|
+
* default scattered across the components rather than on anything central:
|
|
191
|
+
*
|
|
192
|
+
* chains absent → the chain order/filter falls back to the order the
|
|
193
|
+
* session listed the user's wallets in (see useChains)
|
|
194
|
+
* name absent → 'Pollar'
|
|
195
|
+
* theme absent → 'light'
|
|
196
|
+
* accentColor absent → '#005DB4'
|
|
197
|
+
* emailEnabled, providers, embeddedWallets, smartWallet
|
|
198
|
+
* absent → false. NOTE: that means EVERY login method is off
|
|
199
|
+
* and the login modal renders with no way in.
|
|
200
|
+
*
|
|
201
|
+
* Leave this `undefined` to have the SDK fetch `/applications/config` on
|
|
202
|
+
* mount, which is also what keeps branding, login methods and chains current:
|
|
203
|
+
* that fetch re-runs on every mount, so dashboard changes land on the next
|
|
204
|
+
* page load. Supplying this prop opts out of that too.
|
|
172
205
|
*/
|
|
173
206
|
appConfig?: PollarConfig;
|
|
174
207
|
adapters?: PollarAdapters;
|
|
@@ -224,6 +257,64 @@ interface WalletButtonTemplateProps {
|
|
|
224
257
|
}
|
|
225
258
|
declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
|
|
226
259
|
|
|
260
|
+
/**
|
|
261
|
+
* The chain a record lives on, with the legacy shape folded in: sessions and
|
|
262
|
+
* balance rows minted before multi-chain carry no `chain` and are Stellar by
|
|
263
|
+
* definition, so absent counts as STELLAR rather than as "unknown".
|
|
264
|
+
*/
|
|
265
|
+
declare function resolveChain(chain: WalletChain | undefined): WalletChain;
|
|
266
|
+
/**
|
|
267
|
+
* The selectable chains — the first is the default everywhere (network picker,
|
|
268
|
+
* the address the wallet button shows). De-duplicated because two wallets on one
|
|
269
|
+
* chain (e.g. a custodial and a linked external Stellar wallet) are still one
|
|
270
|
+
* network choice.
|
|
271
|
+
*
|
|
272
|
+
* `order` is the app's chain list from `/applications/config`, as arranged in the
|
|
273
|
+
* dashboard. When passed it both ORDERS and FILTERS: a chain missing from it is
|
|
274
|
+
* dropped, because the app switched it off and must stop appearing everywhere.
|
|
275
|
+
*
|
|
276
|
+
* Filtering here and not only in the backend is deliberate. `wallets` comes from
|
|
277
|
+
* the session, which is written at login and then persisted for as long as the
|
|
278
|
+
* session lives; `/config` is refetched on every page load. So a chain disabled
|
|
279
|
+
* today disappears on the next reload even for a user who logged in last week
|
|
280
|
+
* and still carries it in their stored session.
|
|
281
|
+
*
|
|
282
|
+
* Without `order` (config still loading) the fallback is the order the backend
|
|
283
|
+
* listed the wallets in.
|
|
284
|
+
*/
|
|
285
|
+
declare function chainsOf(wallets: WalletInfo[], order?: readonly WalletChain[]): WalletChain[];
|
|
286
|
+
/** The address to show for `chain`, or '' when the user has no wallet there. */
|
|
287
|
+
declare function addressForChain(wallets: WalletInfo[], chain: WalletChain | null): string;
|
|
288
|
+
interface ChainSelectProps {
|
|
289
|
+
label?: string;
|
|
290
|
+
value: WalletChain | null;
|
|
291
|
+
options: WalletChain[];
|
|
292
|
+
onChange: (chain: WalletChain) => void;
|
|
293
|
+
disabled?: boolean;
|
|
294
|
+
}
|
|
295
|
+
declare function ChainSelect({ label, value, options, onChange, disabled }: ChainSelectProps): react_jsx_runtime.JSX.Element | null;
|
|
296
|
+
|
|
297
|
+
interface UseChainsResult {
|
|
298
|
+
/**
|
|
299
|
+
* Chains to offer, in the app's configured order: those the app serves AND the
|
|
300
|
+
* user already holds a wallet on. `[]` until `/config` resolves, so a network
|
|
301
|
+
* picker driven by this renders nothing rather than a list it may have to
|
|
302
|
+
* reorder a moment later.
|
|
303
|
+
*/
|
|
304
|
+
chains: WalletChain[];
|
|
305
|
+
/** The app's first configured chain that the user holds. `null` until ready. */
|
|
306
|
+
primaryChain: WalletChain | null;
|
|
307
|
+
/**
|
|
308
|
+
* The address on {@link primaryChain}. While `/config` is still in flight this
|
|
309
|
+
* falls back to the first wallet the session lists, so a logged-in user never
|
|
310
|
+
* sees the wallet button blank out into a "Connect" state on every reload.
|
|
311
|
+
*/
|
|
312
|
+
primaryAddress: string;
|
|
313
|
+
/** `false` while `/config` is in flight or failed. Gate any chain UI on it. */
|
|
314
|
+
ready: boolean;
|
|
315
|
+
}
|
|
316
|
+
declare function useChains(): UseChainsResult;
|
|
317
|
+
|
|
227
318
|
interface KycModalProps {
|
|
228
319
|
onClose: () => void;
|
|
229
320
|
/** ISO 3166-1 alpha-2 country code to filter providers. Defaults to 'MX'. */
|
|
@@ -455,17 +546,29 @@ interface WalletBalanceModalTemplateProps {
|
|
|
455
546
|
theme: string;
|
|
456
547
|
accentColor: string;
|
|
457
548
|
walletBalance: WalletBalanceState;
|
|
549
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
458
550
|
walletAddress: string;
|
|
551
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
552
|
+
chains: WalletChain[];
|
|
553
|
+
selectedChain: WalletChain | null;
|
|
554
|
+
/** testnet vs mainnet — gates the Solana devnet faucet hint. */
|
|
555
|
+
network: StellarNetwork;
|
|
556
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
459
557
|
onRefresh: () => void;
|
|
460
558
|
onClose: () => void;
|
|
461
559
|
}
|
|
462
|
-
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
560
|
+
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, chains, selectedChain, network, onSelectChain, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
463
561
|
|
|
464
562
|
interface EnabledAssetsModalTemplateProps {
|
|
465
563
|
theme: string;
|
|
466
564
|
accentColor: string;
|
|
467
565
|
enabledAssets: EnabledAssetsState;
|
|
566
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
468
567
|
walletAddress: string;
|
|
568
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
569
|
+
chains: WalletChain[];
|
|
570
|
+
selectedChain: WalletChain | null;
|
|
571
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
469
572
|
/** Key (`code+issuer`) of the asset whose trustline action is in flight. */
|
|
470
573
|
busyKey: string | null;
|
|
471
574
|
actionError: string | null;
|
|
@@ -474,7 +577,20 @@ interface EnabledAssetsModalTemplateProps {
|
|
|
474
577
|
onToggleTrustline: (record: EnabledAssetRecord) => void;
|
|
475
578
|
onAddCustom: () => void;
|
|
476
579
|
}
|
|
477
|
-
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
580
|
+
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, chains, selectedChain, onSelectChain, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
581
|
+
interface CustomTrustlineModalTemplateProps {
|
|
582
|
+
theme: string;
|
|
583
|
+
accentColor: string;
|
|
584
|
+
busy: boolean;
|
|
585
|
+
actionError: string | null;
|
|
586
|
+
onBack: () => void;
|
|
587
|
+
onClose: () => void;
|
|
588
|
+
onSubmit: (input: {
|
|
589
|
+
code: string;
|
|
590
|
+
issuer: string;
|
|
591
|
+
limit?: string;
|
|
592
|
+
}) => void;
|
|
593
|
+
}
|
|
478
594
|
|
|
479
595
|
interface SendModalTemplateProps {
|
|
480
596
|
theme: string;
|
|
@@ -483,6 +599,14 @@ interface SendModalTemplateProps {
|
|
|
483
599
|
txTitle: string;
|
|
484
600
|
assets: WalletBalanceRecord[];
|
|
485
601
|
selectedAsset: WalletBalanceRecord | null;
|
|
602
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
603
|
+
chains: WalletChain[];
|
|
604
|
+
selectedChain: WalletChain | null;
|
|
605
|
+
/** Address of the wallet on {@link selectedChain}, shown under the picker. */
|
|
606
|
+
walletAddress: string;
|
|
607
|
+
/** Can a payment be built on {@link selectedChain}? Stellar and Solana only. */
|
|
608
|
+
canSendOnChain: boolean;
|
|
609
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
486
610
|
amount: string;
|
|
487
611
|
destination: string;
|
|
488
612
|
formError: string;
|
|
@@ -507,7 +631,7 @@ interface SendModalTemplateProps {
|
|
|
507
631
|
onRetry: () => void;
|
|
508
632
|
onDone: () => void;
|
|
509
633
|
}
|
|
510
|
-
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onRefresh, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
634
|
+
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, chains, selectedChain, walletAddress, canSendOnChain, onSelectChain, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onRefresh, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
511
635
|
|
|
512
636
|
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
513
637
|
interface SwapAssetOption {
|
|
@@ -568,12 +692,17 @@ declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOpti
|
|
|
568
692
|
interface ReceiveModalTemplateProps {
|
|
569
693
|
theme: string;
|
|
570
694
|
accentColor: string;
|
|
695
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
571
696
|
walletAddress: string;
|
|
697
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
698
|
+
chains: WalletChain[];
|
|
699
|
+
selectedChain: WalletChain | null;
|
|
700
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
572
701
|
copied: boolean;
|
|
573
702
|
onCopy: () => void;
|
|
574
703
|
onClose: () => void;
|
|
575
704
|
}
|
|
576
|
-
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
705
|
+
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, chains, selectedChain, onSelectChain, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
577
706
|
|
|
578
707
|
interface SessionsModalTemplateProps {
|
|
579
708
|
theme: string;
|
|
@@ -601,4 +730,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
601
730
|
}
|
|
602
731
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
603
732
|
|
|
604
|
-
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, 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 };
|
|
733
|
+
export { type AuthModalProps, ChainSelect, type ChainSelectProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, 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, type UseChainsResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, chainsOf, createPollarAdapterHook, resolveChain, useChains, usePollar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, WalletId, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
2
|
+
import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, WalletId, WalletChain, KycStatus as KycStatus$1, RampQuote, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampTxStatus, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
|
|
3
3
|
export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
@@ -27,6 +27,13 @@ interface PollarContextValue {
|
|
|
27
27
|
* on-chain address and `wallet.provider` for the wallet/login provider.
|
|
28
28
|
*/
|
|
29
29
|
wallet: WalletInfo | null;
|
|
30
|
+
/**
|
|
31
|
+
* Every wallet the user holds, one per chain — a superset of {@link wallet},
|
|
32
|
+
* with `chain` populated. `[]` when unauthenticated. Drives the network
|
|
33
|
+
* selector in the Send / Wallet Balance / Assets modals: each entry is a
|
|
34
|
+
* network the user can switch to, and the first one is the default.
|
|
35
|
+
*/
|
|
36
|
+
wallets: WalletInfo[];
|
|
30
37
|
getClient: () => PollarClient;
|
|
31
38
|
openLoginModal: () => void;
|
|
32
39
|
isAuthenticated: boolean;
|
|
@@ -63,6 +70,12 @@ interface PollarContextValue {
|
|
|
63
70
|
buildAndSignAndSubmitTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
64
71
|
/** Alias of `buildAndSignAndSubmitTx`. */
|
|
65
72
|
runTx: (operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']) => Promise<SubmitOutcome>;
|
|
73
|
+
/**
|
|
74
|
+
* Send a payment on any chain the user holds a wallet on. Stellar keeps the
|
|
75
|
+
* split flow (so external adapters and passkeys still work); a chain whose
|
|
76
|
+
* signature expires goes through one server-side call and is custodial-only.
|
|
77
|
+
*/
|
|
78
|
+
sendPayment: (params: SendPaymentParams) => Promise<SubmitOutcome>;
|
|
66
79
|
network: StellarNetwork;
|
|
67
80
|
setNetwork: (network: StellarNetwork) => void;
|
|
68
81
|
walletBalance: WalletBalanceState;
|
|
@@ -76,16 +89,17 @@ interface PollarContextValue {
|
|
|
76
89
|
refreshAssets: () => Promise<void>;
|
|
77
90
|
/**
|
|
78
91
|
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an
|
|
79
|
-
* asset.
|
|
80
|
-
*
|
|
81
|
-
* {@link PollarClient.setTrustline}.
|
|
92
|
+
* asset. Sponsorship is derived automatically from the app's dashboard config
|
|
93
|
+
* (the app covers the reserve + fee when eligible); pass `skipSponsorship` to
|
|
94
|
+
* force the user's own wallet to pay. Mirrors {@link PollarClient.setTrustline}.
|
|
82
95
|
*/
|
|
83
96
|
setTrustline: (asset: {
|
|
84
97
|
code: string;
|
|
85
98
|
issuer: string;
|
|
86
99
|
}, opts?: {
|
|
87
100
|
limit?: string;
|
|
88
|
-
|
|
101
|
+
/** Force self-pay even when the app would sponsor the trustline. */
|
|
102
|
+
skipSponsorship?: boolean;
|
|
89
103
|
}) => Promise<TrustlineOutcome>;
|
|
90
104
|
/** Open the enabled-assets / trustline-state modal. */
|
|
91
105
|
openEnabledAssetsModal: () => void;
|
|
@@ -165,10 +179,29 @@ interface PollarProviderProps {
|
|
|
165
179
|
*/
|
|
166
180
|
client: PollarClient | PollarClientConfig;
|
|
167
181
|
/**
|
|
168
|
-
* Local
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
182
|
+
* Local REPLACEMENT for the `/applications/config` response, not a patch over
|
|
183
|
+
* it. Passing anything at all skips the remote fetch entirely; what you pass
|
|
184
|
+
* is used verbatim and is never merged with the server's answer, so there is
|
|
185
|
+
* no "fill in the fields I left out".
|
|
186
|
+
*
|
|
187
|
+
* `styles` may be partial (every field in it is optional), but `application`
|
|
188
|
+
* may not: `name`, `network` and `chains` are all required by the type. If you
|
|
189
|
+
* bypass the type anyway (plain JS, or a cast), each missing field lands on a
|
|
190
|
+
* default scattered across the components rather than on anything central:
|
|
191
|
+
*
|
|
192
|
+
* chains absent → the chain order/filter falls back to the order the
|
|
193
|
+
* session listed the user's wallets in (see useChains)
|
|
194
|
+
* name absent → 'Pollar'
|
|
195
|
+
* theme absent → 'light'
|
|
196
|
+
* accentColor absent → '#005DB4'
|
|
197
|
+
* emailEnabled, providers, embeddedWallets, smartWallet
|
|
198
|
+
* absent → false. NOTE: that means EVERY login method is off
|
|
199
|
+
* and the login modal renders with no way in.
|
|
200
|
+
*
|
|
201
|
+
* Leave this `undefined` to have the SDK fetch `/applications/config` on
|
|
202
|
+
* mount, which is also what keeps branding, login methods and chains current:
|
|
203
|
+
* that fetch re-runs on every mount, so dashboard changes land on the next
|
|
204
|
+
* page load. Supplying this prop opts out of that too.
|
|
172
205
|
*/
|
|
173
206
|
appConfig?: PollarConfig;
|
|
174
207
|
adapters?: PollarAdapters;
|
|
@@ -224,6 +257,64 @@ interface WalletButtonTemplateProps {
|
|
|
224
257
|
}
|
|
225
258
|
declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
|
|
226
259
|
|
|
260
|
+
/**
|
|
261
|
+
* The chain a record lives on, with the legacy shape folded in: sessions and
|
|
262
|
+
* balance rows minted before multi-chain carry no `chain` and are Stellar by
|
|
263
|
+
* definition, so absent counts as STELLAR rather than as "unknown".
|
|
264
|
+
*/
|
|
265
|
+
declare function resolveChain(chain: WalletChain | undefined): WalletChain;
|
|
266
|
+
/**
|
|
267
|
+
* The selectable chains — the first is the default everywhere (network picker,
|
|
268
|
+
* the address the wallet button shows). De-duplicated because two wallets on one
|
|
269
|
+
* chain (e.g. a custodial and a linked external Stellar wallet) are still one
|
|
270
|
+
* network choice.
|
|
271
|
+
*
|
|
272
|
+
* `order` is the app's chain list from `/applications/config`, as arranged in the
|
|
273
|
+
* dashboard. When passed it both ORDERS and FILTERS: a chain missing from it is
|
|
274
|
+
* dropped, because the app switched it off and must stop appearing everywhere.
|
|
275
|
+
*
|
|
276
|
+
* Filtering here and not only in the backend is deliberate. `wallets` comes from
|
|
277
|
+
* the session, which is written at login and then persisted for as long as the
|
|
278
|
+
* session lives; `/config` is refetched on every page load. So a chain disabled
|
|
279
|
+
* today disappears on the next reload even for a user who logged in last week
|
|
280
|
+
* and still carries it in their stored session.
|
|
281
|
+
*
|
|
282
|
+
* Without `order` (config still loading) the fallback is the order the backend
|
|
283
|
+
* listed the wallets in.
|
|
284
|
+
*/
|
|
285
|
+
declare function chainsOf(wallets: WalletInfo[], order?: readonly WalletChain[]): WalletChain[];
|
|
286
|
+
/** The address to show for `chain`, or '' when the user has no wallet there. */
|
|
287
|
+
declare function addressForChain(wallets: WalletInfo[], chain: WalletChain | null): string;
|
|
288
|
+
interface ChainSelectProps {
|
|
289
|
+
label?: string;
|
|
290
|
+
value: WalletChain | null;
|
|
291
|
+
options: WalletChain[];
|
|
292
|
+
onChange: (chain: WalletChain) => void;
|
|
293
|
+
disabled?: boolean;
|
|
294
|
+
}
|
|
295
|
+
declare function ChainSelect({ label, value, options, onChange, disabled }: ChainSelectProps): react_jsx_runtime.JSX.Element | null;
|
|
296
|
+
|
|
297
|
+
interface UseChainsResult {
|
|
298
|
+
/**
|
|
299
|
+
* Chains to offer, in the app's configured order: those the app serves AND the
|
|
300
|
+
* user already holds a wallet on. `[]` until `/config` resolves, so a network
|
|
301
|
+
* picker driven by this renders nothing rather than a list it may have to
|
|
302
|
+
* reorder a moment later.
|
|
303
|
+
*/
|
|
304
|
+
chains: WalletChain[];
|
|
305
|
+
/** The app's first configured chain that the user holds. `null` until ready. */
|
|
306
|
+
primaryChain: WalletChain | null;
|
|
307
|
+
/**
|
|
308
|
+
* The address on {@link primaryChain}. While `/config` is still in flight this
|
|
309
|
+
* falls back to the first wallet the session lists, so a logged-in user never
|
|
310
|
+
* sees the wallet button blank out into a "Connect" state on every reload.
|
|
311
|
+
*/
|
|
312
|
+
primaryAddress: string;
|
|
313
|
+
/** `false` while `/config` is in flight or failed. Gate any chain UI on it. */
|
|
314
|
+
ready: boolean;
|
|
315
|
+
}
|
|
316
|
+
declare function useChains(): UseChainsResult;
|
|
317
|
+
|
|
227
318
|
interface KycModalProps {
|
|
228
319
|
onClose: () => void;
|
|
229
320
|
/** ISO 3166-1 alpha-2 country code to filter providers. Defaults to 'MX'. */
|
|
@@ -455,17 +546,29 @@ interface WalletBalanceModalTemplateProps {
|
|
|
455
546
|
theme: string;
|
|
456
547
|
accentColor: string;
|
|
457
548
|
walletBalance: WalletBalanceState;
|
|
549
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
458
550
|
walletAddress: string;
|
|
551
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
552
|
+
chains: WalletChain[];
|
|
553
|
+
selectedChain: WalletChain | null;
|
|
554
|
+
/** testnet vs mainnet — gates the Solana devnet faucet hint. */
|
|
555
|
+
network: StellarNetwork;
|
|
556
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
459
557
|
onRefresh: () => void;
|
|
460
558
|
onClose: () => void;
|
|
461
559
|
}
|
|
462
|
-
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
560
|
+
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, chains, selectedChain, network, onSelectChain, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
463
561
|
|
|
464
562
|
interface EnabledAssetsModalTemplateProps {
|
|
465
563
|
theme: string;
|
|
466
564
|
accentColor: string;
|
|
467
565
|
enabledAssets: EnabledAssetsState;
|
|
566
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
468
567
|
walletAddress: string;
|
|
568
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
569
|
+
chains: WalletChain[];
|
|
570
|
+
selectedChain: WalletChain | null;
|
|
571
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
469
572
|
/** Key (`code+issuer`) of the asset whose trustline action is in flight. */
|
|
470
573
|
busyKey: string | null;
|
|
471
574
|
actionError: string | null;
|
|
@@ -474,7 +577,20 @@ interface EnabledAssetsModalTemplateProps {
|
|
|
474
577
|
onToggleTrustline: (record: EnabledAssetRecord) => void;
|
|
475
578
|
onAddCustom: () => void;
|
|
476
579
|
}
|
|
477
|
-
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
580
|
+
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, chains, selectedChain, onSelectChain, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
581
|
+
interface CustomTrustlineModalTemplateProps {
|
|
582
|
+
theme: string;
|
|
583
|
+
accentColor: string;
|
|
584
|
+
busy: boolean;
|
|
585
|
+
actionError: string | null;
|
|
586
|
+
onBack: () => void;
|
|
587
|
+
onClose: () => void;
|
|
588
|
+
onSubmit: (input: {
|
|
589
|
+
code: string;
|
|
590
|
+
issuer: string;
|
|
591
|
+
limit?: string;
|
|
592
|
+
}) => void;
|
|
593
|
+
}
|
|
478
594
|
|
|
479
595
|
interface SendModalTemplateProps {
|
|
480
596
|
theme: string;
|
|
@@ -483,6 +599,14 @@ interface SendModalTemplateProps {
|
|
|
483
599
|
txTitle: string;
|
|
484
600
|
assets: WalletBalanceRecord[];
|
|
485
601
|
selectedAsset: WalletBalanceRecord | null;
|
|
602
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
603
|
+
chains: WalletChain[];
|
|
604
|
+
selectedChain: WalletChain | null;
|
|
605
|
+
/** Address of the wallet on {@link selectedChain}, shown under the picker. */
|
|
606
|
+
walletAddress: string;
|
|
607
|
+
/** Can a payment be built on {@link selectedChain}? Stellar and Solana only. */
|
|
608
|
+
canSendOnChain: boolean;
|
|
609
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
486
610
|
amount: string;
|
|
487
611
|
destination: string;
|
|
488
612
|
formError: string;
|
|
@@ -507,7 +631,7 @@ interface SendModalTemplateProps {
|
|
|
507
631
|
onRetry: () => void;
|
|
508
632
|
onDone: () => void;
|
|
509
633
|
}
|
|
510
|
-
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onRefresh, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
634
|
+
declare function SendModalTemplate({ theme, accentColor, step, txTitle, assets, selectedAsset, chains, selectedChain, walletAddress, canSendOnChain, onSelectChain, amount, destination, formError, isLoadingBalance, transaction, showXdr, copied, explorerUrl, walletType, showBack, isInProgress, onClose, onBack, onRefresh, onSelectAsset, onAmountChange, onDestinationChange, onSubmit, onSignAndSend, onToggleXdr, onCopyHash, onRetry, onDone, }: SendModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
511
635
|
|
|
512
636
|
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
513
637
|
interface SwapAssetOption {
|
|
@@ -568,12 +692,17 @@ declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOpti
|
|
|
568
692
|
interface ReceiveModalTemplateProps {
|
|
569
693
|
theme: string;
|
|
570
694
|
accentColor: string;
|
|
695
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
571
696
|
walletAddress: string;
|
|
697
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
698
|
+
chains: WalletChain[];
|
|
699
|
+
selectedChain: WalletChain | null;
|
|
700
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
572
701
|
copied: boolean;
|
|
573
702
|
onCopy: () => void;
|
|
574
703
|
onClose: () => void;
|
|
575
704
|
}
|
|
576
|
-
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
705
|
+
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, chains, selectedChain, onSelectChain, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
577
706
|
|
|
578
707
|
interface SessionsModalTemplateProps {
|
|
579
708
|
theme: string;
|
|
@@ -601,4 +730,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
601
730
|
}
|
|
602
731
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
603
732
|
|
|
604
|
-
export { type AuthModalProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, 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 };
|
|
733
|
+
export { type AuthModalProps, ChainSelect, type ChainSelectProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, 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, type UseChainsResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, chainsOf, createPollarAdapterHook, resolveChain, useChains, usePollar };
|