@stridge/kit 0.1.0-alpha.17 → 0.1.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/KitProvider.d.ts +12 -0
- package/dist/KitProvider.js +1 -1
- 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 +1 -1
- package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
- package/dist/flows/withdraw/orchestrator/controller.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/types.d.ts +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/shared/support/SupportButton.d.ts +1 -0
- package/dist/shared/support/SupportButton.js +1 -0
- 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 -1
- package/dist/shared/support/SupportSpinner.d.ts +1 -0
- package/dist/shared/support/index.d.ts +2 -0
- package/dist/shared/support/index.js +1 -1
- package/dist/shared/support/intercom-loader.d.ts +17 -0
- package/dist/shared/support/intercom-loader.js +1 -1
- package/dist/shared/support/resolveSupport.d.ts +1 -0
- package/dist/shared/support/resolveSupport.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 -1
- package/dist/shared/support/useMerchantContext.d.ts +1 -0
- package/dist/shared/support/useMerchantContext.js +1 -0
- package/dist/shared/ui/ExternalLink/ExternalLink.js +1 -1
- package/dist/stridge/StridgeProvider.d.ts +9 -0
- package/dist/stridge/StridgeProvider.js +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/withdraw/dialog/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/flows/withdraw/dialog/WithdrawDialogBindingsContext.d.ts +0 -44
- package/dist/flows/withdraw/dialog/WithdrawDialogBindingsContext.js +0 -1
package/dist/KitProvider.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { DepositDriver } from "./flows/deposit/driver/types.js";
|
|
|
2
2
|
import { WithdrawDriver } from "./flows/withdraw/driver/types.js";
|
|
3
3
|
import { KitScope } from "./scope/KitScope.js";
|
|
4
4
|
import { KitI18nConfig } from "./shared/i18n/createKitI18n.js";
|
|
5
|
+
import { IntercomMerchantContext } from "./shared/support/useIntercomMerchantContext.js";
|
|
6
|
+
import { SupportConfig } from "./shared/support/types.js";
|
|
5
7
|
import { KitStoragePersistence } from "./storage/types.js";
|
|
6
8
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
9
|
|
|
@@ -48,6 +50,8 @@ declare function KitProvider({
|
|
|
48
50
|
withdraw,
|
|
49
51
|
storage,
|
|
50
52
|
storageNamespace,
|
|
53
|
+
support,
|
|
54
|
+
merchantContext,
|
|
51
55
|
attribution,
|
|
52
56
|
...scopeProps
|
|
53
57
|
}: KitProvider.Props): _$react_jsx_runtime0.JSX.Element;
|
|
@@ -86,6 +90,14 @@ declare namespace KitProvider {
|
|
|
86
90
|
* keep state isolated. Defaults to `stridge-kit:storage:v1`.
|
|
87
91
|
*/
|
|
88
92
|
storageNamespace?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Merchant-configurable in-dialog "Get help" override for direct `<KitProvider />` mounts.
|
|
95
|
+
*/
|
|
96
|
+
support?: SupportConfig;
|
|
97
|
+
/**
|
|
98
|
+
* Merchant and user triage metadata passed to merchant-owned support callbacks.
|
|
99
|
+
*/
|
|
100
|
+
merchantContext?: IntercomMerchantContext;
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
//#endregion
|
package/dist/KitProvider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{DepositDriverProvider as t}from"./flows/deposit/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{GatewayController as i}from"./flows/deposit/orchestrator/controller.js";import{
|
|
1
|
+
"use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{DepositDriverProvider as t}from"./flows/deposit/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{GatewayController as i}from"./flows/deposit/orchestrator/controller.js";import{WithdrawBindingsProvider as a}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{WithdrawDriverProvider as o}from"./flows/withdraw/driver/context.js";import{WithdrawControllerProvider as s}from"./flows/withdraw/orchestrator/controller.js";import{KitScope as c}from"./scope/KitScope.js";import"./scope/index.js";import{SupportConfigContext as l}from"./shared/support/SupportConfigContext.js";import{useMemo as u}from"react";import{jsx as d}from"react/jsx-runtime";function f({children:f,i18n:p,direction:m,deposit:h,withdraw:g,storage:_,storageNamespace:v,support:y,merchantContext:b,attribution:x=`visible`,...S}){let C=n(p?.locale),w=f;g&&(w=d(a,{children:d(o,{driver:g,children:d(s,{children:w})})})),h&&(w=d(t,{driver:h,children:d(i,{children:w})}));let T=u(()=>({config:y,merchantContext:b??null}),[y,b]),E=y!==void 0||b!==void 0,D=d(r,{locale:p?.locale,messages:p?.messages,children:d(c,{...S,direction:m??C,locale:p?.locale,attribution:x,children:d(e,{storage:_,namespace:v,children:w})})});return E?d(l.Provider,{value:T,children:D}):D}export{f as KitProvider};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { WithdrawSubmitCallback } from "../orchestrator/types.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/flows/withdraw/bindings/WithdrawBindings.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Withdrawable balance the host surfaces to the withdraw form. Two accepted forms:
|
|
6
|
+
*
|
|
7
|
+
* - `number` — bare amount in display units (kit infers symbol from the provider-level
|
|
8
|
+
* `asset.symbol`; USD value is derived for known stablecoins or hidden otherwise).
|
|
9
|
+
* - `{ amount, amountUsd? }` — explicit amount plus optional pre-computed USD value.
|
|
10
|
+
*
|
|
11
|
+
* `undefined` represents the loading state — the kit renders a skeleton / em-dashes instead
|
|
12
|
+
* of a value.
|
|
13
|
+
*/
|
|
14
|
+
type WithdrawBalanceInput = number | {
|
|
15
|
+
amount: number;
|
|
16
|
+
amountUsd?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Trusted-recipient prefill chip surfaced next to the recipient address input. The kit no
|
|
20
|
+
* longer auto-derives a chip from `wagmi.address` — that misled users on embedded-wallet
|
|
21
|
+
* integrations, where `wagmi.address` is the integration's generated wallet rather than the
|
|
22
|
+
* user's primary self-custodial wallet. Hosts that have a verified, user-trusted address (a
|
|
23
|
+
* saved wallet on the user's profile, a KYC-bound payout destination, a whitelisted withdrawal
|
|
24
|
+
* address) pass it via {@link useWithdrawBindings} (or the `<WithdrawDialog>` prop of the same
|
|
25
|
+
* name); the chip's `aria-label` reads off `label` so the affordance is unambiguous about which
|
|
26
|
+
* address the user is filling with.
|
|
27
|
+
*/
|
|
28
|
+
interface WithdrawSuggestedRecipient {
|
|
29
|
+
/** Address that fills the recipient input when the chip is clicked. */
|
|
30
|
+
address: string;
|
|
31
|
+
/**
|
|
32
|
+
* Short human label for the chip — used as the accessible name (`aria-label`) so screen
|
|
33
|
+
* readers and click targets describe the saved address concretely (e.g. `"Saved wallet"`,
|
|
34
|
+
* `"Your verified address"`). When omitted, the chip falls back to a generic kit-default.
|
|
35
|
+
*/
|
|
36
|
+
label?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Receive-side chain id this address belongs to (EIP-155 numeric). When set, the chip is
|
|
39
|
+
* surfaced only while the form's selected receive chain matches — prevents the user from
|
|
40
|
+
* one-click-filling an Ethereum address while routing to BSC, etc. When omitted, the chip
|
|
41
|
+
* is surfaced unconditionally and address-chain compatibility is the integrator's concern.
|
|
42
|
+
*/
|
|
43
|
+
chainId?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Render-time inputs the host supplies to the withdraw flow. Whoever renders the withdraw UI —
|
|
47
|
+
* the kit's `<WithdrawDialog>` or a fully custom headless surface — publishes these via
|
|
48
|
+
* {@link useWithdrawBindings}. Form widgets read the display values reactively; the orchestrator's
|
|
49
|
+
* submit action reads `onSubmit` at submit time to fire the host's callback.
|
|
50
|
+
*/
|
|
51
|
+
interface WithdrawBindings {
|
|
52
|
+
/** Host-supplied source-side balance the form renders. */
|
|
53
|
+
balance?: WithdrawBalanceInput;
|
|
54
|
+
/**
|
|
55
|
+
* Host-supplied submit handler. Fired when the user submits the form (after the kit has
|
|
56
|
+
* prepared a fresh UDA target). The host calls the supplied actions to advance the FSM at
|
|
57
|
+
* the points its backend reaches the matching state.
|
|
58
|
+
*/
|
|
59
|
+
onSubmit?: WithdrawSubmitCallback;
|
|
60
|
+
/**
|
|
61
|
+
* Trusted recipient address surfaced as a prefill chip on the recipient field. See
|
|
62
|
+
* {@link WithdrawSuggestedRecipient}.
|
|
63
|
+
*/
|
|
64
|
+
suggestedRecipient?: WithdrawSuggestedRecipient;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Publish the host's render-time withdraw inputs (`balance`, `onSubmit`, `suggestedRecipient`)
|
|
68
|
+
* into the kit's withdraw scope. Call it once from whatever component renders the withdraw UI:
|
|
69
|
+
*
|
|
70
|
+
* - The kit's `<WithdrawDialog>` calls it internally with its render-time props.
|
|
71
|
+
* - A **headless** host that renders fully custom withdraw UI from `useWithdraw()` /
|
|
72
|
+
* `useWithdrawState()` / `useWithdrawSnapshot()` calls it directly — it's the supported way
|
|
73
|
+
* to wire `onSubmit` (and the optional display inputs) without mounting the dialog.
|
|
74
|
+
*
|
|
75
|
+
* Writes synchronously to the bridge ref during render so the controller's submit action always
|
|
76
|
+
* reads the latest `onSubmit`; a deferred `setState` updates the reactive state read by display
|
|
77
|
+
* widgets. Clears the bridge on unmount.
|
|
78
|
+
*
|
|
79
|
+
* @example Headless usage
|
|
80
|
+
* ```tsx
|
|
81
|
+
* useWithdrawBindings({
|
|
82
|
+
* balance: walletBalance,
|
|
83
|
+
* onSubmit: async (input, actions) => {
|
|
84
|
+
* const txHash = await backend.broadcastWithdrawal(input.depositTarget);
|
|
85
|
+
* actions.beginProcessing({ hash: txHash });
|
|
86
|
+
* },
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function useWithdrawBindings(bindings: WithdrawBindings): void;
|
|
91
|
+
//#endregion
|
|
92
|
+
export { WithdrawBalanceInput, WithdrawBindings, WithdrawSuggestedRecipient, useWithdrawBindings };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as e,use as t,useEffect as n,useMemo as r,useRef as i,useState as a}from"react";import{jsx as o}from"react/jsx-runtime";const s=e(null);s.displayName=`WithdrawBindingsContext`;function c({children:e}){let[t,n]=a({}),c=i({});return o(s,{value:r(()=>({bindings:t,setBindings:n,ref:c}),[t]),children:e})}function l(){return t(s)?.bindings??{}}function u(){let e=t(s),n=i({});return e?.ref??n}function d(e){let r=t(s),a=e.balance,o=e.onSubmit,c=e.suggestedRecipient;r&&(r.ref.current={...a===void 0?{}:{balance:a},...o?{onSubmit:o}:{},...c?{suggestedRecipient:c}:{}});let l=i(r?.setBindings);l.current=r?.setBindings;let u=i(r?.ref);u.current=r?.ref,n(()=>{let e=l.current;if(e)return e({...a===void 0?{}:{balance:a},...o?{onSubmit:o}:{},...c?{suggestedRecipient:c}:{}}),()=>{let e=l.current,t=u.current;t&&(t.current={}),e&&e({})}},[a,o,c])}export{c as WithdrawBindingsProvider,d as useWithdrawBindings,u as useWithdrawBindingsRef,l as useWithdrawBindingsValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { WithdrawBalanceInput, WithdrawBindings, WithdrawSuggestedRecipient, useWithdrawBindings } from "./WithdrawBindings.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./WithdrawBindings.js";
|
|
@@ -3,7 +3,7 @@ import { WithdrawalQuotePayload, WithdrawalSettlementFailurePayload, WithdrawalS
|
|
|
3
3
|
import { PrepareWithdrawalInput } from "../driver/types.js";
|
|
4
4
|
import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
5
5
|
import { WithdrawStateName, WithdrawSubmitCallback } from "../orchestrator/types.js";
|
|
6
|
-
import { WithdrawBalanceInput, WithdrawSuggestedRecipient } from "
|
|
6
|
+
import { WithdrawBalanceInput, WithdrawSuggestedRecipient } from "../bindings/WithdrawBindings.js";
|
|
7
7
|
import { WithdrawFormEventCallbacks } from "./WithdrawDialogEventsContext.js";
|
|
8
8
|
import { ErrorInfo } from "react";
|
|
9
9
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDialogLifecycle as e}from"../../../shared/orchestrator/useDialogLifecycle.js";import"../../../shared/orchestrator/index.js";import{
|
|
1
|
+
"use client";import{useDialogLifecycle as e}from"../../../shared/orchestrator/useDialogLifecycle.js";import"../../../shared/orchestrator/index.js";import{useWithdrawBindings as t}from"../bindings/WithdrawBindings.js";import"../bindings/index.js";import{useWithdrawSnapshot as n}from"../driver/context.js";import{useWithdrawEffectiveState as r,useWithdrawState as i}from"../orchestrator/controller.js";import{useWithdraw as a}from"../orchestrator/useWithdraw.js";import"../orchestrator/index.js";import{useIntercomShutdownOnUnmount as o}from"../../../shared/support/useIntercomShutdownOnUnmount.js";import"../../../shared/support/index.js";import{Dialog as s}from"../../../shared/ui/Dialog/Dialog.js";import"../../../shared/ui/Dialog/index.js";import{StepTransition as c}from"../../../shared/dialog/StepTransition.js";import{GatewayKitBoundary as l}from"../../../shared/error-handling/components/GatewayKitBoundary.js";import"../../../shared/error-handling/index.js";import{WithdrawError as u}from"../widgets/withdraw-error/WithdrawError.js";import{WithdrawDialogEventsProvider as d}from"./WithdrawDialogEventsContext.js";import{WithdrawForm as f}from"../widgets/withdraw-form/WithdrawForm.js";import{WithdrawInProgress as p}from"../widgets/withdraw-in-progress/WithdrawInProgress.js";import{WithdrawSuccess as m}from"../widgets/withdraw-success/WithdrawSuccess.js";import"../../../_internal/withdraw/widgets/index.js";import{useRef as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";function v({container:e,onError:h,onOpened:v,onClosed:b,onStepChanged:x,events:S,balance:C,onSubmit:w,suggestedRecipient:T}={}){let E=i(),D=r(),{close:O}=a(),k=n(),A=E.name!==`closed`;y(E,k.settlement,k.quote,{onOpened:v,onClosed:b,onStepChanged:x,events:S}),o(),t({...C===void 0?{}:{balance:C},...w?{onSubmit:w}:{},...T?{suggestedRecipient:T}:{}});let j=D.name===`submitting`?`form`:D.name;return g(s,{open:A,onOpenChange:e=>e?void 0:O(),children:g(s.Content,{container:e,children:g(l,{onError:h,onReset:O,children:g(d,{events:S??{},children:_(c,{stateKey:j,children:[D.name===`form`||D.name===`submitting`?g(f,{}):null,D.name===`inProgress`?g(p,{}):null,D.name===`success`?g(m,{}):null,D.name===`error`?g(u,{}):null]})})})})})}function y(t,n,r,i){let a=h(i);a.current=i,e({state:t,settlement:n,quote:r,fireFsm:(e,t)=>b(e,t,a.current),fireSettlement:(e,t)=>x(t,a.current),fireQuote:(e,t)=>{if(t.status===e)return;let n=a.current.events;t.status===`ready`&&n?.onQuoteResolved?.(t.payload),t.status===`error`&&n?.onQuoteFailed?.({reason:t.error.message||`Quote failed.`,...t.error.name?{code:t.error.name}:{}})}})}function b(e,t,n){let{onOpened:r,onClosed:i,onStepChanged:a,events:o}=n,s=e.name===`form`&&!!e.ctx?.notice;if(t.name===`form`&&t.ctx?.notice&&!s&&o?.onSignatureDeclined?.(),e.name!==t.name&&(e.name===`closed`&&t.name!==`closed`&&r?.(),e.name!==`closed`&&t.name===`closed`&&i?.(e.name),a?.({from:e.name,to:t.name}),e.name===`form`&&t.name===`submitting`&&o?.onWithdrawalConfirmed?.(),e.name===`submitting`&&t.name===`inProgress`&&t.ctx.tx&&o?.onWithdrawalSubmitted?.({input:t.ctx.input,tx:t.ctx.tx}),t.name===`error`)){let e=t.ctx.failure;e!==void 0&&t.ctx.tx===void 0&&e&&(o?.onSubmissionFailed?.(e),o?.onFailed?.(e))}}function x(e,t){if(e.status!==`ready`&&e.status!==`stale`)return;let n=e.payload,r=t.events;if(r){if(n.kind===`pending`){r.onProcessingProgress?.(n);return}if(n.kind===`succeeded`){r.onSucceeded?.(n);return}n.kind===`failed`&&r.onFailed?.(n)}}export{v as WithdrawDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useLingui as e}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as t}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as n}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as r}from"../../../shared/orchestrator/useEffectiveState.js";import{useSettlementWatcher as i}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{
|
|
1
|
+
"use client";import{useLingui as e}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as t}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as n}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as r}from"../../../shared/orchestrator/useEffectiveState.js";import{useSettlementWatcher as i}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useWithdrawBindingsRef as a}from"../bindings/WithdrawBindings.js";import"../bindings/index.js";import{useWithdrawDriverInstance as o}from"../driver/context.js";import{initialState as s,reducer as c}from"./reducer.js";import{createContext as l,use as u,useCallback as d,useMemo as f,useReducer as p,useRef as m}from"react";import{jsx as h}from"react/jsx-runtime";const g={id:`ldK3jJ`,message:`Failed to submit withdrawal.`},_={id:`kUFhUv`,message:`Withdrawal failed.`},v=l(null);v.displayName=`WithdrawControllerContext`;function y(){let e=u(v);if(!e)throw Error(`useWithdraw / WithdrawControllerProvider must be used inside <KitProvider withdraw={…} />. Mount KitProvider once at the host's app root with a withdraw driver.`);return e}function b(){return y().state}function x(){return y().effectiveState}function S(){return y().actions}function C({children:e}){let t=o(),[n,a]=p(c,s),l=T(n,a,t),u=n.name===`inProgress`?{form:n.ctx.input,submittedAt:n.ctx.submittedAt,...n.ctx.tx?{tx:n.ctx.tx}:{}}:void 0;i(t,u,u?`${u.submittedAt}|${u.tx?.hash??``}`:void 0),E(n,a,t);let d=r(n),m=w(a,l);return h(v,{value:f(()=>({state:n,effectiveState:d,dispatch:a,controller:m,actions:l}),[n,d,m,l]),children:e})}function w(e,t){let n=d(()=>{e({type:`OPEN`})},[e]),r=d(()=>{e({type:`CLOSE`})},[e]);return f(()=>({open:n,close:r,actions:t}),[n,r,t])}function T(n,r,i){let o=m(n);o.current=n;let s=m(i);s.current=i;let c=m(r);c.current=r;let{i18n:l}=e(),u=m(l);u.current=l;let p=a(),h=d(e=>{let n=s.current;c.current({type:`SUBMIT`,input:e});let r=new AbortController,i={sourceAssetSymbol:e.sourceAssetSymbol,sourceChainId:e.sourceChainId,amount:e.amount,receiveTokenSymbol:e.receiveTokenSymbol,receiveChainId:e.receiveChainId,recipientAddress:e.recipientAddress},a={beginProcessing(e){c.current({type:`BEGIN_PROCESSING`,submittedAt:Date.now(),...e?{tx:e}:{}})},setTxHash(e){c.current({type:`SET_TX_HASH`,tx:e,submittedAt:Date.now()})},fail(e){c.current({type:`MARK_FAILED`,...e?{failure:e}:{}})},succeed(){c.current({type:`MARK_SUCCEEDED`})}};n.prepareWithdrawal(i,r.signal).then(i=>{if(r.signal.aborted)return;let o=p.current.onSubmit;if(!o){c.current({type:`SUBMIT_FAILED`,failure:t(Error(`WithdrawDialog onSubmit is missing.`),u.current._(g)),input:e});return}let s=n.getSnapshot().quote,l=s.status===`ready`||s.status===`stale`?s.payload:void 0;try{let n=o({form:e,depositTarget:i.depositTarget,correlation:i.correlation,...l?{quote:l}:{}},a,r.signal);n&&typeof n.catch==`function`&&n.catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})}catch(n){if(r.signal.aborted)return;c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})}}).catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})},[]),_=d(()=>{c.current({type:`CLOSE`})},[]),v=d(()=>{c.current({type:`RESET`})},[]),y=d(()=>{c.current({type:`CLEAR_NOTICE`})},[]);return f(()=>({submit:h,close:_,reset:v,clearNotice:y}),[h,_,v,y])}function E(t,r,i){let a=m(t);a.current=t;let{i18n:o}=e(),s=m(o);s.current=o,n(i,(e,t)=>{if(a.current.name===`inProgress`){if(e===`succeeded`){r({type:`SETTLEMENT_SUCCEEDED`});return}if(e===`failed`){let e=t.settlement,n=e.status===`ready`||e.status===`stale`?e.payload:null,i=n&&n.kind===`failed`?{reason:s.current._(_),code:n.failureKind}:void 0;r({type:`SETTLEMENT_FAILED`,...i?{failure:i}:{}})}}})}export{C as WithdrawControllerProvider,y as useControllerContext,S as useWithdrawActions,x as useWithdrawEffectiveState,b as useWithdrawState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useKitI18n as e}from"../../../../shared/i18n/useKitI18n.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{
|
|
1
|
+
"use client";import{useKitI18n as e}from"../../../../shared/i18n/useKitI18n.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useWithdrawBindingsValue as n}from"../../bindings/WithdrawBindings.js";import"../../bindings/index.js";import{useWithdrawDriverInstance as r,useWithdrawSnapshot as i}from"../../driver/context.js";import{useWithdrawActions as ee,useWithdrawEffectiveState as te}from"../../orchestrator/controller.js";import{formatTokenAmount as ne}from"../../../../shared/format/formatTokenAmount.js";import{parseAmountInputValue as re}from"../../../../shared/ui/AmountInput/utils.js";import"../../../../shared/ui/AmountInput/index.js";import{toAssetDescriptor as a}from"../../../../shared/widgets/asset-descriptor.js";import{useQuoteCountdown as ie}from"../../../../shared/quote/useQuoteCountdown.js";import"../../../../shared/quote/index.js";import{WithdrawForm as o}from"./compound/WithdrawForm.js";import"./compound/index.js";import{useWithdrawDialogEvents as ae}from"../../dialog/WithdrawDialogEventsContext.js";import{isValidEvmAddress as oe,resolveSubmitLabel as se}from"./validation.js";import{useCallback as s,useEffect as c,useMemo as l,useRef as u,useState as d}from"react";import{jsx as f,jsxs as ce}from"react/jsx-runtime";function p({events:p}){let m=i(),h=r(),g=te(),_=ee(),{i18n:le,_:v}=t(),ue=ae(),de=l(()=>({...ue,...p??{}}),[ue,p]),y=u(de);y.current=de;let{balance:b,suggestedRecipient:fe}=n(),[x,pe]=d(``),[me,he]=d(``),S=g.name===`submitting`,C=g.name===`form`?g.ctx?.notice:void 0,ge=u(C);ge.current=C;let w=m.withdrawableBalances.status===`ready`||m.withdrawableBalances.status===`stale`?m.withdrawableBalances.payload[0]:void 0,T=l(()=>a(w)??{symbol:`USDC`},[w]),_e=l(()=>a(w?{symbol:w.networkName,eip155Id:w.eip155Id,isNative:!0,logoUrl:w.chainLogoUrl}:void 0)??{symbol:`BSC`},[w]),E=typeof b==`number`?b:typeof b==`object`?b.amount:void 0,ve=w?.symbol??T.symbol,D=E??w?.amount.value,ye=E===void 0?w?.symbol:ve,O=D!==void 0&&ye!==void 0?{amount:E===void 0?w?.amount.formatted??ne(D,le):ne(E,le),symbol:ye}:void 0,k=m.receiveOptions.status===`ready`||m.receiveOptions.status===`stale`?m.receiveOptions.payload:[],A=w?.eip155Id?Number(w.eip155Id):void 0,j=w?.symbol??T.symbol,M=l(()=>{let e=new Map;for(let t of k)for(let n of t.tokens){let r=n.symbol.toUpperCase(),i=e.get(r);i?i.push({chain:t,token:n}):e.set(r,[{chain:t,token:n}])}return e},[k]),N=l(()=>{if(M.size===0)return;let e=j.toUpperCase();return M.has(e)?e:M.keys().next().value},[M,j]),P=s(e=>{let t=M.get(e);if(!(!t||t.length===0))return(A===void 0?void 0:t.find(e=>e.chain.eip155Id===A))??t[0]},[M,A]),[F,I]=d(void 0),[L,R]=d(void 0);c(()=>{if(L||!N)return;let e=P(N);e&&(I(e.chain),R(e.token))},[N,P,L]);let z=s(()=>{ge.current&&_.clearNotice()},[_]),be=s(e=>{z(),pe(e),y.current.onRecipientChanged?.(e)},[z]),B=e().locale,V=s(e=>{z(),he(e);let t=re(e,B);y.current.onAmountChanged?.({raw:e,numeric:t})},[z,B]),xe=s(e=>{z();let t=e.symbol.toUpperCase(),n=M.get(t)?.find(e=>e.chain.eip155Id===F?.eip155Id)??P(t);n&&(I(n.chain),R(n.token),y.current.onReceiveTokenChanged?.(n.token),n.chain.eip155Id!==F?.eip155Id&&y.current.onReceiveChainChanged?.(n.chain))},[z,M,P,F?.eip155Id]),Se=s(e=>{z(),I(e);let t=L?.symbol.toUpperCase(),n=(t?e.tokens.find(e=>e.symbol.toUpperCase()===t):void 0)??e.tokens[0];n&&R(n),y.current.onReceiveChainChanged?.(e),n&&n.symbol!==L?.symbol&&y.current.onReceiveTokenChanged?.(n)},[z,L?.symbol]),H=re(me,B),U=H!==null&&H>0,Ce=x.trim(),we=Ce.length>0,W=oe(Ce),G=F!==void 0&&L!==void 0,K=U&&D!==void 0&&H>D,[q,Te]=d(null),J=(m.quote.status===`ready`||m.quote.status===`stale`)&&we&&U&&G&&q!==null&&q.recipient===x&&q.amount===H&&q.receiveChainId===F.eip155Id&&q.receiveSymbol===L.symbol?m.quote.payload:void 0,Ee=l(()=>M.size===0?[T]:[...M.values()].map(e=>{let t=e[0];return a({symbol:t.token.symbol,eip155Id:t.chain.eip155Id,address:t.token.address,isNative:t.token.isNative,logoUrl:t.token.assetLogoUrl})??{symbol:t.token.symbol}}),[M,T]),De=l(()=>{let e=L?.symbol.toUpperCase(),t=e?M.get(e):void 0;return(t?t.map(e=>e.chain):k).map(e=>a({symbol:e.networkName,eip155Id:e.eip155Id,isNative:!0,logoUrl:e.chainLogoUrl})??{symbol:e.networkName})},[L?.symbol,M,k]),Oe=L?a({symbol:L.symbol,eip155Id:F?.eip155Id,address:L.address,isNative:L.isNative,logoUrl:L.assetLogoUrl}):T,ke=F?a({symbol:F.networkName,eip155Id:F.eip155Id,isNative:!0,logoUrl:F.chainLogoUrl}):_e,Ae=l(()=>{if(J?.breakdown)return{route:J.breakdown.selectedRoute?.label,networkCost:J.breakdown.networkCost?.formatted,priceImpact:J.breakdown.priceImpact?.formatted}},[J]),je=l(()=>{if(U)return J?.receiveAmountUsd?J.receiveAmountUsd.formatted:`$${H.toFixed(2)}`},[H,U,J]),Me=J&&U?J.receiveAmount.formatted:void 0,Ne=J?.receiveAmountUsd?.formatted,Y=W&&U&&!K&&G&&J===void 0&&m.quote.status!==`error`,X=W&&U&&!K&&G&&J!==void 0,Pe=ie({expiresAt:J?.expiresAt,enabled:X}),Fe=X&&J?J.quoteTotalSeconds:void 0,[Z,Q]=d(!1);c(()=>{Q(!1)},[x,H,F?.eip155Id,L?.symbol,g.name]),c(()=>{if(!X||!J||g.name!==`form`||Z)return;let e=Math.max(0,J.expiresAt-Date.now()),t=setTimeout(()=>{Q(!0)},e);return()=>clearTimeout(t)},[X,J,g.name,Z]),c(()=>{if(!Z||g.name!==`form`||A===void 0||!F||!L||!W||!U||K)return;let e=new AbortController,t={recipient:x,amount:H??0,receiveChainId:F.eip155Id,receiveSymbol:L.symbol},n={sourceAssetSymbol:j,sourceChainId:A,amount:H??0,receiveTokenSymbol:L.symbol,receiveChainId:F.eip155Id,recipientAddress:x};return y.current.onQuoteRequested?.(n),h.requestQuote(n,e.signal).then(()=>{e.signal.aborted||Te(t)}).catch(()=>{}).finally(()=>{e.signal.aborted||Q(!1)}),()=>e.abort()},[Z,h,x,H,W,U,K,A,j,F,L,g.name]);let $=!W||!U||K||!G||Y||Z,Ie=se({enterRecipientAddress:v({id:`nr03QI`,message:`Enter Recipient Address`}),enterValidRecipientAddress:v({id:`GZPxmc`,message:`Enter Valid Recipient Address`}),enterAmount:v({id:`yH9V_J`,message:`Enter Amount`}),insufficientBalance:v({id:`N2DUxS`,message:`Insufficient Balance`}),regeneratingQuote:v({id:`Ly6geA`,message:`Regenerating quote…`}),estimatingQuote:v({id:`Uevt3L`,message:`Estimating quote`})},{isRecipientFilled:we,isRecipientValid:W,isAmountValid:U,exceedsBalance:K,quoteEstimating:Y,quoteRegenerating:Z}),Le=u(null);c(()=>{if(Le.current?.abort(),!W||!U||K||!G||g.name!==`form`||A===void 0)return;let e=new AbortController;Le.current=e;let t={recipient:x,amount:H,receiveChainId:F.eip155Id,receiveSymbol:L.symbol},n=setTimeout(()=>{let n={sourceAssetSymbol:j,sourceChainId:A,amount:H,receiveTokenSymbol:L.symbol,receiveChainId:F.eip155Id,recipientAddress:x};y.current.onQuoteRequested?.(n),h.requestQuote(n,e.signal).then(()=>{e.signal.aborted||Te(t)}).catch(()=>{})},400);return()=>{clearTimeout(n),e.abort()}},[h,x,H,W,U,K,G,A,j,F?.eip155Id,L?.symbol,g.name]);let Re=s(()=>{O&&V(O.amount)},[O,V]),ze=s(()=>{S||$||A===void 0||!F||!L||_.submit({sourceAssetSymbol:j,sourceChainId:A,amount:H??0,recipientAddress:x,receiveTokenSymbol:L.symbol,receiveChainId:F.eip155Id})},[_,H,A,j,F,L,x,$,S]),Be=s(e=>{let t=k.find(t=>String(t.eip155Id)===String(e.chainId));t&&Se(t)},[Se,k]),Ve=s(e=>{let t=e.symbol.toUpperCase(),n=M.get(t);!n||n.length===0||xe((n.find(e=>e.chain.eip155Id===F?.eip155Id)??n[0]).token)},[xe,M,F?.eip155Id]);return g.name!==`form`&&g.name!==`submitting`?null:ce(o,{recipientAddress:x,onRecipientChange:be,...fe?{suggestedRecipient:fe}:{},amount:me,onAmountChange:V,onAmountMax:Re,sourceAsset:T,sourceChain:_e,receiveAsset:Oe,receiveChain:ke,receiveAssetOptions:Ee,onReceiveAssetChange:Ve,receiveChainOptions:De,onReceiveChainChange:Be,balance:O,amountUsd:je,receiveAmount:Me,receiveAmountUsd:Ne,breakdown:Ae,quoteEstimating:Y,quoteRegenerating:Z,...Pe===void 0?{}:{quoteSeconds:Pe},...Fe===void 0?{}:{quoteTotalSeconds:Fe},submitting:S,submitDisabled:$,submitLabel:Ie,...C?{notice:C}:{},onSubmit:ze,children:[f(o.Header,{}),ce(o.Body,{children:[f(o.RecipientField,{}),f(o.AmountField,{}),f(o.ReceiveSelectors,{}),f(o.BreakdownCard,{})]}),f(o.Footer,{})]})}export{p as WithdrawForm};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DialogShellControls } from "../../../../../shared/dialog/DialogShell.js";
|
|
2
2
|
import { AssetDescriptor } from "../../../../../shared/widgets/asset-descriptor.js";
|
|
3
|
-
import { WithdrawSuggestedRecipient } from "../../../
|
|
3
|
+
import { WithdrawSuggestedRecipient } from "../../../bindings/WithdrawBindings.js";
|
|
4
4
|
import { ComponentProps, ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/flows/withdraw/widgets/withdraw-form/compound/types.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,16 @@ import { WithdrawSnapshot } from "./flows/withdraw/driver/types.js";
|
|
|
5
5
|
import { useWithdrawSnapshot } from "./flows/withdraw/driver/context.js";
|
|
6
6
|
import { useKitConfig } from "./scope/context.js";
|
|
7
7
|
import { KitPortalScope } from "./scope/KitPortalScope.js";
|
|
8
|
+
import { IntercomMerchantContext } from "./shared/support/useIntercomMerchantContext.js";
|
|
9
|
+
import { SupportConfig, SupportOpenContext } from "./shared/support/types.js";
|
|
8
10
|
import { createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, resolveStorageAdapter } from "./storage/adapters.js";
|
|
9
11
|
import { createKitStorage } from "./storage/createKitStorage.js";
|
|
10
12
|
import { DEFAULT_KIT_STORAGE_NAMESPACE, KitStorageProvider, useKitStorage, useKitStorageValue } from "./storage/context.js";
|
|
11
13
|
import { StridgeEnvironment } from "./drivers/stridge/types.js";
|
|
12
14
|
import { FailureInfo } from "./shared/orchestrator/types.js";
|
|
13
15
|
import { DepositActions, DepositController, DepositMethod, DepositState, DepositStateName, OpenInput } from "./flows/deposit/orchestrator/types.js";
|
|
14
|
-
import { WithdrawActions, WithdrawController, WithdrawState, WithdrawStateName, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
|
|
16
|
+
import { WithdrawActions, WithdrawController, WithdrawState, WithdrawStateName, WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
|
|
17
|
+
import { WithdrawBalanceInput, WithdrawBindings, WithdrawSuggestedRecipient, useWithdrawBindings } from "./flows/withdraw/bindings/WithdrawBindings.js";
|
|
15
18
|
import { ChainInput, ChainSlug, chains } from "./shared/chains/index.js";
|
|
16
19
|
import { ChainLogoMeta } from "./shared/utils/logos/chains.js";
|
|
17
20
|
import { ChainLogoInput, TokenLogoInput } from "./shared/utils/logos/types.js";
|
|
@@ -23,4 +26,4 @@ import { useWithdrawState } from "./flows/withdraw/orchestrator/controller.js";
|
|
|
23
26
|
import { useWithdraw } from "./flows/withdraw/orchestrator/useWithdraw.js";
|
|
24
27
|
import { useOptionalStridge, useStridge } from "./stridge/StridgeContext.js";
|
|
25
28
|
import { StridgeAppearance, StridgeAsset, StridgeDepositDestination, StridgeDepositFlowConfig, StridgeFlowOwner, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig } from "./stridge/StridgeProvider.js";
|
|
26
|
-
export { type BannerAckBucket, type ChainInput, type ChainLogoInput, type ChainLogoMeta, type ChainSlug, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositController, type DepositMethod, type OpenInput as DepositOpenInput, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, KitPortalScope, KitStorageProvider, type LogosNamespace, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeEnvironment, type StridgeFlowOwner, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type TokenLogoInput, type TxRef, type WithdrawActions, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, chains, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, logos, resolveStorageAdapter, useBannerAck, useBannerAckForSettlement, useDeposit, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalStridge, useStridge, useWithdraw, useWithdrawSnapshot, useWithdrawState };
|
|
29
|
+
export { type BannerAckBucket, type ChainInput, type ChainLogoInput, type ChainLogoMeta, type ChainSlug, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositController, type DepositMethod, type OpenInput as DepositOpenInput, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type IntercomMerchantContext, KitPortalScope, KitStorageProvider, type LogosNamespace, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeEnvironment, type StridgeFlowOwner, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SupportConfig, type SupportOpenContext, type TokenLogoInput, type TxRef, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, chains, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, logos, resolveStorageAdapter, useBannerAck, useBannerAckForSettlement, useDeposit, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalStridge, useStridge, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chains as e}from"./shared/chains/index.js";import{logos as t}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as n,createMemoryStorageAdapter as r,createSessionStorageAdapter as i,resolveStorageAdapter as a}from"./storage/adapters.js";import{createKitStorage as o}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as s,KitStorageProvider as c,useKitStorage as l,useKitStorageValue as u}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as d,bucketFromSettlement as f,useBannerAck as p,useBannerAckForSettlement as m}from"./banners/useBannerAck.js";import"./banners/index.js";import{useDepositSnapshot as h}from"./flows/deposit/driver/context.js";import{useDepositState as g}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as _}from"./flows/deposit/orchestrator/useDeposit.js";import{
|
|
1
|
+
import{chains as e}from"./shared/chains/index.js";import{logos as t}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as n,createMemoryStorageAdapter as r,createSessionStorageAdapter as i,resolveStorageAdapter as a}from"./storage/adapters.js";import{createKitStorage as o}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as s,KitStorageProvider as c,useKitStorage as l,useKitStorageValue as u}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as d,bucketFromSettlement as f,useBannerAck as p,useBannerAckForSettlement as m}from"./banners/useBannerAck.js";import"./banners/index.js";import{useDepositSnapshot as h}from"./flows/deposit/driver/context.js";import{useDepositState as g}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as _}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as v}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as y}from"./flows/withdraw/driver/context.js";import{useWithdrawState as b}from"./flows/withdraw/orchestrator/controller.js";import{useWithdraw as x}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as S}from"./scope/context.js";import{KitPortalScope as C}from"./scope/KitPortalScope.js";import{useOptionalStridge as w,useStridge as T}from"./stridge/StridgeContext.js";import{StridgeProvider as E}from"./stridge/StridgeProvider.js";export{s as DEFAULT_KIT_STORAGE_NAMESPACE,C as KitPortalScope,c as KitStorageProvider,E as StridgeProvider,d as bannerAckStorageKey,f as bucketFromSettlement,e as chains,o as createKitStorage,n as createLocalStorageAdapter,r as createMemoryStorageAdapter,i as createSessionStorageAdapter,t as logos,a as resolveStorageAdapter,p as useBannerAck,m as useBannerAckForSettlement,_ as useDeposit,h as useDepositSnapshot,g as useDepositState,S as useKitConfig,l as useKitStorage,u as useKitStorageValue,w as useOptionalStridge,T as useStridge,x as useWithdraw,v as useWithdrawBindings,y as useWithdrawSnapshot,b as useWithdrawState};
|
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`0.1.0-alpha.
|
|
1
|
+
var e=`0.1.0-alpha.19`;export{e as version};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{styles as e}from"../ui/ExternalLink/ExternalLink.styles.js";import{joinClassNames as t}from"../utils/joinClassNames.js";import{cloneElement as n,isValidElement as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import*as o from"@stylexjs/stylex";function s({children:n,suffix:r,className:s,style:d,...f}){let p=r!=null&&r!==!1,m=o.props(e.root,l.button),h=t(m.className,s),g=o.props(e.iconSlot,e.suffixSpacing);return a(`button`,{"data-stridge-slot":u.root,type:`button`,...f,className:h,style:{...m.style,...d},children:[n,p?i(`span`,{"data-icon":`inline-end`,...g,children:c(r)}):null]})}function c(t){if(!r(t))return t;let i=o.props(e.iconSvg);return n(t,{className:[t.props.className,i.className].filter(Boolean).join(` `),style:{...t.props.style,...i.style}})}const l={button:{"SupportButton__supportButtonStyles.button":`SupportButton__supportButtonStyles.button`,"appearance-kysU6D":`xjyslct`,"padding-kmVPX3":`x1717udv`,"font-kVVagm":`xln7xf2`,"color-kMwMTN":`x1heor9g`,"cursor-kkrTdU":`x1ypdohk`,"textAlign-k9WMMc":`x16tdsg8`,$$css:`@stridge/kit:src/shared/support/SupportButton.tsx:52`}},u={root:`support-button`};export{s as SupportButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as e,use as t}from"react";const n=e({config:void 0,merchantContext:null});n.displayName=`SupportConfigContext`;function r(){return t(n)}export{n as SupportConfigContext,r as useSupportConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { CSSProperties, MouseEventHandler, ReactNode } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{useSupportConfig as e}from"./SupportConfigContext.js";import{resolveSupport as t}from"./resolveSupport.js";import{SupportButton as n}from"./SupportButton.js";import{BRAND_LINKS as r}from"../constants/brand-links.js";import{ExternalLink as i}from"../ui/ExternalLink/ExternalLink.js";import"../ui/ExternalLink/index.js";import{SupportSpinner as a}from"./SupportSpinner.js";import{useSupportTrigger as o}from"./useSupportTrigger.js";import{useCallback as s}from"react";import{jsx as c}from"react/jsx-runtime";const l={cursor:`not-allowed`,opacity:.6,pointerEvents:`none`};function u(n){let{config:r,merchantContext:i}=e(),a=t(r);return a.kind===`stridge`?c(d,{...n}):a.kind===`url`?c(f,{...n,url:a.url}):c(p,{...n,url:a.url,onOpen:a.onOpen,merchantContext:i})}function d({children:e,suffix:t,onClick:n,style:u,...d}){let f=o(),p=f.status===`loading`,m=s(e=>{n?.(e),!e.defaultPrevented&&e.button===0&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),f.open()))},[f,n]),h=p?{...u,...l}:u;return c(i,{...d,href:r.support,suffix:p?c(a,{}):t,onClick:m,"aria-busy":p||void 0,"aria-disabled":p||void 0,style:h,children:e})}function f({url:e,children:t,...n}){return c(i,{...n,href:e,children:t})}function p({url:e,onOpen:t,merchantContext:r,children:a,suffix:o,onClick:l,...u}){let d=s(e=>{l?.(e),!e.defaultPrevented&&e.button===0&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t({event:e,...m(r)})))},[l,t,r]),f=s(e=>{l?.(e),!e.defaultPrevented&&t({event:e,...m(r)})},[l,t,r]);return e?c(i,{...u,href:e,suffix:o,onClick:d,children:a}):c(n,{...u,suffix:o,onClick:f,children:a})}function m(e){return e??{gatewayKey:``,environment:``,assetChain:``,assetSymbol:``}}export{u as SupportLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./intercom-loader.js";import"./SupportSpinner.js";import"./useSupportTrigger.js";import"./SupportLink.js";import"./useIntercomMerchantContext.js";import"./useIntercomShutdownOnUnmount.js";
|
|
1
|
+
import"./SupportConfigContext.js";import"./intercom-loader.js";import"./resolveSupport.js";import"./SupportButton.js";import"./SupportSpinner.js";import"./useSupportTrigger.js";import"./SupportLink.js";import"./useIntercomMerchantContext.js";import"./useIntercomShutdownOnUnmount.js";import"./useMerchantContext.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/shared/support/intercom-loader.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Messenger command dispatcher exposed at `window.Intercom`. The vendor accepts arbitrary
|
|
4
|
+
* command tuples (`["boot", settings]`, `["onShow", callback]`, `["show"]`, …); our calls
|
|
5
|
+
* are funneled through {@link openIntercom} / {@link shutdownIntercom}.
|
|
6
|
+
*/
|
|
7
|
+
type IntercomFn = (...args: unknown[]) => void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
Intercom?: IntercomFn;
|
|
11
|
+
intercomSettings?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns `true` when the vendor's real dispatcher is mounted on `window.Intercom`. Used by
|
|
16
|
+
* {@link useSupportTrigger} as a hint for whether a subsequent click can skip the spinner.
|
|
17
|
+
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BRAND_INTERCOM as e}from"../constants/brand-intercom.js";const t=`__stridgeKitShim__`;let n=null;function
|
|
1
|
+
import{BRAND_INTERCOM as e}from"../constants/brand-intercom.js";const t=`__stridgeKitShim__`;let n=null,r=!1;function i(e){return e[t]===!0}function a(){if(typeof window>`u`)return!1;let t=window.intercomSettings?.app_id,n=!1;if(typeof t==`string`&&t!==e.appId)n=!0;else{let e=window.Intercom;typeof e==`function`&&!i(e)&&t===void 0&&(n=!0)}return n&&o(),n}function o(){r||process.env.NODE_ENV!==`production`&&(r=!0,console.warn("[@stridge/kit] Detected a foreign Intercom workspace already mounted on this page. The kit's support link will fall back to opening the static support URL in a new tab. Configure `<StridgeProvider support={{ url: '...' }} />` or `<StridgeProvider support={{ onOpen: ... }} />` to silence this warning and customize the behavior."))}function s(){let e=window;if(typeof e.Intercom==`function`)return e.Intercom;let n=[],r=Object.assign((...e)=>{n.push(e)},{q:n,c:e=>{n.push(e)},[t]:!0});return e.Intercom=r,r}function c(){return n||(typeof document>`u`?Promise.reject(Error(`Intercom can only load in a browser`)):(n=new Promise((t,r)=>{let a=document.createElement(`script`);a.type=`text/javascript`,a.async=!0,a.src=`https://widget.intercom.io/widget/${e.appId}`,a.dataset.stridgeIntercom=`true`,a.addEventListener(`load`,()=>t()),a.addEventListener(`error`,()=>{n=null,a.remove(),typeof window<`u`&&window.Intercom&&i(window.Intercom)&&delete window.Intercom,r(Error(`Failed to load Intercom widget script`))}),document.head.appendChild(a)}),n))}function l(){if(typeof window>`u`)return!1;let e=window.Intercom;return typeof e==`function`&&!i(e)}function u(){return typeof window>`u`?Promise.reject(Error(`Intercom can only load in a browser`)):a()?Promise.reject(Error(`Another Intercom workspace is already mounted; falling back to web link`)):new Promise((t,n)=>{let r=window;r.intercomSettings={...r.intercomSettings,app_id:e.appId,hide_default_launcher:!0};let i=s(),a=!1,o,l=e=>{a||(a=!0,o!==void 0&&clearTimeout(o),e())};i(`boot`,{...r.intercomSettings,app_id:e.appId,hide_default_launcher:!0}),i(`onShow`,()=>{l(()=>t())}),i(`onHide`,()=>{d()}),i(`show`),o=setTimeout(()=>{l(()=>n(Error(`Intercom messenger did not display within timeout`)))},1e4),c().catch(e=>{l(()=>n(e))})})}function d(){if(typeof window>`u`)return;let e=window.Intercom;if(typeof e==`function`&&!i(e))try{e(`shutdown`)}catch{}}export{l as isIntercomReady,u as openIntercom,d as shutdownIntercom};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e?.onOpen?e.url?{kind:`custom`,onOpen:e.onOpen,url:e.url}:{kind:`custom`,onOpen:e.onOpen}:e?.url?{kind:`url`,url:e.url}:{kind:`stridge`}}export{e as resolveSupport};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IntercomMerchantContext } from "./useIntercomMerchantContext.js";
|
|
2
|
+
import { MouseEvent } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/support/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configures the kit's in-dialog "Get help" entry point.
|
|
7
|
+
*
|
|
8
|
+
* Omit `support` to boot Stridge's hosted messenger on plain left-click and fall back to
|
|
9
|
+
* {@link https://stridge.com/contact-us | the support URL}. Provide `url`, `onOpen`, or both
|
|
10
|
+
* to use merchant-owned support; either field opts out of Stridge messenger globals. Empty
|
|
11
|
+
* values (`{}` or `{ url: "" }`) fall back to the Stridge default.
|
|
12
|
+
*
|
|
13
|
+
* Treated as static across the kit's lifetime. Switching the mode after mount (e.g. from
|
|
14
|
+
* Stridge to merchant-owned support) is not supported — the kit will not shut down an
|
|
15
|
+
* already-booted Stridge messenger or clear `window.intercomSettings` on the transition.
|
|
16
|
+
* Resolve support configuration before the first render of `<StridgeProvider>`.
|
|
17
|
+
*/
|
|
18
|
+
interface SupportConfig {
|
|
19
|
+
/**
|
|
20
|
+
* URL used as the "Get help" anchor `href`.
|
|
21
|
+
*
|
|
22
|
+
* Empty string is treated as if the field were omitted.
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Custom click handler invoked instead of the default Stridge messenger.
|
|
27
|
+
*
|
|
28
|
+
* Fires on plain left-click with the click event and the merchant/user triage metadata.
|
|
29
|
+
* Modified clicks keep anchor navigation when `url` is set.
|
|
30
|
+
*/
|
|
31
|
+
onOpen?: (ctx: SupportOpenContext) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Represents the argument passed to {@link SupportConfig.onOpen}.
|
|
35
|
+
*
|
|
36
|
+
* Combines the click event with the same triage metadata used by the Stridge messenger.
|
|
37
|
+
*/
|
|
38
|
+
interface SupportOpenContext extends IntercomMerchantContext {
|
|
39
|
+
/** React synthetic event for the click that triggered support. */
|
|
40
|
+
event: MouseEvent<HTMLElement>;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { SupportConfig, SupportOpenContext };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/shared/support/useIntercomMerchantContext.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Merchant, asset, and end-user triage metadata the kit attaches to support requests.
|
|
4
|
+
*
|
|
5
|
+
* Stridge's hosted messenger reads these fields via `window.intercomSettings` so support
|
|
6
|
+
* agents can route an incoming conversation without asking the user for context. Merchant-
|
|
7
|
+
* owned support entry points receive the same shape via
|
|
8
|
+
* {@link SupportOpenContext}, so triage data carries through verbatim into custom handlers.
|
|
9
|
+
*/
|
|
10
|
+
interface IntercomMerchantContext {
|
|
11
|
+
/** Stridge gateway key — primary key uniquely identifying which integrating business the user is coming through. */
|
|
12
|
+
gatewayKey: string;
|
|
13
|
+
/** Stridge API environment the kit is talking to. Goes alongside the gateway key for support triage. */
|
|
14
|
+
environment: string;
|
|
15
|
+
/** Stridge `network_id` of the settlement asset (e.g. `"60"`, `"9006"`). */
|
|
16
|
+
assetChain: string;
|
|
17
|
+
/** Settlement asset symbol (e.g. `"USDC"`). */
|
|
18
|
+
assetSymbol: string;
|
|
19
|
+
/** Connected wallet address — best-effort end-user identifier in a web3 context. */
|
|
20
|
+
userAddress?: string;
|
|
21
|
+
/** Merchant display name resolved from `gateway/start.metadata.brand_name`. Async; undefined pre-bootstrap. */
|
|
22
|
+
brandName?: string;
|
|
23
|
+
/** Optional secondary line from `gateway/start.metadata.checkout_item_title`. */
|
|
24
|
+
checkoutItemTitle?: string;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { IntercomMerchantContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{BRAND_INTERCOM as e}from"../constants/brand-intercom.js";import{useEffect as t}from"react";function n({gatewayKey
|
|
1
|
+
"use client";import{BRAND_INTERCOM as e}from"../constants/brand-intercom.js";import{useEffect as t}from"react";function n(n){let r=n?.gatewayKey,i=n?.environment,a=n?.assetChain,o=n?.assetSymbol,s=n?.userAddress,c=n?.brandName,l=n?.checkoutItemTitle;t(()=>{if(!r||!i||!a||!o||typeof window>`u`)return;let t=window.intercomSettings?.app_id;if(typeof t==`string`&&t!==e.appId)return;let n={company_id:r,environment:i,asset_chain:a,asset_symbol:o};c&&(n.name=c),l&&(n.checkout_item_title=l);let u={...window.intercomSettings,app_id:e.appId,hide_default_launcher:!0,company:n};if(s&&(u.user_id=s,u.wallet_address=s),window.intercomSettings=u,typeof window.Intercom==`function`)try{window.Intercom(`update`,u)}catch{}},[r,i,a,o,s,c,l])}export{n as useIntercomMerchantContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useSyncExternalStore as e}from"react";function t({gatewayKey:t,environment:n,assetChain:r,assetSymbol:i,userAddress:a,depositDriver:o}){let s=e(e=>o?.subscribe(e)??(()=>{}),()=>{if(!o)return;let e=o.getSnapshot();if(e.brand.status===`ready`||e.brand.status===`stale`)return e.brand.payload.name},()=>void 0),c=e(e=>o?.subscribe(e)??(()=>{}),()=>{if(!o)return;let e=o.getSnapshot();if(e.brand.status===`ready`||e.brand.status===`stale`)return e.brand.payload.checkoutItemTitle},()=>void 0);return{gatewayKey:t,environment:n,assetChain:r,assetSymbol:i,...a?{userAddress:a}:{},...s?{brandName:s}:{},...c?{checkoutItemTitle:c}:{}}}export{t as useMerchantContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{styles as e}from"./ExternalLink.styles.js";import{joinClassNames as t}from"../../utils/joinClassNames.js";import{EXTERNAL_LINK_SLOTS as n}from"./ExternalLink.slots.js";import{toSafeHref as r}from"./toSafeHref.js";import{cloneElement as i,isValidElement as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import*as c from"@stylexjs/stylex";function l({href:i,suffix:a,className:l,style:d,children:f,...p}){let m=r(i)??`#`,h=a!=null&&a!==!1,g=c.props(e.root),_=t(g.className,l),v=c.props(e.iconSlot,e.suffixSpacing);return s(`a`,{"data-stridge-slot":n.root,...p,href:m,target:`_blank`,rel:`noreferrer noopener`,className:_,style:{...g.style,...d},children:[f,h?o(`span`,{"data-icon":`inline-end`,...v,children:u(a)}):null]})}function u(t){if(!a(t))return t;let n=c.props(e.iconSvg);return i(t,{className:[t.props.className,n.className].filter(Boolean).join(` `),style:{...t.props.style,...n.style}})}export{l as ExternalLink};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KitI18nConfig } from "../shared/i18n/createKitI18n.js";
|
|
2
|
+
import { SupportConfig } from "../shared/support/types.js";
|
|
2
3
|
import { StridgeEnvironment } from "../drivers/stridge/types.js";
|
|
3
4
|
import { ChainInput } from "../shared/chains/index.js";
|
|
4
5
|
import { Address } from "viem";
|
|
@@ -187,6 +188,13 @@ declare namespace StridgeProvider {
|
|
|
187
188
|
* prefix at the call site.
|
|
188
189
|
*/
|
|
189
190
|
dev?: StridgeDevConfig;
|
|
191
|
+
/**
|
|
192
|
+
* Customer-support entry point configuration.
|
|
193
|
+
*
|
|
194
|
+
* Omit to use Stridge Intercom. Provide `url`, `onOpen`, or both to use merchant-owned
|
|
195
|
+
* support and opt out of Stridge messenger globals.
|
|
196
|
+
*/
|
|
197
|
+
support?: SupportConfig;
|
|
190
198
|
/** Optional className applied to the kit's scope root `<div>`. */
|
|
191
199
|
className?: string;
|
|
192
200
|
children?: ReactNode;
|
|
@@ -226,6 +234,7 @@ declare function StridgeProvider({
|
|
|
226
234
|
i18n,
|
|
227
235
|
storage,
|
|
228
236
|
dev,
|
|
237
|
+
support,
|
|
229
238
|
className,
|
|
230
239
|
children
|
|
231
240
|
}: StridgeProvider.Props): _$react_jsx_runtime0.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{normalizeChainToNetworkId as e}from"../shared/chains/index.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{StridgeContext as n}from"./StridgeContext.js";import{createStridgeDepositDriver as r}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as i}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{KitProvider as a}from"../KitProvider.js";import{
|
|
1
|
+
"use client";import{normalizeChainToNetworkId as e}from"../shared/chains/index.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{StridgeContext as n}from"./StridgeContext.js";import{createStridgeDepositDriver as r}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as i}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{KitProvider as a}from"../KitProvider.js";import{resolveSupport as o}from"../shared/support/resolveSupport.js";import{useIntercomMerchantContext as s}from"../shared/support/useIntercomMerchantContext.js";import{useMerchantContext as c}from"../shared/support/useMerchantContext.js";import"../shared/support/index.js";import{useOptionalWagmi as l}from"./optionalWagmi.js";import{createStubDepositDriver as u,createStubWithdrawDriver as d}from"./stubs.js";import{useMemo as f,useRef as p,useSyncExternalStore as m}from"react";import{jsx as h}from"react/jsx-runtime";function g({gatewayKey:g,environment:_,asset:v,flows:y,appearance:b,i18n:x,storage:S,dev:C,support:w,className:T,children:E}){if(!y.deposit&&!y.withdraw)throw Error("<StridgeProvider /> requires at least one of `flows.deposit` or `flows.withdraw`.");if(!v)throw Error("<StridgeProvider /> requires `asset: { chain, symbol }`.");let{config:D,address:O}=l(),k=f(()=>t(x??{}),[x?.locale,x?.messages]),A=p(k);A.current=k;let j=f(()=>e(v.chain),[v.chain]),M=v.symbol,N=y.deposit,P=y.withdraw,F=N?.owner?.address??O??C?.userAddressOverride,I=P?.owner.address,L=f(()=>{if(!(!N||!F))return r({userAddress:F,projectKey:g,destination:{network_id:j,asset_symbol:M,to_address:N.destination.address},wagmiConfig:D,getI18n:()=>A.current,..._?{environment:_}:{},...N.minDepositUsd===void 0?{}:{minDepositUsd:N.minDepositUsd},...N.metadata?{metadata:N.metadata}:{}})},[N,F,g,_,j,M,D]),R=f(()=>u(),[]),z=N?L??R:void 0,B=f(()=>{if(!(!P||!I))return i({userAddress:I,projectKey:g,currency:{networkId:j,assetSymbol:M},wagmiConfig:D,getI18n:()=>A.current,..._?{environment:_}:{},...P.metadata?{metadata:P.metadata}:{}})},[P,I,g,_,j,M,D]),V=f(()=>d(),[]),H=P?B??V:void 0,U=L??B,W=m(e=>U?.subscribe(e)??(()=>{}),()=>{if(L){let e=L.getSnapshot();return e.brand.status===`ready`&&e.target.status===`ready`}return B?B.getSnapshot().receiveOptions.status===`ready`:!1},()=>!1),G=F??I,K=c({gatewayKey:g,environment:_??`production`,assetChain:j,assetSymbol:M,...G?{userAddress:G}:{},...L?{depositDriver:L}:{}});return s(o(w).kind===`stridge`?K:null),h(n,{value:f(()=>({isReady:W,driver:L}),[W,L]),children:h(a,{theme:b?.theme,accent:b?.accent,radius:b?.radius,direction:b?.direction,attribution:b?.attribution,i18n:x,storage:S?.driver,storageNamespace:S?.namespace,className:T,support:w,merchantContext:K,...z?{deposit:z}:{},...H?{withdraw:H}:{},children:E})})}export{g as StridgeProvider};
|
package/dist/types.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import { KitStorageAdapter, KitStoragePersistence } from "./storage/types.js";
|
|
|
9
9
|
import { KitStorage } from "./storage/createKitStorage.js";
|
|
10
10
|
import { FailureInfo } from "./shared/orchestrator/types.js";
|
|
11
11
|
import { ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec } from "./flows/deposit/orchestrator/types.js";
|
|
12
|
-
import { WithdrawActions, WithdrawController, WithdrawEvent, WithdrawState, WithdrawStateName, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
|
|
12
|
+
import { WithdrawActions, WithdrawController, WithdrawEvent, WithdrawState, WithdrawStateName, WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
|
|
13
|
+
import { WithdrawBalanceInput, WithdrawBindings, WithdrawSuggestedRecipient } from "./flows/withdraw/bindings/WithdrawBindings.js";
|
|
13
14
|
import { BannerAckBucket } from "./banners/useBannerAck.js";
|
|
14
15
|
import { STEPS_WITH_OWN_SETTLEMENT_VIEW, stepRendersSettlement } from "./flows/deposit/orchestrator/steps.js";
|
|
15
|
-
export { type AcceptedAssetPayload, type AddressItemPayload, type AssetPayload, type BalanceItemPayload, type BannerAckBucket, type BrandPayload, type ChainPayload, type ConfirmDepositPhase, type DepositActions, type DepositController, type DepositMethod, type DepositSnapshot, type DepositState, type DepositStateName, type Entity, type FailureInfo, type GatewayEvent, type KitConfig, type KitDirection, type KitRadius, type KitStorage, type KitStorageAdapter, type KitStoragePersistence, type KitTarget, type KitTheme, type OpenInput, type QuoteBreakdownPayload, type QuotePayload, type QuoteRoutePayload, type ReceiveChainPayload, type ReceiveOptionDto, type ReceiveOptionsResponse, type ReceiveTokenOptionPayload, type ResolvedOpenInput, type RetryTargetSpec, STEPS_WITH_OWN_SETTLEMENT_VIEW, type SettlementFailureKind, type SettlementFailurePayload, type SettlementPayload, type SettlementPendingPayload, type SettlementSuccessPayload, type SourceWalletPayload, type TargetPayload, type TxRef, type WalletInfo, type WalletPayload, type WithdrawActions, type WithdrawController, type WithdrawEvent, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawableBalanceDto, type WithdrawableBalanceItemPayload, type WithdrawableBalancesResponse, type WithdrawalFormSnapshot, type WithdrawalQuoteBreakdownPayload, type WithdrawalQuoteDto, type WithdrawalQuotePayload, type WithdrawalQuoteResponse, type WithdrawalReceiveAssetPayload, type WithdrawalSettlementDto, type WithdrawalSettlementFailurePayload, type WithdrawalSettlementPayload, type WithdrawalSettlementPendingPayload, type WithdrawalSettlementResponse, type WithdrawalSettlementSuccessPayload, stepRendersSettlement };
|
|
16
|
+
export { type AcceptedAssetPayload, type AddressItemPayload, type AssetPayload, type BalanceItemPayload, type BannerAckBucket, type BrandPayload, type ChainPayload, type ConfirmDepositPhase, type DepositActions, type DepositController, type DepositMethod, type DepositSnapshot, type DepositState, type DepositStateName, type Entity, type FailureInfo, type GatewayEvent, type KitConfig, type KitDirection, type KitRadius, type KitStorage, type KitStorageAdapter, type KitStoragePersistence, type KitTarget, type KitTheme, type OpenInput, type QuoteBreakdownPayload, type QuotePayload, type QuoteRoutePayload, type ReceiveChainPayload, type ReceiveOptionDto, type ReceiveOptionsResponse, type ReceiveTokenOptionPayload, type ResolvedOpenInput, type RetryTargetSpec, STEPS_WITH_OWN_SETTLEMENT_VIEW, type SettlementFailureKind, type SettlementFailurePayload, type SettlementPayload, type SettlementPendingPayload, type SettlementSuccessPayload, type SourceWalletPayload, type TargetPayload, type TxRef, type WalletInfo, type WalletPayload, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawEvent, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawableBalanceDto, type WithdrawableBalanceItemPayload, type WithdrawableBalancesResponse, type WithdrawalFormSnapshot, type WithdrawalQuoteBreakdownPayload, type WithdrawalQuoteDto, type WithdrawalQuotePayload, type WithdrawalQuoteResponse, type WithdrawalReceiveAssetPayload, type WithdrawalSettlementDto, type WithdrawalSettlementFailurePayload, type WithdrawalSettlementPayload, type WithdrawalSettlementPendingPayload, type WithdrawalSettlementResponse, type WithdrawalSettlementSuccessPayload, stepRendersSettlement };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput } from "../../flows/withdraw/orchestrator/types.js";
|
|
2
|
-
import { WithdrawBalanceInput, WithdrawSuggestedRecipient } from "../../flows/withdraw/
|
|
2
|
+
import { WithdrawBalanceInput, WithdrawBindings, WithdrawSuggestedRecipient } from "../../flows/withdraw/bindings/WithdrawBindings.js";
|
|
3
3
|
import { WithdrawDialog } from "../../flows/withdraw/dialog/WithdrawDialog.js";
|
|
4
|
-
export { type WithdrawBalanceInput, WithdrawDialog, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient };
|
|
4
|
+
export { type WithdrawBalanceInput, type WithdrawBindings, WithdrawDialog, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient };
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
//#region src/flows/withdraw/dialog/WithdrawDialogBindingsContext.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Withdrawable balance the host surfaces to the dialog. Two accepted forms:
|
|
5
|
-
*
|
|
6
|
-
* - `number` — bare amount in display units (kit infers symbol from the provider-level
|
|
7
|
-
* `asset.symbol`; USD value is derived for known stablecoins or hidden otherwise).
|
|
8
|
-
* - `{ amount, amountUsd? }` — explicit amount plus optional pre-computed USD value.
|
|
9
|
-
*
|
|
10
|
-
* `undefined` represents the loading state — the kit renders a skeleton / em-dashes instead
|
|
11
|
-
* of a value.
|
|
12
|
-
*/
|
|
13
|
-
type WithdrawBalanceInput = number | {
|
|
14
|
-
amount: number;
|
|
15
|
-
amountUsd?: number;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Trusted-recipient prefill chip surfaced next to the recipient address input. The kit no
|
|
19
|
-
* longer auto-derives a chip from `wagmi.address` — that misled users on embedded-wallet
|
|
20
|
-
* integrations, where `wagmi.address` is the integration's generated wallet rather than the
|
|
21
|
-
* user's primary self-custodial wallet. Hosts that have a verified, user-trusted address (a
|
|
22
|
-
* saved wallet on the user's profile, a KYC-bound payout destination, a whitelisted withdrawal
|
|
23
|
-
* address) pass it via the dialog's `suggestedRecipient` prop; the chip's `aria-label` reads
|
|
24
|
-
* off `label` so the affordance is unambiguous about which address the user is filling with.
|
|
25
|
-
*/
|
|
26
|
-
interface WithdrawSuggestedRecipient {
|
|
27
|
-
/** Address that fills the recipient input when the chip is clicked. */
|
|
28
|
-
address: string;
|
|
29
|
-
/**
|
|
30
|
-
* Short human label for the chip — used as the accessible name (`aria-label`) so screen
|
|
31
|
-
* readers and click targets describe the saved address concretely (e.g. `"Saved wallet"`,
|
|
32
|
-
* `"Your verified address"`). When omitted, the chip falls back to a generic kit-default.
|
|
33
|
-
*/
|
|
34
|
-
label?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Receive-side chain id this address belongs to (EIP-155 numeric). When set, the chip is
|
|
37
|
-
* surfaced only while the form's selected receive chain matches — prevents the user from
|
|
38
|
-
* one-click-filling an Ethereum address while routing to BSC, etc. When omitted, the chip
|
|
39
|
-
* is surfaced unconditionally and address-chain compatibility is the integrator's concern.
|
|
40
|
-
*/
|
|
41
|
-
chainId?: number;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { WithdrawBalanceInput, WithdrawSuggestedRecipient };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{createContext as e,use as t,useEffect as n,useMemo as r,useRef as i,useState as a}from"react";import{jsx as o}from"react/jsx-runtime";const s=e(null);s.displayName=`WithdrawDialogBindingsContext`;function c({children:e}){let[t,n]=a({}),c=i({});return o(s,{value:r(()=>({bindings:t,setBindings:n,ref:c}),[t]),children:e})}function l(){return t(s)?.bindings??{}}function u(){let e=t(s),n=i({});return e?.ref??n}function d(e){let r=t(s),a=e.balance,o=e.onSubmit,c=e.suggestedRecipient;r&&(r.ref.current={...a===void 0?{}:{balance:a},...o?{onSubmit:o}:{},...c?{suggestedRecipient:c}:{}});let l=i(r?.setBindings);l.current=r?.setBindings;let u=i(r?.ref);u.current=r?.ref,n(()=>{let e=l.current;if(e)return e({...a===void 0?{}:{balance:a},...o?{onSubmit:o}:{},...c?{suggestedRecipient:c}:{}}),()=>{let e=l.current,t=u.current;t&&(t.current={}),e&&e({})}},[a,o,c])}export{c as WithdrawDialogBindingsProvider,d as usePublishWithdrawDialogBindings,l as useWithdrawDialogBindings,u as useWithdrawDialogBindingsRef};
|