@stridge/kit 0.1.0-alpha.31 → 0.1.0-alpha.32

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.
Files changed (60) hide show
  1. package/dist/deposit/compound/index.d.ts +1 -1
  2. package/dist/events/bus/createBus.d.ts +7 -0
  3. package/dist/events/bus/createBus.js +1 -0
  4. package/dist/events/bus/flowIdRegistry.d.ts +17 -0
  5. package/dist/events/bus/flowIdRegistry.js +1 -0
  6. package/dist/events/bus/index.js +1 -0
  7. package/dist/events/bus/metadata.js +1 -0
  8. package/dist/events/context.js +1 -0
  9. package/dist/events/emit/index.js +1 -0
  10. package/dist/events/emit/mapFailure.js +1 -0
  11. package/dist/events/emit/useDepositEmissions.js +1 -0
  12. package/dist/events/emit/useKitEmitter.js +1 -0
  13. package/dist/events/emit/useWithdrawEmissions.js +1 -0
  14. package/dist/events/hooks/index.d.ts +6 -0
  15. package/dist/events/hooks/index.js +1 -0
  16. package/dist/events/hooks/useCurrentFlowId.d.ts +6 -0
  17. package/dist/events/hooks/useCurrentFlowId.js +1 -0
  18. package/dist/events/hooks/useStableHandler.js +1 -0
  19. package/dist/events/hooks/useStridgeEvent.d.ts +8 -0
  20. package/dist/events/hooks/useStridgeEvent.js +1 -0
  21. package/dist/events/hooks/useStridgeEventBus.d.ts +33 -0
  22. package/dist/events/hooks/useStridgeEventBus.js +1 -0
  23. package/dist/events/hooks/useStridgeEvents.d.ts +6 -0
  24. package/dist/events/hooks/useStridgeEvents.js +1 -0
  25. package/dist/events/hooks/useStridgeFlowEvent.d.ts +8 -0
  26. package/dist/events/hooks/useStridgeFlowEvent.js +1 -0
  27. package/dist/events/hooks/useStridgeFlowEvents.d.ts +6 -0
  28. package/dist/events/hooks/useStridgeFlowEvents.js +1 -0
  29. package/dist/events/index.d.ts +14 -0
  30. package/dist/events/index.js +1 -0
  31. package/dist/events/publish.js +1 -0
  32. package/dist/events/types/deposit.d.ts +235 -0
  33. package/dist/events/types/envelope.d.ts +145 -0
  34. package/dist/events/types/index.d.ts +31 -0
  35. package/dist/events/types/kit.d.ts +23 -0
  36. package/dist/events/types/withdraw.d.ts +150 -0
  37. package/dist/flows/deposit/dialog/DepositDialog.d.ts +14 -81
  38. package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
  39. package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
  40. package/dist/flows/deposit/widgets/confirm-deposit/ConfirmDeposit.js +1 -1
  41. package/dist/flows/deposit/widgets/transfer-crypto/TransferCrypto.js +1 -1
  42. package/dist/flows/deposit/widgets/transfer-crypto/compound/TransferCrypto.d.ts +1 -1
  43. package/dist/flows/withdraw/dialog/WithdrawDialog.d.ts +27 -109
  44. package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
  45. package/dist/flows/withdraw/orchestrator/controller.js +1 -1
  46. package/dist/flows/withdraw/orchestrator/types.d.ts +18 -1
  47. package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.d.ts +5 -13
  48. package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
  49. package/dist/i18n/locales/ar.js +1 -1
  50. package/dist/i18n/locales/es.js +1 -1
  51. package/dist/i18n/locales/source-keys.d.ts +1 -1
  52. package/dist/index.d.ts +9 -1
  53. package/dist/index.js +1 -1
  54. package/dist/package.js +1 -1
  55. package/dist/shared/support/SupportLink.js +1 -1
  56. package/dist/shared/terms/TermsLink.js +1 -1
  57. package/dist/stridge/StridgeProvider.js +1 -1
  58. package/package.json +7 -3
  59. package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.d.ts +0 -36
  60. package/dist/flows/withdraw/dialog/WithdrawDialogEventsContext.js +0 -1
