@pollar/react 0.11.1-rc.3 → 0.11.2
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 +103 -33
- package/dist/index.css +173 -124
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +150 -15
- package/dist/index.d.ts +150 -15
- package/dist/index.js +366 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +364 -97
- 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'. */
|
|
@@ -444,28 +535,46 @@ interface TxHistoryModalTemplateProps {
|
|
|
444
535
|
accentColor: string;
|
|
445
536
|
txHistory: TxHistoryState;
|
|
446
537
|
offset: number;
|
|
538
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
539
|
+
chains: WalletChain[];
|
|
540
|
+
selectedChain: WalletChain | null;
|
|
541
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
542
|
+
walletAddress: string;
|
|
543
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
447
544
|
onRefresh: () => void;
|
|
448
545
|
onPrev: () => void;
|
|
449
546
|
onNext: () => void;
|
|
450
547
|
onClose: () => void;
|
|
451
548
|
}
|
|
452
|
-
declare function TxHistoryModalTemplate({ theme, accentColor, txHistory, offset, onRefresh, onPrev, onNext, onClose, }: TxHistoryModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
declare function TxHistoryModalTemplate({ theme, accentColor, txHistory, offset, chains, selectedChain, walletAddress, onSelectChain, onRefresh, onPrev, onNext, onClose, }: TxHistoryModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
453
550
|
|
|
454
551
|
interface WalletBalanceModalTemplateProps {
|
|
455
552
|
theme: string;
|
|
456
553
|
accentColor: string;
|
|
457
554
|
walletBalance: WalletBalanceState;
|
|
555
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
458
556
|
walletAddress: string;
|
|
557
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
558
|
+
chains: WalletChain[];
|
|
559
|
+
selectedChain: WalletChain | null;
|
|
560
|
+
/** testnet vs mainnet — gates the Solana devnet faucet hint. */
|
|
561
|
+
network: StellarNetwork;
|
|
562
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
459
563
|
onRefresh: () => void;
|
|
460
564
|
onClose: () => void;
|
|
461
565
|
}
|
|
462
|
-
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
566
|
+
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, chains, selectedChain, network, onSelectChain, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
463
567
|
|
|
464
568
|
interface EnabledAssetsModalTemplateProps {
|
|
465
569
|
theme: string;
|
|
466
570
|
accentColor: string;
|
|
467
571
|
enabledAssets: EnabledAssetsState;
|
|
572
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
468
573
|
walletAddress: string;
|
|
574
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
575
|
+
chains: WalletChain[];
|
|
576
|
+
selectedChain: WalletChain | null;
|
|
577
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
469
578
|
/** Key (`code+issuer`) of the asset whose trustline action is in flight. */
|
|
470
579
|
busyKey: string | null;
|
|
471
580
|
actionError: string | null;
|
|
@@ -474,7 +583,20 @@ interface EnabledAssetsModalTemplateProps {
|
|
|
474
583
|
onToggleTrustline: (record: EnabledAssetRecord) => void;
|
|
475
584
|
onAddCustom: () => void;
|
|
476
585
|
}
|
|
477
|
-
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
586
|
+
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, chains, selectedChain, onSelectChain, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
587
|
+
interface CustomTrustlineModalTemplateProps {
|
|
588
|
+
theme: string;
|
|
589
|
+
accentColor: string;
|
|
590
|
+
busy: boolean;
|
|
591
|
+
actionError: string | null;
|
|
592
|
+
onBack: () => void;
|
|
593
|
+
onClose: () => void;
|
|
594
|
+
onSubmit: (input: {
|
|
595
|
+
code: string;
|
|
596
|
+
issuer: string;
|
|
597
|
+
limit?: string;
|
|
598
|
+
}) => void;
|
|
599
|
+
}
|
|
478
600
|
|
|
479
601
|
interface SendModalTemplateProps {
|
|
480
602
|
theme: string;
|
|
@@ -483,6 +605,14 @@ interface SendModalTemplateProps {
|
|
|
483
605
|
txTitle: string;
|
|
484
606
|
assets: WalletBalanceRecord[];
|
|
485
607
|
selectedAsset: WalletBalanceRecord | null;
|
|
608
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
609
|
+
chains: WalletChain[];
|
|
610
|
+
selectedChain: WalletChain | null;
|
|
611
|
+
/** Address of the wallet on {@link selectedChain}, shown under the picker. */
|
|
612
|
+
walletAddress: string;
|
|
613
|
+
/** Can a payment be built on {@link selectedChain}? Stellar and Solana only. */
|
|
614
|
+
canSendOnChain: boolean;
|
|
615
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
486
616
|
amount: string;
|
|
487
617
|
destination: string;
|
|
488
618
|
formError: string;
|
|
@@ -507,7 +637,7 @@ interface SendModalTemplateProps {
|
|
|
507
637
|
onRetry: () => void;
|
|
508
638
|
onDone: () => void;
|
|
509
639
|
}
|
|
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;
|
|
640
|
+
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
641
|
|
|
512
642
|
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
513
643
|
interface SwapAssetOption {
|
|
@@ -568,12 +698,17 @@ declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOpti
|
|
|
568
698
|
interface ReceiveModalTemplateProps {
|
|
569
699
|
theme: string;
|
|
570
700
|
accentColor: string;
|
|
701
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
571
702
|
walletAddress: string;
|
|
703
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
704
|
+
chains: WalletChain[];
|
|
705
|
+
selectedChain: WalletChain | null;
|
|
706
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
572
707
|
copied: boolean;
|
|
573
708
|
onCopy: () => void;
|
|
574
709
|
onClose: () => void;
|
|
575
710
|
}
|
|
576
|
-
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
711
|
+
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, chains, selectedChain, onSelectChain, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
577
712
|
|
|
578
713
|
interface SessionsModalTemplateProps {
|
|
579
714
|
theme: string;
|
|
@@ -601,4 +736,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
601
736
|
}
|
|
602
737
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
603
738
|
|
|
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 };
|
|
739
|
+
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'. */
|
|
@@ -444,28 +535,46 @@ interface TxHistoryModalTemplateProps {
|
|
|
444
535
|
accentColor: string;
|
|
445
536
|
txHistory: TxHistoryState;
|
|
446
537
|
offset: number;
|
|
538
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
539
|
+
chains: WalletChain[];
|
|
540
|
+
selectedChain: WalletChain | null;
|
|
541
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
542
|
+
walletAddress: string;
|
|
543
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
447
544
|
onRefresh: () => void;
|
|
448
545
|
onPrev: () => void;
|
|
449
546
|
onNext: () => void;
|
|
450
547
|
onClose: () => void;
|
|
451
548
|
}
|
|
452
|
-
declare function TxHistoryModalTemplate({ theme, accentColor, txHistory, offset, onRefresh, onPrev, onNext, onClose, }: TxHistoryModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
declare function TxHistoryModalTemplate({ theme, accentColor, txHistory, offset, chains, selectedChain, walletAddress, onSelectChain, onRefresh, onPrev, onNext, onClose, }: TxHistoryModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
453
550
|
|
|
454
551
|
interface WalletBalanceModalTemplateProps {
|
|
455
552
|
theme: string;
|
|
456
553
|
accentColor: string;
|
|
457
554
|
walletBalance: WalletBalanceState;
|
|
555
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
458
556
|
walletAddress: string;
|
|
557
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
558
|
+
chains: WalletChain[];
|
|
559
|
+
selectedChain: WalletChain | null;
|
|
560
|
+
/** testnet vs mainnet — gates the Solana devnet faucet hint. */
|
|
561
|
+
network: StellarNetwork;
|
|
562
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
459
563
|
onRefresh: () => void;
|
|
460
564
|
onClose: () => void;
|
|
461
565
|
}
|
|
462
|
-
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
566
|
+
declare function WalletBalanceModalTemplate({ theme, accentColor, walletBalance, walletAddress, chains, selectedChain, network, onSelectChain, onRefresh, onClose, }: WalletBalanceModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
463
567
|
|
|
464
568
|
interface EnabledAssetsModalTemplateProps {
|
|
465
569
|
theme: string;
|
|
466
570
|
accentColor: string;
|
|
467
571
|
enabledAssets: EnabledAssetsState;
|
|
572
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
468
573
|
walletAddress: string;
|
|
574
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
575
|
+
chains: WalletChain[];
|
|
576
|
+
selectedChain: WalletChain | null;
|
|
577
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
469
578
|
/** Key (`code+issuer`) of the asset whose trustline action is in flight. */
|
|
470
579
|
busyKey: string | null;
|
|
471
580
|
actionError: string | null;
|
|
@@ -474,7 +583,20 @@ interface EnabledAssetsModalTemplateProps {
|
|
|
474
583
|
onToggleTrustline: (record: EnabledAssetRecord) => void;
|
|
475
584
|
onAddCustom: () => void;
|
|
476
585
|
}
|
|
477
|
-
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
586
|
+
declare function EnabledAssetsModalTemplate({ theme, accentColor, enabledAssets, walletAddress, chains, selectedChain, onSelectChain, busyKey, actionError, onRefresh, onClose, onToggleTrustline, onAddCustom, }: EnabledAssetsModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
587
|
+
interface CustomTrustlineModalTemplateProps {
|
|
588
|
+
theme: string;
|
|
589
|
+
accentColor: string;
|
|
590
|
+
busy: boolean;
|
|
591
|
+
actionError: string | null;
|
|
592
|
+
onBack: () => void;
|
|
593
|
+
onClose: () => void;
|
|
594
|
+
onSubmit: (input: {
|
|
595
|
+
code: string;
|
|
596
|
+
issuer: string;
|
|
597
|
+
limit?: string;
|
|
598
|
+
}) => void;
|
|
599
|
+
}
|
|
478
600
|
|
|
479
601
|
interface SendModalTemplateProps {
|
|
480
602
|
theme: string;
|
|
@@ -483,6 +605,14 @@ interface SendModalTemplateProps {
|
|
|
483
605
|
txTitle: string;
|
|
484
606
|
assets: WalletBalanceRecord[];
|
|
485
607
|
selectedAsset: WalletBalanceRecord | null;
|
|
608
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
609
|
+
chains: WalletChain[];
|
|
610
|
+
selectedChain: WalletChain | null;
|
|
611
|
+
/** Address of the wallet on {@link selectedChain}, shown under the picker. */
|
|
612
|
+
walletAddress: string;
|
|
613
|
+
/** Can a payment be built on {@link selectedChain}? Stellar and Solana only. */
|
|
614
|
+
canSendOnChain: boolean;
|
|
615
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
486
616
|
amount: string;
|
|
487
617
|
destination: string;
|
|
488
618
|
formError: string;
|
|
@@ -507,7 +637,7 @@ interface SendModalTemplateProps {
|
|
|
507
637
|
onRetry: () => void;
|
|
508
638
|
onDone: () => void;
|
|
509
639
|
}
|
|
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;
|
|
640
|
+
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
641
|
|
|
512
642
|
/** A selectable asset in the sell/buy pickers, normalized across balance/enabled records. */
|
|
513
643
|
interface SwapAssetOption {
|
|
@@ -568,12 +698,17 @@ declare function SwapModalTemplate({ theme, accentColor, step, txTitle, sellOpti
|
|
|
568
698
|
interface ReceiveModalTemplateProps {
|
|
569
699
|
theme: string;
|
|
570
700
|
accentColor: string;
|
|
701
|
+
/** Address of the wallet on {@link selectedChain}. */
|
|
571
702
|
walletAddress: string;
|
|
703
|
+
/** Networks the user holds a wallet on; the first one is the default. */
|
|
704
|
+
chains: WalletChain[];
|
|
705
|
+
selectedChain: WalletChain | null;
|
|
706
|
+
onSelectChain: (chain: WalletChain) => void;
|
|
572
707
|
copied: boolean;
|
|
573
708
|
onCopy: () => void;
|
|
574
709
|
onClose: () => void;
|
|
575
710
|
}
|
|
576
|
-
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
711
|
+
declare function ReceiveModalTemplate({ theme, accentColor, walletAddress, chains, selectedChain, onSelectChain, copied, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
577
712
|
|
|
578
713
|
interface SessionsModalTemplateProps {
|
|
579
714
|
theme: string;
|
|
@@ -601,4 +736,4 @@ interface DistributionRulesModalTemplateProps {
|
|
|
601
736
|
}
|
|
602
737
|
declare function DistributionRulesModalTemplate({ theme, accentColor, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
603
738
|
|
|
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 };
|
|
739
|
+
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 };
|