@stridge/kit 0.1.0-alpha.61 → 0.1.0-alpha.63
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/dist/_internal/deposit/driver/index.d.ts +2 -2
- package/dist/deposit/compound/index.d.ts +10 -2
- package/dist/deposit/compound/index.js +1 -1
- package/dist/deposit/widgets/index.d.ts +3 -1
- package/dist/deposit/widgets/index.js +1 -1
- package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockDriver.js +1 -1
- package/dist/drivers/stridge-mock/fixtures.d.ts +1 -1
- package/dist/drivers/stridge-mock/fixtures.js +1 -1
- package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
- package/dist/flows/deposit/driver/payloads.d.ts +136 -7
- package/dist/flows/deposit/driver/types.d.ts +44 -2
- package/dist/flows/deposit/orchestrator/controller.js +1 -1
- package/dist/flows/deposit/orchestrator/reducer.js +1 -1
- package/dist/flows/deposit/orchestrator/types.d.ts +105 -12
- package/dist/flows/deposit/shared/onramp.js +1 -1
- package/dist/flows/deposit/shared/onrampError.js +1 -0
- package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
- package/dist/flows/deposit/widgets/error-state/ErrorState.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/OnrampAmountEntry.d.ts +12 -8
- package/dist/flows/deposit/widgets/onramp-amount-entry/OnrampAmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.d.ts +4 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.slots.d.ts +7 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.slots.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.styles.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/CurrencyChip.d.ts +12 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/CurrencyChip.js +1 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/ProviderCard.d.ts +12 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/ProviderCard.js +1 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/components/ReceiveChip.js +1 -1
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/context.d.ts +14 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/onramp-amount-entry/compound/types.d.ts +12 -1
- package/dist/flows/deposit/widgets/onramp-confirm/OnrampConfirm.d.ts +2 -0
- package/dist/flows/deposit/widgets/onramp-confirm/OnrampConfirm.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.d.ts +2 -0
- package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.slots.d.ts +7 -0
- package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.slots.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/OnrampConfirm.styles.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Body.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Disclaimer.d.ts +21 -0
- package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Disclaimer.js +1 -0
- package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Summary.d.ts +2 -2
- package/dist/flows/deposit/widgets/onramp-confirm/compound/components/Summary.js +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/context.d.ts +28 -7
- package/dist/flows/deposit/widgets/onramp-confirm/compound/index.d.ts +1 -1
- package/dist/flows/deposit/widgets/onramp-confirm/compound/types.d.ts +7 -2
- package/dist/flows/deposit/widgets/onramp-currency-picker/OnrampCurrencyPicker.d.ts +39 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/OnrampCurrencyPicker.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/OnrampCurrencyPicker.d.ts +37 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/OnrampCurrencyPicker.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/OnrampCurrencyPicker.slots.d.ts +17 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/OnrampCurrencyPicker.slots.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/OnrampCurrencyPicker.styles.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Body.d.ts +6 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Body.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/CurrencyRow.d.ts +12 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/CurrencyRow.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Empty.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Header.d.ts +10 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Header.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Search.d.ts +6 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/components/Search.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/context.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/index.d.ts +3 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/index.js +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/compound/types.d.ts +48 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/onramp-currency-picker/index.js +1 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/OnrampPaymentPending.d.ts +2 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/OnrampPaymentPending.js +1 -1
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.d.ts +6 -1
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.js +1 -1
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.slots.d.ts +3 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/OnrampPaymentPending.slots.js +1 -1
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/components/Flow.d.ts +13 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/components/Flow.js +1 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/components/Flow.styles.js +1 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/context.d.ts +32 -0
- package/dist/flows/deposit/widgets/onramp-payment-pending/compound/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/OnrampProviderPicker.d.ts +38 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/OnrampProviderPicker.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/OnrampProviderPicker.d.ts +35 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/OnrampProviderPicker.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/OnrampProviderPicker.slots.d.ts +19 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/OnrampProviderPicker.slots.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/OnrampProviderPicker.styles.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/Body.d.ts +6 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/Body.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/Header.d.ts +10 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/Header.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/ProviderRow.d.ts +15 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/components/ProviderRow.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/context.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/index.d.ts +3 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/index.js +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/compound/types.d.ts +50 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/onramp-provider-picker/index.js +1 -0
- package/dist/flows/deposit/widgets/success-state/SuccessState.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.js +1 -1
- package/dist/format/index.d.ts +2 -1
- package/dist/format/index.js +1 -1
- package/dist/i18n/locales/ar.js +1 -1
- package/dist/i18n/locales/es.js +1 -1
- package/dist/i18n/locales/source-keys.d.ts +1 -1
- package/dist/icons/index.d.ts +4 -1
- package/dist/icons/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/shared/attribution/Attribution.js +1 -1
- package/dist/shared/attribution/Attribution.styles.js +1 -1
- package/dist/shared/dialog/Frame.js +1 -1
- package/dist/shared/format/formatFiat.d.ts +31 -0
- package/dist/shared/format/formatFiat.js +1 -0
- package/dist/shared/icons/BellIcon.d.ts +7 -0
- package/dist/shared/icons/BellIcon.js +1 -0
- package/dist/shared/icons/DirhamSignIcon.d.ts +16 -0
- package/dist/shared/icons/DirhamSignIcon.js +1 -0
- package/dist/shared/icons/SearchIcon.d.ts +7 -0
- package/dist/shared/icons/SearchIcon.js +1 -0
- package/dist/shared/ui/AmountInput/useAutoShrinkFontSize.js +1 -1
- package/dist/shared/ui/Checkbox/Checkbox.d.ts +47 -0
- package/dist/shared/ui/Checkbox/Checkbox.js +1 -0
- package/dist/shared/ui/Checkbox/Checkbox.slots.d.ts +12 -0
- package/dist/shared/ui/Checkbox/Checkbox.slots.js +1 -0
- package/dist/shared/ui/Checkbox/Checkbox.styles.js +1 -0
- package/dist/shared/ui/Checkbox/index.d.ts +2 -0
- package/dist/shared/ui/Checkbox/index.js +1 -0
- package/dist/shared/ui/CurrencyGlyph/CurrencyGlyph.d.ts +36 -0
- package/dist/shared/ui/CurrencyGlyph/CurrencyGlyph.js +1 -0
- package/dist/shared/ui/CurrencyGlyph/CurrencyGlyph.slots.d.ts +12 -0
- package/dist/shared/ui/CurrencyGlyph/CurrencyGlyph.slots.js +1 -0
- package/dist/shared/ui/CurrencyGlyph/CurrencyGlyph.styles.js +1 -0
- package/dist/shared/ui/CurrencyGlyph/flags.js +1 -0
- package/dist/shared/ui/CurrencyGlyph/index.d.ts +2 -0
- package/dist/shared/ui/CurrencyGlyph/index.js +1 -0
- package/dist/shared/ui/DisclosureRow/DisclosureRow.d.ts +56 -0
- package/dist/shared/ui/DisclosureRow/DisclosureRow.js +1 -0
- package/dist/shared/ui/DisclosureRow/DisclosureRow.slots.d.ts +8 -0
- package/dist/shared/ui/DisclosureRow/DisclosureRow.slots.js +1 -0
- package/dist/shared/ui/DisclosureRow/DisclosureRow.styles.js +1 -0
- package/dist/shared/ui/DisclosureRow/index.d.ts +2 -0
- package/dist/shared/ui/DisclosureRow/index.js +1 -0
- package/dist/shared/ui/FiatSymbol/FiatAmount.d.ts +32 -0
- package/dist/shared/ui/FiatSymbol/FiatAmount.js +1 -0
- package/dist/shared/ui/FiatSymbol/FiatSymbol.d.ts +30 -0
- package/dist/shared/ui/FiatSymbol/FiatSymbol.js +1 -0
- package/dist/shared/ui/FiatSymbol/index.d.ts +2 -0
- package/dist/shared/ui/FiatSymbol/index.js +1 -0
- package/dist/shared/utils/logos/resolveLogoSrc.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.styles.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/Hero.d.ts +2 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/Hero.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/StaticBand.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/types.d.ts +10 -0
- package/dist/shared/widgets/confirm-transfer/compound/components/Breakdown.js +1 -1
- package/dist/shared/widgets/error-state/compound/ErrorState.styles.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/MoreDetails.d.ts +3 -3
- package/dist/shared/widgets/error-state/compound/components/MoreDetails.js +1 -1
- package/dist/shared/widgets/success-state/compound/SuccessState.styles.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/MoreDetails.d.ts +2 -3
- package/dist/shared/widgets/success-state/compound/components/MoreDetails.js +1 -1
- package/dist/styles/index.css +118 -0
- package/dist/ui/index.d.ts +9 -1
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Entity, SettlementFailureKind, TxRef } from "../../../shared/driver/types.js";
|
|
2
|
-
import { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, ChainPayload, OnrampMethodCapability, OnrampMethodsPayload, OnrampQuotePayload, OnrampReceiveAssetPayload, OnrampSessionPayload, OnrampSessionStateName, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload } from "./payloads.js";
|
|
3
|
-
import { DepositAddressDto, GatewaySettlementDto, GatewayStartResponse, GatewayUdaDto, OnchainBalanceResponse, OnrampQuoteResponse, OnrampSessionResponse, QuoteResponse, SupportedAssetDto, SupportedAssetsResponse } from "@stridge/sdk";
|
|
2
|
+
import { AcceptedAssetPayload, AddressItemPayload, AssetPayload, BalanceItemPayload, BrandPayload, ChainPayload, OnrampCurrenciesPayload, OnrampCurrencyPayload, OnrampMethodCapability, OnrampMethodsPayload, OnrampProviderDisclaimer, OnrampProviderPayload, OnrampProviderStatus, OnrampProvidersPayload, OnrampQuotePayload, OnrampReceiveAssetPayload, OnrampSessionPayload, OnrampSessionStateName, QuoteBreakdownPayload, QuotePayload, QuoteRoutePayload, SettlementFailurePayload, SettlementPayload, SettlementPendingPayload, SettlementSuccessPayload, SourceWalletPayload, TargetPayload, WalletInfo, WalletPayload } from "./payloads.js";
|
|
3
|
+
import { DepositAddressDto, GatewaySettlementDto, GatewayStartResponse, GatewayUdaDto, OnchainBalanceResponse, OnrampFiatsResponse, OnrampQuoteResponse, OnrampSessionResponse, QuoteResponse, SupportedAssetDto, SupportedAssetsResponse } from "@stridge/sdk";
|
|
4
4
|
|
|
5
5
|
//#region src/flows/deposit/driver/types.d.ts
|
|
6
6
|
/**
|
|
@@ -68,6 +68,21 @@ interface DepositSnapshot {
|
|
|
68
68
|
* {@link DepositDriver.createOnrampSession} runs. Backed by the SDK's `OnrampSessionResponse`.
|
|
69
69
|
*/
|
|
70
70
|
onrampSession?: Entity<OnrampSessionPayload, OnrampSessionResponse, OnrampSessionResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Selectable fiat currencies for the onramp rail — the country-resolved default + the full
|
|
73
|
+
* list the currency picker renders. Optional (same back-compat rationale as
|
|
74
|
+
* {@link onrampMethods}); `idle` until {@link DepositDriver.requestOnrampCurrencies} runs, in
|
|
75
|
+
* which case the currency chip falls back to USD. Backed by the SDK's `OnrampFiatsResponse`.
|
|
76
|
+
*/
|
|
77
|
+
onrampCurrencies?: Entity<OnrampCurrenciesPayload, OnrampFiatsResponse, OnrampFiatsResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Onramp provider catalog — the active/default provider (carrying the one real quote) plus any
|
|
80
|
+
* driver-curated coming-soon rows. Optional; `idle` until
|
|
81
|
+
* {@link DepositDriver.requestOnrampProviders} runs, in which case the provider card hides. No
|
|
82
|
+
* single SDK response backs it — the backend resolves one provider server-side, so the shape is
|
|
83
|
+
* driver-defined.
|
|
84
|
+
*/
|
|
85
|
+
onrampProviders?: Entity<OnrampProvidersPayload, unknown, unknown>;
|
|
71
86
|
}
|
|
72
87
|
/**
|
|
73
88
|
* Input to {@link DepositDriver.requestQuote}.
|
|
@@ -109,6 +124,8 @@ interface SubmitDepositInput {
|
|
|
109
124
|
interface RequestOnrampQuoteInput {
|
|
110
125
|
/** Fiat amount the user wants to spend (display units, e.g. dollars). */
|
|
111
126
|
amount: number;
|
|
127
|
+
/** ISO-4217 code of the fiat currency to price in (e.g. `"USD"`, `"EUR"`). Threaded into `quote.fiatCurrency`. */
|
|
128
|
+
currency: string;
|
|
112
129
|
}
|
|
113
130
|
/**
|
|
114
131
|
* Input to {@link DepositDriver.createOnrampSession}. Binds the priced amount to a provider checkout.
|
|
@@ -116,6 +133,8 @@ interface RequestOnrampQuoteInput {
|
|
|
116
133
|
interface CreateOnrampSessionInput {
|
|
117
134
|
/** Fiat amount to charge (display units). */
|
|
118
135
|
amount: number;
|
|
136
|
+
/** ISO-4217 code of the fiat currency to charge in. Threaded into `createSession.fiatCurrency`. */
|
|
137
|
+
currency: string;
|
|
119
138
|
}
|
|
120
139
|
/**
|
|
121
140
|
* Input to {@link DepositDriver.watchOnrampSession}. Scopes the poll to a single created session.
|
|
@@ -247,6 +266,29 @@ interface DepositDriver {
|
|
|
247
266
|
* {@link requestQuote} for the fiat side.
|
|
248
267
|
*/
|
|
249
268
|
requestOnrampQuote?(input: RequestOnrampQuoteInput, signal: AbortSignal): Promise<void>;
|
|
269
|
+
/**
|
|
270
|
+
* Onramp rail — populates the `onrampMethods` capability entity (rail limit + processing time)
|
|
271
|
+
* from the country-scoped catalog. The kit fires this on onramp entry (when the user picks
|
|
272
|
+
* "Cash"), NOT on mount, so a deposit that never opens the Cash rail makes no catalog request.
|
|
273
|
+
* The rail's visibility is independent of this entity (host opt-in only); it supplies the meta
|
|
274
|
+
* line once Cash is chosen. Optional — drivers without an onramp backend omit it; a failure
|
|
275
|
+
* leaves the entity `idle`.
|
|
276
|
+
*/
|
|
277
|
+
requestOnrampMethods?(signal: AbortSignal): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* Onramp rail — populates the `onrampCurrencies` entity with the selectable fiat list (the
|
|
280
|
+
* country-resolved default + the full catalog). The kit fires this once on onramp entry; a
|
|
281
|
+
* failure leaves the entity `idle` and the currency chip falls back to USD. Optional — drivers
|
|
282
|
+
* without an onramp backend omit it. Mirrors the fire-and-forget posture of {@link requestOnrampQuote}.
|
|
283
|
+
*/
|
|
284
|
+
requestOnrampCurrencies?(signal: AbortSignal): Promise<void>;
|
|
285
|
+
/**
|
|
286
|
+
* Onramp rail — populates the `onrampProviders` entity with the active/default provider (carrying
|
|
287
|
+
* the live receive amount) plus any driver-curated coming-soon rows. The kit fires this once on
|
|
288
|
+
* onramp entry; a failure leaves the entity `idle` and the provider card hides. Optional. The
|
|
289
|
+
* backend resolves one provider server-side, so this is driver-shaped data, not a network list.
|
|
290
|
+
*/
|
|
291
|
+
requestOnrampProviders?(signal: AbortSignal): Promise<void>;
|
|
250
292
|
/**
|
|
251
293
|
* Onramp rail — binds the priced amount to a provider checkout session, populates the
|
|
252
294
|
* `onrampSession` entity, and resolves with the created session (carrying `checkoutUrl`). The kit
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{useOnrampSessionWatcher as a}from"../../../shared/orchestrator/useOnrampSessionWatcher.js";import{isUserRejectionFailure as o}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as s}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as c}from"../driver/context.js";import{openCheckoutPopup as l}from"../shared/checkoutPopup.js";import{initialState as u,reducer as d}from"./reducer.js";import{resolveAssetById as f}from"./resolveAssetById.js";import{createContext as p,use as m,useCallback as h,useEffect as g,useMemo as _,useReducer as v,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";const x={id:`ELhVSL`,message:`Failed to submit deposit.`},S={id:`Ej5HL9`,message:`Signature declined. Please try again.`},C={id:`Z0UMar`,message:`Failed to fetch quote.`},w={id:`9d3cBd`,message:`Failed to open the payment window. Please try again.`},T=p(null);T.displayName=`GatewayControllerStateContext`;const E=p(null);E.displayName=`GatewayControllerStableContext`;function D(){let e=m(T),t=m(E);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function O(){let e=m(E);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function k(){return m(E)}const A=p(void 0);A.displayName=`DepositMethodsConfigContext`;function j(){return m(A)}function M(e){let t=j();return _(()=>t?e.filter(e=>e.value===`onramp`?t.onrampRail?.disabled!==!0:!0):e,[e,t])}function N(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function P(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function F(){return O().actions}function I({methodsConfig:t,children:n}){let r=c(),a=e(),[o,s]=v(d,u),l=R(o,s,r,a);z(o,s,r),B(o,s,r,a);let f=i(o),p=L(o,s,r,l,t);return b(A,{value:t,children:b(E,{value:_(()=>({dispatch:s,controller:p,actions:l}),[s,p,l]),children:b(T,{value:_(()=>({state:o,effectiveState:f}),[o,f]),children:n})})})}function L(e,t,n,r,i){let a=y(n);a.current=n;let o=y(i);o.current=i;let s=h(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=f(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=h(()=>{t({type:`CLOSE`})},[t]);return _(()=>({open:s,close:c,actions:r}),[s,c,r])}function R(e,r,i,a){let s=y(e);s.current=e;let c=y(i);c.current=i;let l=y(a);l.current=a;let u=y(r);u.current=r;let{i18n:d}=t(),f=y(d);f.current=d;let p=h((e,t)=>{let r=c.current,i=new AbortController,a=H(e,t);r.submitDeposit(a,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(x));if(o(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(S)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),m=h(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),g=h(()=>{u.current({type:`ONRAMP_SELECTED`})},[]),v=h(e=>{s.current.name===`onrampAmountEntry`&&u.current({type:`ONRAMP_AMOUNT_CHANGED`,amount:e})},[]),b=h(e=>{u.current({type:`ONRAMP_AMOUNT_CONFIRMED`,amount:e})},[]),C=h(()=>{let e=s.current;if(e.name!==`onrampConfirm`)return;let t=e.ctx.phase;t.kind!==`ready`&&t.kind!==`failed`||u.current({type:`ONRAMP_CONFIRMED`})},[]),w=h(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),T=h(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),E=h(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),p(n,r)},[p]),D=h(()=>{u.current({type:`BACK`})},[]),O=h(()=>{u.current({type:`CLOSE`})},[]),k=h(()=>{u.current({type:`SUCCESS_DONE`})},[]),A=h(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),j=h((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),M=h((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),N=h(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),P=h(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),F=h(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return _(()=>({selectMethod:m,selectOnramp:g,setOnrampAmount:v,confirmOnrampAmount:b,confirmOnramp:C,confirmAsset:w,confirmAmount:T,confirmDeposit:E,back:D,close:O,successDone:k,tryAgain:A,resumeToProcessing:j,resumeToSuccess:M,resumeToError:N,openActivity:P,selectSettlement:F}),[m,g,v,b,C,w,T,E,D,O,k,A,j,M,N,P,F])}function z(e,r,i){let{i18n:a}=t(),o=y(a);o.current=a;let s=e.name===`onrampAmountEntry`?e.ctx.amount:void 0;g(()=>{if(e.name!==`onrampAmountEntry`||!i.requestOnrampQuote)return;let t=s;if(t==null||!Number.isFinite(t)||t<=0)return;let n=new AbortController,r=setTimeout(()=>{i.requestOnrampQuote?.({amount:t},n.signal).catch(()=>{})},400);return()=>{clearTimeout(r),n.abort()}},[e.name,s,i]);let c=e.name===`onrampConfirm`&&e.ctx.phase.kind===`loading`,u=e.name===`onrampConfirm`?e.ctx.amount:void 0;g(()=>{if(!c||!i.requestOnrampQuote||u==null)return;let e=new AbortController;return i.requestOnrampQuote({amount:u},e.signal).catch(t=>{e.signal.aborted||r({type:`ONRAMP_QUOTE_FAILED`,failure:n(t,o.current._(C))})}),()=>e.abort()},[c,u,i,r]);let d=e.name===`onrampConfirm`&&e.ctx.phase.kind===`creating`,f=e.name===`onrampConfirm`?e.ctx.amount:void 0;g(()=>{if(!d||f==null)return;if(!i.createOnrampSession){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}let e=new AbortController;return i.createOnrampSession({amount:f},e.signal).then(t=>{if(!e.signal.aborted){if(!t.checkoutUrl){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}l(t.checkoutUrl),r({type:`ONRAMP_SESSION_CREATED`,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl})}}).catch(t=>{e.signal.aborted||r({type:`ONRAMP_SESSION_FAILED`,failure:n(t,o.current._(w))})}),()=>e.abort()},[d,f,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let t=new AbortController,a=V(e.ctx.asset,e.ctx.amount);return i.requestQuote(a,t.signal).catch(e=>{t.signal.aborted||r({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>t.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let t=e.ctx.phase.quoteExpiresAt,n=Math.max(0,t-Date.now()),i=setTimeout(()=>{r({type:`QUOTE_EXPIRED`})},n);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,r])}function B(e,t,n,i){let o=y(i);o.current=i;let c=e.name===`processing`?e.ctx.tx:void 0;s(n,c?{tx:c}:void 0,c?.hash);let l=e.name===`onrampPaymentPending`?e.ctx.sessionId:void 0;a(n,l?{sessionId:l}:void 0,l),g(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{o.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let u=e.name===`activityList`||e.name===`activityDetail`;g(()=>{if(!u||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[u,i]),g(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||u||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,u,n]);let d=y(e);d.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}d.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let f=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.quote;i.status!==f.current&&(f.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}}))},r=n.subscribe(e);return e(),r},[n,t]);let p=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampQuote,a=i?.status??`idle`;a!==p.current&&(p.current=a,!(r.name!==`onrampConfirm`||r.ctx.phase.kind!==`loading`)&&(a===`ready`||a===`stale`?t({type:`ONRAMP_QUOTE_RESOLVED`}):a===`error`&&i?.status===`error`&&t({type:`ONRAMP_QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}})))},r=n.subscribe(e);return e(),r},[n,t]);let m=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampSession,a=i?.status===`ready`||i?.status===`stale`?i.payload.state:i?.status??`idle`;if(a!==m.current&&(m.current=a,r.name===`onrampPaymentPending`)){if(a===`SESSION_COMPLETED`)t({type:`ONRAMP_SESSION_COMPLETED`});else if(a===`SESSION_EXPIRED`)t({type:`ONRAMP_SESSION_EXPIRED`});else if(a===`SESSION_FAILED`){let e=i?.status===`ready`||i?.status===`stale`?i.payload.failureCode:void 0;t({type:`ONRAMP_SESSION_FAILED`,failure:{reason:e??`Payment failed.`,...e?{code:e}:{}}})}}},r=n.subscribe(e);return e(),r},[n,t])}function V(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function H(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{I as GatewayController,D as useControllerContext,F as useDepositActions,P as useDepositEffectiveState,j as useDepositMethodsConfig,N as useDepositState,M as useEnabledRails,k as useOptionalStableControllerContext,O as useStableControllerContext};
|
|
1
|
+
"use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{useOnrampSessionWatcher as a}from"../../../shared/orchestrator/useOnrampSessionWatcher.js";import{isUserRejectionFailure as o}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as s}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as c}from"../driver/context.js";import{openCheckoutPopup as l}from"../shared/checkoutPopup.js";import{initialState as u,reducer as d}from"./reducer.js";import{resolveAssetById as f}from"./resolveAssetById.js";import{createContext as p,use as m,useCallback as h,useEffect as g,useMemo as _,useReducer as v,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";const x={id:`ELhVSL`,message:`Failed to submit deposit.`},S={id:`Ej5HL9`,message:`Signature declined. Please try again.`},C={id:`Z0UMar`,message:`Failed to fetch quote.`},w={id:`9d3cBd`,message:`Failed to open the payment window. Please try again.`},T=p(null);T.displayName=`GatewayControllerStateContext`;const E=p(null);E.displayName=`GatewayControllerStableContext`;function D(){let e=m(T),t=m(E);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function O(){let e=m(E);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function k(){return m(E)}const A=p(void 0);A.displayName=`DepositMethodsConfigContext`;function j(){return m(A)}function M(e){let t=j();return _(()=>t?e.filter(e=>e.value===`onramp`?t.onrampRail?.disabled!==!0:!0):e,[e,t])}function N(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function P(){let e=m(T);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function F(){return O().actions}function I({methodsConfig:t,children:n}){let r=c(),a=e(),[o,s]=v(d,u),l=R(o,s,r,a);z(o,s,r),B(o,s,r,a);let f=i(o),p=L(o,s,r,l,t);return b(A,{value:t,children:b(E,{value:_(()=>({dispatch:s,controller:p,actions:l}),[s,p,l]),children:b(T,{value:_(()=>({state:o,effectiveState:f}),[o,f]),children:n})})})}function L(e,t,n,r,i){let a=y(n);a.current=n;let o=y(i);o.current=i;let s=h(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(e.method===`onramp`){let n=o.current?.onrampRail;return n?.enabled===!1||n?.disabled===!0?!1:(a.current.arm(),t({type:`OPEN`,input:{method:`onramp`,...e.amount===void 0?{}:{amount:e.amount},...e.currency===void 0?{}:{currency:e.currency}}}),!0)}if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=f(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=h(()=>{t({type:`CLOSE`})},[t]);return _(()=>({open:s,close:c,actions:r}),[s,c,r])}function R(e,r,i,a){let s=y(e);s.current=e;let c=y(i);c.current=i;let l=y(a);l.current=a;let u=y(r);u.current=r;let{i18n:d}=t(),f=y(d);f.current=d;let p=h((e,t)=>{let r=c.current,i=new AbortController,a=H(e,t);r.submitDeposit(a,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(x));if(o(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(S)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),m=h(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),g=h(()=>{u.current({type:`ONRAMP_SELECTED`})},[]),v=h(e=>{s.current.name===`onrampAmountEntry`&&u.current({type:`ONRAMP_AMOUNT_CHANGED`,amount:e})},[]),b=h(e=>{u.current({type:`ONRAMP_AMOUNT_CONFIRMED`,amount:e})},[]),C=h(()=>{s.current.name===`onrampAmountEntry`&&u.current({type:`ONRAMP_CURRENCY_PICKER_OPENED`})},[]),w=h(e=>{let t=s.current.name;t!==`onrampCurrencyPicker`&&t!==`onrampAmountEntry`||u.current({type:`ONRAMP_CURRENCY_SELECTED`,currency:e})},[]),T=h(()=>{s.current.name===`onrampAmountEntry`&&u.current({type:`ONRAMP_PROVIDER_PICKER_OPENED`})},[]),E=h(e=>{s.current.name===`onrampProviderPicker`&&u.current({type:`ONRAMP_PROVIDER_SELECTED`,providerId:e})},[]),D=h(()=>{let e=s.current;if(e.name!==`onrampConfirm`)return;let t=e.ctx.phase;t.kind!==`ready`&&t.kind!==`failed`||u.current({type:`ONRAMP_CONFIRMED`})},[]),O=h(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),k=h(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),A=h(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),p(n,r)},[p]),j=h(()=>{u.current({type:`BACK`})},[]),M=h(()=>{u.current({type:`CLOSE`})},[]),N=h(()=>{u.current({type:`SUCCESS_DONE`})},[]),P=h(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),F=h((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),I=h((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),L=h(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),R=h(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),z=h(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return _(()=>({selectMethod:m,selectOnramp:g,setOnrampAmount:v,confirmOnrampAmount:b,openOnrampCurrencyPicker:C,selectOnrampCurrency:w,openOnrampProviderPicker:T,selectOnrampProvider:E,confirmOnramp:D,confirmAsset:O,confirmAmount:k,confirmDeposit:A,back:j,close:M,successDone:N,tryAgain:P,resumeToProcessing:F,resumeToSuccess:I,resumeToError:L,openActivity:R,selectSettlement:z}),[m,g,v,b,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,z])}function z(e,r,i){let{i18n:a}=t(),o=y(a);o.current=a;let s=y(null),c=e.name===`onrampAmountEntry`?e.ctx.amount:void 0,u=e.name===`onrampAmountEntry`?e.ctx.currency:void 0;g(()=>{if(e.name!==`onrampAmountEntry`||!i.requestOnrampQuote)return;let t=c;if(t==null||!Number.isFinite(t)||t<=0)return;let n=u??`USD`,r=`${t}|${n}`,a=i.getSnapshot?.().onrampQuote;if(r===s.current&&(a?.status===`ready`||a?.status===`stale`))return;let o=new AbortController,l=setTimeout(()=>{s.current=r,i.requestOnrampQuote?.({amount:t,currency:n},o.signal).catch(()=>{})},400);return()=>{clearTimeout(l),o.abort()}},[e.name,c,u,i]);let d=e.name===`onrampAmountEntry`||e.name===`onrampCurrencyPicker`||e.name===`onrampProviderPicker`||e.name===`onrampConfirm`;g(()=>{if(!d)return;let e=new AbortController;return i.requestOnrampMethods?.(e.signal).catch(()=>{}),i.requestOnrampCurrencies?.(e.signal).catch(()=>{}),i.requestOnrampProviders?.(e.signal).catch(()=>{}),()=>e.abort()},[d,i]);let f=e.name===`onrampConfirm`&&e.ctx.phase.kind===`loading`,p=e.name===`onrampConfirm`?e.ctx.amount:void 0,m=e.name===`onrampConfirm`?e.ctx.currency:void 0;g(()=>{if(!f||!i.requestOnrampQuote||p==null)return;let e=new AbortController;return i.requestOnrampQuote({amount:p,currency:m??`USD`},e.signal).catch(t=>{e.signal.aborted||r({type:`ONRAMP_QUOTE_FAILED`,failure:n(t,o.current._(C))})}),()=>e.abort()},[f,p,m,i,r]);let h=e.name===`onrampConfirm`&&e.ctx.phase.kind===`creating`,_=e.name===`onrampConfirm`?e.ctx.amount:void 0,v=e.name===`onrampConfirm`?e.ctx.currency:void 0;g(()=>{if(!h||_==null)return;if(!i.createOnrampSession){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}let e=new AbortController;return i.createOnrampSession({amount:_,currency:v??`USD`},e.signal).then(t=>{if(!e.signal.aborted){if(!t.checkoutUrl){r({type:`ONRAMP_SESSION_FAILED`,failure:{reason:o.current._(w)}});return}l(t.checkoutUrl),r({type:`ONRAMP_SESSION_CREATED`,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl})}}).catch(t=>{e.signal.aborted||r({type:`ONRAMP_SESSION_FAILED`,failure:n(t,o.current._(w))})}),()=>e.abort()},[h,_,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let t=new AbortController,a=V(e.ctx.asset,e.ctx.amount);return i.requestQuote(a,t.signal).catch(e=>{t.signal.aborted||r({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>t.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,i,r]),g(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let t=e.ctx.phase.quoteExpiresAt,n=Math.max(0,t-Date.now()),i=setTimeout(()=>{r({type:`QUOTE_EXPIRED`})},n);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,r])}function B(e,t,n,i){let o=y(i);o.current=i;let c=e.name===`processing`?e.ctx.tx:void 0;s(n,c?{tx:c}:void 0,c?.hash);let l=e.name===`onrampPaymentPending`?e.ctx.sessionId:void 0;a(n,l?{sessionId:l}:void 0,l),g(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{o.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let u=e.name===`activityList`||e.name===`activityDetail`;g(()=>{if(!u||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[u,i]),g(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||u||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,u,n]);let d=y(e);d.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}d.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let f=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.quote;i.status!==f.current&&(f.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}}))},r=n.subscribe(e);return e(),r},[n,t]);let p=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampQuote,a=i?.status??`idle`;a!==p.current&&(p.current=a,!(r.name!==`onrampConfirm`||r.ctx.phase.kind!==`loading`)&&(a===`ready`||a===`stale`?t({type:`ONRAMP_QUOTE_RESOLVED`}):a===`error`&&i?.status===`error`&&t({type:`ONRAMP_QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}})))},r=n.subscribe(e);return e(),r},[n,t]);let m=y(null);g(()=>{let e=()=>{let e=n.getSnapshot(),r=d.current,i=e.onrampSession,a=i?.status===`ready`||i?.status===`stale`?i.payload.state:i?.status??`idle`;if(a!==m.current&&(m.current=a,r.name===`onrampPaymentPending`)){if(a===`SESSION_COMPLETED`)t({type:`ONRAMP_SESSION_COMPLETED`});else if(a===`SESSION_EXPIRED`)t({type:`ONRAMP_SESSION_EXPIRED`});else if(a===`SESSION_FAILED`){let e=i?.status===`ready`||i?.status===`stale`?i.payload.failureCode:void 0;t({type:`ONRAMP_SESSION_FAILED`,failure:{reason:e??`Payment failed.`,...e?{code:e}:{}}})}}},r=n.subscribe(e);return e(),r},[n,t])}function V(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function H(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{I as GatewayController,D as useControllerContext,F as useDepositActions,P as useDepositEffectiveState,j as useDepositMethodsConfig,N as useDepositState,M as useEnabledRails,k as useOptionalStableControllerContext,O as useStableControllerContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";import{assertNever as t}from"../../../shared/utils/assertNever.js";const n={name:`closed`},{reduceFromActivityList:r,reduceFromActivityDetail:i}=e({activityList:e=>({name:`activityList`,ctx:{backTarget:e}}),activityDetail:(e,t,n)=>({name:`activityDetail`,ctx:{settlementId:e,backTarget:t,viaList:n}}),closed:()=>({name:`closed`}),restoreFromBackTarget:e=>v(e)});function a(e,n){if(n.type===`RESUME_TO_PROCESSING`)return e.name===`closed`?e:{name:`processing`,ctx:{method:n.method,tx:n.tx,retryTargetForFailure:{kind:`fresh`}}};if(n.type===`RESUME_TO_SUCCESS`)return e.name===`closed`?e:{name:`success`,ctx:{method:n.method,tx:n.tx}};if(n.type===`RESUME_TO_ERROR`)return e.name===`closed`?e:{name:`error`,ctx:{retryTarget:{kind:`fresh`},...n.tx?{tx:n.tx}:{}}};switch(e.name){case`closed`:return o(n);case`deposit`:return s(e,n);case`assetPicker`:return c(e,n);case`amountEntry`:return l(e,n);case`onrampAmountEntry`:return u(e,n);case`onrampConfirm`:return d(e,n);case`onrampPaymentPending`:return f(e,n);case`confirmDeposit`:return p(e,n);case`transferCrypto`:return m(e,n);case`processing`:return h(e,n);case`success`:return g(e,n);case`error`:return _(e,n);case`activityList`:return r(e,n);case`activityDetail`:return i(e,n);default:return t(e)}}function o(e){if(e.type!==`OPEN`)return{name:`closed`};let t=e.input;return t?t.method===`transfer`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`closed`}}:t.asset?{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`closed`}}:{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`closed`}}:{name:`deposit`,ctx:{backTarget:`closed`}}}function s(e,t){switch(t.type){case`DEPOSIT_METHOD_SELECTED`:return t.method===`wallet`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`deposit`}};case`ONRAMP_SELECTED`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`deposit`,backTarget:`closed`}}};case`BACK`:case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`ASSET_CONFIRMED`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`assetPicker`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`assetPicker`,method:`wallet`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e,t){switch(t.type){case`AMOUNT_CONFIRMED`:return{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.ctx.asset,amount:t.amount,phase:{kind:`loading`},backTarget:`amountEntry`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`amountEntry`,method:`wallet`,asset:e.ctx.asset,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function u(e,t){switch(t.type){case`ONRAMP_AMOUNT_CHANGED`:return t.amount===null?{...e,ctx:{...e.ctx,amount:void 0}}:{...e,ctx:{...e.ctx,amount:t.amount}};case`ONRAMP_AMOUNT_CONFIRMED`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:t.amount,phase:{kind:`loading`},backTarget:`onrampAmountEntry`}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function d(e,t){let n=e.ctx.phase;switch(t.type){case`ONRAMP_QUOTE_RESOLVED`:return n.kind===`loading`?{...e,ctx:{...e.ctx,phase:{kind:`ready`}}}:e;case`ONRAMP_QUOTE_FAILED`:return n.kind===`loading`||n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`ONRAMP_CONFIRMED`:return n.kind===`ready`||n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`creating`}}}:e;case`ONRAMP_SESSION_CREATED`:return n.kind===`creating`?{name:`onrampPaymentPending`,ctx:{method:`onramp`,amount:e.ctx.amount,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl,backTarget:`onrampConfirm`}}:e;case`ONRAMP_SESSION_FAILED`:return n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`BACK`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`,amount:e.ctx.amount}};case`CLOSE`:return{name:`closed`};default:return e}}function f(e,t){switch(t.type){case`ONRAMP_SESSION_COMPLETED`:return{name:`success`,ctx:{method:`onramp`,sessionId:e.ctx.sessionId}};case`ONRAMP_SESSION_EXPIRED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,...t.failure?{failure:t.failure}:{}}};case`ONRAMP_SESSION_FAILED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,failure:t.failure}};case`BACK`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:e.ctx.amount,phase:{kind:`ready`},backTarget:`onrampAmountEntry`}};case`CLOSE`:return{name:`closed`};default:return e}}function p(e,t){let n=e.ctx.phase;switch(t.type){case`QUOTE_RESOLVED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`ready`,quoteExpiresAt:t.expiresAt}}}:e;case`QUOTE_FAILED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`quote`}}}:e;case`QUOTE_RETRY`:return n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`loading`}}}:e;case`QUOTE_EXPIRED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`}}}:e;case`DEPOSIT_CONFIRMED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`submitting`}}}:e;case`DEPOSIT_SUBMITTED`:if(n.kind===`submitting`){let n={kind:`confirmDepositReady`,method:`wallet`,asset:e.ctx.asset,amount:e.ctx.amount};return{name:`processing`,ctx:{method:`wallet`,tx:t.tx,retryTargetForFailure:n}}}return e;case`DEPOSIT_SUBMISSION_FAILED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`submission`}}}:e;case`DEPOSIT_SIGNATURE_DECLINED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`,...t.notice?{notice:t.notice}:{}}}}:e;case`BACK`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:e.ctx.asset,backTarget:`assetPicker`}};case`CLOSE`:return{name:`closed`};default:return e}}function m(e,t){switch(t.type){case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`transferCrypto`,method:`transfer`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function h(e,t){switch(t.type){case`PROCESSING_SUCCEEDED`:return{name:`success`,ctx:{method:e.ctx.method,tx:e.ctx.tx}};case`PROCESSING_FAILED`:return{name:`error`,ctx:{retryTarget:e.ctx.retryTargetForFailure,tx:e.ctx.tx}};case`CLOSE`:return{name:`closed`};default:return e}}function g(e,t){return t.type===`SUCCESS_DONE`||t.type===`CLOSE`?{name:`closed`}:e}function _(e,t){return t.type===`ERROR_TRY_AGAIN`?y(e.ctx.retryTarget):t.type===`CLOSE`?{name:`closed`}:e}function v(e){return e.kind===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:e.backTarget}}:e.kind===`amountEntry`?{name:`amountEntry`,ctx:{method:`wallet`,asset:e.asset,backTarget:e.backTarget}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}}function y(e){return e.kind===`fresh`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`onrampAmountEntry`?{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}}:e.kind===`transferCrypto`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}:{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.asset,amount:e.amount,phase:{kind:`loading`},backTarget:`amountEntry`}}}export{n as initialState,a as reducer};
|
|
1
|
+
import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";import{assertNever as t}from"../../../shared/utils/assertNever.js";const n={name:`closed`},{reduceFromActivityList:r,reduceFromActivityDetail:i}=e({activityList:e=>({name:`activityList`,ctx:{backTarget:e}}),activityDetail:(e,t,n)=>({name:`activityDetail`,ctx:{settlementId:e,backTarget:t,viaList:n}}),closed:()=>({name:`closed`}),restoreFromBackTarget:e=>x(e)});function a(e,n){if(n.type===`RESUME_TO_PROCESSING`)return e.name===`closed`?e:{name:`processing`,ctx:{method:n.method,tx:n.tx,retryTargetForFailure:{kind:`fresh`}}};if(n.type===`RESUME_TO_SUCCESS`)return e.name===`closed`?e:{name:`success`,ctx:{method:n.method,tx:n.tx}};if(n.type===`RESUME_TO_ERROR`)return e.name===`closed`?e:{name:`error`,ctx:{retryTarget:{kind:`fresh`},...n.tx?{tx:n.tx}:{}}};switch(e.name){case`closed`:return o(n);case`deposit`:return s(e,n);case`assetPicker`:return c(e,n);case`amountEntry`:return l(e,n);case`onrampAmountEntry`:return u(e,n);case`onrampCurrencyPicker`:return f(e,n);case`onrampProviderPicker`:return p(e,n);case`onrampConfirm`:return m(e,n);case`onrampPaymentPending`:return h(e,n);case`confirmDeposit`:return g(e,n);case`transferCrypto`:return _(e,n);case`processing`:return v(e,n);case`success`:return y(e,n);case`error`:return b(e,n);case`activityList`:return r(e,n);case`activityDetail`:return i(e,n);default:return t(e)}}function o(e){if(e.type!==`OPEN`)return{name:`closed`};let t=e.input;return t?t.method===`transfer`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`closed`}}:t.method===`onramp`?{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`closed`,...t.amount===void 0?{}:{amount:t.amount},...t.currency===void 0?{}:{currency:t.currency}}}:t.asset?{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`closed`}}:{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`closed`}}:{name:`deposit`,ctx:{backTarget:`closed`}}}function s(e,t){switch(t.type){case`DEPOSIT_METHOD_SELECTED`:return t.method===`wallet`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`deposit`}};case`ONRAMP_SELECTED`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`deposit`,backTarget:`closed`}}};case`BACK`:case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`ASSET_CONFIRMED`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`assetPicker`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`assetPicker`,method:`wallet`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e,t){switch(t.type){case`AMOUNT_CONFIRMED`:return{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.ctx.asset,amount:t.amount,phase:{kind:`loading`},backTarget:`amountEntry`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`amountEntry`,method:`wallet`,asset:e.ctx.asset,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function u(e,t){switch(t.type){case`ONRAMP_AMOUNT_CHANGED`:return t.amount===null?{...e,ctx:{...e.ctx,amount:void 0}}:{...e,ctx:{...e.ctx,amount:t.amount}};case`ONRAMP_AMOUNT_CONFIRMED`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:t.amount,phase:{kind:`loading`},backTarget:`onrampAmountEntry`,...e.ctx.currency===void 0?{}:{currency:e.ctx.currency},...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}};case`ONRAMP_CURRENCY_SELECTED`:return{...e,ctx:{...e.ctx,currency:t.currency}};case`ONRAMP_CURRENCY_PICKER_OPENED`:return{name:`onrampCurrencyPicker`,ctx:{method:`onramp`,backTarget:`onrampAmountEntry`,...e.ctx.amount===void 0?{}:{amount:e.ctx.amount},currency:e.ctx.currency??`USD`,...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}};case`ONRAMP_PROVIDER_PICKER_OPENED`:return{name:`onrampProviderPicker`,ctx:{method:`onramp`,backTarget:`onrampAmountEntry`,...e.ctx.amount===void 0?{}:{amount:e.ctx.amount},currency:e.ctx.currency??`USD`,...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function d(e,t){return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`,...e.amount===void 0?{}:{amount:e.amount},currency:t??e.currency,...e.providerId===void 0?{}:{providerId:e.providerId}}}}function f(e,t){switch(t.type){case`ONRAMP_CURRENCY_SELECTED`:return d(e.ctx,t.currency);case`BACK`:return d(e.ctx);case`CLOSE`:return{name:`closed`};default:return e}}function p(e,t){switch(t.type){case`ONRAMP_PROVIDER_SELECTED`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`,...e.ctx.amount===void 0?{}:{amount:e.ctx.amount},currency:e.ctx.currency,providerId:t.providerId}};case`BACK`:return d(e.ctx);case`CLOSE`:return{name:`closed`};default:return e}}function m(e,t){let n=e.ctx.phase;switch(t.type){case`ONRAMP_QUOTE_RESOLVED`:return n.kind===`loading`?{...e,ctx:{...e.ctx,phase:{kind:`ready`}}}:e;case`ONRAMP_QUOTE_FAILED`:return n.kind===`loading`||n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`ONRAMP_CONFIRMED`:return n.kind===`ready`||n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`creating`}}}:e;case`ONRAMP_SESSION_CREATED`:return n.kind===`creating`?{name:`onrampPaymentPending`,ctx:{method:`onramp`,amount:e.ctx.amount,sessionId:t.sessionId,checkoutUrl:t.checkoutUrl,backTarget:`onrampConfirm`,...e.ctx.currency===void 0?{}:{currency:e.ctx.currency},...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}}:e;case`ONRAMP_SESSION_FAILED`:return n.kind===`creating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure}}}:e;case`BACK`:return{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`,amount:e.ctx.amount,...e.ctx.currency===void 0?{}:{currency:e.ctx.currency},...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}};case`CLOSE`:return{name:`closed`};default:return e}}function h(e,t){switch(t.type){case`ONRAMP_SESSION_COMPLETED`:return{name:`success`,ctx:{method:`onramp`,sessionId:e.ctx.sessionId}};case`ONRAMP_SESSION_EXPIRED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,...t.failure?{failure:t.failure}:{}}};case`ONRAMP_SESSION_FAILED`:return{name:`error`,ctx:{retryTarget:{kind:`onrampAmountEntry`},sessionId:e.ctx.sessionId,failure:t.failure}};case`BACK`:return{name:`onrampConfirm`,ctx:{method:`onramp`,amount:e.ctx.amount,phase:{kind:`ready`},backTarget:`onrampAmountEntry`,...e.ctx.currency===void 0?{}:{currency:e.ctx.currency},...e.ctx.providerId===void 0?{}:{providerId:e.ctx.providerId}}};case`CLOSE`:return{name:`closed`};default:return e}}function g(e,t){let n=e.ctx.phase;switch(t.type){case`QUOTE_RESOLVED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`ready`,quoteExpiresAt:t.expiresAt}}}:e;case`QUOTE_FAILED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`quote`}}}:e;case`QUOTE_RETRY`:return n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`loading`}}}:e;case`QUOTE_EXPIRED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`}}}:e;case`DEPOSIT_CONFIRMED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`submitting`}}}:e;case`DEPOSIT_SUBMITTED`:if(n.kind===`submitting`){let n={kind:`confirmDepositReady`,method:`wallet`,asset:e.ctx.asset,amount:e.ctx.amount};return{name:`processing`,ctx:{method:`wallet`,tx:t.tx,retryTargetForFailure:n}}}return e;case`DEPOSIT_SUBMISSION_FAILED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`submission`}}}:e;case`DEPOSIT_SIGNATURE_DECLINED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`,...t.notice?{notice:t.notice}:{}}}}:e;case`BACK`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:e.ctx.asset,backTarget:`assetPicker`}};case`CLOSE`:return{name:`closed`};default:return e}}function _(e,t){switch(t.type){case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`transferCrypto`,method:`transfer`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function v(e,t){switch(t.type){case`PROCESSING_SUCCEEDED`:return{name:`success`,ctx:{method:e.ctx.method,tx:e.ctx.tx}};case`PROCESSING_FAILED`:return{name:`error`,ctx:{retryTarget:e.ctx.retryTargetForFailure,tx:e.ctx.tx}};case`CLOSE`:return{name:`closed`};default:return e}}function y(e,t){return t.type===`SUCCESS_DONE`||t.type===`CLOSE`?{name:`closed`}:e}function b(e,t){return t.type===`ERROR_TRY_AGAIN`?S(e.ctx.retryTarget):t.type===`CLOSE`?{name:`closed`}:e}function x(e){return e.kind===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:e.backTarget}}:e.kind===`amountEntry`?{name:`amountEntry`,ctx:{method:`wallet`,asset:e.asset,backTarget:e.backTarget}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}}function S(e){return e.kind===`fresh`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`onrampAmountEntry`?{name:`onrampAmountEntry`,ctx:{method:`onramp`,backTarget:`deposit`}}:e.kind===`transferCrypto`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}:{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.asset,amount:e.amount,phase:{kind:`loading`},backTarget:`amountEntry`}}}export{n as initialState,a as reducer};
|
|
@@ -39,18 +39,15 @@ interface DepositMethodConfig {
|
|
|
39
39
|
*/
|
|
40
40
|
interface DepositRailConfig {
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* is equivalent to leaving it unset.
|
|
42
|
+
* Toggle for the rail. The onramp ("Cash") rail is shown by DEFAULT, so most hosts leave this
|
|
43
|
+
* unset. Crypto-only integrators (or any host without an onramp-capable driver) opt OUT by
|
|
44
|
+
* setting `enabled: false`. The catalog is fetched lazily on selection, so an enabled rail with
|
|
45
|
+
* no onramp backend simply leads to an empty Cash flow — set `enabled: false` to hide it.
|
|
47
46
|
*/
|
|
48
47
|
enabled?: boolean;
|
|
49
48
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* should prefer {@link DepositRailConfig.enabled}; setting `disabled: true` continues
|
|
53
|
-
* to hide the rail regardless of `enabled`.
|
|
49
|
+
* Alternate opt-OUT toggle. `disabled: true` hides the rail regardless of {@link DepositRailConfig.enabled}.
|
|
50
|
+
* Equivalent to `enabled: false`; either one hides the "Cash" rail.
|
|
54
51
|
*/
|
|
55
52
|
disabled?: boolean;
|
|
56
53
|
}
|
|
@@ -192,6 +189,46 @@ type DepositState = {
|
|
|
192
189
|
* (the widget falls back to the first preset).
|
|
193
190
|
*/
|
|
194
191
|
amount?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Selected fiat currency (ISO-4217). Absent until the user picks one or the controller
|
|
194
|
+
* seeds it from `onrampCurrencies.suggested` / persisted storage; readers fall back to
|
|
195
|
+
* `"USD"`. Threaded into the onramp quote + session requests.
|
|
196
|
+
*/
|
|
197
|
+
currency?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Selected onramp provider id. Absent until the user picks one or the controller seeds
|
|
200
|
+
* it from `onrampProviders.activeId`; readers fall back to the active provider. Today
|
|
201
|
+
* only the active provider is selectable, so this is idempotent.
|
|
202
|
+
*/
|
|
203
|
+
providerId?: string;
|
|
204
|
+
};
|
|
205
|
+
} | {
|
|
206
|
+
/**
|
|
207
|
+
* Searchable fiat-currency picker — reached from `onrampAmountEntry` via the currency chip.
|
|
208
|
+
* Carries the in-progress `amount` + `currency` so the selection (or a back-out) restores
|
|
209
|
+
* the amount-entry screen losslessly.
|
|
210
|
+
*/
|
|
211
|
+
name: "onrampCurrencyPicker";
|
|
212
|
+
ctx: {
|
|
213
|
+
method: "onramp";
|
|
214
|
+
backTarget: "onrampAmountEntry";
|
|
215
|
+
amount?: number;
|
|
216
|
+
currency: string;
|
|
217
|
+
providerId?: string;
|
|
218
|
+
};
|
|
219
|
+
} | {
|
|
220
|
+
/**
|
|
221
|
+
* Provider picker — reached from `onrampAmountEntry` via the provider card. Built as a real
|
|
222
|
+
* selectable list (single live provider today, multi-ready); carries the same `amount` +
|
|
223
|
+
* `currency` so a selection or back-out restores amount entry losslessly.
|
|
224
|
+
*/
|
|
225
|
+
name: "onrampProviderPicker";
|
|
226
|
+
ctx: {
|
|
227
|
+
method: "onramp";
|
|
228
|
+
backTarget: "onrampAmountEntry";
|
|
229
|
+
amount?: number;
|
|
230
|
+
currency: string;
|
|
231
|
+
providerId?: string;
|
|
195
232
|
};
|
|
196
233
|
} | {
|
|
197
234
|
name: "onrampConfirm";
|
|
@@ -199,7 +236,9 @@ type DepositState = {
|
|
|
199
236
|
method: "onramp";
|
|
200
237
|
amount: number;
|
|
201
238
|
phase: OnrampConfirmPhase;
|
|
202
|
-
backTarget: "onrampAmountEntry";
|
|
239
|
+
backTarget: "onrampAmountEntry"; /** Selected fiat currency carried from amount entry — drives the confirm re-quote + session. */
|
|
240
|
+
currency?: string; /** Selected provider carried from amount entry. */
|
|
241
|
+
providerId?: string;
|
|
203
242
|
};
|
|
204
243
|
} | {
|
|
205
244
|
name: "onrampPaymentPending";
|
|
@@ -208,7 +247,9 @@ type DepositState = {
|
|
|
208
247
|
amount: number;
|
|
209
248
|
sessionId: string;
|
|
210
249
|
checkoutUrl: string;
|
|
211
|
-
backTarget: "onrampConfirm";
|
|
250
|
+
backTarget: "onrampConfirm"; /** Selected fiat currency, preserved so a back-out restores the confirm/amount screens. */
|
|
251
|
+
currency?: string; /** Selected provider, preserved across the back-out path. */
|
|
252
|
+
providerId?: string;
|
|
212
253
|
};
|
|
213
254
|
} | {
|
|
214
255
|
name: "confirmDeposit";
|
|
@@ -295,6 +336,10 @@ type ResolvedOpenInput = undefined | {
|
|
|
295
336
|
asset?: BalanceItemPayload;
|
|
296
337
|
} | {
|
|
297
338
|
method: "transfer";
|
|
339
|
+
} | {
|
|
340
|
+
method: "onramp";
|
|
341
|
+
amount?: number;
|
|
342
|
+
currency?: string;
|
|
298
343
|
};
|
|
299
344
|
/**
|
|
300
345
|
* Reducer event union. Strict discriminated; no stringly-typed transitions, no payload
|
|
@@ -325,6 +370,28 @@ type GatewayEvent = {
|
|
|
325
370
|
} | {
|
|
326
371
|
type: "ONRAMP_AMOUNT_CONFIRMED";
|
|
327
372
|
amount: number;
|
|
373
|
+
} | {
|
|
374
|
+
/**
|
|
375
|
+
* User tapped the currency chip on `onrampAmountEntry`. Routes to `onrampCurrencyPicker`,
|
|
376
|
+
* carrying the in-progress amount + currency.
|
|
377
|
+
*/
|
|
378
|
+
type: "ONRAMP_CURRENCY_PICKER_OPENED";
|
|
379
|
+
} | {
|
|
380
|
+
/**
|
|
381
|
+
* User picked a fiat currency on `onrampCurrencyPicker`. Returns to `onrampAmountEntry`
|
|
382
|
+
* with the new `currency`; the controller's quote effect re-quotes in that currency.
|
|
383
|
+
*/
|
|
384
|
+
type: "ONRAMP_CURRENCY_SELECTED";
|
|
385
|
+
currency: string;
|
|
386
|
+
} | {
|
|
387
|
+
/** User tapped the provider card on `onrampAmountEntry`. Routes to `onrampProviderPicker`. */type: "ONRAMP_PROVIDER_PICKER_OPENED";
|
|
388
|
+
} | {
|
|
389
|
+
/**
|
|
390
|
+
* User picked a provider on `onrampProviderPicker`. Returns to `onrampAmountEntry` with the
|
|
391
|
+
* selected `providerId`. Idempotent for the already-active provider.
|
|
392
|
+
*/
|
|
393
|
+
type: "ONRAMP_PROVIDER_SELECTED";
|
|
394
|
+
providerId: string;
|
|
328
395
|
} | {
|
|
329
396
|
type: "ONRAMP_QUOTE_RESOLVED";
|
|
330
397
|
} | {
|
|
@@ -437,6 +504,10 @@ type OpenInput = undefined | {
|
|
|
437
504
|
assetId?: string;
|
|
438
505
|
} | {
|
|
439
506
|
method: "transfer";
|
|
507
|
+
} | {
|
|
508
|
+
method: "onramp"; /** Optional fiat amount to preselect on the Cash amount-entry band (falls back to the first preset). */
|
|
509
|
+
amount?: number; /** Optional ISO-4217 currency to preselect (falls back to persisted / country-resolved / USD). */
|
|
510
|
+
currency?: string;
|
|
440
511
|
};
|
|
441
512
|
/**
|
|
442
513
|
* Imperative controller returned by `useDeposit()`. Stable across re-renders.
|
|
@@ -450,9 +521,12 @@ interface DepositController {
|
|
|
450
521
|
* - `open({ method: "wallet", assetId })` → `amountEntry` when `assetId` resolves, otherwise
|
|
451
522
|
* falls through to `assetPicker`
|
|
452
523
|
* - `open({ method: "transfer" })` → `transferCrypto`
|
|
524
|
+
* - `open({ method: "onramp" })` → `onrampAmountEntry` (the "Cash" flow); pass `amount` /
|
|
525
|
+
* `currency` to preselect the band and price the quote on entry. The driver arms and the
|
|
526
|
+
* onramp catalog / currency / provider fetches fire just as they would from the picker.
|
|
453
527
|
*
|
|
454
528
|
* Returns `false` only when the requested `method` is disabled via
|
|
455
|
-
* {@link DepositMethodsConfig}.
|
|
529
|
+
* {@link DepositMethodsConfig} (for onramp, when `onrampRail.enabled === false` or `disabled`).
|
|
456
530
|
*
|
|
457
531
|
* For direct-entry into the activity surface, see {@link useActivity}.
|
|
458
532
|
*/
|
|
@@ -492,6 +566,25 @@ interface DepositActions {
|
|
|
492
566
|
* flips the phase to `ready`.
|
|
493
567
|
*/
|
|
494
568
|
confirmOnrampAmount(amount: number): void;
|
|
569
|
+
/**
|
|
570
|
+
* Opens the fiat-currency picker from `onrampAmountEntry` (`ONRAMP_CURRENCY_PICKER_OPENED`),
|
|
571
|
+
* carrying the in-progress amount + currency so a back-out restores the amount-entry screen.
|
|
572
|
+
*/
|
|
573
|
+
openOnrampCurrencyPicker(): void;
|
|
574
|
+
/**
|
|
575
|
+
* Commits a fiat-currency selection (`ONRAMP_CURRENCY_SELECTED`): sets `ctx.currency`, returns
|
|
576
|
+
* to `onrampAmountEntry`, and triggers a re-quote in the new currency.
|
|
577
|
+
*/
|
|
578
|
+
selectOnrampCurrency(currency: string): void;
|
|
579
|
+
/** Opens the provider picker from `onrampAmountEntry` (`ONRAMP_PROVIDER_PICKER_OPENED`). */
|
|
580
|
+
openOnrampProviderPicker(): void;
|
|
581
|
+
/**
|
|
582
|
+
* Commits a provider selection (`ONRAMP_PROVIDER_SELECTED`): sets `ctx.providerId` and returns
|
|
583
|
+
* to `onrampAmountEntry`. In scope now; today only the active provider is selectable
|
|
584
|
+
* (coming-soon rows are inert), but the action is fully wired. Selecting the already-active
|
|
585
|
+
* provider is a valid idempotent confirm.
|
|
586
|
+
*/
|
|
587
|
+
selectOnrampProvider(providerId: string): void;
|
|
495
588
|
/**
|
|
496
589
|
* Flips `onrampConfirm{ready}` → `onrampConfirm{creating}`. The controller's session effect
|
|
497
590
|
* calls `createOnrampSession`, opens the hosted checkout in a new tab, and dispatches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=[{
|
|
1
|
+
const e=`data:image/svg+xml,%3Csvg%20width%3D%22520%22%20height%3D%22470%22%20viewBox%3D%220%200%20520%20470%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22banxa-gradient%22%20x1%3D%2278.5%22%20y1%3D%22390.5%22%20x2%3D%22441.5%22%20y2%3D%2278.5%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%230076D0%22%2F%3E%3Cstop%20offset%3D%220.42%22%20stop-color%3D%22%2300B4C6%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%2300D6BF%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M%20417%20390.5%20L%20102%20390.5%20L%2092%20386.5%20L%2082.5%20377%20L%2078.5%20367%20L%2078.5%20356%20L%2084.5%20342%20L%20226.5%2096%20L%20235%2086.5%20L%20241%2082.5%20L%20252%2078.5%20L%20268%2078.5%20L%20280%2083.5%20L%20291.5%2094%20L%20434.5%20341%20L%20440.5%20353%20L%20441.5%20359%20L%20439.5%20372%20L%20436.5%20378%20L%20429%20385.5%20Z%20M%20360.5%20331%20L%20260%20157.5%20L%20254.5%20165%20L%20159.5%20330%20L%20160%20331.5%20Z%22%20fill%3D%22url(%23banxa-gradient)%22%2F%3E%3C%2Fsvg%3E`,t=`deposit.last-currency`,n=[`USD`,`EUR`,`GBP`,`JPY`,`CNY`,`AUD`,`CAD`,`CHF`],r={USD:[100,500,1e3],EUR:[100,500,1e3],GBP:[100,500,1e3],CHF:[100,500,1e3],CAD:[100,500,1e3],AUD:[100,500,1e3],CNY:[1e3,5e3,1e4],JPY:[2e4,5e4,1e5],KRW:[2e5,5e5,1e6],AED:[500,2e3,5e3],INR:[1e4,25e3,5e4]},i=[100,500,1e3];function a(e,t){try{return new Intl.NumberFormat(`en`,{style:`currency`,currency:t,currencyDisplay:`narrowSymbol`,notation:`compact`,maximumFractionDigits:1}).format(e)}catch{return String(e)}}function o(e){return(r[e]??i).map(t=>({value:t,label:a(t,e)}))}export{e as BANXA_LOGO_DATA_URI,t as LAST_DEPOSIT_CURRENCY_KEY,n as ONRAMP_POPULAR_CURRENCIES,o as resolveOnrampPresets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={id:`fWsBTs`,message:`Something went wrong. Please try again.`},t={id:`y1R6QS`,message:`This wallet can't receive this deposit. Try a different address.`},n={id:`a3WpTF`,message:`You already have a payment in progress. Finish or cancel it before starting another.`},r={id:`LZueaM`,message:`This purchase isn't available right now. Try a different amount or asset.`},i={id:`AmaCQf`,message:`Card payments are temporarily unavailable. Please try again later.`},a={id:`HtxAvT`,message:`This checkout is no longer available. Please start again.`},o={id:`q9raxs`,message:`This checkout has expired. Please start again.`},s={id:`hFe8Jo`,message:`We couldn't price that amount. Try a different amount.`},c={id:`7zrAuh`,message:`We couldn't start checkout. Please try again.`};function l(e){if(typeof e==`string`)return{message:e};if(e instanceof Error){let t=u(e.statusCode),n=e.message;if(!n||/^request failed/i.test(n)){let t=e.cause,r=f(t);r&&(n=r)}return t===void 0?{message:n}:{message:n,status:t}}if(e&&typeof e==`object`){let t=e,n=d(t.error)??d(t.message)??``,r=u(t.code);return r===void 0?{message:n}:{message:n,status:r}}return{message:``}}function u(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function d(e){return typeof e==`string`&&e.trim()?e:void 0}function f(e){if(!(!e||typeof e!=`object`))return d(e.error)}function p(e){let t=e.indexOf(`{`);if(t===-1)return;let n=e.slice(t).trim();if(n.endsWith(`[truncated]`))return;let r;try{r=JSON.parse(n)}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(i.errors&&typeof i.errors==`object`)for(let e of Object.values(i.errors)){let t=Array.isArray(e)?e.find(e=>typeof e==`string`&&e.trim().length>0):d(e);if(t)return m(t)}let a=d(i.message);return a?m(a):void 0}function m(e){let t=e.trim().replace(/'([\d.,]+)'/g,`$1`);return/[.!?]$/.test(t)?t:`${t}.`}function h(e,l,u){let d=e.toLowerCase();if(d.includes(`business allowlist`)||d.includes(`not a registered address`)||d.includes(`belongs to a different owner`))return u._(t);if(d.includes(`another active`)||l===409)return u._(n);if(d.includes(`session expired`)||d.includes(`session has expired`))return u._(o);if(d.includes(`session not found`))return u._(a);if(d.includes(`provider is disabled`)||l===503)return u._(i);if(d.includes(`no onramp provider matches`)||d.includes(`no deposit asset matches`)||d.includes(`provider asset mapping`)||d.includes(`unknown onramp provider`))return u._(r);if(d.includes(`failed to create session`))return u._(c);if(d.includes(`failed to quote`)||d.includes(`rejected request`))return u._(s)}function g(t,n){let{message:r,status:i}=l(t);return p(r)??h(r,i,n)??n._(e)}export{g as resolveOnrampErrorMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useOptionalKitStorage as e}from"../../../../storage/context.js";import"../../../../storage/index.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useDepositActions as r,useDepositEffectiveState as i,useDepositMethodsConfig as a,useEnabledRails as o}from"../../orchestrator/controller.js";import{BitcoinIcon as s}from"../../../../shared/icons/BitcoinIcon.js";import{CardIcon as c}from"../../../../shared/icons/CardIcon.js";import{QrCodeIcon as l}from"../../../../shared/icons/QrCodeIcon.js";import{WalletIcon as u}from"../../../../shared/icons/WalletIcon.js";import"../../../../icons/index.js";import{DialogShell as d}from"../../../../shared/dialog/DialogShell.js";import{Image as f}from"../../../../shared/ui/Image/Image.js";import{Skeleton as p}from"../../../../shared/ui/Skeleton/Skeleton.js";import"../../../../shared/ui/Skeleton/index.js";import{TokenLogo as m}from"../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../shared/ui/TokenLogo/index.js";import"../../../../ui/index.js";import{Deposit as h}from"./compound/Deposit.js";import"./compound/index.js";import{useMemo as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";const b={width:18,height:18,"aria-hidden":!0},x=`deposit.last-rail`;function S({children:d,...f}){let m=n(),S=i().name,{selectMethod:w,selectOnramp:T}=r(),E=a(),D=e(),{_:O}=t(),k=m.wallet,A=k.status===`ready`||k.status===`stale`?k.payload:void 0,j=A!==void 0,M=m.brand,N=M.status===`ready`||M.status===`stale`?M.payload:void 0,P=m.addresses,F=P.status===`ready`||P.status===`stale`?P.payload:[],I=m.balances.status===`error`,L=!A?.balanceTotalUsd?.formatted&&!I,R=!!m.brand,z=N?.name?O({id:`ogD_nm`,message:`Deposit to {0}`,values:{0:N.name}}):void 0,B=g(()=>C(F),[F]),V=E?.wallet,H=E?.transfer,U=E?.onrampRail?.enabled
|
|
1
|
+
"use client";import{useOptionalKitStorage as e}from"../../../../storage/context.js";import"../../../../storage/index.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useDepositActions as r,useDepositEffectiveState as i,useDepositMethodsConfig as a,useEnabledRails as o}from"../../orchestrator/controller.js";import{BitcoinIcon as s}from"../../../../shared/icons/BitcoinIcon.js";import{CardIcon as c}from"../../../../shared/icons/CardIcon.js";import{QrCodeIcon as l}from"../../../../shared/icons/QrCodeIcon.js";import{WalletIcon as u}from"../../../../shared/icons/WalletIcon.js";import"../../../../icons/index.js";import{DialogShell as d}from"../../../../shared/dialog/DialogShell.js";import{Image as f}from"../../../../shared/ui/Image/Image.js";import{Skeleton as p}from"../../../../shared/ui/Skeleton/Skeleton.js";import"../../../../shared/ui/Skeleton/index.js";import{TokenLogo as m}from"../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../shared/ui/TokenLogo/index.js";import"../../../../ui/index.js";import{Deposit as h}from"./compound/Deposit.js";import"./compound/index.js";import{useMemo as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";const b={width:18,height:18,"aria-hidden":!0},x=`deposit.last-rail`;function S({children:d,...f}){let m=n(),S=i().name,{selectMethod:w,selectOnramp:T}=r(),E=a(),D=e(),{_:O}=t(),k=m.wallet,A=k.status===`ready`||k.status===`stale`?k.payload:void 0,j=A!==void 0,M=m.brand,N=M.status===`ready`||M.status===`stale`?M.payload:void 0,P=m.addresses,F=P.status===`ready`||P.status===`stale`?P.payload:[],I=m.balances.status===`error`,L=!A?.balanceTotalUsd?.formatted&&!I,R=!!m.brand,z=N?.name?O({id:`ogD_nm`,message:`Deposit to {0}`,values:{0:N.name}}):void 0,B=g(()=>C(F),[F]),V=E?.wallet,H=E?.transfer,U=E?.onrampRail?.enabled!==!1,W=m.onrampMethods,G=W?.status,K=G===`ready`||G===`stale`?W?.payload:void 0,q=U,J=g(()=>{let e=!j||L,t=V?.disabled??!1,n=e||t,r=t?V?.disabledHint:void 0,i=(()=>{if(t)return r;if(!j)return O({id:`5AApJw`,message:`Connect a wallet to continue`});if(A?.balanceTotalUsd?.formatted)return A.balanceTotalUsd.formatted;if(!I)return v(p,{width:56,height:12})})(),a=[{id:`wallet`,title:O({id:`sb9Y58`,message:`Wallet`}),icon:v(u,{...b}),...A&&!t?{titleAdornment:A.address.formatted}:{},...i===void 0?{}:{meta:i},recommended:!0,disabled:n,onSelect:n?void 0:()=>w(`wallet`)}];if(R){let e=H?.disabled??!1,t=e?H?.disabledHint:void 0,n=e?t:[O({id:`qtoOYG`,message:`No limit`}),O({id:`D79cZK`,message:`Instant`})];a.push({id:`transfer`,title:O({id:`3dqPLT`,message:`Transfer Crypto`}),icon:v(l,{...b}),...n===void 0?{}:{meta:n},...B?{trailing:B}:{},disabled:e,onSelect:e?void 0:()=>w(`transfer`)})}return a},[A,I,L,j,R,B,V,H,w,O]),Y=g(()=>{let e=(()=>{if(!K)return;let e=[];K.limit?.formatted&&e.push(O({id:`jtKSW-`,message:`{0} limit`,values:{0:K.limit.formatted}}));let t=K.processingTime;if(t){let n=t.value===0?O({id:`D79cZK`,message:`Instant`}):t.formatted||void 0;n&&e.push(n)}return e.length>0?e:void 0})();return{id:`onramp`,title:O({id:`ib77lj`,message:`Debit Card`}),icon:v(c,{...b}),...e===void 0?{}:{meta:e},metaEmphasis:`uniform`,onSelect:()=>T()}},[K,T,O]),X=o(g(()=>{let e=[{value:`crypto`,label:O({id:`0TEl46`,message:`Crypto`}),icon:v(s,{width:12,height:12,"aria-hidden":!0})}];return q&&e.push({value:`onramp`,label:O({id:`_rHUhS`,message:`Cash`}),icon:v(c,{width:12,height:12,"aria-hidden":!0})}),e},[O,q]));if(S!==`deposit`)return null;let Z={crypto:v(h.Methods,{}),onramp:v(h.Methods,{children:v(h.Method,{...Y})})},[Q]=X,$=D?.get(x)??null,ee=X.find(e=>e.value===$)?.value??Q?.value,te=y(_,{children:[v(h.Header,{}),v(h.Body,{children:X.length>=2?v(h.RailPicker,{defaultValue:ee,rails:X,onValueChange:e=>D?.set(x,e),children:X.map(e=>v(h.Rail,{value:e.value,children:Z[e.value]},e.value))}):Z[Q?.value??`crypto`]})]});return v(h,{...f,...z?{title:z}:{},methods:J,children:d??te})}function C(e){if(e.length!==0)return v(f.Group,{max:4,overflow:Math.max(0,e.length-4),size:`md`,children:e.map(e=>v(m,{isNative:!0,symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},hideChainBadge:!0},e.eip155Id??e.networkName))})}function w({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return v(d,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:v(S,{...i})})}(function(e){e.Dialog=w,e.Header=h.Header,e.Body=h.Body,e.Methods=h.Methods,e.Method=h.Method,e.MethodSection=h.MethodSection,e.Steps=h.Steps,e.Step=h.Step,e.RailPicker=h.RailPicker,e.Rail=h.Rail})(S||={});export{S as Deposit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useLingui as e}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useFailureReasonForKind as t}from"../../../../shared/orchestrator/failureReason.js";import"../../../../shared/orchestrator/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useDepositActions as r,useDepositEffectiveState as i}from"../../orchestrator/controller.js";import{DialogShell as a}from"../../../../shared/dialog/DialogShell.js";import{
|
|
1
|
+
"use client";import{useLingui as e}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useFailureReasonForKind as t}from"../../../../shared/orchestrator/failureReason.js";import"../../../../shared/orchestrator/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useDepositActions as r,useDepositEffectiveState as i}from"../../orchestrator/controller.js";import{DialogShell as a}from"../../../../shared/dialog/DialogShell.js";import{FiatAmount as o}from"../../../../shared/ui/FiatSymbol/FiatAmount.js";import"../../../../shared/ui/FiatSymbol/index.js";import{ErrorState as s}from"../../../../shared/widgets/error-state/compound/ErrorState.js";import"../../../../shared/widgets/error-state/compound/index.js";import{toAssetDescriptor as c}from"../../../../shared/widgets/asset-descriptor.js";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";const f={declined:{headline:{id:`mn0HrT`,message:`Payment declined`},reason:{id:`UDBU3S`,message:`Your payment was declined. Try a different card or amount.`}},cancelled:{headline:{id:`0VFO13`,message:`Payment cancelled`},reason:{id:`5R2524`,message:`You cancelled the payment before it completed.`}},refunded:{headline:{id:`hPpyl6`,message:`Payment refunded`},reason:{id:`3ytoeI`,message:`This payment was refunded. No crypto was delivered.`}},timeout:{headline:{id:`S7anoa`,message:`Payment timed out`},reason:{id:`Z1fsV0`,message:`The checkout window expired before payment completed.`}},generic:{headline:{id:`NzshpK`,message:`Purchase failed`},reason:{id:`X_Y-Ev`,message:`Something went wrong with your purchase. Please try again.`}}};function p(e,t){let n=e?.toLowerCase()??``,r=`generic`;n.includes(`declin`)?r=`declined`:n.includes(`cancel`)?r=`cancelled`:n.includes(`refund`)?r=`refunded`:(n.includes(`timeout`)||n.includes(`expire`))&&(r=`timeout`);let i=f[r];return{headline:t._(i.headline),reason:t._(i.reason)}}function m({children:a,...f}){let m=n(),h=i(),{tryAgain:g}=r(),{_,i18n:v}=e(),y=t();if(h.name!==`error`)return null;if(h.ctx.sessionId!==void 0){let e=m.onrampSession,t=e?.status===`ready`||e?.status===`stale`?e.payload:void 0,n=m.onrampQuote,r=n?.status===`ready`||n?.status===`stale`?n.payload:void 0,{headline:i,reason:y}=p(t?.failureCode??h.ctx.failure?.code,v),b=t?.fiatAmount?.formatted??r?.amountFiat.formatted,x=t?.fiatAmount?.value??r?.amountFiat.value,S=t?.fiatCurrency??r?.fiatCurrency,C=x!==void 0&&S?u(o,{value:x,currency:S,locale:v.locale}):b,w=t?.receiveAmount?.formatted??r?.receiveAmount.formatted,T=r?.receiveAsset.symbol??t?.depositAsset,E=r?c({symbol:r.receiveAsset.symbol,chainId:r.receiveAsset.chainId,address:r.receiveAsset.address,isNative:r.receiveAsset.isNative,...r.receiveAsset.assetLogoUrl?{assetLogoUrl:r.receiveAsset.assetLogoUrl}:{}})??(T?{symbol:T}:void 0):T?{symbol:T}:void 0,D=t?.providerOrderId,O=!!(b||w||D);return u(s,{...f,headline:i,reason:y,...w?{receiveAmount:w}:{},...E?{receiveAsset:E}:{},onTryAgain:g,children:a??d(l,{children:[u(s.Header,{}),d(s.Body,{children:[u(s.Hero,{}),O?d(s.Details,{children:[b?u(s.Detail,{label:_({id:`VAxOSg`,message:`You pay`}),value:C}):null,w?u(s.YouReceiveRow,{}):null,D?u(s.Detail,{label:_({id:`oI_hGR`,message:`Order ID`}),value:D}):null]}):null]}),u(s.Actions,{})]})})}let b=m.settlement,x=b.status===`ready`&&b.payload.kind===`failed`?b.payload:void 0,S=h.name===`error`?h.ctx.failure:void 0,C=_({id:`i-4Fbp`,message:`Deposit failed`}),w=x?y(x.failureKind):S?.reason;if(!x)return u(s,{...f,headline:C,...w?{reason:w}:{},onTryAgain:g,children:a??d(l,{children:[u(s.Header,{}),u(s.Body,{children:u(s.Hero,{})}),u(s.Actions,{})]})});let T=x,E={...T.sourceWallet.name===void 0?{}:{name:T.sourceWallet.name},address:T.sourceWallet.address.formatted,...T.sourceWallet.explorerUrl?{explorerUrl:T.sourceWallet.explorerUrl}:{}},D={...T.destination.name===void 0?{}:{name:T.destination.name},address:T.destination.address.formatted},O=c(T.creditedAsset)??{symbol:T.creditedAsset.symbol},k={hash:T.txHash.formatted,...T.txExplorerUrl?{explorerUrl:T.txExplorerUrl}:{}};return u(s,{...f,headline:C,...w?{reason:w}:{},sourceWallet:E,destination:D,receiveAmount:T.receiveAmount.formatted,receiveAsset:O,depositTx:k,submittedAt:T.submittedAt.formatted,failedAt:T.failedAt.formatted,onTryAgain:g,children:a??d(l,{children:[u(s.Header,{}),d(s.Body,{children:[u(s.Hero,{}),d(s.Details,{children:[u(s.FillStatusRow,{}),u(s.SourceRow,{}),u(s.DestinationRow,{}),u(s.YouReceiveRow,{}),d(s.MoreDetails,{children:[u(s.DepositTxRow,{}),u(s.SubmittedAtRow,{}),u(s.FailedAtRow,{})]})]}),u(s.HelpInfo,{})]}),u(s.Actions,{})]})})}function h({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return u(a,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:u(m,{...i})})}(function(e){e.Dialog=h,e.Header=s.Header,e.Body=s.Body,e.Hero=s.Hero,e.Details=s.Details,e.FillStatusRow=s.FillStatusRow,e.SourceRow=s.SourceRow,e.DestinationRow=s.DestinationRow,e.YouReceiveRow=s.YouReceiveRow,e.MoreDetails=s.MoreDetails,e.DepositTxRow=s.DepositTxRow,e.SubmittedAtRow=s.SubmittedAtRow,e.FailedAtRow=s.FailedAtRow,e.HelpInfo=s.HelpInfo,e.Actions=s.Actions})(m||={});export{m as ErrorState};
|
|
@@ -7,7 +7,9 @@ import { AmountEntryFooter } from "../../../../shared/widgets/amount-entry/compo
|
|
|
7
7
|
import { AmountEntryHero } from "../../../../shared/widgets/amount-entry/compound/components/Hero/Hero.js";
|
|
8
8
|
import { AmountEntryNotice } from "../../../../shared/widgets/amount-entry/compound/components/Notice.js";
|
|
9
9
|
import { AmountEntryPills } from "../../../../shared/widgets/amount-entry/compound/components/Pills.js";
|
|
10
|
+
import { OnrampAmountEntryCurrencyChip } from "./compound/components/CurrencyChip.js";
|
|
10
11
|
import { OnrampAmountEntryHeroLabel } from "./compound/components/HeroLabel.js";
|
|
12
|
+
import { OnrampAmountEntryProviderCard } from "./compound/components/ProviderCard.js";
|
|
11
13
|
import { OnrampAmountEntryReceiveChip } from "./compound/components/ReceiveChip.js";
|
|
12
14
|
import { ComponentProps, ReactNode } from "react";
|
|
13
15
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -16,18 +18,18 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
16
18
|
interface OnrampAmountEntryOwnProps {
|
|
17
19
|
/**
|
|
18
20
|
* Optional custom composition. When omitted, the canonical default composition renders —
|
|
19
|
-
* `<Header />` + `<Body>` with YOU PAY label
|
|
20
|
-
* Pills
|
|
21
|
-
*
|
|
21
|
+
* `<Header />` + `<Body>` with the currency chip, YOU PAY label, Hero (Receive chip subLine),
|
|
22
|
+
* currency-aware Pills, and the Provider card + `<Footer />`. The full fee breakdown lives on the
|
|
23
|
+
* confirm step, so it is intentionally omitted here.
|
|
22
24
|
*/
|
|
23
25
|
children?: ReactNode;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
|
-
* Orchestrated `OnrampAmountEntry` widget — the screen between the "Cash" rail and the
|
|
27
|
-
*
|
|
28
|
-
* limit from
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* Orchestrated `OnrampAmountEntry` widget — the screen between the "Cash" rail and the onramp
|
|
29
|
+
* confirm screen. Reads the entered fiat amount + selected currency from the FSM's
|
|
30
|
+
* `onrampAmountEntry.ctx`, the limit from `onrampMethods`, the live breakdown from `onrampQuote`, and
|
|
31
|
+
* the currency / provider catalogs from `onrampCurrencies` / `onrampProviders`. Renders nothing on
|
|
32
|
+
* any other FSM state.
|
|
31
33
|
*/
|
|
32
34
|
declare function OnrampAmountEntry({
|
|
33
35
|
children,
|
|
@@ -50,6 +52,8 @@ declare namespace OnrampAmountEntry {
|
|
|
50
52
|
*/
|
|
51
53
|
const HeroLabel: typeof OnrampAmountEntryHeroLabel;
|
|
52
54
|
const ReceiveChip: typeof OnrampAmountEntryReceiveChip;
|
|
55
|
+
const CurrencyChip: typeof OnrampAmountEntryCurrencyChip;
|
|
56
|
+
const ProviderCard: typeof OnrampAmountEntryProviderCard;
|
|
53
57
|
const Header: typeof AmountEntryHeader;
|
|
54
58
|
const Body: (props: AmountEntryBodyProps) => _$react_jsx_runtime0.JSX.Element;
|
|
55
59
|
const Hero: typeof AmountEntryHero;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useOptionalKitStorage as e}from"../../../../storage/context.js";import"../../../../storage/index.js";import{Trans as t}from"../../../../shared/i18n/Trans.js";import{useLingui as n}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as r}from"../../driver/context.js";import{useDepositActions as i,useDepositEffectiveState as ee}from"../../orchestrator/controller.js";import{resolveOnrampPresets as te}from"../../shared/onramp.js";import{DialogShell as a}from"../../../../shared/dialog/DialogShell.js";import{OnrampAmountEntry as o}from"./compound/OnrampAmountEntry.js";import"./compound/index.js";import{resolveOnrampErrorMessage as ne}from"../../shared/onrampError.js";import{useEffect as s,useMemo as c,useRef as re,useState as l}from"react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";const ie={symbol:`USDC`,chainId:1,address:`0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`};function ae(e,t){try{return new Intl.NumberFormat(t,{style:`currency`,currency:e,currencyDisplay:`narrowSymbol`}).formatToParts(0).find(e=>e.type===`currency`)?.value??e}catch{return e}}function p(e,t){try{return new Intl.NumberFormat(t,{style:`currency`,currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function m({children:a,...m}){let h=r(),g=ee(),{back:oe,confirmOnrampAmount:se,setOnrampAmount:_,openOnrampCurrencyPicker:ce,openOnrampProviderPicker:le,selectOnrampCurrency:v}=i(),{_:y,i18n:b}=n(),ue=e(),x=g.name===`onrampAmountEntry`,S=x?g.ctx.amount:void 0,C=x?g.ctx.currency:void 0,w=h.onrampMethods,T=w?.status===`ready`||w?.status===`stale`?w.payload:void 0,E=T?.limit?.value,D=T?.limit?.formatted,O=h.onrampQuote,k=O?.status===`ready`||O?.status===`stale`?O.payload:void 0,A=O==null||O.status===`idle`||O.status===`loading`,j=O?.status===`error`?ne(O.error,b):void 0,M=h.onrampCurrencies,N=M?.status===`ready`||M?.status===`stale`,de=N?M.payload.suggested:void 0,P=ue?.get(`deposit.last-currency`)??void 0??de,F=C??P??`USD`,I=(N?M.payload.currencies.find(e=>e.code===F):void 0)?.symbol??k?.fiatSymbol??ae(F,b.locale),fe=p(F,b.locale);s(()=>{x&&C===void 0&&P!==void 0&&v(P)},[x,C,P,v]);let L=c(()=>{let e=te(F),t=typeof E==`number`?e.filter(e=>e.value<=E):e;return t.length>0?t:typeof E==`number`&&D?[{value:E,label:D}]:e},[F,E,D]),R=L[0]?.value??0,z=S??R,[B,V]=l(z),[H,U]=l(()=>{let e=L.find(e=>e.value===z);return e?String(e.value):void 0}),pe=c(()=>L.map(e=>({value:String(e.value),label:e.label})),[L]),W=re(F);s(()=>{W.current!==F&&(W.current=F,V(R),U(R?String(R):void 0))},[F,R]),s(()=>{_(B)},[B,_]);let me=e=>{let t=Number(e);Number.isFinite(t)&&(V(t),U(e))},he=e=>{V(e),U(void 0)},G=E===0,ge=()=>{if(!G){if(typeof E==`number`&&B!==null&&B>E){V(E),U(void 0);return}B===null||B<=0||se(B)}},K=h.onrampProviders,q=K?.status===`ready`||K?.status===`stale`?K.payload.providers.find(e=>e.id===K.payload.activeId):void 0,J=c(()=>{if(q)return{name:q.name,...q.logoUrl===void 0?{}:{logoUrl:q.logoUrl},...q.note===void 0?{}:{note:q.note},...T?.processingTime?.formatted?{deliveryTime:T.processingTime.formatted}:{}}},[q,T]);if(!x)return null;let Y=!G&&typeof E==`number`&&B!==null&&B>E,X=(()=>{if(G)return d(t,{id:`EzZNDI`,message:`Buy-with-card isn't available for your region`});if(Y&&D)return d(t,{id:`GXkBas`,message:`Max {formattedLimit}`,values:{formattedLimit:D}});if(j)return j})(),Z=Y?y({id:`wkskq5`,message:`Use max`}):void 0,Q=k?{symbol:k.receiveAsset.symbol,chainId:k.receiveAsset.chainId,address:k.receiveAsset.address,isNative:k.receiveAsset.isNative,...k.receiveAsset.assetLogoUrl?{logoUrl:k.receiveAsset.assetLogoUrl}:{}}:ie,_e=k?.receiveAmount.formatted??``,$=g.ctx.backTarget===`closed`?void 0:oe;return d(o,{...m,formattedReceive:_e,onrampReceiveToken:Q,quoteLoading:A,amount:B,sendToken:{symbol:F},receiveToken:Q,...typeof E==`number`&&E>0?{max:E}:{},headerTitle:y({id:`WE9GC7`,message:`Deposit Cash`}),currencySymbol:I,format:{useGrouping:!0,maximumFractionDigits:fe},currencyCode:F,currencyGlyphSymbol:I,onOpenCurrencyPicker:ce,...J?{provider:J}:{},onOpenProviderPicker:le,onAmountChange:he,...$?{onBack:$}:{},presets:pe,...H===void 0?{}:{activePreset:H},onPresetSelect:me,...Z===void 0?{}:{footerLabel:Z},...G?{}:{onContinue:ge},ctaDisabled:A||!Y&&j!==void 0,notice:X,children:a??f(u,{children:[d(o.Header,{}),f(o.Body,{children:[d(o.CurrencyChip,{}),d(o.HeroLabel,{children:d(t,{id:`VAxOSg`,message:`You pay`})}),d(o.Hero,{compact:!0}),d(o.Pills,{}),d(o.ProviderCard,{})]}),d(o.Footer,{children:d(o.Notice,{})})]})})}function h({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return d(a,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:d(m,{...i})})}(function(e){e.Dialog=h,e.HeroLabel=o.HeroLabel,e.ReceiveChip=o.ReceiveChip,e.CurrencyChip=o.CurrencyChip,e.ProviderCard=o.ProviderCard,e.Header=o.Header,e.Body=o.Body,e.Hero=o.Hero,e.Pills=o.Pills,e.Flow=o.Flow,e.Footer=o.Footer,e.Notice=o.Notice,e.Details=o.Details,e.DetailsRow=o.DetailsRow})(m||={});export{m as OnrampAmountEntry};
|
|
@@ -6,8 +6,10 @@ import { AmountEntryFooter } from "../../../../../shared/widgets/amount-entry/co
|
|
|
6
6
|
import { AmountEntryHero } from "../../../../../shared/widgets/amount-entry/compound/components/Hero/Hero.js";
|
|
7
7
|
import { AmountEntryNotice } from "../../../../../shared/widgets/amount-entry/compound/components/Notice.js";
|
|
8
8
|
import { AmountEntryPills } from "../../../../../shared/widgets/amount-entry/compound/components/Pills.js";
|
|
9
|
+
import { OnrampAmountEntryCurrencyChip } from "./components/CurrencyChip.js";
|
|
9
10
|
import { OnrampAmountEntryDialogProps, OnrampAmountEntryHeroLabelProps, OnrampAmountEntryProps } from "./types.js";
|
|
10
11
|
import { OnrampAmountEntryHeroLabel } from "./components/HeroLabel.js";
|
|
12
|
+
import { OnrampAmountEntryProviderCard } from "./components/ProviderCard.js";
|
|
11
13
|
import { OnrampAmountEntryReceiveChip } from "./components/ReceiveChip.js";
|
|
12
14
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
13
15
|
|
|
@@ -46,6 +48,8 @@ declare namespace OnrampAmountEntry {
|
|
|
46
48
|
/** Onramp-flow-specific sub-parts. */
|
|
47
49
|
const HeroLabel: typeof OnrampAmountEntryHeroLabel;
|
|
48
50
|
const ReceiveChip: typeof OnrampAmountEntryReceiveChip;
|
|
51
|
+
const CurrencyChip: typeof OnrampAmountEntryCurrencyChip;
|
|
52
|
+
const ProviderCard: typeof OnrampAmountEntryProviderCard;
|
|
49
53
|
/** AmountEntry compound parts re-exposed for one-stop composition. */
|
|
50
54
|
const Header: typeof AmountEntryHeader;
|
|
51
55
|
const Body: (props: AmountEntryBodyProps) => _$react_jsx_runtime0.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{DialogShell as e}from"../../../../../shared/dialog/DialogShell.js";import{AmountEntry as t}from"../../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../../shared/widgets/amount-entry/compound/index.js";import{
|
|
1
|
+
"use client";import{DialogShell as e}from"../../../../../shared/dialog/DialogShell.js";import{AmountEntry as t}from"../../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../../shared/widgets/amount-entry/compound/index.js";import{OnrampAmountEntryContext as n}from"./context.js";import{OnrampAmountEntryCurrencyChip as r}from"./components/CurrencyChip.js";import{OnrampAmountEntryHeroLabel as i}from"./components/HeroLabel.js";import{OnrampAmountEntryProviderCard as a}from"./components/ProviderCard.js";import{OnrampAmountEntryReceiveChip as o}from"./components/ReceiveChip.js";import{useMemo as s}from"react";import{jsx as c}from"react/jsx-runtime";const l=c(o,{});function u(e){let{formattedReceive:r,onrampReceiveToken:i,quoteLoading:a=!1,currencyCode:o,currencyGlyphSymbol:u,onOpenCurrencyPicker:d,provider:f,onOpenProviderPicker:p,subLine:m,children:h,...g}=e;return c(n,{value:s(()=>({formattedReceive:r,receiveToken:i,loading:a,...o===void 0?{}:{currencyCode:o},...u===void 0?{}:{currencyGlyphSymbol:u},...d?{onOpenCurrencyPicker:d}:{},...f===void 0?{}:{provider:f},...p?{onOpenProviderPicker:p}:{}}),[r,i,a,o,u,d,f,p]),children:c(t,{...g,...o===void 0?{}:{currencyCode:o},subLine:m??l,children:h})})}function d({open:t,defaultOpen:n,onOpenChange:r,trigger:i,children:a,...o}){return c(e,{open:t,defaultOpen:n,onOpenChange:r,trigger:i,children:c(u,{...o,children:a})})}(function(e){e.HeroLabel=i,e.ReceiveChip=o,e.CurrencyChip=r,e.ProviderCard=a,e.Header=t.Header,e.Body=t.Body,e.Hero=t.Hero,e.Pills=t.Pills,e.Flow=t.Flow,e.Footer=t.Footer,e.Notice=t.Notice,e.Details=t.Details,e.DetailsRow=t.DetailsRow,e.Dialog=d})(u||={});export{u as OnrampAmountEntry};
|
package/dist/flows/deposit/widgets/onramp-amount-entry/compound/OnrampAmountEntry.slots.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ declare const ONRAMP_AMOUNT_ENTRY_SLOTS: {
|
|
|
8
8
|
readonly root: "onramp-amount-entry";
|
|
9
9
|
readonly heroLabel: "onramp-amount-entry-hero-label";
|
|
10
10
|
readonly receiveChip: "onramp-amount-entry-receive-chip";
|
|
11
|
+
readonly currencyChip: "onramp-amount-entry-currency-chip";
|
|
12
|
+
readonly providerCard: "onramp-amount-entry-provider-card";
|
|
13
|
+
readonly providerCardLabel: "onramp-amount-entry-provider-card-label";
|
|
14
|
+
readonly providerCardRow: "onramp-amount-entry-provider-card-row";
|
|
15
|
+
readonly providerCardName: "onramp-amount-entry-provider-card-name";
|
|
16
|
+
readonly providerCardNote: "onramp-amount-entry-provider-card-note";
|
|
17
|
+
readonly providerCardDelivery: "onramp-amount-entry-provider-card-delivery";
|
|
11
18
|
};
|
|
12
19
|
type OnrampAmountEntrySlot = (typeof ONRAMP_AMOUNT_ENTRY_SLOTS)[keyof typeof ONRAMP_AMOUNT_ENTRY_SLOTS];
|
|
13
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={root:`onramp-amount-entry`,heroLabel:`onramp-amount-entry-hero-label`,receiveChip:`onramp-amount-entry-receive-chip`};export{e as ONRAMP_AMOUNT_ENTRY_SLOTS};
|
|
1
|
+
const e={root:`onramp-amount-entry`,heroLabel:`onramp-amount-entry-hero-label`,receiveChip:`onramp-amount-entry-receive-chip`,currencyChip:`onramp-amount-entry-currency-chip`,providerCard:`onramp-amount-entry-provider-card`,providerCardLabel:`onramp-amount-entry-provider-card-label`,providerCardRow:`onramp-amount-entry-provider-card-row`,providerCardName:`onramp-amount-entry-provider-card-name`,providerCardNote:`onramp-amount-entry-provider-card-note`,providerCardDelivery:`onramp-amount-entry-provider-card-delivery`};export{e as ONRAMP_AMOUNT_ENTRY_SLOTS};
|