@pollar/react 0.12.0 → 0.12.1-rc.5

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 CHANGED
@@ -1,95 +1,20 @@
1
1
  # @pollar/react
2
2
 
3
- React bindings for [Pollar](https://pollar.xyz) — drop-in authentication UI, transaction modals, and hooks for
3
+ React bindings for [Pollar](https://pollar.xyz) - drop-in authentication UI, transaction modals, and hooks for
4
4
  Stellar and Solana applications.
5
5
 
6
- > **0.12.0** (requires `@pollar/core@^0.12.0`). `<RampWidget>` runs on the v3 ramps API: routes, quotes leg by
7
- > leg, the fields a quote asks for, the order's progress and its pending action; it signs a leg with the connected
8
- > Stellar or Solana wallet only when the leg was built for it. **Wallets the user holds**: the wallet button lets the
9
- > user pick co-signed or self-custody when the app leaves it to them, `<RecoveryModal>` manages passkeys, email,
10
- > devices and the recovery phrase (`recoveryLocked`, `openRecoveryModal()`), and `<CustodyMigrationModal>` moves a
11
- > custodial wallet to Turnkey after login. `<SendModal>` offers to create a Stellar account that does not exist.
12
- > Branding yields to the host stylesheet, with `--pollar-font-family` and `--pollar-font-family-mono`;
13
- > `WalletButtonTemplateProps` takes `theme`, `accentColor` and `styleOverrides`. **Breaking**; see
14
- > [UPGRADE.md](../../UPGRADE.md).
6
+ > **0.12.1** (requires `@pollar/core@^0.12.1`). Every modal and exported template speaks English, Spanish and
7
+ > Portuguese (see [Language](#language)). `<SwapModal>` swaps on Solana too, with a Network selector when the app has
8
+ > venues on both chains. `<SendModal>` offers a Hash memo next to Text and ID. `<ConfirmModal>` shows a Soroban token
9
+ > transfer (`kind: 'sign_auth_entry'`) with its destination, amount and asset. `<RequirementFormModal>` asks a field
10
+ > with `showIf` only while the answer it depends on matches. `<CardModal>` copies the number, expiry date and CVC,
11
+ > offers a network picker when the user holds a wallet on Stellar and Solana, and funds the card from a co-signed
12
+ > wallet too. The email code input takes an autofilled one-time code. The ramp widget says a route's minimum or
13
+ > maximum and offers "Change amount", and an order whose price changed before anything moved offers "Get a new quote".
14
+ > A hook built with `createPollarAdapterHook` signs the auth entry an adapter answers with, without submitting
15
+ > anything, and hands it to the adapter's `complete`.
15
16
  >
16
- > Earlier: **0.11.5** (requires `@pollar/core@^0.11.5`).
17
- > **Turnkey co-signed wallets**: `<CosignModal>` opens for a request the device did not settle and enables
18
- > Approve only after it verifies against Turnkey; `useCosign()` exposes the pending requests.
19
- > `<ConfirmModal>` shows every signature first under `confirmation: 'prompt'`. The ramp widget links the
20
- > chain a ramp settles on and retries funds in transit; Send takes a Stellar memo (`SendMemoType`). See
21
- > [UPGRADE.md](../../UPGRADE.md).
22
- >
23
- > Earlier: **0.11.4** (requires `@pollar/core@^0.11.4`).
24
- > **KYC by ramp corridor**: `<RampWidget>` lists routes locked by a requirement step and opens that
25
- > step - `<KycModal>`, `<RequirementFormModal>`, `<RegistryCheckModal>` or `<ProviderRegistrationModal>`
26
- > (all exported) - then quotes again; `openKycModal()` without a corridor walks the app's own KYC
27
- > steps. **Redesign**: Send, Swap, Receive, Sessions and Wallet balance follow the new design, keeping the
28
- > network picker (a multichain app) and Swap's custom buy token. A template you
29
- > mount yourself gains required handlers (`onMax`, `onPaste`, `onReverse`, `revokeError`,
30
- > `kycRequired`, `onVerifyRoute`) - see [UPGRADE.md](../../UPGRADE.md). Licensed under Apache-2.0
31
- > from this release.
32
- >
33
- > **Wallet provisioning** (requires `@pollar/core@^0.11.4`, no breaking change). The platform now creates an
34
- > end-user's Stellar account **in the background**, so a login returns before the account is on
35
- > the ledger and the first payment in that window is refused by the server. Two things changed
36
- > here. **A wallet that finishes provisioning now reaches the UI**: `sessionsEqual` did not
37
- > compare `provisioning` and the context memo's dependency list did not include it, and either
38
- > one alone froze every screen built on the transition. And the modals say what is happening -
39
- > **Send** refuses to build a payment while the account is off the ledger and gives the reason
40
- > (kept apart from the "no transfer path on this network" message, which would otherwise tell
41
- > someone waiting on a brand-new wallet that Stellar cannot send), **Receive** warns while the
42
- > address is still unbacked, and the **wallet button** carries the same reason as a banner in its
43
- > dropdown. `walletNotReadyReason(wallet, chain)` is exported so a custom template phrases the
44
- > wait the way the built-ins do; `SendModalTemplateProps`, `ReceiveModalTemplateProps` and
45
- > `WalletButtonTemplateProps` each gain an **optional** `notReadyReason`, so a custom template
46
- > written before this keeps compiling untouched. In the **ramp widget**: a user whose provider
47
- > setup is still pending is no longer asked to verify an identity they already verified
48
- > (`onboardingStatus: 'awaiting_provider'` says the account is being set up and stops the
49
- > pointless KYC poll), and three failures that printed as raw error codes get sentences.
50
- > `RampWidgetTemplateProps` gains an optional `onboardingStatus`.
51
- >
52
- > **Cards**: `<CardModal>`, opened with `openCardModal()` from `usePollar()`, walks the user through
53
- > the card provider's steps, sign-up and issuing, then shows the card with the app's logo and card
54
- > label, its balance and movements, funding from the wallet (each funding's step while it is in
55
- > flight) and the number revealed on the device. **Wallets on demand**: `usePollar()` exposes
56
- > `hasWallet` and `createWallet`, and signed in without a wallet `<WalletButton>` offers Create wallet
57
- > to an app that creates wallets on demand. The modals that act on the session close when it ends,
58
- > and form fields are checked before sending.
59
- >
60
- > Earlier: **0.11.3** required `@pollar/core@^0.11.3`. A **pre-built `PollarClient`
61
- > passed to `PollarProvider` no longer loses passkey support**: the provider installs the
62
- > browser passkey ceremony on every path (via core's new `setPasskeyDefaults()`), and an
63
- > explicit `passkey: undefined` no longer wipes the default. `browserPasskeyCeremony` and
64
- > `browserPasskeySigner` are now exported for consumers who build their own client or want
65
- > to wrap the ceremony. Also, **StrictMode no longer leaves an orphaned `PollarClient`
66
- > running**: the provider keys the client it builds on the config object, so StrictMode's
67
- > second render pass reuses the first pass's instance instead of constructing a second
68
- > client whose refresh loop could clear the session the real login just wrote (dev only,
69
- > no API change). Packaging: **`@pollar/core` moved from `dependencies` to
70
- > `peerDependencies`**, so npm no longer installs a package-local duplicate of core (the
71
- > configuration that broke `instanceof` and split the live-client registry); the provider
72
- > now discriminates with core's new `isPollarClient()` guard, which works across copies.
73
- > npm 7+ installs peers automatically; on npm 6, Yarn 1 or `--legacy-peer-deps`, add
74
- > `@pollar/core` to your own dependencies. If you pin exact versions, keep both packages
75
- > on the same version.
76
- >
77
- > Earlier: **0.11.2** required `@pollar/core@^0.11.2`. The **Transaction History modal
78
- > goes multichain**: the same network picker and address chip as the Balance /
79
- > Send modals, a server-side chain filter (pagination is server-side, so
80
- > switching networks refetches and resets to page 1), per-chain explorer links
81
- > (stellar.expert for Stellar, explorer.solana.com for Solana), and the unified
82
- > `{ amount, unit }` fee, so a Solana row reads "5000 lamports". The picker
83
- > hides itself on a single-chain app. Non-breaking.
84
- >
85
- > Earlier: **0.11.1** added the network picker (`<ChainSelect>`) across the
86
- > wallet-balance, enabled-assets, send and receive modals - each scopes its rows
87
- > to the selected chain instead of tagging every row, with a local filter (the
88
- > backend returns every chain in one payload). Balances format against each
89
- > token's own `decimals`, and a `null` balance renders as a dash rather than as
90
- > `0`, because `null` means the chain could not be read. See the
91
- > [CHANGELOG](../../CHANGELOG.md) and [UPGRADE.md](../../UPGRADE.md) for the full
92
- > version history before upgrading.
17
+ > See the [CHANGELOG](https://github.com/pollar-xyz/pollar/blob/main/CHANGELOG.md) for earlier releases and [UPGRADE.md](https://github.com/pollar-xyz/pollar/blob/main/UPGRADE.md) before upgrading.
93
18
 
94
19
  ## Installation
95
20
 
@@ -101,7 +26,8 @@ pnpm add @pollar/react @pollar/core
101
26
  yarn add @pollar/react @pollar/core
102
27
  ```
103
28
 
104
- **Peer dependencies:** `react >= 18`, `react-dom >= 18`. Node ≥ 20 in toolchains.
29
+ **Peer dependencies:** `@pollar/core ^0.12.1`, `react >= 18`, `react-dom >= 18`. Node >= 20 in toolchains. npm 7+
30
+ installs peers automatically; on npm 6, Yarn 1 or `--legacy-peer-deps`, list `@pollar/core` in your own dependencies.
105
31
 
106
32
  ## Quick Start
107
33
 
@@ -149,17 +75,20 @@ Context provider that initialises the Pollar client and makes it available to ch
149
75
  <PollarProvider
150
76
  client={{
151
77
  apiKey: 'your-api-key',
152
- baseUrl: 'https://sdk.api.pollar.xyz', // optional, origin only — the SDK appends /v3
78
+ baseUrl: 'https://sdk.api.pollar.xyz', // optional, origin only - the SDK appends /v3
153
79
  stellarNetwork: 'testnet', // optional, default: 'testnet'
80
+ locale: 'pt-BR', // optional, BCP 47 tag for the modals' language (see Language below)
154
81
  storage, // optional, RN apps inject this
155
82
  keyManager, // optional, autodetects on web
156
- walletAdapters, // optional, WalletAdapter[] — external wallet stacks
157
- deviceLabel: 'iPhone — Safari', // optional, shown in SessionsModal
83
+ walletAdapters, // optional, WalletAdapter[] - external wallet stacks
84
+ deviceLabel: 'iPhone - Safari', // optional, shown in SessionsModal
158
85
  onStorageDegrade, // optional, telemetry hook
159
86
  }}
160
- // Optional: pass `appConfig` (even `{}`) to skip the remote
161
- // `/applications/config` fetch and use local-only styles/branding.
87
+ // Optional: pass `appConfig` to skip the remote `/applications/config` fetch
88
+ // and use a local config instead. `application` is required; `styles` may be partial,
89
+ // but a login method it leaves out (emailEnabled, providers, ...) is off.
162
90
  appConfig={{
91
+ application: { name: 'My app', network: 'testnet', chains: ['STELLAR'] },
163
92
  styles: {
164
93
  /* optional style overrides */
165
94
  },
@@ -174,35 +103,38 @@ Context provider that initialises the Pollar client and makes it available to ch
174
103
  </PollarProvider>
175
104
  ```
176
105
 
177
- | Prop | Type | Required | Description |
178
- | ----------- | ------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
179
- | `client` | `PollarClient \| PollarClientConfig` | Yes | Either a pre-built `PollarClient` (testing, reuse outside React) or a `PollarClientConfig` the provider will construct one from. **Locked at first render** — swapping after mount is ignored |
180
- | `appConfig` | `PollarConfig` | No | Local override of `/applications/config`. **Presence is the opt-out switch**: pass it (even `{}`) and the remote fetch is skipped. Omit it to keep the existing remote-fetch-on-mount behaviour. Unlike `client`, it can be added or swapped after mount — the context re-applies it (compared by value, so an inline object literal is fine) |
181
- | `adapters` | `PollarAdapters` | No | Named set of `PollarAdapter` objects (e.g. Trustless Work). See below |
106
+ | Prop | Type | Required | Description |
107
+ | ------------------ | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
108
+ | `client` | `PollarClient \| PollarClientConfig` | Yes | Either a pre-built `PollarClient` (testing, reuse outside React) or a `PollarClientConfig` the provider will construct one from. **Locked at first render** - swapping after mount is ignored |
109
+ | `appConfig` | `PollarConfig` | No | Local replacement for `/applications/config`, used verbatim and never merged with the server's answer. **Presence is the opt-out switch**: pass it and the remote fetch is skipped. Omit it to fetch the config on mount, which keeps branding, login methods and chains current. Unlike `client`, it can be added or swapped after mount - the context re-applies it (compared by value, so an inline object literal is fine) |
110
+ | `adapters` | `PollarAdapters` | No | Named set of `PollarAdapter` objects (e.g. Trustless Work). See [Custom adapters](#custom-adapters) |
111
+ | `onStorageDegrade` | `OnStorageDegrade` | No | Called once when persistent storage falls back to in-memory mode (Safari private browsing, sandboxed iframes), so the session will not survive a reload |
182
112
 
183
113
  ---
184
114
 
185
115
  ### `usePollar()`
186
116
 
187
- Returns the full Pollar context. Every modal opener returned here renders an already-wired modal — no extra mounting
117
+ Returns the full Pollar context. Every modal opener returned here renders an already-wired modal - no extra mounting
188
118
  needed.
189
119
 
190
120
  ```ts
191
121
  const {
192
122
  // Session
193
- isAuthenticated, // boolean - true when a wallet address is present
123
+ isAuthenticated, // boolean - true while a session exists, with or without a wallet
194
124
  wallet, // WalletInfo | null - read wallet?.address for the on-chain address
195
125
  wallets, // WalletInfo[] - every wallet the user holds, one per chain. To drive
196
126
  // a network picker, prefer the useChains() hook (below) over reading
197
127
  // this directly - it applies the app's configured chain order
198
128
  verified, // boolean - true once the server has confirmed the session
129
+ hasWallet, // boolean - false until createWallet() runs on an app that creates wallets on demand
130
+ createWallet, // (options?: { custody? }) => Promise<WalletInfo> (custody: the user's pick under USER_CHOICE)
199
131
 
200
132
  // App config (the remote /config fetch behind the login modal)
201
133
  configStatus, // 'loading' | 'ready' | 'error'
202
134
  retryConfig, // () => void - re-runs the fetch after an error
203
135
 
204
136
  // Client escape hatch
205
- getClient, // () => PollarClient - for getUserProfile(), listSessions(), …
137
+ getClient, // () => PollarClient - for getUserProfile(), listSessions(), ...
206
138
 
207
139
  // Auth
208
140
  login, // (options: PollarLoginOptions) => void
@@ -213,6 +145,20 @@ const {
213
145
  sessions, // SessionsState
214
146
  openSessionsModal, // () => void
215
147
 
148
+ // Co-signed wallets (Turnkey)
149
+ cosign, // CosignState - requests waiting for this device's vote
150
+ openCosignModal, // () => void (also opens by itself when a request arrives)
151
+ setCosignNextStep, // (next: string | null) => void - keeps the prompt open for a flow's next approval
152
+ recovery, // RecoveryState | null
153
+ recoveryLocked, // boolean - true while the wallet cannot be recovered without this device
154
+ refreshRecovery, // () => void
155
+ openRecoveryModal, // () => void (passkeys, email, devices, recovery phrase)
156
+ custodyMigration, // CustodyMigrationState | null - while `required`, the provider shows the move to Turnkey
157
+ refreshCustodyMigration, // () => void
158
+
159
+ // Signature confirmation
160
+ confirmations, // PendingConfirmation[] - signing calls waiting under confirmation: 'prompt'; the provider shows the first
161
+
216
162
  // Transactions
217
163
  tx, // TransactionState
218
164
  buildTx, // (operation, params, options?) => Promise<BuildOutcome>
@@ -241,12 +187,15 @@ const {
241
187
 
242
188
  // Swap (DEX/AMM)
243
189
  getSwapQuote, // (params: SwapQuoteParams) => Promise<SwapQuote[]>
244
- swap, // (quote: SwapQuote, opts?) => Promise<SubmitOutcome>
190
+ swap, // (quote: SwapQuote, opts?: { autoTrustline? }) => Promise<SubmitOutcome>
245
191
  getSwapConfig, // () => Promise<SwapVenue[]> (which venues this app offers)
246
192
  getSwapTokens, // () => Promise<SwapToken[]>
193
+ getSolanaSwapConfig, // () => Promise<SolanaSwapVenue[]> (Jupiter, Titan; mainnet)
194
+ getSolanaSwapQuote, // (params: SolanaSwapQuoteParams) => Promise<SolanaSwapQuote[]>
195
+ swapSolana, // (quote: SolanaSwapQuote, opts?: { slippageBps? }) => Promise<SubmitOutcome>
247
196
  openSwapModal, // () => void
248
197
 
249
- // Earn (yield vaults + lending — DeFindex + Blend)
198
+ // Earn (yield vaults + lending - DeFindex + Blend)
250
199
  getEarnProviders, // () => Promise<EarnProviderId[]> ([] means Earn is disabled)
251
200
  getEarnOpportunities, // (provider: EarnProviderId) => Promise<EarnOpportunity[]>
252
201
  getEarnPosition, // (params: EarnPositionParams) => Promise<EarnPosition>
@@ -254,6 +203,9 @@ const {
254
203
  earnWithdraw, // (params: EarnTxParams) => Promise<SubmitOutcome>
255
204
  openEarnModal, // () => void
256
205
 
206
+ // Cards (the card calls live on getClient(): getCardProviders, issueCard, fundCard, ...)
207
+ openCardModal, // () => void
208
+
257
209
  // Distribution rules
258
210
  openDistributionRulesModal, // () => void
259
211
 
@@ -290,7 +242,7 @@ Custody is derived from `wallet`, not a separate field - e.g.
290
242
  login({ provider: 'google' });
291
243
  login({ provider: 'github' });
292
244
 
293
- // Email OTP
245
+ // Email OTP (the code input accepts a code the browser or keyboard autofills, or a paste)
294
246
  login({ provider: 'email', email: 'user@example.com' });
295
247
 
296
248
  // Built-in Stellar wallet adapters (the adapter's `type` IS the provider)
@@ -311,7 +263,7 @@ The login modal is gated on the remote app-config fetch. While it runs the modal
311
263
  driving `<LoginModalTemplate>` yourself. Passing `appConfig` to `<PollarProvider>` opts out of the fetch entirely, so
312
264
  neither state can occur.
313
265
 
314
- #### Self-driving interactive adapters (Privy, …)
266
+ #### Self-driving interactive adapters (Privy, ...)
315
267
 
316
268
  Registered adapters that opt into the interactive-auth contract
317
269
  (`isInteractiveAuthAdapter` + `onProviderAuthChange`) are auto-driven by the
@@ -334,7 +286,7 @@ provider:
334
286
  The single source of truth for "which chains, in what order, and which address to
335
287
  show". Every built-in component (`<WalletButton>`, the network pickers) reads from
336
288
  it, so they can never disagree about which chain leads. Use it when you build your
337
- own wallet button or picker instead of calling `chainsOf(wallets)` yourself —
289
+ own wallet button or picker instead of calling `chainsOf(wallets)` yourself -
338
290
  `chainsOf` alone cannot know the app's configured order.
339
291
 
340
292
  ```ts
@@ -348,7 +300,7 @@ const { chains, primaryChain, primaryAddress, ready } = useChains();
348
300
  | `chains` | `WalletChain[]` | Chains to offer, in the app's configured order: those the app serves **and** the user holds. `[]` until config resolves |
349
301
  | `primaryChain` | `WalletChain \| null` | The app's first configured chain the user holds. `null` until ready |
350
302
  | `primaryAddress` | `string` | The address on `primaryChain`. Falls back to the session's first wallet while config is in flight |
351
- | `ready` | `boolean` | `false` while `/config` is loading or failed — gate any chain UI on it |
303
+ | `ready` | `boolean` | `false` while `/config` is loading or failed - gate any chain UI on it |
352
304
 
353
305
  The order and membership come from the app's `/applications/config`
354
306
  (`appConfig.application.chains`), not from the session's `wallets`: a chain the app
@@ -357,32 +309,60 @@ session still carries it.
357
309
 
358
310
  ---
359
311
 
312
+ ### Language
313
+
314
+ Every modal, shared block (footer, copy button, amount field, pickers) and exported template speaks English (`en`),
315
+ Spanish (`es`) and Portuguese (`pt`). The provider picks the language once, in this order:
316
+
317
+ 1. The language the app pins in the dashboard (Branding > Language, served as `styles.language`).
318
+ 2. The `language` prop of `<RampWidget>`, `<KycModal>`, `<RequirementFormModal>`, `<RegistryCheckModal>` or
319
+ `<ProviderRegistrationModal>`, a BCP 47 tag.
320
+ 3. The client's `locale` (`client={{ apiKey, locale: 'pt-BR' }}`), any BCP 47 tag.
321
+ 4. The browser language.
322
+
323
+ A tag the modals have no translation for is skipped, and English is the fallback. Every exported template takes a
324
+ `language` prop (`PollarLanguage` from `@pollar/core`: `'en' | 'es' | 'pt'`); a template rendered inside the provider
325
+ follows the provider's language, and one rendered outside it uses the browser's.
326
+
327
+ ---
328
+
360
329
  ### Components
361
330
 
362
- Every modal mounts itself when its `openXModal()` action is called. You don't need to render these directly — they're
363
- already wired inside `<PollarProvider>` — and most are exported in case you want to mount them yourself.
331
+ Every modal mounts itself when its `openXModal()` action is called. You don't need to render these directly - they're
332
+ already wired inside `<PollarProvider>` - and most are exported in case you want to mount them yourself.
364
333
 
365
334
  > Two wrappers are **not** exported: `<TxHistoryModal>` and `<TransactionModal>`. Only their templates
366
335
  > (`TxHistoryModalTemplate` / `TransactionModalTemplate`) are public. Mount those instead if you need to drive them
367
336
  > yourself.
368
-
369
- | Component | Purpose |
370
- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
371
- | `<WalletButton>` | Drop-in button. Opens login when signed out; signed in, shows the wallet address with a dropdown (Send, Receive, copy address, balance, history, ramp, KYC, distribution rules, sessions, sign out, plus a "Create account" action when the external wallet has no on-chain account yet). Inline arc spinner during in-progress transactions |
372
- | `<SendModal>` | Full send flow: network picker (shown when the app has more than one chain), asset picker, amount with Max (from the available balance), destination with Paste, inline build > sign > success/error. Sending is available on Stellar and Solana; Polygon can be browsed but not sent from |
373
- | `<SwapModal>` | On-chain asset-to-asset swap: pick from/to assets and amount, quote across venues, execute (auto-trustline on the buy asset when needed); paste a custom buy token (code + issuer) |
374
- | `<EarnModal>` | Deposit/withdraw across DeFindex vaults and Blend pools: provider + opportunity selection with live APY, wallet balance, over-spend guards, and auto-trustline on deposit |
375
- | `<ReceiveModal>` | Wallet address as QR code with copy-to-clipboard (no external QR dependency required) |
376
- | `<TxHistoryModal>` | Paginated multichain transaction history with auto-fetch on open. A `<ChainSelect>` in the header filters server-side (switching networks refetches and resets to page 1); rows link to their own chain's explorer (stellar.expert for Stellar, explorer.solana.com for Solana) and show the unified `{ amount, unit }` fee |
377
- | `<WalletBalanceModal>` | Multichain wallet balances (Stellar, Polygon, Solana). A `<ChainSelect>` picks the network and the rows are filtered to it; shows that chain's address plus a refresh button, and each row's issuer with a copy action. An unreadable chain's balance renders as a dash, never as `0`. On Solana testnet each row offers a faucet hint — a devnet SOL faucet on the native row, Circle's USDC faucet on the USDC row |
378
- | `<EnabledAssetsModal>` | The application's dashboard-enabled assets for the network picked in the header, with per-asset trustline state; establish/remove trustlines (Stellar only - other chains are informational) |
379
- | `<DistributionRulesModal>` | Manage the wallet's distribution rules |
380
- | `<SessionsModal>` | Lists every active refresh-token family for the current user with device metadata, marks the local session, per-row revoke, and a "Sign out everywhere" button |
381
- | `<KycModal>` | Identity verification: hosted (iframe or redirect) flow per option, corridor-scoped when a ramp route asks for it (`corridorId`), or started on one option (`providerId`). Shows review, expiry and retry states; without either id it walks the app's own KYC steps |
382
- | `<RampWidget>` | Buy/sell crypto: direction tabs, country, fiat and asset pickers, route comparison leg by leg, the fields a route asks for, then the order's progress with its pending action (payment QR or bank details, Authorize, co-sign approval, verification link) and what to do when a leg fails. Orders waiting on the user can be resumed. |
383
- | `<RequirementFormModal>` | One `FORM` requirement step of a ramp route: renders the form the backend names (`formId`), prefilled with the user's previous answers, and stores the answers encrypted. `<RampWidget>` opens it itself; exported for consumers who build their own route list from `requirementsRequired` |
384
- | `<RegistryCheckModal>` | One `REGISTRY_CHECK` step (SEGIP through Stereum, `optionId`): the verified identity prefilled and read-only except the surname split and the CI complement; a check the registry did not confirm shows the review state with nothing to retry |
385
- | `<ProviderRegistrationModal>` | One `PROVIDER_REGISTRATION` step (`corridorId`): lists what the ramp provider receives and registers the user with it on consent; an already registered user is passed through |
337
+ >
338
+ > The provider also shows three prompts by itself, with no opener: `<ConfirmModal>` (internal) for a signing call
339
+ > waiting under `confirmation: 'prompt'`, including a Soroban token transfer (`kind: 'sign_auth_entry'`) with its
340
+ > destination, amount and asset; `<CosignModal>` when a co-signed wallet has a request for this device; and
341
+ > `<CustodyMigrationModal>` while `custodyMigration.required` asks to move a custodial wallet to Turnkey.
342
+
343
+ | Component | Purpose |
344
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
345
+ | `<WalletButton>` | Drop-in button. Opens login when signed out; signed in, shows the wallet address with a dropdown (Send, Receive, copy address, balance, history, ramp, KYC, distribution rules, sessions, recovery methods, sign out, plus a "Create account" action when the external wallet has no on-chain account yet). Inline arc spinner during in-progress transactions |
346
+ | `<SendModal>` | Full send flow: network picker (shown when the app has more than one chain), asset picker, amount with Max (from the available balance), destination with Paste, a Stellar memo (Text, ID or Hash: 64 hex characters), inline build > sign > success/error. A Stellar destination with no account offers to create it with the XLM being sent. Sending is available on Stellar and Solana; Polygon can be browsed but not sent from |
347
+ | `<SwapModal>` | On-chain asset-to-asset swap on Stellar and Solana (a Network selector when the app has venues on both): pick from/to assets and amount, quote across venues, execute (auto-trustline on the buy asset when needed); paste a custom Stellar buy token (code + issuer). On Solana it sells what the Solana wallet holds, buys SOL or a token the app enabled, shows the route's output and minimum, and links the swap to Solscan |
348
+ | `<EarnModal>` | Deposit/withdraw across DeFindex vaults and Blend pools: provider + opportunity selection with live APY, wallet balance, over-spend guards, and auto-trustline on deposit |
349
+ | `<ReceiveModal>` | Wallet address as QR code with copy-to-clipboard (no external QR dependency required) |
350
+ | `<TxHistoryModal>` | Paginated multichain transaction history with auto-fetch on open. A `<ChainSelect>` in the header filters server-side (switching networks refetches and resets to page 1); rows link to their own chain's explorer (stellar.expert for Stellar, explorer.solana.com for Solana) and show the unified `{ amount, unit }` fee |
351
+ | `<WalletBalanceModal>` | Multichain wallet balances (Stellar, Polygon, Solana). A `<ChainSelect>` picks the network and the rows are filtered to it; shows that chain's address plus a refresh button, and each row's issuer with a copy action. An unreadable chain's balance renders as a dash, never as `0`. On Solana testnet each row offers a faucet hint - a devnet SOL faucet on the native row, Circle's USDC faucet on the USDC row |
352
+ | `<EnabledAssetsModal>` | The application's dashboard-enabled assets for the network picked in the header, with per-asset trustline state; establish/remove trustlines (Stellar only - other chains are informational) |
353
+ | `<DistributionRulesModal>` | Manage the wallet's distribution rules |
354
+ | `<SessionsModal>` | Lists every active refresh-token family for the current user with device metadata, marks the local session, per-row revoke, and a "Sign out everywhere" button |
355
+ | `<KycModal>` | Identity verification: hosted (iframe or redirect) flow per option, corridor-scoped when a ramp route asks for it (`corridorId`), or started on one option (`providerId`). Shows review, expiry and retry states; without either id it walks the app's own KYC steps |
356
+ | `<RampWidget>` | Buy/sell crypto: direction tabs, country, fiat and asset pickers, route comparison leg by leg, the fields a route asks for, then the order's progress with its pending action (payment QR or bank details, Authorize, co-sign approval, verification link) and what to do when a leg fails. A route refused for its amount says the minimum or maximum it takes and offers "Change amount"; an order whose price changed before anything moved offers "Get a new quote". Orders waiting on the user can be resumed |
357
+ | `<RequirementFormModal>` | One `FORM` requirement step of a ramp route: renders the form the backend names (`formId`), prefilled with the user's previous answers, and stores the answers encrypted. A field with `showIf: { key, in }` is shown only while the earlier select, multiselect or checkbox it names answers one of those values, and is neither checked nor sent while hidden. `<RampWidget>` opens it itself; exported for consumers who build their own route list from `requirementsRequired` |
358
+ | `<RegistryCheckModal>` | One `REGISTRY_CHECK` step (SEGIP through Stereum, `optionId`): the verified identity prefilled and read-only except the surname split and the CI complement; a check the registry did not confirm shows the review state with nothing to retry |
359
+ | `<ProviderRegistrationModal>` | One `PROVIDER_REGISTRATION` step (`corridorId`): lists what the ramp provider receives and registers the user with it on consent; an already registered user is passed through |
360
+ | `<CardModal>` | Opened with `openCardModal()`: the card provider's sign-up, identity verification and issuing, then the card with the app's logo and label, its balance and movements, and the number revealed on the device. Copy buttons next to the number and CVC while the details are shown, and next to the expiry date always. Funds the card from the wallet, including a co-signed one, with a network picker when the user holds a wallet on Stellar and Solana, and shows each funding's steps |
361
+ | `<RecoveryModal>` | Opened with `openRecoveryModal()`: the recovery methods of a Turnkey wallet (passkeys, email, devices, recovery phrase) |
362
+ | `<CosignModal>` | The approval prompt of a co-signed wallet. Enables Approve only after the request verifies against Turnkey |
363
+ | `<CustodyMigrationModal>` | Moves a custodial wallet to Turnkey after login when the app keeps its wallets there (`state`, `onMoved`, `onLater` props) |
364
+ | `<KycStatus>` | A KYC status badge (`status`, optional `label`) |
365
+ | `<RouteDisplay>` / `<RejectedRouteDisplay>` | One ramp route, offered or refused, as the ramp widget lists it |
386
366
 
387
367
  ```tsx
388
368
  import { WalletButton } from '@pollar/react';
@@ -396,9 +376,9 @@ export function Header() {
396
376
 
397
377
  ### Template components
398
378
 
399
- Almost every modal ships a pure presentational "template" companion — same name with a `Template` suffix. Use these when
400
- you want to swap the chrome but keep the data wiring from `usePollar()`. (`<EarnModal>`, `<RequirementFormModal>`,
401
- `<RegistryCheckModal>` and `<ProviderRegistrationModal>` are the exceptions: they have no template yet.)
379
+ Almost every modal ships a pure presentational "template" companion - same name with a `Template` suffix. Use these when
380
+ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<EarnModal>`, `<CardModal>`, `<RequirementFormModal>`,
381
+ `<RegistryCheckModal>` and `<ProviderRegistrationModal>` are the exceptions: they have no template.)
402
382
 
403
383
  > The enabled-assets template requires `chains`, `selectedChain` and `onSelectChain`; the wallet-balance, send and
404
384
  > receive templates require `selectedChain` and take `chains` / `onSelectChain` as optional - pass both to show the
@@ -422,16 +402,17 @@ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<Earn
422
402
  | `<KycModal>` | `<KycModalTemplate>` |
423
403
  | `<RampWidget>` | `<RampWidgetTemplate>` |
424
404
  | `<SessionsModal>` | `<SessionsModalTemplate>` |
405
+ | `<CosignModal>` | `<CosignModalTemplate>` |
406
+ | `<RecoveryModal>` | `<RecoveryModalTemplate>` |
407
+ | `<CustodyMigrationModal>` | `<CustodyMigrationModalTemplate>` |
425
408
 
426
- `<TxStatusView>` is the shared status component (build → sign → success/error) reused by `TransactionModal` and
409
+ `<TxStatusView>` is the shared status component (build -> sign -> success/error) reused by `TransactionModal` and
427
410
  `SendModal`; it's exported on its own for consumers that want to embed the lifecycle elsewhere.
428
411
 
429
412
  > `onWalletConnect` is **optional** on `<LoginModalTemplate>` (defaults to a no-op).
430
413
 
431
414
  > `notReadyReason` is **optional** on `<SendModalTemplate>`, `<ReceiveModalTemplate>` and
432
- > `<WalletButtonTemplate>`, and `onboardingStatus` is optional on `<RampWidgetTemplate>` - a custom
433
- > template written before 0.11.4 keeps compiling and keeps its old wording. Render `notReadyReason`
434
- > when it is present: it is the sentence for a Stellar account the platform is still creating, and
415
+ > `<WalletButtonTemplate>`. Render it when it is present: it is the sentence for a Stellar account the platform is still creating, and
435
416
  > without it a custom Send lets the user build a payment the server will refuse
436
417
  > (`SDK_WALLET_NOT_READY`). To phrase it yourself, call the exported
437
418
  > `walletNotReadyReason(wallet, chain)`. It gates on `STELLAR` and on the ACCOUNT only, so a
@@ -443,41 +424,72 @@ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<Earn
443
424
  ### Custom adapters
444
425
 
445
426
  The `adapters` prop on `<PollarProvider>` accepts any named set of `PollarAdapter` objects. Each adapter function
446
- receives params, returns an unsigned XDR, and Pollar handles signing and submission automatically.
427
+ receives params and returns either an unsigned transaction or a Soroban auth entry to sign; Pollar handles the
428
+ signing (and, for a transaction, the submission).
447
429
 
448
430
  ```tsx
449
431
  import type { PollarAdapter } from '@pollar/core';
450
432
 
451
- const trustlessWork: PollarAdapter = {
452
- initialize: async (params) => ({ unsignedTransaction: '…' }),
453
- release: async (params) => ({ unsignedTransaction: '…' }),
454
- };
433
+ const trustlessWork = {
434
+ initialize: async (params: InitializeParams) => ({ unsignedTransaction: '...' }),
435
+ release: async (params: ReleaseParams) => ({ unsignedTransaction: '...' }),
436
+ } satisfies PollarAdapter;
455
437
 
456
438
  <PollarProvider client={{ apiKey }} adapters={{ trustlessWork }}>
457
- …
439
+ ...
458
440
  </PollarProvider>;
459
441
  ```
460
442
 
461
443
  #### `createPollarAdapterHook(key)`
462
444
 
463
- Factory that generates a fully-typed hook mirroring an adapter's API with automatic XDR signing built in:
445
+ Factory that generates a fully-typed hook mirroring an adapter's API with signing built in:
464
446
 
465
- ```ts
447
+ ```tsx
466
448
  import { createPollarAdapterHook } from '@pollar/react';
467
449
 
468
450
  const useTrustlessWork = createPollarAdapterHook<typeof trustlessWork>('trustlessWork');
469
451
 
470
- function MyComponent() {
452
+ function ReleaseButton() {
471
453
  const tw = useTrustlessWork();
472
- await tw.initialize({
473
- /* … */
474
- }); // unsigned XDR is built, signed, and submitted automatically
454
+ // The adapter builds the XDR; the hook signs and submits it and resolves with a SubmitOutcome.
455
+ return (
456
+ <button
457
+ onClick={() =>
458
+ tw.release({
459
+ /* ... */
460
+ })
461
+ }
462
+ >
463
+ Release
464
+ </button>
465
+ );
475
466
  }
476
467
  ```
477
468
 
469
+ #### Auth-entry steps
470
+
471
+ When someone else submits the call and pays its fee (an x402 facilitator, a contract that sponsors the gas), an
472
+ adapter function answers `{ unsignedAuthEntry, validUntilLedger, complete }` instead of `{ unsignedTransaction }`.
473
+ The hook signs the entry with the user's wallet through `signAuthEntry` (the app's allowlist, the validity window,
474
+ the signature confirmation, a co-signed wallet's vote), submits nothing, and passes the signed entry to `complete`.
475
+ The call resolves with `{ status: 'completed', result }`, where `result` is what `complete` returned, or with the
476
+ signing outcome that stopped it (`{ status: 'cosign_pending', request }` or `{ status: 'error', code?, details? }`).
477
+
478
+ ```ts
479
+ const x402 = {
480
+ pay: async (params: PayParams) => ({
481
+ unsignedAuthEntry: entryXdr, // base64 XDR of the unsigned SorobanAuthorizationEntry
482
+ validUntilLedger, // within the app's validity window
483
+ complete: async (signedAuthEntry: string) => submitToFacilitator(signedAuthEntry),
484
+ }),
485
+ } satisfies PollarAdapter;
486
+ ```
487
+
488
+ `isAuthEntryAdapterStep` and `completeAuthEntryStep` (from `@pollar/core`) run the same step outside React.
489
+
478
490
  ---
479
491
 
480
- ### External wallet stacks (Stellar Wallets Kit, …)
492
+ ### External wallet stacks (Stellar Wallets Kit, ...)
481
493
 
482
494
  Register adapters for wallets that live outside `@pollar/core` by passing a
483
495
  `walletAdapters: WalletAdapter[]` array. `LoginModal` auto-renders one button per
@@ -504,7 +516,7 @@ import { Networks } from '@creit.tech/stellar-wallets-kit';
504
516
 
505
517
  Each adapter's `meta.group` controls placement: adapters sharing a group label
506
518
  collapse behind one gateway button (the kit wallets default to `'Wallet'`),
507
- while adapters with no group — e.g. Privy — render as their own button in the
519
+ while adapters with no group - e.g. Privy - render as their own button in the
508
520
  root view. Pass `picker.groupLabel` to give the kit wallets a distinct gateway.
509
521
 
510
522
  ---
@@ -536,13 +548,20 @@ import type {
536
548
  PollarAuthProvider,
537
549
  AuthProviderContext,
538
550
 
539
- // Network picker
551
+ // Network picker and co-signing
540
552
  ChainSelectProps,
541
553
  UseChainsResult,
554
+ UseCosignResult,
555
+
556
+ // Modal theming
557
+ ModalStyleOverrides,
558
+ ModalVariant,
559
+ ModalChrome,
542
560
 
543
561
  // Template props
544
562
  WalletButtonTemplateProps,
545
563
  SendModalTemplateProps,
564
+ SendMemoType,
546
565
  SwapModalTemplateProps,
547
566
  SwapAssetOption,
548
567
  ReceiveModalTemplateProps,
@@ -550,8 +569,13 @@ import type {
550
569
  TxStatusViewProps,
551
570
  WalletBalanceModalTemplateProps,
552
571
  EnabledAssetsModalTemplateProps,
572
+ CustomTrustlineModalTemplateProps,
553
573
  SessionsModalTemplateProps,
554
574
  SessionsState,
575
+ CosignModalTemplateProps,
576
+ RecoveryModalTemplateProps,
577
+ RecoveryView,
578
+ CustodyMigrationModalTemplateProps,
555
579
 
556
580
  // Step unions
557
581
  KycStep,
@@ -560,7 +584,8 @@ import type {
560
584
  ```
561
585
 
562
586
  The state types (`TransactionState`, `TxHistoryState`, `WalletBalanceState`, `NetworkState`, `AuthState`,
563
- `PollarPersistedSession`, `PollarUserProfile`, `SessionInfo`, …) are re-exported from `@pollar/core`.
587
+ `CosignState`, `RecoveryState`, `PendingConfirmation`, `PollarPersistedSession`, `PollarUserProfile`, `SessionInfo`,
588
+ `PollarLanguage`, ...) are exported by `@pollar/core`; import them from there.
564
589
 
565
590
  ---
566
591