@@ -0,0 +1,145 @@
1
+ //#region src/events/types/envelope.d.ts
2
+ /**
3
+ * Envelope, tier, flow, and failure types shared by every event variant in the unified bus.
4
+ *
5
+ * # Naming pattern (READ THIS BEFORE ADDING A NEW EVENT)
6
+ *
7
+ * Every event type is a string of the form `<flow>.<noun>.<verb-past>` (or
8
+ * `<flow>.<noun>.<sub-noun>.<verb-past>` for nested concepts):
9
+ *
10
+ * - `deposit.quote.resolved`
11
+ * - `withdraw.settlement.succeeded`
12
+ * - `deposit.transfer.address.copied`
13
+ * - `kit.support.opened`
14
+ *
15
+ * Rules:
16
+ *
17
+ * 1. **Lowercase, dot-segmented.** No camelCase, no colons, no slashes.
18
+ * 2. **Past-tense final verb.** Events describe things that already happened. `quote.resolved`,
19
+ * not `quote.resolve`. Even in-flight signals use past tense (`quote.requested` — the
20
+ * request *was made*).
21
+ * 3. **Same `noun.verb` across flows = same semantic concept.** A consumer who learns deposit
22
+ * events should immediately recognise the withdraw equivalents. If a concept exists in both
23
+ * flows, the trailing segments must match: `deposit.quote.resolved` ↔ `withdraw.quote.resolved`.
24
+ * 4. **Flow prefix is required.** Even for events that conceptually exist in both flows, each
25
+ * flow gets its own typed variant. The prefix lets TypeScript narrow payloads precisely on
26
+ * `e.type ===` checks without needing additional `e.flow ===` guards.
27
+ *
28
+ * # Tier rule
29
+ *
30
+ * - `tier: "flow"` — orchestrator/driver-emitted domain milestones (quote, submission,
31
+ * settlement). Fire whether or not the user sees any UI, as long as the orchestrator is
32
+ * running (which today means a dialog is mounted).
33
+ * - `tier: "ui"` — user-driven affordances and view-state changes from any kit-rendered
34
+ * element. Includes dialog lifecycle (open / close / step.changed) and widget interactions
35
+ * (keystrokes, selections, copy clicks). Fires only when the relevant kit-rendered component
36
+ * is mounted.
37
+ *
38
+ * # Envelope shape
39
+ *
40
+ * Every event variant ships as a `StridgeEventBase<...>`. Field discipline:
41
+ *
42
+ * - `type` — unique string discriminator. Stable across versions; never reshape an existing
43
+ * `type`. Adding a new event = adding a new variant to the appropriate union.
44
+ * - `flow` — duplicated from the `type` prefix for cheap field-based filtering by analytics
45
+ * integrations that don't want to string-parse.
46
+ * - `tier` — duplicated from per-variant convention for filterable inspection.
47
+ * - `timestamp` — `Date.now()` at emit; wall-clock, not `performance.now()`, because
48
+ * consumers want it for logging/funnels.
49
+ * - `flowId` — session correlation id. Minted at `<flow>.opened`, retired after the terminal
50
+ * event (`*.settlement.succeeded` / `*.settlement.failed` / `*.cancelled`). Always
51
+ * `string` for `flow:*` and `ui:*` events; `null` for `kit:*` events (which have no flow
52
+ * context to belong to).
53
+ * - `payload` — event-specific data, always an object even when single-field, so future
54
+ * fields can be added non-breakingly.
55
+ * - `metadata` — consumer-attached, snapshotted at `<flow>.opened` and frozen for the
56
+ * session. Always present (empty object if the consumer didn't supply any). `Record<string,
57
+ * unknown>` — the kit does not validate, normalise, or enforce a schema.
58
+ *
59
+ * # What's intentionally NOT in the envelope
60
+ *
61
+ * - No `id` per-event uuid — `flowId + type + timestamp` is sufficient correlation.
62
+ * - No `preventDefault` / `stopPropagation` — events are read-only notifications.
63
+ * - No `version` field — versioning happens through the union, not at runtime.
64
+ * - No `source: "user" | "system"` distinction beyond `tier` — adding finer grain invites
65
+ * bikeshed without paying for itself.
66
+ */
67
+ /** Flow identifier — one per orchestrator family, plus `"kit"` for flow-less provider events. */
68
+ type StridgeEventFlow = "deposit" | "withdraw" | "kit";
69
+ /** Delivery tier — see envelope JSDoc for the rule. */
70
+ type StridgeEventTier = "flow" | "ui";
71
+ /**
72
+ * Generic envelope every event variant extends. Concrete variants narrow the four type
73
+ * parameters so `e.type === "..."` discrimination narrows `flow`, `tier`, and `payload`
74
+ * in lockstep.
75
+ */
76
+ interface StridgeEventBase<TType extends string, TFlow extends StridgeEventFlow, TTier extends StridgeEventTier, TPayload> {
77
+ /** Stable string discriminator. See the naming pattern in this file's top-of-file JSDoc. */
78
+ type: TType;
79
+ /** Originating flow. Always derivable from the `type` prefix; duplicated for cheap field-based filtering. */
80
+ flow: TFlow;
81
+ /** Delivery tier. */
82
+ tier: TTier;
83
+ /** Wall-clock millisecond timestamp at emit. */
84
+ timestamp: number;
85
+ /**
86
+ * Session correlation id. `string` for flow-scoped events, `null` for `kit:*` events
87
+ * (which have no flow context to belong to).
88
+ */
89
+ flowId: TFlow extends "kit" ? null : string;
90
+ /** Event-specific payload. Always an object even when single-field. */
91
+ payload: TPayload;
92
+ /**
93
+ * Consumer-attached metadata, snapshotted at `<flow>.opened`, frozen for the session.
94
+ * Empty object when the consumer didn't supply any. Consumer-typed at the consumption
95
+ * site — the kit does not validate or normalise.
96
+ */
97
+ metadata: Record<string, unknown>;
98
+ }
99
+ /**
100
+ * Stable taxonomy of failure codes carried by every `*.failed` event. Constrained enum (not
101
+ * free string) because consumers writing `switch(code)` need exhaustiveness and analytics
102
+ * platforms need bounded cardinality.
103
+ *
104
+ * Every internal failure path must map to one of these. Add new codes here when a new
105
+ * failure category genuinely appears — don't widen the union with overlapping codes.
106
+ */
107
+ type FailureCode = /** Transport-level fetch failure, DNS error, browser offline. */"network" /** Operation exceeded its deadline before producing a result. */ | "timeout" /** Backend returned 429 / equivalent rate-limit signal. */ | "rate_limited" /** Gateway key invalid, scope mismatch, or session expired. */ | "unauthorized" /** Requested amount exceeds available balance. */ | "insufficient_funds" /** Backend rejected the payload as malformed (validation failure). */ | "invalid_input" /** Quote went stale between request and submit. */ | "quote_expired" /** On-chain transaction reverted. */ | "tx_reverted" /** Transaction replaced or dropped from the mempool before inclusion. */ | "tx_dropped" /** Backend couldn't correlate a settlement to the submitted transaction. */ | "settlement_lost" /** Catch-all for anything else; consumers should treat as opaque. */ | "internal";
108
+ /**
109
+ * Shape carried by every `*.failed` event in the bus. Common base lets generic error handlers
110
+ * write `analytics.track("error", e.payload.code, e.payload.reason)` once and have it work
111
+ * across every flow and every failure point.
112
+ *
113
+ * Per-event extensions (e.g. `SettlementFailurePayload`) extend this with richer fields when
114
+ * the failure has additional structure worth surfacing.
115
+ *
116
+ * **`.declined` (user refused a wallet prompt) and `.cancelled` (flow interrupted by close /
117
+ * AbortSignal) are NOT `.failed`** — they have their own event names with their own (often
118
+ * empty) payloads. Conflating them would let analytics count user choices as errors.
119
+ */
120
+ interface FailurePayloadBase {
121
+ /**
122
+ * Stable taxonomy code. Drives consumer logic: retry decisions, custom messaging,
123
+ * error-grouping in analytics dashboards.
124
+ */
125
+ code: FailureCode;
126
+ /**
127
+ * Human-readable reason, already localised by the kit. Safe to render directly to users.
128
+ * Consumers who want raw keys for their own messaging branch on {@link code} instead.
129
+ */
130
+ reason: string;
131
+ /**
132
+ * Whether retrying the same operation could plausibly succeed. `true` for transient
133
+ * failures (`network`, `timeout`, `rate_limited`); `false` for permanent ones
134
+ * (`unauthorized`, `invalid_input`, `tx_reverted`).
135
+ */
136
+ retryable: boolean;
137
+ /**
138
+ * Raw cause for debugging only — typically the underlying `Error`, fetch `Response`, or
139
+ * wallet-provider error object. Never displayed; safe to log. Consumers must not depend
140
+ * on its shape.
141
+ */
142
+ cause?: unknown;
143
+ }
144
+ //#endregion
145
+ export { FailureCode, FailurePayloadBase, StridgeEventBase, StridgeEventFlow, StridgeEventTier };
@@ -0,0 +1,31 @@
1
+ import { FailureCode, FailurePayloadBase, StridgeEventBase, StridgeEventFlow, StridgeEventTier } from "./envelope.js";
2
+ import { DepositAmountChangedEvent, DepositAmountSubmittedEvent, DepositAssetClickedEvent, DepositBackClickedEvent, DepositCancelPhase, DepositCancelledEvent, DepositClosedEvent, DepositConfirmClickedEvent, DepositEvent, DepositFlowEvent, DepositMaxClickedEvent, DepositMethodClickedEvent, DepositOpenedEvent, DepositQuoteExpiredEvent, DepositQuoteFailedEvent, DepositQuoteRequestInput, DepositQuoteRequestedEvent, DepositQuoteResolvedEvent, DepositSettlementFailedEvent, DepositSettlementFailurePayload, DepositSettlementProgressedEvent, DepositSettlementResumedEvent, DepositSettlementSucceededEvent, DepositStepChangedEvent, DepositSubmissionBroadcastEvent, DepositSubmissionConfirmedEvent, DepositSubmissionDeclinedEvent, DepositSubmissionFailedEvent, DepositTransferAddressCopiedEvent, DepositTransferChainChangedEvent, DepositTransferTokenChangedEvent, DepositUiEvent } from "./deposit.js";
3
+ import { KitEvent, KitSupportClickedEvent, KitTermsClickedEvent } from "./kit.js";
4
+ import { WithdrawAmountChangedEvent, WithdrawBreakdownClickedEvent, WithdrawCancelPhase, WithdrawCancelledEvent, WithdrawClosedEvent, WithdrawEvent, WithdrawFlowEvent, WithdrawMaxClickedEvent, WithdrawOpenedEvent, WithdrawQuoteExpiredEvent, WithdrawQuoteFailedEvent, WithdrawQuoteRequestedEvent, WithdrawQuoteResolvedEvent, WithdrawReceiveChainChangedEvent, WithdrawReceiveTokenChangedEvent, WithdrawRecipientChangedEvent, WithdrawSettlementFailedEvent, WithdrawSettlementFailurePayload, WithdrawSettlementProgressedEvent, WithdrawSettlementSucceededEvent, WithdrawStepChangedEvent, WithdrawSubmissionBroadcastEvent, WithdrawSubmissionConfirmedEvent, WithdrawSubmissionDeclinedEvent, WithdrawSubmissionFailedEvent, WithdrawSubmitClickedEvent, WithdrawUiEvent } from "./withdraw.js";
5
+
6
+ //#region src/events/types/index.d.ts
7
+ /**
8
+ * Every `flow:*` event across all flows. Headless-safe — this is what
9
+ * `useStridgeFlowEvents` narrows its handler to. Does not include any `ui:*` or `kit:*`
10
+ * events; consumers who only render the dialog (no widgets, no provider affordances) can
11
+ * subscribe to this union and never see a UI-noise event in their autocomplete.
12
+ */
13
+ type FlowEvent = DepositFlowEvent | WithdrawFlowEvent;
14
+ /**
15
+ * Every `ui:*` event across all flows, plus every `kit:*` provider-scoped event (kit
16
+ * affordances are user-driven, so they share the `ui` tier today even though they don't
17
+ * belong to a deposit/withdraw flow). Does NOT include `flow:*` events — for the firehose
18
+ * union, use {@link StridgeEvent}.
19
+ */
20
+ type UiEvent = DepositUiEvent | WithdrawUiEvent | KitEvent;
21
+ /**
22
+ * Firehose union — every event the kit ever emits. Equivalent to `FlowEvent | UiEvent`.
23
+ * What `useStridgeEvents` hands to its handler.
24
+ */
25
+ type StridgeEvent = FlowEvent | UiEvent;
26
+ /** Convenience: every distinct `type` literal across the full union. */
27
+ type StridgeEventType = StridgeEvent["type"];
28
+ type FlowEventType = FlowEvent["type"];
29
+ type UiEventType = UiEvent["type"];
30
+ //#endregion
31
+ export { FlowEvent, FlowEventType, StridgeEvent, StridgeEventType, UiEvent, UiEventType };
@@ -0,0 +1,23 @@
1
+ import { SupportOpenContext } from "../../shared/support/types.js";
2
+ import { TermsSelectContext } from "../../shared/terms/types.js";
3
+ import { StridgeEventBase } from "./envelope.js";
4
+ //#region src/events/types/kit.d.ts
5
+ /**
6
+ * User clicked the support entry point (the "Get help" link / button). Fires regardless of
7
+ * whether the consumer provided a custom `support.onOpen` handler — the bus event is an
8
+ * observation channel for analytics, the prop is a behaviour-override contract. Both coexist.
9
+ */
10
+ type KitSupportClickedEvent = StridgeEventBase<"kit.support.clicked", "kit", "ui", {
11
+ context: SupportOpenContext;
12
+ }>;
13
+ /**
14
+ * User clicked a terms link. Fires regardless of whether the consumer provided a custom
15
+ * `terms.onSelect` handler.
16
+ */
17
+ type KitTermsClickedEvent = StridgeEventBase<"kit.terms.clicked", "kit", "ui", {
18
+ context: TermsSelectContext;
19
+ }>;
20
+ /** Union of every `kit.*` event. */
21
+ type KitEvent = KitSupportClickedEvent | KitTermsClickedEvent;
22
+ //#endregion
23
+ export { KitEvent, KitSupportClickedEvent, KitTermsClickedEvent };
@@ -0,0 +1,150 @@
1
+ import { SettlementFailureKind, TxRef } from "../../shared/driver/types.js";
2
+ import { ReceiveChainPayload, ReceiveTokenOptionPayload, WithdrawalQuotePayload, WithdrawalSettlementPendingPayload, WithdrawalSettlementSuccessPayload } from "../../flows/withdraw/driver/payloads.js";
3
+ import { PrepareWithdrawalInput, RequestWithdrawalQuoteInput } from "../../flows/withdraw/driver/types.js";
4
+ import { FailurePayloadBase, StridgeEventBase } from "./envelope.js";
5
+ import { WithdrawStateName } from "../../flows/withdraw/orchestrator/types.js";
6
+
7
+ //#region src/events/types/withdraw.d.ts
8
+ /**
9
+ * Phase the withdraw flow was in when it was cancelled. Mirrors {@link DepositCancelPhase}
10
+ * for symmetry; same set of values.
11
+ */
12
+ type WithdrawCancelPhase = "quoting" | "confirming" | "submitting" | "processing" | "unknown";
13
+ /**
14
+ * Settlement failure variant — extends the base with settlement-specific structure.
15
+ * Mirrors {@link DepositSettlementFailurePayload}.
16
+ */
17
+ interface WithdrawSettlementFailurePayload extends FailurePayloadBase {
18
+ /**
19
+ * Driver-classified failure kind for downstream branching. Bounded enum so consumers can
20
+ * `switch (e.payload.kind)` exhaustively. The kit also escalates FSM-level failures with
21
+ * `kind: "unknown"` when no settlement-specific classification applies.
22
+ */
23
+ kind: SettlementFailureKind;
24
+ /** On-chain transaction hash, when one was surfaced before settlement failed. */
25
+ txHash?: TxRef;
26
+ }
27
+ /**
28
+ * Orchestrator asked the driver for a quote — fires after the 400 ms form-input debounce when
29
+ * the form has a complete, parseable target. Payload is the input envelope sent to the driver.
30
+ */
31
+ type WithdrawQuoteRequestedEvent = StridgeEventBase<"withdraw.quote.requested", "withdraw", "flow", {
32
+ input: RequestWithdrawalQuoteInput;
33
+ }>;
34
+ /**
35
+ * Driver returned a successful quote. Payload is the formatted quote entity ready for
36
+ * display. Subsequent form changes will trigger a new `withdraw.quote.requested`.
37
+ */
38
+ type WithdrawQuoteResolvedEvent = StridgeEventBase<"withdraw.quote.resolved", "withdraw", "flow", {
39
+ quote: WithdrawalQuotePayload;
40
+ }>;
41
+ /** Quote fetch failed. Standard {@link FailurePayloadBase} payload — same shape as deposit. */
42
+ type WithdrawQuoteFailedEvent = StridgeEventBase<"withdraw.quote.failed", "withdraw", "flow", FailurePayloadBase>;
43
+ /**
44
+ * Active quote went stale before submit and the orchestrator regenerated it. Empty payload;
45
+ * the next `withdraw.quote.resolved` carries the replacement.
46
+ */
47
+ type WithdrawQuoteExpiredEvent = StridgeEventBase<"withdraw.quote.expired", "withdraw", "flow", Record<string, never>>;
48
+ /**
49
+ * Host signaled (via `actions.beginProcessing(tx)` or `actions.setTxHash(tx)` inside
50
+ * `WithdrawSubmitCallback`) that the withdraw transaction has been broadcast. Orchestrator
51
+ * has transitioned into `inProgress`; settlement polling has started.
52
+ */
53
+ type WithdrawSubmissionBroadcastEvent = StridgeEventBase<"withdraw.submission.broadcast", "withdraw", "flow", {
54
+ input: PrepareWithdrawalInput;
55
+ tx: TxRef;
56
+ }>;
57
+ /**
58
+ * Host signaled user-rejection — either explicitly via `actions.decline()` or implicitly by
59
+ * throwing a wallet-rejection-shaped error from `onSubmit`. Distinct from
60
+ * {@link WithdrawSubmissionFailedEvent}: declining is a user choice, not an error.
61
+ */
62
+ type WithdrawSubmissionDeclinedEvent = StridgeEventBase<"withdraw.submission.declined", "withdraw", "flow", Record<string, never>>;
63
+ /**
64
+ * Host signaled a non-rejection submission failure (via `actions.fail(failure)` or by
65
+ * throwing a non-rejection error from `onSubmit`). Standard {@link FailurePayloadBase}.
66
+ */
67
+ type WithdrawSubmissionFailedEvent = StridgeEventBase<"withdraw.submission.failed", "withdraw", "flow", FailurePayloadBase>;
68
+ /** Settlement entity emitted a progressive pending update. Fires once per update. */
69
+ type WithdrawSettlementProgressedEvent = StridgeEventBase<"withdraw.settlement.progressed", "withdraw", "flow", {
70
+ settlement: WithdrawalSettlementPendingPayload;
71
+ }>;
72
+ /** Terminal success — settlement entity reached `ready{kind: "succeeded"}`. Retires the `flowId`. */
73
+ type WithdrawSettlementSucceededEvent = StridgeEventBase<"withdraw.settlement.succeeded", "withdraw", "flow", {
74
+ settlement: WithdrawalSettlementSuccessPayload;
75
+ }>;
76
+ /**
77
+ * Terminal failure — settlement entity reached `ready{kind: "failed"}` or an FSM-level
78
+ * failure escalated to the global error arm. Extends {@link FailurePayloadBase} with
79
+ * settlement-specific fields.
80
+ */
81
+ type WithdrawSettlementFailedEvent = StridgeEventBase<"withdraw.settlement.failed", "withdraw", "flow", WithdrawSettlementFailurePayload>;
82
+ /**
83
+ * Flow ended before reaching a terminal state. `payload.phase` indicates where in the
84
+ * lifecycle cancellation happened. Mirrors `deposit.cancelled`.
85
+ */
86
+ type WithdrawCancelledEvent = StridgeEventBase<"withdraw.cancelled", "withdraw", "flow", {
87
+ phase: WithdrawCancelPhase;
88
+ }>;
89
+ /** Union of every `withdraw.*` `flow:*` event. */
90
+ type WithdrawFlowEvent = WithdrawQuoteRequestedEvent | WithdrawQuoteResolvedEvent | WithdrawQuoteFailedEvent | WithdrawQuoteExpiredEvent | WithdrawSubmissionBroadcastEvent | WithdrawSubmissionDeclinedEvent | WithdrawSubmissionFailedEvent | WithdrawSettlementProgressedEvent | WithdrawSettlementSucceededEvent | WithdrawSettlementFailedEvent | WithdrawCancelledEvent;
91
+ /** Dialog transitioned from `closed` to any open step. Mints the `flowId` and snapshots `metadata`. */
92
+ type WithdrawOpenedEvent = StridgeEventBase<"withdraw.opened", "withdraw", "ui", Record<string, never>>;
93
+ /** Dialog returned to `closed`. `payload.atStep` is the step the dialog was on at close time. */
94
+ type WithdrawClosedEvent = StridgeEventBase<"withdraw.closed", "withdraw", "ui", {
95
+ atStep: WithdrawStateName;
96
+ }>;
97
+ /** Dialog step transitioned. Same-step `ctx` changes don't fire this — they surface via `flow:*`. */
98
+ type WithdrawStepChangedEvent = StridgeEventBase<"withdraw.step.changed", "withdraw", "ui", {
99
+ from: WithdrawStateName;
100
+ to: WithdrawStateName;
101
+ }>;
102
+ /**
103
+ * User typed in the recipient field. Fires per keystroke (no debounce); `payload.value` is the
104
+ * literal input string.
105
+ */
106
+ type WithdrawRecipientChangedEvent = StridgeEventBase<"withdraw.recipient.changed", "withdraw", "ui", {
107
+ value: string;
108
+ }>;
109
+ /**
110
+ * User typed in the amount field. Fires per keystroke; `payload.raw` is the literal input
111
+ * string, `payload.numeric` is the parsed value (or `null` when empty / unparseable). Mirrors
112
+ * {@link DepositAmountChangedEvent}.
113
+ */
114
+ type WithdrawAmountChangedEvent = StridgeEventBase<"withdraw.amount.changed", "withdraw", "ui", {
115
+ raw: string;
116
+ numeric: number | null;
117
+ }>;
118
+ /** User clicked the Max pill in the amount field. Empty payload — the amount is reactive form state. */
119
+ type WithdrawMaxClickedEvent = StridgeEventBase<"withdraw.max.clicked", "withdraw", "ui", Record<string, never>>;
120
+ /** User picked a different receive token in the form. */
121
+ type WithdrawReceiveTokenChangedEvent = StridgeEventBase<"withdraw.receive.token.changed", "withdraw", "ui", {
122
+ token: ReceiveTokenOptionPayload;
123
+ }>;
124
+ /** User picked a different receive chain in the form. */
125
+ type WithdrawReceiveChainChangedEvent = StridgeEventBase<"withdraw.receive.chain.changed", "withdraw", "ui", {
126
+ chain: ReceiveChainPayload;
127
+ }>;
128
+ /**
129
+ * User clicked the submit button on the form. This is the UI signal; the FSM commitment is
130
+ * carried by {@link WithdrawSubmissionConfirmedEvent} immediately after.
131
+ */
132
+ type WithdrawSubmitClickedEvent = StridgeEventBase<"withdraw.submit.clicked", "withdraw", "ui", Record<string, never>>;
133
+ /**
134
+ * Form submission triggered the orchestrator transition to `submitting`. Fires just before
135
+ * the host's `WithdrawSubmitCallback` runs.
136
+ */
137
+ type WithdrawSubmissionConfirmedEvent = StridgeEventBase<"withdraw.submission.confirmed", "withdraw", "ui", Record<string, never>>;
138
+ /**
139
+ * User clicked the breakdown card header to toggle it. `payload.open` reflects the new state.
140
+ * Deposit has no symmetric event — the deposit flow doesn't surface a breakdown card today.
141
+ */
142
+ type WithdrawBreakdownClickedEvent = StridgeEventBase<"withdraw.breakdown.clicked", "withdraw", "ui", {
143
+ open: boolean;
144
+ }>;
145
+ /** Union of every `withdraw.*` `ui:*` event. */
146
+ type WithdrawUiEvent = WithdrawOpenedEvent | WithdrawClosedEvent | WithdrawStepChangedEvent | WithdrawRecipientChangedEvent | WithdrawAmountChangedEvent | WithdrawMaxClickedEvent | WithdrawReceiveTokenChangedEvent | WithdrawReceiveChainChangedEvent | WithdrawSubmitClickedEvent | WithdrawSubmissionConfirmedEvent | WithdrawBreakdownClickedEvent;
147
+ /** Union of every `withdraw.*` event regardless of tier. */
148
+ type WithdrawEvent = WithdrawFlowEvent | WithdrawUiEvent;
149
+ //#endregion
150
+ export { WithdrawAmountChangedEvent, WithdrawBreakdownClickedEvent, WithdrawCancelPhase, WithdrawCancelledEvent, WithdrawClosedEvent, WithdrawEvent, WithdrawFlowEvent, WithdrawMaxClickedEvent, WithdrawOpenedEvent, WithdrawQuoteExpiredEvent, WithdrawQuoteFailedEvent, WithdrawQuoteRequestedEvent, WithdrawQuoteResolvedEvent, WithdrawReceiveChainChangedEvent, WithdrawReceiveTokenChangedEvent, WithdrawRecipientChangedEvent, WithdrawSettlementFailedEvent, WithdrawSettlementFailurePayload, WithdrawSettlementProgressedEvent, WithdrawSettlementSucceededEvent, WithdrawStepChangedEvent, WithdrawSubmissionBroadcastEvent, WithdrawSubmissionConfirmedEvent, WithdrawSubmissionDeclinedEvent, WithdrawSubmissionFailedEvent, WithdrawSubmitClickedEvent, WithdrawUiEvent };
@@ -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
- * Three top-level callbacks (`onOpened`, `onClosed`, `onStepChanged`) describe the dialog as a
20
- * stateful component. The grouped `events={{ }}` prop carries the operational lifecycle —
21
- * user actions, async outcomes from the orchestrator, and settlement-entity transitions for
22
- * pending / succeeded / failed deposits.
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
- onOpened,
27
- onClosed,
28
- onStepChanged,
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
- * Terminal failure either a settlement failure (driver-emitted classification) or an
97
- * FSM-derived failure (quote / submission rejection escalated to the global error arm).
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
- onFailed?: (failure: SettlementFailurePayload | FailureInfo) => void;
100
- /**
101
- * Background `fetchActiveSettlement` probe surfaced a pending deposit — the driver's
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{useDialogLifecycle as t}from"../../../shared/orchestrator/useDialogLifecycle.js";import"../../../shared/orchestrator/index.js";import{useControllerContext as n}from"../orchestrator/controller.js";import{useIntercomShutdownOnUnmount as r}from"../../../shared/support/useIntercomShutdownOnUnmount.js";import"../../../shared/support/index.js";import{Dialog as i}from"../../../shared/ui/Dialog/Dialog.js";import"../../../shared/ui/Dialog/index.js";import{AmountEntry as a}from"../widgets/amount-entry/AmountEntry.js";import"../widgets/amount-entry/index.js";import{AssetPicker as o}from"../widgets/asset-picker/AssetPicker.js";import"../widgets/asset-picker/index.js";import{ConfirmDeposit as s}from"../widgets/confirm-deposit/ConfirmDeposit.js";import"../widgets/confirm-deposit/index.js";import{Deposit as c}from"../widgets/deposit/Deposit.js";import"../widgets/deposit/index.js";import{DepositStatusBanner as l}from"../widgets/deposit-status-banner/DepositStatusBanner.js";import"../widgets/deposit-status-banner/index.js";import{ErrorState as u}from"../widgets/error-state/ErrorState.js";import"../widgets/error-state/index.js";import{ProcessingState as d}from"../widgets/processing-state/ProcessingState.js";import"../widgets/processing-state/index.js";import{SuccessState as f}from"../widgets/success-state/SuccessState.js";import"../widgets/success-state/index.js";import{TransferCrypto as p}from"../widgets/transfer-crypto/TransferCrypto.js";import"../widgets/transfer-crypto/index.js";import{StepTransition as m}from"../../../shared/dialog/StepTransition.js";import{GatewayKitBoundary as h}from"../../../shared/error-handling/components/GatewayKitBoundary.js";import"../../../shared/error-handling/index.js";import{DepositBootstrapErrorState as g}from"./DepositBootstrapErrorState.js";import{useRef as _}from"react";import{jsx as v,jsxs as y}from"react/jsx-runtime";const b=new Set([`deposit`,`assetPicker`,`amountEntry`,`confirmDeposit`,`transferCrypto`]);function x({container:t,onOpened:_,onClosed:x,onStepChanged:C,onError:w,events:T}){let{state:E,effectiveState:D,controller:O}=n(),k=e(),A=E.name!==`closed`;S(E,k.settlement,k.quote,{onOpened:_,onClosed:x,onStepChanged:C,events:T}),r();let j=D,M=k.target.status===`error`&&b.has(j.name);return v(i,{open:A,onOpenChange:e=>{e||O.close()},children:v(i.Content,{container:t,children:y(h,{onError:w,onReset:O.close,children:[M?v(g,{}):y(m,{stateKey:j.name,children:[j.name===`deposit`?v(c,{}):null,j.name===`assetPicker`?v(o,{}):null,j.name===`amountEntry`?v(a,{}):null,j.name===`confirmDeposit`?v(s,{}):null,j.name===`transferCrypto`?v(p,{}):null,j.name===`processing`?v(d,{}):null,j.name===`success`?v(f,{}):null,j.name===`error`?v(u,{}):null]}),v(l,{})]})})})}function S(e,n,r,i){let a=_(i);a.current=i,t({state:e,settlement:n,quote:r,fireFsm:(e,t)=>C(e,t,a.current),fireSettlement:(e,t)=>E(e,t,a.current),fireQuote:(e,t)=>{t.status===`ready`&&e!==`ready`&&a.current.events?.onQuoteResolved?.(t.payload)}})}function C(e,t,n){let{onOpened:r,onClosed:i,onStepChanged:a,events:o}=n;if(e.name===t.name){t.name===`confirmDeposit`&&e.name===`confirmDeposit`&&T(e.ctx.phase,t.ctx.phase,t,o);return}e.name===`closed`&&t.name!==`closed`&&r?.(w(t)),e.name!==`closed`&&t.name===`closed`&&i?.(e.name),a?.({from:e.name,to:t.name,ctx:t.name===`closed`?null:t.ctx}),e.name===`deposit`&&t.name===`assetPicker`&&o?.onMethodSelected?.(`wallet`),e.name===`deposit`&&t.name===`transferCrypto`&&o?.onMethodSelected?.(`transfer`),e.name===`assetPicker`&&t.name===`amountEntry`&&o?.onAssetSelected?.(t.ctx.asset),e.name===`amountEntry`&&t.name===`confirmDeposit`&&o?.onAmountSubmitted?.(t.ctx.amount),t.name===`confirmDeposit`&&(e.name!==`confirmDeposit`||e.ctx.phase.kind!==t.ctx.phase.kind)&&T(e.name===`confirmDeposit`?e.ctx.phase:void 0,t.ctx.phase,t,o),e.name===`confirmDeposit`&&t.name===`processing`&&o?.onDepositSubmitted?.(t.ctx.tx),e.name!==`error`&&t.name===`error`&&t.ctx.failure&&(o?.onFailed?.(t.ctx.failure),(e.name===`confirmDeposit`?e.ctx.phase:void 0)?.kind===`submitting`&&o?.onSubmissionFailed?.(t.ctx.failure)),t.name!==`closed`&&e.name!==`closed`&&`backTarget`in e.ctx&&t.name===e.ctx.backTarget&&o?.onBackPressed?.(e.name)}function w(e){if(e.name!==`deposit`){if(e.name===`transferCrypto`)return{method:`transfer`};if(e.name===`assetPicker`)return{method:`wallet`};if(e.name===`amountEntry`||e.name===`confirmDeposit`)return{method:`wallet`,asset:e.ctx.asset};if(e.name===`processing`||e.name===`success`)return e.ctx.method===`transfer`?{method:`transfer`}:{method:`wallet`}}}function T(e,t,n,r){r&&e?.kind!==t.kind&&((t.kind===`loading`||t.kind===`regenerating`)&&(r.onQuoteRequested?.({asset:n.ctx.asset,amount:n.ctx.amount}),t.kind===`regenerating`&&(e?.kind===`submitting`?r.onSignatureDeclined?.():e?.kind===`ready`&&r.onQuoteExpired?.())),t.kind===`failed`&&r.onQuoteFailed?.(t.failure),t.kind===`submitting`&&r.onDepositConfirmed?.())}function E(e,t,n){if(t.status!==`ready`&&t.status!==`stale`)return;let r=t.payload,i=n.events;if(i){if(r.kind===`pending`){e===null?i.onPendingSnapshotDetected?.(r):i.onProcessingProgress?.(r);return}if(r.kind===`succeeded`){i.onSucceeded?.(r);return}r.kind===`failed`&&i.onFailed?.(r)}}export{x as DepositDialog};
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{Dialog as i}from"../../../shared/ui/Dialog/Dialog.js";import"../../../shared/ui/Dialog/index.js";import{AmountEntry as a}from"../widgets/amount-entry/AmountEntry.js";import"../widgets/amount-entry/index.js";import{AssetPicker as o}from"../widgets/asset-picker/AssetPicker.js";import"../widgets/asset-picker/index.js";import{ConfirmDeposit as s}from"../widgets/confirm-deposit/ConfirmDeposit.js";import"../widgets/confirm-deposit/index.js";import{Deposit as c}from"../widgets/deposit/Deposit.js";import"../widgets/deposit/index.js";import{DepositStatusBanner as l}from"../widgets/deposit-status-banner/DepositStatusBanner.js";import"../widgets/deposit-status-banner/index.js";import{ErrorState as u}from"../widgets/error-state/ErrorState.js";import"../widgets/error-state/index.js";import{ProcessingState as d}from"../widgets/processing-state/ProcessingState.js";import"../widgets/processing-state/index.js";import{SuccessState as f}from"../widgets/success-state/SuccessState.js";import"../widgets/success-state/index.js";import{TransferCrypto as p}from"../widgets/transfer-crypto/TransferCrypto.js";import"../widgets/transfer-crypto/index.js";import{StepTransition as m}from"../../../shared/dialog/StepTransition.js";import{GatewayKitBoundary as h}from"../../../shared/error-handling/components/GatewayKitBoundary.js";import"../../../shared/error-handling/index.js";import{DepositBootstrapErrorState as g}from"./DepositBootstrapErrorState.js";import{jsx as _,jsxs as v}from"react/jsx-runtime";const y=new Set([`deposit`,`assetPicker`,`amountEntry`,`confirmDeposit`,`transferCrypto`]);function b({container:b,metadata:x,onError:S}={}){let{state:C,effectiveState:w,controller:T}=t(),E=e(),D=C.name!==`closed`;n({state:C,settlement:E.settlement,quote:E.quote,metadata:x}),r();let O=w,k=E.target.status===`error`&&y.has(O.name);return _(i,{open:D,onOpenChange:e=>{e||T.close()},children:_(i.Content,{container:b,children:v(h,{onError:S,onReset:T.close,children:[k?_(g,{}):v(m,{stateKey:O.name,children:[O.name===`deposit`?_(c,{}):null,O.name===`assetPicker`?_(o,{}):null,O.name===`amountEntry`?_(a,{}):null,O.name===`confirmDeposit`?_(s,{}):null,O.name===`transferCrypto`?_(p,{}):null,O.name===`processing`?_(d,{}):null,O.name===`success`?_(f,{}):null,O.name===`error`?_(u,{}):null]}),_(l,{})]})})})}export{b as DepositDialog};
@@ -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{DialogShell as s}from"../../../../shared/dialog/DialogShell.js";import{text as c}from"../../../../shared/ui/Text/Text.js";import"../../../../shared/ui/Text/index.js";import{AmountEntry as l}from"../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../shared/widgets/amount-entry/compound/index.js";import{toAssetDescriptor as u}from"../../../../shared/widgets/asset-descriptor.js";import{effectiveMaxUsd as d,resolveFooterIntent as f}from"./footerIntent.js";import{useEffect as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";const v=[{value:`25`,label:`25%`},{value:`50`,label:`50%`},{value:`75`,label:`75%`},{value:`max`,label:`Max`}];function y(n){let s=e(),c=a(),{confirmAmount:y,back:C}=i(),{_:w}=r(),T=t(),E=s.target,D=E.status===`ready`||E.status===`stale`?E.payload:void 0,O=c.name===`amountEntry`?c.ctx.asset:void 0,k=O?.amountUsd?.value??0,A=D?.minAmountUsd?.value,j=D?.minAmountUsd?.formatted,M=D?.maxAmountUsd?.value,N=D?.maxAmountUsd?.formatted,P=d(k,M),F=O?.priceUsd,[I,L]=h(A??null),[R,z]=h(),B=m(void 0),V=O?`${O.eip155Id??``}:${O.address??``}`:void 0;p(()=>{V&&B.current!==V&&(B.current=V,typeof A==`number`&&(L(A),z(void 0)))},[V,A]);let H=e=>{z(e);let t=e===`max`?1:Number.parseInt(e,10)/100;Number.isFinite(t)&&L(P*t)},U=e=>{L(e),z(void 0)},W=f({amount:I,...A===void 0?{}:{minAmountUsd:A},...M===void 0?{}:{maxAmountUsd:M},walletBalanceUsd:k}),G=()=>{if(W===`aboveBalance`||W===`aboveCap`){L(P),z(`max`);return}if(W===`belowMin`&&typeof A==`number`){L(A),z(void 0);return}I!==null&&y(F&&F>0?I/F:I)};if(c.name!==`amountEntry`||!O||!D)return null;let K=c.ctx.backTarget===`closed`?void 0:C,q=u(O)??{symbol:O.symbol},J=u(D)??{symbol:D.symbol},Y=`${o((I??0)/1,T,{maxDecimals:5})} ${D.symbol}`,X=b(W,{updateOrder:w({id:`bOZXx5`,message:`Update order`}),depositMax:w({id:`9cCjMJ`,message:`Deposit max balance`})});return _(l,{...n,amount:I,sendToken:q,receiveToken:J,max:P,...A===void 0?{}:{min:A},onAmountChange:U,...K?{onBack:K}:{},subLineAmount:Y,presets:v,...R===void 0?{}:{activePreset:R},onPresetSelect:H,...X===void 0?{}:{footerLabel:X},onContinue:G,children:[g(l.Header,{}),_(l.Body,{children:[g(l.Hero,{}),g(l.Pills,{}),g(x,{intent:W,formattedCap:N}),g(l.Flow,{}),g(S,{intent:W,formattedMin:j})]}),g(l.Footer,{})]})}function b(e,t){if(e===`aboveCap`||e===`belowMin`)return t.updateOrder;if(e===`aboveBalance`)return t.depositMax}function x({intent:e,formattedCap:t}){return e===`aboveCap`&&t?g(c.p,{size:`sm`,color:`subdued`,className:`AmountEntry__noticeStyles.root x2b8uid x1vvogim`,"data-style-src":`@stridge/kit:src/flows/deposit/widgets/amount-entry/AmountEntry.tsx:17`,children:g(n,{id:`-I_tc5`,message:`Max {formattedCap}`,values:{formattedCap:t}})}):e===`aboveBalance`?g(c.p,{size:`sm`,color:`subdued`,className:`AmountEntry__noticeStyles.root x2b8uid x1vvogim`,"data-style-src":`@stridge/kit:src/flows/deposit/widgets/amount-entry/AmountEntry.tsx:17`,children:g(n,{id:`znqB4T`,message:`Insufficient balance`})}):null}function S({intent:e,formattedMin:t}){return e!==`belowMin`||!t?null:g(c.p,{size:`sm`,color:`subdued`,className:`AmountEntry__noticeStyles.root x2b8uid x1vvogim`,"data-style-src":`@stridge/kit:src/flows/deposit/widgets/amount-entry/AmountEntry.tsx:17`,children:g(n,{id:`3eKjkO`,message:`{formattedMin} minimum deposit`,values:{formattedMin:t}})})}function C({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return g(s,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:g(y,{...i})})}(function(e){e.Dialog=C})(y||={});export{y as AmountEntry};
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";const y=[{value:`25`,label:`25%`},{value:`50`,label:`50%`},{value:`75`,label:`75%`},{value:`max`,label:`Max`}];function b(n){let c=e(),l=a(),{confirmAmount:b,back:w}=i(),{_:T}=r(),E=t(),D=c.target,O=D.status===`ready`||D.status===`stale`?D.payload:void 0,k=l.name===`amountEntry`?l.ctx.asset:void 0,A=k?.amountUsd?.value??0,j=O?.minAmountUsd?.value,M=O?.minAmountUsd?.formatted,N=O?.maxAmountUsd?.value,P=O?.maxAmountUsd?.formatted,F=f(A,N),I=k?.priceUsd,[L,R]=g(j??null),[z,B]=g(),V=s(),H=e=>{V({type:`deposit.amount.changed`,flow:`deposit`,tier:`ui`,payload:{raw:e===null?``:String(e),numeric:e}})},U=h(void 0),W=k?`${k.eip155Id??``}:${k.address??``}`:void 0;m(()=>{W&&U.current!==W&&(U.current=W,typeof j==`number`&&(R(j),B(void 0)))},[W,j]);let G=e=>{B(e);let t=e===`max`?1:Number.parseInt(e,10)/100;if(Number.isFinite(t)){let n=F*t;R(n),H(n),e===`max`&&V({type:`deposit.max.clicked`,flow:`deposit`,tier:`ui`,payload:{}})}},K=e=>{R(e),B(void 0),H(e)},q=p({amount:L,...j===void 0?{}:{minAmountUsd:j},...N===void 0?{}:{maxAmountUsd:N},walletBalanceUsd:A}),J=()=>{if(q===`aboveBalance`||q===`aboveCap`){R(F),B(`max`);return}if(q===`belowMin`&&typeof j==`number`){R(j),B(void 0);return}L!==null&&b(I&&I>0?L/I:L)};if(l.name!==`amountEntry`||!k||!O)return null;let Y=l.ctx.backTarget===`closed`?void 0:w,X=d(k)??{symbol:k.symbol},Z=d(O)??{symbol:O.symbol},Q=`${o((L??0)/1,E,{maxDecimals:5})} ${O.symbol}`,$=x(q,{updateOrder:T({id:`bOZXx5`,message:`Update order`}),depositMax:T({id:`9cCjMJ`,message:`Deposit max balance`})});return v(u,{...n,amount:L,sendToken:X,receiveToken:Z,max:F,...j===void 0?{}:{min:j},onAmountChange:K,...Y?{onBack:Y}:{},subLineAmount:Q,presets:y,...z===void 0?{}:{activePreset:z},onPresetSelect:G,...$===void 0?{}:{footerLabel:$},onContinue:J,children:[_(u.Header,{}),v(u.Body,{children:[_(u.Hero,{}),_(u.Pills,{}),_(S,{intent:q,formattedCap:P}),_(u.Flow,{}),_(C,{intent:q,formattedMin:M})]}),_(u.Footer,{})]})}function x(e,t){if(e===`aboveCap`||e===`belowMin`)return t.updateOrder;if(e===`aboveBalance`)return t.depositMax}function S({intent:e,formattedCap:t}){return e===`aboveCap`&&t?_(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:18`,children:_(n,{id:`-I_tc5`,message:`Max {formattedCap}`,values:{formattedCap:t}})}):e===`aboveBalance`?_(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:18`,children:_(n,{id:`znqB4T`,message:`Insufficient balance`})}):null}function C({intent:e,formattedMin:t}){return e!==`belowMin`||!t?null:_(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:18`,children:_(n,{id:`3eKjkO`,message:`{formattedMin} minimum deposit`,values:{formattedMin:t}})})}function w({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return _(c,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:_(b,{...i})})}(function(e){e.Dialog=w})(b||={});export{b as AmountEntry};
@@ -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{DialogShell as c}from"../../../../shared/dialog/DialogShell.js";import{ConfirmTransfer as l}from"../../../../shared/widgets/confirm-transfer/compound/ConfirmTransfer.js";import"../../../../shared/widgets/confirm-transfer/compound/index.js";import{useQuoteCountdown as u}from"../../../../shared/quote/useQuoteCountdown.js";import"../../../../shared/quote/index.js";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p(o){let c=e(),p=i(),g=a(),{confirmDeposit:v,back:y}=r(),{_:b}=n(),x=t(),S=c.quote,C=p.name===`confirmDeposit`?p.ctx.phase:void 0,w=c.target,T=c.wallet,E=g.name===`confirmDeposit`&&g.ctx.phase.kind===`ready`,D=u({expiresAt:C?.kind===`ready`?C.quoteExpiresAt:void 0,enabled:E});if(!C)return null;let O=C.kind===`loading`||C.kind===`regenerating`,k=h(c,w,T,x),A=_(c,{routeLabel:b({id:`rT8e1f`,message:`Route`}),networkCostLabel:b({id:`bZnukT`,message:`Network cost`}),priceImpactLabel:b({id:`kH6wUX`,message:`Price impact`}),maxSlippageLabel:b({id:`SZRUQ4`,message:`Max slippage`})}),j=`$0.00`;if(S.status===`ready`||S.status===`stale`)j=S.payload.heroAmountUsd.formatted;else if(g.name===`confirmDeposit`){let e=g.ctx.asset,t=g.ctx.amount,n=e?.priceUsd;j=s(typeof n==`number`&&Number.isFinite(n)&&n>0?t*n:t,x)}let M=S.status===`ready`||S.status===`stale`?S.payload.quoteTotalSeconds:30,N=D,P=m(C),F=C.kind===`failed`?C.failure:void 0,I=C.kind===`regenerating`?C.notice:void 0,L=w.status===`ready`||w.status===`stale`?w.payload:void 0,R=c.brand.status===`ready`||c.brand.status===`stale`?c.brand.payload:void 0,z=L&&R?.name?b({id:`zbtijb`,message:`Deposit {0} to {1}`,values:{0:L.symbol,1:R.name}}):void 0;return f(l,{...o,transfer:k,breakdown:A,heroAmountUsd:j,loading:O,phase:P,...I?{notice:I}:{},...F?{error:{message:F.reason,...F.code?{code:F.code}:{}}}:{},...N===void 0?{}:{quoteSeconds:N},quoteTotalSeconds:M,...z?{headerTitle:z}:{},onBack:y,onConfirm:v,children:[d(l.Header,{}),f(l.Body,{children:[d(l.Hero,{}),d(l.Meta,{}),d(l.Amounts,{}),d(l.Breakdown,{}),d(l.Disclaimer,{})]}),d(l.Footer,{})]})}function m(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 h(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?g(u):{symbol:`—`},receiveAmount:a?a.receiveAmount.formatted:`0`,receiveToken:d?g(d):{symbol:s?.symbol??`—`}}}function g(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 _(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 v({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return d(c,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:d(p,{...i})})}(function(e){e.Dialog=v})(p||={});export{p as ConfirmDeposit};
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{useDepositActions as t,useDepositEffectiveState as n}from"../../orchestrator/controller.js";import{DialogShell as r}from"../../../../shared/dialog/DialogShell.js";import{TransferCrypto as i}from"./compound/TransferCrypto.js";import"./compound/index.js";import{useMemo as a,useState as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";function l(r){let l=e(),u=n(),d=u.name,{back:f}=t(),p=u.name===`transferCrypto`&&u.ctx.backTarget!==`closed`?f:void 0,m=l.addresses,h=m.status===`ready`||m.status===`stale`?m.payload:[],g=l.target,_=g.status===`ready`||g.status===`stale`?g.payload:void 0,v=_?.minAmountUsd?.formatted,y=a(()=>{let e=new Map;for(let t of h)for(let n of t.acceptedAssets??[]){let r=n.symbol.toUpperCase(),i=e.get(r);i?i.push({chain:t,asset:n}):e.set(r,[{chain:t,asset:n}])}return e},[h]),b=a(()=>y.size===0?_?[{symbol:_.symbol,..._.eip155Id?{chainId:Number(_.eip155Id)}:{},..._.address?{address:_.address}:{},..._.isNative===void 0?{}:{isNative:_.isNative},..._.assetLogoUrl?{logoUrl:_.assetLogoUrl}:{}}]:[]:[...y.values()].map(e=>{let t=e[0];return{symbol:t.asset.symbol,...t.chain.eip155Id?{chainId:Number(t.chain.eip155Id)}:{},...t.asset.address?{address:t.asset.address}:{},isNative:t.asset.isNative,...t.asset.assetLogoUrl?{logoUrl:t.asset.assetLogoUrl}:{}}}),[y,_]),[x,S]=o(void 0),[C,w]=o(void 0),T=a(()=>{if(x&&b.some(e=>e.symbol.toUpperCase()===x.symbol.toUpperCase()))return x;let e=_?.symbol.toUpperCase();return b.find(t=>t.symbol.toUpperCase()===e)??b[0]},[x,b,_?.symbol]),E=a(()=>(T?y.get(T.symbol.toUpperCase())?.map(e=>e.chain)??[...h]:[...h]).map(e=>{let t=e.minAmountUsd?.formatted??v;return{symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},isNative:!0,...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},...t?{minDeposit:t}:{}}}),[T,y,h,v]),D=a(()=>{if(C&&E.some(e=>e.chainId===C.chainId))return C;let e=_?.eip155Id?Number(_.eip155Id):void 0;return(e===void 0?void 0:E.find(t=>t.chainId===e))??E[0]},[C,E,_?.eip155Id]),O=a(()=>D?.chainId?h.find(e=>e.eip155Id&&Number(e.eip155Id)===D.chainId)??h[0]:h[0],[D,h]),k=a(()=>{if(!T)return;let e=O?.acceptedAssets?.find(e=>e.symbol.toUpperCase()===T.symbol.toUpperCase());return e?{symbol:e.symbol,...D?.chainId===void 0?{}:{chainId:D.chainId},...e.address?{address:e.address}:{},isNative:e.isNative,...e.assetLogoUrl?{logoUrl:e.assetLogoUrl}:{}}:T},[T,O,D?.chainId]),A=O?.address.value??``;if(d!==`transferCrypto`||!_||h.length===0)return null;let j={symbol:_.symbol,..._.eip155Id?{chainId:Number(_.eip155Id)}:{},..._.address?{address:_.address}:{},..._.isNative===void 0?{}:{isNative:_.isNative},..._.assetLogoUrl?{logoUrl:_.assetLogoUrl}:{}},M={symbol:_.networkName,..._.eip155Id?{chainId:Number(_.eip155Id)}:{},isNative:!0,..._.chainLogoUrl?{logoUrl:_.chainLogoUrl}:{}};return c(i,{...r,depositAddress:A,token:k,chain:D,onTokenChange:S,onChainChange:w,tokenOptions:b,chainOptions:E,sendAsset:k,sendNetwork:D,receiveAsset:j,receiveNetwork:M,children:[s(i.Header,{...p?{onBack:p}:{}}),c(i.Body,{children:[s(i.Selectors,{}),s(i.QrCode,{}),s(i.Summary,{}),s(i.Address,{}),s(i.Disclosure,{})]})]})}function u({open:e,defaultOpen:t,onOpenChange:n,trigger:i,...a}){return s(r,{open:e,defaultOpen:t,onOpenChange:n,trigger:i,children:s(l,{...a})})}(function(e){e.Dialog=u})(l||={});export{l as TransferCrypto};
1
+ "use client";import{useDepositSnapshot as e}from"../../driver/context.js";import{useDepositActions as t,useDepositEffectiveState as n}from"../../orchestrator/controller.js";import{useKitEmitter as r}from"../../../../events/emit/useKitEmitter.js";import"../../../../events/emit/index.js";import{DialogShell as i}from"../../../../shared/dialog/DialogShell.js";import{TransferCrypto as a}from"./compound/TransferCrypto.js";import"./compound/index.js";import{useCallback as o,useMemo as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";function d(i){let d=e(),f=n(),p=f.name,{back:m}=t(),h=f.name===`transferCrypto`&&f.ctx.backTarget!==`closed`?m:void 0,g=d.addresses,_=g.status===`ready`||g.status===`stale`?g.payload:[],v=d.target,y=v.status===`ready`||v.status===`stale`?v.payload:void 0,b=y?.minAmountUsd?.formatted,x=s(()=>{let e=new Map;for(let t of _)for(let n of t.acceptedAssets??[]){let r=n.symbol.toUpperCase(),i=e.get(r);i?i.push({chain:t,asset:n}):e.set(r,[{chain:t,asset:n}])}return e},[_]),S=s(()=>x.size===0?y?[{symbol:y.symbol,...y.eip155Id?{chainId:Number(y.eip155Id)}:{},...y.address?{address:y.address}:{},...y.isNative===void 0?{}:{isNative:y.isNative},...y.assetLogoUrl?{logoUrl:y.assetLogoUrl}:{}}]:[]:[...x.values()].map(e=>{let t=e[0];return{symbol:t.asset.symbol,...t.chain.eip155Id?{chainId:Number(t.chain.eip155Id)}:{},...t.asset.address?{address:t.asset.address}:{},isNative:t.asset.isNative,...t.asset.assetLogoUrl?{logoUrl:t.asset.assetLogoUrl}:{}}}),[x,y]),[C,w]=c(void 0),[T,E]=c(void 0),D=r(),O=o(e=>{w(e),D({type:`deposit.transfer.token.changed`,flow:`deposit`,tier:`ui`,payload:{token:e}})},[D]),k=o(e=>{E(e),D({type:`deposit.transfer.chain.changed`,flow:`deposit`,tier:`ui`,payload:{chain:e}})},[D]),A=o(e=>{D({type:`deposit.transfer.address.copied`,flow:`deposit`,tier:`ui`,payload:{address:e}})},[D]),j=s(()=>{if(C&&S.some(e=>e.symbol.toUpperCase()===C.symbol.toUpperCase()))return C;let e=y?.symbol.toUpperCase();return S.find(t=>t.symbol.toUpperCase()===e)??S[0]},[C,S,y?.symbol]),M=s(()=>(j?x.get(j.symbol.toUpperCase())?.map(e=>e.chain)??[..._]:[..._]).map(e=>{let t=e.minAmountUsd?.formatted??b;return{symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},isNative:!0,...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},...t?{minDeposit:t}:{}}}),[j,x,_,b]),N=s(()=>{if(T&&M.some(e=>e.chainId===T.chainId))return T;let e=y?.eip155Id?Number(y.eip155Id):void 0;return(e===void 0?void 0:M.find(t=>t.chainId===e))??M[0]},[T,M,y?.eip155Id]),P=s(()=>N?.chainId?_.find(e=>e.eip155Id&&Number(e.eip155Id)===N.chainId)??_[0]:_[0],[N,_]),F=s(()=>{if(!j)return;let e=P?.acceptedAssets?.find(e=>e.symbol.toUpperCase()===j.symbol.toUpperCase());return e?{symbol:e.symbol,...N?.chainId===void 0?{}:{chainId:N.chainId},...e.address?{address:e.address}:{},isNative:e.isNative,...e.assetLogoUrl?{logoUrl:e.assetLogoUrl}:{}}:j},[j,P,N?.chainId]),I=P?.address.value??``;if(p!==`transferCrypto`||!y||_.length===0)return null;let L={symbol:y.symbol,...y.eip155Id?{chainId:Number(y.eip155Id)}:{},...y.address?{address:y.address}:{},...y.isNative===void 0?{}:{isNative:y.isNative},...y.assetLogoUrl?{logoUrl:y.assetLogoUrl}:{}},R={symbol:y.networkName,...y.eip155Id?{chainId:Number(y.eip155Id)}:{},isNative:!0,...y.chainLogoUrl?{logoUrl:y.chainLogoUrl}:{}};return u(a,{...i,depositAddress:I,token:F,chain:N,onTokenChange:O,onChainChange:k,onCopy:A,tokenOptions:S,chainOptions:M,sendAsset:F,sendNetwork:N,receiveAsset:L,receiveNetwork:R,children:[l(a.Header,{...h?{onBack:h}:{}}),u(a.Body,{children:[l(a.Selectors,{}),l(a.QrCode,{}),l(a.Summary,{}),l(a.Address,{}),l(a.Disclosure,{})]})]})}function f({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...a}){return l(i,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:l(d,{...a})})}(function(e){e.Dialog=f})(d||={});export{d as TransferCrypto};
@@ -1,5 +1,5 @@
1
- import { TransferCryptoAddress } from "./components/Address.js";
2
1
  import { TransferCryptoBodyProps, TransferCryptoDialogProps, TransferCryptoDisclosureProps, TransferCryptoHeaderProps, TransferCryptoProps } from "./types.js";
2
+ import { TransferCryptoAddress } from "./components/Address.js";
3
3
  import { TransferCryptoDisclosure } from "./components/Disclosure.js";
4
4
  import { TransferCryptoHeader } from "./components/Header.js";
5
5
  import { TransferCryptoQrCode } from "./components/QrCode.js";