@pollar/react 0.12.0 → 0.12.1-rc.11

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,26 @@
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. `<ConfirmModal>`, `<CosignModal>` and
10
+ > every transaction status view share one review: what moves, a fee badge when who pays is known, and "Show details"
11
+ > with the addresses, network, fee, raw transaction and hash. `<RequirementFormModal>` asks a field
12
+ > with `showIf` only while the answer it depends on matches. `<CardModal>` copies the number, expiry date and CVC,
13
+ > offers a network picker when the user holds a wallet on Stellar and Solana, and funds the card from a co-signed
14
+ > wallet too. The email code input takes an autofilled one-time code. The ramp widget says a route's minimum or
15
+ > maximum and offers "Change amount", and an order whose price changed before anything moved offers "Get a new quote".
16
+ > `openRampModal(options)` opens the ramp widget on a direction, country, fiat, asset and amount; the send, swap, earn,
17
+ > receive, history and card modals take options too, with `onSuccess` / `onFunded` callbacks.
18
+ > `<PollarProvider language>` and `client.setLocale()` switch the modals' language at runtime, open ones included. The
19
+ > ramp widget names each country in the modal's language.
20
+ > A hook built with `createPollarAdapterHook` signs the auth entry an adapter answers with, without submitting
21
+ > anything, and hands it to the adapter's `complete`.
15
22
  >
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.
23
+ > 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
24
 
94
25
  ## Installation
95
26
 
@@ -101,7 +32,8 @@ pnpm add @pollar/react @pollar/core
101
32
  yarn add @pollar/react @pollar/core
102
33
  ```
103
34
 
104
- **Peer dependencies:** `react >= 18`, `react-dom >= 18`. Node ≥ 20 in toolchains.
35
+ **Peer dependencies:** `@pollar/core ^0.12.1`, `react >= 18`, `react-dom >= 18`. Node >= 20 in toolchains. npm 7+
36
+ installs peers automatically; on npm 6, Yarn 1 or `--legacy-peer-deps`, list `@pollar/core` in your own dependencies.
105
37
 
106
38
  ## Quick Start
107
39
 
@@ -149,17 +81,20 @@ Context provider that initialises the Pollar client and makes it available to ch
149
81
  <PollarProvider
150
82
  client={{
151
83
  apiKey: 'your-api-key',
152
- baseUrl: 'https://sdk.api.pollar.xyz', // optional, origin only — the SDK appends /v3
84
+ baseUrl: 'https://sdk.api.pollar.xyz', // optional, origin only - the SDK appends /v3
153
85
  stellarNetwork: 'testnet', // optional, default: 'testnet'
86
+ locale: 'pt-BR', // optional, BCP 47 tag for the modals' language (see Language below)
154
87
  storage, // optional, RN apps inject this
155
88
  keyManager, // optional, autodetects on web
156
- walletAdapters, // optional, WalletAdapter[] — external wallet stacks
157
- deviceLabel: 'iPhone — Safari', // optional, shown in SessionsModal
89
+ walletAdapters, // optional, WalletAdapter[] - external wallet stacks
90
+ deviceLabel: 'iPhone - Safari', // optional, shown in SessionsModal
158
91
  onStorageDegrade, // optional, telemetry hook
159
92
  }}
160
- // Optional: pass `appConfig` (even `{}`) to skip the remote
161
- // `/applications/config` fetch and use local-only styles/branding.
93
+ // Optional: pass `appConfig` to skip the remote `/applications/config` fetch
94
+ // and use a local config instead. `application` is required; `styles` may be partial,
95
+ // but a login method it leaves out (emailEnabled, providers, ...) is off.
162
96
  appConfig={{
97
+ application: { name: 'My app', network: 'testnet', chains: ['STELLAR'] },
163
98
  styles: {
164
99
  /* optional style overrides */
165
100
  },
@@ -174,35 +109,39 @@ Context provider that initialises the Pollar client and makes it available to ch
174
109
  </PollarProvider>
175
110
  ```
