@multiversx/sdk-dapp-liquidity 2.3.0-alpha.3 → 2.3.0-alpha.5
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/package.json +1 -1
- package/reactjs/components/BridgeForm/Deposit.js +1 -1
- package/reactjs/components/BridgeForm/Deposit.mjs +149 -146
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +169 -163
- package/reactjs/hooks/useBalances.js +1 -1
- package/reactjs/hooks/useBalances.mjs +16 -15
- package/reactjs/hooks/useBridgeFormik.js +1 -1
- package/reactjs/hooks/useBridgeFormik.mjs +14 -14
- package/reactjs/hooks/useDebounce.js +1 -1
- package/reactjs/hooks/useDebounce.mjs +6 -6
- package/reactjs/hooks/useFetchTokens.js +1 -1
- package/reactjs/hooks/useFetchTokens.mjs +19 -14
- package/reactjs/init/init.d.ts +1 -0
- package/reactjs/init/init.js +1 -1
- package/reactjs/init/init.mjs +32 -32
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ct=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),lt=require("@reown/appkit/react"),ut=require("lodash/debounce"),i=require("react"),ue=require("react-toastify"),dt=require("./hooks/useBridgeTokenSelection.js"),de=require("../../../constants/index.js"),mt=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const Y=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const qt=require("../../../types/chainType.js"),ht=require("../../../types/providerType.js"),me=require("../../context/useWeb3App.js"),k=require("../../helpers/resolveBridgeApiChainId.js");require("yup");require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");require("bignumber.js");const pt=require("../../hooks/useAccount.js");require("axios");const I=require("../../hooks/useBridgeFormik.js"),gt=require("../../hooks/useFetchBridgeData.js"),xt=require("../../hooks/useBridgeApiChainId.js");require("@tanstack/react-query");const _t=require("../../hooks/useGetChainId.js"),ft=require("../../hooks/useSendTransactions.js");require("@reown/appkit-adapter-solana/react");require("wagmi");require("@reown/appkit-controllers");const jt=require("../../hooks/useDisconnectOnChainTypeChange.js"),Ct=require("../../hooks/useNamespaceAddress.js"),bt=require("../../queries/useGetHistory.query.js"),vt=require("../../queries/useGetRate.mutation.js"),qe=require("../../utils/mxClsx.js"),he=require("../AmountCard/AmountCard.js"),pe=require("../AmountInput/AmountInput.js"),It=require("../base/MxButton/MxButton.js");require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@fortawesome/react-fontawesome");require("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const At=require("../BridgeHistory/BridgeHistory.js"),Bt=require("../Connect/BridgeConnectButton.js"),yt=require("../Connect/MvxConnectButton.js"),Nt=require("../Connect/BridgeAccountDisplay.js"),Mt=require("../Connect/MvxAccountDisplay.js"),Et=require("../ToggleDirection/ToggleDirection.js"),ge=require("../TokenSelector/TokenSelector.js");let O;const wt=({mvxChainId:A,mvxAddress:a,username:xe,callbackRoute:_e="/",firstTokenIdentifier:fe,secondTokenIdentifier:je,firstTokenAmount:B,secondTokenAmount:_,refetchTrigger:Ce,showHistory:be,forcedDestinationTokenSymbol:ve,onSuccessfullySentTransaction:d,onFailedSentTransaction:q,onHistoryClose:y,onMvxConnect:J,onMvxDisconnect:Ie,onNavigate:Ae,onChangeDirection:Be})=>{var ce,le;const ye=i.useRef(null),[R,Ne]=i.useState(!1),[Me,Ee]=i.useState(1),[V,Z]=i.useState(0),[T,ee]=i.useState([]),we=pt.useAccount(),{switchNetwork:te}=lt.useAppKitNetwork(),ie=bt.useInvalidateHistoryQuery(),{options:se,supportedChains:f,nativeAuthToken:N,bridgeOnly:De}=me.useWeb3App(),F=_t.useGetChainId(),re=xt.useBridgeApiChainId(),ne=ft.useSendTransactions(),{signMvxTransactions:L,resetMvxTransactionHash:S,latestMvxTransactionHash:U}=me.useWeb3App(),{evmTokensWithBalances:ke,mvxTokensWithBalances:Oe,isTokensLoading:Re,isLoadingEvmTokensBalances:Ve,isLoadingMvxTokensBalances:Fe,chains:j=[],isChainsLoading:Le}=gt.useFetchBridgeData({refetchTrigger:Ce,mvxAddress:a,mvxApiURL:se.mvxApiURL}),G=Re||Ve||Fe||Le,Se=i.useMemo(()=>f.find(t=>k.sameBridgeApiChainId(t.id,F)),[F,f]),h=i.useMemo(()=>j.find(t=>t.chainId.toString()===A.toString()),[F,j]),{mutate:Ue,data:o,isPending:C,error:p}=vt.useGetRateMutation(),b=((ce=p==null?void 0:p.response)==null?void 0:ce.status)===400?(le=p==null?void 0:p.response)==null?void 0:le.data.message:void 0,Ge=i.useCallback(t=>{const x=f.find(at=>k.sameBridgeApiChainId(at.id,t.id));x&&te(x)},[f,te]),{firstToken:s,secondToken:r,fromOptions:He,toOptions:We,selectedChainOption:v,onChangeFirstSelect:Pe,onChangeSecondSelect:Qe,handleChangeDirection:Xe}=dt.useBridgeTokenSelection({chains:j,activeChain:Se,sdkChains:f,switchNetwork:Ge,fromTokens:Oe,toTokens:ke,firstTokenIdentifier:fe,secondTokenIdentifier:je,forcedDestinationTokenSymbol:ve,isTokensLoading:G,mvxChainId:A,callbackRoute:_e,onNavigate:Ae}),$e=()=>{Xe(),Be()},[l,ze]=i.useState(B??""),[M,E]=i.useState(_??""),Ke=i.useMemo(()=>s?de.MVX_CHAIN_IDS.includes(s.chainId.toString()):!1,[s==null?void 0:s.chainId]),Ye=i.useMemo(()=>r?de.MVX_CHAIN_IDS.includes(r.chainId.toString()):!1,[r==null?void 0:r.chainId]),n=i.useMemo(()=>r?j.find(t=>k.sameBridgeApiChainId(t.chainId,r.chainId))??v:v,[r==null?void 0:r.chainId,j,v]),w=i.useMemo(()=>k.toBridgeApiChainId(r==null?void 0:r.chainId)??re,[r==null?void 0:r.chainId,re]);jt.useDisconnectOnChainTypeChange(n==null?void 0:n.chainType);const c=Ct.useNamespaceAddress(n==null?void 0:n.chainType),Je=c,oe=we.isConnected&&!!c,H=l!==""&&M!=="",W=i.useCallback(ut(async t=>{!t||!Number(t)||!c||!(s!=null&&s.address)||!(r!=null&&r.address)||!v||!w||Ue({nativeAuthToken:N??"",body:{tokenIn:s.address,amountIn:t,fromChainId:A,tokenOut:r.address,toChainId:w}})},500),[c,w,s==null?void 0:s.address,r==null?void 0:r.address,v]),u=i.useCallback(t=>{ze(()=>t)},[]),g=i.useCallback(t=>{E(()=>t)},[]),Ze=i.useCallback(()=>{y==null||y()},[y]),Te=i.useCallback(()=>{const t=ct.formatAmount({decimals:s==null?void 0:s.decimals,input:(s==null?void 0:s.balance)??"0",addCommas:!1,digits:4});m.setFieldValue("firstAmount",t),u(t)},[s==null?void 0:s.balance,s==null?void 0:s.decimals,u]),et=i.useCallback(async t=>{u(""),g(""),ie(),ie(),d==null||d(t)},[u,g,d]),tt=i.useCallback(async({transactions:t})=>{Z(()=>t.length);try{if(!L)throw new Error("signMvxTransactions function is not provided");await L(t),ee(t)}catch(x){console.error(x),ue.toast.dismiss(),ue.toast.error("Transaction cancelled"),q==null||q("Transaction cancelled"),Z(0),st(),u(""),g("")}},[Je,u,g,N,et,L]),{formik:m,firstAmountError:P,secondAmountError:Q,fromChainError:X,senderAddressError:$,receiverAddressError:z,confirmRateError:K,handleBlur:D,handleChange:ae,handleSubmit:it,resetSwapForm:st}=I.useBridgeFormik({isMvxConnected:!!a,rate:o,sender:a??"",receiver:c??"",firstToken:s,firstAmount:l,fromChainId:A,toChainId:w,secondToken:r,secondAmount:M,setForceRefetchRate:Ee,senderChainType:qt.ChainType.mvx,receiverChainType:n==null?void 0:n.chainType,onSubmit:tt}),rt=!!(P||Q||X||b||$||z||K),nt=i.useMemo(()=>l!==""?b??P:void 0,[P,l,b]),ot=i.useMemo(()=>M!==""?X??Q:void 0,[X,Q,M]);return i.useEffect(()=>(l||E(""),W(l),O&&clearInterval(O),O=setInterval(()=>{W(l)},50*1e3),()=>clearInterval(O)),[l,Me,W]),i.useEffect(()=>{o!=null&&o.amountOut&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,o.amountOut),E(o.amountOut))},[o==null?void 0:o.amountOut]),i.useEffect(()=>{b&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,"0"),E("0"))},[b]),i.useEffect(()=>{B&&(m.setFieldValue(I.BridgeFormikValuesEnum.firstAmount,B),u(B))},[]),i.useEffect(()=>{_&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,_),g(_))},[_]),i.useEffect(()=>{if(U)try{const t=U;ne({transactions:T.map(x=>({...x,txHash:t,receiver:c})),provider:(o==null?void 0:o.provider)??ht.ProviderType.None,url:mt.getApiURL()??"",token:N??""}),d==null||d([t])}catch(t){console.error("Error while sending transactions:",t),q==null||q("An error occurred while sending the transaction");return}finally{S==null||S(),ee([])}},[U,T,c,N,o==null?void 0:o.provider,ne]),e.jsx(e.Fragment,{children:e.jsxs("form",{ref:ye,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:it,children:[be&&e.jsx(At.BridgeHistory,{mvxAddress:a,onClose:Ze}),e.jsxs(he.AmountCard,{className:qe.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":R,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!R}),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[e.jsx("span",{children:"From"}),e.jsx(Mt.MvxAccountDisplay,{accountAddress:a,chainIcon:Y.safeImageUrl(h==null?void 0:h.pngUrl),username:xe,accountExplorerUrl:`${se.mvxExplorerAddress}/accounts/${a}`,showTag:!0,onDisconnect:Ie,onConnect:J})]}),$&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:$}),e.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[e.jsx(pe.AmountInput,{inputName:"firstAmount",inputValue:m.values.firstAmount,amountError:nt,disabled:!1,onInputDebounceChange:u,onInputChange:ae,onBlur:D}),e.jsx(ge.TokenSelector,{name:"firstToken",disabled:C,options:He,areOptionsLoading:G,isMvxSelector:Ke,isDestination:!1,color:"neutral-850",onChange:Pe,onBlur:D,onMaxBtnClick:Te,selectedOption:s,onTokenSelectorDisplay:t=>Ne(t)})]})]}),e.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:De&&e.jsx(Et.ToggleDirection,{onChangeDirection:$e})}),e.jsxs(he.AmountCard,{className:qe.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":R}),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[e.jsx("span",{children:"To"}),e.jsx(Nt.BridgeAccountDisplay,{disabled:C,activeChain:n})]}),z&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:z}),K&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:K}),e.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[e.jsx(pe.AmountInput,{inputName:"secondAmount",inputValue:m.values.secondAmount,amountError:ot,disabled:!1,onInputDebounceChange:g,onInputChange:ae,onBlur:D}),e.jsx(ge.TokenSelector,{name:"secondToken",disabled:C,omitDisableClass:!0,options:We,areOptionsLoading:G,isMvxSelector:Ye,color:"neutral-850",onChange:Qe,onBlur:D,selectedOption:r})]})]}),e.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!a&&e.jsx(yt.MvxConnectButton,{mvxAccountAddress:a,icon:Y.safeImageUrl(h==null?void 0:h.pngUrl),onClick:J}),a&&!oe&&e.jsx(Bt.BridgeConnectButton,{className:"liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",disabled:C,activeChain:n}),a&&oe&&e.jsxs(It.MxButton,{"data-testid":"submit-button",type:"submit",variant:"neutral-850",className:"liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",disabled:!H||C||!a||!c||rt,children:[H&&e.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[e.jsx("div",{children:"Transfer to "}),e.jsx("img",{src:Y.safeImageUrl(n==null?void 0:n.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("div",{children:n==null?void 0:n.networkName})]}),!H&&e.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"})]})]}),c&&V>0&&e.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:e.jsxs("div",{children:["You will be asked to sign ",V," ",V>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Transfer=wt;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ct=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),lt=require("@reown/appkit/react"),ut=require("lodash/debounce"),i=require("react"),de=require("react-toastify"),dt=require("./hooks/useBridgeTokenSelection.js"),me=require("../../../constants/index.js"),mt=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const Y=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const qt=require("../../../types/chainType.js"),ht=require("../../../types/providerType.js"),qe=require("../../context/useWeb3App.js"),O=require("../../helpers/resolveBridgeApiChainId.js");require("yup");require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");require("bignumber.js");const pt=require("../../hooks/useAccount.js");require("axios");const B=require("../../hooks/useBridgeFormik.js"),gt=require("../../hooks/useFetchBridgeData.js"),xt=require("../../hooks/useBridgeApiChainId.js");require("@tanstack/react-query");const _t=require("../../hooks/useGetChainId.js"),ft=require("../../hooks/useSendTransactions.js");require("@reown/appkit-adapter-solana/react");require("wagmi");require("@reown/appkit-controllers");const jt=require("../../hooks/useDisconnectOnChainTypeChange.js"),bt=require("../../hooks/useNamespaceAddress.js"),Ct=require("../../queries/useGetHistory.query.js"),vt=require("../../queries/useGetRate.mutation.js"),he=require("../../utils/mxClsx.js"),pe=require("../AmountCard/AmountCard.js"),ge=require("../AmountInput/AmountInput.js"),It=require("../base/MxButton/MxButton.js");require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@fortawesome/react-fontawesome");require("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const At=require("../BridgeHistory/BridgeHistory.js"),Bt=require("../Connect/BridgeConnectButton.js"),yt=require("../Connect/MvxConnectButton.js"),Nt=require("../Connect/BridgeAccountDisplay.js"),Mt=require("../Connect/MvxAccountDisplay.js"),Et=require("../ToggleDirection/ToggleDirection.js"),xe=require("../TokenSelector/TokenSelector.js");let R;const wt=({mvxChainId:_,mvxAddress:a,username:_e,callbackRoute:fe="/",firstTokenIdentifier:je,secondTokenIdentifier:be,firstTokenAmount:y,secondTokenAmount:f,refetchTrigger:Ce,showHistory:ve,forcedDestinationTokenSymbol:Ie,onSuccessfullySentTransaction:l,onFailedSentTransaction:m,onHistoryClose:N,onMvxConnect:J,onMvxDisconnect:Ae,onNavigate:Be,onChangeDirection:ye})=>{var le,ue;const Ne=i.useRef(null),[V,Me]=i.useState(!1),[Ee,we]=i.useState(1),[F,Z]=i.useState(0),[T,ee]=i.useState([]),De=pt.useAccount(),{switchNetwork:te}=lt.useAppKitNetwork(),ie=Ct.useInvalidateHistoryQuery(),{options:re,supportedChains:j,nativeAuthToken:b,bridgeOnly:ke}=qe.useWeb3App(),L=_t.useGetChainId(),se=xt.useBridgeApiChainId(),ne=ft.useSendTransactions(),{signMvxTransactions:U,resetMvxTransactionHash:M,latestMvxTransactionHash:S}=qe.useWeb3App(),{evmTokensWithBalances:Oe,mvxTokensWithBalances:Re,isTokensLoading:Ve,isLoadingEvmTokensBalances:Fe,isLoadingMvxTokensBalances:Le,chains:C=[],isChainsLoading:Ue}=gt.useFetchBridgeData({refetchTrigger:Ce,mvxAddress:a,mvxApiURL:re.mvxApiURL}),G=Ve||Fe||Le||Ue,Se=i.useMemo(()=>j.find(t=>O.sameBridgeApiChainId(t.id,L)),[L,j]),h=i.useMemo(()=>C.find(t=>t.chainId.toString()===_.toString()),[L,C]),{mutate:oe,data:o,isPending:v,error:p}=vt.useGetRateMutation(),I=((le=p==null?void 0:p.response)==null?void 0:le.status)===400?(ue=p==null?void 0:p.response)==null?void 0:ue.data.message:void 0,Ge=i.useCallback(t=>{const x=j.find(at=>O.sameBridgeApiChainId(at.id,t.id));x&&te(x)},[j,te]),{firstToken:r,secondToken:s,fromOptions:He,toOptions:We,selectedChainOption:A,onChangeFirstSelect:Pe,onChangeSecondSelect:Qe,handleChangeDirection:Xe}=dt.useBridgeTokenSelection({chains:C,activeChain:Se,sdkChains:j,switchNetwork:Ge,fromTokens:Re,toTokens:Oe,firstTokenIdentifier:je,secondTokenIdentifier:be,forcedDestinationTokenSymbol:Ie,isTokensLoading:G,mvxChainId:_,callbackRoute:fe,onNavigate:Be}),$e=()=>{Xe(),ye()},[u,ze]=i.useState(y??""),[E,w]=i.useState(f??""),Ke=i.useMemo(()=>r?me.MVX_CHAIN_IDS.includes(r.chainId.toString()):!1,[r==null?void 0:r.chainId]),Ye=i.useMemo(()=>s?me.MVX_CHAIN_IDS.includes(s.chainId.toString()):!1,[s==null?void 0:s.chainId]),n=i.useMemo(()=>s?C.find(t=>O.sameBridgeApiChainId(t.chainId,s.chainId))??A:A,[s==null?void 0:s.chainId,C,A]),D=i.useMemo(()=>O.toBridgeApiChainId(s==null?void 0:s.chainId)??se,[s==null?void 0:s.chainId,se]);jt.useDisconnectOnChainTypeChange(n==null?void 0:n.chainType);const c=bt.useNamespaceAddress(n==null?void 0:n.chainType),Je=c,ae=De.isConnected&&!!c,H=u!==""&&E!=="",W=i.useCallback(ut(async t=>{!t||!Number(t)||!c||!(r!=null&&r.address)||!(s!=null&&s.address)||!A||!D||oe({nativeAuthToken:b??"",body:{tokenIn:r.address,amountIn:t,fromChainId:_,tokenOut:s.address,toChainId:D}})},500),[c,D,r==null?void 0:r.address,s==null?void 0:s.address,A,_,b,oe]),d=i.useCallback(t=>{ze(()=>t)},[]),g=i.useCallback(t=>{w(()=>t)},[]),Ze=i.useCallback(()=>{N==null||N()},[N]),Te=i.useCallback(()=>{const t=ct.formatAmount({decimals:r==null?void 0:r.decimals,input:(r==null?void 0:r.balance)??"0",addCommas:!1,digits:4});q.setFieldValue("firstAmount",t),d(t)},[r==null?void 0:r.balance,r==null?void 0:r.decimals,d]),et=i.useCallback(async t=>{d(""),g(""),ie(),ie(),l==null||l(t)},[d,g,l]),tt=i.useCallback(async({transactions:t})=>{Z(()=>t.length);try{if(!U)throw new Error("signMvxTransactions function is not provided");await U(t),ee(t)}catch(x){console.error(x),de.toast.dismiss(),de.toast.error("Transaction cancelled"),m==null||m("Transaction cancelled"),Z(0),rt(),d(""),g("")}},[Je,d,g,b,et,U]),{formik:q,firstAmountError:P,secondAmountError:Q,fromChainError:X,senderAddressError:$,receiverAddressError:z,confirmRateError:K,handleBlur:k,handleChange:ce,handleSubmit:it,resetSwapForm:rt}=B.useBridgeFormik({isMvxConnected:!!a,rate:o,sender:a??"",receiver:c??"",firstToken:r,firstAmount:u,fromChainId:_,toChainId:D,secondToken:s,secondAmount:E,setForceRefetchRate:we,senderChainType:qt.ChainType.mvx,receiverChainType:n==null?void 0:n.chainType,onSubmit:tt}),st=!!(P||Q||X||I||$||z||K),nt=i.useMemo(()=>u!==""?I??P:void 0,[P,u,I]),ot=i.useMemo(()=>E!==""?X??Q:void 0,[X,Q,E]);return i.useEffect(()=>(u||w(""),W(u),R&&clearInterval(R),R=setInterval(()=>{W(u)},50*1e3),()=>clearInterval(R)),[u,Ee,W]),i.useEffect(()=>{o!=null&&o.amountOut&&(q.setFieldValue(B.BridgeFormikValuesEnum.secondAmount,o.amountOut),w(o.amountOut))},[o==null?void 0:o.amountOut]),i.useEffect(()=>{I&&(q.setFieldValue(B.BridgeFormikValuesEnum.secondAmount,"0"),w("0"))},[I]),i.useEffect(()=>{y&&(q.setFieldValue(B.BridgeFormikValuesEnum.firstAmount,y),d(y))},[]),i.useEffect(()=>{f&&(q.setFieldValue(B.BridgeFormikValuesEnum.secondAmount,f),g(f))},[f]),i.useEffect(()=>{if(S)try{const t=S;ne({transactions:T.map(x=>({...x,txHash:t,receiver:c})),provider:(o==null?void 0:o.provider)??ht.ProviderType.None,url:mt.getApiURL()??"",token:b??""}),l==null||l([t])}catch(t){console.error("Error while sending transactions:",t),m==null||m("An error occurred while sending the transaction");return}finally{M==null||M(),ee([])}},[S,T,c,b,m,l,o==null?void 0:o.provider,M,ne]),e.jsx(e.Fragment,{children:e.jsxs("form",{ref:Ne,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:it,children:[ve&&e.jsx(At.BridgeHistory,{mvxAddress:a,onClose:Ze}),e.jsxs(pe.AmountCard,{className:he.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":V,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!V}),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[e.jsx("span",{children:"From"}),e.jsx(Mt.MvxAccountDisplay,{accountAddress:a,chainIcon:Y.safeImageUrl(h==null?void 0:h.pngUrl),username:_e,accountExplorerUrl:`${re.mvxExplorerAddress}/accounts/${a}`,showTag:!0,onDisconnect:Ae,onConnect:J})]}),$&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:$}),e.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[e.jsx(ge.AmountInput,{inputName:"firstAmount",inputValue:q.values.firstAmount,amountError:nt,disabled:!1,onInputDebounceChange:d,onInputChange:ce,onBlur:k}),e.jsx(xe.TokenSelector,{name:"firstToken",disabled:v,options:He,areOptionsLoading:G,isMvxSelector:Ke,isDestination:!1,color:"neutral-850",onChange:Pe,onBlur:k,onMaxBtnClick:Te,selectedOption:r,onTokenSelectorDisplay:t=>Me(t)})]})]}),e.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:ke&&e.jsx(Et.ToggleDirection,{onChangeDirection:$e})}),e.jsxs(pe.AmountCard,{className:he.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":V}),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[e.jsx("span",{children:"To"}),e.jsx(Nt.BridgeAccountDisplay,{disabled:v,activeChain:n})]}),z&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:z}),K&&e.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:K}),e.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[e.jsx(ge.AmountInput,{inputName:"secondAmount",inputValue:q.values.secondAmount,amountError:ot,disabled:!1,onInputDebounceChange:g,onInputChange:ce,onBlur:k}),e.jsx(xe.TokenSelector,{name:"secondToken",disabled:v,omitDisableClass:!0,options:We,areOptionsLoading:G,isMvxSelector:Ye,color:"neutral-850",onChange:Qe,onBlur:k,selectedOption:s})]})]}),e.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!a&&e.jsx(yt.MvxConnectButton,{mvxAccountAddress:a,icon:Y.safeImageUrl(h==null?void 0:h.pngUrl),onClick:J}),a&&!ae&&e.jsx(Bt.BridgeConnectButton,{className:"liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",disabled:v,activeChain:n}),a&&ae&&e.jsxs(It.MxButton,{"data-testid":"submit-button",type:"submit",variant:"neutral-850",className:"liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",disabled:!H||v||!a||!c||st,children:[H&&e.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[e.jsx("div",{children:"Transfer to "}),e.jsx("img",{src:Y.safeImageUrl(n==null?void 0:n.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("div",{children:n==null?void 0:n.networkName})]}),!H&&e.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"})]})]}),c&&F>0&&e.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:e.jsxs("div",{children:["You will be asked to sign ",F," ",F>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Transfer=wt;
|
|
@@ -2,10 +2,10 @@ import { jsx as r, Fragment as pi, jsxs as l } from "react/jsx-runtime";
|
|
|
2
2
|
import { formatAmount as ui } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
3
3
|
import { useAppKitNetwork as hi } from "@reown/appkit/react";
|
|
4
4
|
import fi from "lodash/debounce";
|
|
5
|
-
import { useRef as gi, useState as C, useMemo as
|
|
6
|
-
import { toast as
|
|
5
|
+
import { useRef as gi, useState as C, useMemo as p, useCallback as u, useEffect as I } from "react";
|
|
6
|
+
import { toast as fe } from "react-toastify";
|
|
7
7
|
import { useBridgeTokenSelection as qi } from "./hooks/useBridgeTokenSelection.mjs";
|
|
8
|
-
import { MVX_CHAIN_IDS as
|
|
8
|
+
import { MVX_CHAIN_IDS as ge } from "../../../constants/index.mjs";
|
|
9
9
|
import { getApiURL as vi } from "../../../helpers/getApiURL.mjs";
|
|
10
10
|
import "../../constants/index.mjs";
|
|
11
11
|
import { safeImageUrl as T } from "../../../helpers/safeImageUrl.mjs";
|
|
@@ -14,14 +14,14 @@ import "bitcoinjs-lib";
|
|
|
14
14
|
import "viem";
|
|
15
15
|
import { ChainType as bi } from "../../../types/chainType.mjs";
|
|
16
16
|
import { ProviderType as Ci } from "../../../types/providerType.mjs";
|
|
17
|
-
import { useWeb3App as
|
|
17
|
+
import { useWeb3App as qe } from "../../context/useWeb3App.mjs";
|
|
18
18
|
import { sameBridgeApiChainId as ee, toBridgeApiChainId as Ii } from "../../helpers/resolveBridgeApiChainId.mjs";
|
|
19
19
|
import "yup";
|
|
20
20
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
21
21
|
import "bignumber.js";
|
|
22
22
|
import { useAccount as xi } from "../../hooks/useAccount.mjs";
|
|
23
23
|
import "axios";
|
|
24
|
-
import { useBridgeFormik as Ai, BridgeFormikValuesEnum as
|
|
24
|
+
import { useBridgeFormik as Ai, BridgeFormikValuesEnum as j } from "../../hooks/useBridgeFormik.mjs";
|
|
25
25
|
import { useFetchBridgeData as Ni } from "../../hooks/useFetchBridgeData.mjs";
|
|
26
26
|
import { useBridgeApiChainId as Bi } from "../../hooks/useBridgeApiChainId.mjs";
|
|
27
27
|
import "@tanstack/react-query";
|
|
@@ -34,9 +34,9 @@ import { useDisconnectOnChainTypeChange as Di } from "../../hooks/useDisconnectO
|
|
|
34
34
|
import { useNamespaceAddress as Ei } from "../../hooks/useNamespaceAddress.mjs";
|
|
35
35
|
import { useInvalidateHistoryQuery as Oi } from "../../queries/useGetHistory.query.mjs";
|
|
36
36
|
import { useGetRateMutation as Mi } from "../../queries/useGetRate.mutation.mjs";
|
|
37
|
-
import { mxClsx as
|
|
38
|
-
import { AmountCard as
|
|
39
|
-
import { AmountInput as
|
|
37
|
+
import { mxClsx as ve } from "../../utils/mxClsx.mjs";
|
|
38
|
+
import { AmountCard as be } from "../AmountCard/AmountCard.mjs";
|
|
39
|
+
import { AmountInput as Ce } from "../AmountInput/AmountInput.mjs";
|
|
40
40
|
import { MxButton as Ri } from "../base/MxButton/MxButton.mjs";
|
|
41
41
|
import "../base/MxCard/MxCard.mjs";
|
|
42
42
|
import "../base/MxLink/MxLink.mjs";
|
|
@@ -53,169 +53,172 @@ import { MvxConnectButton as Fi } from "../Connect/MvxConnectButton.mjs";
|
|
|
53
53
|
import { BridgeAccountDisplay as Ui } from "../Connect/BridgeAccountDisplay.mjs";
|
|
54
54
|
import { MvxAccountDisplay as ji } from "../Connect/MvxAccountDisplay.mjs";
|
|
55
55
|
import { ToggleDirection as Pi } from "../ToggleDirection/ToggleDirection.mjs";
|
|
56
|
-
import { TokenSelector as
|
|
57
|
-
let
|
|
56
|
+
import { TokenSelector as Ie } from "../TokenSelector/TokenSelector.mjs";
|
|
57
|
+
let P;
|
|
58
58
|
const Qt = ({
|
|
59
|
-
mvxChainId:
|
|
59
|
+
mvxChainId: x,
|
|
60
60
|
mvxAddress: a,
|
|
61
|
-
username:
|
|
62
|
-
callbackRoute:
|
|
63
|
-
firstTokenIdentifier:
|
|
64
|
-
secondTokenIdentifier:
|
|
65
|
-
firstTokenAmount:
|
|
66
|
-
secondTokenAmount:
|
|
67
|
-
refetchTrigger:
|
|
68
|
-
showHistory:
|
|
69
|
-
forcedDestinationTokenSymbol:
|
|
70
|
-
onSuccessfullySentTransaction:
|
|
71
|
-
onFailedSentTransaction:
|
|
72
|
-
onHistoryClose:
|
|
61
|
+
username: xe,
|
|
62
|
+
callbackRoute: Ae = "/",
|
|
63
|
+
firstTokenIdentifier: Ne,
|
|
64
|
+
secondTokenIdentifier: Be,
|
|
65
|
+
firstTokenAmount: O,
|
|
66
|
+
secondTokenAmount: A,
|
|
67
|
+
refetchTrigger: we,
|
|
68
|
+
showHistory: ye,
|
|
69
|
+
forcedDestinationTokenSymbol: De,
|
|
70
|
+
onSuccessfullySentTransaction: m,
|
|
71
|
+
onFailedSentTransaction: h,
|
|
72
|
+
onHistoryClose: M,
|
|
73
73
|
onMvxConnect: ie,
|
|
74
|
-
onMvxDisconnect:
|
|
75
|
-
onNavigate:
|
|
76
|
-
onChangeDirection:
|
|
74
|
+
onMvxDisconnect: Ee,
|
|
75
|
+
onNavigate: Oe,
|
|
76
|
+
onChangeDirection: Me
|
|
77
77
|
}) => {
|
|
78
|
-
var
|
|
79
|
-
const
|
|
78
|
+
var ue, he;
|
|
79
|
+
const Re = gi(null), [W, Ve] = C(!1), [Le, Fe] = C(1), [G, te] = C(0), [re, oe] = C([]), Ue = xi(), { switchNetwork: ne } = hi(), ae = Oi(), {
|
|
80
80
|
options: le,
|
|
81
|
-
supportedChains:
|
|
82
|
-
nativeAuthToken:
|
|
83
|
-
bridgeOnly:
|
|
84
|
-
} =
|
|
85
|
-
signMvxTransactions:
|
|
86
|
-
resetMvxTransactionHash:
|
|
81
|
+
supportedChains: N,
|
|
82
|
+
nativeAuthToken: B,
|
|
83
|
+
bridgeOnly: je
|
|
84
|
+
} = qe(), Q = wi(), se = Bi(), me = yi(), {
|
|
85
|
+
signMvxTransactions: _,
|
|
86
|
+
resetMvxTransactionHash: R,
|
|
87
87
|
latestMvxTransactionHash: $
|
|
88
|
-
} =
|
|
89
|
-
evmTokensWithBalances:
|
|
90
|
-
mvxTokensWithBalances:
|
|
91
|
-
isTokensLoading:
|
|
92
|
-
isLoadingEvmTokensBalances:
|
|
93
|
-
isLoadingMvxTokensBalances:
|
|
94
|
-
chains:
|
|
95
|
-
isChainsLoading:
|
|
88
|
+
} = qe(), {
|
|
89
|
+
evmTokensWithBalances: Pe,
|
|
90
|
+
mvxTokensWithBalances: We,
|
|
91
|
+
isTokensLoading: Ge,
|
|
92
|
+
isLoadingEvmTokensBalances: Qe,
|
|
93
|
+
isLoadingMvxTokensBalances: _e,
|
|
94
|
+
chains: w = [],
|
|
95
|
+
isChainsLoading: $e
|
|
96
96
|
} = Ni({
|
|
97
|
-
refetchTrigger:
|
|
97
|
+
refetchTrigger: we,
|
|
98
98
|
mvxAddress: a,
|
|
99
99
|
mvxApiURL: le.mvxApiURL
|
|
100
|
-
}), z =
|
|
101
|
-
(e) => e.chainId.toString() ===
|
|
102
|
-
), [
|
|
103
|
-
mutate:
|
|
100
|
+
}), z = Ge || Qe || _e || $e, ze = p(() => N.find((e) => ee(e.id, Q)), [Q, N]), g = p(() => w.find(
|
|
101
|
+
(e) => e.chainId.toString() === x.toString()
|
|
102
|
+
), [Q, w]), {
|
|
103
|
+
mutate: ce,
|
|
104
104
|
data: n,
|
|
105
|
-
isPending:
|
|
105
|
+
isPending: y,
|
|
106
106
|
error: q
|
|
107
|
-
} = Mi(),
|
|
107
|
+
} = Mi(), D = ((ue = q == null ? void 0 : q.response) == null ? void 0 : ue.status) === 400 ? (he = q == null ? void 0 : q.response) == null ? void 0 : he.data.message : void 0, He = u(
|
|
108
108
|
(e) => {
|
|
109
|
-
const b =
|
|
109
|
+
const b = N.find(
|
|
110
110
|
(di) => ee(di.id, e.id)
|
|
111
111
|
);
|
|
112
112
|
b && ne(b);
|
|
113
113
|
},
|
|
114
|
-
[
|
|
114
|
+
[N, ne]
|
|
115
115
|
), {
|
|
116
116
|
firstToken: i,
|
|
117
117
|
secondToken: t,
|
|
118
118
|
fromOptions: Ke,
|
|
119
119
|
toOptions: Xe,
|
|
120
|
-
selectedChainOption:
|
|
120
|
+
selectedChainOption: E,
|
|
121
121
|
onChangeFirstSelect: Ye,
|
|
122
122
|
onChangeSecondSelect: Je,
|
|
123
123
|
handleChangeDirection: Ze
|
|
124
124
|
} = qi({
|
|
125
|
-
chains:
|
|
126
|
-
activeChain:
|
|
127
|
-
sdkChains:
|
|
125
|
+
chains: w,
|
|
126
|
+
activeChain: ze,
|
|
127
|
+
sdkChains: N,
|
|
128
128
|
switchNetwork: He,
|
|
129
|
-
fromTokens:
|
|
130
|
-
toTokens:
|
|
131
|
-
firstTokenIdentifier:
|
|
132
|
-
secondTokenIdentifier:
|
|
133
|
-
forcedDestinationTokenSymbol:
|
|
129
|
+
fromTokens: We,
|
|
130
|
+
toTokens: Pe,
|
|
131
|
+
firstTokenIdentifier: Ne,
|
|
132
|
+
secondTokenIdentifier: Be,
|
|
133
|
+
forcedDestinationTokenSymbol: De,
|
|
134
134
|
isTokensLoading: z,
|
|
135
|
-
mvxChainId:
|
|
136
|
-
callbackRoute:
|
|
137
|
-
onNavigate:
|
|
138
|
-
}),
|
|
139
|
-
Ze(),
|
|
140
|
-
}, [c,
|
|
135
|
+
mvxChainId: x,
|
|
136
|
+
callbackRoute: Ae,
|
|
137
|
+
onNavigate: Oe
|
|
138
|
+
}), ke = () => {
|
|
139
|
+
Ze(), Me();
|
|
140
|
+
}, [c, Se] = C(O ?? ""), [V, L] = C(A ?? ""), Te = p(() => i ? ge.includes(i.chainId.toString()) : !1, [i == null ? void 0 : i.chainId]), ei = p(() => t ? ge.includes(t.chainId.toString()) : !1, [t == null ? void 0 : t.chainId]), o = p(() => t ? w.find(
|
|
141
141
|
(e) => ee(e.chainId, t.chainId)
|
|
142
|
-
) ??
|
|
142
|
+
) ?? E : E, [t == null ? void 0 : t.chainId, w, E]), F = p(
|
|
143
143
|
() => Ii(t == null ? void 0 : t.chainId) ?? se,
|
|
144
144
|
[t == null ? void 0 : t.chainId, se]
|
|
145
145
|
);
|
|
146
146
|
Di(o == null ? void 0 : o.chainType);
|
|
147
|
-
const s = Ei(o == null ? void 0 : o.chainType), ii = s,
|
|
147
|
+
const s = Ei(o == null ? void 0 : o.chainType), ii = s, de = Ue.isConnected && !!s, H = c !== "" && V !== "", K = u(
|
|
148
148
|
fi(async (e) => {
|
|
149
|
-
!e || !Number(e) || !s || !(i != null && i.address) || !(t != null && t.address) || !
|
|
150
|
-
nativeAuthToken:
|
|
149
|
+
!e || !Number(e) || !s || !(i != null && i.address) || !(t != null && t.address) || !E || !F || ce({
|
|
150
|
+
nativeAuthToken: B ?? "",
|
|
151
151
|
body: {
|
|
152
152
|
tokenIn: i.address,
|
|
153
153
|
amountIn: e,
|
|
154
|
-
fromChainId:
|
|
154
|
+
fromChainId: x,
|
|
155
155
|
tokenOut: t.address,
|
|
156
|
-
toChainId:
|
|
156
|
+
toChainId: F
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
}, 500),
|
|
160
160
|
[
|
|
161
161
|
s,
|
|
162
|
-
|
|
162
|
+
F,
|
|
163
163
|
i == null ? void 0 : i.address,
|
|
164
164
|
t == null ? void 0 : t.address,
|
|
165
|
-
|
|
165
|
+
E,
|
|
166
|
+
x,
|
|
167
|
+
B,
|
|
168
|
+
ce
|
|
166
169
|
]
|
|
167
|
-
),
|
|
168
|
-
|
|
169
|
-
}, []), v =
|
|
170
|
-
|
|
171
|
-
}, []), ti =
|
|
172
|
-
|
|
173
|
-
}, [
|
|
170
|
+
), d = u((e) => {
|
|
171
|
+
Se(() => e);
|
|
172
|
+
}, []), v = u((e) => {
|
|
173
|
+
L(() => e);
|
|
174
|
+
}, []), ti = u(() => {
|
|
175
|
+
M == null || M();
|
|
176
|
+
}, [M]), ri = u(() => {
|
|
174
177
|
const e = ui({
|
|
175
178
|
decimals: i == null ? void 0 : i.decimals,
|
|
176
179
|
input: (i == null ? void 0 : i.balance) ?? "0",
|
|
177
180
|
addCommas: !1,
|
|
178
181
|
digits: 4
|
|
179
182
|
});
|
|
180
|
-
|
|
181
|
-
}, [i == null ? void 0 : i.balance, i == null ? void 0 : i.decimals,
|
|
183
|
+
f.setFieldValue("firstAmount", e), d(e);
|
|
184
|
+
}, [i == null ? void 0 : i.balance, i == null ? void 0 : i.decimals, d]), oi = u(
|
|
182
185
|
async (e) => {
|
|
183
|
-
|
|
186
|
+
d(""), v(""), ae(), ae(), m == null || m(e);
|
|
184
187
|
},
|
|
185
188
|
[
|
|
186
|
-
|
|
189
|
+
d,
|
|
187
190
|
v,
|
|
188
|
-
|
|
191
|
+
m
|
|
189
192
|
]
|
|
190
|
-
), ni =
|
|
193
|
+
), ni = u(
|
|
191
194
|
async ({ transactions: e }) => {
|
|
192
195
|
te(() => e.length);
|
|
193
196
|
try {
|
|
194
|
-
if (!
|
|
197
|
+
if (!_)
|
|
195
198
|
throw new Error("signMvxTransactions function is not provided");
|
|
196
|
-
await
|
|
199
|
+
await _(e), oe(e);
|
|
197
200
|
} catch (b) {
|
|
198
|
-
console.error(b),
|
|
201
|
+
console.error(b), fe.dismiss(), fe.error("Transaction cancelled"), h == null || h("Transaction cancelled"), te(0), li(), d(""), v("");
|
|
199
202
|
}
|
|
200
203
|
},
|
|
201
204
|
[
|
|
202
205
|
ii,
|
|
203
|
-
|
|
206
|
+
d,
|
|
204
207
|
v,
|
|
205
|
-
|
|
208
|
+
B,
|
|
206
209
|
oi,
|
|
207
|
-
|
|
210
|
+
_
|
|
208
211
|
]
|
|
209
212
|
), {
|
|
210
|
-
formik:
|
|
213
|
+
formik: f,
|
|
211
214
|
firstAmountError: X,
|
|
212
215
|
secondAmountError: Y,
|
|
213
216
|
fromChainError: J,
|
|
214
217
|
senderAddressError: Z,
|
|
215
|
-
receiverAddressError:
|
|
216
|
-
confirmRateError:
|
|
217
|
-
handleBlur:
|
|
218
|
-
handleChange:
|
|
218
|
+
receiverAddressError: k,
|
|
219
|
+
confirmRateError: S,
|
|
220
|
+
handleBlur: U,
|
|
221
|
+
handleChange: pe,
|
|
219
222
|
handleSubmit: ai,
|
|
220
223
|
resetSwapForm: li
|
|
221
224
|
} = Ai({
|
|
@@ -225,36 +228,36 @@ const Qt = ({
|
|
|
225
228
|
receiver: s ?? "",
|
|
226
229
|
firstToken: i,
|
|
227
230
|
firstAmount: c,
|
|
228
|
-
fromChainId:
|
|
229
|
-
toChainId:
|
|
231
|
+
fromChainId: x,
|
|
232
|
+
toChainId: F,
|
|
230
233
|
secondToken: t,
|
|
231
|
-
secondAmount:
|
|
232
|
-
setForceRefetchRate:
|
|
234
|
+
secondAmount: V,
|
|
235
|
+
setForceRefetchRate: Fe,
|
|
233
236
|
senderChainType: bi.mvx,
|
|
234
237
|
receiverChainType: o == null ? void 0 : o.chainType,
|
|
235
238
|
onSubmit: ni
|
|
236
|
-
}), si = !!(X || Y || J ||
|
|
237
|
-
return I(() => (c ||
|
|
239
|
+
}), si = !!(X || Y || J || D || Z || k || S), mi = p(() => c !== "" ? D ?? X : void 0, [X, c, D]), ci = p(() => V !== "" ? J ?? Y : void 0, [J, Y, V]);
|
|
240
|
+
return I(() => (c || L(""), K(c), P && clearInterval(P), P = setInterval(() => {
|
|
238
241
|
K(c);
|
|
239
|
-
}, 50 * 1e3), () => clearInterval(
|
|
240
|
-
n != null && n.amountOut && (
|
|
242
|
+
}, 50 * 1e3), () => clearInterval(P)), [c, Le, K]), I(() => {
|
|
243
|
+
n != null && n.amountOut && (f.setFieldValue(j.secondAmount, n.amountOut), L(n.amountOut));
|
|
241
244
|
}, [n == null ? void 0 : n.amountOut]), I(() => {
|
|
242
|
-
|
|
243
|
-
}, [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
),
|
|
245
|
+
D && (f.setFieldValue(j.secondAmount, "0"), L("0"));
|
|
246
|
+
}, [D]), I(() => {
|
|
247
|
+
O && (f.setFieldValue(
|
|
248
|
+
j.firstAmount,
|
|
249
|
+
O
|
|
250
|
+
), d(O));
|
|
248
251
|
}, []), I(() => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
), v(
|
|
253
|
-
}, [
|
|
252
|
+
A && (f.setFieldValue(
|
|
253
|
+
j.secondAmount,
|
|
254
|
+
A
|
|
255
|
+
), v(A));
|
|
256
|
+
}, [A]), I(() => {
|
|
254
257
|
if ($)
|
|
255
258
|
try {
|
|
256
259
|
const e = $;
|
|
257
|
-
|
|
260
|
+
me({
|
|
258
261
|
transactions: re.map((b) => ({
|
|
259
262
|
...b,
|
|
260
263
|
txHash: e,
|
|
@@ -262,41 +265,44 @@ const Qt = ({
|
|
|
262
265
|
})),
|
|
263
266
|
provider: (n == null ? void 0 : n.provider) ?? Ci.None,
|
|
264
267
|
url: vi() ?? "",
|
|
265
|
-
token:
|
|
266
|
-
}),
|
|
268
|
+
token: B ?? ""
|
|
269
|
+
}), m == null || m([e]);
|
|
267
270
|
} catch (e) {
|
|
268
|
-
console.error("Error while sending transactions:", e),
|
|
271
|
+
console.error("Error while sending transactions:", e), h == null || h(
|
|
269
272
|
"An error occurred while sending the transaction"
|
|
270
273
|
);
|
|
271
274
|
return;
|
|
272
275
|
} finally {
|
|
273
|
-
|
|
276
|
+
R == null || R(), oe([]);
|
|
274
277
|
}
|
|
275
278
|
}, [
|
|
276
279
|
$,
|
|
277
280
|
re,
|
|
278
281
|
s,
|
|
279
|
-
|
|
282
|
+
B,
|
|
283
|
+
h,
|
|
284
|
+
m,
|
|
280
285
|
n == null ? void 0 : n.provider,
|
|
281
|
-
|
|
286
|
+
R,
|
|
287
|
+
me
|
|
282
288
|
]), /* @__PURE__ */ r(pi, { children: /* @__PURE__ */ l(
|
|
283
289
|
"form",
|
|
284
290
|
{
|
|
285
|
-
ref:
|
|
291
|
+
ref: Re,
|
|
286
292
|
noValidate: !0,
|
|
287
293
|
className: "liq-flex liq-flex-col liq-gap-1 liq-relative",
|
|
288
294
|
autoComplete: "off",
|
|
289
295
|
onSubmit: ai,
|
|
290
296
|
children: [
|
|
291
|
-
|
|
297
|
+
ye && /* @__PURE__ */ r(Vi, { mvxAddress: a, onClose: ti }),
|
|
292
298
|
/* @__PURE__ */ l(
|
|
293
|
-
|
|
299
|
+
be,
|
|
294
300
|
{
|
|
295
|
-
className:
|
|
301
|
+
className: ve(
|
|
296
302
|
"liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
|
|
297
303
|
{
|
|
298
|
-
"liq-pointer-events-none":
|
|
299
|
-
"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80": !
|
|
304
|
+
"liq-pointer-events-none": W,
|
|
305
|
+
"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80": !W
|
|
300
306
|
}
|
|
301
307
|
),
|
|
302
308
|
children: [
|
|
@@ -307,10 +313,10 @@ const Qt = ({
|
|
|
307
313
|
{
|
|
308
314
|
accountAddress: a,
|
|
309
315
|
chainIcon: T(g == null ? void 0 : g.pngUrl),
|
|
310
|
-
username:
|
|
316
|
+
username: xe,
|
|
311
317
|
accountExplorerUrl: `${le.mvxExplorerAddress}/accounts/${a}`,
|
|
312
318
|
showTag: !0,
|
|
313
|
-
onDisconnect:
|
|
319
|
+
onDisconnect: Ee,
|
|
314
320
|
onConnect: ie
|
|
315
321
|
}
|
|
316
322
|
)
|
|
@@ -318,46 +324,46 @@ const Qt = ({
|
|
|
318
324
|
Z && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: Z }),
|
|
319
325
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
320
326
|
/* @__PURE__ */ r(
|
|
321
|
-
|
|
327
|
+
Ce,
|
|
322
328
|
{
|
|
323
329
|
inputName: "firstAmount",
|
|
324
|
-
inputValue:
|
|
325
|
-
amountError:
|
|
330
|
+
inputValue: f.values.firstAmount,
|
|
331
|
+
amountError: mi,
|
|
326
332
|
disabled: !1,
|
|
327
|
-
onInputDebounceChange:
|
|
328
|
-
onInputChange:
|
|
329
|
-
onBlur:
|
|
333
|
+
onInputDebounceChange: d,
|
|
334
|
+
onInputChange: pe,
|
|
335
|
+
onBlur: U
|
|
330
336
|
}
|
|
331
337
|
),
|
|
332
338
|
/* @__PURE__ */ r(
|
|
333
|
-
|
|
339
|
+
Ie,
|
|
334
340
|
{
|
|
335
341
|
name: "firstToken",
|
|
336
|
-
disabled:
|
|
342
|
+
disabled: y,
|
|
337
343
|
options: Ke,
|
|
338
344
|
areOptionsLoading: z,
|
|
339
345
|
isMvxSelector: Te,
|
|
340
346
|
isDestination: !1,
|
|
341
347
|
color: "neutral-850",
|
|
342
348
|
onChange: Ye,
|
|
343
|
-
onBlur:
|
|
349
|
+
onBlur: U,
|
|
344
350
|
onMaxBtnClick: ri,
|
|
345
351
|
selectedOption: i,
|
|
346
|
-
onTokenSelectorDisplay: (e) =>
|
|
352
|
+
onTokenSelectorDisplay: (e) => Ve(e)
|
|
347
353
|
}
|
|
348
354
|
)
|
|
349
355
|
] })
|
|
350
356
|
]
|
|
351
357
|
}
|
|
352
358
|
),
|
|
353
|
-
/* @__PURE__ */ r("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children:
|
|
359
|
+
/* @__PURE__ */ r("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: je && /* @__PURE__ */ r(Pi, { onChangeDirection: ke }) }),
|
|
354
360
|
/* @__PURE__ */ l(
|
|
355
|
-
|
|
361
|
+
be,
|
|
356
362
|
{
|
|
357
|
-
className:
|
|
363
|
+
className: ve(
|
|
358
364
|
"liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
|
|
359
365
|
{
|
|
360
|
-
"liq-pointer-events-none":
|
|
366
|
+
"liq-pointer-events-none": W
|
|
361
367
|
}
|
|
362
368
|
),
|
|
363
369
|
children: [
|
|
@@ -366,38 +372,38 @@ const Qt = ({
|
|
|
366
372
|
/* @__PURE__ */ r(
|
|
367
373
|
Ui,
|
|
368
374
|
{
|
|
369
|
-
disabled:
|
|
375
|
+
disabled: y,
|
|
370
376
|
activeChain: o
|
|
371
377
|
}
|
|
372
378
|
)
|
|
373
379
|
] }),
|
|
374
|
-
S && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: S }),
|
|
375
380
|
k && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: k }),
|
|
381
|
+
S && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: S }),
|
|
376
382
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
377
383
|
/* @__PURE__ */ r(
|
|
378
|
-
|
|
384
|
+
Ce,
|
|
379
385
|
{
|
|
380
386
|
inputName: "secondAmount",
|
|
381
|
-
inputValue:
|
|
382
|
-
amountError:
|
|
387
|
+
inputValue: f.values.secondAmount,
|
|
388
|
+
amountError: ci,
|
|
383
389
|
disabled: !1,
|
|
384
390
|
onInputDebounceChange: v,
|
|
385
|
-
onInputChange:
|
|
386
|
-
onBlur:
|
|
391
|
+
onInputChange: pe,
|
|
392
|
+
onBlur: U
|
|
387
393
|
}
|
|
388
394
|
),
|
|
389
395
|
/* @__PURE__ */ r(
|
|
390
|
-
|
|
396
|
+
Ie,
|
|
391
397
|
{
|
|
392
398
|
name: "secondToken",
|
|
393
|
-
disabled:
|
|
399
|
+
disabled: y,
|
|
394
400
|
omitDisableClass: !0,
|
|
395
401
|
options: Xe,
|
|
396
402
|
areOptionsLoading: z,
|
|
397
403
|
isMvxSelector: ei,
|
|
398
404
|
color: "neutral-850",
|
|
399
405
|
onChange: Je,
|
|
400
|
-
onBlur:
|
|
406
|
+
onBlur: U,
|
|
401
407
|
selectedOption: t
|
|
402
408
|
}
|
|
403
409
|
)
|
|
@@ -414,22 +420,22 @@ const Qt = ({
|
|
|
414
420
|
onClick: ie
|
|
415
421
|
}
|
|
416
422
|
),
|
|
417
|
-
a && !
|
|
423
|
+
a && !de && /* @__PURE__ */ r(
|
|
418
424
|
Li,
|
|
419
425
|
{
|
|
420
426
|
className: "liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",
|
|
421
|
-
disabled:
|
|
427
|
+
disabled: y,
|
|
422
428
|
activeChain: o
|
|
423
429
|
}
|
|
424
430
|
),
|
|
425
|
-
a &&
|
|
431
|
+
a && de && /* @__PURE__ */ l(
|
|
426
432
|
Ri,
|
|
427
433
|
{
|
|
428
434
|
"data-testid": "submit-button",
|
|
429
435
|
type: "submit",
|
|
430
436
|
variant: "neutral-850",
|
|
431
437
|
className: "liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",
|
|
432
|
-
disabled: !H ||
|
|
438
|
+
disabled: !H || y || !a || !s || si,
|
|
433
439
|
children: [
|
|
434
440
|
H && /* @__PURE__ */ l("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
435
441
|
/* @__PURE__ */ r("div", { children: "Transfer to " }),
|
|
@@ -448,11 +454,11 @@ const Qt = ({
|
|
|
448
454
|
}
|
|
449
455
|
)
|
|
450
456
|
] }),
|
|
451
|
-
s &&
|
|
457
|
+
s && G > 0 && /* @__PURE__ */ r("div", { className: "liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm", children: /* @__PURE__ */ l("div", { children: [
|
|
452
458
|
"You will be asked to sign ",
|
|
453
|
-
|
|
459
|
+
G,
|
|
454
460
|
" ",
|
|
455
|
-
|
|
461
|
+
G > 1 ? "transactions" : "transaction",
|
|
456
462
|
" ",
|
|
457
463
|
"on your wallet"
|
|
458
464
|
] }) })
|