@stridge/kit 0.1.0-alpha.4 → 0.1.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -6
- package/dist/KitProvider.d.ts +29 -0
- package/dist/KitProvider.js +1 -1
- package/dist/_internal/drivers/stridge/index.d.ts +3 -2
- package/dist/_internal/drivers/stridge/index.js +1 -1
- package/dist/_internal/withdraw/driver/index.d.ts +2 -2
- package/dist/deposit/compound/index.d.ts +3 -3
- package/dist/drivers/stridge/catalog.d.ts +54 -0
- package/dist/drivers/stridge/catalog.js +1 -0
- package/dist/drivers/stridge/createStridgeDepositDriver.d.ts +9 -0
- package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
- package/dist/drivers/stridge/createStridgeWithdrawDriver.d.ts +34 -13
- package/dist/drivers/stridge/createStridgeWithdrawDriver.js +1 -1
- package/dist/drivers/stridge/internal/retry.js +1 -0
- package/dist/drivers/stridge/internal/supportedChains.js +1 -0
- package/dist/drivers/stridge/types.d.ts +20 -14
- package/dist/drivers/stridge/types.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockDriver.d.ts +2 -2
- package/dist/drivers/stridge-mock/createStridgeMockDriver.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.d.ts +15 -3
- package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.js +1 -1
- package/dist/drivers/stridge-mock/fixtures.d.ts +13 -11
- package/dist/drivers/stridge-mock/fixtures.js +1 -1
- package/dist/events/bus/createBus.d.ts +7 -0
- package/dist/events/bus/createBus.js +1 -0
- package/dist/events/bus/flowIdRegistry.d.ts +17 -0
- package/dist/events/bus/flowIdRegistry.js +1 -0
- package/dist/events/bus/index.js +1 -0
- package/dist/events/bus/metadata.js +1 -0
- package/dist/events/context.js +1 -0
- package/dist/events/emit/index.js +1 -0
- package/dist/events/emit/mapFailure.js +1 -0
- package/dist/events/emit/useDepositEmissions.js +1 -0
- package/dist/events/emit/useKitEmitter.js +1 -0
- package/dist/events/emit/useWithdrawEmissions.js +1 -0
- package/dist/events/hooks/index.d.ts +6 -0
- package/dist/events/hooks/index.js +1 -0
- package/dist/events/hooks/useCurrentFlowId.d.ts +6 -0
- package/dist/events/hooks/useCurrentFlowId.js +1 -0
- package/dist/events/hooks/useStableHandler.js +1 -0
- package/dist/events/hooks/useStridgeEvent.d.ts +8 -0
- package/dist/events/hooks/useStridgeEvent.js +1 -0
- package/dist/events/hooks/useStridgeEventBus.d.ts +33 -0
- package/dist/events/hooks/useStridgeEventBus.js +1 -0
- package/dist/events/hooks/useStridgeEvents.d.ts +6 -0
- package/dist/events/hooks/useStridgeEvents.js +1 -0
- package/dist/events/hooks/useStridgeFlowEvent.d.ts +8 -0
- package/dist/events/hooks/useStridgeFlowEvent.js +1 -0
- package/dist/events/hooks/useStridgeFlowEvents.d.ts +6 -0
- package/dist/events/hooks/useStridgeFlowEvents.js +1 -0
- package/dist/events/index.d.ts +14 -0
- package/dist/events/index.js +1 -0
- package/dist/events/publish.js +1 -0
- package/dist/events/types/deposit.d.ts +235 -0
- package/dist/events/types/envelope.d.ts +145 -0
- package/dist/events/types/index.d.ts +31 -0
- package/dist/events/types/kit.d.ts +23 -0
- package/dist/events/types/withdraw.d.ts +150 -0
- package/dist/flows/deposit/dialog/DepositDialog.d.ts +14 -81
- package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
- package/dist/flows/deposit/dialog/WalletRequiredState.js +1 -0
- package/dist/flows/deposit/dialog/WalletRequiredState.styles.js +1 -0
- package/dist/flows/deposit/driver/payloads.d.ts +10 -4
- package/dist/flows/deposit/driver/transformers/balanceToBalancesPayload.js +1 -1
- package/dist/flows/deposit/driver/transformers/startToAddressesPayload.js +1 -1
- package/dist/flows/deposit/driver/transformers/startToTargetPayload.js +1 -1
- package/dist/flows/deposit/driver/types.d.ts +11 -0
- package/dist/flows/deposit/orchestrator/controller.js +1 -1
- package/dist/flows/deposit/orchestrator/types.d.ts +30 -1
- package/dist/flows/deposit/orchestrator/useDeposit.d.ts +45 -1
- package/dist/flows/deposit/orchestrator/useDeposit.js +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.d.ts +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/amount-entry/footerIntent.js +1 -0
- package/dist/flows/deposit/widgets/confirm-deposit/ConfirmDeposit.js +1 -1
- package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.d.ts +6 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/types.d.ts +6 -3
- package/dist/flows/deposit/widgets/deposit-status-banner/DepositStatusBanner.d.ts +7 -0
- package/dist/flows/deposit/widgets/deposit-status-banner/DepositStatusBanner.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/DepositStatusBanner.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/components/Hero.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/components/PrimaryAction.js +1 -1
- package/dist/flows/deposit/widgets/processing-state/ProcessingState.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/TransferCrypto.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/TransferCrypto.d.ts +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Address.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Disclosure.d.ts +2 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Disclosure.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.d.ts +4 -10
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.js +1 -1
- package/dist/flows/shared/transformers/pickRelevantSettlement.js +1 -1
- package/dist/flows/shared/transformers/testnets.js +1 -0
- package/dist/flows/withdraw/bindings/WithdrawBindings.d.ts +92 -0
- package/dist/flows/withdraw/bindings/WithdrawBindings.js +1 -0
- package/dist/flows/withdraw/bindings/index.d.ts +1 -0
- package/dist/flows/withdraw/bindings/index.js +1 -0
- package/dist/flows/withdraw/dialog/WithdrawDialog.d.ts +35 -71
- package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
- package/dist/flows/withdraw/driver/payloads.d.ts +16 -1
- package/dist/flows/withdraw/driver/transformers/settlementToWithdrawalPayload.js +1 -1
- package/dist/flows/withdraw/driver/transformers/supportedAssetsToReceiveOptionsPayload.js +1 -1
- package/dist/flows/withdraw/driver/types.d.ts +76 -13
- package/dist/flows/withdraw/orchestrator/controller.js +1 -1
- package/dist/flows/withdraw/orchestrator/index.d.ts +1 -1
- package/dist/flows/withdraw/orchestrator/reducer.js +1 -1
- package/dist/flows/withdraw/orchestrator/types.d.ts +131 -32
- package/dist/flows/withdraw/orchestrator/useWithdraw.d.ts +36 -1
- package/dist/flows/withdraw/orchestrator/useWithdraw.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.d.ts +5 -13
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.d.ts +7 -5
- package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/types.d.ts +15 -5
- package/dist/flows/withdraw/widgets/withdraw-form/validation.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-in-progress/WithdrawInProgress.d.ts +2 -1
- package/dist/flows/withdraw/widgets/withdraw-in-progress/WithdrawInProgress.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-success/WithdrawSuccess.js +1 -1
- package/dist/i18n/index.d.ts +5 -4
- package/dist/i18n/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 +12 -0
- package/dist/i18n/locales/source-keys.js +0 -0
- package/dist/icons/index.d.ts +2 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +21 -9
- package/dist/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/scope/KitPortalScope.js +1 -1
- package/dist/scope/KitScope.d.ts +18 -1
- package/dist/scope/KitScope.js +1 -1
- package/dist/scope/context.d.ts +17 -1
- package/dist/scope/index.d.ts +1 -1
- package/dist/shared/attribution/Attribution.js +1 -0
- package/dist/shared/attribution/Attribution.slots.js +1 -0
- package/dist/shared/attribution/Attribution.styles.js +1 -0
- package/dist/shared/attribution/index.js +1 -0
- package/dist/shared/chains/index.d.ts +48 -29
- package/dist/shared/chains/index.js +1 -1
- package/dist/shared/constants/brand-intercom.js +1 -0
- package/dist/shared/cuer/Cuer.js +1 -0
- package/dist/shared/cuer/QrCode.js +1 -0
- package/dist/shared/cuer/index.js +1 -0
- package/dist/shared/dialog/Frame.js +1 -1
- package/dist/shared/dialog/LoadingState.js +1 -0
- package/dist/shared/dialog/LoadingState.styles.js +1 -0
- package/dist/shared/dialog/StepTransition.js +1 -1
- package/dist/shared/driver/types.d.ts +4 -3
- package/dist/shared/i18n/KitI18nProvider.d.ts +11 -8
- package/dist/shared/i18n/KitI18nProvider.js +1 -1
- package/dist/shared/i18n/createKitI18n.d.ts +79 -16
- package/dist/shared/i18n/createKitI18n.js +1 -1
- package/dist/shared/i18n/useLingui.d.ts +11 -3
- package/dist/shared/icons/LogoIcon.d.ts +13 -0
- package/dist/shared/icons/LogoIcon.js +1 -0
- package/dist/shared/merchant-link/MerchantLink.d.ts +1 -0
- package/dist/shared/merchant-link/MerchantLink.js +1 -0
- package/dist/shared/merchant-link/MerchantLinkButton.d.ts +1 -0
- package/dist/shared/merchant-link/MerchantLinkButton.js +1 -0
- package/dist/shared/merchant-link/index.d.ts +1 -0
- package/dist/shared/merchant-link/index.js +1 -0
- package/dist/shared/merchant-link/resolveMerchantLink.js +1 -0
- package/dist/shared/orchestrator/useSettlementWatcher.js +1 -1
- package/dist/shared/primitives/TxHashValue/TxHashValue.js +1 -1
- package/dist/shared/support/SupportConfigContext.d.ts +1 -0
- package/dist/shared/support/SupportConfigContext.js +1 -0
- package/dist/shared/support/SupportLink.d.ts +1 -0
- package/dist/shared/support/SupportLink.js +1 -0
- package/dist/shared/support/SupportSpinner.d.ts +1 -0
- package/dist/shared/support/SupportSpinner.js +1 -0
- package/dist/shared/support/index.d.ts +2 -0
- package/dist/shared/support/index.js +1 -0
- package/dist/shared/support/intercom-loader.d.ts +17 -0
- package/dist/shared/support/intercom-loader.js +1 -0
- package/dist/shared/support/types.d.ts +43 -0
- package/dist/shared/support/useIntercomMerchantContext.d.ts +27 -0
- package/dist/shared/support/useIntercomMerchantContext.js +1 -0
- package/dist/shared/support/useIntercomShutdownOnUnmount.js +1 -0
- package/dist/shared/support/useMerchantContext.d.ts +1 -0
- package/dist/shared/support/useMerchantContext.js +1 -0
- package/dist/shared/support/useSupportTrigger.js +1 -0
- package/dist/shared/terms/TermsConfigContext.d.ts +1 -0
- package/dist/shared/terms/TermsConfigContext.js +1 -0
- package/dist/shared/terms/TermsLink.d.ts +1 -0
- package/dist/shared/terms/TermsLink.js +1 -0
- package/dist/shared/terms/index.d.ts +1 -0
- package/dist/shared/terms/index.js +1 -0
- package/dist/shared/terms/types.d.ts +43 -0
- package/dist/shared/ui/Card/Card.styles.js +1 -1
- package/dist/shared/ui/Details/Details.d.ts +9 -1
- package/dist/shared/ui/Details/Details.styles.js +1 -1
- package/dist/shared/ui/Dialog/Dialog.js +1 -1
- package/dist/shared/ui/Dialog/Dialog.styles.js +1 -1
- package/dist/shared/ui/Select/Select.js +1 -1
- package/dist/shared/ui/WalletRow/WalletRow.d.ts +1 -1
- package/dist/shared/ui/WalletRow/WalletRow.js +1 -1
- package/dist/shared/utils/useDeepMemo.js +1 -0
- package/dist/shared/wallet/ConnectWalletContext.d.ts +17 -0
- package/dist/shared/wallet/ConnectWalletContext.js +1 -0
- package/dist/shared/widgets/amount-entry/compound/components/Hero/Hero.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/SwapBackdrop.js +1 -1
- package/dist/shared/widgets/asset-picker/compound/components/Asset.d.ts +7 -1
- package/dist/shared/widgets/asset-picker/compound/components/Asset.js +1 -1
- package/dist/shared/widgets/confirm-transfer/compound/components/Disclaimer.d.ts +4 -3
- package/dist/shared/widgets/confirm-transfer/compound/components/Disclaimer.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/AssetValue.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/HelpInfo.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/StatusValue.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.d.ts +1 -5
- package/dist/shared/widgets/processing-state/compound/ProcessingState.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.slots.d.ts +0 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.slots.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.styles.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Details.d.ts +6 -1
- package/dist/shared/widgets/processing-state/compound/components/Details.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Header.d.ts +4 -3
- package/dist/shared/widgets/processing-state/compound/components/Header.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Hero.d.ts +14 -7
- package/dist/shared/widgets/processing-state/compound/components/Hero.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Rows.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/StatusPill.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/splitAmount.js +1 -0
- package/dist/shared/widgets/processing-state/compound/index.d.ts +1 -1
- package/dist/shared/widgets/processing-state/compound/types.d.ts +7 -26
- package/dist/shared/widgets/success-state/compound/components/Actions.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/AssetValue.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/RouteValue.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/StatusPill.js +1 -1
- package/dist/stridge/StridgeProvider.d.ts +165 -35
- package/dist/stridge/StridgeProvider.js +1 -1
- package/dist/stridge/depositOwner.js +1 -0
- package/dist/stridge/optionalWagmi.js +1 -0
- package/dist/stridge/stubs.js +1 -1
- package/dist/styles/index.css +126 -10
- package/dist/types.d.ts +5 -4
- package/dist/ui/index.js +1 -1
- package/dist/withdraw/compound/index.d.ts +2 -2
- package/dist/withdraw/dialog/index.d.ts +3 -1
- package/package.json +13 -9
- package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.d.ts +0 -36
- package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.js +0 -1
- package/dist/shared/widgets/processing-state/compound/components/Actions.d.ts +0 -17
- package/dist/shared/widgets/processing-state/compound/components/Actions.js +0 -1
- package/dist/stridge/StridgeContext.d.ts +0 -29
- package/dist/stridge/StridgeContext.js +0 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { TxRef } from "../../../shared/driver/types.js";
|
|
2
|
-
import { BalanceItemPayload, QuotePayload, SettlementFailurePayload, SettlementPendingPayload, SettlementSuccessPayload } from "../driver/payloads.js";
|
|
3
|
-
import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
4
|
-
import { DepositMethod, DepositState, DepositStateName, ResolvedOpenInput } from "../orchestrator/types.js";
|
|
5
1
|
import { ErrorInfo } from "react";
|
|
6
2
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
3
|
|
|
@@ -16,19 +12,16 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
16
12
|
* renders content per state. Skip the dialog entirely for fully custom UI — render against
|
|
17
13
|
* `useDeposit()` / `useDepositState()` / `useDepositSnapshot()` directly.
|
|
18
14
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
15
|
+
* Lifecycle observability is delivered by the unified event bus exported from
|
|
16
|
+
* `@stridge/kit/events`. The dialog itself takes no `on*` callback props — subscribe via
|
|
17
|
+
* `useStridgeFlowEvents` / `useStridgeEvents` (or the single-event variants) anywhere in
|
|
18
|
+
* the provider subtree.
|
|
23
19
|
*/
|
|
24
20
|
declare function DepositDialog({
|
|
25
21
|
container,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onError,
|
|
30
|
-
events
|
|
31
|
-
}: DepositDialog.Props): _$react_jsx_runtime0.JSX.Element;
|
|
22
|
+
metadata,
|
|
23
|
+
onError
|
|
24
|
+
}?: DepositDialog.Props): _$react_jsx_runtime0.JSX.Element;
|
|
32
25
|
declare namespace DepositDialog {
|
|
33
26
|
interface Props {
|
|
34
27
|
/**
|
|
@@ -37,76 +30,16 @@ declare namespace DepositDialog {
|
|
|
37
30
|
* dialog's width, height, and backdrop to that rect.
|
|
38
31
|
*/
|
|
39
32
|
container?: HTMLElement | null;
|
|
40
|
-
/** Forwarded to the dialog's internal {@link GatewayKitBoundary} for crash reporting. */
|
|
41
|
-
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Fires once when the dialog transitions from `closed` to any open step. Receives the
|
|
44
|
-
* resolved open input derived from the entry state.
|
|
45
|
-
*/
|
|
46
|
-
onOpened?: (input: ResolvedOpenInput) => void;
|
|
47
|
-
/** Fires once when the dialog transitions back to `closed`. `atStep` is the last open step. */
|
|
48
|
-
onClosed?: (atStep: DepositStateName) => void;
|
|
49
|
-
/** Fires on every logical step transition. */
|
|
50
|
-
onStepChanged?: (event: {
|
|
51
|
-
from: DepositStateName;
|
|
52
|
-
to: DepositStateName;
|
|
53
|
-
ctx: GatewayContext | null;
|
|
54
|
-
}) => void;
|
|
55
|
-
/** Operational events — user actions, async outcomes, settlement-entity transitions. */
|
|
56
|
-
events?: Events;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Operational lifecycle hooks. Fire after the controller has acted (state machine has
|
|
60
|
-
* transitioned, driver entity has settled), so payloads are guaranteed valid for the named
|
|
61
|
-
* event.
|
|
62
|
-
*/
|
|
63
|
-
interface Events {
|
|
64
|
-
/** User picked a deposit method on the `Deposit` step. */
|
|
65
|
-
onMethodSelected?: (method: DepositMethod) => void;
|
|
66
|
-
/** User confirmed an asset on the `AssetPicker` step. The asset is the driver-shaped balance row. */
|
|
67
|
-
onAssetSelected?: (asset: BalanceItemPayload) => void;
|
|
68
|
-
/** User submitted an amount on the `AmountEntry` step. */
|
|
69
|
-
onAmountSubmitted?: (amount: number) => void;
|
|
70
|
-
/** User confirmed the deposit on the `ConfirmDeposit` step (wallet prompt is about to fire). */
|
|
71
|
-
onDepositConfirmed?: () => void;
|
|
72
|
-
/** User pressed Back on a non-root step. */
|
|
73
|
-
onBackPressed?: (fromStep: DepositStateName) => void;
|
|
74
|
-
/** Orchestrator requested a quote (`confirmDeposit` entered `loading` or `regenerating`). */
|
|
75
|
-
onQuoteRequested?: (input: {
|
|
76
|
-
asset: BalanceItemPayload;
|
|
77
|
-
amount: number;
|
|
78
|
-
}) => void;
|
|
79
|
-
/** Orchestrator received a successful quote — fires when the driver's `quote` entity transitions to `ready`. */
|
|
80
|
-
onQuoteResolved?: (quote: QuotePayload) => void;
|
|
81
|
-
/** Quote fetch failed (FSM `confirmDeposit{phase: failed, recoverFrom: "quote"}`). */
|
|
82
|
-
onQuoteFailed?: (failure: FailureInfo) => void;
|
|
83
|
-
/** A quote silently expired and a regeneration started (no user interaction). */
|
|
84
|
-
onQuoteExpired?: () => void;
|
|
85
|
-
/** Wallet broadcast a deposit tx; the orchestrator transitioned into `processing`. */
|
|
86
|
-
onDepositSubmitted?: (tx: TxRef) => void;
|
|
87
|
-
/** User declined the wallet signature prompt; orchestrator regenerated the quote. */
|
|
88
|
-
onSignatureDeclined?: () => void;
|
|
89
|
-
/** Deposit submission failed for a non-rejection reason. */
|
|
90
|
-
onSubmissionFailed?: (failure: FailureInfo) => void;
|
|
91
|
-
/** The driver's `settlement` entity emitted a progressive pending update. */
|
|
92
|
-
onProcessingProgress?: (update: SettlementPendingPayload) => void;
|
|
93
|
-
/** Terminal success — settlement entity reached `ready{kind: "succeeded"}`. */
|
|
94
|
-
onSucceeded?: (result: SettlementSuccessPayload) => void;
|
|
95
33
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
34
|
+
* Consumer-attached metadata that rides along on every bus event emitted from this
|
|
35
|
+
* dialog's session. Snapshotted at `deposit.opened` and frozen for the session —
|
|
36
|
+
* mid-flow prop changes are ignored to keep correlation consistent from `opened` to
|
|
37
|
+
* the terminal event. The kit does not validate or normalise the shape.
|
|
98
38
|
*/
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
* `settlement` entity transitioned from `idle` / `loading` straight to a pending payload.
|
|
103
|
-
*/
|
|
104
|
-
onPendingSnapshotDetected?: (snapshot: SettlementPendingPayload) => void;
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
/** Forwarded to the dialog's internal {@link GatewayKitBoundary} for crash reporting. */
|
|
41
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
105
42
|
}
|
|
106
43
|
}
|
|
107
|
-
/** Convenience union — the `ctx` payload on `onStepChanged`. */
|
|
108
|
-
type GatewayContext = Exclude<DepositState, {
|
|
109
|
-
name: "closed";
|
|
110
|
-
}>["ctx"];
|
|
111
44
|
//#endregion
|
|
112
45
|
export { DepositDialog };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositSnapshot as e}from"../driver/context.js";import{
|
|
1
|
+
"use client";import{useDepositSnapshot as e}from"../driver/context.js";import{useControllerContext as t}from"../orchestrator/controller.js";import{useDepositEmissions as n}from"../../../events/emit/useDepositEmissions.js";import"../../../events/emit/index.js";import{useIntercomShutdownOnUnmount as r}from"../../../shared/support/useIntercomShutdownOnUnmount.js";import"../../../shared/support/index.js";import{useDepositOwnerContext as i}from"../../../stridge/depositOwner.js";import{Dialog as a}from"../../../shared/ui/Dialog/Dialog.js";import"../../../shared/ui/Dialog/index.js";import{AmountEntry as o}from"../widgets/amount-entry/AmountEntry.js";import"../widgets/amount-entry/index.js";import{AssetPicker as s}from"../widgets/asset-picker/AssetPicker.js";import"../widgets/asset-picker/index.js";import{ConfirmDeposit as c}from"../widgets/confirm-deposit/ConfirmDeposit.js";import"../widgets/confirm-deposit/index.js";import{Deposit as l}from"../widgets/deposit/Deposit.js";import"../widgets/deposit/index.js";import{DepositStatusBanner as u}from"../widgets/deposit-status-banner/DepositStatusBanner.js";import"../widgets/deposit-status-banner/index.js";import{ErrorState as d}from"../widgets/error-state/ErrorState.js";import"../widgets/error-state/index.js";import{ProcessingState as f}from"../widgets/processing-state/ProcessingState.js";import"../widgets/processing-state/index.js";import{SuccessState as p}from"../widgets/success-state/SuccessState.js";import"../widgets/success-state/index.js";import{TransferCrypto as m}from"../widgets/transfer-crypto/TransferCrypto.js";import"../widgets/transfer-crypto/index.js";import{LoadingState as h}from"../../../shared/dialog/LoadingState.js";import{StepTransition as g}from"../../../shared/dialog/StepTransition.js";import{GatewayKitBoundary as _}from"../../../shared/error-handling/components/GatewayKitBoundary.js";import"../../../shared/error-handling/index.js";import{DepositBootstrapErrorState as v}from"./DepositBootstrapErrorState.js";import{WalletRequiredState as y}from"./WalletRequiredState.js";import{jsx as b,jsxs as x}from"react/jsx-runtime";const S=new Set([`deposit`,`assetPicker`,`amountEntry`,`confirmDeposit`,`transferCrypto`]);function C({container:C,metadata:w,onError:T}={}){let{state:E,effectiveState:D,controller:O}=t(),k=e(),A=i(),j=E.name!==`closed`;n({state:E,settlement:k.settlement,quote:k.quote,metadata:w}),r();let M=D,N=A!==null&&!A.resolved&&S.has(M.name),P=!N&&k.target.status===`error`&&S.has(M.name),F=!N&&!P&&(k.target.status===`loading`||k.target.status===`idle`)&&S.has(M.name);return b(a,{open:j,onOpenChange:e=>{e||O.close()},children:b(a.Content,{container:C,children:x(_,{onError:T,onReset:O.close,children:[N?b(y,{}):P?b(v,{}):F?b(h,{slot:`deposit`}):x(g,{stateKey:M.name,children:[M.name===`deposit`?b(l,{}):null,M.name===`assetPicker`?b(s,{}):null,M.name===`amountEntry`?b(o,{}):null,M.name===`confirmDeposit`?b(c,{}):null,M.name===`transferCrypto`?b(m,{}):null,M.name===`processing`?b(f,{}):null,M.name===`success`?b(p,{}):null,M.name===`error`?b(d,{}):null]}),b(u,{})]})})})}export{C as DepositDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Trans as e}from"../../../shared/i18n/Trans.js";import"../../../i18n/index.js";import{useDepositActions as t}from"../orchestrator/controller.js";import{WalletIcon as n}from"../../../shared/icons/WalletIcon.js";import"../../../icons/index.js";import{useConnectWallet as r}from"../../../shared/wallet/ConnectWalletContext.js";import{Button as i}from"../../../shared/ui/Button/Button.js";import{Dialog as a}from"../../../shared/ui/Dialog/Dialog.js";import"../../../shared/ui/Dialog/index.js";import{Card as o}from"../../../shared/ui/Card/Card.js";import{text as s}from"../../../shared/ui/Text/Text.js";import"../../../ui/index.js";import{Frame as c}from"../../../shared/dialog/Frame.js";import{styles as l}from"./WalletRequiredState.styles.js";import{jsx as u,jsxs as d}from"react/jsx-runtime";import*as f from"@stylexjs/stylex";function p(){return d(`div`,{"aria-hidden":!0,...f.props(l.heroRing),children:[d(`svg`,{viewBox:`0 0 64 64`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,...f.props(l.heroRingSvg),children:[u(`circle`,{cx:`32`,cy:`32`,r:`28`,strokeWidth:`2`,style:{stroke:`color-mix(in oklab, var(--stridge-kit-info) 55%, transparent)`}}),u(`circle`,{cx:`32`,cy:`32`,r:`20`,style:{fill:`var(--stridge-kit-info)`}})]}),u(n,{style:{color:`var(--stridge-kit-info-foreground)`},...f.props(l.heroRingGlyph)})]})}function m(){let{close:n}=t(),m=r();return d(c,{"data-stridge-slot":`deposit-wallet-required`,"data-testid":`deposit-wallet-required`,...f.props(l.root),children:[d(o.Header,{...f.props(l.header),children:[u(s.span,{size:`base`,fontWeight:`semibold`,leading:`tight`,tracking:`tight`,children:u(e,{id:`5AApJw`,message:`Connect a wallet to continue`})}),u(a.CloseButton,{})]}),u(o.Body,{children:d(`div`,{"data-stridge-slot":`deposit-wallet-required-hero`,...f.props(l.hero),children:[u(p,{}),u(s.span,{size:`lg`,fontWeight:`semibold`,leading:`tight`,tracking:`tight`,align:`center`,...f.props(l.heroHeadline),children:u(e,{id:`BoQOH3`,message:`A wallet is required to deposit`})}),u(s.span,{size:`sm`,leading:`normal`,align:`center`,color:`subdued`,...f.props(l.heroReason),children:u(e,{id:`mF_ucv`,message:`Connect a wallet so the gateway can provision a deposit address and route your transfer.`})})]})}),d(o.Footer,{...f.props(l.footer),children:[m?u(i,{variant:`default`,size:`cta`,onClick:()=>{m.onClick()},"data-stridge-slot":`deposit-wallet-required-connect`,...f.props(l.cta),children:m.label??u(e,{id:`VHOVEJ`,message:`Connect wallet`})}):null,u(i,{variant:m?`ghost`:`default`,size:`cta`,onClick:n,"data-stridge-slot":`deposit-wallet-required-close`,...f.props(l.cta),children:u(e,{id:`yz7wBu`,message:`Close`})})]})]})}export{m as WalletRequiredState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={root:{"WalletRequiredState__styles.root":`WalletRequiredState__styles.root`,"position-kVAEAm":`x1n2onr6`,"width-kzqmXN":`xh8yej3`,"maxWidth-ks0D6T":`x17fpy1y`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:25`},header:{"WalletRequiredState__styles.header":`WalletRequiredState__styles.header`,"justifyContent-kjj79g":`x1qughib`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:34`},hero:{"WalletRequiredState__styles.hero":`WalletRequiredState__styles.hero`,"display-k1xSpc":`x78zum5`,"flexDirection-kXwgrk":`xdt5ytf`,"alignItems-kGNEyG":`x6s0dn4`,"gap-kOIVth":`x883omv`,"paddingTop-kLKAdn":`x9desvi`,"paddingInline-kg3NbH":`x65v0h`,"paddingBottom-kGO01o":`x1hhzuzn`,"animationName-kKVMdj":`xv305lp`,"animationDuration-k44tkh":`xmprevt x1s1fvk8`,"animationTimingFunction-kyAemX":`xrkt6z0`,"animationFillMode-kWV6AL":`x1u6ievf`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:42`},heroRing:{"WalletRequiredState__styles.heroRing":`WalletRequiredState__styles.heroRing`,"position-kVAEAm":`x1n2onr6`,"width-kzqmXN":`x1fu8urw`,"height-kZKoxP":`x1peatla`,"flexShrink-kmuXW":`x2lah0s`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:64`},heroRingSvg:{"WalletRequiredState__styles.heroRingSvg":`WalletRequiredState__styles.heroRingSvg`,"display-k1xSpc":`x1lliihq`,"width-kzqmXN":`xh8yej3`,"height-kZKoxP":`x5yr21d`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:73`},heroRingGlyph:{"WalletRequiredState__styles.heroRingGlyph":`WalletRequiredState__styles.heroRingGlyph`,"position-kVAEAm":`x10l6tqk`,"insetInlineStart-kLqNvP":`xbudbmw`,"top-k87sOh":`xwa60dl`,"transform-k3aq6I":`x11lhmoz`,"width-kzqmXN":`xgd8bvy`,"height-kZKoxP":`x1fgtraw`,"strokeWidth-kfJifR":`xvlca1e`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:87`},heroHeadline:{"WalletRequiredState__styles.heroHeadline":`WalletRequiredState__styles.heroHeadline`,"marginTop-keoZOQ":`x1k70j0n`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:96`},heroReason:{"WalletRequiredState__styles.heroReason":`WalletRequiredState__styles.heroReason`,"maxWidth-ks0D6T":`x1va8c73`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:99`},footer:{"WalletRequiredState__styles.footer":`WalletRequiredState__styles.footer`,"display-k1xSpc":`x78zum5`,"flexDirection-kXwgrk":`xdt5ytf`,"alignItems-kGNEyG":`x1qjc9v5`,"gap-kOIVth":`x1a6yh9e`,"paddingTop-kLKAdn":`x109j2v6`,"paddingInline-kg3NbH":`x65v0h`,"paddingBottom-kGO01o":`x1t4gjm`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:107`},cta:{"WalletRequiredState__styles.cta":`WalletRequiredState__styles.cta`,"width-kzqmXN":`xh8yej3`,"alignSelf-kSGwAc":`xkh2ocl`,$$css:`@stridge/kit:src/flows/deposit/dialog/WalletRequiredState.styles.ts:116`}};export{e as styles};
|
|
@@ -95,7 +95,13 @@ interface AssetPayload {
|
|
|
95
95
|
*/
|
|
96
96
|
interface TargetPayload extends ChainPayload, AssetPayload {
|
|
97
97
|
/** Optional minimum-deposit USD floor surfaced on amount-entry / asset-picker chrome. */
|
|
98
|
-
|
|
98
|
+
minAmountUsd?: FormattedField<number>;
|
|
99
|
+
/**
|
|
100
|
+
* Optional upper USD bound on the deposit amount. When set, the amount-entry treats
|
|
101
|
+
* `min(walletBalanceUsd, maxAmountUsd.value)` as the effective ceiling. Omitted when the
|
|
102
|
+
* host did not configure `flows.deposit.maxAmountUsd`.
|
|
103
|
+
*/
|
|
104
|
+
maxAmountUsd?: FormattedField<number>;
|
|
99
105
|
}
|
|
100
106
|
/**
|
|
101
107
|
* Per-chain deposit address provisioned by `gateway/start`. The kit ships one envelope item per
|
|
@@ -111,9 +117,9 @@ interface AddressItemPayload extends ChainPayload {
|
|
|
111
117
|
* Per-chain minimum-deposit USD floor surfaced next to the chain row in the transfer-crypto
|
|
112
118
|
* picker (`"Min $5"`). Drivers populate this from `supportedAssets`'s per-(chain × asset)
|
|
113
119
|
* floors so the user sees the right number for the chain they're funding from. Optional —
|
|
114
|
-
* the picker falls back to {@link TargetPayload.
|
|
120
|
+
* the picker falls back to {@link TargetPayload.minAmountUsd} when this isn't available.
|
|
115
121
|
*/
|
|
116
|
-
|
|
122
|
+
minAmountUsd?: FormattedField<number>;
|
|
117
123
|
/**
|
|
118
124
|
* Tokens the gateway accepts on this chain (`gateway/start.deposit_addresses[i].accepted_assets`).
|
|
119
125
|
* Drives the transfer-crypto Tokens dropdown — when the user picks a chain, the dropdown
|
|
@@ -154,7 +160,7 @@ interface BalanceItemPayload extends ChainPayload, AssetPayload {
|
|
|
154
160
|
priceUsd?: number;
|
|
155
161
|
/**
|
|
156
162
|
* `true` when this row's USD value is below the kit's deposit floor
|
|
157
|
-
* ({@link TargetPayload.
|
|
163
|
+
* ({@link TargetPayload.minAmountUsd}). Drives the muted "Low Balance" badge in the asset
|
|
158
164
|
* picker; the row remains visible so the user knows the asset exists in the wallet.
|
|
159
165
|
*/
|
|
160
166
|
lowBalance?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseDecimalSafe as e}from"../../../shared/transformers/parseSmallestUnit.js";import{formatTokenAmount as t}from"../../../../shared/format/formatTokenAmount.js";import{formatUsd as n}from"../../../../shared/format/formatUsd.js";function r(e){let t=new Set,n=new Set;for(let r of e.assets){let e=String(r.eip155_id);t.add(e);for(let t of r.assets)t.address&&n.add(`${e}:${t.address.toLowerCase()}`)}return{nativeChains:t,tokens:n}}function i(e,t){let n=t.routable!==void 0&&(t.routable.nativeChains.size>0||t.routable.tokens.size>0),r=[];for(let i of e.chains)for(let e of i.tokens)e.is_spam||n&&t.routable&&!o(i.eip155_id,e,t.routable)||r.push(a(i.label,i.eip155_id,i.stridge_network_id,e,t));return r.sort(s),r}function a(r,i,a,o,s){let c=e(o.amount),l=e(o.amount_usd),u=e(o.usd_price),d=s.resolveTokenIcon?.({chainId:i,tokenAddress:o.token_address,symbol:o.symbol,isNative:o.is_native})??s.logos?.(i,o.token_address,o.is_native)??o.logo??void 0,f=s.
|
|
1
|
+
import{parseDecimalSafe as e}from"../../../shared/transformers/parseSmallestUnit.js";import{formatTokenAmount as t}from"../../../../shared/format/formatTokenAmount.js";import{formatUsd as n}from"../../../../shared/format/formatUsd.js";function r(e){let t=new Set,n=new Set;for(let r of e.assets){let e=String(r.eip155_id);t.add(e);for(let t of r.assets)t.address&&n.add(`${e}:${t.address.toLowerCase()}`)}return{nativeChains:t,tokens:n}}function i(e,t){let n=t.routable!==void 0&&(t.routable.nativeChains.size>0||t.routable.tokens.size>0),r=[];for(let i of e.chains)for(let e of i.tokens)e.is_spam||n&&t.routable&&!o(i.eip155_id,e,t.routable)||r.push(a(i.label,i.eip155_id,i.stridge_network_id,e,t));return r.sort(s),r}function a(r,i,a,o,s){let c=e(o.amount),l=e(o.amount_usd),u=e(o.usd_price),d=s.resolveTokenIcon?.({chainId:i,tokenAddress:o.token_address,symbol:o.symbol,isNative:o.is_native})??s.logos?.(i,o.token_address,o.is_native)??o.logo??void 0,f=s.minAmountUsd!==void 0&&s.minAmountUsd>0&&l<s.minAmountUsd;return{networkId:a,networkName:r,eip155Id:String(i),symbol:o.symbol,decimals:o.decimals,address:o.token_address||`0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`,isNative:o.is_native,...d?{assetLogoUrl:d}:{},amount:{value:c,formatted:t(c,s.i18n,{compact:!0})},...l>0?{amountUsd:{value:l,formatted:n(l,s.i18n)}}:{},...u>0?{priceUsd:u}:{},...f?{lowBalance:!0,disabled:!0}:{}}}function o(e,t,n){let r=String(e);return t.is_native?n.nativeChains.has(r):t.token_address?n.tokens.has(`${r}:${t.token_address.toLowerCase()}`):!1}function s(e,t){return(t.amountUsd?.value??0)-(e.amountUsd?.value??0)}export{i as balanceToBalancesPayload,r as buildRoutableAllowlist};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{KNOWN_TESTNET_EIP155_IDS as e}from"../../../shared/transformers/testnets.js";import{formatNetworkName as t}from"../../../../shared/format/formatNetworkName.js";import{formatUsd as n}from"../../../../shared/format/formatUsd.js";import{shortenAddress as r}from"../../../../shared/format/shortenAddress.js";function i(i,o={}){let s=o.includeTestnets??!1;return i.flatMap(i=>{let c=String(i.eip155_id??``),l=Number(c);if(!s&&Number.isFinite(l)&&e.has(l))return[];let u=o.explorers?.[l],d=o.i18n&&c?o.minAmountUsdByEip155Id?.[c]:void 0,f=a(i.accepted_assets,c?o.nativeAssetByEip155Id?.[c]:void 0);return[{networkName:t(i.network_name??``),...c?{eip155Id:c}:{},...o.chainLogos?.[c]?{chainLogoUrl:o.chainLogos[c]}:{},address:{value:i.address,formatted:r(i.address)},...u?{explorerUrl:`${u.replace(/\/+$/,``)}/address/${i.address}`}:{},...d!==void 0&&o.i18n?{minAmountUsd:{value:d,formatted:n(d,o.i18n)}}:{},...f.length>0?{acceptedAssets:f}:{}}]})}function a(e,t){let n=Array.isArray(e)?e.map(o):[];return!t||new Set(n.map(e=>e.symbol.toUpperCase())).has(t.symbol.toUpperCase())?n:[t,...n]}function o(e){let t=e.logo,n=!e.address;return{symbol:e.symbol,address:e.address,decimals:e.decimals,...typeof t==`string`&&t.length>0?{assetLogoUrl:t}:{},isNative:n}}export{i as startToAddressesPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatNetworkName as e}from"../../../../shared/format/formatNetworkName.js";import{formatUsd as t}from"../../../../shared/format/formatUsd.js";function n(n,r){let i=n.assets.find(e=>String(e.network_id)===r.networkId);if(!i)return;let a=i.assets.find(e=>e.symbol.toUpperCase()===r.assetSymbol.toUpperCase());if(!a)return;let o=i.native_currency?.logo;return{networkId:r.networkId,networkName:e(i.network_name),eip155Id:String(i.eip155_id),...o?{chainLogoUrl:o}:{},symbol:a.symbol,decimals:a.decimals,address:a.address??``,isNative:!a.address,...a.logo?{assetLogoUrl:a.logo}:{},...r.
|
|
1
|
+
import{formatNetworkName as e}from"../../../../shared/format/formatNetworkName.js";import{formatUsd as t}from"../../../../shared/format/formatUsd.js";function n(n,r){let i=n.assets.find(e=>String(e.network_id)===r.networkId);if(!i)return;let a=i.assets.find(e=>e.symbol.toUpperCase()===r.assetSymbol.toUpperCase());if(!a)return;let o=i.native_currency?.logo;return{networkId:r.networkId,networkName:e(i.network_name),eip155Id:String(i.eip155_id),...o?{chainLogoUrl:o}:{},symbol:a.symbol,decimals:a.decimals,address:a.address??``,isNative:!a.address,...a.logo?{assetLogoUrl:a.logo}:{},...r.minAmountUsd===void 0?{}:{minAmountUsd:{value:r.minAmountUsd,formatted:t(r.minAmountUsd,r.i18n)}},...r.maxAmountUsd===void 0?{}:{maxAmountUsd:{value:r.maxAmountUsd,formatted:t(r.maxAmountUsd,r.i18n)}}}}export{n as startToTargetPayload};
|
|
@@ -139,6 +139,17 @@ interface DepositDriver {
|
|
|
139
139
|
getSnapshot(): DepositSnapshot;
|
|
140
140
|
/** Lets you subscribe to entity transitions outside React (analytics, headless integrations). */
|
|
141
141
|
subscribe(listener: () => void): () => void;
|
|
142
|
+
/**
|
|
143
|
+
* Idempotent bootstrap trigger. The kit calls this from `useDeposit().open()` and the
|
|
144
|
+
* headless `usePrefetchDeposit()` hook. First call kicks off any deferred network work
|
|
145
|
+
* (`gateway/start`, `supportedAssets`, the initial `balance/onchain` fetch); subsequent
|
|
146
|
+
* calls are no-ops while bootstrap is in flight or completed.
|
|
147
|
+
*
|
|
148
|
+
* BYO drivers that bootstrap eagerly can implement this as a no-op — the contract is "after
|
|
149
|
+
* `arm()` returns, the driver's entities are either already populated or will populate as
|
|
150
|
+
* soon as the first network round-trips land".
|
|
151
|
+
*/
|
|
152
|
+
arm(): void;
|
|
142
153
|
/**
|
|
143
154
|
* Fetches a fresh quote for `input` and updates the `quote` entity through its lifecycle
|
|
144
155
|
* (`idle | loading → ready | error`). The optional `signal` cancels in-flight work.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositDriverInstance as e}from"../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{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{initialState as s,reducer as c}from"./reducer.js";import{resolveAssetById as l}from"./resolveAssetById.js";import{createContext as u,use as d,useCallback as f,useEffect as p,useMemo as m,useReducer as h,useRef as g}from"react";import{jsx as _}from"react/jsx-runtime";const v={id:`ELhVSL`,message:`Failed to submit deposit.`},y={id:`Ej5HL9`,message:`Signature declined. Please try again.`},b=u(null);b.displayName=`GatewayControllerContext`;function x(){let e=d(b);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function S(){return x().state}function
|
|
1
|
+
"use client";import{useDepositDriverInstance as e}from"../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{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{initialState as s,reducer as c}from"./reducer.js";import{resolveAssetById as l}from"./resolveAssetById.js";import{createContext as u,use as d,useCallback as f,useEffect as p,useMemo as m,useReducer as h,useRef as g}from"react";import{jsx as _}from"react/jsx-runtime";const v={id:`ELhVSL`,message:`Failed to submit deposit.`},y={id:`Ej5HL9`,message:`Signature declined. Please try again.`},b=u(null);b.displayName=`GatewayControllerContext`;function x(){let e=d(b);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function S(){return d(b)}const C=u(void 0);C.displayName=`DepositMethodsConfigContext`;function w(){return d(C)}function T(){return x().state}function E(){return x().effectiveState}function D(){return x().actions}function O({methodsConfig:t,children:n}){let r=e(),[a,o]=h(c,s),l=A(a,o,r);j(a,o,r),M(a,o,r);let u=i(a),d=k(a,o,r,l,t);return _(C,{value:t,children:_(b,{value:m(()=>({state:a,effectiveState:u,dispatch:o,controller:d,actions:l}),[a,u,d,l]),children:n})})}function k(e,t,n,r,i){let a=g(n);a.current=n;let o=g(i);o.current=i;let s=f(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=l(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=f(()=>{t({type:`CLOSE`})},[t]);return m(()=>({open:s,close:c,actions:r}),[s,c,r])}function A(e,r,i){let o=g(e);o.current=e;let s=g(i);s.current=i;let c=g(r);c.current=r;let{i18n:l}=t(),u=g(l);u.current=l;let d=f((e,t)=>{let r=s.current,i=new AbortController,o=P(e,t);r.submitDeposit(o,i.signal).then(e=>{i.signal.aborted||c.current({type:`DEPOSIT_SUBMITTED`,tx:e})}).catch(e=>{if(i.signal.aborted)return;let t=n(e,u.current._(v));if(a(t)){c.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:u.current._(y)});return}c.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),p=f(e=>{c.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),h=f(e=>{c.current({type:`ASSET_CONFIRMED`,asset:e})},[]),_=f(e=>{o.current.name===`amountEntry`&&c.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),b=f(()=>{let e=o.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){c.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;c.current({type:`DEPOSIT_CONFIRMED`}),d(n,r)},[d]),x=f(()=>{c.current({type:`BACK`})},[]),S=f(()=>{c.current({type:`CLOSE`})},[]),C=f(()=>{c.current({type:`SUCCESS_DONE`})},[]),w=f(()=>{c.current({type:`ERROR_TRY_AGAIN`})},[]),T=f((e,t)=>{c.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),E=f((e,t)=>{c.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),D=f(e=>{c.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]);return m(()=>({selectMethod:p,confirmAsset:h,confirmAmount:_,confirmDeposit:b,back:x,close:S,successDone:C,tryAgain:w,resumeToProcessing:T,resumeToSuccess:E,resumeToError:D}),[p,h,_,b,x,S,C,w,T,E,D])}function j(e,t,r){p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=N(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.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,r,t]),p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function M(e,t,n){let i=e.name===`processing`?e.ctx.tx:void 0;o(n,i?{tx:i}:void 0,i?.hash),p(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{t.signal.aborted||r||(r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal))},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]),p(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||!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,n]);let a=g(e);a.current=e,r(n,e=>{a.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let s=g(null);p(()=>{let e=()=>{let e=n.getSnapshot(),r=a.current,i=e.quote;i.status!==s.current&&(s.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}}))},r=n.subscribe(e);return e(),r},[n,t])}function N(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 P(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{O as GatewayController,x as useControllerContext,D as useDepositActions,E as useDepositEffectiveState,w as useDepositMethodsConfig,T as useDepositState,S as useOptionalControllerContext};
|
|
@@ -9,6 +9,35 @@ import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
|
9
9
|
* (transfer-crypto → process).
|
|
10
10
|
*/
|
|
11
11
|
type DepositMethod = "wallet" | "transfer";
|
|
12
|
+
/**
|
|
13
|
+
* Host-supplied disable lever for a single payment method on the deposit-method picker. The host
|
|
14
|
+
* decides eligibility — the kit ships no per-host inference (embedded vs. external wallet,
|
|
15
|
+
* region, KYC tier, …). When `disabled` is true the tile stays in the picker (preserves
|
|
16
|
+
* discoverability), renders natively disabled, can't be selected, and shows `disabledHint` as
|
|
17
|
+
* the inline meta line below the title (also folded into the tile's accessible name so screen
|
|
18
|
+
* readers convey the reason).
|
|
19
|
+
*/
|
|
20
|
+
interface DepositMethodConfig {
|
|
21
|
+
/** When true, the method is rendered disabled and can't be selected. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Plain-text reason shown inline as the tile's meta line — replaces the address+balance
|
|
25
|
+
* reading on the wallet tile and the `"No limit · Instant"` reading on the transfer tile so
|
|
26
|
+
* the explanation is unmissable and the auto-derived signals (which can read misleadingly,
|
|
27
|
+
* e.g. an embedded wallet's $0.00) are suppressed. Also folded into the tile's accessible
|
|
28
|
+
* name so screen readers convey it alongside the title. Ignored when `disabled` is falsy.
|
|
29
|
+
*/
|
|
30
|
+
disabledHint?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Per-method host configuration for the deposit picker. Omitting a method (or the whole object)
|
|
34
|
+
* keeps default behavior; supply `{ disabled: true, disabledHint: "…" }` to mark an option as
|
|
35
|
+
* unavailable for the current user.
|
|
36
|
+
*/
|
|
37
|
+
interface DepositMethodsConfig {
|
|
38
|
+
wallet?: DepositMethodConfig;
|
|
39
|
+
transfer?: DepositMethodConfig;
|
|
40
|
+
}
|
|
12
41
|
/**
|
|
13
42
|
* Confirm-deposit phase sub-union. Drives the confirm-deposit widget's hero / footer chrome.
|
|
14
43
|
* Phase data is pure navigation; the actual quote payload comes from the driver's `quote` entity.
|
|
@@ -263,4 +292,4 @@ interface DepositActions {
|
|
|
263
292
|
resumeToError(tx?: TxRef): void;
|
|
264
293
|
}
|
|
265
294
|
//#endregion
|
|
266
|
-
export { ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec };
|
|
295
|
+
export { ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec };
|
|
@@ -31,5 +31,49 @@ import { DepositController } from "./types.js";
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare function useDeposit(): DepositController;
|
|
34
|
+
/**
|
|
35
|
+
* Non-throwing variant of {@link useDeposit} — returns `null` when called outside a
|
|
36
|
+
* `<KitProvider deposit={…} />`. Lets hosts mount `<StridgeProvider />` conditionally
|
|
37
|
+
* (e.g. only after a wallet is connected) without descendants crashing the moment they render
|
|
38
|
+
* before the provider exists.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const deposit = useOptionalDeposit();
|
|
43
|
+
* return (
|
|
44
|
+
* <button onClick={() => deposit?.open()} disabled={!deposit}>
|
|
45
|
+
* Deposit
|
|
46
|
+
* </button>
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function useOptionalDeposit(): DepositController | null;
|
|
51
|
+
/**
|
|
52
|
+
* Headless prefetch handle for the deposit driver. Returns a stable function that arms the
|
|
53
|
+
* driver — kicks off the deferred `gateway/start` + `supportedAssets` + initial `balance/onchain`
|
|
54
|
+
* bootstrap. Calling it before the user opens the dialog warms the cache so the subsequent
|
|
55
|
+
* `useDeposit().open()` lands on populated data without a perceptible loading window.
|
|
56
|
+
*
|
|
57
|
+
* The function is fire-and-forget: returns `void`. To observe bootstrap state, read
|
|
58
|
+
* `useDepositSnapshot().target.status` directly — the snapshot is the single source of truth.
|
|
59
|
+
*
|
|
60
|
+
* The most common use is hover-to-warm:
|
|
61
|
+
*
|
|
62
|
+
* ```tsx
|
|
63
|
+
* const deposit = useDeposit();
|
|
64
|
+
* const prefetchDeposit = usePrefetchDeposit();
|
|
65
|
+
* <button onMouseEnter={prefetchDeposit} onClick={() => deposit.open()}>Deposit</button>;
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Headless balance widgets that need data on render call this in an effect:
|
|
69
|
+
*
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const prefetchDeposit = usePrefetchDeposit();
|
|
72
|
+
* useEffect(() => { prefetchDeposit(); }, [prefetchDeposit]);
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Idempotent — subsequent calls are no-ops while the driver is already armed.
|
|
76
|
+
*/
|
|
77
|
+
declare function usePrefetchDeposit(): () => void;
|
|
34
78
|
//#endregion
|
|
35
|
-
export { useDeposit };
|
|
79
|
+
export { useDeposit, useOptionalDeposit, usePrefetchDeposit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useDepositDriverInstance as e}from"../driver/context.js";import{useControllerContext as t,useOptionalControllerContext as n}from"./controller.js";import{useCallback as r}from"react";function i(){return t().controller}function a(){return n()?.controller??null}function o(){let t=e();return r(()=>{t.arm()},[t])}export{i as useDeposit,a as useOptionalDeposit,o as usePrefetchDeposit};
|
|
@@ -14,7 +14,7 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
14
14
|
* minimum-deposit USD floor from the driver's `target` entity. Renders nothing on any other
|
|
15
15
|
* FSM state.
|
|
16
16
|
*
|
|
17
|
-
* Honors `target.payload.
|
|
17
|
+
* Honors `target.payload.minAmountUsd.value`: when the entered amount is below it, the footer
|
|
18
18
|
* CTA flips to "Update order" and clicking auto-snaps the amount up to the floor. The widget
|
|
19
19
|
* also prefills the entry to the floor on first render so the user starts at a valid amount.
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{Trans as n}from"../../../../shared/i18n/Trans.js";import{useLingui as r}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as i,useDepositEffectiveState as a}from"../../orchestrator/controller.js";import{formatTokenAmount as o}from"../../../../shared/format/formatTokenAmount.js";import{
|
|
1
|
+
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{Trans as n}from"../../../../shared/i18n/Trans.js";import{useLingui as r}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as i,useDepositEffectiveState as a}from"../../orchestrator/controller.js";import{formatTokenAmount as o}from"../../../../shared/format/formatTokenAmount.js";import{useKitEmitter as s}from"../../../../events/emit/useKitEmitter.js";import"../../../../events/emit/index.js";import{DialogShell as c}from"../../../../shared/dialog/DialogShell.js";import{text as l}from"../../../../shared/ui/Text/Text.js";import"../../../../shared/ui/Text/index.js";import{AmountEntry as u}from"../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../shared/widgets/amount-entry/compound/index.js";import{toAssetDescriptor as d}from"../../../../shared/widgets/asset-descriptor.js";import{effectiveMaxUsd as f,resolveFooterIntent as p}from"./footerIntent.js";import{useEffect as m,useRef as h,useState as g}from"react";import{jsx as _,jsxs as v}from"react/jsx-runtime";import{AnimatePresence as y,m as b}from"motion/react";const x=[.16,1,.3,1],S={enter:{opacity:0,height:0},center:{opacity:1,height:`auto`,transition:{duration:.22,ease:x}},exit:{opacity:0,height:0,transition:{duration:.18,ease:x}}},C={enter:{opacity:0,filter:`blur(6px)`},center:{opacity:1,filter:`blur(0px)`,transition:{duration:.2,ease:x}},exit:{opacity:0,filter:`blur(6px)`,transition:{duration:.16,ease:x}}},w=[{value:`25`,label:`25%`},{value:`50`,label:`50%`},{value:`75`,label:`75%`},{value:`max`,label:`Max`}];function T(n){let c=e(),l=a(),{confirmAmount:y,back:b}=i(),{_:x}=r(),S=t(),C=c.target,T=C.status===`ready`||C.status===`stale`?C.payload:void 0,O=l.name===`amountEntry`?l.ctx.asset:void 0,k=O?.amountUsd?.value??0,A=T?.minAmountUsd?.value,j=T?.minAmountUsd?.formatted,M=T?.maxAmountUsd?.value,N=T?.maxAmountUsd?.formatted,P=f(k,M),F=O?.priceUsd,[I,L]=g(A??null),[R,z]=g(),B=s(),V=e=>{B({type:`deposit.amount.changed`,flow:`deposit`,tier:`ui`,payload:{raw:e===null?``:String(e),numeric:e}})},H=h(void 0),U=O?`${O.eip155Id??``}:${O.address??``}`:void 0;m(()=>{U&&H.current!==U&&(H.current=U,typeof A==`number`&&(L(A),z(void 0)))},[U,A]);let W=e=>{z(e);let t=e===`max`?1:Number.parseInt(e,10)/100;if(Number.isFinite(t)){let n=P*t;L(n),V(n),e===`max`&&B({type:`deposit.max.clicked`,flow:`deposit`,tier:`ui`,payload:{}})}},G=e=>{L(e),z(void 0),V(e)},K=p({amount:I,...A===void 0?{}:{minAmountUsd:A},...M===void 0?{}:{maxAmountUsd:M},walletBalanceUsd:k}),q=()=>{if(K===`aboveBalance`||K===`aboveCap`){L(P),z(`max`);return}if(K===`belowMin`&&typeof A==`number`){L(A),z(void 0);return}I!==null&&y(F&&F>0?I/F:I)};if(l.name!==`amountEntry`||!O||!T)return null;let J=l.ctx.backTarget===`closed`?void 0:b,Y=d(O)??{symbol:O.symbol},X=d(T)??{symbol:T.symbol},Z=`${o((I??0)/1,S,{maxDecimals:5})} ${T.symbol}`,Q=E(K,{updateOrder:x({id:`bOZXx5`,message:`Update order`}),depositMax:x({id:`9cCjMJ`,message:`Deposit max balance`})});return v(u,{...n,amount:I,sendToken:Y,receiveToken:X,max:P,...A===void 0?{}:{min:A},onAmountChange:G,...J?{onBack:J}:{},subLineAmount:Z,presets:w,...R===void 0?{}:{activePreset:R},onPresetSelect:W,...Q===void 0?{}:{footerLabel:Q},onContinue:q,children:[_(u.Header,{}),v(u.Body,{children:[_(u.Hero,{}),_(u.Pills,{}),_(u.Flow,{}),_(D,{intent:K,formattedCap:N,formattedMin:j})]}),_(u.Footer,{})]})}function E(e,t){if(e===`aboveCap`||e===`belowMin`)return t.updateOrder;if(e===`aboveBalance`)return t.depositMax}function D({intent:e,formattedCap:t,formattedMin:r}){let i=null;return e===`aboveCap`&&t?i={kind:`aboveCap`,node:_(n,{id:`-I_tc5`,message:`Max {formattedCap}`,values:{formattedCap:t}})}:e===`aboveBalance`?i={kind:`aboveBalance`,node:_(n,{id:`znqB4T`,message:`Insufficient balance`})}:e===`belowMin`&&r&&(i={kind:`belowMin`,node:_(n,{id:`3eKjkO`,message:`{formattedMin} minimum deposit`,values:{formattedMin:r}})}),_(y,{initial:!1,children:i?_(b.div,{variants:S,initial:`enter`,animate:`center`,exit:`exit`,style:{overflow:`hidden`},children:_(y,{initial:!1,mode:`wait`,children:_(b.div,{variants:C,initial:`enter`,animate:`center`,exit:`exit`,children:_(l.p,{size:`sm`,color:`subdued`,className:`AmountEntry__noticeStyles.root x2b8uid x1vvogim`,"data-style-src":`@stridge/kit:src/flows/deposit/widgets/amount-entry/AmountEntry.tsx:19`,children:i.node})},i.kind)})},`notice-slot`):null})}function O({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return _(c,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:_(T,{...i})})}(function(e){e.Dialog=O})(T||={});export{T as AmountEntry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){let{amount:r,minAmountUsd:i,maxAmountUsd:a,walletBalanceUsd:o}=e,s=t(o,a);return r!==null&&s>0&&r>s?n(o,a)?`aboveCap`:`aboveBalance`:typeof i==`number`&&i>0&&(r===null||r<i)?`belowMin`:`ready`}function t(e,t){return typeof t==`number`&&t>0?Math.min(e,t):e}function n(e,t){return typeof t==`number`&&t>0&&t<=e}export{t as effectiveMaxUsd,e as resolveFooterIntent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{useLingui as n}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as r,useDepositEffectiveState as i,useDepositState as a}from"../../orchestrator/controller.js";import{formatDurationCoarse as o}from"../../../../shared/format/formatDurationCoarse.js";import{formatUsd as s}from"../../../../shared/format/formatUsd.js";import{
|
|
1
|
+
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{useLingui as n}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as r,useDepositEffectiveState as i,useDepositState as a}from"../../orchestrator/controller.js";import{formatDurationCoarse as o}from"../../../../shared/format/formatDurationCoarse.js";import{formatUsd as s}from"../../../../shared/format/formatUsd.js";import{useKitEmitter as c}from"../../../../events/emit/useKitEmitter.js";import"../../../../events/emit/index.js";import{DialogShell as l}from"../../../../shared/dialog/DialogShell.js";import{ConfirmTransfer as u}from"../../../../shared/widgets/confirm-transfer/compound/ConfirmTransfer.js";import"../../../../shared/widgets/confirm-transfer/compound/index.js";import{useQuoteCountdown as d}from"../../../../shared/quote/useQuoteCountdown.js";import"../../../../shared/quote/index.js";import{jsx as f,jsxs as p}from"react/jsx-runtime";function m(o){let l=e(),m=i(),_=a(),{confirmDeposit:y,back:b}=r(),{_:x}=n(),S=t(),C=c(),w=()=>{C({type:`deposit.confirm.clicked`,flow:`deposit`,tier:`ui`,payload:{}}),y()},T=l.quote,E=m.name===`confirmDeposit`?m.ctx.phase:void 0,D=l.target,O=l.wallet,k=_.name===`confirmDeposit`&&_.ctx.phase.kind===`ready`,A=d({expiresAt:E?.kind===`ready`?E.quoteExpiresAt:void 0,enabled:k});if(!E)return null;let j=E.kind===`loading`||E.kind===`regenerating`,M=g(l,D,O,S),N=v(l,{routeLabel:x({id:`rT8e1f`,message:`Route`}),networkCostLabel:x({id:`bZnukT`,message:`Network cost`}),priceImpactLabel:x({id:`kH6wUX`,message:`Price impact`}),maxSlippageLabel:x({id:`SZRUQ4`,message:`Max slippage`})}),P=`$0.00`;if(T.status===`ready`||T.status===`stale`)P=T.payload.heroAmountUsd.formatted;else if(_.name===`confirmDeposit`){let e=_.ctx.asset,t=_.ctx.amount,n=e?.priceUsd;P=s(typeof n==`number`&&Number.isFinite(n)&&n>0?t*n:t,S)}let F=T.status===`ready`||T.status===`stale`?T.payload.quoteTotalSeconds:30,I=A,L=h(E),R=E.kind===`failed`?E.failure:void 0,z=E.kind===`regenerating`?E.notice:void 0,B=D.status===`ready`||D.status===`stale`?D.payload:void 0,V=l.brand.status===`ready`||l.brand.status===`stale`?l.brand.payload:void 0,H=B&&V?.name?x({id:`zbtijb`,message:`Deposit {0} to {1}`,values:{0:B.symbol,1:V.name}}):void 0;return p(u,{...o,transfer:M,breakdown:N,heroAmountUsd:P,loading:j,phase:L,...z?{notice:z}:{},...R?{error:{message:R.reason,...R.code?{code:R.code}:{}}}:{},...I===void 0?{}:{quoteSeconds:I},quoteTotalSeconds:F,...H?{headerTitle:H}:{},onBack:b,onConfirm:w,children:[f(u.Header,{}),p(u.Body,{children:[f(u.Hero,{}),f(u.Meta,{}),f(u.Amounts,{}),f(u.Breakdown,{}),f(u.Disclaimer,{})]}),f(u.Footer,{})]})}function h(e){switch(e.kind){case`loading`:return`loading`;case`ready`:return`ready`;case`regenerating`:return`regenerating`;case`submitting`:return`submitting`;case`failed`:return`error`}}function g(e,t,n,r){let i=e.quote,a=i.status===`ready`||i.status===`stale`?i.payload:void 0,s=t.status===`ready`||t.status===`stale`?t.payload:void 0,c=n.status===`ready`||n.status===`stale`?n.payload:void 0,l=e.brand.status===`ready`||e.brand.status===`stale`?e.brand.payload:void 0,u=a?.sendAsset,d=a?.receiveAsset??s,f=l?.name?`${l.name} Account`:`Account`,p=a?.etaSeconds===void 0?`—`:o(a.etaSeconds*1e3,r);return{sourceLabel:c?`Wallet (${c.address.formatted})`:`Wallet`,destinationLabel:f,eta:p,sendAmount:a?a.sendAmount.formatted:`0`,sendToken:u?_(u):{symbol:`—`},receiveAmount:a?a.receiveAmount.formatted:`0`,receiveToken:d?_(d):{symbol:s?.symbol??`—`}}}function _(e){return{symbol:e.symbol,...e.chainId===void 0?{}:{chainId:e.chainId},...e.address?{address:e.address}:{},...e.isNative===void 0?{}:{isNative:e.isNative},...e.assetLogoUrl?{logoUrl:e.assetLogoUrl}:{}}}function v(e,t){let n=e.quote,r=n.status===`ready`||n.status===`stale`?n.payload:void 0;if(!r?.breakdown)return{};let i=r.breakdown,a={};return i.selectedRoute&&(a.selectedRoute={label:t.routeLabel,value:i.selectedRoute.label}),i.networkCost&&(a.networkCost={label:t.networkCostLabel,valueUsd:i.networkCost.formatted}),i.priceImpact&&(a.priceImpact={label:t.priceImpactLabel,valuePercent:i.priceImpact.formatted}),i.maxSlippage&&(a.maxSlippage={label:t.maxSlippageLabel,valuePercent:i.maxSlippage.value.formatted,auto:i.maxSlippage.auto}),a}function y({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return f(l,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:f(m,{...i})})}(function(e){e.Dialog=y})(m||={});export{m as ConfirmDeposit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as n,useDepositEffectiveState as r}from"../../orchestrator/controller.js";import{QrCodeIcon as
|
|
1
|
+
"use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as n,useDepositEffectiveState as r,useDepositMethodsConfig as i}from"../../orchestrator/controller.js";import{QrCodeIcon as a}from"../../../../shared/icons/QrCodeIcon.js";import{WalletIcon as o}from"../../../../shared/icons/WalletIcon.js";import"../../../../icons/index.js";import{DialogShell as s}from"../../../../shared/dialog/DialogShell.js";import{Image as c}from"../../../../shared/ui/Image/Image.js";import{Skeleton as l}from"../../../../shared/ui/Skeleton/Skeleton.js";import"../../../../shared/ui/Skeleton/index.js";import{TokenLogo as u}from"../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../shared/ui/TokenLogo/index.js";import"../../../../ui/index.js";import{Deposit as d}from"./compound/Deposit.js";import"./compound/index.js";import{useMemo as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";const h={width:18,height:18,"aria-hidden":!0};function g(s){let c=e(),u=r().name,{selectMethod:g}=n(),v=i(),{_:y}=t(),b=c.wallet,x=b.status===`ready`||b.status===`stale`?b.payload:void 0,S=x!==void 0,C=c.brand,w=C.status===`ready`||C.status===`stale`?C.payload:void 0,T=c.addresses,E=T.status===`ready`||T.status===`stale`?T.payload:[],D=c.balances.status===`error`,O=!x?.balanceTotalUsd?.formatted&&!D,k=!!c.brand,A=w?.name?y({id:`ogD_nm`,message:`Deposit to {0}`,values:{0:w.name}}):void 0,j=f(()=>_(E),[E]),M=v?.wallet,N=v?.transfer,P=f(()=>{let e=!S||O,t=M?.disabled??!1,n=e||t,r=t?M?.disabledHint:void 0,i=(()=>{if(t)return r;if(!S)return y({id:`5AApJw`,message:`Connect a wallet to continue`});if(x?.balanceTotalUsd?.formatted)return x.balanceTotalUsd.formatted;if(!D)return p(l,{width:56,height:12})})(),s=[{id:`wallet`,title:y({id:`sb9Y58`,message:`Wallet`}),icon:p(o,{...h}),...x&&!t?{titleAdornment:x.address.formatted}:{},...i===void 0?{}:{meta:i},recommended:!0,disabled:n,onSelect:n?void 0:()=>g(`wallet`)}];if(k){let e=N?.disabled??!1,t=e?N?.disabledHint:void 0,n=e?t:[y({id:`qtoOYG`,message:`No limit`}),y({id:`D79cZK`,message:`Instant`})];s.push({id:`transfer`,title:y({id:`3dqPLT`,message:`Transfer Crypto`}),icon:p(a,{...h}),...n===void 0?{}:{meta:n},...j?{trailing:j}:{},disabled:e,onSelect:e?void 0:()=>g(`transfer`)})}return s},[x,D,O,S,k,j,M,N,g,y]);return u===`deposit`?m(d,{...s,...A?{title:A}:{},methods:P,children:[p(d.Header,{}),p(d.Body,{children:p(d.Methods,{})})]}):null}function _(e){if(e.length!==0)return p(c.Group,{max:4,overflow:Math.max(0,e.length-4),size:`md`,children:e.map(e=>p(u,{isNative:!0,symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},hideChainBadge:!0},e.eip155Id??e.networkName))})}function v({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return p(s,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:p(g,{...i})})}(function(e){e.Dialog=v})(g||={});export{g as Deposit};
|
|
@@ -17,6 +17,12 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
17
17
|
* `SelectableTile` primitive — see `ui/SelectableTile`. The row only contributes its
|
|
18
18
|
* own gap, leading-edge padding (so the recommended bar lands flush), and inner
|
|
19
19
|
* children layout.
|
|
20
|
+
*
|
|
21
|
+
* Disabled rows render natively `disabled` — the user-facing reason for the
|
|
22
|
+
* disable lives in the `meta` slot (the orchestrated `Deposit` widget maps
|
|
23
|
+
* `flows.deposit.methods.<m>.disabledHint` onto `meta` for host-gated methods).
|
|
24
|
+
* When `meta` is a string, it is also folded into the tile's accessible name so
|
|
25
|
+
* screen readers convey the reason alongside the title.
|
|
20
26
|
*/
|
|
21
27
|
declare function DepositMethod({
|
|
22
28
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{ChevronRightIcon as e}from"../../../../../../shared/icons/ChevronRightIcon.js";import"../../../../../../icons/index.js";import{SelectableTile as t}from"../../../../../../shared/ui/SelectableTile/SelectableTile.js";import"../../../../../../shared/ui/SelectableTile/index.js";import{text as n}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{DEPOSIT_SLOTS as r}from"../Deposit.slots.js";import{styles as i}from"../Deposit.styles.js";import{Fragment as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import*as c from"@stylexjs/stylex";function l({title:a,titleAdornment:l,meta:d,icon:f,trailing:p,recommended:m=!1,disabled:h=!1,onSelect:g}){return s(t,{shape:`card`,onClick:g,disabled:h,"aria-label":
|
|
1
|
+
"use client";import{ChevronRightIcon as e}from"../../../../../../shared/icons/ChevronRightIcon.js";import"../../../../../../icons/index.js";import{SelectableTile as t}from"../../../../../../shared/ui/SelectableTile/SelectableTile.js";import"../../../../../../shared/ui/SelectableTile/index.js";import{text as n}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{DEPOSIT_SLOTS as r}from"../Deposit.slots.js";import{styles as i}from"../Deposit.styles.js";import{Fragment as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import*as c from"@stylexjs/stylex";function l({title:a,titleAdornment:l,meta:d,icon:f,trailing:p,recommended:m=!1,disabled:h=!1,onSelect:g}){let _=h&&typeof d==`string`&&d.length>0?`${a} — ${d}`:a;return s(t,{shape:`card`,interactive:!0,onClick:h?void 0:g,disabled:h,"aria-label":_,"aria-disabled":h||void 0,"data-stridge-slot":r.method,"data-recommended":m||void 0,"data-disabled":h||void 0,...c.props(i.methodRow),children:[m?o(`span`,{"aria-hidden":!0,...c.props(i.methodRecommendedBar)}):null,o(`span`,{...c.props(i.methodIconSlot),children:f}),s(`span`,{...c.props(i.methodText),children:[s(`span`,{...c.props(i.methodTitleRow),children:[o(n.span,{size:`sm`,fontWeight:`semibold`,leading:`tight`,tracking:`tight`,truncate:!0,children:a}),l?o(n.span,{size:`xs`,leading:`tight`,tracking:`wide`,color:`subdued`,font:`mono`,style:{flexShrink:0},children:l}):null]}),d?o(u,{meta:d}):null]}),o(`span`,{...c.props(i.methodTrailing),children:p??o(e,{"aria-hidden":!0,...c.props(i.methodChevron)})})]})}function u({meta:e}){return Array.isArray(e)?o(n.span,{size:`xs`,leading:`tight`,color:`subdued`,...c.props(i.methodMeta),children:e.map((e,t)=>s(a,{children:[t>0?o(`span`,{...c.props(i.methodMetaItem),children:`·`}):null,o(n.span,{size:`xs`,leading:`tight`,fontWeight:t===0?`medium`:`normal`,color:t===0?`default`:`inherit`,...c.props(i.methodMetaItem),children:e})]},t))}):o(n.span,{size:`xs`,leading:`tight`,color:`subdued`,...c.props(i.methodMeta),children:e})}export{l as DepositMethod};
|
|
@@ -36,9 +36,12 @@ interface DepositMethodOption {
|
|
|
36
36
|
*/
|
|
37
37
|
recommended?: boolean;
|
|
38
38
|
/**
|
|
39
|
-
* When true, renders the row
|
|
40
|
-
*
|
|
41
|
-
* but click is a no-op.
|
|
39
|
+
* When true, renders the row natively disabled — used for "coming soon"
|
|
40
|
+
* methods or host-gated options. The row stays in the list for
|
|
41
|
+
* discoverability but click is a no-op. Supply the user-facing reason
|
|
42
|
+
* through the `meta` slot; when `meta` is a string, it is also folded
|
|
43
|
+
* into the tile's accessible name so screen readers convey it alongside
|
|
44
|
+
* the title.
|
|
42
45
|
*/
|
|
43
46
|
disabled?: boolean;
|
|
44
47
|
}
|
|
@@ -14,6 +14,13 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
14
14
|
* hook keys ack rows by `<txHash, bucket>` where `bucket` is `inflight` for pending and
|
|
15
15
|
* `terminal` for succeeded / failed. Acking the pending banner does NOT suppress the eventual
|
|
16
16
|
* success / failure banner for the same source-chain tx — the buckets are distinct.
|
|
17
|
+
*
|
|
18
|
+
* Reaching a terminal FSM step (`success` / `error`) auto-acks the terminal bucket: the user is
|
|
19
|
+
* looking at the full-screen outcome, so that IS the acknowledgment. Without it, the natural
|
|
20
|
+
* `processing → success` / `processing → error` progression would re-surface the banner once
|
|
21
|
+
* the dialog is closed (FSM resets to `deposit`) and reopened, because the settlement entity
|
|
22
|
+
* still carries the terminal payload. `processing` is deliberately NOT auto-acked — an
|
|
23
|
+
* in-flight deposit should still re-surface its banner on reopen.
|
|
17
24
|
*/
|
|
18
25
|
declare function DepositStatusBanner(): _$react_jsx_runtime0.JSX.Element;
|
|
19
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useBannerAckForSettlement as
|
|
1
|
+
"use client";import{bucketFromSettlement as e,useBannerAckForSettlement as t}from"../../../../banners/useBannerAck.js";import"../../../../banners/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useLingui as r}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositActions as i,useDepositState as a}from"../../orchestrator/controller.js";import{stepRendersSettlement as o}from"../../orchestrator/steps.js";import{DepositStatusBanner as s}from"./compound/DepositStatusBanner.js";import"./compound/index.js";import{useEffect as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{AnimatePresence as f}from"motion/react";function p(){let s=n(),l=a().name,{resumeToProcessing:d,resumeToSuccess:p,resumeToError:h}=i(),{_}=r(),v=s.settlement,y=v.status===`ready`||v.status===`stale`?v.payload:void 0,{acked:b,ack:x}=t(y),S=(l===`success`||l===`error`)&&e(y)?.bucket===`terminal`;c(()=>{S&&!b&&x()},[S,b,x]);let C=y!==void 0&&!b&&!o(l);function w(e){return()=>{x(),e()}}return u(f,{children:C&&y?u(m,{payload:y,brandName:s.brand.status===`ready`||s.brand.status===`stale`?s.brand.payload.name:void 0,onDismiss:x,onResumeToProcessing:()=>d(`wallet`,g(y)),onResumeToSuccess:w(()=>p(`wallet`,g(y))),onResumeToError:w(()=>h(g(y))),labels:{completed:_({id:`3kg1gB`,message:`Deposit completed`}),didntComplete:_({id:`Rxjdjn`,message:`Deposit didn't complete`}),receivedProcessing:_({id:`junZX6`,message:`Deposit received and processing…`}),creditedToBrand:e=>_({id:`IRogzB`,message:`Your deposit has been credited to {brand}.`,values:{brand:e}}),creditedToAccount:_({id:`9JHY2T`,message:`Your deposit has been credited to your account.`}),fundsSafe:_({id:`Z1WbO6`,message:`Funds are safe on the source chain — contact support to recover.`}),willBeCreditedToBrand:e=>_({id:`TG4WOd`,message:`Your deposit will be credited to {brand}.`,values:{brand:e}}),willBeCreditedToAccount:_({id:`Offl0a`,message:`Your deposit will be credited to your account.`})}},`banner`):null})}function m({payload:e,brandName:t,onDismiss:n,onResumeToProcessing:r,onResumeToSuccess:i,onResumeToError:a,labels:o}){let[c,f]=l(!1),p=()=>f(e=>!e),m=e.kind,g={symbol:e.creditedAsset.symbol,...e.creditedAsset.address?{address:e.creditedAsset.address}:{},...e.creditedAsset.isNative===void 0?{}:{isNative:e.creditedAsset.isNative},...e.creditedAsset.assetLogoUrl?{logoUrl:e.creditedAsset.assetLogoUrl}:{}},_=m===`succeeded`?o.completed:m===`failed`?o.didntComplete:o.receivedProcessing,v=m===`succeeded`?t?o.creditedToBrand(t):o.creditedToAccount:m===`failed`?o.fundsSafe:t?o.willBeCreditedToBrand(t):o.willBeCreditedToAccount,y=h(e),b=e.kind===`succeeded`&&e.completionTx?{hash:e.completionTx.hash.formatted,...e.completionTx.explorerUrl?{explorerUrl:e.completionTx.explorerUrl}:{}}:void 0,x=e.kind===`succeeded`||e.kind===`failed`?e.submittedAt.formatted:void 0,S=e.kind===`succeeded`?e.filledAt.formatted:void 0,C=m===`succeeded`?i:m===`failed`?a:r;return d(s,{kind:m,asset:g,headline:_,subline:v,expanded:c,onToggleExpanded:p,onDismiss:n,...y?{depositTx:y}:{},...b?{completionTx:b}:{},...x===void 0?{}:{submittedAt:x},...S===void 0?{}:{filledAt:S},onPrimaryAction:C,children:[d(s.Body,{children:[u(s.Hero,{}),u(s.Close,{})]}),d(s.Details,{children:[u(s.DepositTxRow,{}),u(s.CompletionTxRow,{}),u(s.SubmittedAtRow,{}),u(s.FilledAtRow,{})]}),d(s.Footer,{children:[u(s.Toggle,{}),u(s.PrimaryAction,{})]})]})}function h(e){if(e.kind===`succeeded`)return{hash:e.depositTx.hash.formatted,...e.depositTx.explorerUrl?{explorerUrl:e.depositTx.explorerUrl}:{}};if(e.kind===`failed`||e.txHash)return{hash:e.txHash.formatted,...e.txExplorerUrl?{explorerUrl:e.txExplorerUrl}:{}}}function g(e){return e.kind===`succeeded`?{hash:e.depositTx.hash.value,...e.depositTx.explorerUrl?{explorerUrl:e.depositTx.explorerUrl}:{}}:e.kind===`failed`?{hash:e.txHash.value,...e.txExplorerUrl?{explorerUrl:e.txExplorerUrl}:{}}:{hash:e.txHash?.value??``,...e.txExplorerUrl?{explorerUrl:e.txExplorerUrl}:{}}}export{p as DepositStatusBanner};
|