176
111
 
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 |
112
+ | Prop | Type | Required | Description |
113
+ | ------------------ | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
114
+ | `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 |
115
+ | `language` | `string` | No | The modals' language, a BCP 47 tag (`'es'`, `'pt-BR'`): typically the app's current language. Followed on every render, so open modals switch when it changes. See [Language](#language) |
116
+ | `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) |
117
+ | `adapters` | `PollarAdapters` | No | Named set of `PollarAdapter` objects (e.g. Trustless Work). See [Custom adapters](#custom-adapters) |
118
+ | `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
119
 
183
120
  ---
184
121
 
185
122
  ### `usePollar()`
186
123
 
187
- Returns the full Pollar context. Every modal opener returned here renders an already-wired modal — no extra mounting
124
+ Returns the full Pollar context. Every modal opener returned here renders an already-wired modal - no extra mounting
188
125
  needed.
189
126
 
190
127
  ```ts
191
128
  const {
192
129
  // Session
193
- isAuthenticated, // boolean - true when a wallet address is present
130
+ isAuthenticated, // boolean - true while a session exists, with or without a wallet
194
131
  wallet, // WalletInfo | null - read wallet?.address for the on-chain address
195
132
  wallets, // WalletInfo[] - every wallet the user holds, one per chain. To drive
196
133
  // a network picker, prefer the useChains() hook (below) over reading
197
134
  // this directly - it applies the app's configured chain order
198
135
  verified, // boolean - true once the server has confirmed the session
136
+ hasWallet, // boolean - false until createWallet() runs on an app that creates wallets on demand
137
+ createWallet, // (options?: { custody? }) => Promise<WalletInfo> (custody: the user's pick under USER_CHOICE)
199
138
 
200
139
  // App config (the remote /config fetch behind the login modal)
201
140
  configStatus, // 'loading' | 'ready' | 'error'
202
141
  retryConfig, // () => void - re-runs the fetch after an error
203
142
 
204
143
  // Client escape hatch
205
- getClient, // () => PollarClient - for getUserProfile(), listSessions(), …
144
+ getClient, // () => PollarClient - for getUserProfile(), listSessions(), ...
206
145
 
207
146
  // Auth
208
147
  login, // (options: PollarLoginOptions) => void
@@ -213,6 +152,20 @@ const {
213
152
  sessions, // SessionsState
214
153
  openSessionsModal, // () => void
215
154
 
155
+ // Co-signed wallets (Turnkey)
156
+ cosign, // CosignState - requests waiting for this device's vote
157
+ openCosignModal, // () => void (also opens by itself when a request arrives)
158
+ setCosignNextStep, // (next: string | null) => void - keeps the prompt open for a flow's next approval
159
+ recovery, // RecoveryState | null
160
+ recoveryLocked, // boolean - true while the wallet cannot be recovered without this device
161
+ refreshRecovery, // () => void
162
+ openRecoveryModal, // () => void (passkeys, email, devices, recovery phrase)
163
+ custodyMigration, // CustodyMigrationState | null - while `required`, the provider shows the move to Turnkey
164
+ refreshCustodyMigration, // () => void
165
+
166
+ // Signature confirmation
167
+ confirmations, // PendingConfirmation[] - signing calls waiting under confirmation: 'prompt'; the provider shows the first
168
+
216
169
  // Transactions
217
170
  tx, // TransactionState
218
171
  buildTx, // (operation, params, options?) => Promise<BuildOutcome>
@@ -226,7 +179,7 @@ const {
226
179
 
227
180
  // Transaction history
228
181
  txHistory, // TxHistoryState
229
- openTxHistoryModal, // () => void
182
+ openTxHistoryModal, // (options?: TxHistoryModalOptions) => void
230
183
 
231
184
  // Wallet balance
232
185
  walletBalance, // WalletBalanceState
@@ -241,25 +194,31 @@ const {
241
194
 
242
195
  // Swap (DEX/AMM)
243
196
  getSwapQuote, // (params: SwapQuoteParams) => Promise<SwapQuote[]>
244
- swap, // (quote: SwapQuote, opts?) => Promise<SubmitOutcome>
197
+ swap, // (quote: SwapQuote, opts?: { autoTrustline? }) => Promise<SubmitOutcome>
245
198
  getSwapConfig, // () => Promise<SwapVenue[]> (which venues this app offers)
246
199
  getSwapTokens, // () => Promise<SwapToken[]>
247
- openSwapModal, // () => void
200
+ getSolanaSwapConfig, // () => Promise<SolanaSwapVenue[]> (Jupiter, Titan; mainnet)
201
+ getSolanaSwapQuote, // (params: SolanaSwapQuoteParams) => Promise<SolanaSwapQuote[]>
202
+ swapSolana, // (quote: SolanaSwapQuote, opts?: { slippageBps? }) => Promise<SubmitOutcome>
203
+ openSwapModal, // (options?: SwapModalOptions) => void
248
204
 
249
- // Earn (yield vaults + lending — DeFindex + Blend)
205
+ // Earn (yield vaults + lending - DeFindex + Blend)
250
206
  getEarnProviders, // () => Promise<EarnProviderId[]> ([] means Earn is disabled)
251
207
  getEarnOpportunities, // (provider: EarnProviderId) => Promise<EarnOpportunity[]>
252
208
  getEarnPosition, // (params: EarnPositionParams) => Promise<EarnPosition>
253
209
  earnDeposit, // (params: EarnTxParams) => Promise<SubmitOutcome>
254
210
  earnWithdraw, // (params: EarnTxParams) => Promise<SubmitOutcome>
255
- openEarnModal, // () => void
211
+ openEarnModal, // (options?: EarnModalOptions) => void
212
+
213
+ // Cards (the card calls live on getClient(): getCardProviders, issueCard, fundCard, ...)
214
+ openCardModal, // (options?: CardModalOptions) => void
256
215
 
257
216
  // Distribution rules
258
217
  openDistributionRulesModal, // () => void
259
218
 
260
219
  // Send / Receive
261
- openSendModal, // () => void
262
- openReceiveModal, // () => void
220
+ openSendModal, // (options?: SendModalOptions) => void
221
+ openReceiveModal, // (options?: ReceiveModalOptions) => void
263
222
 
264
223
  // Network
265
224
  network, // StellarNetwork - 'mainnet' | 'testnet'
@@ -269,7 +228,7 @@ const {
269
228
  openKycModal, // (options?: { corridorId?, providerId?, country?, level?, onApproved? }) => void
270
229
 
271
230
  // Ramp (fiat on/off-ramps on the v3 ramps API, wired through core)
272
- openRampModal, // () => void
231
+ openRampModal, // (options?: RampModalOptions) => void
273
232
 
274
233
  // App config / styles served by the Pollar API
275
234
  appConfig, // PollarConfig
@@ -283,6 +242,60 @@ const {
283
242
  Custody is derived from `wallet`, not a separate field - e.g.
284
243
  `wallet?.custody === 'external' ? wallet.provider : null`.
285
244
 
245
+ #### Ramp options
246
+
247
+ `openRampModal()` opens the ramp widget on its defaults. `openRampModal(options)` opens it on a direction, country,
248
+ fiat, asset and amount; the user can still change each one.
249
+
250
+ ```ts
251
+ import type { RampModalOptions } from '@pollar/react';
252
+
253
+ openRampModal({ country: 'BR', direction: flow === 'withdraw' ? 'sell' : 'buy' });
254
+ openRampModal({ direction: 'buy', country: 'MX', fiat: 'MXN', asset: 'USDC', amount: '500' });
255
+ ```
256
+
257
+ | Option | Type | Description |
258
+ | ----------- | ----------------- | -------------------------------------------------------------------- |
259
+ | `direction` | `'buy' \| 'sell'` | Buy (on-ramp) or sell (off-ramp). Defaults to `'buy'` |
260
+ | `country` | `string` | ISO 3166-1 alpha-2, e.g. `'BR'` |
261
+ | `fiat` | `string` | Currency code, e.g. `'BRL'`. Defaults to the country's first fiat |
262
+ | `asset` | `string` | Asset code, e.g. `'USDC'`. Defaults to the first asset for that fiat |
263
+ | `amount` | `string` | A plain decimal, e.g. `'100'` or `'12.5'`; anything else is left out |
264
+
265
+ A country that does not route in the requested direction, or that the app does not offer, opens on the widget's default
266
+ country, without the fiat, asset or amount; a fiat or asset the country does not offer opens on the country's first one.
267
+ Nothing is thrown. The options wait for the routes when they are still loading. Each call starts over: opening again
268
+ with other options, or with none, drops the earlier ones. `<RampWidget initial={options}>` takes the same options.
269
+
270
+ #### Modal options
271
+
272
+ The other `open*Modal` actions take options the same way: the modal opens on them and the user can still change each
273
+ one. An option the app or wallet cannot use (a network the app does not offer, an asset the wallet does not hold, a
274
+ provider that is not enabled, an amount that is not a plain decimal) is left out and that field opens on its default;
275
+ nothing is thrown. An option whose data is still loading is applied when it arrives. Each call starts over: opening
276
+ again with other options, or with none, drops the earlier ones. Every type is exported from `@pollar/react`, and each
277
+ modal takes the same options as its `initial` prop.
278
+
279
+ ```ts
280
+ openSendModal({ asset: 'USDC', destination: 'G...', amount: '25', memo: 'order-1042', onSuccess: ({ hash }) => save(hash) });
281
+ openSwapModal({ sell: 'XLM', buy: 'USDC', amount: '100' });
282
+ openEarnModal({ provider: 'blend', tab: 'withdraw' });
283
+ openReceiveModal({ chain: 'SOLANA' });
284
+ openCardModal({ panel: 'fund', amount: '50', onFunded: (funding) => track(funding.id) });
285
+ ```
286
+
287
+ | Action | Options |
288
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------ |
289
+ | `openSendModal` | `chain`, `asset` (code), `destination`, `amount`, `memo`, `memoType` (`'text' \| 'id' \| 'hash'`), `onSuccess({ hash })` |
290
+ | `openSwapModal` | `chain` (`'STELLAR' \| 'SOLANA'`), `sell` (code), `buy` (code), `amount`, `onSuccess({ hash })` |
291
+ | `openEarnModal` | `provider`, `opportunityId`, `tab` (`'deposit' \| 'withdraw'`), `amount`, `onSuccess({ hash })` |
292
+ | `openReceiveModal` | `chain` |
293
+ | `openTxHistoryModal` | `chain` |
294
+ | `openCardModal` | `panel: 'fund'` (opens the funding panel once the user's card loads), `amount`, `chain`, `onFunded(funding)` |
295
+
296
+ `onSuccess` is called once per transaction that lands while the modal is open; `onFunded` with each funding the user
297
+ sends from the card modal. A Solana or Polygon send takes `amount` in the asset's decimals, as the form shows it.
298
+
286
299
  #### Login options
287
300
 
288
301
  ```ts
@@ -290,7 +303,7 @@ Custody is derived from `wallet`, not a separate field - e.g.
290
303
  login({ provider: 'google' });
291
304
  login({ provider: 'github' });
292
305
 
293
- // Email OTP
306
+ // Email OTP (the code input accepts a code the browser or keyboard autofills, or a paste)
294
307
  login({ provider: 'email', email: 'user@example.com' });
295
308
 
296
309
  // Built-in Stellar wallet adapters (the adapter's `type` IS the provider)
@@ -311,7 +324,7 @@ The login modal is gated on the remote app-config fetch. While it runs the modal
311
324
  driving `<LoginModalTemplate>` yourself. Passing `appConfig` to `<PollarProvider>` opts out of the fetch entirely, so
312
325
  neither state can occur.
313
326
 
314
- #### Self-driving interactive adapters (Privy, …)
327
+ #### Self-driving interactive adapters (Privy, ...)
315
328
 
316
329
  Registered adapters that opt into the interactive-auth contract
317
330
  (`isInteractiveAuthAdapter` + `onProviderAuthChange`) are auto-driven by the
@@ -334,7 +347,7 @@ provider:
334
347
  The single source of truth for "which chains, in what order, and which address to
335
348
  show". Every built-in component (`<WalletButton>`, the network pickers) reads from
336
349
  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 —
350
+ own wallet button or picker instead of calling `chainsOf(wallets)` yourself -
338
351
  `chainsOf` alone cannot know the app's configured order.
339
352
 
340
353
  ```ts
@@ -348,7 +361,7 @@ const { chains, primaryChain, primaryAddress, ready } = useChains();
348
361
  | `chains` | `WalletChain[]` | Chains to offer, in the app's configured order: those the app serves **and** the user holds. `[]` until config resolves |
349
362
  | `primaryChain` | `WalletChain \| null` | The app's first configured chain the user holds. `null` until ready |
350
363
  | `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 |
364
+ | `ready` | `boolean` | `false` while `/config` is loading or failed - gate any chain UI on it |
352
365
 
353
366
  The order and membership come from the app's `/applications/config`
354
367
  (`appConfig.application.chains`), not from the session's `wallets`: a chain the app
@@ -357,32 +370,70 @@ session still carries it.
357
370
 
358
371
  ---
359
372
 
373
+ ### Language
374
+
375
+ Every modal, shared block (footer, copy button, amount field, pickers) and exported template speaks English (`en`),
376
+ Spanish (`es`) and Portuguese (`pt`). The language is, in this order:
377
+
378
+ 1. The language the app pins in the dashboard (Branding > Language, served as `styles.language`).
379
+ 2. The `language` prop of `<RampWidget>`, `<KycModal>`, `<RequirementFormModal>`, `<RegistryCheckModal>` or
380
+ `<ProviderRegistrationModal>`, a BCP 47 tag.
381
+ 3. The `language` prop of `<PollarProvider>`, a BCP 47 tag.
382
+ 4. The client's `locale` (`client={{ apiKey, locale: 'pt-BR' }}`, or `client.setLocale(tag)` later), any BCP 47 tag.
383
+ 5. The browser language.
384
+
385
+ An app whose language changes at runtime passes it to the provider, and every open or later modal follows it without
386
+ remounting anything:
387
+
388
+ ```tsx
389
+ <PollarProvider client={{ apiKey }} language={i18n.language}>
390
+ ```
391
+
392
+ `getClient().setLocale(tag)` does the same from outside React; `config.locale` is the starting value.
393
+
394
+ A tag the modals have no translation for is skipped, and English is the fallback. Every exported template takes a
395
+ `language` prop (`PollarLanguage` from `@pollar/core`: `'en' | 'es' | 'pt'`); a template rendered inside the provider
396
+ follows the provider's language, and one rendered outside it uses the browser's.
397
+
398
+ ---
399
+
360
400
  ### Components
361
401
 
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.
402
+ Every modal mounts itself when its `openXModal()` action is called. You don't need to render these directly - they're
403
+ already wired inside `<PollarProvider>` - and most are exported in case you want to mount them yourself.
364
404
 
365
405
  > Two wrappers are **not** exported: `<TxHistoryModal>` and `<TransactionModal>`. Only their templates
366
406
  > (`TxHistoryModalTemplate` / `TransactionModalTemplate`) are public. Mount those instead if you need to drive them
367
407
  > 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 |
408
+ >
409
+ > The provider also shows three prompts by itself, with no opener: `<ConfirmModal>` (internal) for a signing call
410
+ > waiting under `confirmation: 'prompt'`, including a Soroban token transfer (`kind: 'sign_auth_entry'`) with its
411
+ > destination, amount and asset; `<CosignModal>` when a co-signed wallet has a request for this device; and
412
+ > `<CustodyMigrationModal>` while `custodyMigration.required` asks to move a custodial wallet to Turnkey.
413
+
414
+ | Component | Purpose |
415
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
416
+ | `<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 |
417
+ | `<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 |
418
+ | `<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 |
419
+ | `<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 |
420
+ | `<ReceiveModal>` | Wallet address as QR code with copy-to-clipboard (no external QR dependency required) |
421
+ | `<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 |
422
+ | `<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 |
423
+ | `<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) |
424
+ | `<DistributionRulesModal>` | Manage the wallet's distribution rules |
425
+ | `<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 |
426
+ | `<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 |
427
+ | `<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 |
428
+ | `<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` |
429
+ | `<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 |
430
+ | `<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 |
431
+ | `<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 |
432
+ | `<RecoveryModal>` | Opened with `openRecoveryModal()`: the recovery methods of a Turnkey wallet (passkeys, email, devices, recovery phrase) |
433
+ | `<CosignModal>` | The approval prompt of a co-signed wallet. Enables Approve only after the request verifies against Turnkey |
434
+ | `<CustodyMigrationModal>` | Moves a custodial wallet to Turnkey after login when the app keeps its wallets there (`state`, `onMoved`, `onLater` props) |
435
+ | `<KycStatus>` | A KYC status badge (`status`, optional `label`) |
436
+ | `<RouteDisplay>` / `<RejectedRouteDisplay>` | One ramp route, offered or refused, as the ramp widget lists it |
386
437
 
387
438
  ```tsx
388
439
  import { WalletButton } from '@pollar/react';
@@ -396,9 +447,9 @@ export function Header() {
396
447
 
397
448
  ### Template components
398
449
 
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.)
450
+ Almost every modal ships a pure presentational "template" companion - same name with a `Template` suffix. Use these when
451
+ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<EarnModal>`, `<CardModal>`, `<RequirementFormModal>`,
452
+ `<RegistryCheckModal>` and `<ProviderRegistrationModal>` are the exceptions: they have no template.)
402
453
 
403
454
  > The enabled-assets template requires `chains`, `selectedChain` and `onSelectChain`; the wallet-balance, send and
404
455
  > receive templates require `selectedChain` and take `chains` / `onSelectChain` as optional - pass both to show the
@@ -422,16 +473,19 @@ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<Earn
422
473
  | `<KycModal>` | `<KycModalTemplate>` |
423
474
  | `<RampWidget>` | `<RampWidgetTemplate>` |
424
475
  | `<SessionsModal>` | `<SessionsModalTemplate>` |
476
+ | `<CosignModal>` | `<CosignModalTemplate>` |
477
+ | `<RecoveryModal>` | `<RecoveryModalTemplate>` |
478
+ | `<CustodyMigrationModal>` | `<CustodyMigrationModalTemplate>` |
425
479
 
426
- `<TxStatusView>` is the shared status component (build → sign → success/error) reused by `TransactionModal` and
427
- `SendModal`; it's exported on its own for consumers that want to embed the lifecycle elsewhere.
480
+ `<TxStatusView>` is the shared status component (build -> sign -> success/error) reused by `TransactionModal` and
481
+ `SendModal`; it's exported on its own for consumers that want to embed the lifecycle elsewhere. It shows the same
482
+ review as `<ConfirmModal>` and `<CosignModal>`: the asset and chain logos with the sender and recipient, the fee badge
483
+ once the platform reports who paid, and "Show details".
428
484
 
429
485
  > `onWalletConnect` is **optional** on `<LoginModalTemplate>` (defaults to a no-op).
430
486
 
431
487
  > `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
488
+ > `<WalletButtonTemplate>`. Render it when it is present: it is the sentence for a Stellar account the platform is still creating, and
435
489
  > without it a custom Send lets the user build a payment the server will refuse
436
490
  > (`SDK_WALLET_NOT_READY`). To phrase it yourself, call the exported
437
491
  > `walletNotReadyReason(wallet, chain)`. It gates on `STELLAR` and on the ACCOUNT only, so a
@@ -443,41 +497,72 @@ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<Earn
443
497
  ### Custom adapters
444
498
 
445
499
  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.
500
+ receives params and returns either an unsigned transaction or a Soroban auth entry to sign; Pollar handles the
501
+ signing (and, for a transaction, the submission).
447
502
 
448
503
  ```tsx
449
504
  import type { PollarAdapter } from '@pollar/core';
450
505
 
451
- const trustlessWork: PollarAdapter = {
452
- initialize: async (params) => ({ unsignedTransaction: '…' }),
453
- release: async (params) => ({ unsignedTransaction: '…' }),
454
- };
506
+ const trustlessWork = {
507
+ initialize: async (params: InitializeParams) => ({ unsignedTransaction: '...' }),
508
+ release: async (params: ReleaseParams) => ({ unsignedTransaction: '...' }),
509
+ } satisfies PollarAdapter;
455
510
 
456
511
  <PollarProvider client={{ apiKey }} adapters={{ trustlessWork }}>
457
- …
512
+ ...
458
513
  </PollarProvider>;
459
514
  ```
460
515
 
461
516
  #### `createPollarAdapterHook(key)`
462
517
 
463
- Factory that generates a fully-typed hook mirroring an adapter's API with automatic XDR signing built in:
518
+ Factory that generates a fully-typed hook mirroring an adapter's API with signing built in:
464
519
 
465
- ```ts
520
+ ```tsx
466
521
  import { createPollarAdapterHook } from '@pollar/react';
467
522
 
468
523
  const useTrustlessWork = createPollarAdapterHook<typeof trustlessWork>('trustlessWork');
469
524
 
470
- function MyComponent() {
525
+ function ReleaseButton() {
471
526
  const tw = useTrustlessWork();
472
- await tw.initialize({
473
- /* … */
474
- }); // unsigned XDR is built, signed, and submitted automatically
527
+ // The adapter builds the XDR; the hook signs and submits it and resolves with a SubmitOutcome.
528
+ return (
529
+ <button
530
+ onClick={() =>
531
+ tw.release({
532
+ /* ... */
533
+ })
534
+ }
535
+ >
536
+ Release
537
+ </button>
538
+ );
475
539
  }
476
540
  ```
477
541
 
542
+ #### Auth-entry steps
543
+
544
+ When someone else submits the call and pays its fee (an x402 facilitator, a contract that sponsors the gas), an
545
+ adapter function answers `{ unsignedAuthEntry, validUntilLedger, complete }` instead of `{ unsignedTransaction }`.
546
+ The hook signs the entry with the user's wallet through `signAuthEntry` (the app's allowlist, the validity window,
547
+ the signature confirmation, a co-signed wallet's vote), submits nothing, and passes the signed entry to `complete`.
548
+ The call resolves with `{ status: 'completed', result }`, where `result` is what `complete` returned, or with the
549
+ signing outcome that stopped it (`{ status: 'cosign_pending', request }` or `{ status: 'error', code?, details? }`).
550
+
551
+ ```ts
552
+ const x402 = {
553
+ pay: async (params: PayParams) => ({
554
+ unsignedAuthEntry: entryXdr, // base64 XDR of the unsigned SorobanAuthorizationEntry
555
+ validUntilLedger, // within the app's validity window
556
+ complete: async (signedAuthEntry: string) => submitToFacilitator(signedAuthEntry),
557
+ }),
558
+ } satisfies PollarAdapter;
559
+ ```
560
+
561
+ `isAuthEntryAdapterStep` and `completeAuthEntryStep` (from `@pollar/core`) run the same step outside React.
562
+
478
563
  ---
479
564
 
480
- ### External wallet stacks (Stellar Wallets Kit, …)
565
+ ### External wallet stacks (Stellar Wallets Kit, ...)
481
566
 
482
567
  Register adapters for wallets that live outside `@pollar/core` by passing a
483
568
  `walletAdapters: WalletAdapter[]` array. `LoginModal` auto-renders one button per
@@ -504,7 +589,7 @@ import { Networks } from '@creit.tech/stellar-wallets-kit';
504
589
 
505
590
  Each adapter's `meta.group` controls placement: adapters sharing a group label
506
591
  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
592
+ while adapters with no group - e.g. Privy - render as their own button in the
508
593
  root view. Pass `picker.groupLabel` to give the kit wallets a distinct gateway.
509
594
 
510
595
  ---
@@ -536,13 +621,20 @@ import type {
536
621
  PollarAuthProvider,
537
622
  AuthProviderContext,
538
623
 
539
- // Network picker
624
+ // Network picker and co-signing
540
625
  ChainSelectProps,
541
626
  UseChainsResult,
627
+ UseCosignResult,
628
+
629
+ // Modal theming
630
+ ModalStyleOverrides,
631
+ ModalVariant,
632
+ ModalChrome,
542
633
 
543
634
  // Template props
544
635
  WalletButtonTemplateProps,
545
636
  SendModalTemplateProps,
637
+ SendMemoType,
546
638
  SwapModalTemplateProps,
547
639
  SwapAssetOption,
548
640
  ReceiveModalTemplateProps,
@@ -550,8 +642,13 @@ import type {
550
642
  TxStatusViewProps,
551
643
  WalletBalanceModalTemplateProps,
552
644
  EnabledAssetsModalTemplateProps,
645
+ CustomTrustlineModalTemplateProps,
553
646
  SessionsModalTemplateProps,
554
647
  SessionsState,
648
+ CosignModalTemplateProps,
649
+ RecoveryModalTemplateProps,
650
+ RecoveryView,
651
+ CustodyMigrationModalTemplateProps,
555
652
 
556
653
  // Step unions
557
654
  KycStep,
@@ -560,7 +657,8 @@ import type {
560
657
  ```
561
658
 
562
659
  The state types (`TransactionState`, `TxHistoryState`, `WalletBalanceState`, `NetworkState`, `AuthState`,
563
- `PollarPersistedSession`, `PollarUserProfile`, `SessionInfo`, …) are re-exported from `@pollar/core`.
660
+ `CosignState`, `RecoveryState`, `PendingConfirmation`, `PollarPersistedSession`, `PollarUserProfile`, `SessionInfo`,
661
+ `PollarLanguage`, ...) are exported by `@pollar/core`; import them from there.
564
662
 
565
663
  ---
566
664