@multiversx/sdk-dapp-liquidity 2.3.0-alpha.1 → 2.3.0-alpha.2
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 +85 -82
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +62 -59
- package/reactjs/components/Connect/BridgeAccountDisplay.js +1 -1
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +45 -44
- package/reactjs/hooks/useDisconnectOnChainTypeChange.d.ts +12 -0
- package/reactjs/hooks/useDisconnectOnChainTypeChange.js +2 -0
- package/reactjs/hooks/useDisconnectOnChainTypeChange.mjs +13 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "MultiversX",
|
|
4
4
|
"description": "A complete toolkit for bridging assets between MultiversX, Ethereum, BNB Chain and Sui",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.3.0-alpha.
|
|
6
|
+
"version": "2.3.0-alpha.2",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/multiversx/mx-sdk-dapp-liquidity.git"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Bs=require("@fortawesome/free-solid-svg-icons/faSpinner"),ys=require("@fortawesome/react-fontawesome"),As=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),ks=require("@reown/appkit/react"),Ns=require("@wagmi/core"),Ss=require("lodash/debounce"),t=require("react"),k=require("react-toastify"),ws=require("./hooks/useBridgeTokenSelection.js"),Ms=require("./utils/bridgeFormHelpers.js"),Me=require("../../../constants/index.js"),Ds=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const L=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const N=require("../../../types/chainType.js"),Es=require("../../context/useWeb3App.js"),T=require("../../helpers/resolveBridgeApiChainId.js"),Rs=require("../../hooks/useAccount.js"),Fs=require("../../hooks/useBridgeApiChainId.js"),S=require("../../hooks/useBridgeFormik.js"),Vs=require("../../hooks/useFetchBridgeData.js"),Ps=require("../../hooks/useGetChainId.js"),Us=require("../../hooks/useNamespaceAddress.js"),Hs=require("../../hooks/useSendTransactions.js"),Ls=require("../../hooks/useSignTransaction.js"),Ts=require("../../queries/useGetHistory.query.js"),Os=require("../../queries/useGetRate.mutation.js"),De=require("../../utils/mxClsx.js"),Ee=require("../AmountCard/AmountCard.js"),Re=require("../AmountInput/AmountInput.js"),Gs=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("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const Ws=require("../BridgeHistory/BridgeHistory.js"),Xs=require("../Connect/BridgeConnectButton.js");require("wagmi");const zs=require("../Connect/MvxConnectButton.js"),Qs=require("../Connect/BridgeAccountDisplay.js"),$s=require("../Connect/MvxAccountDisplay.js");require("@reown/appkit-controllers");const Ks=require("../ToggleDirection/ToggleDirection.js"),Fe=require("../TokenSelector/TokenSelector.js");let O;const Ys=({mvxChainId:G,mvxAddress:l,username:Ve,callbackRoute:Pe="/",firstTokenIdentifier:Ue,secondTokenIdentifier:He,firstTokenAmount:w,secondTokenAmount:j,refetchTrigger:Le,showHistory:Te,forcedDestinationTokenSymbol:Oe,onSuccessfullySentTransaction:M,onFailedSentTransaction:f,onHistoryClose:D,onMvxConnect:oe,onMvxDisconnect:Ge,onNavigate:We,onChangeDirection:Xe})=>{var Ce,Be;const ze=t.useRef(null),ce=t.useRef(void 0),[W,Qe]=t.useState(!1),[E,I]=t.useState(!1),[$e,Ke]=t.useState(1),[X,z]=t.useState(0),Ye=Rs.useAccount(),{switchNetwork:le}=ks.useAppKitNetwork(),ue=Ts.useInvalidateHistoryQuery(),{config:de,options:me,supportedChains:v,nativeAuthToken:Q,bridgeOnly:Je}=Es.useWeb3App(),$=Ps.useGetChainId(),he=Fs.useBridgeApiChainId(),{evmTokensWithBalances:Ze,mvxTokensWithBalances:es,isTokensLoading:ss,isLoadingEvmTokensBalances:ts,isLoadingMvxTokensBalances:ns,chains:C=[],isChainsLoading:is}=Vs.useFetchBridgeData({refetchTrigger:Le,mvxAddress:l,mvxApiURL:me.mvxApiURL}),K=ss||ts||ns||is,rs=t.useMemo(()=>v.find(n=>T.sameBridgeApiChainId(n.id,$)),[$,v]),o=t.useMemo(()=>C.find(n=>n.chainId.toString()===G.toString()),[$,C]),{evm:qe,solana:ge,bitcoin:pe,sui:xe}=Ls.useSignTransaction(),fe=Hs.useSendTransactions(),{mutate:as,data:d,isPending:B,error:b}=Os.useGetRateMutation(),y=((Ce=b==null?void 0:b.response)==null?void 0:Ce.status)===400?(Be=b==null?void 0:b.response)==null?void 0:Be.data.message:void 0,os=t.useCallback(n=>{const x=v.find(u=>T.sameBridgeApiChainId(u.id,n.id));x&&le(x)},[v,le]),{firstToken:e,secondToken:a,fromOptions:R,toOptions:cs,selectedChainOption:r,onChangeFirstSelect:be,onChangeSecondSelect:ls,handleChangeDirection:us}=ws.useBridgeTokenSelection({chains:C,activeChain:rs,sdkChains:v,switchNetwork:os,fromTokens:Ze,toTokens:es,firstTokenIdentifier:Ue,secondTokenIdentifier:He,forcedDestinationTokenSymbol:Oe,isTokensLoading:K,callbackRoute:Pe,onNavigate:We}),ds=t.useMemo(()=>e?Me.MVX_CHAIN_IDS.includes(e.chainId.toString()):!1,[e==null?void 0:e.chainId]),ms=t.useMemo(()=>a?Me.MVX_CHAIN_IDS.includes(a.chainId.toString()):!1,[a==null?void 0:a.chainId]),[m,hs]=t.useState(w??""),[F,V]=t.useState(j??""),c=t.useMemo(()=>e?C.find(n=>T.sameBridgeApiChainId(n.chainId,e.chainId))??r:r,[e==null?void 0:e.chainId,C,r]),P=t.useMemo(()=>T.toBridgeApiChainId(e==null?void 0:e.chainId)??he,[e==null?void 0:e.chainId,he]),g=Us.useNamespaceAddress(c==null?void 0:c.chainType),_e=g,je=Ye.isConnected&&!!g,Y=m!==""&&F!=="",J=t.useCallback(Ss(async n=>{!n||!Number(n)||!g||!(e!=null&&e.address)||!(a!=null&&a.address)||!r||!P||as({nativeAuthToken:Q??"",body:{tokenIn:e.address,amountIn:n,fromChainId:P,tokenOut:a.address,toChainId:G}})},500),[g,P,e==null?void 0:e.address,a==null?void 0:a.address,r]),h=t.useCallback(n=>{hs(()=>n)},[]),_=t.useCallback(n=>{V(()=>n)},[]),qs=t.useCallback(()=>{D==null||D()},[D]),gs=t.useCallback(()=>{const n=As.formatAmount({decimals:e==null?void 0:e.decimals,input:(e==null?void 0:e.balance)??"0",addCommas:!1,digits:4});p.setFieldValue("firstAmount",n),h(n)},[e==null?void 0:e.balance,e==null?void 0:e.decimals,h]),Ie=t.useCallback(async n=>{h(""),_(""),ue(),ue(),M==null||M(n)},[h,_,M]),ps=()=>{us(),Xe()};t.useEffect(()=>{const n=ce.current;if(ce.current=r==null?void 0:r.chainId,!!n&&(r==null?void 0:r.chainId)!==(e==null?void 0:e.chainId)){const x=R==null?void 0:R.find(u=>u.chainId.toString()===(r==null?void 0:r.chainId));if(!x)return;be(x)}},[r==null?void 0:r.chainId]);const xs=t.useCallback(async({transactions:n,provider:x})=>{var ye,Ae,ke;const u=[];I(!0),z(()=>n.length);try{let A=-1;for(const i of n){++A;try{switch(Ms.resolveSigningChainType(i,c)){case N.ChainType.evm:{const q=await qe.signTransaction({...i,value:BigInt(i.value),gas:BigInt(i.gasLimit),account:_e});if(!q||(u.push({...i,txHash:q}),A===n.length-1||!q))break;const H=await Ns.waitForTransactionReceipt(de,{confirmations:1,hash:q});console.info({transactionReceipt:H,hash:q});break}case N.ChainType.sol:if(!i.instructions||!i.feePayer)break;const ae=await ge.signTransaction({feePayer:i.feePayer,instructions:i.instructions,recentBlockhash:i.recentBlockhash});if(!ae)break;u.push({...i,txHash:ae});break;case N.ChainType.btc:if(!i.bitcoinParams){console.error("No bitcoin params");break}const Cs=await pe.signTransaction(i.bitcoinParams);u.push({...i,txHash:Cs});break;case N.ChainType.sui:{const q=(ye=i.suiParams)==null?void 0:ye.transactionBytes,H=(Ae=i.suiParams)==null?void 0:Ae.sender;if(!q||!H){console.error("No Sui transaction bytes or sender address");break}const we=await xe.signTransaction({transaction:q,address:H});if(!we)break;u.push({...i,suiParams:{...i.suiParams,signature:we}});break}default:k.toast.error("Provider not supported"),I(!1);return}z(()=>n.length-1-A)}catch{k.toast.dismiss(),k.toast.error("Transaction aborted"),f==null||f("Transaction aborted"),I(!1);return}}const{data:re}=await fe({transactions:u,provider:x,url:Ds.getApiURL()??"",token:Q??""}),Ne=((ke=re.transactions)==null?void 0:ke.map(i=>i.txHash).filter(i=>!!i))??[],Se=u.map(i=>i.txHash).filter(i=>!!i),vs=Ne.length>0?Ne:Se.length>0?Se:re.batchId?[re.batchId]:[];Ie(vs),I(!1)}catch(A){console.error(A),k.toast.dismiss(),k.toast.error("Transaction cancelled"),f==null||f("Transaction cancelled"),I(!1),z(0),bs(),h(""),_("")}},[c==null?void 0:c.chainType,_e,de,h,_,Q,Ie,fe,pe.signTransaction,qe.signTransaction,ge.signTransaction,xe.signTransaction]),{formik:p,firstAmountError:Z,secondAmountError:ee,fromChainError:se,senderAddressError:te,receiverAddressError:ne,confirmRateError:ie,handleBlur:U,handleChange:ve,handleSubmit:fs,resetSwapForm:bs}=S.useBridgeFormik({isMvxConnected:!!l,rate:d,sender:g??"",receiver:l??"",firstToken:e,firstAmount:m,fromChainId:P,toChainId:G,secondToken:a,secondAmount:F,setForceRefetchRate:Ke,senderChainType:c==null?void 0:c.chainType,receiverChainType:N.ChainType.mvx,onSubmit:xs}),_s=!!(Z||ee||se||y||te||ne||ie),js=t.useMemo(()=>m!==""?y??Z:void 0,[Z,m,y]),Is=t.useMemo(()=>F!==""?se??ee:void 0,[se,ee,F]);return t.useEffect(()=>(m||V(""),J(m),O&&clearInterval(O),O=setInterval(()=>{J(m)},50*1e3),()=>clearInterval(O)),[m,$e,J]),t.useEffect(()=>{d!=null&&d.amountOut&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,d.amountOut),V(d.amountOut))},[d==null?void 0:d.amountOut]),t.useEffect(()=>{y&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,"0"),V("0"))},[y]),t.useEffect(()=>{w&&(p.setFieldValue(S.BridgeFormikValuesEnum.firstAmount,w),h(w))},[]),t.useEffect(()=>{j&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,j),_(j))},[j]),s.jsx(s.Fragment,{children:s.jsxs("form",{ref:ze,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:fs,children:[Te&&s.jsx(Ws.BridgeHistory,{mvxAddress:l,onClose:qs}),s.jsxs(Ee.AmountCard,{className:De.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"From"}),s.jsx(Qs.BridgeAccountDisplay,{disabled:B,activeChain:c})]}),te&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:te}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Re.AmountInput,{inputName:"firstAmount",inputValue:p.values.firstAmount,amountError:js,disabled:!1,onInputDebounceChange:h,onInputChange:ve,onBlur:U}),s.jsx(Fe.TokenSelector,{name:"firstToken",disabled:B,options:R,areOptionsLoading:K,isMvxSelector:ds,isDestination:!1,color:"neutral-850",onChange:be,onBlur:U,onMaxBtnClick:gs,selectedOption:e,onTokenSelectorDisplay:n=>Qe(n)})]})]}),s.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:Je&&s.jsx(Ks.ToggleDirection,{onChangeDirection:ps})}),s.jsxs(Ee.AmountCard,{className:De.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"To"}),s.jsx($s.MvxAccountDisplay,{accountAddress:l,chainIcon:L.safeImageUrl(o==null?void 0:o.pngUrl),username:Ve,accountExplorerUrl:`${me.mvxExplorerAddress}/accounts/${l}`,showTag:!0,onDisconnect:Ge,onConnect:oe})]}),ne&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ne}),ie&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ie}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Re.AmountInput,{inputName:"secondAmount",inputValue:p.values.secondAmount,amountError:Is,disabled:!1,onInputDebounceChange:_,onInputChange:ve,onBlur:U}),s.jsx(Fe.TokenSelector,{name:"secondToken",disabled:B,omitDisableClass:!0,options:cs,areOptionsLoading:K,isMvxSelector:ms,color:"neutral-850",onChange:ls,onBlur:U,selectedOption:a})]})]}),s.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!l&&s.jsx(zs.MvxConnectButton,{mvxAccountAddress:l,icon:L.safeImageUrl(o==null?void 0:o.pngUrl),onClick:oe}),l&&!je&&s.jsx(Xs.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:B,activeChain:c}),l&&je&&s.jsxs(Gs.MxButton,{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:!Y||B||!l||!g||_s||E,children:[Y&&!E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx("div",{children:"Deposit on "}),s.jsx("img",{src:L.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]}),!Y&&!E&&s.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"}),E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx(ys.FontAwesomeIcon,{icon:Bs.faSpinner,spin:!0,className:"liq-mx-1 liq-flex liq-items-center"}),s.jsx("div",{children:"Depositing on"}),s.jsx("img",{src:L.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]})]})]}),g&&X>0&&s.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:s.jsxs("div",{children:["You will be asked to sign ",X," ",X>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Deposit=Ys;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Bs=require("@fortawesome/free-solid-svg-icons/faSpinner"),ys=require("@fortawesome/react-fontawesome"),As=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),ks=require("@reown/appkit/react"),Ns=require("@wagmi/core"),Ss=require("lodash/debounce"),t=require("react"),k=require("react-toastify"),ws=require("./hooks/useBridgeTokenSelection.js"),Ds=require("./utils/bridgeFormHelpers.js"),De=require("../../../constants/index.js"),Ms=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const H=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const N=require("../../../types/chainType.js"),Es=require("../../context/useWeb3App.js"),L=require("../../helpers/resolveBridgeApiChainId.js"),Rs=require("../../hooks/useAccount.js"),Fs=require("../../hooks/useBridgeApiChainId.js"),S=require("../../hooks/useBridgeFormik.js"),Vs=require("../../hooks/useDisconnectOnChainTypeChange.js"),Ps=require("../../hooks/useFetchBridgeData.js"),Ts=require("../../hooks/useGetChainId.js"),Us=require("../../hooks/useNamespaceAddress.js"),Hs=require("../../hooks/useSendTransactions.js"),Ls=require("../../hooks/useSignTransaction.js"),Os=require("../../queries/useGetHistory.query.js"),Gs=require("../../queries/useGetRate.mutation.js"),Me=require("../../utils/mxClsx.js"),Ee=require("../AmountCard/AmountCard.js"),Re=require("../AmountInput/AmountInput.js"),Ws=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("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const Xs=require("../BridgeHistory/BridgeHistory.js"),zs=require("../Connect/BridgeConnectButton.js");require("wagmi");const Qs=require("../Connect/MvxConnectButton.js"),$s=require("../Connect/BridgeAccountDisplay.js"),Ks=require("../Connect/MvxAccountDisplay.js");require("@reown/appkit-controllers");const Ys=require("../ToggleDirection/ToggleDirection.js"),Fe=require("../TokenSelector/TokenSelector.js");let O;const Js=({mvxChainId:G,mvxAddress:l,username:Ve,callbackRoute:Pe="/",firstTokenIdentifier:Te,secondTokenIdentifier:Ue,firstTokenAmount:w,secondTokenAmount:j,refetchTrigger:He,showHistory:Le,forcedDestinationTokenSymbol:Oe,onSuccessfullySentTransaction:D,onFailedSentTransaction:b,onHistoryClose:M,onMvxConnect:oe,onMvxDisconnect:Ge,onNavigate:We,onChangeDirection:Xe})=>{var ve,Be;const ze=t.useRef(null),ce=t.useRef(void 0),[W,Qe]=t.useState(!1),[E,I]=t.useState(!1),[$e,Ke]=t.useState(1),[X,z]=t.useState(0),Ye=Rs.useAccount(),{switchNetwork:le}=ks.useAppKitNetwork(),ue=Os.useInvalidateHistoryQuery(),{config:de,options:me,supportedChains:C,nativeAuthToken:Q,bridgeOnly:Je}=Es.useWeb3App(),$=Ts.useGetChainId(),he=Fs.useBridgeApiChainId(),{evmTokensWithBalances:Ze,mvxTokensWithBalances:es,isTokensLoading:ss,isLoadingEvmTokensBalances:ts,isLoadingMvxTokensBalances:ns,chains:v=[],isChainsLoading:is}=Ps.useFetchBridgeData({refetchTrigger:He,mvxAddress:l,mvxApiURL:me.mvxApiURL}),K=ss||ts||ns||is,rs=t.useMemo(()=>C.find(n=>L.sameBridgeApiChainId(n.id,$)),[$,C]),c=t.useMemo(()=>v.find(n=>n.chainId.toString()===G.toString()),[$,v]),{evm:ge,solana:qe,bitcoin:pe,sui:xe}=Ls.useSignTransaction(),be=Hs.useSendTransactions(),{mutate:as,data:d,isPending:B,error:f}=Gs.useGetRateMutation(),y=((ve=f==null?void 0:f.response)==null?void 0:ve.status)===400?(Be=f==null?void 0:f.response)==null?void 0:Be.data.message:void 0,os=t.useCallback(n=>{const x=C.find(u=>L.sameBridgeApiChainId(u.id,n.id));x&&le(x)},[C,le]),{firstToken:e,secondToken:o,fromOptions:R,toOptions:cs,selectedChainOption:r,onChangeFirstSelect:fe,onChangeSecondSelect:ls,handleChangeDirection:us}=ws.useBridgeTokenSelection({chains:v,activeChain:rs,sdkChains:C,switchNetwork:os,fromTokens:Ze,toTokens:es,firstTokenIdentifier:Te,secondTokenIdentifier:Ue,forcedDestinationTokenSymbol:Oe,isTokensLoading:K,callbackRoute:Pe,onNavigate:We}),ds=t.useMemo(()=>e?De.MVX_CHAIN_IDS.includes(e.chainId.toString()):!1,[e==null?void 0:e.chainId]),ms=t.useMemo(()=>o?De.MVX_CHAIN_IDS.includes(o.chainId.toString()):!1,[o==null?void 0:o.chainId]),[m,hs]=t.useState(w??""),[F,V]=t.useState(j??""),a=t.useMemo(()=>e?v.find(n=>L.sameBridgeApiChainId(n.chainId,e.chainId))??r:r,[e==null?void 0:e.chainId,v,r]),P=t.useMemo(()=>L.toBridgeApiChainId(e==null?void 0:e.chainId)??he,[e==null?void 0:e.chainId,he]);Vs.useDisconnectOnChainTypeChange(a==null?void 0:a.chainType);const q=Us.useNamespaceAddress(a==null?void 0:a.chainType),_e=q,je=Ye.isConnected&&!!q,Y=m!==""&&F!=="",J=t.useCallback(Ss(async n=>{!n||!Number(n)||!q||!(e!=null&&e.address)||!(o!=null&&o.address)||!r||!P||as({nativeAuthToken:Q??"",body:{tokenIn:e.address,amountIn:n,fromChainId:P,tokenOut:o.address,toChainId:G}})},500),[q,P,e==null?void 0:e.address,o==null?void 0:o.address,r]),h=t.useCallback(n=>{hs(()=>n)},[]),_=t.useCallback(n=>{V(()=>n)},[]),gs=t.useCallback(()=>{M==null||M()},[M]),qs=t.useCallback(()=>{const n=As.formatAmount({decimals:e==null?void 0:e.decimals,input:(e==null?void 0:e.balance)??"0",addCommas:!1,digits:4});p.setFieldValue("firstAmount",n),h(n)},[e==null?void 0:e.balance,e==null?void 0:e.decimals,h]),Ie=t.useCallback(async n=>{h(""),_(""),ue(),ue(),D==null||D(n)},[h,_,D]),ps=()=>{us(),Xe()};t.useEffect(()=>{const n=ce.current;if(ce.current=r==null?void 0:r.chainId,!!n&&(r==null?void 0:r.chainId)!==(e==null?void 0:e.chainId)){const x=R==null?void 0:R.find(u=>u.chainId.toString()===(r==null?void 0:r.chainId));if(!x)return;fe(x)}},[r==null?void 0:r.chainId]);const xs=t.useCallback(async({transactions:n,provider:x})=>{var ye,Ae,ke;const u=[];I(!0),z(()=>n.length);try{let A=-1;for(const i of n){++A;try{switch(Ds.resolveSigningChainType(i,a)){case N.ChainType.evm:{const g=await ge.signTransaction({...i,value:BigInt(i.value),gas:BigInt(i.gasLimit),account:_e});if(!g||(u.push({...i,txHash:g}),A===n.length-1||!g))break;const U=await Ns.waitForTransactionReceipt(de,{confirmations:1,hash:g});console.info({transactionReceipt:U,hash:g});break}case N.ChainType.sol:if(!i.instructions||!i.feePayer)break;const ae=await qe.signTransaction({feePayer:i.feePayer,instructions:i.instructions,recentBlockhash:i.recentBlockhash});if(!ae)break;u.push({...i,txHash:ae});break;case N.ChainType.btc:if(!i.bitcoinParams){console.error("No bitcoin params");break}const vs=await pe.signTransaction(i.bitcoinParams);u.push({...i,txHash:vs});break;case N.ChainType.sui:{const g=(ye=i.suiParams)==null?void 0:ye.transactionBytes,U=(Ae=i.suiParams)==null?void 0:Ae.sender;if(!g||!U){console.error("No Sui transaction bytes or sender address");break}const we=await xe.signTransaction({transaction:g,address:U});if(!we)break;u.push({...i,suiParams:{...i.suiParams,signature:we}});break}default:k.toast.error("Provider not supported"),I(!1);return}z(()=>n.length-1-A)}catch{k.toast.dismiss(),k.toast.error("Transaction aborted"),b==null||b("Transaction aborted"),I(!1);return}}const{data:re}=await be({transactions:u,provider:x,url:Ms.getApiURL()??"",token:Q??""}),Ne=((ke=re.transactions)==null?void 0:ke.map(i=>i.txHash).filter(i=>!!i))??[],Se=u.map(i=>i.txHash).filter(i=>!!i),Cs=Ne.length>0?Ne:Se.length>0?Se:re.batchId?[re.batchId]:[];Ie(Cs),I(!1)}catch(A){console.error(A),k.toast.dismiss(),k.toast.error("Transaction cancelled"),b==null||b("Transaction cancelled"),I(!1),z(0),fs(),h(""),_("")}},[a==null?void 0:a.chainType,_e,de,h,_,Q,Ie,be,pe.signTransaction,ge.signTransaction,qe.signTransaction,xe.signTransaction]),{formik:p,firstAmountError:Z,secondAmountError:ee,fromChainError:se,senderAddressError:te,receiverAddressError:ne,confirmRateError:ie,handleBlur:T,handleChange:Ce,handleSubmit:bs,resetSwapForm:fs}=S.useBridgeFormik({isMvxConnected:!!l,rate:d,sender:q??"",receiver:l??"",firstToken:e,firstAmount:m,fromChainId:P,toChainId:G,secondToken:o,secondAmount:F,setForceRefetchRate:Ke,senderChainType:a==null?void 0:a.chainType,receiverChainType:N.ChainType.mvx,onSubmit:xs}),_s=!!(Z||ee||se||y||te||ne||ie),js=t.useMemo(()=>m!==""?y??Z:void 0,[Z,m,y]),Is=t.useMemo(()=>F!==""?se??ee:void 0,[se,ee,F]);return t.useEffect(()=>(m||V(""),J(m),O&&clearInterval(O),O=setInterval(()=>{J(m)},50*1e3),()=>clearInterval(O)),[m,$e,J]),t.useEffect(()=>{d!=null&&d.amountOut&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,d.amountOut),V(d.amountOut))},[d==null?void 0:d.amountOut]),t.useEffect(()=>{y&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,"0"),V("0"))},[y]),t.useEffect(()=>{w&&(p.setFieldValue(S.BridgeFormikValuesEnum.firstAmount,w),h(w))},[]),t.useEffect(()=>{j&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,j),_(j))},[j]),s.jsx(s.Fragment,{children:s.jsxs("form",{ref:ze,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:bs,children:[Le&&s.jsx(Xs.BridgeHistory,{mvxAddress:l,onClose:gs}),s.jsxs(Ee.AmountCard,{className:Me.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"From"}),s.jsx($s.BridgeAccountDisplay,{disabled:B,activeChain:a})]}),te&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:te}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Re.AmountInput,{inputName:"firstAmount",inputValue:p.values.firstAmount,amountError:js,disabled:!1,onInputDebounceChange:h,onInputChange:Ce,onBlur:T}),s.jsx(Fe.TokenSelector,{name:"firstToken",disabled:B,options:R,areOptionsLoading:K,isMvxSelector:ds,isDestination:!1,color:"neutral-850",onChange:fe,onBlur:T,onMaxBtnClick:qs,selectedOption:e,onTokenSelectorDisplay:n=>Qe(n)})]})]}),s.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:Je&&s.jsx(Ys.ToggleDirection,{onChangeDirection:ps})}),s.jsxs(Ee.AmountCard,{className:Me.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"To"}),s.jsx(Ks.MvxAccountDisplay,{accountAddress:l,chainIcon:H.safeImageUrl(c==null?void 0:c.pngUrl),username:Ve,accountExplorerUrl:`${me.mvxExplorerAddress}/accounts/${l}`,showTag:!0,onDisconnect:Ge,onConnect:oe})]}),ne&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ne}),ie&&s.jsx("div",{className:"liq-text-red-400 liq-text-xs liq-mt-1",children:ie}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Re.AmountInput,{inputName:"secondAmount",inputValue:p.values.secondAmount,amountError:Is,disabled:!1,onInputDebounceChange:_,onInputChange:Ce,onBlur:T}),s.jsx(Fe.TokenSelector,{name:"secondToken",disabled:B,omitDisableClass:!0,options:cs,areOptionsLoading:K,isMvxSelector:ms,color:"neutral-850",onChange:ls,onBlur:T,selectedOption:o})]})]}),s.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!l&&s.jsx(Qs.MvxConnectButton,{mvxAccountAddress:l,icon:H.safeImageUrl(c==null?void 0:c.pngUrl),onClick:oe}),l&&!je&&s.jsx(zs.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:B,activeChain:a}),l&&je&&s.jsxs(Ws.MxButton,{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:!Y||B||!l||!q||_s||E,children:[Y&&!E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx("div",{children:"Deposit on "}),s.jsx("img",{src:H.safeImageUrl(c==null?void 0:c.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]}),!Y&&!E&&s.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"}),E&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx(ys.FontAwesomeIcon,{icon:Bs.faSpinner,spin:!0,className:"liq-mx-1 liq-flex liq-items-center"}),s.jsx("div",{children:"Depositing on"}),s.jsx("img",{src:H.safeImageUrl(c==null?void 0:c.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]})]})]}),q&&X>0&&s.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:s.jsxs("div",{children:["You will be asked to sign ",X," ",X>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Deposit=Js;
|
|
@@ -3,13 +3,13 @@ import { faSpinner as Ei } from "@fortawesome/free-solid-svg-icons/faSpinner";
|
|
|
3
3
|
import { FontAwesomeIcon as Mi } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { formatAmount as Pi } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
5
5
|
import { useAppKitNetwork as Vi } from "@reown/appkit/react";
|
|
6
|
-
import { waitForTransactionReceipt as
|
|
7
|
-
import
|
|
8
|
-
import { useRef as
|
|
6
|
+
import { waitForTransactionReceipt as Fi } from "@wagmi/core";
|
|
7
|
+
import Li from "lodash/debounce";
|
|
8
|
+
import { useRef as Le, useState as B, useMemo as g, useCallback as f, useEffect as N } from "react";
|
|
9
9
|
import { toast as M } from "react-toastify";
|
|
10
|
-
import { useBridgeTokenSelection as
|
|
10
|
+
import { useBridgeTokenSelection as ki } from "./hooks/useBridgeTokenSelection.mjs";
|
|
11
11
|
import { resolveSigningChainType as Ui } from "./utils/bridgeFormHelpers.mjs";
|
|
12
|
-
import { MVX_CHAIN_IDS as
|
|
12
|
+
import { MVX_CHAIN_IDS as ke } from "../../../constants/index.mjs";
|
|
13
13
|
import { getApiURL as ji } from "../../../helpers/getApiURL.mjs";
|
|
14
14
|
import "../../constants/index.mjs";
|
|
15
15
|
import { safeImageUrl as z } from "../../../helpers/safeImageUrl.mjs";
|
|
@@ -22,17 +22,18 @@ import { sameBridgeApiChainId as de, toBridgeApiChainId as Oi } from "../../help
|
|
|
22
22
|
import { useAccount as Wi } from "../../hooks/useAccount.mjs";
|
|
23
23
|
import { useBridgeApiChainId as Xi } from "../../hooks/useBridgeApiChainId.mjs";
|
|
24
24
|
import { useBridgeFormik as zi, BridgeFormikValuesEnum as G } from "../../hooks/useBridgeFormik.mjs";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
25
|
+
import { useDisconnectOnChainTypeChange as Gi } from "../../hooks/useDisconnectOnChainTypeChange.mjs";
|
|
26
|
+
import { useFetchBridgeData as Qi } from "../../hooks/useFetchBridgeData.mjs";
|
|
27
|
+
import { useGetChainId as _i } from "../../hooks/useGetChainId.mjs";
|
|
28
|
+
import { useNamespaceAddress as $i } from "../../hooks/useNamespaceAddress.mjs";
|
|
29
|
+
import { useSendTransactions as Ki } from "../../hooks/useSendTransactions.mjs";
|
|
30
|
+
import { useSignTransaction as Yi } from "../../hooks/useSignTransaction.mjs";
|
|
31
|
+
import { useInvalidateHistoryQuery as Ji } from "../../queries/useGetHistory.query.mjs";
|
|
32
|
+
import { useGetRateMutation as Zi } from "../../queries/useGetRate.mutation.mjs";
|
|
32
33
|
import { mxClsx as Ue } from "../../utils/mxClsx.mjs";
|
|
33
34
|
import { AmountCard as je } from "../AmountCard/AmountCard.mjs";
|
|
34
35
|
import { AmountInput as He } from "../AmountInput/AmountInput.mjs";
|
|
35
|
-
import { MxButton as
|
|
36
|
+
import { MxButton as Ti } from "../base/MxButton/MxButton.mjs";
|
|
36
37
|
import "../base/MxCard/MxCard.mjs";
|
|
37
38
|
import "../base/MxLink/MxLink.mjs";
|
|
38
39
|
import "../base/MxSearch/MxSearch.mjs";
|
|
@@ -41,17 +42,17 @@ import "@headlessui/react";
|
|
|
41
42
|
import "react-dom";
|
|
42
43
|
import "react-popper";
|
|
43
44
|
import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
|
|
44
|
-
import { BridgeHistory as
|
|
45
|
-
import { BridgeConnectButton as
|
|
45
|
+
import { BridgeHistory as et } from "../BridgeHistory/BridgeHistory.mjs";
|
|
46
|
+
import { BridgeConnectButton as it } from "../Connect/BridgeConnectButton.mjs";
|
|
46
47
|
import "wagmi";
|
|
47
|
-
import { MvxConnectButton as
|
|
48
|
-
import { BridgeAccountDisplay as
|
|
49
|
-
import { MvxAccountDisplay as
|
|
48
|
+
import { MvxConnectButton as tt } from "../Connect/MvxConnectButton.mjs";
|
|
49
|
+
import { BridgeAccountDisplay as nt } from "../Connect/BridgeAccountDisplay.mjs";
|
|
50
|
+
import { MvxAccountDisplay as rt } from "../Connect/MvxAccountDisplay.mjs";
|
|
50
51
|
import "@reown/appkit-controllers";
|
|
51
|
-
import { ToggleDirection as
|
|
52
|
+
import { ToggleDirection as ot } from "../ToggleDirection/ToggleDirection.mjs";
|
|
52
53
|
import { TokenSelector as Oe } from "../TokenSelector/TokenSelector.mjs";
|
|
53
54
|
let Q;
|
|
54
|
-
const
|
|
55
|
+
const an = ({
|
|
55
56
|
mvxChainId: _,
|
|
56
57
|
mvxAddress: c,
|
|
57
58
|
username: We,
|
|
@@ -63,22 +64,22 @@ const rn = ({
|
|
|
63
64
|
refetchTrigger: Qe,
|
|
64
65
|
showHistory: _e,
|
|
65
66
|
forcedDestinationTokenSymbol: $e,
|
|
66
|
-
onSuccessfullySentTransaction:
|
|
67
|
+
onSuccessfullySentTransaction: F,
|
|
67
68
|
onFailedSentTransaction: I,
|
|
68
|
-
onHistoryClose:
|
|
69
|
+
onHistoryClose: L,
|
|
69
70
|
onMvxConnect: me,
|
|
70
71
|
onMvxDisconnect: Ke,
|
|
71
72
|
onNavigate: Ye,
|
|
72
73
|
onChangeDirection: Je
|
|
73
74
|
}) => {
|
|
74
75
|
var De, Se;
|
|
75
|
-
const Ze =
|
|
76
|
+
const Ze = Le(null), ue = Le(void 0), [$, Te] = B(!1), [k, A] = B(!1), [ei, ii] = B(1), [K, Y] = B(0), ti = Wi(), { switchNetwork: pe } = Vi(), he = Ji(), {
|
|
76
77
|
config: ge,
|
|
77
78
|
options: fe,
|
|
78
79
|
supportedChains: w,
|
|
79
80
|
nativeAuthToken: J,
|
|
80
81
|
bridgeOnly: ni
|
|
81
|
-
} = Hi(), Z =
|
|
82
|
+
} = Hi(), Z = _i(), qe = Xi(), {
|
|
82
83
|
evmTokensWithBalances: ri,
|
|
83
84
|
mvxTokensWithBalances: oi,
|
|
84
85
|
isTokensLoading: ai,
|
|
@@ -86,18 +87,18 @@ const rn = ({
|
|
|
86
87
|
isLoadingMvxTokensBalances: li,
|
|
87
88
|
chains: D = [],
|
|
88
89
|
isChainsLoading: ci
|
|
89
|
-
} =
|
|
90
|
+
} = Qi({
|
|
90
91
|
refetchTrigger: Qe,
|
|
91
92
|
mvxAddress: c,
|
|
92
93
|
mvxApiURL: fe.mvxApiURL
|
|
93
|
-
}), T = ai || si || li || ci, di = g(() => w.find((i) => de(i.id, Z)), [Z, w]),
|
|
94
|
+
}), T = ai || si || li || ci, di = g(() => w.find((i) => de(i.id, Z)), [Z, w]), s = g(() => D.find(
|
|
94
95
|
(i) => i.chainId.toString() === _.toString()
|
|
95
|
-
), [Z, D]), { evm: be, solana: ve, bitcoin: Ie, sui: xe } =
|
|
96
|
+
), [Z, D]), { evm: be, solana: ve, bitcoin: Ie, sui: xe } = Yi(), ye = Ki(), {
|
|
96
97
|
mutate: mi,
|
|
97
98
|
data: m,
|
|
98
99
|
isPending: S,
|
|
99
100
|
error: x
|
|
100
|
-
} =
|
|
101
|
+
} = Zi(), R = ((De = x == null ? void 0 : x.response) == null ? void 0 : De.status) === 400 ? (Se = x == null ? void 0 : x.response) == null ? void 0 : Se.data.message : void 0, ui = f(
|
|
101
102
|
(i) => {
|
|
102
103
|
const v = w.find(
|
|
103
104
|
(d) => de(d.id, i.id)
|
|
@@ -107,14 +108,14 @@ const rn = ({
|
|
|
107
108
|
[w, pe]
|
|
108
109
|
), {
|
|
109
110
|
firstToken: e,
|
|
110
|
-
secondToken:
|
|
111
|
+
secondToken: a,
|
|
111
112
|
fromOptions: U,
|
|
112
113
|
toOptions: pi,
|
|
113
114
|
selectedChainOption: r,
|
|
114
|
-
onChangeFirstSelect:
|
|
115
|
+
onChangeFirstSelect: Be,
|
|
115
116
|
onChangeSecondSelect: hi,
|
|
116
117
|
handleChangeDirection: gi
|
|
117
|
-
} =
|
|
118
|
+
} = ki({
|
|
118
119
|
chains: D,
|
|
119
120
|
activeChain: di,
|
|
120
121
|
sdkChains: w,
|
|
@@ -127,20 +128,22 @@ const rn = ({
|
|
|
127
128
|
isTokensLoading: T,
|
|
128
129
|
callbackRoute: Xe,
|
|
129
130
|
onNavigate: Ye
|
|
130
|
-
}), fi = g(() => e ?
|
|
131
|
+
}), fi = g(() => e ? ke.includes(e.chainId.toString()) : !1, [e == null ? void 0 : e.chainId]), qi = g(() => a ? ke.includes(a.chainId.toString()) : !1, [a == null ? void 0 : a.chainId]), [u, bi] = B(V ?? ""), [j, H] = B(C ?? ""), o = g(() => e ? D.find(
|
|
131
132
|
(i) => de(i.chainId, e.chainId)
|
|
132
133
|
) ?? r : r, [e == null ? void 0 : e.chainId, D, r]), O = g(
|
|
133
134
|
() => Oi(e == null ? void 0 : e.chainId) ?? qe,
|
|
134
135
|
[e == null ? void 0 : e.chainId, qe]
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
);
|
|
137
|
+
Gi(o == null ? void 0 : o.chainType);
|
|
138
|
+
const q = $i(o == null ? void 0 : o.chainType), Ne = q, Ce = ti.isConnected && !!q, ee = u !== "" && j !== "", ie = f(
|
|
139
|
+
Li(async (i) => {
|
|
140
|
+
!i || !Number(i) || !q || !(e != null && e.address) || !(a != null && a.address) || !r || !O || mi({
|
|
138
141
|
nativeAuthToken: J ?? "",
|
|
139
142
|
body: {
|
|
140
143
|
tokenIn: e.address,
|
|
141
144
|
amountIn: i,
|
|
142
145
|
fromChainId: O,
|
|
143
|
-
tokenOut:
|
|
146
|
+
tokenOut: a.address,
|
|
144
147
|
toChainId: _
|
|
145
148
|
}
|
|
146
149
|
});
|
|
@@ -149,16 +152,16 @@ const rn = ({
|
|
|
149
152
|
q,
|
|
150
153
|
O,
|
|
151
154
|
e == null ? void 0 : e.address,
|
|
152
|
-
|
|
155
|
+
a == null ? void 0 : a.address,
|
|
153
156
|
r
|
|
154
157
|
]
|
|
155
158
|
), p = f((i) => {
|
|
156
159
|
bi(() => i);
|
|
157
|
-
}, []),
|
|
160
|
+
}, []), y = f((i) => {
|
|
158
161
|
H(() => i);
|
|
159
162
|
}, []), vi = f(() => {
|
|
160
|
-
|
|
161
|
-
}, [
|
|
163
|
+
L == null || L();
|
|
164
|
+
}, [L]), Ii = f(() => {
|
|
162
165
|
const i = Pi({
|
|
163
166
|
decimals: e == null ? void 0 : e.decimals,
|
|
164
167
|
input: (e == null ? void 0 : e.balance) ?? "0",
|
|
@@ -168,12 +171,12 @@ const rn = ({
|
|
|
168
171
|
b.setFieldValue("firstAmount", i), p(i);
|
|
169
172
|
}, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals, p]), Ae = f(
|
|
170
173
|
async (i) => {
|
|
171
|
-
p(""),
|
|
174
|
+
p(""), y(""), he(), he(), F == null || F(i);
|
|
172
175
|
},
|
|
173
176
|
[
|
|
174
177
|
p,
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
y,
|
|
179
|
+
F
|
|
177
180
|
]
|
|
178
181
|
), xi = () => {
|
|
179
182
|
gi(), Je();
|
|
@@ -186,10 +189,10 @@ const rn = ({
|
|
|
186
189
|
);
|
|
187
190
|
if (!v)
|
|
188
191
|
return;
|
|
189
|
-
|
|
192
|
+
Be(v);
|
|
190
193
|
}
|
|
191
194
|
}, [r == null ? void 0 : r.chainId]);
|
|
192
|
-
const
|
|
195
|
+
const yi = f(
|
|
193
196
|
async ({
|
|
194
197
|
transactions: i,
|
|
195
198
|
provider: v
|
|
@@ -202,7 +205,7 @@ const rn = ({
|
|
|
202
205
|
for (const t of i) {
|
|
203
206
|
++E;
|
|
204
207
|
try {
|
|
205
|
-
switch (Ui(t,
|
|
208
|
+
switch (Ui(t, o)) {
|
|
206
209
|
case P.evm: {
|
|
207
210
|
const h = await be.signTransaction({
|
|
208
211
|
...t,
|
|
@@ -215,7 +218,7 @@ const rn = ({
|
|
|
215
218
|
txHash: h
|
|
216
219
|
}), E === i.length - 1 || !h))
|
|
217
220
|
break;
|
|
218
|
-
const X = await
|
|
221
|
+
const X = await Fi(
|
|
219
222
|
ge,
|
|
220
223
|
{
|
|
221
224
|
confirmations: 1,
|
|
@@ -262,17 +265,17 @@ const rn = ({
|
|
|
262
265
|
console.error("No Sui transaction bytes or sender address");
|
|
263
266
|
break;
|
|
264
267
|
}
|
|
265
|
-
const
|
|
268
|
+
const Fe = await xe.signTransaction({
|
|
266
269
|
transaction: h,
|
|
267
270
|
address: X
|
|
268
271
|
});
|
|
269
|
-
if (!
|
|
272
|
+
if (!Fe)
|
|
270
273
|
break;
|
|
271
274
|
d.push({
|
|
272
275
|
...t,
|
|
273
276
|
suiParams: {
|
|
274
277
|
...t.suiParams,
|
|
275
|
-
signature:
|
|
278
|
+
signature: Fe
|
|
276
279
|
}
|
|
277
280
|
});
|
|
278
281
|
break;
|
|
@@ -289,7 +292,7 @@ const rn = ({
|
|
|
289
292
|
return;
|
|
290
293
|
}
|
|
291
294
|
}
|
|
292
|
-
const { data: le } = await
|
|
295
|
+
const { data: le } = await ye({
|
|
293
296
|
transactions: d,
|
|
294
297
|
provider: v,
|
|
295
298
|
url: ji() ?? "",
|
|
@@ -297,18 +300,18 @@ const rn = ({
|
|
|
297
300
|
}), Pe = ((Me = le.transactions) == null ? void 0 : Me.map((t) => t.txHash).filter((t) => !!t)) ?? [], Ve = d.map((t) => t.txHash).filter((t) => !!t), Di = Pe.length > 0 ? Pe : Ve.length > 0 ? Ve : le.batchId ? [le.batchId] : [];
|
|
298
301
|
Ae(Di), A(!1);
|
|
299
302
|
} catch (E) {
|
|
300
|
-
console.error(E), M.dismiss(), M.error("Transaction cancelled"), I == null || I("Transaction cancelled"), A(!1), Y(0), Ni(), p(""),
|
|
303
|
+
console.error(E), M.dismiss(), M.error("Transaction cancelled"), I == null || I("Transaction cancelled"), A(!1), Y(0), Ni(), p(""), y("");
|
|
301
304
|
}
|
|
302
305
|
},
|
|
303
306
|
[
|
|
304
|
-
|
|
307
|
+
o == null ? void 0 : o.chainType,
|
|
305
308
|
Ne,
|
|
306
309
|
ge,
|
|
307
310
|
p,
|
|
308
|
-
|
|
311
|
+
y,
|
|
309
312
|
J,
|
|
310
313
|
Ae,
|
|
311
|
-
|
|
314
|
+
ye,
|
|
312
315
|
Ie.signTransaction,
|
|
313
316
|
be.signTransaction,
|
|
314
317
|
ve.signTransaction,
|
|
@@ -324,7 +327,7 @@ const rn = ({
|
|
|
324
327
|
confirmRateError: se,
|
|
325
328
|
handleBlur: W,
|
|
326
329
|
handleChange: we,
|
|
327
|
-
handleSubmit:
|
|
330
|
+
handleSubmit: Bi,
|
|
328
331
|
resetSwapForm: Ni
|
|
329
332
|
} = zi({
|
|
330
333
|
isMvxConnected: !!c,
|
|
@@ -335,12 +338,12 @@ const rn = ({
|
|
|
335
338
|
firstAmount: u,
|
|
336
339
|
fromChainId: O,
|
|
337
340
|
toChainId: _,
|
|
338
|
-
secondToken:
|
|
341
|
+
secondToken: a,
|
|
339
342
|
secondAmount: j,
|
|
340
343
|
setForceRefetchRate: ii,
|
|
341
|
-
senderChainType:
|
|
344
|
+
senderChainType: o == null ? void 0 : o.chainType,
|
|
342
345
|
receiverChainType: P.mvx,
|
|
343
|
-
onSubmit:
|
|
346
|
+
onSubmit: yi
|
|
344
347
|
}), Ci = !!(te || ne || re || R || oe || ae || se), Ai = g(() => u !== "" ? R ?? te : void 0, [te, u, R]), wi = g(() => j !== "" ? re ?? ne : void 0, [re, ne, j]);
|
|
345
348
|
return N(() => (u || H(""), ie(u), Q && clearInterval(Q), Q = setInterval(() => {
|
|
346
349
|
ie(u);
|
|
@@ -357,7 +360,7 @@ const rn = ({
|
|
|
357
360
|
C && (b.setFieldValue(
|
|
358
361
|
G.secondAmount,
|
|
359
362
|
C
|
|
360
|
-
),
|
|
363
|
+
), y(C));
|
|
361
364
|
}, [C]), /* @__PURE__ */ n(Ri, { children: /* @__PURE__ */ l(
|
|
362
365
|
"form",
|
|
363
366
|
{
|
|
@@ -365,9 +368,9 @@ const rn = ({
|
|
|
365
368
|
noValidate: !0,
|
|
366
369
|
className: "liq-flex liq-flex-col liq-gap-1 liq-relative",
|
|
367
370
|
autoComplete: "off",
|
|
368
|
-
onSubmit:
|
|
371
|
+
onSubmit: Bi,
|
|
369
372
|
children: [
|
|
370
|
-
_e && /* @__PURE__ */ n(
|
|
373
|
+
_e && /* @__PURE__ */ n(et, { mvxAddress: c, onClose: vi }),
|
|
371
374
|
/* @__PURE__ */ l(
|
|
372
375
|
je,
|
|
373
376
|
{
|
|
@@ -382,10 +385,10 @@ const rn = ({
|
|
|
382
385
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
383
386
|
/* @__PURE__ */ n("span", { children: "From" }),
|
|
384
387
|
/* @__PURE__ */ n(
|
|
385
|
-
|
|
388
|
+
nt,
|
|
386
389
|
{
|
|
387
390
|
disabled: S,
|
|
388
|
-
activeChain:
|
|
391
|
+
activeChain: o
|
|
389
392
|
}
|
|
390
393
|
)
|
|
391
394
|
] }),
|
|
@@ -413,7 +416,7 @@ const rn = ({
|
|
|
413
416
|
isMvxSelector: fi,
|
|
414
417
|
isDestination: !1,
|
|
415
418
|
color: "neutral-850",
|
|
416
|
-
onChange:
|
|
419
|
+
onChange: Be,
|
|
417
420
|
onBlur: W,
|
|
418
421
|
onMaxBtnClick: Ii,
|
|
419
422
|
selectedOption: e,
|
|
@@ -424,7 +427,7 @@ const rn = ({
|
|
|
424
427
|
]
|
|
425
428
|
}
|
|
426
429
|
),
|
|
427
|
-
/* @__PURE__ */ n("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: ni && /* @__PURE__ */ n(
|
|
430
|
+
/* @__PURE__ */ n("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: ni && /* @__PURE__ */ n(ot, { onChangeDirection: xi }) }),
|
|
428
431
|
/* @__PURE__ */ l(
|
|
429
432
|
je,
|
|
430
433
|
{
|
|
@@ -438,10 +441,10 @@ const rn = ({
|
|
|
438
441
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
439
442
|
/* @__PURE__ */ n("span", { children: "To" }),
|
|
440
443
|
/* @__PURE__ */ n(
|
|
441
|
-
|
|
444
|
+
rt,
|
|
442
445
|
{
|
|
443
446
|
accountAddress: c,
|
|
444
|
-
chainIcon: z(
|
|
447
|
+
chainIcon: z(s == null ? void 0 : s.pngUrl),
|
|
445
448
|
username: We,
|
|
446
449
|
accountExplorerUrl: `${fe.mvxExplorerAddress}/accounts/${c}`,
|
|
447
450
|
showTag: !0,
|
|
@@ -460,7 +463,7 @@ const rn = ({
|
|
|
460
463
|
inputValue: b.values.secondAmount,
|
|
461
464
|
amountError: wi,
|
|
462
465
|
disabled: !1,
|
|
463
|
-
onInputDebounceChange:
|
|
466
|
+
onInputDebounceChange: y,
|
|
464
467
|
onInputChange: we,
|
|
465
468
|
onBlur: W
|
|
466
469
|
}
|
|
@@ -477,7 +480,7 @@ const rn = ({
|
|
|
477
480
|
color: "neutral-850",
|
|
478
481
|
onChange: hi,
|
|
479
482
|
onBlur: W,
|
|
480
|
-
selectedOption:
|
|
483
|
+
selectedOption: a
|
|
481
484
|
}
|
|
482
485
|
)
|
|
483
486
|
] })
|
|
@@ -486,43 +489,43 @@ const rn = ({
|
|
|
486
489
|
),
|
|
487
490
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-justify-center", children: [
|
|
488
491
|
!c && /* @__PURE__ */ n(
|
|
489
|
-
|
|
492
|
+
tt,
|
|
490
493
|
{
|
|
491
494
|
mvxAccountAddress: c,
|
|
492
|
-
icon: z(
|
|
495
|
+
icon: z(s == null ? void 0 : s.pngUrl),
|
|
493
496
|
onClick: me
|
|
494
497
|
}
|
|
495
498
|
),
|
|
496
499
|
c && !Ce && /* @__PURE__ */ n(
|
|
497
|
-
|
|
500
|
+
it,
|
|
498
501
|
{
|
|
499
502
|
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",
|
|
500
503
|
disabled: S,
|
|
501
|
-
activeChain:
|
|
504
|
+
activeChain: o
|
|
502
505
|
}
|
|
503
506
|
),
|
|
504
507
|
c && Ce && /* @__PURE__ */ l(
|
|
505
|
-
|
|
508
|
+
Ti,
|
|
506
509
|
{
|
|
507
510
|
type: "submit",
|
|
508
511
|
variant: "neutral-850",
|
|
509
512
|
className: "liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",
|
|
510
|
-
disabled: !ee || S || !c || !q || Ci ||
|
|
513
|
+
disabled: !ee || S || !c || !q || Ci || k,
|
|
511
514
|
children: [
|
|
512
|
-
ee && !
|
|
515
|
+
ee && !k && /* @__PURE__ */ l("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
513
516
|
/* @__PURE__ */ n("div", { children: "Deposit on " }),
|
|
514
517
|
/* @__PURE__ */ n(
|
|
515
518
|
"img",
|
|
516
519
|
{
|
|
517
|
-
src: z(
|
|
520
|
+
src: z(s == null ? void 0 : s.pngUrl),
|
|
518
521
|
alt: "",
|
|
519
522
|
className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
520
523
|
}
|
|
521
524
|
),
|
|
522
525
|
/* @__PURE__ */ n("div", { children: "MultiversX" })
|
|
523
526
|
] }),
|
|
524
|
-
!ee && !
|
|
525
|
-
|
|
527
|
+
!ee && !k && /* @__PURE__ */ n("span", { className: "liq-text-neutral-100", children: "Enter amount" }),
|
|
528
|
+
k && /* @__PURE__ */ l("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
526
529
|
/* @__PURE__ */ n(
|
|
527
530
|
Mi,
|
|
528
531
|
{
|
|
@@ -535,7 +538,7 @@ const rn = ({
|
|
|
535
538
|
/* @__PURE__ */ n(
|
|
536
539
|
"img",
|
|
537
540
|
{
|
|
538
|
-
src: z(
|
|
541
|
+
src: z(s == null ? void 0 : s.pngUrl),
|
|
539
542
|
alt: "",
|
|
540
543
|
className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
541
544
|
}
|
|
@@ -559,5 +562,5 @@ const rn = ({
|
|
|
559
562
|
) });
|
|
560
563
|
};
|
|
561
564
|
export {
|
|
562
|
-
|
|
565
|
+
an as Deposit
|
|
563
566
|
};
|
|
@@ -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/useNamespaceAddress.js"),bt=require("../../queries/useGetHistory.query.js"),Ct=require("../../queries/useGetRate.mutation.js"),qe=require("../../utils/mxClsx.js"),he=require("../AmountCard/AmountCard.js"),pe=require("../AmountInput/AmountInput.js"),vt=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 It=require("../BridgeHistory/BridgeHistory.js"),At=require("../Connect/BridgeConnectButton.js"),Bt=require("../Connect/MvxConnectButton.js"),yt=require("../Connect/BridgeAccountDisplay.js"),Nt=require("../Connect/MvxAccountDisplay.js"),Mt=require("../ToggleDirection/ToggleDirection.js"),ge=require("../TokenSelector/TokenSelector.js");let D;const Et=({mvxChainId:A,mvxAddress:a,username:xe,callbackRoute:_e="/",firstTokenIdentifier:fe,secondTokenIdentifier:je,firstTokenAmount:B,secondTokenAmount:_,refetchTrigger:be,showHistory:Ce,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),[O,Z]=i.useState(0),[T,ee]=i.useState([]),we=pt.useAccount(),{switchNetwork:te}=lt.useAppKitNetwork(),ie=bt.useInvalidateHistoryQuery(),{options:re,supportedChains:f,nativeAuthToken:V,bridgeOnly:ke}=me.useWeb3App(),F=_t.useGetChainId(),se=xt.useBridgeApiChainId(),ne=ft.useSendTransactions(),{signMvxTransactions:L,resetMvxTransactionHash:S,latestMvxTransactionHash:U}=me.useWeb3App(),{evmTokensWithBalances:De,mvxTokensWithBalances:Re,isTokensLoading:Oe,isLoadingEvmTokensBalances:Ve,isLoadingMvxTokensBalances:Fe,chains:j=[],isChainsLoading:Le}=gt.useFetchBridgeData({refetchTrigger:be,mvxAddress:a,mvxApiURL:re.mvxApiURL}),G=Oe||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:n,isPending:b,error:p}=Ct.useGetRateMutation(),C=((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:r,secondToken:s,fromOptions:He,toOptions:We,selectedChainOption:v,onChangeFirstSelect:Pe,onChangeSecondSelect:Qe,handleChangeDirection:Xe}=dt.useBridgeTokenSelection({chains:j,activeChain:Se,sdkChains:f,switchNetwork:Ge,fromTokens:Re,toTokens:De,firstTokenIdentifier:fe,secondTokenIdentifier:je,forcedDestinationTokenSymbol:ve,isTokensLoading:G,mvxChainId:A,callbackRoute:_e,onNavigate:Ae}),$e=()=>{Xe(),Be()},[c,ze]=i.useState(B??""),[N,M]=i.useState(_??""),Ke=i.useMemo(()=>r?de.MVX_CHAIN_IDS.includes(r.chainId.toString()):!1,[r==null?void 0:r.chainId]),Ye=i.useMemo(()=>s?de.MVX_CHAIN_IDS.includes(s.chainId.toString()):!1,[s==null?void 0:s.chainId]),o=i.useMemo(()=>s?j.find(t=>k.sameBridgeApiChainId(t.chainId,s.chainId))??v:v,[s==null?void 0:s.chainId,j,v]),E=i.useMemo(()=>k.toBridgeApiChainId(s==null?void 0:s.chainId)??se,[s==null?void 0:s.chainId,se]),l=jt.useNamespaceAddress(o==null?void 0:o.chainType),Je=l,oe=we.isConnected&&!!l,H=c!==""&&N!=="",W=i.useCallback(ut(async t=>{!t||!Number(t)||!l||!(r!=null&&r.address)||!(s!=null&&s.address)||!v||!E||Ue({nativeAuthToken:V??"",body:{tokenIn:r.address,amountIn:t,fromChainId:A,tokenOut:s.address,toChainId:E}})},500),[l,E,r==null?void 0:r.address,s==null?void 0:s.address,v]),u=i.useCallback(t=>{ze(()=>t)},[]),g=i.useCallback(t=>{M(()=>t)},[]),Ze=i.useCallback(()=>{y==null||y()},[y]),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});m.setFieldValue("firstAmount",t),u(t)},[r==null?void 0:r.balance,r==null?void 0:r.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),rt(),u(""),g("")}},[Je,u,g,V,et,L]),{formik:m,firstAmountError:P,secondAmountError:Q,fromChainError:X,senderAddressError:$,receiverAddressError:z,confirmRateError:K,handleBlur:w,handleChange:ae,handleSubmit:it,resetSwapForm:rt}=I.useBridgeFormik({isMvxConnected:!!a,rate:n,sender:a??"",receiver:l??"",firstToken:r,firstAmount:c,fromChainId:A,toChainId:E,secondToken:s,secondAmount:N,setForceRefetchRate:Ee,senderChainType:qt.ChainType.mvx,receiverChainType:o==null?void 0:o.chainType,onSubmit:tt}),st=!!(P||Q||X||C||$||z||K),nt=i.useMemo(()=>c!==""?C??P:void 0,[P,c,C]),ot=i.useMemo(()=>N!==""?X??Q:void 0,[X,Q,N]);return i.useEffect(()=>(c||M(""),W(c),D&&clearInterval(D),D=setInterval(()=>{W(c)},50*1e3),()=>clearInterval(D)),[c,Me,W]),i.useEffect(()=>{n!=null&&n.amountOut&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,n.amountOut),M(n.amountOut))},[n==null?void 0:n.amountOut]),i.useEffect(()=>{C&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,"0"),M("0"))},[C]),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:l})),provider:(n==null?void 0:n.provider)??ht.ProviderType.None,url:mt.getApiURL()??"",token:V??""}),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,n==null?void 0:n.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:[Ce&&e.jsx(It.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(Nt.MvxAccountDisplay,{accountAddress:a,chainIcon:Y.safeImageUrl(h==null?void 0:h.pngUrl),username:xe,accountExplorerUrl:`${re.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:w}),e.jsx(ge.TokenSelector,{name:"firstToken",disabled:b,options:He,areOptionsLoading:G,isMvxSelector:Ke,isDestination:!1,color:"neutral-850",onChange:Pe,onBlur:w,onMaxBtnClick:Te,selectedOption:r,onTokenSelectorDisplay:t=>Ne(t)})]})]}),e.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:ke&&e.jsx(Mt.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(yt.BridgeAccountDisplay,{disabled:b,activeChain:o})]}),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:w}),e.jsx(ge.TokenSelector,{name:"secondToken",disabled:b,omitDisableClass:!0,options:We,areOptionsLoading:G,isMvxSelector:Ye,color:"neutral-850",onChange:Qe,onBlur:w,selectedOption:s})]})]}),e.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!a&&e.jsx(Bt.MvxConnectButton,{mvxAccountAddress:a,icon:Y.safeImageUrl(h==null?void 0:h.pngUrl),onClick:J}),a&&!oe&&e.jsx(At.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:b,activeChain:o}),a&&oe&&e.jsxs(vt.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||b||!a||!l||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(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("div",{children:o==null?void 0:o.networkName})]}),!H&&e.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"})]})]}),l&&O>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 ",O," ",O>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Transfer=Et;
|
|
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"),D=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 k;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),[O,Ne]=i.useState(!1),[Me,Ee]=i.useState(1),[R,Z]=i.useState(0),[T,ee]=i.useState([]),we=pt.useAccount(),{switchNetwork:te}=lt.useAppKitNetwork(),ie=bt.useInvalidateHistoryQuery(),{options:se,supportedChains:f,nativeAuthToken:V,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=>D.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=>D.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()},[c,ze]=i.useState(B??""),[N,M]=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=>D.sameBridgeApiChainId(t.chainId,r.chainId))??v:v,[r==null?void 0:r.chainId,j,v]),E=i.useMemo(()=>D.toBridgeApiChainId(r==null?void 0:r.chainId)??re,[r==null?void 0:r.chainId,re]);jt.useDisconnectOnChainTypeChange(n==null?void 0:n.chainType);const l=Ct.useNamespaceAddress(n==null?void 0:n.chainType),Je=l,oe=we.isConnected&&!!l,H=c!==""&&N!=="",W=i.useCallback(ut(async t=>{!t||!Number(t)||!l||!(s!=null&&s.address)||!(r!=null&&r.address)||!v||!E||Ue({nativeAuthToken:V??"",body:{tokenIn:s.address,amountIn:t,fromChainId:A,tokenOut:r.address,toChainId:E}})},500),[l,E,s==null?void 0:s.address,r==null?void 0:r.address,v]),u=i.useCallback(t=>{ze(()=>t)},[]),g=i.useCallback(t=>{M(()=>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,V,et,L]),{formik:m,firstAmountError:P,secondAmountError:Q,fromChainError:X,senderAddressError:$,receiverAddressError:z,confirmRateError:K,handleBlur:w,handleChange:ae,handleSubmit:it,resetSwapForm:st}=I.useBridgeFormik({isMvxConnected:!!a,rate:o,sender:a??"",receiver:l??"",firstToken:s,firstAmount:c,fromChainId:A,toChainId:E,secondToken:r,secondAmount:N,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(()=>c!==""?b??P:void 0,[P,c,b]),ot=i.useMemo(()=>N!==""?X??Q:void 0,[X,Q,N]);return i.useEffect(()=>(c||M(""),W(c),k&&clearInterval(k),k=setInterval(()=>{W(c)},50*1e3),()=>clearInterval(k)),[c,Me,W]),i.useEffect(()=>{o!=null&&o.amountOut&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,o.amountOut),M(o.amountOut))},[o==null?void 0:o.amountOut]),i.useEffect(()=>{b&&(m.setFieldValue(I.BridgeFormikValuesEnum.secondAmount,"0"),M("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:l})),provider:(o==null?void 0:o.provider)??ht.ProviderType.None,url:mt.getApiURL()??"",token:V??""}),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,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":O,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!O}),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:w}),e.jsx(ge.TokenSelector,{name:"firstToken",disabled:C,options:He,areOptionsLoading:G,isMvxSelector:Ke,isDestination:!1,color:"neutral-850",onChange:Pe,onBlur:w,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":O}),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:w}),e.jsx(ge.TokenSelector,{name:"secondToken",disabled:C,omitDisableClass:!0,options:We,areOptionsLoading:G,isMvxSelector:Ye,color:"neutral-850",onChange:Qe,onBlur:w,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||!l||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"})]})]}),l&&R>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 ",R," ",R>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Transfer=wt;
|
|
@@ -30,13 +30,14 @@ import { useSendTransactions as yi } from "../../hooks/useSendTransactions.mjs";
|
|
|
30
30
|
import "@reown/appkit-adapter-solana/react";
|
|
31
31
|
import "wagmi";
|
|
32
32
|
import "@reown/appkit-controllers";
|
|
33
|
+
import { useDisconnectOnChainTypeChange as Di } from "../../hooks/useDisconnectOnChainTypeChange.mjs";
|
|
33
34
|
import { useNamespaceAddress as Ei } from "../../hooks/useNamespaceAddress.mjs";
|
|
34
|
-
import { useInvalidateHistoryQuery as
|
|
35
|
-
import { useGetRateMutation as
|
|
35
|
+
import { useInvalidateHistoryQuery as Oi } from "../../queries/useGetHistory.query.mjs";
|
|
36
|
+
import { useGetRateMutation as Mi } from "../../queries/useGetRate.mutation.mjs";
|
|
36
37
|
import { mxClsx as qe } from "../../utils/mxClsx.mjs";
|
|
37
38
|
import { AmountCard as ve } from "../AmountCard/AmountCard.mjs";
|
|
38
39
|
import { AmountInput as be } from "../AmountInput/AmountInput.mjs";
|
|
39
|
-
import { MxButton as
|
|
40
|
+
import { MxButton as Ri } from "../base/MxButton/MxButton.mjs";
|
|
40
41
|
import "../base/MxCard/MxCard.mjs";
|
|
41
42
|
import "../base/MxLink/MxLink.mjs";
|
|
42
43
|
import "../base/MxSearch/MxSearch.mjs";
|
|
@@ -46,22 +47,22 @@ import "@headlessui/react";
|
|
|
46
47
|
import "react-dom";
|
|
47
48
|
import "react-popper";
|
|
48
49
|
import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
|
|
49
|
-
import { BridgeHistory as
|
|
50
|
-
import { BridgeConnectButton as
|
|
51
|
-
import { MvxConnectButton as
|
|
52
|
-
import { BridgeAccountDisplay as
|
|
53
|
-
import { MvxAccountDisplay as
|
|
54
|
-
import { ToggleDirection as
|
|
50
|
+
import { BridgeHistory as Vi } from "../BridgeHistory/BridgeHistory.mjs";
|
|
51
|
+
import { BridgeConnectButton as Li } from "../Connect/BridgeConnectButton.mjs";
|
|
52
|
+
import { MvxConnectButton as Fi } from "../Connect/MvxConnectButton.mjs";
|
|
53
|
+
import { BridgeAccountDisplay as Ui } from "../Connect/BridgeAccountDisplay.mjs";
|
|
54
|
+
import { MvxAccountDisplay as ji } from "../Connect/MvxAccountDisplay.mjs";
|
|
55
|
+
import { ToggleDirection as Pi } from "../ToggleDirection/ToggleDirection.mjs";
|
|
55
56
|
import { TokenSelector as Ce } from "../TokenSelector/TokenSelector.mjs";
|
|
56
57
|
let U;
|
|
57
|
-
const
|
|
58
|
-
mvxChainId:
|
|
58
|
+
const Qt = ({
|
|
59
|
+
mvxChainId: D,
|
|
59
60
|
mvxAddress: a,
|
|
60
61
|
username: Ie,
|
|
61
62
|
callbackRoute: xe = "/",
|
|
62
63
|
firstTokenIdentifier: Ae,
|
|
63
64
|
secondTokenIdentifier: Ne,
|
|
64
|
-
firstTokenAmount:
|
|
65
|
+
firstTokenAmount: E,
|
|
65
66
|
secondTokenAmount: x,
|
|
66
67
|
refetchTrigger: Be,
|
|
67
68
|
showHistory: we,
|
|
@@ -70,12 +71,12 @@ const Wt = ({
|
|
|
70
71
|
onFailedSentTransaction: f,
|
|
71
72
|
onHistoryClose: O,
|
|
72
73
|
onMvxConnect: ie,
|
|
73
|
-
onMvxDisconnect:
|
|
74
|
-
onNavigate:
|
|
74
|
+
onMvxDisconnect: De,
|
|
75
|
+
onNavigate: Ee,
|
|
75
76
|
onChangeDirection: Oe
|
|
76
77
|
}) => {
|
|
77
78
|
var pe, ue;
|
|
78
|
-
const Me = gi(null), [j, Re] = C(!1), [Ve, Le] = C(1), [P, te] = C(0), [re, oe] = C([]), Fe = xi(), { switchNetwork: ne } = hi(), ae =
|
|
79
|
+
const Me = gi(null), [j, Re] = C(!1), [Ve, Le] = C(1), [P, te] = C(0), [re, oe] = C([]), Fe = xi(), { switchNetwork: ne } = hi(), ae = Oi(), {
|
|
79
80
|
options: le,
|
|
80
81
|
supportedChains: A,
|
|
81
82
|
nativeAuthToken: W,
|
|
@@ -97,13 +98,13 @@ const Wt = ({
|
|
|
97
98
|
mvxAddress: a,
|
|
98
99
|
mvxApiURL: le.mvxApiURL
|
|
99
100
|
}), z = We || Ge || Qe || _e, $e = d(() => A.find((e) => ee(e.id, G)), [G, A]), g = d(() => N.find(
|
|
100
|
-
(e) => e.chainId.toString() ===
|
|
101
|
+
(e) => e.chainId.toString() === D.toString()
|
|
101
102
|
), [G, N]), {
|
|
102
103
|
mutate: ze,
|
|
103
|
-
data:
|
|
104
|
+
data: n,
|
|
104
105
|
isPending: B,
|
|
105
106
|
error: q
|
|
106
|
-
} =
|
|
107
|
+
} = Mi(), w = ((pe = q == null ? void 0 : q.response) == null ? void 0 : pe.status) === 400 ? (ue = q == null ? void 0 : q.response) == null ? void 0 : ue.data.message : void 0, He = p(
|
|
107
108
|
(e) => {
|
|
108
109
|
const b = A.find(
|
|
109
110
|
(di) => ee(di.id, e.id)
|
|
@@ -118,8 +119,8 @@ const Wt = ({
|
|
|
118
119
|
toOptions: Xe,
|
|
119
120
|
selectedChainOption: y,
|
|
120
121
|
onChangeFirstSelect: Ye,
|
|
121
|
-
onChangeSecondSelect:
|
|
122
|
-
handleChangeDirection:
|
|
122
|
+
onChangeSecondSelect: Je,
|
|
123
|
+
handleChangeDirection: Ze
|
|
123
124
|
} = qi({
|
|
124
125
|
chains: N,
|
|
125
126
|
activeChain: $e,
|
|
@@ -131,24 +132,26 @@ const Wt = ({
|
|
|
131
132
|
secondTokenIdentifier: Ne,
|
|
132
133
|
forcedDestinationTokenSymbol: ye,
|
|
133
134
|
isTokensLoading: z,
|
|
134
|
-
mvxChainId:
|
|
135
|
+
mvxChainId: D,
|
|
135
136
|
callbackRoute: xe,
|
|
136
|
-
onNavigate:
|
|
137
|
-
}),
|
|
138
|
-
|
|
139
|
-
}, [s,
|
|
137
|
+
onNavigate: Ee
|
|
138
|
+
}), Se = () => {
|
|
139
|
+
Ze(), Oe();
|
|
140
|
+
}, [s, ke] = C(E ?? ""), [M, R] = C(x ?? ""), Te = d(() => i ? fe.includes(i.chainId.toString()) : !1, [i == null ? void 0 : i.chainId]), ei = d(() => t ? fe.includes(t.chainId.toString()) : !1, [t == null ? void 0 : t.chainId]), o = d(() => t ? N.find(
|
|
140
141
|
(e) => ee(e.chainId, t.chainId)
|
|
141
142
|
) ?? y : y, [t == null ? void 0 : t.chainId, N, y]), V = d(
|
|
142
143
|
() => Ii(t == null ? void 0 : t.chainId) ?? se,
|
|
143
144
|
[t == null ? void 0 : t.chainId, se]
|
|
144
|
-
)
|
|
145
|
+
);
|
|
146
|
+
Di(o == null ? void 0 : o.chainType);
|
|
147
|
+
const c = Ei(o == null ? void 0 : o.chainType), ii = c, me = Fe.isConnected && !!c, H = s !== "" && M !== "", K = p(
|
|
145
148
|
fi(async (e) => {
|
|
146
149
|
!e || !Number(e) || !c || !(i != null && i.address) || !(t != null && t.address) || !y || !V || ze({
|
|
147
150
|
nativeAuthToken: W ?? "",
|
|
148
151
|
body: {
|
|
149
152
|
tokenIn: i.address,
|
|
150
153
|
amountIn: e,
|
|
151
|
-
fromChainId:
|
|
154
|
+
fromChainId: D,
|
|
152
155
|
tokenOut: t.address,
|
|
153
156
|
toChainId: V
|
|
154
157
|
}
|
|
@@ -162,7 +165,7 @@ const Wt = ({
|
|
|
162
165
|
y
|
|
163
166
|
]
|
|
164
167
|
), m = p((e) => {
|
|
165
|
-
|
|
168
|
+
ke(() => e);
|
|
166
169
|
}, []), v = p((e) => {
|
|
167
170
|
R(() => e);
|
|
168
171
|
}, []), ti = p(() => {
|
|
@@ -207,41 +210,41 @@ const Wt = ({
|
|
|
207
210
|
formik: h,
|
|
208
211
|
firstAmountError: X,
|
|
209
212
|
secondAmountError: Y,
|
|
210
|
-
fromChainError:
|
|
211
|
-
senderAddressError:
|
|
212
|
-
receiverAddressError:
|
|
213
|
-
confirmRateError:
|
|
213
|
+
fromChainError: J,
|
|
214
|
+
senderAddressError: Z,
|
|
215
|
+
receiverAddressError: S,
|
|
216
|
+
confirmRateError: k,
|
|
214
217
|
handleBlur: L,
|
|
215
218
|
handleChange: de,
|
|
216
219
|
handleSubmit: ai,
|
|
217
220
|
resetSwapForm: li
|
|
218
221
|
} = Ai({
|
|
219
222
|
isMvxConnected: !!a,
|
|
220
|
-
rate:
|
|
223
|
+
rate: n,
|
|
221
224
|
sender: a ?? "",
|
|
222
225
|
receiver: c ?? "",
|
|
223
226
|
firstToken: i,
|
|
224
227
|
firstAmount: s,
|
|
225
|
-
fromChainId:
|
|
228
|
+
fromChainId: D,
|
|
226
229
|
toChainId: V,
|
|
227
230
|
secondToken: t,
|
|
228
231
|
secondAmount: M,
|
|
229
232
|
setForceRefetchRate: Le,
|
|
230
233
|
senderChainType: bi.mvx,
|
|
231
|
-
receiverChainType:
|
|
234
|
+
receiverChainType: o == null ? void 0 : o.chainType,
|
|
232
235
|
onSubmit: ni
|
|
233
|
-
}), si = !!(X || Y ||
|
|
236
|
+
}), si = !!(X || Y || J || w || Z || S || k), ci = d(() => s !== "" ? w ?? X : void 0, [X, s, w]), mi = d(() => M !== "" ? J ?? Y : void 0, [J, Y, M]);
|
|
234
237
|
return I(() => (s || R(""), K(s), U && clearInterval(U), U = setInterval(() => {
|
|
235
238
|
K(s);
|
|
236
239
|
}, 50 * 1e3), () => clearInterval(U)), [s, Ve, K]), I(() => {
|
|
237
|
-
|
|
238
|
-
}, [
|
|
240
|
+
n != null && n.amountOut && (h.setFieldValue(F.secondAmount, n.amountOut), R(n.amountOut));
|
|
241
|
+
}, [n == null ? void 0 : n.amountOut]), I(() => {
|
|
239
242
|
w && (h.setFieldValue(F.secondAmount, "0"), R("0"));
|
|
240
243
|
}, [w]), I(() => {
|
|
241
|
-
|
|
244
|
+
E && (h.setFieldValue(
|
|
242
245
|
F.firstAmount,
|
|
243
|
-
|
|
244
|
-
), m(
|
|
246
|
+
E
|
|
247
|
+
), m(E));
|
|
245
248
|
}, []), I(() => {
|
|
246
249
|
x && (h.setFieldValue(
|
|
247
250
|
F.secondAmount,
|
|
@@ -257,7 +260,7 @@ const Wt = ({
|
|
|
257
260
|
txHash: e,
|
|
258
261
|
receiver: c
|
|
259
262
|
})),
|
|
260
|
-
provider: (
|
|
263
|
+
provider: (n == null ? void 0 : n.provider) ?? Ci.None,
|
|
261
264
|
url: vi() ?? "",
|
|
262
265
|
token: W ?? ""
|
|
263
266
|
}), u == null || u([e]);
|
|
@@ -272,7 +275,7 @@ const Wt = ({
|
|
|
272
275
|
}, [
|
|
273
276
|
$,
|
|
274
277
|
re,
|
|
275
|
-
|
|
278
|
+
n == null ? void 0 : n.provider,
|
|
276
279
|
ce
|
|
277
280
|
]), /* @__PURE__ */ r(pi, { children: /* @__PURE__ */ l(
|
|
278
281
|
"form",
|
|
@@ -283,7 +286,7 @@ const Wt = ({
|
|
|
283
286
|
autoComplete: "off",
|
|
284
287
|
onSubmit: ai,
|
|
285
288
|
children: [
|
|
286
|
-
we && /* @__PURE__ */ r(
|
|
289
|
+
we && /* @__PURE__ */ r(Vi, { mvxAddress: a, onClose: ti }),
|
|
287
290
|
/* @__PURE__ */ l(
|
|
288
291
|
ve,
|
|
289
292
|
{
|
|
@@ -298,19 +301,19 @@ const Wt = ({
|
|
|
298
301
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
299
302
|
/* @__PURE__ */ r("span", { children: "From" }),
|
|
300
303
|
/* @__PURE__ */ r(
|
|
301
|
-
|
|
304
|
+
ji,
|
|
302
305
|
{
|
|
303
306
|
accountAddress: a,
|
|
304
307
|
chainIcon: T(g == null ? void 0 : g.pngUrl),
|
|
305
308
|
username: Ie,
|
|
306
309
|
accountExplorerUrl: `${le.mvxExplorerAddress}/accounts/${a}`,
|
|
307
310
|
showTag: !0,
|
|
308
|
-
onDisconnect:
|
|
311
|
+
onDisconnect: De,
|
|
309
312
|
onConnect: ie
|
|
310
313
|
}
|
|
311
314
|
)
|
|
312
315
|
] }),
|
|
313
|
-
|
|
316
|
+
Z && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: Z }),
|
|
314
317
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
315
318
|
/* @__PURE__ */ r(
|
|
316
319
|
be,
|
|
@@ -345,7 +348,7 @@ const Wt = ({
|
|
|
345
348
|
]
|
|
346
349
|
}
|
|
347
350
|
),
|
|
348
|
-
/* @__PURE__ */ r("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: Ue && /* @__PURE__ */ r(
|
|
351
|
+
/* @__PURE__ */ r("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: Ue && /* @__PURE__ */ r(Pi, { onChangeDirection: Se }) }),
|
|
349
352
|
/* @__PURE__ */ l(
|
|
350
353
|
ve,
|
|
351
354
|
{
|
|
@@ -359,15 +362,15 @@ const Wt = ({
|
|
|
359
362
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
360
363
|
/* @__PURE__ */ r("span", { children: "To" }),
|
|
361
364
|
/* @__PURE__ */ r(
|
|
362
|
-
|
|
365
|
+
Ui,
|
|
363
366
|
{
|
|
364
367
|
disabled: B,
|
|
365
|
-
activeChain:
|
|
368
|
+
activeChain: o
|
|
366
369
|
}
|
|
367
370
|
)
|
|
368
371
|
] }),
|
|
369
|
-
Z && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: Z }),
|
|
370
372
|
S && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: S }),
|
|
373
|
+
k && /* @__PURE__ */ r("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: k }),
|
|
371
374
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
372
375
|
/* @__PURE__ */ r(
|
|
373
376
|
be,
|
|
@@ -391,7 +394,7 @@ const Wt = ({
|
|
|
391
394
|
areOptionsLoading: z,
|
|
392
395
|
isMvxSelector: ei,
|
|
393
396
|
color: "neutral-850",
|
|
394
|
-
onChange:
|
|
397
|
+
onChange: Je,
|
|
395
398
|
onBlur: L,
|
|
396
399
|
selectedOption: t
|
|
397
400
|
}
|
|
@@ -402,7 +405,7 @@ const Wt = ({
|
|
|
402
405
|
),
|
|
403
406
|
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-justify-center", children: [
|
|
404
407
|
!a && /* @__PURE__ */ r(
|
|
405
|
-
|
|
408
|
+
Fi,
|
|
406
409
|
{
|
|
407
410
|
mvxAccountAddress: a,
|
|
408
411
|
icon: T(g == null ? void 0 : g.pngUrl),
|
|
@@ -410,15 +413,15 @@ const Wt = ({
|
|
|
410
413
|
}
|
|
411
414
|
),
|
|
412
415
|
a && !me && /* @__PURE__ */ r(
|
|
413
|
-
|
|
416
|
+
Li,
|
|
414
417
|
{
|
|
415
418
|
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",
|
|
416
419
|
disabled: B,
|
|
417
|
-
activeChain:
|
|
420
|
+
activeChain: o
|
|
418
421
|
}
|
|
419
422
|
),
|
|
420
423
|
a && me && /* @__PURE__ */ l(
|
|
421
|
-
|
|
424
|
+
Ri,
|
|
422
425
|
{
|
|
423
426
|
"data-testid": "submit-button",
|
|
424
427
|
type: "submit",
|
|
@@ -431,12 +434,12 @@ const Wt = ({
|
|
|
431
434
|
/* @__PURE__ */ r(
|
|
432
435
|
"img",
|
|
433
436
|
{
|
|
434
|
-
src: T(
|
|
437
|
+
src: T(o == null ? void 0 : o.pngUrl),
|
|
435
438
|
alt: "",
|
|
436
439
|
className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
437
440
|
}
|
|
438
441
|
),
|
|
439
|
-
/* @__PURE__ */ r("div", { children:
|
|
442
|
+
/* @__PURE__ */ r("div", { children: o == null ? void 0 : o.networkName })
|
|
440
443
|
] }),
|
|
441
444
|
!H && /* @__PURE__ */ r("span", { className: "liq-text-neutral-100", children: "Enter amount" })
|
|
442
445
|
]
|
|
@@ -456,5 +459,5 @@ const Wt = ({
|
|
|
456
459
|
) });
|
|
457
460
|
};
|
|
458
461
|
export {
|
|
459
|
-
|
|
462
|
+
Qt as Transfer
|
|
460
463
|
};
|
|
@@ -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"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@fortawesome/free-solid-svg-icons/faPowerOff"),p=require("@fortawesome/react-fontawesome"),g=require("@reown/appkit/react"),r=require("../../../helpers/getDisplayName.js"),j=require("./SwitchChainButton.js"),y=require("../../../types/chainType.js"),f=require("../../hooks/useAccount.js"),N=require("../../hooks/useNamespaceAddress.js"),b=require("../../hooks/useSuiConnect.js");require("clsx");require("tailwind-merge");require("../base/MxCard/MxCard.js");const _=require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@headlessui/react");require("react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");require("../../constants/index.js");const w=require("../CopyButton/CopyButton.js"),h=require("../TrimAddress/TrimAddress.js"),k=({activeChain:s,disabled:n})=>{var c;const t=f.useAccount(),{disconnect:q}=g.useDisconnect(),l=b.useSuiConnect(),d=N.useNamespaceAddress(s==null?void 0:s.chainType),o=(s==null?void 0:s.chainType)===y.ChainType.sui,i=d??t.address,a=async u=>{try{u.preventDefault(),o?await l.disconnect():await q()}catch(m){console.error("Failed to disconnect:",m)}};return i?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s==null?void 0:s.pngUrl,alt:"",className:"liq-w-6 liq-h-6 liq-rounded-lg"}),e.jsx("span",{className:"liq-truncate liq-text-gray-400",children:r.getDisplayName(s)}),e.jsx("span",{className:"liq-ml-[-5px]",children:":"}),e.jsx("div",{className:"liq-flex liq-items-center liq-justify-between",children:e.jsxs("div",{className:"liq-flex liq-max-w-[10rem] liq-items-center liq-gap-1",children:[e.jsx(_.MxLink,{to:`${(c=s==null?void 0:s.blockExplorerUrls)==null?void 0:c[0]}/address/${i}`,target:"_blank",showExternalIcon:!1,className:"!liq-relative",children:e.jsx("div",{className:"liq-flex liq-min-w-0 liq-flex-grow liq-overflow-hidden liq-leading-none liq-max-w-[10rem]",children:e.jsx(h.TrimAddress,{address:i,"data-testid":"evm-address"})})}),e.jsx(w.CopyButton,{text:i,className:"liq-text-sm","data-testid":"evm-copy-button"})]})}),e.jsx("div",{className:"liq-ml-auto liq-mr-0 liq-flex liq-items-center liq-gap-1",children:e.jsx("button",{className:"focus-primary liq-flex liq-items-center liq-gap-1 liq-rounded-xl liq-px-0 liq-py-2 liq-text-sm liq-font-semibold liq-text-neutral-400 liq-transition-colors liq-duration-200 hover:enabled:liq-text-white disabled:liq-opacity-50",onClick:a,"data-testid":"evm-disconnect-button",children:e.jsx(p.FontAwesomeIcon,{icon:x.faPowerOff})})})]}):o?e.jsxs("div",{className:"liq-flex liq-max-w-full liq-items-center liq-gap-2",children:[e.jsx("button",{disabled:n||l.isConnecting,onClick:()=>l.connect(),className:"liq-rounded-lg liq-font-semibold liq-transition-colors liq-duration-200 disabled:liq-opacity-50 liq-bg-neutral-750 !liq-text-primary-200 hover:enabled:liq-bg-primary liq-px-2",children:e.jsx("div",{className:"liq-flex liq-items-center",children:e.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[e.jsx("div",{children:l.isConnecting?"Connecting...":"Connect"}),e.jsx("img",{src:s==null?void 0:s.pngUrl,alt:"",className:"liq-w-4 liq-h-4 liq-rounded-sm"}),e.jsx("div",{className:"liq-truncate md:liq-text-clip",children:r.getDisplayName(s)})]})})}),l.isConnecting&&e.jsx("button",{type:"button",onClick:()=>void l.cancelPendingConnection(),className:"liq-shrink-0 liq-rounded-lg liq-px-2 liq-py-1 liq-text-xs liq-font-medium liq-text-neutral-400 hover:liq-text-white",children:"Cancel"})]}):e.jsx(j.SwitchChainButton,{disabled:n,className:"liq-rounded-lg liq-font-semibold liq-transition-colors liq-duration-200 disabled:liq-opacity-50 liq-bg-neutral-750 !liq-text-primary-200 hover:enabled:liq-bg-primary liq-px-2",children:e.jsx("div",{className:"liq-flex liq-items-center",children:e.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[e.jsx("div",{children:t.isConnecting?"Connecting...":"Connect"}),e.jsx("img",{src:s==null?void 0:s.pngUrl,alt:"",className:"liq-w-4 liq-h-4 liq-rounded-sm"}),e.jsx("div",{className:"liq-truncate md:liq-text-clip",children:r.getDisplayName(s)})]})})})};exports.BridgeAccountDisplay=k;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { faPowerOff as
|
|
3
|
-
import { FontAwesomeIcon as
|
|
4
|
-
import { useDisconnect as
|
|
1
|
+
import { jsxs as r, Fragment as f, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { faPowerOff as x } from "@fortawesome/free-solid-svg-icons/faPowerOff";
|
|
3
|
+
import { FontAwesomeIcon as g } from "@fortawesome/react-fontawesome";
|
|
4
|
+
import { useDisconnect as y } from "@reown/appkit/react";
|
|
5
5
|
import { getDisplayName as s } from "../../../helpers/getDisplayName.mjs";
|
|
6
|
-
import { SwitchChainButton as
|
|
7
|
-
import { ChainType as
|
|
8
|
-
import { useAccount as
|
|
9
|
-
import {
|
|
6
|
+
import { SwitchChainButton as N } from "./SwitchChainButton.mjs";
|
|
7
|
+
import { ChainType as b } from "../../../types/chainType.mjs";
|
|
8
|
+
import { useAccount as w } from "../../hooks/useAccount.mjs";
|
|
9
|
+
import { useNamespaceAddress as h } from "../../hooks/useNamespaceAddress.mjs";
|
|
10
|
+
import { useSuiConnect as k } from "../../hooks/useSuiConnect.mjs";
|
|
10
11
|
import "clsx";
|
|
11
12
|
import "tailwind-merge";
|
|
12
13
|
import "../base/MxCard/MxCard.mjs";
|
|
13
|
-
import { MxLink as
|
|
14
|
+
import { MxLink as A } from "../base/MxLink/MxLink.mjs";
|
|
14
15
|
import "../base/MxSearch/MxSearch.mjs";
|
|
15
16
|
import "@fortawesome/free-solid-svg-icons/faClose";
|
|
16
17
|
import "@headlessui/react";
|
|
@@ -19,52 +20,52 @@ import "react-dom";
|
|
|
19
20
|
import "react-popper";
|
|
20
21
|
import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
|
|
21
22
|
import "../../constants/index.mjs";
|
|
22
|
-
import { CopyButton as
|
|
23
|
-
import { TrimAddress as
|
|
24
|
-
const
|
|
25
|
-
activeChain:
|
|
23
|
+
import { CopyButton as j } from "../CopyButton/CopyButton.mjs";
|
|
24
|
+
import { TrimAddress as D } from "../TrimAddress/TrimAddress.mjs";
|
|
25
|
+
const Z = ({
|
|
26
|
+
activeChain: e,
|
|
26
27
|
disabled: o
|
|
27
28
|
}) => {
|
|
28
29
|
var d;
|
|
29
|
-
const
|
|
30
|
+
const n = w(), { disconnect: c } = y(), i = k(), q = h(e == null ? void 0 : e.chainType), m = (e == null ? void 0 : e.chainType) === b.sui, t = q ?? n.address, a = async (p) => {
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
-
} catch (
|
|
33
|
-
console.error("Failed to disconnect:",
|
|
32
|
+
p.preventDefault(), m ? await i.disconnect() : await c();
|
|
33
|
+
} catch (u) {
|
|
34
|
+
console.error("Failed to disconnect:", u);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
return
|
|
37
|
+
return t ? /* @__PURE__ */ r(f, { children: [
|
|
37
38
|
/* @__PURE__ */ l(
|
|
38
39
|
"img",
|
|
39
40
|
{
|
|
40
|
-
src:
|
|
41
|
+
src: e == null ? void 0 : e.pngUrl,
|
|
41
42
|
alt: "",
|
|
42
43
|
className: "liq-w-6 liq-h-6 liq-rounded-lg"
|
|
43
44
|
}
|
|
44
45
|
),
|
|
45
|
-
/* @__PURE__ */ l("span", { className: "liq-truncate liq-text-gray-400", children: s(
|
|
46
|
+
/* @__PURE__ */ l("span", { className: "liq-truncate liq-text-gray-400", children: s(e) }),
|
|
46
47
|
/* @__PURE__ */ l("span", { className: "liq-ml-[-5px]", children: ":" }),
|
|
47
|
-
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-justify-between", children: /* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ l("div", { className: "liq-flex liq-items-center liq-justify-between", children: /* @__PURE__ */ r("div", { className: "liq-flex liq-max-w-[10rem] liq-items-center liq-gap-1", children: [
|
|
48
49
|
/* @__PURE__ */ l(
|
|
49
|
-
|
|
50
|
+
A,
|
|
50
51
|
{
|
|
51
|
-
to: `${(d =
|
|
52
|
+
to: `${(d = e == null ? void 0 : e.blockExplorerUrls) == null ? void 0 : d[0]}/address/${t}`,
|
|
52
53
|
target: "_blank",
|
|
53
54
|
showExternalIcon: !1,
|
|
54
55
|
className: "!liq-relative",
|
|
55
56
|
children: /* @__PURE__ */ l("div", { className: "liq-flex liq-min-w-0 liq-flex-grow liq-overflow-hidden liq-leading-none liq-max-w-[10rem]", children: /* @__PURE__ */ l(
|
|
56
|
-
|
|
57
|
+
D,
|
|
57
58
|
{
|
|
58
|
-
address:
|
|
59
|
+
address: t,
|
|
59
60
|
"data-testid": "evm-address"
|
|
60
61
|
}
|
|
61
62
|
) })
|
|
62
63
|
}
|
|
63
64
|
),
|
|
64
65
|
/* @__PURE__ */ l(
|
|
65
|
-
|
|
66
|
+
j,
|
|
66
67
|
{
|
|
67
|
-
text:
|
|
68
|
+
text: t,
|
|
68
69
|
className: "liq-text-sm",
|
|
69
70
|
"data-testid": "evm-copy-button"
|
|
70
71
|
}
|
|
@@ -74,61 +75,61 @@ const W = ({
|
|
|
74
75
|
"button",
|
|
75
76
|
{
|
|
76
77
|
className: "focus-primary liq-flex liq-items-center liq-gap-1 liq-rounded-xl liq-px-0 liq-py-2 liq-text-sm liq-font-semibold liq-text-neutral-400 liq-transition-colors liq-duration-200 hover:enabled:liq-text-white disabled:liq-opacity-50",
|
|
77
|
-
onClick:
|
|
78
|
+
onClick: a,
|
|
78
79
|
"data-testid": "evm-disconnect-button",
|
|
79
|
-
children: /* @__PURE__ */ l(
|
|
80
|
+
children: /* @__PURE__ */ l(g, { icon: x })
|
|
80
81
|
}
|
|
81
82
|
) })
|
|
82
|
-
] }) :
|
|
83
|
+
] }) : m ? /* @__PURE__ */ r("div", { className: "liq-flex liq-max-w-full liq-items-center liq-gap-2", children: [
|
|
83
84
|
/* @__PURE__ */ l(
|
|
84
85
|
"button",
|
|
85
86
|
{
|
|
86
|
-
disabled: o ||
|
|
87
|
-
onClick: () =>
|
|
87
|
+
disabled: o || i.isConnecting,
|
|
88
|
+
onClick: () => i.connect(),
|
|
88
89
|
className: "liq-rounded-lg liq-font-semibold liq-transition-colors liq-duration-200 disabled:liq-opacity-50 liq-bg-neutral-750 !liq-text-primary-200 hover:enabled:liq-bg-primary liq-px-2",
|
|
89
|
-
children: /* @__PURE__ */ l("div", { className: "liq-flex liq-items-center", children: /* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */ l("div", { children:
|
|
90
|
+
children: /* @__PURE__ */ l("div", { className: "liq-flex liq-items-center", children: /* @__PURE__ */ r("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
91
|
+
/* @__PURE__ */ l("div", { children: i.isConnecting ? "Connecting..." : "Connect" }),
|
|
91
92
|
/* @__PURE__ */ l(
|
|
92
93
|
"img",
|
|
93
94
|
{
|
|
94
|
-
src:
|
|
95
|
+
src: e == null ? void 0 : e.pngUrl,
|
|
95
96
|
alt: "",
|
|
96
97
|
className: "liq-w-4 liq-h-4 liq-rounded-sm"
|
|
97
98
|
}
|
|
98
99
|
),
|
|
99
|
-
/* @__PURE__ */ l("div", { className: "liq-truncate md:liq-text-clip", children: s(
|
|
100
|
+
/* @__PURE__ */ l("div", { className: "liq-truncate md:liq-text-clip", children: s(e) })
|
|
100
101
|
] }) })
|
|
101
102
|
}
|
|
102
103
|
),
|
|
103
|
-
|
|
104
|
+
i.isConnecting && /* @__PURE__ */ l(
|
|
104
105
|
"button",
|
|
105
106
|
{
|
|
106
107
|
type: "button",
|
|
107
|
-
onClick: () => void
|
|
108
|
+
onClick: () => void i.cancelPendingConnection(),
|
|
108
109
|
className: "liq-shrink-0 liq-rounded-lg liq-px-2 liq-py-1 liq-text-xs liq-font-medium liq-text-neutral-400 hover:liq-text-white",
|
|
109
110
|
children: "Cancel"
|
|
110
111
|
}
|
|
111
112
|
)
|
|
112
113
|
] }) : /* @__PURE__ */ l(
|
|
113
|
-
|
|
114
|
+
N,
|
|
114
115
|
{
|
|
115
116
|
disabled: o,
|
|
116
117
|
className: "liq-rounded-lg liq-font-semibold liq-transition-colors liq-duration-200 disabled:liq-opacity-50 liq-bg-neutral-750 !liq-text-primary-200 hover:enabled:liq-bg-primary liq-px-2",
|
|
117
|
-
children: /* @__PURE__ */ l("div", { className: "liq-flex liq-items-center", children: /* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */ l("div", { children:
|
|
118
|
+
children: /* @__PURE__ */ l("div", { className: "liq-flex liq-items-center", children: /* @__PURE__ */ r("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
119
|
+
/* @__PURE__ */ l("div", { children: n.isConnecting ? "Connecting..." : "Connect" }),
|
|
119
120
|
/* @__PURE__ */ l(
|
|
120
121
|
"img",
|
|
121
122
|
{
|
|
122
|
-
src:
|
|
123
|
+
src: e == null ? void 0 : e.pngUrl,
|
|
123
124
|
alt: "",
|
|
124
125
|
className: "liq-w-4 liq-h-4 liq-rounded-sm"
|
|
125
126
|
}
|
|
126
127
|
),
|
|
127
|
-
/* @__PURE__ */ l("div", { className: "liq-truncate md:liq-text-clip", children: s(
|
|
128
|
+
/* @__PURE__ */ l("div", { className: "liq-truncate md:liq-text-clip", children: s(e) })
|
|
128
129
|
] }) })
|
|
129
130
|
}
|
|
130
131
|
);
|
|
131
132
|
};
|
|
132
133
|
export {
|
|
133
|
-
|
|
134
|
+
Z as BridgeAccountDisplay
|
|
134
135
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChainType } from '../../types/chainType';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Disconnects the previous chain namespace when the active chain type changes.
|
|
5
|
+
*
|
|
6
|
+
* This covers all paths that can change the chain type (token selection, direction
|
|
7
|
+
* toggle, etc.) and prevents stale SUI sessions from lingering after switching to
|
|
8
|
+
* EVM (and vice-versa) in mobile dapp browsers.
|
|
9
|
+
*
|
|
10
|
+
* Only reacts to genuine transitions — skips the initial undefined→value mount.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useDisconnectOnChainTypeChange(chainType: ChainType | undefined): void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@reown/appkit/react"),s=require("react"),c=require("../../types/chainType.js");function r(n){const{disconnect:i}=o.useDisconnect(),t=s.useRef(void 0);s.useEffect(()=>{const e=t.current;t.current=n,!(e===void 0||e===n)&&(e===c.ChainType.sui?i({namespace:"sui"}):e===c.ChainType.evm&&i())},[n])}exports.useDisconnectOnChainTypeChange=r;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useDisconnect as t } from "@reown/appkit/react";
|
|
2
|
+
import { useRef as s, useEffect as c } from "react";
|
|
3
|
+
import { ChainType as r } from "../../types/chainType.mjs";
|
|
4
|
+
function p(n) {
|
|
5
|
+
const { disconnect: o } = t(), i = s(void 0);
|
|
6
|
+
c(() => {
|
|
7
|
+
const e = i.current;
|
|
8
|
+
i.current = n, !(e === void 0 || e === n) && (e === r.sui ? o({ namespace: "sui" }) : e === r.evm && o());
|
|
9
|
+
}, [n]);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
p as useDisconnectOnChainTypeChange
|
|
13
|
+
};
|