@stridge/kit 0.1.0-alpha.3 → 0.1.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -6
- package/dist/KitProvider.d.ts +29 -0
- package/dist/KitProvider.js +1 -1
- package/dist/_internal/drivers/stridge/index.d.ts +2 -2
- package/dist/_internal/drivers/stridge/index.js +1 -1
- package/dist/_internal/withdraw/driver/index.d.ts +2 -2
- package/dist/deposit/compound/index.d.ts +2 -2
- package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
- package/dist/drivers/stridge/createStridgeWithdrawDriver.d.ts +26 -13
- package/dist/drivers/stridge/createStridgeWithdrawDriver.js +1 -1
- package/dist/drivers/stridge/internal/metadata.js +1 -1
- package/dist/drivers/stridge/types.d.ts +20 -14
- package/dist/drivers/stridge/types.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockDriver.d.ts +2 -2
- package/dist/drivers/stridge-mock/createStridgeMockDriver.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.d.ts +15 -3
- package/dist/drivers/stridge-mock/createStridgeMockWithdrawDriver.js +1 -1
- package/dist/drivers/stridge-mock/fixtures.d.ts +13 -11
- package/dist/drivers/stridge-mock/fixtures.js +1 -1
- package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
- package/dist/flows/deposit/driver/payloads.d.ts +10 -4
- package/dist/flows/deposit/driver/transformers/balanceToBalancesPayload.js +1 -1
- package/dist/flows/deposit/driver/transformers/startToAddressesPayload.js +1 -1
- package/dist/flows/deposit/driver/transformers/startToTargetPayload.js +1 -1
- package/dist/flows/deposit/orchestrator/controller.js +1 -1
- package/dist/flows/deposit/orchestrator/types.d.ts +30 -1
- package/dist/flows/deposit/orchestrator/useDeposit.d.ts +18 -1
- package/dist/flows/deposit/orchestrator/useDeposit.js +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.d.ts +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/amount-entry/footerIntent.js +1 -0
- package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.d.ts +6 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/types.d.ts +6 -3
- package/dist/flows/deposit/widgets/deposit-status-banner/DepositStatusBanner.d.ts +7 -0
- package/dist/flows/deposit/widgets/deposit-status-banner/DepositStatusBanner.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/DepositStatusBanner.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/components/Hero.js +1 -1
- package/dist/flows/deposit/widgets/deposit-status-banner/compound/components/PrimaryAction.js +1 -1
- package/dist/flows/deposit/widgets/processing-state/ProcessingState.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/TransferCrypto.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Address.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Disclosure.d.ts +2 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/Disclosure.js +1 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.d.ts +4 -10
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.js +1 -1
- package/dist/flows/shared/transformers/pickRelevantSettlement.js +1 -1
- package/dist/flows/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 +58 -12
- package/dist/flows/withdraw/dialog/WithdrawDialog.js +1 -1
- package/dist/flows/withdraw/driver/payloads.d.ts +16 -1
- package/dist/flows/withdraw/driver/transformers/settlementToWithdrawalPayload.js +1 -1
- package/dist/flows/withdraw/driver/transformers/supportedAssetsToReceiveOptionsPayload.js +1 -1
- package/dist/flows/withdraw/driver/types.d.ts +69 -13
- package/dist/flows/withdraw/orchestrator/controller.js +1 -1
- package/dist/flows/withdraw/orchestrator/index.d.ts +1 -1
- package/dist/flows/withdraw/orchestrator/reducer.js +1 -1
- package/dist/flows/withdraw/orchestrator/types.d.ts +106 -32
- package/dist/flows/withdraw/orchestrator/useWithdraw.d.ts +18 -1
- package/dist/flows/withdraw/orchestrator/useWithdraw.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/WithdrawForm.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.d.ts +7 -5
- package/dist/flows/withdraw/widgets/withdraw-form/compound/components/RecipientField.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-form/compound/types.d.ts +15 -5
- package/dist/flows/withdraw/widgets/withdraw-form/validation.js +1 -1
- package/dist/flows/withdraw/widgets/withdraw-in-progress/WithdrawInProgress.d.ts +2 -1
- package/dist/flows/withdraw/widgets/withdraw-in-progress/WithdrawInProgress.js +1 -1
- package/dist/i18n/index.d.ts +5 -4
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/locales/ar.js +1 -1
- package/dist/i18n/locales/es.js +1 -1
- package/dist/i18n/locales/source-keys.d.ts +12 -0
- package/dist/i18n/locales/source-keys.js +0 -0
- package/dist/icons/index.d.ts +2 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +1 -1
- package/dist/package.js +1 -0
- package/dist/scope/KitPortalScope.js +1 -1
- package/dist/scope/KitScope.d.ts +18 -1
- package/dist/scope/KitScope.js +1 -1
- package/dist/scope/context.d.ts +17 -1
- package/dist/scope/index.d.ts +1 -1
- package/dist/shared/attribution/Attribution.js +1 -0
- package/dist/shared/attribution/Attribution.slots.js +1 -0
- package/dist/shared/attribution/Attribution.styles.js +1 -0
- package/dist/shared/attribution/index.js +1 -0
- package/dist/shared/chains/index.d.ts +48 -29
- package/dist/shared/chains/index.js +1 -1
- package/dist/shared/constants/brand-intercom.js +1 -0
- package/dist/shared/cuer/Cuer.js +1 -0
- package/dist/shared/cuer/QrCode.js +1 -0
- package/dist/shared/cuer/index.js +1 -0
- package/dist/shared/dialog/Frame.js +1 -1
- package/dist/shared/dialog/StepTransition.js +1 -1
- package/dist/shared/driver/types.d.ts +4 -3
- package/dist/shared/i18n/KitI18nProvider.d.ts +11 -8
- package/dist/shared/i18n/KitI18nProvider.js +1 -1
- package/dist/shared/i18n/createKitI18n.d.ts +79 -16
- package/dist/shared/i18n/createKitI18n.js +1 -1
- package/dist/shared/i18n/useLingui.d.ts +11 -3
- package/dist/shared/icons/LogoIcon.d.ts +13 -0
- package/dist/shared/icons/LogoIcon.js +1 -0
- package/dist/shared/orchestrator/useSettlementWatcher.js +1 -1
- package/dist/shared/primitives/TxHashValue/TxHashValue.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 -0
- package/dist/shared/support/SupportSpinner.d.ts +1 -0
- package/dist/shared/support/SupportSpinner.js +1 -0
- package/dist/shared/support/index.d.ts +2 -0
- package/dist/shared/support/index.js +1 -0
- package/dist/shared/support/intercom-loader.d.ts +17 -0
- package/dist/shared/support/intercom-loader.js +1 -0
- package/dist/shared/support/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 -0
- package/dist/shared/support/useIntercomShutdownOnUnmount.js +1 -0
- package/dist/shared/support/useMerchantContext.d.ts +1 -0
- package/dist/shared/support/useMerchantContext.js +1 -0
- package/dist/shared/support/useSupportTrigger.js +1 -0
- package/dist/shared/terms/TermsButton.d.ts +1 -0
- package/dist/shared/terms/TermsButton.js +1 -0
- package/dist/shared/terms/TermsConfigContext.d.ts +1 -0
- package/dist/shared/terms/TermsConfigContext.js +1 -0
- package/dist/shared/terms/TermsLink.d.ts +1 -0
- package/dist/shared/terms/TermsLink.js +1 -0
- package/dist/shared/terms/index.d.ts +1 -0
- package/dist/shared/terms/index.js +1 -0
- package/dist/shared/terms/resolveTerms.d.ts +1 -0
- package/dist/shared/terms/resolveTerms.js +1 -0
- package/dist/shared/terms/types.d.ts +43 -0
- package/dist/shared/ui/Card/Card.styles.js +1 -1
- package/dist/shared/ui/Details/Details.d.ts +9 -1
- package/dist/shared/ui/Details/Details.styles.js +1 -1
- package/dist/shared/ui/Dialog/Dialog.js +1 -1
- package/dist/shared/ui/Dialog/Dialog.styles.js +1 -1
- package/dist/shared/ui/ExternalLink/ExternalLink.js +1 -1
- package/dist/shared/ui/Select/Select.js +1 -1
- package/dist/shared/ui/WalletRow/WalletRow.d.ts +1 -1
- package/dist/shared/ui/WalletRow/WalletRow.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/Hero.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Hero/SwapBackdrop.js +1 -1
- package/dist/shared/widgets/confirm-transfer/compound/components/Disclaimer.d.ts +4 -3
- package/dist/shared/widgets/confirm-transfer/compound/components/Disclaimer.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/AssetValue.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/HelpInfo.js +1 -1
- package/dist/shared/widgets/error-state/compound/components/StatusValue.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.d.ts +1 -5
- package/dist/shared/widgets/processing-state/compound/ProcessingState.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.slots.d.ts +0 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.slots.js +1 -1
- package/dist/shared/widgets/processing-state/compound/ProcessingState.styles.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Details.d.ts +6 -1
- package/dist/shared/widgets/processing-state/compound/components/Details.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Header.d.ts +4 -3
- package/dist/shared/widgets/processing-state/compound/components/Header.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Hero.d.ts +11 -7
- package/dist/shared/widgets/processing-state/compound/components/Hero.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/Rows.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/StatusPill.js +1 -1
- package/dist/shared/widgets/processing-state/compound/components/splitAmount.js +1 -0
- package/dist/shared/widgets/processing-state/compound/index.d.ts +1 -1
- package/dist/shared/widgets/processing-state/compound/types.d.ts +7 -26
- package/dist/shared/widgets/success-state/compound/components/Actions.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/AssetValue.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/RouteValue.js +1 -1
- package/dist/shared/widgets/success-state/compound/components/StatusPill.js +1 -1
- package/dist/stridge/StridgeProvider.d.ts +172 -18
- package/dist/stridge/StridgeProvider.js +1 -1
- package/dist/stridge/optionalWagmi.js +1 -0
- package/dist/stridge/stubs.js +1 -1
- package/dist/styles/index.css +58 -12
- package/dist/types.d.ts +5 -4
- package/dist/ui/index.js +1 -1
- package/dist/withdraw/compound/index.d.ts +2 -2
- package/dist/withdraw/dialog/index.d.ts +3 -1
- package/package.json +10 -11
- package/dist/kit/package.js +0 -1
- package/dist/shared/widgets/processing-state/compound/components/Actions.d.ts +0 -17
- package/dist/shared/widgets/processing-state/compound/components/Actions.js +0 -1
- /package/dist/{utils/src/use-copy-to-clipboard.js → shared/utils/useCopyToClipboard.js} +0 -0
|
@@ -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=_?.
|
|
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 +1 @@
|
|
|
1
|
-
"use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{CopyIcon as t}from"../../../../../../shared/icons/CopyIcon.js";import{InfoIcon as n}from"../../../../../../shared/icons/InfoIcon.js";import"../../../../../../icons/index.js";import{Button as r}from"../../../../../../shared/ui/Button/Button.js";import"../../../../../../shared/ui/Button/index.js";import{Card as i}from"../../../../../../shared/ui/Card/Card.js";import{
|
|
1
|
+
"use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{CopyIcon as t}from"../../../../../../shared/icons/CopyIcon.js";import{InfoIcon as n}from"../../../../../../shared/icons/InfoIcon.js";import"../../../../../../icons/index.js";import{Button as r}from"../../../../../../shared/ui/Button/Button.js";import"../../../../../../shared/ui/Button/index.js";import{Card as i}from"../../../../../../shared/ui/Card/Card.js";import{text as a}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{TermsLink as o}from"../../../../../../shared/terms/TermsLink.js";import"../../../../../../shared/terms/index.js";import{useCopyToClipboard as s}from"../../../../../../shared/utils/useCopyToClipboard.js";import{useTransferCryptoContext as c}from"../context.js";import{TRANSFER_CRYPTO_SLOTS as l}from"../TransferCrypto.slots.js";import{styles as u}from"../TransferCrypto.styles.js";import{InfoTooltip as d}from"./InfoTooltip.js";import{useCallback as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import*as h from"@stylexjs/stylex";function g(){let g=c(`TransferCrypto.Address`),{_}=e(),{isCopied:v,copy:y}=s(g.depositAddress),b=_({id:`6D8qH6`,message:`Send the selected token on the selected chain to this address. Funds appear in your account once the network confirms the transfer.`}),x=f(async()=>{await y()&&g.onCopy?.(g.depositAddress)},[y,g]);return m(`div`,{"data-stridge-slot":l.address,...h.props(u.addressSection),children:[m(`div`,{...h.props(u.addressLabelRow),children:[m(a.span,{size:`meta`,fontWeight:`medium`,leading:`tight`,...h.props(u.addressLabel),children:[_({id:`pCzTTC`,message:`Your deposit address`}),p(d,{content:b,children:p(n,{"aria-hidden":!0,...h.props(u.addressLabelInfo)})})]}),p(o,{...h.props(u.termsLink),children:p(a.span,{size:`xs`,fontWeight:`medium`,leading:`tight`,color:`inherit`,children:_({id:`cGYrpE`,message:`Terms apply`})})})]}),m(i,{variant:`subdued`,dir:`ltr`,...h.props(u.addressPill),children:[p(a.span,{size:`xs`,fontWeight:`medium`,leading:`tight`,tracking:`normal`,font:`mono`,...h.props(u.addressText),children:g.depositAddress}),m(r,{variant:`secondary`,onClick:x,"aria-label":_({id:`SOVBoe`,message:`Copy deposit address`}),...h.props(u.copyButton),children:[p(t,{"aria-hidden":!0,...h.props(u.copyIcon)}),p(a.span,{size:`meta`,fontWeight:`semibold`,leading:`tight`,tracking:`tight`,color:`inherit`,children:_(v?{id:`PiH3UR`,message:`Copied!`}:{id:`he3ygx`,message:`Copy`})})]})]})]})}export{g as TransferCryptoAddress};
|
|
@@ -5,7 +5,8 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
5
5
|
/**
|
|
6
6
|
* Disclosure part — collapsible footer surfacing the rough processing-time
|
|
7
7
|
* hint as the trigger and the "Have questions?" help row inside the panel.
|
|
8
|
-
* The help row always renders and
|
|
8
|
+
* The help row always renders and opens the Stridge messenger via
|
|
9
|
+
* {@link SupportLink}.
|
|
9
10
|
*/
|
|
10
11
|
declare function TransferCryptoDisclosure({
|
|
11
12
|
defaultOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ChevronDownIcon as t}from"../../../../../../shared/icons/ChevronDownIcon.js";import{CircleHelpIcon as n}from"../../../../../../shared/icons/CircleHelpIcon.js";import{ClockIcon as r}from"../../../../../../shared/icons/ClockIcon.js";import"../../../../../../icons/index.js";import{
|
|
1
|
+
"use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ChevronDownIcon as t}from"../../../../../../shared/icons/ChevronDownIcon.js";import{CircleHelpIcon as n}from"../../../../../../shared/icons/CircleHelpIcon.js";import{ClockIcon as r}from"../../../../../../shared/icons/ClockIcon.js";import"../../../../../../icons/index.js";import{SupportLink as i}from"../../../../../../shared/support/SupportLink.js";import"../../../../../../shared/support/index.js";import{Card as a}from"../../../../../../shared/ui/Card/Card.js";import{Collapsible as o}from"../../../../../../shared/ui/Collapsible/Collapsible.js";import"../../../../../../shared/ui/Collapsible/index.js";import{text as s}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{TRANSFER_CRYPTO_SLOTS as c}from"../TransferCrypto.slots.js";import{styles as l}from"../TransferCrypto.styles.js";import{jsx as u,jsxs as d}from"react/jsx-runtime";import*as f from"@stylexjs/stylex";function p({defaultOpen:p=!1,open:m,onOpenChange:h,processingTime:g}){let{_}=e(),v=g??_({id:`KuqCAK`,message:`~ 2 min`});return d(o,{"data-stridge-slot":c.disclosure,defaultOpen:p,open:m,onOpenChange:h,render:u(a,{variant:`subdued`}),...f.props(l.disclosure),children:[d(o.Trigger,{render:u(`div`,{}),nativeButton:!1,...f.props(l.disclosureHeader),children:[u(r,{"aria-hidden":!0,...f.props(l.disclosureRowIcon)}),u(`div`,{...f.props(l.disclosureRowTextWithInfo),children:u(s.span,{size:`meta`,fontWeight:`medium`,leading:`tight`,children:_({id:`7evBec`,message:`Processing time: {resolvedProcessingTime}`,values:{resolvedProcessingTime:v}})})}),u(t,{"aria-hidden":!0,...f.props(l.disclosureChevron,l.disclosureHeaderChevron)})]}),u(o.Panel,{children:u(`div`,{...f.props(l.disclosurePanelInner),children:d(`div`,{...f.props(l.disclosureRow),children:[u(n,{"aria-hidden":!0,...f.props(l.disclosureRowIcon)}),d(`div`,{children:[u(s.span,{size:`meta`,fontWeight:`medium`,leading:`tight`,...f.props(l.helpQuestion),children:_({id:`QU2cIs`,message:`Have questions?`})}),u(i,{...f.props(l.helpLink),children:u(s.span,{size:`meta`,fontWeight:`medium`,leading:`tight`,color:`inherit`,children:_({id:`AWtGgd`,message:`Get help`})})})]})]})})})]})}export{p as TransferCryptoDisclosure};
|
|
@@ -5,16 +5,10 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
5
5
|
* QR code part — renders the deposit address as a QR code with the
|
|
6
6
|
* selected chain's logo punched out at the center.
|
|
7
7
|
*
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* grid) — `height: 36px` on the icon turned into ~175 actual pixels
|
|
13
|
-
* and the SVG ballooned. Percentages resolve correctly because they
|
|
14
|
-
* stay in the local user-unit space, so the img sizes against Cuer's
|
|
15
|
-
* arena `<foreignObject>` width/height directly. `object-fit: contain`
|
|
16
|
-
* preserves aspect ratio so chain logos with non-square viewBoxes
|
|
17
|
-
* (Ethereum is 784×1277) don't squish.
|
|
8
|
+
* The logo is rendered via `Cuer.Arena` as a native SVG `<image>` —
|
|
9
|
+
* `preserveAspectRatio="xMidYMid meet"` (the SVG equivalent of
|
|
10
|
+
* `object-fit: contain`) keeps non-square chain artwork from squishing,
|
|
11
|
+
* and the SVG coordinate system places it exactly on the QR centre.
|
|
18
12
|
*/
|
|
19
13
|
declare function TransferCryptoQrCode(): _$react_jsx_runtime0.JSX.Element;
|
|
20
14
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{resolveChainLogoChain as e}from"../../../../../../shared/utils/logos/resolveLogoSrc.js";import"../../../../../../shared/utils/logos/index.js";import{useTransferCryptoContext as t}from"../context.js";import{TRANSFER_CRYPTO_SLOTS as n}from"../TransferCrypto.slots.js";import{styles as r}from"../TransferCrypto.styles.js";import{useEffect as
|
|
1
|
+
"use client";import{resolveChainLogoChain as e}from"../../../../../../shared/utils/logos/resolveLogoSrc.js";import"../../../../../../shared/utils/logos/index.js";import{useTransferCryptoContext as t}from"../context.js";import{TRANSFER_CRYPTO_SLOTS as n}from"../TransferCrypto.slots.js";import{styles as r}from"../TransferCrypto.styles.js";import{Cuer as i}from"../../../../../../shared/cuer/Cuer.js";import"../../../../../../shared/cuer/index.js";import{useEffect as a,useState as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import*as l from"@stylexjs/stylex";function u(){let u=t(`TransferCrypto.QrCode`),d=e({...u.chain.chainId===void 0?{}:{chainId:u.chain.chainId},...u.chain.logoUrl===void 0?{}:{chainLogoUrl:u.chain.logoUrl}}),[f,p]=o(0);a(()=>{p(0)},[d.join(`|`)]);let m=d[f];return s(`div`,{"data-stridge-slot":n.qr,...l.props(r.qrFrame),children:c(i.Root,{value:u.depositAddress,size:160,...l.props(r.qrSvg),children:[s(i.Finder,{}),s(i.Cells,{}),m&&s(i.Arena,{href:m,"aria-label":u.chain.symbol,"data-stridge-slot":n.qrArena,onError:()=>{f<d.length-1&&p(f+1)}},m)]})})}export{u as TransferCryptoQrCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t={}){let n=e.settlements??[],r=t.txHash?.toLowerCase()
|
|
1
|
+
function e(e,t={}){let n=e.settlements??[],r=t.txHash?.toLowerCase();if(r){let e=n.filter(e=>e.from?.tx_id?.toLowerCase()===r);return e.length===0?void 0:[...e].sort((e,t)=>(t.updated_at??``).localeCompare(e.updated_at??``))[0]}let i=t.bestMatch;if(i){let t=i.destination.recipientAddress.toLowerCase(),r=i.destination.tokenSymbol.toLowerCase(),a=new Date(i.submittedAt).toISOString(),o=i.sourceAmountBaseUnits,s=n.filter(n=>{let s=n.created_at??``;if(s&&s<a)return!1;let c=e.destination;return!(Number(c.eip155_id)!==i.destination.chainId||(c.asset_symbol??``).toLowerCase()!==r||(c.address??``).toLowerCase()!==t||o!==void 0&&n.from?.raw_amount!==o)});return s.length===0?void 0:[...s].sort((e,t)=>(t.updated_at??``).localeCompare(e.updated_at??``))[0]}let a=t.sinceIso??``,o=n.filter(e=>(e.created_at??``)>=a);if(o.length!==0)return[...o].sort((e,t)=>(t.updated_at??``).localeCompare(e.updated_at??``))[0]}export{e as pickRelevantSettlement};
|
|
@@ -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";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TxRef } from "../../../shared/driver/types.js";
|
|
2
|
-
import { WithdrawalQuotePayload, WithdrawalSettlementFailurePayload, WithdrawalSettlementPendingPayload, WithdrawalSettlementSuccessPayload } from "../driver/payloads.js";
|
|
3
|
-
import { SubmitWithdrawalInput } from "../driver/types.js";
|
|
4
2
|
import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
5
|
-
import {
|
|
3
|
+
import { WithdrawalQuotePayload, WithdrawalSettlementFailurePayload, WithdrawalSettlementPendingPayload, WithdrawalSettlementSuccessPayload } from "../driver/payloads.js";
|
|
4
|
+
import { PrepareWithdrawalInput } from "../driver/types.js";
|
|
5
|
+
import { WithdrawStateName, WithdrawSubmitCallback } from "../orchestrator/types.js";
|
|
6
|
+
import { WithdrawBalanceInput, WithdrawSuggestedRecipient } from "../bindings/WithdrawBindings.js";
|
|
6
7
|
import { WithdrawFormEventCallbacks } from "./WithdrawDialogEventsContext.js";
|
|
7
8
|
import { ErrorInfo } from "react";
|
|
8
9
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -25,7 +26,10 @@ declare function WithdrawDialog({
|
|
|
25
26
|
onOpened,
|
|
26
27
|
onClosed,
|
|
27
28
|
onStepChanged,
|
|
28
|
-
events
|
|
29
|
+
events,
|
|
30
|
+
balance,
|
|
31
|
+
onSubmit,
|
|
32
|
+
suggestedRecipient
|
|
29
33
|
}?: WithdrawDialog.Props): _$react_jsx_runtime0.JSX.Element;
|
|
30
34
|
declare namespace WithdrawDialog {
|
|
31
35
|
interface Props {
|
|
@@ -56,21 +60,56 @@ declare namespace WithdrawDialog {
|
|
|
56
60
|
* valid for the named event.
|
|
57
61
|
*/
|
|
58
62
|
events?: Events;
|
|
63
|
+
/**
|
|
64
|
+
* Withdrawable balance to display in the form. Two forms:
|
|
65
|
+
*
|
|
66
|
+
* - `number` — bare amount in display units (kit infers symbol from the provider's
|
|
67
|
+
* `asset.symbol`; USD value is short-circuited to $1 for known stablecoins or
|
|
68
|
+
* hidden otherwise).
|
|
69
|
+
* - `{ amount, amountUsd? }` — explicit amount plus an optional pre-computed USD
|
|
70
|
+
* value.
|
|
71
|
+
*
|
|
72
|
+
* Pass `undefined` (or omit) while loading; the form renders a skeleton until a value
|
|
73
|
+
* arrives.
|
|
74
|
+
*/
|
|
75
|
+
balance?: WithdrawBalanceInput;
|
|
76
|
+
/**
|
|
77
|
+
* Submit handler — fires once the kit has prepared a fresh UDA target for the
|
|
78
|
+
* withdrawal. The host's backend (treasury wallet, custodial signer, whatever fits their
|
|
79
|
+
* stack) is responsible for broadcasting a transfer of the brand currency to that UDA;
|
|
80
|
+
* the kit hands a `WithdrawSubmitActions` handle the host calls to advance the FSM at
|
|
81
|
+
* the point its backend reaches the matching state. Required when the dialog is used —
|
|
82
|
+
* a missing callback lands the user on the error screen instead of an infinite spinner.
|
|
83
|
+
*/
|
|
84
|
+
onSubmit?: WithdrawSubmitCallback;
|
|
85
|
+
/**
|
|
86
|
+
* Trusted recipient address surfaced as a one-click prefill chip next to the recipient
|
|
87
|
+
* input. The kit no longer auto-derives this from `wagmi.address` (it misled users on
|
|
88
|
+
* embedded-wallet integrations where wagmi exposes a generated wallet, not the user's
|
|
89
|
+
* primary self-custodial wallet). Pass an explicit address you trust the user wants to
|
|
90
|
+
* fill with — a saved profile wallet, a KYC-bound payout destination, a whitelisted
|
|
91
|
+
* payout. When omitted, no chip renders.
|
|
92
|
+
*/
|
|
93
|
+
suggestedRecipient?: WithdrawSuggestedRecipient;
|
|
59
94
|
}
|
|
60
95
|
/**
|
|
61
96
|
* Operational lifecycle hooks. Splits cleanly into:
|
|
62
97
|
*
|
|
63
98
|
* - **Form-level inputs** (`onRecipientChanged` / `onAmountChanged` / `onReceiveTokenChanged`
|
|
64
99
|
* / `onReceiveChainChanged`) — fire on every change of the form's local state.
|
|
65
|
-
* - **User actions** (`onWithdrawalConfirmed`) —
|
|
100
|
+
* - **User actions** (`onWithdrawalConfirmed`) — fires when the user submits the form, just
|
|
101
|
+
* before the kit hands control to the host's `<WithdrawDialog onSubmit>` callback.
|
|
66
102
|
* - **Quote lifecycle** — track the form's quote entity through `loading → ready / error`.
|
|
67
|
-
* - **Submit lifecycle** — track the
|
|
68
|
-
*
|
|
103
|
+
* - **Submit lifecycle** — track the host-driven progression. The host calls
|
|
104
|
+
* `actions.beginProcessing(tx?)` from inside `onSubmit` to move the orchestrator into
|
|
105
|
+
* `inProgress`; `onWithdrawalSubmitted` fires once a tx hash is surfaced (either via
|
|
106
|
+
* `beginProcessing({ hash })` or a later `setTxHash`). `onSubmissionFailed` fires when
|
|
107
|
+
* the host calls `actions.fail(failure)` or `onSubmit` throws.
|
|
69
108
|
* - **Settlement entity** — track the gateway's settlement payload through pending / succeeded /
|
|
70
109
|
* failed.
|
|
71
110
|
*/
|
|
72
111
|
interface Events extends WithdrawFormEventCallbacks {
|
|
73
|
-
/** User submitted the form
|
|
112
|
+
/** User submitted the form — fires just before the host's `onSubmit` callback runs. */
|
|
74
113
|
onWithdrawalConfirmed?: () => void;
|
|
75
114
|
/** Quote entity reached `ready` with the formatted payload. */
|
|
76
115
|
onQuoteResolved?: (quote: WithdrawalQuotePayload) => void;
|
|
@@ -79,14 +118,21 @@ declare namespace WithdrawDialog {
|
|
|
79
118
|
reason: string;
|
|
80
119
|
code?: string;
|
|
81
120
|
}) => void;
|
|
82
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Orchestrator transitioned into `inProgress` with a tx hash supplied by the host —
|
|
123
|
+
* either passed to `actions.beginProcessing({ hash })` or surfaced later via
|
|
124
|
+
* `actions.setTxHash`.
|
|
125
|
+
*/
|
|
83
126
|
onWithdrawalSubmitted?: (event: {
|
|
84
|
-
input:
|
|
127
|
+
input: PrepareWithdrawalInput;
|
|
85
128
|
tx: TxRef;
|
|
86
129
|
}) => void;
|
|
87
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Host signaled a user-rejection-shaped failure from `onSubmit` (typically the user
|
|
132
|
+
* backed out of a wallet prompt); the orchestrator routed back to `form{notice}`.
|
|
133
|
+
*/
|
|
88
134
|
onSignatureDeclined?: () => void;
|
|
89
|
-
/**
|
|
135
|
+
/** Host signaled a non-rejection submission failure (backend rejection, network, …). */
|
|
90
136
|
onSubmissionFailed?: (failure: FailureInfo) => void;
|
|
91
137
|
/** The driver's `settlement` entity emitted a progressive pending update. */
|
|
92
138
|
onProcessingProgress?: (update: WithdrawalSettlementPendingPayload) => void;
|
|
@@ -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,5 +1,7 @@
|
|
|
1
1
|
import { SettlementFailureKind } from "../../../shared/driver/types.js";
|
|
2
2
|
import { FormattedField } from "../../../shared/format/types.js";
|
|
3
|
+
import { ChainType } from "../../../shared/chains/index.js";
|
|
4
|
+
|
|
3
5
|
//#region src/flows/withdraw/driver/payloads.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Per-asset balance available to withdraw — the brand-managed source the cash-out flow draws
|
|
@@ -108,6 +110,12 @@ interface WithdrawalSettlementPendingPayload {
|
|
|
108
110
|
kind: "pending";
|
|
109
111
|
receiveAsset: WithdrawalReceiveAssetPayload;
|
|
110
112
|
receiveAmount: FormattedField<number>;
|
|
113
|
+
/**
|
|
114
|
+
* USD value of `receiveAmount` at the settlement leg's price snapshot. Sourced from the
|
|
115
|
+
* gateway leg's `amount_usd` (`to` preferred, `from` fallback). Omitted when neither leg
|
|
116
|
+
* carries a priced amount — the in-progress hero then falls back to the quote's USD figure.
|
|
117
|
+
*/
|
|
118
|
+
receiveAmountUsd?: FormattedField<number>;
|
|
111
119
|
/** Recipient address — the destination the user supplied on the form. */
|
|
112
120
|
recipient: FormattedField<string>;
|
|
113
121
|
/** Unix-ms timestamp when the withdrawal was submitted. */
|
|
@@ -191,8 +199,15 @@ interface ReceiveChainPayload {
|
|
|
191
199
|
networkId: string;
|
|
192
200
|
/** Human-readable network name (e.g. `"Polygon"`). */
|
|
193
201
|
networkName: string;
|
|
194
|
-
/** EIP-155 chain id (numeric). */
|
|
202
|
+
/** EIP-155 chain id (numeric). Only meaningful when `chainType === "evm"`. */
|
|
195
203
|
eip155Id: number;
|
|
204
|
+
/**
|
|
205
|
+
* Chain family this network belongs to — driver-populated from the gateway's `chain_type`
|
|
206
|
+
* tag. The withdraw form drives recipient-address validation off this so a non-EVM receive
|
|
207
|
+
* chain accepts its own address shape instead of the EVM `0x…` form. Drivers that can't
|
|
208
|
+
* determine the family tag it `"unknown"`, which keeps the address gate permissive.
|
|
209
|
+
*/
|
|
210
|
+
chainType: ChainType;
|
|
196
211
|
/** Resolved chain icon URL — derived from the chain's native_currency.logo. */
|
|
197
212
|
chainLogoUrl?: string;
|
|
198
213
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{classifyFailureKind as e,classifySettlementStatus as t}from"../../../shared/transformers/classifySettlementStatus.js";import{parseDecimalSafe as n,parseSmallestUnit as r}from"../../../shared/transformers/parseSmallestUnit.js";import{parseIsoMs as i}from"../../../shared/transformers/parseIsoMs.js";import{formatDurationCompact as a}from"../../../../shared/format/formatDurationCompact.js";import{formatTimestamp as o}from"../../../../shared/format/formatTimestamp.js";import{formatTokenAmount as s}from"../../../../shared/format/formatTokenAmount.js";import{
|
|
1
|
+
import{classifyFailureKind as e,classifySettlementStatus as t}from"../../../shared/transformers/classifySettlementStatus.js";import{parseDecimalSafe as n,parseSmallestUnit as r}from"../../../shared/transformers/parseSmallestUnit.js";import{parseIsoMs as i}from"../../../shared/transformers/parseIsoMs.js";import{formatDurationCompact as a}from"../../../../shared/format/formatDurationCompact.js";import{formatTimestamp as o}from"../../../../shared/format/formatTimestamp.js";import{formatTokenAmount as s}from"../../../../shared/format/formatTokenAmount.js";import{formatUsd as c}from"../../../../shared/format/formatUsd.js";import{shortenAddress as l}from"../../../../shared/format/shortenAddress.js";function u(e,n,r){let i=t(e.status);return i===`completed`?f(e,n,r):i===`failed`?p(e,n,r):d(e,n,r)}function d(e,t,r){let a=e.from,u=e.to,d=i(a?.confirmed_at)??i(e.created_at)??Date.now(),f=m(t,r),p=g(u,t,r),y=_(a,t,r),b=h(u,p)||h(a,y),x=n(u?.amount_usd)||n(a?.amount_usd),S=t.destination.address,C=a?.tx_id,w=a?.eip155_id===void 0?void 0:Number(a.eip155_id);return{kind:`pending`,receiveAsset:f,receiveAmount:{value:b,formatted:s(b,r.i18n,{maxDecimals:p})},...x>0?{receiveAmountUsd:{value:x,formatted:c(x,r.i18n)}}:{},recipient:{value:S,formatted:l(S)},submittedAt:{value:d,formatted:o(d,r.i18n)},...C?{txHash:{value:C,formatted:l(C)},...v(r,w,C)?{txExplorerUrl:v(r,w,C)}:{}}:{}}}function f(e,t,n){let r=e.from,c=e.to,u=i(r?.confirmed_at)??i(e.created_at)??Date.now(),d=i(c?.settled_at)??i(e.updated_at)??Date.now(),f=Math.max(0,d-u),p=Math.round(f/1e3),_=m(t,n),b=g(c,t,n),x=h(c,b),S=t.destination.address,C=r?.tx_id??``,w=r?.eip155_id===void 0?void 0:Number(r.eip155_id),T=c?.tx_id,E=v(n,y(c?.eip155_id)??y(t.destination.eip155_id),T);return{kind:`succeeded`,receiveAsset:_,receiveAmount:{value:x,formatted:s(x,n.i18n,{maxDecimals:b})},recipient:{value:S,formatted:l(S)},submittedAt:{value:u,formatted:o(u,n.i18n)},filledAt:{value:d,formatted:o(d,n.i18n)},totalTime:{value:p,formatted:a(f,n.i18n)},txHash:{value:C,formatted:C?l(C):``},...v(n,w,C)?{txExplorerUrl:v(n,w,C)}:{},...T?{completionTx:{hash:{value:T,formatted:l(T)},...E?{explorerUrl:E}:{}}}:{}}}function p(t,n,r){let a=t.from,c=i(a?.confirmed_at)??i(t.created_at)??Date.now(),u=i(t.updated_at)??Date.now(),d=m(n,r),f=n.destination.address,p=a?.tx_id,h=a?.eip155_id===void 0?void 0:Number(a.eip155_id);return{kind:`failed`,failureKind:e(t.error),receiveAsset:d,receiveAmount:{value:0,formatted:s(0,r.i18n)},recipient:{value:f,formatted:l(f)},submittedAt:{value:c,formatted:o(c,r.i18n)},failedAt:{value:u,formatted:o(u,r.i18n)},...p?{txHash:{value:p,formatted:l(p)},...v(r,h,p)?{txExplorerUrl:v(r,h,p)}:{}}:{}}}function m(e,t){let n=t.receiveAssetEnrichment,r=Number(e.destination.eip155_id);return{symbol:e.destination.asset_symbol,decimals:e.destination.asset_decimals,address:e.destination.asset_address,isNative:!e.destination.asset_address,...n?.assetLogoUrl?{assetLogoUrl:n.assetLogoUrl}:{},networkId:e.destination.network_id,networkName:n?.networkName??e.destination.network_name,...Number.isFinite(r)?{eip155Id:e.destination.eip155_id}:{},...n?.chainLogoUrl?{chainLogoUrl:n.chainLogoUrl}:{}}}function h(e,t){if(!e)return 0;if(e.amount){let t=n(e.amount);if(t>0)return t}return e.raw_amount?r(e.raw_amount,t):0}function g(e,t,n){return n.receiveAssetDecimals??e?.asset_decimals??t.destination.asset_decimals}function _(e,t,n){return n.sendAssetDecimals??e?.asset_decimals??t.destination.asset_decimals}function v(e,t,n){if(!n||t===void 0)return;let r=e.explorers?.[t];if(r)return`${r.replace(/\/+$/,``)}/tx/${n}`}function y(e){if(e==null||e===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}export{u as settlementToWithdrawalPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{toChainType as e}from"../../../../shared/chains/index.js";import{formatNetworkName as t}from"../../../../shared/format/formatNetworkName.js";function n(n,r={}){let i=r.excludedChainIds,a=[];for(let r of n.assets){if(i?.has(r.eip155_id))continue;let n=r.native_currency,o=new Set,s=(e,t)=>`${e.toUpperCase()}@${t.toLowerCase()}`,c=[];if(n?.symbol){let e={symbol:n.symbol,name:n.name??n.symbol,address:``,decimals:typeof n.decimals==`number`?n.decimals:18,isNative:!0,...n.logo?{assetLogoUrl:n.logo}:{}};c.push(e),o.add(s(e.symbol,e.address))}let l=n?.symbol?.toUpperCase();for(let e of r.assets){if(!e.symbol||!e.address||l&&e.symbol.toUpperCase()===l)continue;let t=s(e.symbol,e.address);o.has(t)||(o.add(t),c.push({symbol:e.symbol,name:e.name??e.symbol,address:e.address,decimals:e.decimals,isNative:!1,...e.logo?{assetLogoUrl:e.logo}:{}}))}c.length!==0&&a.push({networkId:r.network_id,networkName:t(r.network_name),eip155Id:r.eip155_id,chainType:e(r.chain_type),...n?.logo?{chainLogoUrl:n.logo}:{},tokens:c})}return a.sort((e,t)=>e.eip155Id-t.eip155Id),a}export{n as supportedAssetsToReceiveOptionsPayload};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Entity, SettlementFailureKind, TxRef } from "../../../shared/driver/types.js";
|
|
2
|
+
import { FormattedField } from "../../../shared/format/types.js";
|
|
2
3
|
import { ReceiveOptionDto, ReceiveOptionsResponse, WithdrawableBalanceDto, WithdrawableBalancesResponse, WithdrawalQuoteDto, WithdrawalQuoteResponse, WithdrawalSettlementDto, WithdrawalSettlementResponse } from "./dto.js";
|
|
3
4
|
import { ReceiveChainPayload, ReceiveTokenOptionPayload, WithdrawableBalanceItemPayload, WithdrawalQuoteBreakdownPayload, WithdrawalQuotePayload, WithdrawalReceiveAssetPayload, WithdrawalSettlementFailurePayload, WithdrawalSettlementPayload, WithdrawalSettlementPendingPayload, WithdrawalSettlementSuccessPayload } from "./payloads.js";
|
|
4
5
|
|
|
@@ -8,8 +9,9 @@ import { ReceiveChainPayload, ReceiveTokenOptionPayload, WithdrawableBalanceItem
|
|
|
8
9
|
* {@link WithdrawDriver.getSnapshot} and consumed by `useSyncExternalStore`. The kit's
|
|
9
10
|
* `useWithdrawSnapshot()` hook returns this shape.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
* the `ready` / `stale` variants.
|
|
12
|
+
* Most fields are {@link Entity} envelopes — components switch on `status` and read `payload` on
|
|
13
|
+
* the `ready` / `stale` variants. The optional `minAmountUsd` / `maxAmountUsd` carry static
|
|
14
|
+
* config-derived USD bounds (set once at driver construction) and stay outside the entity model.
|
|
13
15
|
*/
|
|
14
16
|
interface WithdrawSnapshot {
|
|
15
17
|
/**
|
|
@@ -37,6 +39,18 @@ interface WithdrawSnapshot {
|
|
|
37
39
|
* error state screen renders.
|
|
38
40
|
*/
|
|
39
41
|
settlement: Entity<WithdrawalSettlementPayload, WithdrawalSettlementDto, WithdrawalSettlementResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Optional lower USD bound on the withdraw amount. The withdraw form blocks submit with a
|
|
44
|
+
* localized "Min $X" CTA when the typed amount sits below `value`. Set from
|
|
45
|
+
* `<StridgeProvider flows.withdraw.minAmountUsd>` and constant across the driver's lifetime.
|
|
46
|
+
*/
|
|
47
|
+
minAmountUsd?: FormattedField<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Optional upper USD bound on the withdraw amount. The withdraw form blocks submit with a
|
|
50
|
+
* localized "Max $X" CTA when the typed amount sits above `value`. Set from
|
|
51
|
+
* `<StridgeProvider flows.withdraw.maxAmountUsd>` and constant across the driver's lifetime.
|
|
52
|
+
*/
|
|
53
|
+
maxAmountUsd?: FormattedField<number>;
|
|
40
54
|
}
|
|
41
55
|
/**
|
|
42
56
|
* Input to {@link WithdrawDriver.requestQuote}. The form widget builds this from current field
|
|
@@ -57,17 +71,57 @@ interface RequestWithdrawalQuoteInput {
|
|
|
57
71
|
recipientAddress: string;
|
|
58
72
|
}
|
|
59
73
|
/**
|
|
60
|
-
* Input to {@link WithdrawDriver.
|
|
61
|
-
* — the live driver re-uses the most recent quote for
|
|
62
|
-
* scope both calls.
|
|
74
|
+
* Input to {@link WithdrawDriver.prepareWithdrawal}. Identical to {@link RequestWithdrawalQuoteInput}
|
|
75
|
+
* — the live driver re-uses the most recent quote shape for the gateway/start call, so the same
|
|
76
|
+
* identifying fields scope both calls.
|
|
63
77
|
*/
|
|
64
|
-
type
|
|
78
|
+
type PrepareWithdrawalInput = RequestWithdrawalQuoteInput;
|
|
65
79
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
80
|
+
* Result of {@link WithdrawDriver.prepareWithdrawal}. Carries everything the host's `onSubmit`
|
|
81
|
+
* callback needs to broadcast a transfer to the Stridge UDA on the brand-currency chain — the
|
|
82
|
+
* UDA address, the chain, the token, the amount — plus the Stridge correlation fields the host
|
|
83
|
+
* may want to mirror into their own backend logs.
|
|
84
|
+
*/
|
|
85
|
+
interface WithdrawPreparation {
|
|
86
|
+
/**
|
|
87
|
+
* Where the host should send brand-currency funds. The kit has already provisioned a UDA
|
|
88
|
+
* (via `gateway/start`); the host's job is to broadcast a single on-chain transfer of
|
|
89
|
+
* `amount` of `tokenSymbol` from their treasury / custodial wallet to `address` on `chainId`.
|
|
90
|
+
* Stridge takes over from there to bridge into the user's chosen recipient/chain/token.
|
|
91
|
+
*/
|
|
92
|
+
depositTarget: {
|
|
93
|
+
/** UDA deposit address on the brand-currency chain. */address: string; /** EIP-155 chain id of the brand-currency network. */
|
|
94
|
+
chainId: number; /** Brand-currency token symbol (e.g. `"USDC"`). */
|
|
95
|
+
tokenSymbol: string; /** ERC-20 contract address of the brand currency. Empty string for native gas tokens. */
|
|
96
|
+
tokenAddress: string; /** On-chain decimal precision (e.g. `6` for USDC on Ethereum, `18` for ETH). */
|
|
97
|
+
tokenDecimals: number; /** `true` when the brand currency is the chain's native gas token. */
|
|
98
|
+
isNative: boolean; /** Exact amount to transfer, in display units (kit-managed decimals already factored in). */
|
|
99
|
+
amount: number;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Stridge correlation slot the host can pass through to their own backend / logs. `owner`
|
|
103
|
+
* is the same value the kit threaded into `gateway/start.owner` for this UDA.
|
|
104
|
+
*/
|
|
105
|
+
correlation: {
|
|
106
|
+
owner: string;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Input to {@link WithdrawDriver.watchSettlement}. `tx` is optional — when the host has
|
|
111
|
+
* surfaced a broadcast tx hash via the orchestrator's `setTxHash` action, the watcher anchors
|
|
112
|
+
* to it for precise matching. When omitted, the watcher falls back to a best-match heuristic
|
|
113
|
+
* (destination tuple + amount tolerance + submit-time window) so the kit can find the relevant
|
|
114
|
+
* settlement even if the host never surfaces a tx hash.
|
|
68
115
|
*/
|
|
69
116
|
interface WatchWithdrawalSettlementInput {
|
|
70
|
-
tx
|
|
117
|
+
tx?: TxRef;
|
|
118
|
+
/**
|
|
119
|
+
* Form snapshot at submit time. The driver uses this in best-match mode to filter
|
|
120
|
+
* `gateway/{owner}` to settlements whose destination matches the user's selection.
|
|
121
|
+
*/
|
|
122
|
+
form: RequestWithdrawalQuoteInput;
|
|
123
|
+
/** Unix-ms timestamp the host called `beginProcessing` — the start of the matching window. */
|
|
124
|
+
submittedAt: number;
|
|
71
125
|
}
|
|
72
126
|
/**
|
|
73
127
|
* Input to {@link WithdrawDriver.watchWithdrawableBalances}. Optional listener — the form's
|
|
@@ -113,10 +167,12 @@ interface WithdrawDriver {
|
|
|
113
167
|
*/
|
|
114
168
|
requestQuote(input: RequestWithdrawalQuoteInput, signal: AbortSignal): Promise<void>;
|
|
115
169
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
170
|
+
* Provisions a fresh UDA for this withdrawal (via `gateway/start`) and returns the deposit
|
|
171
|
+
* target + Stridge correlation slot for the host's `onSubmit` callback to act on. The kit
|
|
172
|
+
* never signs the withdraw transfer itself — the host's backend (treasury wallet, custodial
|
|
173
|
+
* signer, hot-wallet service) does. See {@link WithdrawPreparation}.
|
|
118
174
|
*/
|
|
119
|
-
|
|
175
|
+
prepareWithdrawal(input: PrepareWithdrawalInput, signal: AbortSignal): Promise<WithdrawPreparation>;
|
|
120
176
|
/**
|
|
121
177
|
* Watches the settlement entity through its lifecycle (pending → succeeded / failed). The
|
|
122
178
|
* listener fires on every transition with the new envelope; the FSM consumes these via the
|
|
@@ -130,4 +186,4 @@ interface WithdrawDriver {
|
|
|
130
186
|
watchWithdrawableBalances?(input: WatchWithdrawableBalancesInput, listener: (entity: WithdrawSnapshot["withdrawableBalances"]) => void, signal: AbortSignal): void;
|
|
131
187
|
}
|
|
132
188
|
//#endregion
|
|
133
|
-
export {
|
|
189
|
+
export { PrepareWithdrawalInput, RequestWithdrawalQuoteInput, WatchWithdrawableBalancesInput, WatchWithdrawalSettlementInput, WithdrawDriver, WithdrawPreparation, WithdrawSnapshot };
|
|
@@ -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 u(v)}function x(){return y().state}function S(){return y().effectiveState}function C(){return y().actions}function w({children:e}){let t=o(),[n,a]=p(c,s),l=E(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),D(n,a,t);let d=r(n),m=T(a,l);return h(v,{value:f(()=>({state:n,effectiveState:d,dispatch:a,controller:m,actions:l}),[n,d,m,l]),children:e})}function T(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 E(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 D(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{w as WithdrawControllerProvider,y as useControllerContext,b as useOptionalControllerContext,C as useWithdrawActions,S as useWithdrawEffectiveState,x as useWithdrawState};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
2
2
|
import { WithdrawActions, WithdrawController, WithdrawEvent, WithdrawState, WithdrawStateName, WithdrawalFormSnapshot } from "./types.js";
|
|
3
3
|
import { useWithdrawState } from "./controller.js";
|
|
4
|
-
import { useWithdraw } from "./useWithdraw.js";
|
|
4
|
+
import { useOptionalWithdraw, useWithdraw } from "./useWithdraw.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isUserRejectionFailure as e}from"../../../shared/orchestrator/userRejection.js";import"../../../shared/orchestrator/index.js";const t={name:`closed`};function n(e,t){switch(e.name){case`closed`:return r(t);case`form`:return i(e,t);case`submitting`:return a(e,t);case`inProgress`:return o(e,t);case`success`:return s(e,t);case`error`:return c(e,t);default:return l(e)}}function r(e){return e.type===`OPEN`?{name:`form`}:{name:`closed`}}function i(e,t){switch(t.type){case`SUBMIT`:return{name:`submitting`,ctx:{input:t.input}};case`CLEAR_NOTICE`:return e.ctx?.notice?{name:`form`}:e;case`CLOSE`:return{name:`closed`};default:return e}}function a(t,n){switch(n.type){case`
|
|
1
|
+
import{isUserRejectionFailure as e}from"../../../shared/orchestrator/userRejection.js";import"../../../shared/orchestrator/index.js";const t={name:`closed`};function n(e,t){switch(e.name){case`closed`:return r(t);case`form`:return i(e,t);case`submitting`:return a(e,t);case`inProgress`:return o(e,t);case`success`:return s(e,t);case`error`:return c(e,t);default:return l(e)}}function r(e){return e.type===`OPEN`?{name:`form`}:{name:`closed`}}function i(e,t){switch(t.type){case`SUBMIT`:return{name:`submitting`,ctx:{input:t.input}};case`CLEAR_NOTICE`:return e.ctx?.notice?{name:`form`}:e;case`CLOSE`:return{name:`closed`};default:return e}}function a(t,n){switch(n.type){case`BEGIN_PROCESSING`:return{name:`inProgress`,ctx:{input:t.ctx.input,submittedAt:n.submittedAt,...n.tx?{tx:n.tx}:{}}};case`SET_TX_HASH`:return{name:`inProgress`,ctx:{input:t.ctx.input,submittedAt:n.submittedAt,tx:n.tx}};case`MARK_SUCCEEDED`:return{name:`success`,ctx:{input:t.ctx.input}};case`MARK_FAILED`:return{name:`error`,ctx:{input:t.ctx.input,...n.failure?{failure:n.failure}:{}}};case`SUBMIT_FAILED`:return e(n.failure)?{name:`form`,ctx:{notice:n.failure.reason}}:{name:`error`,ctx:{input:n.input,failure:n.failure}};case`CLOSE`:return{name:`closed`};default:return t}}function o(e,t){switch(t.type){case`SET_TX_HASH`:return{name:`inProgress`,ctx:{...e.ctx,tx:t.tx}};case`BEGIN_PROCESSING`:return{name:`inProgress`,ctx:{input:e.ctx.input,submittedAt:e.ctx.submittedAt,...e.ctx.tx?{tx:e.ctx.tx}:t.tx?{tx:t.tx}:{}}};case`MARK_SUCCEEDED`:return{name:`success`,ctx:{input:e.ctx.input,...e.ctx.tx?{tx:e.ctx.tx}:{}}};case`MARK_FAILED`:return{name:`error`,ctx:{input:e.ctx.input,...e.ctx.tx?{tx:e.ctx.tx}:{},...t.failure?{failure:t.failure}:{}}};case`SETTLEMENT_SUCCEEDED`:return{name:`success`,ctx:{input:e.ctx.input,...e.ctx.tx?{tx:e.ctx.tx}:{}}};case`SETTLEMENT_FAILED`:return{name:`error`,ctx:{input:e.ctx.input,...e.ctx.tx?{tx:e.ctx.tx}:{},...t.failure?{failure:t.failure}:{}}};case`CLOSE`:return{name:`closed`};default:return e}}function s(e,t){switch(t.type){case`RESET`:return{name:`form`};case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`RESET`:return{name:`form`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e){throw Error(`Unhandled withdraw state: ${JSON.stringify(e)}`)}export{t as initialState,n as reducer};
|