@multiversx/sdk-dapp-liquidity 2.4.0-alpha.0 → 2.4.0-alpha.1
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/BridgeHistory-0NVr8Uxp.js +2 -0
- package/{BridgeHistory-CInRkJ6T.mjs → BridgeHistory-BUSiuT1d.mjs} +10 -10
- package/{useFetchBridgeData-C_hZjzd_.mjs → hooks-DMIHvAKb.mjs} +16 -16
- package/hooks-SJPsZfDx.js +2 -0
- package/index.js +1 -1
- package/index.mjs +42 -42
- package/package.json +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.js +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.mjs +77 -49
- package/reactjs/components/BridgeForm/Deposit.js +1 -1
- package/reactjs/components/BridgeForm/Deposit.mjs +221 -222
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +44 -44
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +1 -1
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +3 -3
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.d.ts +2 -0
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +1 -1
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +2 -2
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +1 -1
- package/reactjs/components/BridgeHistory/index.js +1 -1
- package/reactjs/components/BridgeHistory/index.mjs +1 -1
- package/reactjs/components/Connect/ChainSelectConnect.js +1 -1
- package/reactjs/components/Connect/ChainSelectConnect.mjs +3 -3
- package/reactjs/components/index.js +1 -1
- package/reactjs/components/index.mjs +1 -1
- package/reactjs/context/Web3AppProvider.js +1 -1
- package/reactjs/context/Web3AppProvider.mjs +5 -5
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +14 -14
- package/reactjs/hooks/useBridgeFormik.js +1 -1
- package/reactjs/hooks/useBridgeFormik.mjs +14 -14
- package/reactjs/hooks/useFetchBridgeData.js +1 -1
- package/reactjs/hooks/useFetchBridgeData.mjs +1 -1
- package/reactjs/hooks/useFetchTokens.js +1 -1
- package/reactjs/hooks/useFetchTokens.mjs +1 -1
- package/reactjs/hooks/useSignTransaction.d.ts +3 -470
- package/reactjs/hooks/useSignTransaction.js +1 -1
- package/reactjs/hooks/useSignTransaction.mjs +39 -40
- package/reactjs/index.js +1 -1
- package/reactjs/index.mjs +42 -42
- package/reactjs/queries/index.js +1 -1
- package/reactjs/queries/index.mjs +3 -3
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +1 -1
- package/reactjs/utils/index.js +1 -1
- package/reactjs/utils/index.mjs +11 -11
- package/BridgeHistory-BU-L_w0l.js +0 -2
- package/useFetchBridgeData-B5xt9GbW.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunk-oiTVcehM.js"),t=require("../../../constants/index.js"),ee=require("../../../helpers/getApiURL.js"),n=require("../../../helpers/safeImageUrl.js"),te=require("../../../types/chainType.js");require("../../../helpers/index.js");const ne=require("../../utils/mxClsx.js"),re=require("../base/MxButton/MxButton.js");require("../base/index.js");const ie=require("../AmountCard/AmountCard.js");require("../AmountCard/index.js");const ae=require("../AmountInput/AmountInput.js");require("../AmountInput/index.js");const r=require("../../helpers/resolveBridgeApiChainId.js"),oe=require("./hooks/useBridgeTokenSelection.js"),se=require("../../context/useWeb3App.js"),ce=require("../../hooks/useAccount.js"),le=require("../../hooks/useBridgeApiChainId.js"),ue=require("../../../types/providerType.js"),i=require("../../hooks/useBridgeFormik.js"),de=require("../../hooks/useDisconnectOnChainTypeChange.js"),fe=require("../../hooks/useGetChainId.js"),pe=require("../../hooks/useSendTransactions.js"),me=require("../../../useFetchBridgeData-B5xt9GbW.js"),he=require("../../hooks/useNamespaceAddress.js"),ge=require("../../queries/useGetHistory.query.js"),_e=require("../../queries/useGetRate.mutation.js"),ve=require("../../../BridgeHistory-BU-L_w0l.js");require("../BridgeHistory/index.js");const ye=require("../Connect/BridgeConnectButton.js"),be=require("../Connect/MvxConnectButton.js"),xe=require("../Connect/BridgeAccountDisplay.js"),Se=require("../Connect/MvxAccountDisplay.js");require("../Connect/index.js");const Ce=require("../../../ToggleDirection-CZ9-ZD7Y.js"),we=require("../TokenSelector/TokenSelector.js");require("../TokenSelector/index.js");let a=require("react/jsx-runtime"),o=require("react"),Te=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),Ee=require("@reown/appkit/react"),s=require("lodash/debounce");s=e.n(s);let De=require("react-toastify");var c,l=({mvxChainId:e,mvxAddress:l,username:Oe,callbackRoute:ke=`/`,firstTokenIdentifier:Ae,secondTokenIdentifier:je,firstTokenAmount:u,secondTokenAmount:d,refetchTrigger:Me,showHistory:Ne,forcedDestinationTokenSymbol:Pe,onSuccessfullySentTransaction:f,onFailedSentTransaction:p,onHistoryClose:m,onMvxConnect:h,onMvxDisconnect:Fe,onNavigate:Ie,onChangeDirection:Le})=>{let Re=(0,o.useRef)(null),[g,ze]=(0,o.useState)(!1),[Be,Ve]=(0,o.useState)(1),[_,v]=(0,o.useState)(0),[y,b]=(0,o.useState)([]),He=ce.useAccount(),{switchNetwork:x}=(0,Ee.useAppKitNetwork)(),S=ge.useInvalidateHistoryQuery(),{options:Ue,supportedChains:C,nativeAuthToken:w,bridgeOnly:We}=se.useWeb3App(),T=fe.useGetChainId(),Ge=le.useBridgeApiChainId(),Ke=pe.useSendTransactions(),{signMvxTransactions:E,resetMvxTransactionHash:qe,latestMvxTransactionHash:D}=se.useWeb3App(),{evmTokensWithBalances:Je,mvxTokensWithBalances:Ye,isTokensLoading:Xe,isLoadingEvmTokensBalances:Ze,isLoadingMvxTokensBalances:Qe,chains:O=[],isChainsLoading:$e}=me.t({refetchTrigger:Me,mvxAddress:l,mvxApiURL:Ue.mvxApiURL}),k=Xe||Ze||Qe||$e,et=(0,o.useMemo)(()=>C.find(e=>r.sameBridgeApiChainId(e.id,T)),[T,C]),tt=(0,o.useMemo)(()=>O.find(t=>t.chainId.toString()===e.toString()),[T,O]),{mutate:nt,data:A,isPending:j,error:rt}=_e.useGetRateMutation(),M=rt?.response?.status===400?rt?.response?.data.message:void 0,{firstToken:N,secondToken:P,fromOptions:it,toOptions:at,selectedChainOption:F,onChangeFirstSelect:ot,onChangeSecondSelect:st,handleChangeDirection:ct}=oe.useBridgeTokenSelection({chains:O,activeChain:et,sdkChains:C,switchNetwork:(0,o.useCallback)(e=>{let t=C.find(t=>r.sameBridgeApiChainId(t.id,e.id));t&&x(t)},[C,x]),fromTokens:Ye,toTokens:Je,firstTokenIdentifier:Ae,secondTokenIdentifier:je,forcedDestinationTokenSymbol:Pe,isTokensLoading:k,mvxChainId:e,callbackRoute:ke,onNavigate:Ie}),lt=()=>{ct(),Le()},[I,ut]=(0,o.useState)(u??``),[L,R]=(0,o.useState)(d??``),dt=(0,o.useMemo)(()=>N?t.MVX_CHAIN_IDS.includes(N.chainId.toString()):!1,[N?.chainId]),ft=(0,o.useMemo)(()=>P?t.MVX_CHAIN_IDS.includes(P.chainId.toString()):!1,[P?.chainId]),z=(0,o.useMemo)(()=>P?O.find(e=>r.sameBridgeApiChainId(e.chainId,P.chainId))??F:F,[P?.chainId,O,F]),B=(0,o.useMemo)(()=>r.toBridgeApiChainId(P?.chainId)??Ge,[P?.chainId,Ge]);de.useDisconnectOnChainTypeChange(z?.chainType);let V=he.useNamespaceAddress(z?.chainType),pt=V,mt=He.isConnected&&!!V,H=I!==``&&L!==``,U=(0,o.useCallback)((0,s.default)(async t=>{!t||!Number(t)||!V||!N?.address||!P?.address||!F||!B||nt({nativeAuthToken:w??``,body:{tokenIn:N.address,amountIn:t,fromChainId:e,tokenOut:P.address,toChainId:B}})},500),[V,B,N?.address,P?.address,F,e,w,nt]),W=(0,o.useCallback)(e=>{ut(()=>e)},[]),G=(0,o.useCallback)(e=>{R(()=>e)},[]),ht=(0,o.useCallback)(()=>{m?.()},[m]),gt=(0,o.useCallback)(()=>{let e=(0,Te.formatAmount)({decimals:N?.decimals,input:N?.balance??`0`,addCommas:!1,digits:4});K.setFieldValue(`firstAmount`,e),W(e)},[N?.balance,N?.decimals,W]),_t=(0,o.useCallback)(async({transactions:e})=>{v(()=>e.length);try{if(!E)throw Error(`signMvxTransactions function is not provided`);await E(e),b(e)}catch(e){console.error(e),De.toast.dismiss(),De.toast.error(`Transaction cancelled`),p?.(`Transaction cancelled`),v(0),bt(),W(``),G(``)}},[pt,W,G,w,(0,o.useCallback)(async e=>{W(``),G(``),S(),S(),f?.(e)},[W,G,f]),E]),{formik:K,firstAmountError:q,secondAmountError:J,fromChainError:Y,senderAddressError:X,receiverAddressError:Z,confirmRateError:Q,handleBlur:$,handleChange:vt,handleSubmit:yt,resetSwapForm:bt}=i.useBridgeFormik({isMvxConnected:!!l,rate:A,sender:l??``,receiver:V??``,firstToken:N,firstAmount:I,fromChainId:e,toChainId:B,secondToken:P,secondAmount:L,setForceRefetchRate:Ve,senderChainType:te.ChainType.mvx,receiverChainType:z?.chainType,onSubmit:_t}),xt=!!(q||J||Y||M||X||Z||Q),St=(0,o.useMemo)(()=>I===``?void 0:M??q,[q,I,M]),Ct=(0,o.useMemo)(()=>L===``?void 0:Y??J,[Y,J,L]);return(0,o.useEffect)(()=>(I||R(``),U(I),c&&clearInterval(c),c=setInterval(()=>{U(I)},50*1e3),()=>clearInterval(c)),[I,Be,U]),(0,o.useEffect)(()=>{A?.amountOut&&(K.setFieldValue(i.BridgeFormikValuesEnum.secondAmount,A.amountOut),R(A.amountOut))},[A?.amountOut]),(0,o.useEffect)(()=>{M&&(K.setFieldValue(i.BridgeFormikValuesEnum.secondAmount,`0`),R(`0`))},[M]),(0,o.useEffect)(()=>{u&&(K.setFieldValue(i.BridgeFormikValuesEnum.firstAmount,u),W(u))},[]),(0,o.useEffect)(()=>{d&&(K.setFieldValue(i.BridgeFormikValuesEnum.secondAmount,d),G(d))},[d]),(0,o.useEffect)(()=>{if(D)try{let e=D;Ke({transactions:y.map(t=>({...t,txHash:e,receiver:V})),provider:A?.provider??ue.ProviderType.None,url:ee.getApiURL()??``,token:w??``}),f?.([e])}catch(e){console.error(`Error while sending transactions:`,e),p?.(`An error occurred while sending the transaction`);return}finally{qe?.(),b([])}},[D,y,V,w,p,f,A?.provider,qe,Ke]),(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(`form`,{ref:Re,noValidate:!0,className:`liq-flex liq-flex-col liq-gap-1 liq-relative`,autoComplete:`off`,onSubmit:yt,children:[Ne&&(0,a.jsx)(ve.t,{mvxAddress:l,onClose:ht}),(0,a.jsxs)(ie.AmountCard,{className:ne.mxClsx(`liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6`,{"liq-pointer-events-none":g,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!g}),children:[(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-gap-1`,children:[(0,a.jsx)(`span`,{children:`From`}),(0,a.jsx)(Se.MvxAccountDisplay,{accountAddress:l,chainIcon:n.safeImageUrl(tt?.pngUrl),username:Oe,accountExplorerUrl:`${Ue.mvxExplorerAddress}/accounts/${l}`,showTag:!0,onDisconnect:Fe,onConnect:h})]}),X&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:X}),(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-between liq-gap-1`,children:[(0,a.jsx)(ae.AmountInput,{inputName:`firstAmount`,inputValue:K.values.firstAmount,amountError:St,disabled:!1,onInputDebounceChange:W,onInputChange:vt,onBlur:$}),(0,a.jsx)(we.TokenSelector,{name:`firstToken`,disabled:j,options:it,areOptionsLoading:k,isMvxSelector:dt,isDestination:!1,color:`neutral-850`,onChange:ot,onBlur:$,onMaxBtnClick:gt,selectedOption:N,onTokenSelectorDisplay:e=>ze(e)})]})]}),(0,a.jsx)(`div`,{className:`liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10`,children:We&&(0,a.jsx)(Ce.t,{onChangeDirection:lt})}),(0,a.jsxs)(ie.AmountCard,{className:ne.mxClsx(`liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6`,{"liq-pointer-events-none":g}),children:[(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-gap-1`,children:[(0,a.jsx)(`span`,{children:`To`}),(0,a.jsx)(xe.BridgeAccountDisplay,{disabled:j,activeChain:z})]}),Z&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:Z}),Q&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:Q}),(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-between liq-gap-1`,children:[(0,a.jsx)(ae.AmountInput,{inputName:`secondAmount`,inputValue:K.values.secondAmount,amountError:Ct,disabled:!1,onInputDebounceChange:G,onInputChange:vt,onBlur:$}),(0,a.jsx)(we.TokenSelector,{name:`secondToken`,disabled:j,omitDisableClass:!0,options:at,areOptionsLoading:k,isMvxSelector:ft,color:`neutral-850`,onChange:st,onBlur:$,selectedOption:P})]})]}),(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-justify-center`,children:[!l&&(0,a.jsx)(be.MvxConnectButton,{mvxAccountAddress:l,icon:n.safeImageUrl(tt?.pngUrl),onClick:h}),l&&!mt&&(0,a.jsx)(ye.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:j,activeChain:z}),l&&mt&&(0,a.jsxs)(re.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||j||!l||!V||xt,children:[H&&(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-center liq-items-center liq-gap-2`,children:[(0,a.jsx)(`div`,{children:`Transfer to `}),(0,a.jsx)(`img`,{src:n.safeImageUrl(z?.pngUrl),alt:``,className:`liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg`}),(0,a.jsx)(`div`,{children:z?.networkName})]}),!H&&(0,a.jsx)(`span`,{className:`liq-text-neutral-100`,children:`Enter amount`})]})]}),V&&_>0&&(0,a.jsx)(`div`,{className:`liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm`,children:(0,a.jsxs)(`div`,{children:[`You will be asked to sign `,_,` `,_>1?`transactions`:`transaction`,` `,`on your wallet`]})})]})})};exports.Transfer=l;
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunk-oiTVcehM.js"),t=require("../../../constants/index.js"),ee=require("../../../helpers/getApiURL.js"),n=require("../../../helpers/safeImageUrl.js"),te=require("../../../types/chainType.js");require("../../../helpers/index.js");const ne=require("../../utils/mxClsx.js"),re=require("../base/MxButton/MxButton.js");require("../base/index.js");const ie=require("../AmountCard/AmountCard.js");require("../AmountCard/index.js");const ae=require("../AmountInput/AmountInput.js");require("../AmountInput/index.js");const oe=require("../../hooks/useAccount.js"),se=require("../../context/useWeb3App.js"),ce=require("../../../types/providerType.js"),r=require("../../hooks/useBridgeFormik.js"),i=require("../../helpers/resolveBridgeApiChainId.js"),le=require("../../hooks/useBridgeApiChainId.js"),ue=require("../../../hooks-SJPsZfDx.js"),de=require("../../hooks/useGetChainId.js"),fe=require("../../hooks/useSendTransactions.js"),pe=require("./hooks/useBridgeTokenSelection.js"),me=require("../../hooks/useDisconnectOnChainTypeChange.js"),he=require("../../hooks/useNamespaceAddress.js"),ge=require("../../queries/useGetHistory.query.js"),_e=require("../../queries/useGetRate.mutation.js"),ve=require("../../../BridgeHistory-0NVr8Uxp.js");require("../BridgeHistory/index.js");const ye=require("../Connect/BridgeConnectButton.js"),be=require("../Connect/MvxConnectButton.js"),xe=require("../Connect/BridgeAccountDisplay.js"),Se=require("../Connect/MvxAccountDisplay.js");require("../Connect/index.js");const Ce=require("../../../ToggleDirection-CZ9-ZD7Y.js"),we=require("../TokenSelector/TokenSelector.js");require("../TokenSelector/index.js");let a=require("react/jsx-runtime"),o=require("react"),Te=require("@reown/appkit/react"),Ee=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),s=require("lodash/debounce");s=e.n(s);let De=require("react-toastify");var c,l=({mvxChainId:e,mvxAddress:l,username:Oe,callbackRoute:ke=`/`,firstTokenIdentifier:Ae,secondTokenIdentifier:je,firstTokenAmount:u,secondTokenAmount:d,refetchTrigger:Me,showHistory:Ne,forcedDestinationTokenSymbol:Pe,onSuccessfullySentTransaction:f,onFailedSentTransaction:p,onHistoryClose:m,onMvxConnect:h,onMvxDisconnect:Fe,onNavigate:Ie,onChangeDirection:Le})=>{let Re=(0,o.useRef)(null),[g,ze]=(0,o.useState)(!1),[Be,Ve]=(0,o.useState)(1),[_,v]=(0,o.useState)(0),[y,b]=(0,o.useState)([]),He=oe.useAccount(),{switchNetwork:x}=(0,Te.useAppKitNetwork)(),S=ge.useInvalidateHistoryQuery(),{options:Ue,supportedChains:C,nativeAuthToken:w,bridgeOnly:We}=se.useWeb3App(),T=de.useGetChainId(),Ge=le.useBridgeApiChainId(),Ke=fe.useSendTransactions(),{signMvxTransactions:E,resetMvxTransactionHash:qe,latestMvxTransactionHash:D}=se.useWeb3App(),{evmTokensWithBalances:Je,mvxTokensWithBalances:Ye,isTokensLoading:Xe,isLoadingEvmTokensBalances:Ze,isLoadingMvxTokensBalances:Qe,chains:O=[],isChainsLoading:$e}=ue.t({refetchTrigger:Me,mvxAddress:l,mvxApiURL:Ue.mvxApiURL}),k=Xe||Ze||Qe||$e,et=(0,o.useMemo)(()=>C.find(e=>i.sameBridgeApiChainId(e.id,T)),[T,C]),tt=(0,o.useMemo)(()=>O.find(t=>t.chainId.toString()===e.toString()),[T,O]),{mutate:nt,data:A,isPending:j,error:rt}=_e.useGetRateMutation(),M=rt?.response?.status===400?rt?.response?.data.message:void 0,{firstToken:N,secondToken:P,fromOptions:it,toOptions:at,selectedChainOption:F,onChangeFirstSelect:ot,onChangeSecondSelect:st,handleChangeDirection:ct}=pe.useBridgeTokenSelection({chains:O,activeChain:et,sdkChains:C,switchNetwork:(0,o.useCallback)(e=>{let t=C.find(t=>i.sameBridgeApiChainId(t.id,e.id));t&&x(t)},[C,x]),fromTokens:Ye,toTokens:Je,firstTokenIdentifier:Ae,secondTokenIdentifier:je,forcedDestinationTokenSymbol:Pe,isTokensLoading:k,mvxChainId:e,callbackRoute:ke,onNavigate:Ie}),lt=()=>{ct(),Le()},[I,ut]=(0,o.useState)(u??``),[L,R]=(0,o.useState)(d??``),dt=(0,o.useMemo)(()=>N?t.MVX_CHAIN_IDS.includes(N.chainId.toString()):!1,[N?.chainId]),ft=(0,o.useMemo)(()=>P?t.MVX_CHAIN_IDS.includes(P.chainId.toString()):!1,[P?.chainId]),z=(0,o.useMemo)(()=>P?O.find(e=>i.sameBridgeApiChainId(e.chainId,P.chainId))??F:F,[P?.chainId,O,F]),B=(0,o.useMemo)(()=>i.toBridgeApiChainId(P?.chainId)??Ge,[P?.chainId,Ge]);me.useDisconnectOnChainTypeChange(z?.chainType);let V=he.useNamespaceAddress(z?.chainType),pt=V,mt=He.isConnected&&!!V,H=I!==``&&L!==``,U=(0,o.useCallback)((0,s.default)(async t=>{!t||!Number(t)||!V||!N?.address||!P?.address||!F||!B||nt({nativeAuthToken:w??``,body:{tokenIn:N.address,amountIn:t,fromChainId:e,tokenOut:P.address,toChainId:B}})},500),[V,B,N?.address,P?.address,F,e,w,nt]),W=(0,o.useCallback)(e=>{ut(()=>e)},[]),G=(0,o.useCallback)(e=>{R(()=>e)},[]),ht=(0,o.useCallback)(()=>{m?.()},[m]),gt=(0,o.useCallback)(()=>{let e=(0,Ee.formatAmount)({decimals:N?.decimals,input:N?.balance??`0`,addCommas:!1,digits:4});K.setFieldValue(`firstAmount`,e),W(e)},[N?.balance,N?.decimals,W]),_t=(0,o.useCallback)(async({transactions:e})=>{v(()=>e.length);try{if(!E)throw Error(`signMvxTransactions function is not provided`);await E(e),b(e)}catch(e){console.error(e),De.toast.dismiss(),De.toast.error(`Transaction cancelled`),p?.(`Transaction cancelled`),v(0),bt(),W(``),G(``)}},[pt,W,G,w,(0,o.useCallback)(async e=>{W(``),G(``),S(),S(),f?.(e)},[W,G,f]),E]),{formik:K,firstAmountError:q,secondAmountError:J,fromChainError:Y,senderAddressError:X,receiverAddressError:Z,confirmRateError:Q,handleBlur:$,handleChange:vt,handleSubmit:yt,resetSwapForm:bt}=r.useBridgeFormik({isMvxConnected:!!l,rate:A,sender:l??``,receiver:V??``,firstToken:N,firstAmount:I,fromChainId:e,toChainId:B,secondToken:P,secondAmount:L,setForceRefetchRate:Ve,senderChainType:te.ChainType.mvx,receiverChainType:z?.chainType,onSubmit:_t}),xt=!!(q||J||Y||M||X||Z||Q),St=(0,o.useMemo)(()=>I===``?void 0:M??q,[q,I,M]),Ct=(0,o.useMemo)(()=>L===``?void 0:Y??J,[Y,J,L]);return(0,o.useEffect)(()=>(I||R(``),U(I),c&&clearInterval(c),c=setInterval(()=>{U(I)},50*1e3),()=>clearInterval(c)),[I,Be,U]),(0,o.useEffect)(()=>{A?.amountOut&&(K.setFieldValue(r.BridgeFormikValuesEnum.secondAmount,A.amountOut),R(A.amountOut))},[A?.amountOut]),(0,o.useEffect)(()=>{M&&(K.setFieldValue(r.BridgeFormikValuesEnum.secondAmount,`0`),R(`0`))},[M]),(0,o.useEffect)(()=>{u&&(K.setFieldValue(r.BridgeFormikValuesEnum.firstAmount,u),W(u))},[]),(0,o.useEffect)(()=>{d&&(K.setFieldValue(r.BridgeFormikValuesEnum.secondAmount,d),G(d))},[d]),(0,o.useEffect)(()=>{if(D)try{let e=D;Ke({transactions:y.map(t=>({...t,txHash:e,receiver:V})),provider:A?.provider??ce.ProviderType.None,url:ee.getApiURL()??``,token:w??``}),f?.([e])}catch(e){console.error(`Error while sending transactions:`,e),p?.(`An error occurred while sending the transaction`);return}finally{qe?.(),b([])}},[D,y,V,w,p,f,A?.provider,qe,Ke]),(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(`form`,{ref:Re,noValidate:!0,className:`liq-flex liq-flex-col liq-gap-1 liq-relative`,autoComplete:`off`,onSubmit:yt,children:[Ne&&(0,a.jsx)(ve.t,{mvxAddress:l,onClose:ht}),(0,a.jsxs)(ie.AmountCard,{className:ne.mxClsx(`liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6`,{"liq-pointer-events-none":g,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!g}),children:[(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-gap-1`,children:[(0,a.jsx)(`span`,{children:`From`}),(0,a.jsx)(Se.MvxAccountDisplay,{accountAddress:l,chainIcon:n.safeImageUrl(tt?.pngUrl),username:Oe,accountExplorerUrl:`${Ue.mvxExplorerAddress}/accounts/${l}`,showTag:!0,onDisconnect:Fe,onConnect:h})]}),X&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:X}),(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-between liq-gap-1`,children:[(0,a.jsx)(ae.AmountInput,{inputName:`firstAmount`,inputValue:K.values.firstAmount,amountError:St,disabled:!1,onInputDebounceChange:W,onInputChange:vt,onBlur:$}),(0,a.jsx)(we.TokenSelector,{name:`firstToken`,disabled:j,options:it,areOptionsLoading:k,isMvxSelector:dt,isDestination:!1,color:`neutral-850`,onChange:ot,onBlur:$,onMaxBtnClick:gt,selectedOption:N,onTokenSelectorDisplay:e=>ze(e)})]})]}),(0,a.jsx)(`div`,{className:`liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10`,children:We&&(0,a.jsx)(Ce.t,{onChangeDirection:lt})}),(0,a.jsxs)(ie.AmountCard,{className:ne.mxClsx(`liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6`,{"liq-pointer-events-none":g}),children:[(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-gap-1`,children:[(0,a.jsx)(`span`,{children:`To`}),(0,a.jsx)(xe.BridgeAccountDisplay,{disabled:j,activeChain:z})]}),Z&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:Z}),Q&&(0,a.jsx)(`div`,{className:`liq-text-red-400 liq-text-xs liq-mt-1`,children:Q}),(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-between liq-gap-1`,children:[(0,a.jsx)(ae.AmountInput,{inputName:`secondAmount`,inputValue:K.values.secondAmount,amountError:Ct,disabled:!1,onInputDebounceChange:G,onInputChange:vt,onBlur:$}),(0,a.jsx)(we.TokenSelector,{name:`secondToken`,disabled:j,omitDisableClass:!0,options:at,areOptionsLoading:k,isMvxSelector:ft,color:`neutral-850`,onChange:st,onBlur:$,selectedOption:P})]})]}),(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-justify-center`,children:[!l&&(0,a.jsx)(be.MvxConnectButton,{mvxAccountAddress:l,icon:n.safeImageUrl(tt?.pngUrl),onClick:h}),l&&!mt&&(0,a.jsx)(ye.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:j,activeChain:z}),l&&mt&&(0,a.jsxs)(re.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||j||!l||!V||xt,children:[H&&(0,a.jsxs)(`div`,{className:`liq-flex liq-justify-center liq-items-center liq-gap-2`,children:[(0,a.jsx)(`div`,{children:`Transfer to `}),(0,a.jsx)(`img`,{src:n.safeImageUrl(z?.pngUrl),alt:``,className:`liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg`}),(0,a.jsx)(`div`,{children:z?.networkName})]}),!H&&(0,a.jsx)(`span`,{className:`liq-text-neutral-100`,children:`Enter amount`})]})]}),V&&_>0&&(0,a.jsx)(`div`,{className:`liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm`,children:(0,a.jsxs)(`div`,{children:[`You will be asked to sign `,_,` `,_>1?`transactions`:`transaction`,` `,`on your wallet`]})})]})})};exports.Transfer=l;
|
|
@@ -10,21 +10,21 @@ import { AmountCard as re } from "../AmountCard/AmountCard.mjs";
|
|
|
10
10
|
import "../AmountCard/index.mjs";
|
|
11
11
|
import { AmountInput as ie } from "../AmountInput/AmountInput.mjs";
|
|
12
12
|
import "../AmountInput/index.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
13
|
+
import { useAccount as ae } from "../../hooks/useAccount.mjs";
|
|
14
|
+
import { useWeb3App as oe } from "../../context/useWeb3App.mjs";
|
|
15
|
+
import { ProviderType as se } from "../../../types/providerType.mjs";
|
|
16
|
+
import { BridgeFormikValuesEnum as r, useBridgeFormik as ce } from "../../hooks/useBridgeFormik.mjs";
|
|
17
|
+
import { sameBridgeApiChainId as i, toBridgeApiChainId as le } from "../../helpers/resolveBridgeApiChainId.mjs";
|
|
18
|
+
import { useBridgeApiChainId as ue } from "../../hooks/useBridgeApiChainId.mjs";
|
|
19
|
+
import { t as de } from "../../../hooks-DMIHvAKb.mjs";
|
|
20
|
+
import { useGetChainId as fe } from "../../hooks/useGetChainId.mjs";
|
|
21
|
+
import { useSendTransactions as pe } from "../../hooks/useSendTransactions.mjs";
|
|
22
|
+
import { useBridgeTokenSelection as me } from "./hooks/useBridgeTokenSelection.mjs";
|
|
23
|
+
import { useDisconnectOnChainTypeChange as he } from "../../hooks/useDisconnectOnChainTypeChange.mjs";
|
|
24
24
|
import { useNamespaceAddress as ge } from "../../hooks/useNamespaceAddress.mjs";
|
|
25
25
|
import { useInvalidateHistoryQuery as _e } from "../../queries/useGetHistory.query.mjs";
|
|
26
26
|
import { useGetRateMutation as ve } from "../../queries/useGetRate.mutation.mjs";
|
|
27
|
-
import { t as ye } from "../../../BridgeHistory-
|
|
27
|
+
import { t as ye } from "../../../BridgeHistory-BUSiuT1d.mjs";
|
|
28
28
|
import "../BridgeHistory/index.mjs";
|
|
29
29
|
import { BridgeConnectButton as be } from "../Connect/BridgeConnectButton.mjs";
|
|
30
30
|
import { MvxConnectButton as xe } from "../Connect/MvxConnectButton.mjs";
|
|
@@ -36,43 +36,43 @@ import { TokenSelector as Te } from "../TokenSelector/TokenSelector.mjs";
|
|
|
36
36
|
import "../TokenSelector/index.mjs";
|
|
37
37
|
import { Fragment as Ee, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
38
38
|
import { useCallback as s, useEffect as c, useMemo as l, useRef as De, useState as u } from "react";
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
39
|
+
import { useAppKitNetwork as Oe } from "@reown/appkit/react";
|
|
40
|
+
import { formatAmount as ke } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
41
41
|
import Ae from "lodash/debounce";
|
|
42
42
|
import { toast as je } from "react-toastify";
|
|
43
43
|
//#region src/reactjs/components/BridgeForm/Transfer.tsx
|
|
44
44
|
var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/", firstTokenIdentifier: Pe, secondTokenIdentifier: Fe, firstTokenAmount: m, secondTokenAmount: h, refetchTrigger: Ie, showHistory: Le, forcedDestinationTokenSymbol: Re, onSuccessfullySentTransaction: g, onFailedSentTransaction: _, onHistoryClose: v, onMvxConnect: ze, onMvxDisconnect: Be, onNavigate: Ve, onChangeDirection: He }) => {
|
|
45
|
-
let Ue = De(null), [y, We] = u(!1), [Ge, Ke] = u(1), [b, qe] = u(0), [Je, Ye] = u([]), Xe =
|
|
45
|
+
let Ue = De(null), [y, We] = u(!1), [Ge, Ke] = u(1), [b, qe] = u(0), [Je, Ye] = u([]), Xe = ae(), { switchNetwork: Ze } = Oe(), Qe = _e(), { options: $e, supportedChains: x, nativeAuthToken: S, bridgeOnly: et } = oe(), C = fe(), tt = ue(), nt = pe(), { signMvxTransactions: w, resetMvxTransactionHash: T, latestMvxTransactionHash: E } = oe(), { evmTokensWithBalances: rt, mvxTokensWithBalances: it, isTokensLoading: at, isLoadingEvmTokensBalances: ot, isLoadingMvxTokensBalances: st, chains: D = [], isChainsLoading: ct } = de({
|
|
46
46
|
refetchTrigger: Ie,
|
|
47
47
|
mvxAddress: p,
|
|
48
48
|
mvxApiURL: $e.mvxApiURL
|
|
49
|
-
}),
|
|
50
|
-
chains:
|
|
51
|
-
activeChain:
|
|
49
|
+
}), O = at || ot || st || ct, lt = l(() => x.find((e) => i(e.id, C)), [C, x]), ut = l(() => D.find((e) => e.chainId.toString() === f.toString()), [C, D]), { mutate: dt, data: k, isPending: A, error: ft } = ve(), j = ft?.response?.status === 400 ? ft?.response?.data.message : void 0, { firstToken: M, secondToken: N, fromOptions: pt, toOptions: mt, selectedChainOption: P, onChangeFirstSelect: ht, onChangeSecondSelect: gt, handleChangeDirection: _t } = me({
|
|
50
|
+
chains: D,
|
|
51
|
+
activeChain: lt,
|
|
52
52
|
sdkChains: x,
|
|
53
53
|
switchNetwork: s((e) => {
|
|
54
|
-
let t = x.find((t) =>
|
|
54
|
+
let t = x.find((t) => i(t.id, e.id));
|
|
55
55
|
t && Ze(t);
|
|
56
56
|
}, [x, Ze]),
|
|
57
|
-
fromTokens:
|
|
58
|
-
toTokens:
|
|
57
|
+
fromTokens: it,
|
|
58
|
+
toTokens: rt,
|
|
59
59
|
firstTokenIdentifier: Pe,
|
|
60
60
|
secondTokenIdentifier: Fe,
|
|
61
61
|
forcedDestinationTokenSymbol: Re,
|
|
62
|
-
isTokensLoading:
|
|
62
|
+
isTokensLoading: O,
|
|
63
63
|
mvxChainId: f,
|
|
64
64
|
callbackRoute: Ne,
|
|
65
65
|
onNavigate: Ve
|
|
66
66
|
}), vt = () => {
|
|
67
67
|
_t(), He();
|
|
68
|
-
}, [F, yt] = u(m ?? ""), [I, L] = u(h ?? ""), bt = l(() => M ? e.includes(M.chainId.toString()) : !1, [M?.chainId]), xt = l(() => N ? e.includes(N.chainId.toString()) : !1, [N?.chainId]), R = l(() => N ?
|
|
68
|
+
}, [F, yt] = u(m ?? ""), [I, L] = u(h ?? ""), bt = l(() => M ? e.includes(M.chainId.toString()) : !1, [M?.chainId]), xt = l(() => N ? e.includes(N.chainId.toString()) : !1, [N?.chainId]), R = l(() => N ? D.find((e) => i(e.chainId, N.chainId)) ?? P : P, [
|
|
69
69
|
N?.chainId,
|
|
70
|
-
|
|
70
|
+
D,
|
|
71
71
|
P
|
|
72
|
-
]), z = l(() =>
|
|
73
|
-
|
|
72
|
+
]), z = l(() => le(N?.chainId) ?? tt, [N?.chainId, tt]);
|
|
73
|
+
he(R?.chainType);
|
|
74
74
|
let B = ge(R?.chainType), St = B, Ct = Xe.isConnected && !!B, V = F !== "" && I !== "", H = s(Ae(async (e) => {
|
|
75
|
-
!e || !Number(e) || !B || !M?.address || !N?.address || !P || !z ||
|
|
75
|
+
!e || !Number(e) || !B || !M?.address || !N?.address || !P || !z || dt({
|
|
76
76
|
nativeAuthToken: S ?? "",
|
|
77
77
|
body: {
|
|
78
78
|
tokenIn: M.address,
|
|
@@ -90,7 +90,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
90
90
|
P,
|
|
91
91
|
f,
|
|
92
92
|
S,
|
|
93
|
-
|
|
93
|
+
dt
|
|
94
94
|
]), U = s((e) => {
|
|
95
95
|
yt(() => e);
|
|
96
96
|
}, []), W = s((e) => {
|
|
@@ -98,7 +98,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
98
98
|
}, []), wt = s(() => {
|
|
99
99
|
v?.();
|
|
100
100
|
}, [v]), Tt = s(() => {
|
|
101
|
-
let e =
|
|
101
|
+
let e = ke({
|
|
102
102
|
decimals: M?.decimals,
|
|
103
103
|
input: M?.balance ?? "0",
|
|
104
104
|
addCommas: !1,
|
|
@@ -130,7 +130,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
130
130
|
g
|
|
131
131
|
]),
|
|
132
132
|
w
|
|
133
|
-
]), { formik: G, firstAmountError: K, secondAmountError: q, fromChainError: J, senderAddressError: Y, receiverAddressError: X, confirmRateError: Z, handleBlur: Q, handleChange: $, handleSubmit: Dt, resetSwapForm: Ot } =
|
|
133
|
+
]), { formik: G, firstAmountError: K, secondAmountError: q, fromChainError: J, senderAddressError: Y, receiverAddressError: X, confirmRateError: Z, handleBlur: Q, handleChange: $, handleSubmit: Dt, resetSwapForm: Ot } = ce({
|
|
134
134
|
isMvxConnected: !!p,
|
|
135
135
|
rate: k,
|
|
136
136
|
sender: p ?? "",
|
|
@@ -161,23 +161,23 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
161
161
|
Ge,
|
|
162
162
|
H
|
|
163
163
|
]), c(() => {
|
|
164
|
-
k?.amountOut && (G.setFieldValue(
|
|
164
|
+
k?.amountOut && (G.setFieldValue(r.secondAmount, k.amountOut), L(k.amountOut));
|
|
165
165
|
}, [k?.amountOut]), c(() => {
|
|
166
|
-
j && (G.setFieldValue(
|
|
166
|
+
j && (G.setFieldValue(r.secondAmount, "0"), L("0"));
|
|
167
167
|
}, [j]), c(() => {
|
|
168
|
-
m && (G.setFieldValue(
|
|
168
|
+
m && (G.setFieldValue(r.firstAmount, m), U(m));
|
|
169
169
|
}, []), c(() => {
|
|
170
|
-
h && (G.setFieldValue(
|
|
170
|
+
h && (G.setFieldValue(r.secondAmount, h), W(h));
|
|
171
171
|
}, [h]), c(() => {
|
|
172
|
-
if (
|
|
173
|
-
let e =
|
|
172
|
+
if (E) try {
|
|
173
|
+
let e = E;
|
|
174
174
|
nt({
|
|
175
175
|
transactions: Je.map((t) => ({
|
|
176
176
|
...t,
|
|
177
177
|
txHash: e,
|
|
178
178
|
receiver: B
|
|
179
179
|
})),
|
|
180
|
-
provider: k?.provider ??
|
|
180
|
+
provider: k?.provider ?? se.None,
|
|
181
181
|
url: t() ?? "",
|
|
182
182
|
token: S ?? ""
|
|
183
183
|
}), g?.([e]);
|
|
@@ -185,17 +185,17 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
185
185
|
console.error("Error while sending transactions:", e), _?.("An error occurred while sending the transaction");
|
|
186
186
|
return;
|
|
187
187
|
} finally {
|
|
188
|
-
|
|
188
|
+
T?.(), Ye([]);
|
|
189
189
|
}
|
|
190
190
|
}, [
|
|
191
|
-
|
|
191
|
+
E,
|
|
192
192
|
Je,
|
|
193
193
|
B,
|
|
194
194
|
S,
|
|
195
195
|
_,
|
|
196
196
|
g,
|
|
197
197
|
k?.provider,
|
|
198
|
-
|
|
198
|
+
T,
|
|
199
199
|
nt
|
|
200
200
|
]), /* @__PURE__ */ a(Ee, { children: /* @__PURE__ */ o("form", {
|
|
201
201
|
ref: Ue,
|
|
@@ -218,7 +218,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
218
218
|
className: "liq-flex liq-items-center liq-gap-1",
|
|
219
219
|
children: [/* @__PURE__ */ a("span", { children: "From" }), /* @__PURE__ */ a(Ce, {
|
|
220
220
|
accountAddress: p,
|
|
221
|
-
chainIcon: n(
|
|
221
|
+
chainIcon: n(ut?.pngUrl),
|
|
222
222
|
username: Me,
|
|
223
223
|
accountExplorerUrl: `${$e.mvxExplorerAddress}/accounts/${p}`,
|
|
224
224
|
showTag: !0,
|
|
@@ -244,7 +244,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
244
244
|
name: "firstToken",
|
|
245
245
|
disabled: A,
|
|
246
246
|
options: pt,
|
|
247
|
-
areOptionsLoading:
|
|
247
|
+
areOptionsLoading: O,
|
|
248
248
|
isMvxSelector: bt,
|
|
249
249
|
isDestination: !1,
|
|
250
250
|
color: "neutral-850",
|
|
@@ -294,7 +294,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
294
294
|
disabled: A,
|
|
295
295
|
omitDisableClass: !0,
|
|
296
296
|
options: mt,
|
|
297
|
-
areOptionsLoading:
|
|
297
|
+
areOptionsLoading: O,
|
|
298
298
|
isMvxSelector: xt,
|
|
299
299
|
color: "neutral-850",
|
|
300
300
|
onChange: gt,
|
|
@@ -309,7 +309,7 @@ var d, f = ({ mvxChainId: f, mvxAddress: p, username: Me, callbackRoute: Ne = "/
|
|
|
309
309
|
children: [
|
|
310
310
|
!p && /* @__PURE__ */ a(xe, {
|
|
311
311
|
mvxAccountAddress: p,
|
|
312
|
-
icon: n(
|
|
312
|
+
icon: n(ut?.pngUrl),
|
|
313
313
|
onClick: ze
|
|
314
314
|
}),
|
|
315
315
|
p && !Ct && /* @__PURE__ */ a(be, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../helpers/resolveBridgeApiChainId.js"),t=require("../../../utils/getInitialTokens.js"),n=require("../utils/bridgeFormHelpers.js");let r=require("react");var i=({chains:i,firstTokenIdentifier:a,secondTokenIdentifier:o,fromTokens:s,toTokens:c,isTokensLoading:l,activeChainId:u,mvxChainId:d,callbackRoute:f,forcedDestinationTokenSymbol:p,onNavigate:m,switchNetwork:h,sdkChains:g,activeChain:_})=>{let v=(0,r.useRef)(!1),[y,b]=(0,r.useState)(),[x,S]=(0,r.useState)(),C=(0,r.useMemo)(()=>s?.filter(e=>d?e.chainId.toString().toLowerCase()===d.toString().toLowerCase():!0).map(e=>({...e,identifier:e.address,ticker:e.symbol}))??[],[s,d]),w=(0,r.useCallback)(e=>n.getAvailableTokens(e,c,p),[c,p]),T=(0,r.useMemo)(()=>y?c?.filter(e=>e.symbol.toLowerCase()===y.symbol.toLowerCase()).map(e=>({...e,identifier:e.address,ticker:e.symbol}))??[]:[],[y?.symbol,c]),E=(0,r.useMemo)(()=>{let t=d?x:y;return t&&i?.find(n=>e.sameBridgeApiChainId(n.chainId,t.chainId))||i?.find(t=>e.sameBridgeApiChainId(t.chainId,_?.id))||((d?y&&i?.find(t=>e.sameBridgeApiChainId(t.chainId,y.chainId)):x&&i?.find(t=>e.sameBridgeApiChainId(t.chainId,x.chainId)))??i?.[0])},[_?.id,i,y?.chainId,d,x?.chainId]),D=(0,r.useCallback)(e=>n.getDefaultReceivingToken(e,c),[c]),O=(0,r.useCallback)(({firstTokenId:e,secondTokenId:t})=>{n.updateUrlParams({firstTokenId:e,secondTokenId:t,callbackRoute:f,isTokensLoading:l,onNavigate:m})},[f,l,m]),k=(0,r.useCallback)(e=>{if(!e)return;b(e),O({firstTokenId:e.address});let t=c?.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase());if(!t){let n=w(e);t=n.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase())??D(n)}t&&(S(t),O({secondTokenId:t.address}))},[w,D,O,c]),A=(0,r.useCallback)(e=>{if(!e)return;S(e),O({secondTokenId:e.address});let t=C.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase());t&&(b(t),O({firstTokenId:t.address}))},[C,O]),j=(0,r.useCallback)(()=>{if(!y||!x)return;b(x),S(y),O({firstTokenId:x.address,secondTokenId:y.address});let t=g?.find(t=>e.sameBridgeApiChainId(t.id,x.chainId));t&&h&&h(t)},[y,x,O,g,h]);return(0,r.useEffect)(()=>{if(l||v.current||!C.length)return;if(y&&x){v.current=!0;return}let n=t.getInitialTokens({firstTokenId:a,secondTokenId:o}),r=C.find(({identifier:e})=>n?.firstTokenId===e)??C.find(t=>e.sameBridgeApiChainId(t.chainId,u))??C[0],i=c?.find(e=>e.symbol.toLowerCase()===r?.symbol.toLowerCase());if(!i){let e=w(r);i=e?.find(({address:e})=>e.toLowerCase()===(r?.symbol??n?.secondTokenId)?.toLowerCase())??e.find(e=>e.symbol.toLowerCase()===r?.symbol.toLowerCase())??D(e)}if(y&&x&&y?.address?.toLowerCase()===r?.address?.toLowerCase()&&x?.address?.toLowerCase()===i?.address?.toLowerCase())return;let s=!1;if(r){b(r),O({firstTokenId:r.address});let t=g?.find(t=>e.sameBridgeApiChainId(t.id,r.chainId))??_;t&&h&&h(t),s=!0}i&&(S(i),O({secondTokenId:i.address}),s&&=!0),v.current=s},[l,C,c,a,o,u,w,D,O,g,_,h]),(0,r.useEffect)(()=>{let e=s?.find(e=>e.address===y?.address);e&&b(t=>t&&{...t,balance:e.balance})},[s,y?.address]),(0,r.useEffect)(()=>{let e=c?.find(e=>e.address===x?.address);e&&S(t=>t&&{...t,balance:e.balance})},[c,x?.address]),{firstToken:y,secondToken:x,fromOptions:C,toOptions:T,selectedChainOption:E,setFirstToken:b,setSecondToken:S,onChangeFirstSelect:k,onChangeSecondSelect:A,handleChangeDirection:j,updateUrlParams:O}};exports.useBridgeTokenSelection=i;
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../helpers/resolveBridgeApiChainId.js"),t=require("../../../utils/getInitialTokens.js"),n=require("../utils/bridgeFormHelpers.js");let r=require("react");var i=({chains:i,firstTokenIdentifier:a,secondTokenIdentifier:o,fromTokens:s,toTokens:c,isTokensLoading:l,activeChainId:u,mvxChainId:d,callbackRoute:f,forcedDestinationTokenSymbol:p,onNavigate:m,switchNetwork:h,sdkChains:g,activeChain:_})=>{let v=(0,r.useRef)(!1),[y,b]=(0,r.useState)(),[x,S]=(0,r.useState)(),C=(0,r.useMemo)(()=>s?.filter(e=>d?e.chainId.toString().toLowerCase()===d.toString().toLowerCase():!0).map(e=>({...e,identifier:e.address,ticker:e.symbol}))??[],[s,d]),w=(0,r.useCallback)(e=>n.getAvailableTokens(e,c,p),[c,p]),T=(0,r.useMemo)(()=>y?c?.filter(e=>e.symbol.toLowerCase()===y.symbol.toLowerCase()).map(e=>({...e,identifier:e.address,ticker:e.symbol}))??[]:[],[y?.symbol,c]),E=(0,r.useMemo)(()=>{let t=d?x:y;return t&&i?.find(n=>e.sameBridgeApiChainId(n.chainId,t.chainId))||i?.find(t=>e.sameBridgeApiChainId(t.chainId,_?.id))||((d?y&&i?.find(t=>e.sameBridgeApiChainId(t.chainId,y.chainId)):x&&i?.find(t=>e.sameBridgeApiChainId(t.chainId,x.chainId)))??i?.[0])},[_?.id,i,y?.chainId,d,x?.chainId]),D=(0,r.useCallback)(e=>n.getDefaultReceivingToken(e,c),[c]),O=(0,r.useCallback)(({firstTokenId:e,secondTokenId:t})=>{n.updateUrlParams({firstTokenId:e,secondTokenId:t,callbackRoute:f,isTokensLoading:l,onNavigate:m})},[f,l,m]),k=(0,r.useCallback)(e=>{if(!e)return;b(e),O({firstTokenId:e.address});let t=c?.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase());if(!t){let n=w(e);t=n.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase())??D(n)}t&&(S(t),O({secondTokenId:t.address}))},[w,D,O,c]),A=(0,r.useCallback)(e=>{if(!e)return;S(e),O({secondTokenId:e.address});let t=C.find(t=>t.symbol.toLowerCase()===e.symbol.toLowerCase());t&&(b(t),O({firstTokenId:t.address}))},[C,O]),j=(0,r.useCallback)(()=>{if(!y||!x)return;b(x),S(y),O({firstTokenId:x.address,secondTokenId:y.address});let t=g?.find(t=>e.sameBridgeApiChainId(t.id,x.chainId));t&&h&&h(t)},[y,x,O,g,h]);return(0,r.useEffect)(()=>{if(l||v.current||!C.length)return;if(y&&x){v.current=!0;return}let n=t.getInitialTokens({firstTokenId:a,secondTokenId:o}),r=C.find(({identifier:e})=>n?.firstTokenId?.toLowerCase()===e.toLowerCase())??C.find(t=>e.sameBridgeApiChainId(t.chainId,u))??C[0],i=c?.find(e=>e.symbol.toLowerCase()===r?.symbol.toLowerCase());if(!i){let e=w(r);i=e?.find(({address:e})=>e.toLowerCase()===(r?.symbol??n?.secondTokenId)?.toLowerCase())??e.find(e=>e.symbol.toLowerCase()===r?.symbol.toLowerCase())??D(e)}if(y&&x&&y?.address?.toLowerCase()===r?.address?.toLowerCase()&&x?.address?.toLowerCase()===i?.address?.toLowerCase())return;let s=!1;if(r){b(r),O({firstTokenId:r.address});let t=g?.find(t=>e.sameBridgeApiChainId(t.id,r.chainId))??_;t&&h&&h(t),s=!0}i&&(S(i),O({secondTokenId:i.address}),s&&=!0),v.current=s},[l,C,c,a,o,u,w,D,O,g,_,h]),(0,r.useEffect)(()=>{let e=s?.find(e=>e.address.toLowerCase()===y?.address?.toLowerCase());e&&b(t=>t&&{...t,balance:e.balance})},[s,y?.address]),(0,r.useEffect)(()=>{let e=c?.find(e=>e.address.toLowerCase()===x?.address?.toLowerCase());e&&S(t=>t&&{...t,balance:e.balance})},[c,x?.address]),{firstToken:y,secondToken:x,fromOptions:C,toOptions:T,selectedChainOption:E,setFirstToken:b,setSecondToken:S,onChangeFirstSelect:k,onChangeSecondSelect:A,handleChangeDirection:j,updateUrlParams:O}};exports.useBridgeTokenSelection=i;
|
|
@@ -76,7 +76,7 @@ var u = ({ chains: u, firstTokenIdentifier: d, secondTokenIdentifier: f, fromTok
|
|
|
76
76
|
let n = t({
|
|
77
77
|
firstTokenId: d,
|
|
78
78
|
secondTokenId: f
|
|
79
|
-
}), r = k.find(({ identifier: e }) => n?.firstTokenId === e) ?? k.find((t) => e(t.chainId, g)) ?? k[0], i = m?.find((e) => e.symbol.toLowerCase() === r?.symbol.toLowerCase());
|
|
79
|
+
}), r = k.find(({ identifier: e }) => n?.firstTokenId?.toLowerCase() === e.toLowerCase()) ?? k.find((t) => e(t.chainId, g)) ?? k[0], i = m?.find((e) => e.symbol.toLowerCase() === r?.symbol.toLowerCase());
|
|
80
80
|
if (!i) {
|
|
81
81
|
let e = A(r);
|
|
82
82
|
i = e?.find(({ address: e }) => e.toLowerCase() === (r?.symbol ?? n?.secondTokenId)?.toLowerCase()) ?? e.find((e) => e.symbol.toLowerCase() === r?.symbol.toLowerCase()) ?? N(e);
|
|
@@ -103,13 +103,13 @@ var u = ({ chains: u, firstTokenIdentifier: d, secondTokenIdentifier: f, fromTok
|
|
|
103
103
|
C,
|
|
104
104
|
x
|
|
105
105
|
]), o(() => {
|
|
106
|
-
let e = p?.find((e) => e.address === T?.address);
|
|
106
|
+
let e = p?.find((e) => e.address.toLowerCase() === T?.address?.toLowerCase());
|
|
107
107
|
e && E((t) => t && {
|
|
108
108
|
...t,
|
|
109
109
|
balance: e.balance
|
|
110
110
|
});
|
|
111
111
|
}, [p, T?.address]), o(() => {
|
|
112
|
-
let e = m?.find((e) => e.address === D?.address);
|
|
112
|
+
let e = m?.find((e) => e.address.toLowerCase() === D?.address?.toLowerCase());
|
|
113
113
|
e && O((t) => t && {
|
|
114
114
|
...t,
|
|
115
115
|
balance: e.balance
|
|
@@ -19,3 +19,5 @@ export declare const getAvailableTokens: (option: TokenType, targetTokens?: Toke
|
|
|
19
19
|
* Gets the default receiving token (prefers USDC)
|
|
20
20
|
*/
|
|
21
21
|
export declare const getDefaultReceivingToken: (values: TokenType[], fallbackTokens?: TokenType[]) => TokenType | undefined;
|
|
22
|
+
/** True when `tokenId` matches a token in the MVX list (compared by address). */
|
|
23
|
+
export declare const isTokenIdFromMvx: (tokenId: string | undefined, mvxTokens: TokenType[] | undefined) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../constants/index.js"),t=require("../../../../types/chainType.js"),n=require("../../../utils/getCompletePathname.js");var r=({firstTokenId:t,secondTokenId:r,callbackRoute:i,isTokensLoading:a,onNavigate:o})=>{if(a)return;let s=n.getCompletePathname(),c=new URLSearchParams(e.safeWindow.location.search);t&&c.set(`firstToken`,t),r&&c.set(`secondToken`,r);let l=`${i}?${c.toString()}`;s!==l&&(e.safeWindow.history?.replaceState?.(null,``,l),o?.(l,{replace:!0}))};function i(e,n){return e.suiParams?.transactionBytes&&e.suiParams?.sender?t.ChainType.sui:e.instructions&&e.feePayer?t.ChainType.sol:e.bitcoinParams?t.ChainType.btc:e.to&&e.data!==void 0?t.ChainType.evm:n?.chainType}var a=(e,t,n)=>{if(n){let e=t?.find(e=>e.symbol.toLowerCase()===n.toLowerCase());return e?[e]:[]}if(!e?.availableTokens)return[];let r=[];for(let n of e.availableTokens){let e=t?.find(e=>e.address.toLowerCase()===n.address.toLowerCase());e&&r.push(e)}return r},o=(e,t)=>e.find(e=>e.symbol.toLowerCase().includes(`usdc`))??t?.find(e=>e.symbol.toLowerCase().includes(`usdc`));exports.getAvailableTokens=a,exports.getDefaultReceivingToken=o,exports.resolveSigningChainType=i,exports.updateUrlParams=r;
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../constants/index.js"),t=require("../../../../types/chainType.js"),n=require("../../../utils/getCompletePathname.js");var r=({firstTokenId:t,secondTokenId:r,callbackRoute:i,isTokensLoading:a,onNavigate:o})=>{if(a)return;let s=n.getCompletePathname(),c=new URLSearchParams(e.safeWindow.location.search);t&&c.set(`firstToken`,t),r&&c.set(`secondToken`,r);let l=`${i}?${c.toString()}`;s!==l&&(e.safeWindow.history?.replaceState?.(null,``,l),o?.(l,{replace:!0}))};function i(e,n){return e.suiParams?.transactionBytes&&e.suiParams?.sender?t.ChainType.sui:e.instructions&&e.feePayer?t.ChainType.sol:e.bitcoinParams?t.ChainType.btc:e.to&&e.data!==void 0?t.ChainType.evm:n?.chainType}var a=(e,t,n)=>{if(n){let e=t?.find(e=>e.symbol.toLowerCase()===n.toLowerCase());return e?[e]:[]}if(!e?.availableTokens)return[];let r=[];for(let n of e.availableTokens){let e=t?.find(e=>e.address.toLowerCase()===n.address.toLowerCase());e&&r.push(e)}return r},o=(e,t)=>e.find(e=>e.symbol.toLowerCase().includes(`usdc`))??t?.find(e=>e.symbol.toLowerCase().includes(`usdc`)),s=(e,t)=>e?!!t?.some(t=>t.address.toLowerCase()===e.toLowerCase()):!1;exports.getAvailableTokens=a,exports.getDefaultReceivingToken=o,exports.isTokenIdFromMvx=s,exports.resolveSigningChainType=i,exports.updateUrlParams=r;
|
|
@@ -24,6 +24,6 @@ var a = (e, t, n) => {
|
|
|
24
24
|
e && r.push(e);
|
|
25
25
|
}
|
|
26
26
|
return r;
|
|
27
|
-
}, o = (e, t) => e.find((e) => e.symbol.toLowerCase().includes("usdc")) ?? t?.find((e) => e.symbol.toLowerCase().includes("usdc"));
|
|
27
|
+
}, o = (e, t) => e.find((e) => e.symbol.toLowerCase().includes("usdc")) ?? t?.find((e) => e.symbol.toLowerCase().includes("usdc")), s = (e, t) => e ? !!t?.some((t) => t.address.toLowerCase() === e.toLowerCase()) : !1;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { a as getAvailableTokens, o as getDefaultReceivingToken, i as resolveSigningChainType, r as updateUrlParams };
|
|
29
|
+
export { a as getAvailableTokens, o as getDefaultReceivingToken, s as isTokenIdFromMvx, i as resolveSigningChainType, r as updateUrlParams };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../BridgeHistory-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../BridgeHistory-0NVr8Uxp.js");exports.BridgeHistory=e.t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../../BridgeHistory-
|
|
1
|
+
import { t as e } from "../../../BridgeHistory-BUSiuT1d.mjs";
|
|
2
2
|
export { e as BridgeHistory };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../BridgeHistory-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../BridgeHistory-0NVr8Uxp.js");exports.BridgeHistory=e.t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../../BridgeHistory-
|
|
1
|
+
import { t as e } from "../../../BridgeHistory-BUSiuT1d.mjs";
|
|
2
2
|
export { e as BridgeHistory };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chains-Bmeag21l.js");require("../../constants/index.js");const t=require("../../../helpers/getDisplayName.js"),n=require("../../
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chains-Bmeag21l.js");require("../../constants/index.js");const t=require("../../../helpers/getDisplayName.js"),n=require("../../hooks/useAccount.js"),r=require("../../context/useWeb3App.js"),i=require("../../hooks/useSuiConnect.js");let a=require("react/jsx-runtime"),o=require("react"),s=require("@reown/appkit/react");var c=({activeChain:n,hasSui:r,onEvmSelect:i,onSuiSelect:o,onClose:s})=>(0,a.jsx)(`div`,{className:`liq-fixed liq-inset-0 liq-z-[9999] liq-flex liq-items-center liq-justify-center liq-bg-black/60`,onClick:s,children:(0,a.jsxs)(`div`,{className:`liq-w-[340px] liq-rounded-2xl liq-bg-neutral-900 liq-border liq-border-neutral-700/40 liq-shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)(`div`,{className:`liq-flex liq-items-center liq-justify-between liq-px-5 liq-py-4 liq-border-b liq-border-neutral-700/30`,children:[(0,a.jsx)(`h3`,{className:`liq-text-white liq-text-base liq-font-semibold liq-m-0`,children:`Select Chain`}),(0,a.jsx)(`button`,{onClick:s,className:`liq-text-neutral-400 hover:liq-text-white liq-text-lg liq-bg-transparent liq-border-none liq-cursor-pointer liq-p-1`,children:`×`})]}),(0,a.jsxs)(`div`,{className:`liq-flex liq-flex-col liq-gap-2 liq-p-4`,children:[(0,a.jsxs)(`button`,{onClick:i,className:`liq-flex liq-items-center liq-gap-3 liq-w-full liq-rounded-xl liq-bg-neutral-800/60 liq-px-4 liq-py-3 liq-text-left liq-text-white liq-font-medium liq-border liq-border-transparent liq-transition-all liq-duration-200 hover:liq-bg-neutral-750 hover:liq-border-neutral-600/50 liq-cursor-pointer`,children:[n?.pngUrl&&(0,a.jsx)(`img`,{src:n.pngUrl,alt:``,className:`liq-w-8 liq-h-8 liq-rounded-full`}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`div`,{className:`liq-text-sm liq-font-semibold`,children:n?t.getDisplayName(n):`Ethereum`}),(0,a.jsx)(`div`,{className:`liq-text-xs liq-text-neutral-400`,children:`EVM Chains`})]})]}),r&&(0,a.jsxs)(`button`,{onClick:o,className:`liq-flex liq-items-center liq-gap-3 liq-w-full liq-rounded-xl liq-bg-neutral-800/60 liq-px-4 liq-py-3 liq-text-left liq-text-white liq-font-medium liq-border liq-border-transparent liq-transition-all liq-duration-200 hover:liq-bg-neutral-750 hover:liq-border-neutral-600/50 liq-cursor-pointer`,children:[(0,a.jsx)(`img`,{src:e.r.sui,alt:``,className:`liq-w-8 liq-h-8 liq-rounded-full`}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`div`,{className:`liq-text-sm liq-font-semibold`,children:`Sui`}),(0,a.jsx)(`div`,{className:`liq-text-xs liq-text-neutral-400`,children:`Sui Network`})]})]})]})]})}),l=({activeChain:e,disabled:t,className:l})=>{let[u,d]=(0,o.useState)(!1),{open:f}=(0,s.useAppKit)(),p=n.useAccount(),{options:m}=r.useWeb3App(),h=i.useSuiConnect(),g=!!m.suiEnvironment;if(p.isConnected||h.isConnected)return null;let _=()=>{d(!1),f({view:`Connect`,namespace:`eip155`})};return g?(0,a.jsxs)(a.Fragment,{children:[u&&(0,a.jsx)(c,{activeChain:e,hasSui:g,onEvmSelect:_,onSuiSelect:()=>{d(!1),h.connect()},onClose:()=>d(!1)}),(0,a.jsx)(`button`,{onClick:()=>d(!0),disabled:t,className:`liq-font-bold liq-text-inherit liq-rounded-lg ${l??``}`,children:(0,a.jsx)(`div`,{className:`liq-flex liq-items-center liq-justify-center liq-gap-1`,children:(0,a.jsx)(`span`,{className:`liq-text-primary-200`,children:p.isConnecting?`Connecting...`:`Connect`})})})]}):(0,a.jsx)(`button`,{onClick:_,disabled:t,className:`liq-font-bold liq-text-inherit liq-rounded-lg ${l??``}`,children:(0,a.jsx)(`div`,{className:`liq-flex liq-items-center liq-justify-center liq-gap-1`,children:(0,a.jsx)(`span`,{className:`liq-text-primary-200`,children:p.isConnecting?`Connecting...`:`Connect`})})})};exports.ChainSelectConnect=l;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as e } from "../../../chains-DQACurVn.mjs";
|
|
2
2
|
import "../../constants/index.mjs";
|
|
3
3
|
import { getDisplayName as t } from "../../../helpers/getDisplayName.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useAccount as n } from "../../hooks/useAccount.mjs";
|
|
5
|
+
import { useWeb3App as r } from "../../context/useWeb3App.mjs";
|
|
6
6
|
import { useSuiConnect as i } from "../../hooks/useSuiConnect.mjs";
|
|
7
7
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
import { useState as c } from "react";
|
|
@@ -58,7 +58,7 @@ var u = ({ activeChain: n, hasSui: r, onEvmSelect: i, onSuiSelect: a, onClose: c
|
|
|
58
58
|
})]
|
|
59
59
|
})
|
|
60
60
|
}), d = ({ activeChain: e, disabled: t, className: d }) => {
|
|
61
|
-
let [f, p] = c(!1), { open: m } = l(), h =
|
|
61
|
+
let [f, p] = c(!1), { open: m } = l(), h = n(), { options: g } = r(), _ = i(), v = !!g.suiEnvironment;
|
|
62
62
|
if (h.isConnected || _.isConnected) return null;
|
|
63
63
|
let y = () => {
|
|
64
64
|
p(!1), m({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./TrimAddress/TrimAddress.js");require("./TrimAddress/index.js");const t=require("./AccountAddress/AccountAddress.js");require("./AccountAddress/index.js");const n=require("./base/MxButton/MxButton.js"),r=require("./base/MxCard/MxCard.js"),i=require("./base/MxLink/MxLink.js"),a=require("./base/MxSearch/MxSearch.js"),o=require("./base/MxSlideover/MxSlideover.js"),s=require("./base/MxTooltip/MxTooltip.js");require("./base/index.js");const c=require("./AmountCard/AmountCard.js");require("./AmountCard/index.js");const l=require("./AmountInput/AmountInput.js");require("./AmountInput/index.js");const u=require("../../BridgeHistory-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./TrimAddress/TrimAddress.js");require("./TrimAddress/index.js");const t=require("./AccountAddress/AccountAddress.js");require("./AccountAddress/index.js");const n=require("./base/MxButton/MxButton.js"),r=require("./base/MxCard/MxCard.js"),i=require("./base/MxLink/MxLink.js"),a=require("./base/MxSearch/MxSearch.js"),o=require("./base/MxSlideover/MxSlideover.js"),s=require("./base/MxTooltip/MxTooltip.js");require("./base/index.js");const c=require("./AmountCard/AmountCard.js");require("./AmountCard/index.js");const l=require("./AmountInput/AmountInput.js");require("./AmountInput/index.js");const u=require("../../BridgeHistory-0NVr8Uxp.js");require("./BridgeHistory/index.js");const d=require("./Connect/CustomConnectButton.js"),f=require("./Connect/BridgeConnectButton.js"),p=require("./Connect/MvxConnectButton.js"),m=require("./Connect/SwitchChainButton.js"),h=require("./CopyButton/CopyButton.js");require("./CopyButton/index.js");const g=require("./Connect/BridgeAccountDisplay.js"),_=require("./Connect/MvxAccountDisplay.js"),v=require("./Connect/ChainSelectConnect.js");require("./Connect/index.js");const y=require("./SmallLoader/SmallLoader.js");require("./SmallLoader/index.js");const b=require("./DisplayAmount/DisplayAmount.js");require("./DisplayAmount/index.js");const x=require("./TokenSelector/TokenSelector.js");require("./TokenSelector/index.js");const S=require("./BridgeForm/BridgeForm.js");require("./BridgeForm/index.js");const C=require("./TransactionToast/TransactionToastContainer.js"),w=require("./TransactionToast/TransactionToast.js");require("./TransactionToast/index.js");const T=require("./Error/Error.js");require("./Error/index.js"),exports.AccountAddress=t.AccountAddress,exports.AmountCard=c.AmountCard,exports.AmountInput=l.AmountInput,exports.BridgeAccountDisplay=g.BridgeAccountDisplay,exports.BridgeConnectButton=f.BridgeConnectButton,exports.BridgeForm=S.BridgeForm,exports.BridgeHistory=u.t,exports.ChainSelectConnect=v.ChainSelectConnect,exports.CopyButton=h.CopyButton,exports.CustomConnectButton=d.CustomConnectButton,exports.DisplayAmount=b.DisplayAmount,exports.Error=T.Error,exports.MvxAccountDisplay=_.MvxAccountDisplay,exports.MvxConnectButton=p.MvxConnectButton,exports.MxButton=n.MxButton,exports.MxCard=r.MxCard,exports.MxLink=i.MxLink,exports.MxSearch=a.MxSearch,exports.MxSlideover=o.MxSlideover,exports.MxTooltip=s.MxTooltip,exports.SmallLoader=y.SmallLoader,exports.SwitchChainButton=m.SwitchChainButton,exports.TokenSelector=x.TokenSelector,exports.TransactionToast=w.TransactionToast,exports.TransactionToastContainer=C.TransactionToastContainer,exports.TrimAddress=e.TrimAddress;
|
|
@@ -13,7 +13,7 @@ import { AmountCard as c } from "./AmountCard/AmountCard.mjs";
|
|
|
13
13
|
import "./AmountCard/index.mjs";
|
|
14
14
|
import { AmountInput as l } from "./AmountInput/AmountInput.mjs";
|
|
15
15
|
import "./AmountInput/index.mjs";
|
|
16
|
-
import { t as u } from "../../BridgeHistory-
|
|
16
|
+
import { t as u } from "../../BridgeHistory-BUSiuT1d.mjs";
|
|
17
17
|
import "./BridgeHistory/index.mjs";
|
|
18
18
|
import { CustomConnectButton as d } from "./Connect/CustomConnectButton.mjs";
|
|
19
19
|
import { BridgeConnectButton as f } from "./Connect/BridgeConnectButton.mjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime"),t=require("react"),n=require("
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime"),t=require("react"),n=require("wagmi"),r=require("@tanstack/react-query");var i=(0,t.createContext)(void 0);function a({children:a,config:o,appKit:s,options:c,supportedChains:l=[],nativeAuthToken:u,bridgeOnly:d=!1,reconnectOnMount:f=!0,signMvxTransactions:p,latestMvxTransactionHash:m,resetMvxTransactionHash:h}){let[g]=(0,t.useState)(()=>new r.QueryClient);(0,t.useEffect)(()=>{g.invalidateQueries()},[u]);let _=(0,t.useMemo)(()=>({config:o,appKit:s,options:c,supportedChains:l,nativeAuthToken:u,bridgeOnly:d,signMvxTransactions:p,latestMvxTransactionHash:m,resetMvxTransactionHash:h}),[o,s,c,u,p]);return(0,e.jsx)(i.Provider,{value:_,children:(0,e.jsx)(n.WagmiProvider,{config:o,reconnectOnMount:f,children:(0,e.jsx)(r.QueryClientProvider,{client:g,children:a})})})}exports.Web3AppContext=i,exports.Web3AppProvider=a;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { WagmiProvider as a } from "wagmi";
|
|
4
|
+
import { QueryClient as o, QueryClientProvider as s } from "@tanstack/react-query";
|
|
5
5
|
//#region src/reactjs/context/Web3AppProvider.tsx
|
|
6
6
|
var c = t(void 0);
|
|
7
7
|
function l({ children: t, config: l, appKit: u, options: d, supportedChains: f = [], nativeAuthToken: p, bridgeOnly: m = !1, reconnectOnMount: h = !0, signMvxTransactions: g, latestMvxTransactionHash: _, resetMvxTransactionHash: v }) {
|
|
8
|
-
let [y] = i(() => new
|
|
8
|
+
let [y] = i(() => new o());
|
|
9
9
|
n(() => {
|
|
10
10
|
y.invalidateQueries();
|
|
11
11
|
}, [p]);
|
|
@@ -28,10 +28,10 @@ function l({ children: t, config: l, appKit: u, options: d, supportedChains: f =
|
|
|
28
28
|
]);
|
|
29
29
|
return /* @__PURE__ */ e(c.Provider, {
|
|
30
30
|
value: b,
|
|
31
|
-
children: /* @__PURE__ */ e(
|
|
31
|
+
children: /* @__PURE__ */ e(a, {
|
|
32
32
|
config: l,
|
|
33
33
|
reconnectOnMount: h,
|
|
34
|
-
children: /* @__PURE__ */ e(
|
|
34
|
+
children: /* @__PURE__ */ e(s, {
|
|
35
35
|
client: y,
|
|
36
36
|
children: t
|
|
37
37
|
})
|
package/reactjs/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDebounce.js"),t=require("./
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDebounce.js"),t=require("./validation/useTestHasEnoughFunds.js"),n=require("./useAccount.js"),r=require("./validation/useTestIsConnected.js"),i=require("./validation/useAmountSchema.js"),a=require("./validation/useSecondAmountSchema.js"),o=require("./useBalances.js"),s=require("./useBridgeFormik.js"),c=require("./useBridgeApiChainId.js"),l=require("../../hooks-SJPsZfDx.js"),u=require("./useGetChainId.js"),d=require("./useResolveTokenChain.js"),f=require("./useSendTransactions.js"),p=require("./useSignTransaction.js"),m=require("./useSuiConnect.js");exports.BridgeFormikValuesEnum=s.BridgeFormikValuesEnum,exports.useAccount=n.useAccount,exports.useAmountSchema=i.useAmountSchema,exports.useBalances=o.useBalances,exports.useBridgeApiChainId=c.useBridgeApiChainId,exports.useBridgeFormik=s.useBridgeFormik,exports.useDebounce=e.useDebounce,exports.useFetchBridgeData=l.t,exports.useFetchTokens=l.n,exports.useGetChainId=u.useGetChainId,exports.useResolveTokenChain=d.useResolveTokenChain,exports.useSecondAmountSchema=a.useSecondAmountSchema,exports.useSendTransactions=f.useSendTransactions,exports.useSignTransaction=p.useSignTransaction,exports.useSuiConnect=m.useSuiConnect,exports.useTestHasEnoughFunds=t.useTestHasEnoughFunds,exports.useTestIsConnected=r.useTestIsConnected;
|
package/reactjs/hooks/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useDebounce as e } from "./useDebounce.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { useTestHasEnoughFunds as t } from "./validation/useTestHasEnoughFunds.mjs";
|
|
3
|
+
import { useAccount as n } from "./useAccount.mjs";
|
|
4
|
+
import { useTestIsConnected as r } from "./validation/useTestIsConnected.mjs";
|
|
5
|
+
import { useAmountSchema as i } from "./validation/useAmountSchema.mjs";
|
|
6
|
+
import { useSecondAmountSchema as a } from "./validation/useSecondAmountSchema.mjs";
|
|
7
|
+
import { useBalances as o } from "./useBalances.mjs";
|
|
8
8
|
import { BridgeFormikValuesEnum as s, useBridgeFormik as c } from "./useBridgeFormik.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
export { s as BridgeFormikValuesEnum,
|
|
9
|
+
import { useBridgeApiChainId as l } from "./useBridgeApiChainId.mjs";
|
|
10
|
+
import { n as u, t as d } from "../../hooks-DMIHvAKb.mjs";
|
|
11
|
+
import { useGetChainId as f } from "./useGetChainId.mjs";
|
|
12
|
+
import { useResolveTokenChain as p } from "./useResolveTokenChain.mjs";
|
|
13
|
+
import { useSendTransactions as m } from "./useSendTransactions.mjs";
|
|
14
|
+
import { useSignTransaction as h } from "./useSignTransaction.mjs";
|
|
15
|
+
import { useSuiConnect as g } from "./useSuiConnect.mjs";
|
|
16
|
+
export { s as BridgeFormikValuesEnum, n as useAccount, i as useAmountSchema, o as useBalances, l as useBridgeApiChainId, c as useBridgeFormik, e as useDebounce, d as useFetchBridgeData, u as useFetchTokens, f as useGetChainId, p as useResolveTokenChain, a as useSecondAmountSchema, m as useSendTransactions, h as useSignTransaction, g as useSuiConnect, t as useTestHasEnoughFunds, r as useTestIsConnected };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../api/confirmRate.js"),t=require("../../helpers/getApiURL.js"),n=require("../../helpers/isValidAddressForChainType.js"),r=require("
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../api/confirmRate.js"),t=require("../../helpers/getApiURL.js"),n=require("../../helpers/isValidAddressForChainType.js"),r=require("./validation/useAmountSchema.js"),i=require("./validation/useSecondAmountSchema.js"),a=require("../context/useWeb3App.js"),o=require("../../types/errors.js"),s=require("../../helpers/assertConfirmRateData.js"),c=require("../../helpers/assertRateConfirmationMatchesIntent.js"),l=require("../../types/providerType.js");let u=require("react"),d=require("yup"),f=require("formik");var p=function(e){return e.firstToken=`firstToken`,e.firstAmount=`firstAmount`,e.secondToken=`secondToken`,e.secondAmount=`secondAmount`,e.fromChainId=`fromChainId`,e.toChainId=`toChainId`,e}({}),m=({sender:p,receiver:m,firstToken:h,firstAmount:g,secondToken:_,secondAmount:v,fromChainId:y,toChainId:b,setForceRefetchRate:x,rate:S,onSubmit:C,isMvxConnected:w,senderChainType:T,receiverChainType:E})=>{let D=(0,u.useRef)(),{nativeAuthToken:O}=a.useWeb3App(),[k,A]=(0,u.useState)(void 0),j=!p||!T?!0:n.isValidAddressForChainType(p,T),M=!m||!E?!0:n.isValidAddressForChainType(m,E),N=p&&!j?`Invalid ${T} sender address`:void 0,P=m&&!M?`Invalid ${E} receiver address`:void 0,F={firstAmount:``,secondAmount:``,fromChainId:y??``,toChainId:b??``},I=()=>{L.setTouched({},!1),L.setErrors({}),U(`firstAmount`,``),U(`secondAmount`,``)},L=(0,f.useFormik)({initialValues:F,validationSchema:(0,d.object)().shape({firstAmount:r.useAmountSchema({isMvxConnected:w}),firstToken:(0,d.object)().required(),secondAmount:i.useSecondAmountSchema(),secondToken:(0,d.object)().required(),fromChainId:(0,d.string)().required(),toChainId:(0,d.string)().required()}),onSubmit:async n=>{if(!D.current){D.current=!0,A(void 0);try{if(!j||!M){D.current=!1;return}s.assertConfirmRateData({nativeAuthToken:O,orderId:S?.orderId,fromChainId:n.fromChainId,toChainId:n.toChainId,sender:p,receiver:m});let{data:r}=await e.confirmRate({url:t.getApiURL(),nativeAuthToken:O??``,body:{tokenIn:n.firstToken?.address??``,amountIn:g?.toString()??``,fromChainId:n.fromChainId??``,tokenOut:n.secondToken?.address??``,toChainId:n.toChainId??``,amountOut:v?.toString()??``,sender:p??``,receiver:m??``,fee:S?.fee??`0`,provider:S?.provider??l.ProviderType.None,orderId:S?.orderId??``}}),i=r;if(!i||i.length===0){D.current=!1;return}c.assertRateConfirmationMatchesIntent({fromChainId:n.fromChainId??``,sender:p??``},i),I(),C({transactions:i,provider:S?.provider??l.ProviderType.None})}catch(e){console.error(`Error confirming rate:`,e),e instanceof o.ConfirmRateError||e instanceof o.MissingConfirmRateDataError?A(e.message):x?.(e=>e+1)}finally{D.current=!1}}}}),{errors:R,touched:z,handleBlur:B,handleSubmit:V,handleChange:H,setFieldValue:U,setFieldTouched:W}=L;(0,u.useEffect)(()=>{U(`firstToken`,h,!0)},[h,U]),(0,u.useEffect)(()=>{U(`secondToken`,_,!0)},[_,U]),(0,u.useEffect)(()=>{U(`fromChainId`,y,!0)},[y,U]),(0,u.useEffect)(()=>{U(`toChainId`,b,!0)},[b,U]);let G=`secondAmount`in R&&`secondAmount`in z?R.secondAmount:void 0;return{formik:L,errors:R,touched:z,firstToken:h,secondToken:_,firstAmountError:`firstAmount`in R&&`firstAmount`in z?R.firstAmount:void 0,secondAmountError:G,fromChainError:`fromChainId`in R&&`fromChainId`in z?R.fromChainId:void 0,senderAddressError:N,receiverAddressError:P,confirmRateError:k,handleBlur:B,handleChange:H,handleSubmit:V,setFieldValue:U,resetSwapForm:I,setFieldTouched:W}};exports.BridgeFormikValuesEnum=p,exports.useBridgeFormik=m;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { confirmRate as e } from "../../api/confirmRate.mjs";
|
|
2
2
|
import { getApiURL as t } from "../../helpers/getApiURL.mjs";
|
|
3
3
|
import { isValidAddressForChainType as n } from "../../helpers/isValidAddressForChainType.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { useAmountSchema as r } from "./validation/useAmountSchema.mjs";
|
|
5
|
+
import { useSecondAmountSchema as i } from "./validation/useSecondAmountSchema.mjs";
|
|
6
|
+
import { useWeb3App as a } from "../context/useWeb3App.mjs";
|
|
7
7
|
import { ConfirmRateError as o, MissingConfirmRateDataError as s } from "../../types/errors.mjs";
|
|
8
8
|
import { assertConfirmRateData as c } from "../../helpers/assertConfirmRateData.mjs";
|
|
9
9
|
import { assertRateConfirmationMatchesIntent as l } from "../../helpers/assertRateConfirmationMatchesIntent.mjs";
|
|
10
10
|
import { ProviderType as u } from "../../types/providerType.mjs";
|
|
11
11
|
import { useEffect as d, useRef as f, useState as p } from "react";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { object as m, string as h } from "yup";
|
|
13
|
+
import { useFormik as g } from "formik";
|
|
14
14
|
//#region src/reactjs/hooks/useBridgeFormik.ts
|
|
15
15
|
var _ = /* @__PURE__ */ function(e) {
|
|
16
16
|
return e.firstToken = "firstToken", e.firstAmount = "firstAmount", e.secondToken = "secondToken", e.secondAmount = "secondAmount", e.fromChainId = "fromChainId", e.toChainId = "toChainId", e;
|
|
17
17
|
}({}), v = ({ sender: _, receiver: v, firstToken: y, firstAmount: b, secondToken: x, secondAmount: S, fromChainId: C, toChainId: w, setForceRefetchRate: T, rate: E, onSubmit: D, isMvxConnected: O, senderChainType: k, receiverChainType: A }) => {
|
|
18
|
-
let j = f(), { nativeAuthToken: M } =
|
|
18
|
+
let j = f(), { nativeAuthToken: M } = a(), [N, P] = p(void 0), F = !_ || !k ? !0 : n(_, k), I = !v || !A ? !0 : n(v, A), L = _ && !F ? `Invalid ${k} sender address` : void 0, R = v && !I ? `Invalid ${A} receiver address` : void 0, z = {
|
|
19
19
|
firstAmount: "",
|
|
20
20
|
secondAmount: "",
|
|
21
21
|
fromChainId: C ?? "",
|
|
22
22
|
toChainId: w ?? ""
|
|
23
23
|
}, B = () => {
|
|
24
24
|
V.setTouched({}, !1), V.setErrors({}), q("firstAmount", ""), q("secondAmount", "");
|
|
25
|
-
}, V =
|
|
25
|
+
}, V = g({
|
|
26
26
|
initialValues: z,
|
|
27
|
-
validationSchema:
|
|
28
|
-
firstAmount:
|
|
29
|
-
firstToken:
|
|
30
|
-
secondAmount:
|
|
31
|
-
secondToken:
|
|
32
|
-
fromChainId:
|
|
33
|
-
toChainId:
|
|
27
|
+
validationSchema: m().shape({
|
|
28
|
+
firstAmount: r({ isMvxConnected: O }),
|
|
29
|
+
firstToken: m().required(),
|
|
30
|
+
secondAmount: i(),
|
|
31
|
+
secondToken: m().required(),
|
|
32
|
+
fromChainId: h().required(),
|
|
33
|
+
toChainId: h().required()
|
|
34
34
|
}),
|
|
35
35
|
onSubmit: async (n) => {
|
|
36
36
|
if (!j.current) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../hooks-SJPsZfDx.js");exports.useFetchBridgeData=e.t;
|