@pollar/react 0.12.1-rc.5 → 0.12.1-rc.7

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
@@ -6,11 +6,17 @@ Stellar and Solana applications.
6
6
  > **0.12.1** (requires `@pollar/core@^0.12.1`). Every modal and exported template speaks English, Spanish and
7
7
  > Portuguese (see [Language](#language)). `<SwapModal>` swaps on Solana too, with a Network selector when the app has
8
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
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
10
12
  > with `showIf` only while the answer it depends on matches. `<CardModal>` copies the number, expiry date and CVC,
11
13
  > offers a network picker when the user holds a wallet on Stellar and Solana, and funds the card from a co-signed
12
14
  > wallet too. The email code input takes an autofilled one-time code. The ramp widget says a route's minimum or
13
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.
14
20
  > A hook built with `createPollarAdapterHook` signs the auth entry an adapter answers with, without submitting
15
21
  > anything, and hands it to the adapter's `complete`.
16
22
  >
@@ -106,6 +112,7 @@ Context provider that initialises the Pollar client and makes it available to ch
106
112
  | Prop | Type | Required | Description |
107
113
  | ------------------ | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
108
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) |
109
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) |
110
117
  | `adapters` | `PollarAdapters` | No | Named set of `PollarAdapter` objects (e.g. Trustless Work). See [Custom adapters](#custom-adapters) |
111
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 |
@@ -172,7 +179,7 @@ const {
172
179
 
173
180
  // Transaction history
174
181
  txHistory, // TxHistoryState
175
- openTxHistoryModal, // () => void
182
+ openTxHistoryModal, // (options?: TxHistoryModalOptions) => void
176
183
 
177
184
  // Wallet balance
178
185
  walletBalance, // WalletBalanceState
@@ -193,7 +200,7 @@ const {
193
200
  getSolanaSwapConfig, // () => Promise<SolanaSwapVenue[]> (Jupiter, Titan; mainnet)
194
201
  getSolanaSwapQuote, // (params: SolanaSwapQuoteParams) => Promise<SolanaSwapQuote[]>
195
202
  swapSolana, // (quote: SolanaSwapQuote, opts?: { slippageBps? }) => Promise<SubmitOutcome>
196
- openSwapModal, // () => void
203
+ openSwapModal, // (options?: SwapModalOptions) => void
197
204
 
198
205
  // Earn (yield vaults + lending - DeFindex + Blend)
199
206
  getEarnProviders, // () => Promise<EarnProviderId[]> ([] means Earn is disabled)
@@ -201,17 +208,17 @@ const {
201
208
  getEarnPosition, // (params: EarnPositionParams) => Promise<EarnPosition>
202
209
  earnDeposit, // (params: EarnTxParams) => Promise<SubmitOutcome>
203
210
  earnWithdraw, // (params: EarnTxParams) => Promise<SubmitOutcome>
204
- openEarnModal, // () => void
211
+ openEarnModal, // (options?: EarnModalOptions) => void
205
212
 
206
213
  // Cards (the card calls live on getClient(): getCardProviders, issueCard, fundCard, ...)
207
- openCardModal, // () => void
214
+ openCardModal, // (options?: CardModalOptions) => void
208
215
 
209
216
  // Distribution rules
210
217
  openDistributionRulesModal, // () => void
211
218
 
212
219
  // Send / Receive
213
- openSendModal, // () => void
214
- openReceiveModal, // () => void
220
+ openSendModal, // (options?: SendModalOptions) => void
221
+ openReceiveModal, // (options?: ReceiveModalOptions) => void
215
222
 
216
223
  // Network
217
224
  network, // StellarNetwork - 'mainnet' | 'testnet'
@@ -221,7 +228,7 @@ const {
221
228
  openKycModal, // (options?: { corridorId?, providerId?, country?, level?, onApproved? }) => void
222
229
 
223
230
  // Ramp (fiat on/off-ramps on the v3 ramps API, wired through core)
224
- openRampModal, // () => void
231
+ openRampModal, // (options?: RampModalOptions) => void
225
232
 
226
233
  // App config / styles served by the Pollar API
227
234
  appConfig, // PollarConfig
@@ -235,6 +242,60 @@ const {
235
242
  Custody is derived from `wallet`, not a separate field - e.g.
236
243
  `wallet?.custody === 'external' ? wallet.provider : null`.
237
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
+
238
299
  #### Login options
239
300
 
240
301
  ```ts
@@ -312,13 +373,23 @@ session still carries it.
312
373
  ### Language
313
374
 
314
375
  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:
376
+ Spanish (`es`) and Portuguese (`pt`). The language is, in this order:
316
377
 
317
378
  1. The language the app pins in the dashboard (Branding > Language, served as `styles.language`).
318
379
  2. The `language` prop of `<RampWidget>`, `<KycModal>`, `<RequirementFormModal>`, `<RegistryCheckModal>` or
319
380
  `<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.
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.
322
393
 
323
394
  A tag the modals have no translation for is skipped, and English is the fallback. Every exported template takes a
324
395
  `language` prop (`PollarLanguage` from `@pollar/core`: `'en' | 'es' | 'pt'`); a template rendered inside the provider
@@ -407,7 +478,9 @@ you want to swap the chrome but keep the data wiring from `usePollar()`. (`<Earn
407
478
  | `<CustodyMigrationModal>` | `<CustodyMigrationModalTemplate>` |
408
479
 
409
480
  `<TxStatusView>` is the shared status component (build -> sign -> success/error) reused by `TransactionModal` and
410
- `SendModal`; it's exported on its own for consumers that want to embed the lifecycle elsewhere.
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".
411
484
 
412
485
  > `onWalletConnect` is **optional** on `<LoginModalTemplate>` (defaults to a no-op).
413
486
 
package/dist/index.css CHANGED
@@ -3140,6 +3140,131 @@
3140
3140
  }
3141
3141
  }
3142
3142
 
3143
+ /* src/components/bridge-modal/BridgeModal.css */
3144
+ .pollar-bridge-form,
3145
+ .pollar-bridge-transfer {
3146
+ display: flex;
3147
+ flex-direction: column;
3148
+ gap: 0.875rem;
3149
+ }
3150
+ .pollar-bridge-chains {
3151
+ display: flex;
3152
+ align-items: flex-end;
3153
+ gap: 0.5rem;
3154
+ }
3155
+ .pollar-bridge-chains .pollar-bridge-field {
3156
+ flex: 1;
3157
+ min-width: 0;
3158
+ }
3159
+ .pollar-bridge-arrow {
3160
+ padding-bottom: 0.7rem;
3161
+ color: var(--pollar-muted, #6b7280);
3162
+ }
3163
+ .pollar-bridge-field {
3164
+ display: flex;
3165
+ flex-direction: column;
3166
+ gap: 0.375rem;
3167
+ }
3168
+ .pollar-bridge-label,
3169
+ .pollar-bridge-balance {
3170
+ font-size: 0.8125rem;
3171
+ color: var(--pollar-muted, #6b7280);
3172
+ }
3173
+ .pollar-bridge-label-row {
3174
+ display: flex;
3175
+ align-items: center;
3176
+ justify-content: space-between;
3177
+ gap: 0.5rem;
3178
+ }
3179
+ .pollar-bridge-balance {
3180
+ display: inline-flex;
3181
+ align-items: center;
3182
+ gap: 0.375rem;
3183
+ }
3184
+ .pollar-bridge-max {
3185
+ border: 0;
3186
+ background: none;
3187
+ padding: 0;
3188
+ font-size: 0.8125rem;
3189
+ font-weight: 600;
3190
+ color: var(--pollar-accent, #2563eb);
3191
+ cursor: pointer;
3192
+ }
3193
+ .pollar-bridge-quote {
3194
+ display: flex;
3195
+ flex-direction: column;
3196
+ gap: 0.375rem;
3197
+ margin: 0;
3198
+ padding: 0.75rem;
3199
+ border-radius: var(--pollar-input-border-radius, 0.5rem);
3200
+ background-color: var(--pollar-input-bg);
3201
+ }
3202
+ .pollar-bridge-quote > div {
3203
+ display: flex;
3204
+ justify-content: space-between;
3205
+ gap: 0.5rem;
3206
+ font-size: 0.875rem;
3207
+ }
3208
+ .pollar-bridge-quote dt {
3209
+ color: var(--pollar-muted, #6b7280);
3210
+ }
3211
+ .pollar-bridge-quote dd {
3212
+ margin: 0;
3213
+ font-weight: 600;
3214
+ text-align: right;
3215
+ }
3216
+ .pollar-bridge-note {
3217
+ margin: 0;
3218
+ font-size: 0.8125rem;
3219
+ color: var(--pollar-muted, #6b7280);
3220
+ }
3221
+ .pollar-bridge-status strong {
3222
+ display: block;
3223
+ font-size: 1rem;
3224
+ }
3225
+ .pollar-bridge-status p {
3226
+ margin: 0.25rem 0 0;
3227
+ font-size: 0.875rem;
3228
+ color: var(--pollar-muted, #6b7280);
3229
+ }
3230
+ .pollar-bridge-steps {
3231
+ display: flex;
3232
+ flex-direction: column;
3233
+ gap: 0.5rem;
3234
+ margin: 0;
3235
+ padding: 0;
3236
+ list-style: none;
3237
+ font-size: 0.875rem;
3238
+ }
3239
+ .pollar-bridge-step {
3240
+ display: flex;
3241
+ align-items: center;
3242
+ gap: 0.5rem;
3243
+ color: var(--pollar-muted, #6b7280);
3244
+ }
3245
+ .pollar-bridge-step-done {
3246
+ color: inherit;
3247
+ }
3248
+ .pollar-bridge-step-dot {
3249
+ width: 0.625rem;
3250
+ height: 0.625rem;
3251
+ border-radius: 999px;
3252
+ border: 2px solid currentColor;
3253
+ }
3254
+ .pollar-bridge-step-done .pollar-bridge-step-dot {
3255
+ background-color: var(--pollar-accent, #2563eb);
3256
+ border-color: var(--pollar-accent, #2563eb);
3257
+ }
3258
+ .pollar-bridge-links {
3259
+ display: flex;
3260
+ flex-wrap: wrap;
3261
+ gap: 0.75rem;
3262
+ font-size: 0.8125rem;
3263
+ }
3264
+ .pollar-bridge-links a {
3265
+ color: var(--pollar-accent, #2563eb);
3266
+ }
3267
+
3143
3268
  /* src/components/earn-modal/EarnModal.css */
3144
3269
  .pollar-earn-live {
3145
3270
  color: var(--pollar-accent);