@multiversx/sdk-dapp-liquidity 2.1.0 → 2.1.1-alpha.0
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/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -1
- package/helpers/index.mjs +18 -16
- package/helpers/isValidAddressForChainType.d.ts +3 -0
- package/helpers/isValidAddressForChainType.js +2 -0
- package/helpers/isValidAddressForChainType.mjs +37 -0
- package/helpers/tests/isValidAddressForChainType.spec.d.ts +1 -0
- package/helpers/tests/isValidAddressForChainType.spec.js +2 -0
- package/helpers/tests/isValidAddressForChainType.spec.mjs +102 -0
- package/index.js +1 -1
- package/index.mjs +162 -160
- package/package.json +3 -2
- package/reactjs/components/BridgeForm/Deposit.js +1 -1
- package/reactjs/components/BridgeForm/Deposit.mjs +269 -260
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +210 -201
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +5 -3
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -1
- package/reactjs/components/Connect/BridgeConnectButton.mjs +17 -14
- package/reactjs/hooks/useBridgeFormik.d.ts +6 -1
- package/reactjs/hooks/useBridgeFormik.js +1 -1
- package/reactjs/hooks/useBridgeFormik.mjs +94 -85
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +11 -9
- package/style.css +1 -1
|
@@ -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"),G=require("@fortawesome/free-solid-svg-icons/faArrowDownShortWide"),X=require("@fortawesome/free-solid-svg-icons/faArrowUpShortWide"),Q=require("@fortawesome/free-solid-svg-icons/faCircleCheck"),E=require("@fortawesome/free-solid-svg-icons/faCircleXmark"),z=require("@fortawesome/free-solid-svg-icons/faClock"),Y=require("@fortawesome/free-solid-svg-icons/faClose"),t=require("@fortawesome/react-fontawesome"),o=require("react");require("yup");require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");require("bignumber.js");const Z=require("../../hooks/useAccount.js");require("@reown/appkit/react");require("axios");const J=require("../../context/useWeb3App.js");require("formik");const K=require("../../../types/providerType.js"),ee=require("../../hooks/useFetchBridgeData.js"),le=require("../../../constants/index.js");require("@tanstack/react-query");require("../../constants/index.js");require("@reown/appkit-adapter-solana/react");require("@solana/web3.js");require("wagmi");require("@reown/appkit-controllers");const a=require("../../../helpers/safeImageUrl.js"),W=require("../../queries/useGetHistory.query.js"),u=require("../../utils/formatAmount.js"),n=require("../../utils/mxClsx.js"),ie=require("../base/MxButton/MxButton.js"),c=require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@headlessui/react");const x=require("../base/MxTooltip/MxTooltip.js"),se="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e",re=({mvxAddress:h,onClose:R})=>{const{options:g,bridgeOnly:j}=J.useWeb3App(),O=Z.useAccount(),{data:w,isLoading:N,isError:P}=W.useGetHistoryQuery({address:h}),{data:p}=W.useGetHistoryQuery({address:O.address??""}),q=o.useMemo(()=>{const l=w??[],r=j&&p?p:[];return[...l,...r].sort((m,d)=>d.depositTimestamp-m.depositTimestamp)},[j,p,w]),b=o.useCallback(l=>{switch(l.status){case"success":return e.jsx(t.FontAwesomeIcon,{icon:Q.faCircleCheck,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-green-400"});case"failed":return e.jsx(t.FontAwesomeIcon,{icon:E.faCircleXmark,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-red-400"});default:return e.jsx(t.FontAwesomeIcon,{icon:z.faClock,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-yellow-400"})}},[]),s=o.useMemo(()=>q==null?void 0:q.map(l=>({...l,tokenDestination:l.tokenOut.toLowerCase(),tokenSource:l.tokenIn.toLowerCase(),sender:l.sender.toLowerCase(),statusIcon:b(l)})),[q,b]),{evmTokensWithBalances:C,mvxTokensWithBalances:v,chains:y,isTokensLoading:V,isChainsLoading:$}=ee.useFetchBridgeData({mvxAddress:h,mvxApiURL:g.mvxApiURL}),i=o.useMemo(()=>[...C??[],...v??[]].reduce((l,r)=>(l[r.address.toLowerCase()]=r,l),{}),[C,v]),k=o.useMemo(()=>(y??[]).reduce((l,r)=>(l[r.chainId.toString()]=r,l),{}),[y]),f=n.mxClsx("liq-flex liq-flex-col liq-absolute liq-left-0 liq-top-0 liq-order-1 liq-mx-auto liq-w-full liq-gap-1 liq-pt-12 lg:liq-order-2 lg:liq-max-w-[27.5rem] !liq-min-h-[26rem] !liq-h-[26rem] !lg:liq-pt-0 !liq-bg-neutral-850 !liq-z-[16] !liq-p-2 !liq-pointer-events-auto",{"!liq-disabled !liq-animate-pulse":N||V||$});return N&&!s?e.jsx(c.MxCard,{className:n.mxClsx("liq-flex",f)}):P&&!s?e.jsx(c.MxCard,{className:n.mxClsx("liq-flex liq-flex-col liq-gap-1",f),children:"Something went wrong. Please try again later."}):e.jsxs(c.MxCard,{className:n.mxClsx("liq-flex liq-flex-col liq-gap-1",f),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-justify-between liq-py-1 liq-mt-0.5",children:[e.jsx("div",{className:"liq-flex liq-flex-1 liq-items-center liq-justify-center liq-text-center liq-text-lg",children:"History"}),e.jsx(ie.MxButton,{btnSize:"md",className:"liq-border-none !liq-p-0 !liq-mr-2",variant:"link-neutral-500",onClick:R,children:e.jsx(t.FontAwesomeIcon,{icon:Y.faClose,size:"xl"})})]}),e.jsxs("div",{className:"scrollbar-thin liq-flex liq-flex-1 liq-flex-col liq-gap-1 liq-overflow-y-scroll",children:[(s==null?void 0:s.length)===0&&e.jsx(c.MxCard,{cardSize:"lg",variant:"transparent",className:"liq-align-center liq-flex liq-h-full liq-flex-col liq-justify-center liq-gap-4 liq-border-0 !liq-pb-8 !liq-pt-6 !sm:liq-pb-6 !lg:liq-p-4",children:e.jsxs("div",{className:"liq-align-center liq-flex liq-flex-col liq-justify-center liq-gap-8",children:[e.jsx("div",{className:"liq-flex liq-items-center liq-justify-center",children:e.jsx(t.FontAwesomeIcon,{icon:z.faClock,size:"6x",className:"liq-rounded-full liq-bg-primary-400 liq-text-[#2b617a]"})}),e.jsxs("div",{className:n.mxClsx("liq-flex liq-flex-col liq-items-center"),children:[e.jsx("div",{className:"liq-text-xl",children:"No transactions"}),e.jsx("div",{className:"liq-text-neutral-400",children:"Your transactions history will appear here"})]})]})}),s&&(s==null?void 0:s.length)>0&&s.map((l,r)=>{var m,d,_,I,M,A,T,S,U,D,L,B,F,H;return e.jsx(c.MxCard,{cardSize:"lg",variant:"neutral-750",className:"liq-flex liq-flex-col liq-gap-4 !liq-outline liq-outline-transparent !liq-p-4 liq-border liq-border-neutral-750 liq-bg-neutral-850 hover:!liq-bg-neutral-700 !liq-rounded-lg",children:e.jsxs("div",{className:"liq-align-center liq-flex liq-justify-between liq-gap-1",children:[e.jsxs("div",{className:n.mxClsx("liq-flex liq-items-center liq-gap-1",{"liq-text-yellow-200":l.status==="pending","liq-text-green-200":l.status==="success","liq-text-red-200":l.status==="failed"}),children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:l.statusIcon,children:new Date(l.depositTimestamp*1e3).toLocaleString()}),le.MVX_CHAIN_IDS.includes(l.toChainId)?e.jsxs(e.Fragment,{children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx(t.FontAwesomeIcon,{icon:G.faArrowDownShortWide,className:"liq-mx-1 liq-flex liq-items-center"}),children:"Deposit"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(m=i[l.tokenDestination])==null?void 0:m.decimals,amount:l.amountOut,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(d=i[l.tokenDestination])==null?void 0:d.symbol}),e.jsx("img",{src:a.safeImageUrl((_=i[l.tokenDestination])==null?void 0:_.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("span",{className:"liq-whitespace-nowrap",children:"from"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(I=i[l.tokenSource])==null?void 0:I.decimals,amount:l.amountIn,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(M=i[l.tokenSource])==null?void 0:M.symbol}),e.jsxs("div",{className:"liq-flex liq-items-center liq-relative",children:[e.jsx("div",{className:"liq-flex-shrink-0 liq-overflow-hidden liq-rounded-full liq-h-8 liq-w-8 liq-flex liq-items-center liq-justify-center",children:e.jsx("div",{className:"liq-h-6 liq-w-6 liq-flex liq-items-center liq-justify-center",children:e.jsx("img",{src:a.safeImageUrl((A=i[l.tokenSource])==null?void 0:A.pngUrl),alt:"",className:"liq-asset-icon liq-sm liq-p-0"})})}),e.jsx("img",{src:a.safeImageUrl((T=k[l.fromChainId])==null?void 0:T.pngUrl),alt:"",className:"liq-absolute liq-left-3 liq-bottom-[-2px] liq-chain-icon liq-sm liq-w-5 liq-h-5 liq-border-[3px] liq-border-neutral-850 liq-rounded-lg"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx(t.FontAwesomeIcon,{icon:X.faArrowUpShortWide,className:"liq-mx-1 liq-flex liq-items-center"}),children:"Transfer"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(S=i[l.tokenSource])==null?void 0:S.decimals,amount:l.amountIn,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(U=i[l.tokenSource])==null?void 0:U.symbol}),e.jsx("img",{src:a.safeImageUrl((D=i[l.tokenSource])==null?void 0:D.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("span",{className:"liq-whitespace-nowrap",children:"to"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(L=i[l.tokenDestination])==null?void 0:L.decimals,amount:l.amountOut,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(B=i[l.tokenDestination])==null?void 0:B.symbol}),e.jsxs("div",{className:"liq-flex liq-items-center liq-relative",children:[e.jsx("div",{className:"liq-flex-shrink-0 liq-overflow-hidden liq-rounded-full liq-h-8 liq-w-8 liq-flex liq-items-center liq-justify-center",children:e.jsx("div",{className:"liq-h-6 liq-w-6 liq-flex liq-items-center liq-justify-center",children:e.jsx("img",{src:a.safeImageUrl((F=i[l.tokenDestination])==null?void 0:F.pngUrl),alt:"",className:"liq-asset-icon liq-sm liq-p-0"})})}),e.jsx("img",{src:a.safeImageUrl((H=k[l.toChainId])==null?void 0:H.pngUrl),alt:"",className:"liq-absolute liq-left-3 liq-bottom-[-2px] liq-chain-icon liq-sm liq-w-5 liq-h-5 liq-border-[3px] liq-border-neutral-850 liq-rounded-lg"})]})]})]}),l.provider===K.ProviderType.MultiversxBridge&&e.jsx("a",{href:`${g.bridgeURL}/status/${l.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"liq-flex",children:e.jsx("div",{className:"liq-ml-auto liq-mr-0 liq-flex liq-items-center liq-gap-1",children:e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx("img",{src:se,alt:"",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-neutral-200"}),shouldStopPropagation:!1,children:"View"})})})]})},`${l.txHash}-${r}`)})]})]})};exports.BridgeHistory=re;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),G=require("@fortawesome/free-solid-svg-icons/faArrowDownShortWide"),X=require("@fortawesome/free-solid-svg-icons/faArrowUpShortWide"),Q=require("@fortawesome/free-solid-svg-icons/faCircleCheck"),E=require("@fortawesome/free-solid-svg-icons/faCircleXmark"),z=require("@fortawesome/free-solid-svg-icons/faClock"),Y=require("@fortawesome/free-solid-svg-icons/faClose"),t=require("@fortawesome/react-fontawesome"),o=require("react");require("yup");require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");require("bignumber.js");const Z=require("../../hooks/useAccount.js");require("@reown/appkit/react");require("axios");const J=require("../../context/useWeb3App.js");require("formik");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const K=require("../../../types/providerType.js"),ee=require("../../hooks/useFetchBridgeData.js"),le=require("../../../constants/index.js");require("@tanstack/react-query");require("../../constants/index.js");require("@reown/appkit-adapter-solana/react");require("wagmi");require("@reown/appkit-controllers");const a=require("../../../helpers/safeImageUrl.js"),W=require("../../queries/useGetHistory.query.js"),u=require("../../utils/formatAmount.js"),n=require("../../utils/mxClsx.js"),ie=require("../base/MxButton/MxButton.js"),c=require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@headlessui/react");const x=require("../base/MxTooltip/MxTooltip.js"),se="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e",re=({mvxAddress:h,onClose:R})=>{const{options:g,bridgeOnly:j}=J.useWeb3App(),O=Z.useAccount(),{data:w,isLoading:N,isError:P}=W.useGetHistoryQuery({address:h}),{data:p}=W.useGetHistoryQuery({address:O.address??""}),q=o.useMemo(()=>{const l=w??[],r=j&&p?p:[];return[...l,...r].sort((m,d)=>d.depositTimestamp-m.depositTimestamp)},[j,p,w]),b=o.useCallback(l=>{switch(l.status){case"success":return e.jsx(t.FontAwesomeIcon,{icon:Q.faCircleCheck,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-green-400"});case"failed":return e.jsx(t.FontAwesomeIcon,{icon:E.faCircleXmark,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-red-400"});default:return e.jsx(t.FontAwesomeIcon,{icon:z.faClock,size:"lg",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-yellow-400"})}},[]),s=o.useMemo(()=>q==null?void 0:q.map(l=>({...l,tokenDestination:l.tokenOut.toLowerCase(),tokenSource:l.tokenIn.toLowerCase(),sender:l.sender.toLowerCase(),statusIcon:b(l)})),[q,b]),{evmTokensWithBalances:C,mvxTokensWithBalances:v,chains:y,isTokensLoading:V,isChainsLoading:$}=ee.useFetchBridgeData({mvxAddress:h,mvxApiURL:g.mvxApiURL}),i=o.useMemo(()=>[...C??[],...v??[]].reduce((l,r)=>(l[r.address.toLowerCase()]=r,l),{}),[C,v]),k=o.useMemo(()=>(y??[]).reduce((l,r)=>(l[r.chainId.toString()]=r,l),{}),[y]),f=n.mxClsx("liq-flex liq-flex-col liq-absolute liq-left-0 liq-top-0 liq-order-1 liq-mx-auto liq-w-full liq-gap-1 liq-pt-12 lg:liq-order-2 lg:liq-max-w-[27.5rem] !liq-min-h-[26rem] !liq-h-[26rem] !lg:liq-pt-0 !liq-bg-neutral-850 !liq-z-[16] !liq-p-2 !liq-pointer-events-auto",{"!liq-disabled !liq-animate-pulse":N||V||$});return N&&!s?e.jsx(c.MxCard,{className:n.mxClsx("liq-flex",f)}):P&&!s?e.jsx(c.MxCard,{className:n.mxClsx("liq-flex liq-flex-col liq-gap-1",f),children:"Something went wrong. Please try again later."}):e.jsxs(c.MxCard,{className:n.mxClsx("liq-flex liq-flex-col liq-gap-1",f),children:[e.jsxs("div",{className:"liq-flex liq-items-center liq-justify-between liq-py-1 liq-mt-0.5",children:[e.jsx("div",{className:"liq-flex liq-flex-1 liq-items-center liq-justify-center liq-text-center liq-text-lg",children:"History"}),e.jsx(ie.MxButton,{btnSize:"md",className:"liq-border-none !liq-p-0 !liq-mr-2",variant:"link-neutral-500",onClick:R,children:e.jsx(t.FontAwesomeIcon,{icon:Y.faClose,size:"xl"})})]}),e.jsxs("div",{className:"scrollbar-thin liq-flex liq-flex-1 liq-flex-col liq-gap-1 liq-overflow-y-scroll",children:[(s==null?void 0:s.length)===0&&e.jsx(c.MxCard,{cardSize:"lg",variant:"transparent",className:"liq-align-center liq-flex liq-h-full liq-flex-col liq-justify-center liq-gap-4 liq-border-0 !liq-pb-8 !liq-pt-6 !sm:liq-pb-6 !lg:liq-p-4",children:e.jsxs("div",{className:"liq-align-center liq-flex liq-flex-col liq-justify-center liq-gap-8",children:[e.jsx("div",{className:"liq-flex liq-items-center liq-justify-center",children:e.jsx(t.FontAwesomeIcon,{icon:z.faClock,size:"6x",className:"liq-rounded-full liq-bg-primary-400 liq-text-[#2b617a]"})}),e.jsxs("div",{className:n.mxClsx("liq-flex liq-flex-col liq-items-center"),children:[e.jsx("div",{className:"liq-text-xl",children:"No transactions"}),e.jsx("div",{className:"liq-text-neutral-400",children:"Your transactions history will appear here"})]})]})}),s&&(s==null?void 0:s.length)>0&&s.map((l,r)=>{var m,d,_,I,M,A,T,S,U,D,L,B,F,H;return e.jsx(c.MxCard,{cardSize:"lg",variant:"neutral-750",className:"liq-flex liq-flex-col liq-gap-4 !liq-outline liq-outline-transparent !liq-p-4 liq-border liq-border-neutral-750 liq-bg-neutral-850 hover:!liq-bg-neutral-700 !liq-rounded-lg",children:e.jsxs("div",{className:"liq-align-center liq-flex liq-justify-between liq-gap-1",children:[e.jsxs("div",{className:n.mxClsx("liq-flex liq-items-center liq-gap-1",{"liq-text-yellow-200":l.status==="pending","liq-text-green-200":l.status==="success","liq-text-red-200":l.status==="failed"}),children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:l.statusIcon,children:new Date(l.depositTimestamp*1e3).toLocaleString()}),le.MVX_CHAIN_IDS.includes(l.toChainId)?e.jsxs(e.Fragment,{children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx(t.FontAwesomeIcon,{icon:G.faArrowDownShortWide,className:"liq-mx-1 liq-flex liq-items-center"}),children:"Deposit"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(m=i[l.tokenDestination])==null?void 0:m.decimals,amount:l.amountOut,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(d=i[l.tokenDestination])==null?void 0:d.symbol}),e.jsx("img",{src:a.safeImageUrl((_=i[l.tokenDestination])==null?void 0:_.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("span",{className:"liq-whitespace-nowrap",children:"from"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(I=i[l.tokenSource])==null?void 0:I.decimals,amount:l.amountIn,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(M=i[l.tokenSource])==null?void 0:M.symbol}),e.jsxs("div",{className:"liq-flex liq-items-center liq-relative",children:[e.jsx("div",{className:"liq-flex-shrink-0 liq-overflow-hidden liq-rounded-full liq-h-8 liq-w-8 liq-flex liq-items-center liq-justify-center",children:e.jsx("div",{className:"liq-h-6 liq-w-6 liq-flex liq-items-center liq-justify-center",children:e.jsx("img",{src:a.safeImageUrl((A=i[l.tokenSource])==null?void 0:A.pngUrl),alt:"",className:"liq-asset-icon liq-sm liq-p-0"})})}),e.jsx("img",{src:a.safeImageUrl((T=k[l.fromChainId])==null?void 0:T.pngUrl),alt:"",className:"liq-absolute liq-left-3 liq-bottom-[-2px] liq-chain-icon liq-sm liq-w-5 liq-h-5 liq-border-[3px] liq-border-neutral-850 liq-rounded-lg"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx(t.FontAwesomeIcon,{icon:X.faArrowUpShortWide,className:"liq-mx-1 liq-flex liq-items-center"}),children:"Transfer"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(S=i[l.tokenSource])==null?void 0:S.decimals,amount:l.amountIn,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(U=i[l.tokenSource])==null?void 0:U.symbol}),e.jsx("img",{src:a.safeImageUrl((D=i[l.tokenSource])==null?void 0:D.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),e.jsx("span",{className:"liq-whitespace-nowrap",children:"to"}),e.jsx("span",{className:"liq-text-wrap",children:u.formatAmount({decimals:(L=i[l.tokenDestination])==null?void 0:L.decimals,amount:l.amountOut,addCommas:!1,digits:2})}),e.jsx("span",{className:"liq-whitespace-nowrap",children:(B=i[l.tokenDestination])==null?void 0:B.symbol}),e.jsxs("div",{className:"liq-flex liq-items-center liq-relative",children:[e.jsx("div",{className:"liq-flex-shrink-0 liq-overflow-hidden liq-rounded-full liq-h-8 liq-w-8 liq-flex liq-items-center liq-justify-center",children:e.jsx("div",{className:"liq-h-6 liq-w-6 liq-flex liq-items-center liq-justify-center",children:e.jsx("img",{src:a.safeImageUrl((F=i[l.tokenDestination])==null?void 0:F.pngUrl),alt:"",className:"liq-asset-icon liq-sm liq-p-0"})})}),e.jsx("img",{src:a.safeImageUrl((H=k[l.toChainId])==null?void 0:H.pngUrl),alt:"",className:"liq-absolute liq-left-3 liq-bottom-[-2px] liq-chain-icon liq-sm liq-w-5 liq-h-5 liq-border-[3px] liq-border-neutral-850 liq-rounded-lg"})]})]})]}),l.provider===K.ProviderType.MultiversxBridge&&e.jsx("a",{href:`${g.bridgeURL}/status/${l.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"liq-flex",children:e.jsx("div",{className:"liq-ml-auto liq-mr-0 liq-flex liq-items-center liq-gap-1",children:e.jsx(x.MxTooltip,{placement:"top",buttonText:e.jsx("img",{src:se,alt:"",className:"liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-neutral-200"}),shouldStopPropagation:!1,children:"View"})})})]})},`${l.txHash}-${r}`)})]})]})};exports.BridgeHistory=re;
|
|
@@ -15,13 +15,15 @@ import "@reown/appkit/react";
|
|
|
15
15
|
import "axios";
|
|
16
16
|
import { useWeb3App as le } from "../../context/useWeb3App.mjs";
|
|
17
17
|
import "formik";
|
|
18
|
+
import "@solana/web3.js";
|
|
19
|
+
import "bitcoinjs-lib";
|
|
20
|
+
import "viem";
|
|
18
21
|
import { ProviderType as ie } from "../../../types/providerType.mjs";
|
|
19
22
|
import { useFetchBridgeData as te } from "../../hooks/useFetchBridgeData.mjs";
|
|
20
23
|
import { MVX_CHAIN_IDS as re } from "../../../constants/index.mjs";
|
|
21
24
|
import "@tanstack/react-query";
|
|
22
25
|
import "../../constants/index.mjs";
|
|
23
26
|
import "@reown/appkit-adapter-solana/react";
|
|
24
|
-
import "@solana/web3.js";
|
|
25
27
|
import "wagmi";
|
|
26
28
|
import "@reown/appkit-controllers";
|
|
27
29
|
import { safeImageUrl as a } from "../../../helpers/safeImageUrl.mjs";
|
|
@@ -34,7 +36,7 @@ import "../base/MxLink/MxLink.mjs";
|
|
|
34
36
|
import "../base/MxSearch/MxSearch.mjs";
|
|
35
37
|
import "@headlessui/react";
|
|
36
38
|
import { MxTooltip as f } from "../base/MxTooltip/MxTooltip.mjs";
|
|
37
|
-
const oe = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e",
|
|
39
|
+
const oe = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e", _e = ({
|
|
38
40
|
mvxAddress: g,
|
|
39
41
|
onClose: F
|
|
40
42
|
}) => {
|
|
@@ -347,5 +349,5 @@ const oe = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%20
|
|
|
347
349
|
] });
|
|
348
350
|
};
|
|
349
351
|
export {
|
|
350
|
-
|
|
352
|
+
_e as BridgeHistory
|
|
351
353
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),l=require("./CustomConnectButton.js"),o=require("../../../helpers/getDisplayName.js"),i=require("../../../helpers/safeImageUrl.js");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");const c=require("../../hooks/useAccount.js"),u=({activeChain:e,disabled:s,className:r})=>{const t=c.useAccount();return n.jsx(l.CustomConnectButton,{className:r,disabled:s,"data-testid":"evm-network-connect-button",children:t.isConnected?null:n.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center liq-gap-1",children:[!t.isConnected&&n.jsx("div",{className:"liq-ml-2 liq-flex liq-items-center liq-gap-1",children:n.jsx("span",{className:"liq-text-primary-200",children:t.isConnecting?"Connecting...":"Connect"})}),e&&n.jsx("img",{src:i.safeImageUrl(e.pngUrl),alt:"",className:"liq-z-10 liq-flex liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),(e==null?void 0:e.networkName)&&n.jsx("span",{className:"liq-inline liq-truncate",children:o.getDisplayName(e)})]})})};exports.BridgeConnectButton=u;
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { CustomConnectButton as i } from "./CustomConnectButton.mjs";
|
|
3
|
-
import { getDisplayName as
|
|
4
|
-
import { safeImageUrl as
|
|
3
|
+
import { getDisplayName as m } from "../../../helpers/getDisplayName.mjs";
|
|
4
|
+
import { safeImageUrl as s } from "../../../helpers/safeImageUrl.mjs";
|
|
5
|
+
import "@solana/web3.js";
|
|
6
|
+
import "bitcoinjs-lib";
|
|
7
|
+
import "viem";
|
|
5
8
|
import { useAccount as c } from "../../hooks/useAccount.mjs";
|
|
6
|
-
const
|
|
9
|
+
const N = ({
|
|
7
10
|
activeChain: e,
|
|
8
|
-
disabled:
|
|
11
|
+
disabled: n,
|
|
9
12
|
className: r
|
|
10
13
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
return /* @__PURE__ */
|
|
14
|
+
const l = c();
|
|
15
|
+
return /* @__PURE__ */ t(
|
|
13
16
|
i,
|
|
14
17
|
{
|
|
15
18
|
className: r,
|
|
16
|
-
disabled:
|
|
19
|
+
disabled: n,
|
|
17
20
|
"data-testid": "evm-network-connect-button",
|
|
18
|
-
children:
|
|
19
|
-
!
|
|
20
|
-
e && /* @__PURE__ */
|
|
21
|
+
children: l.isConnected ? null : /* @__PURE__ */ o("div", { className: "liq-flex liq-items-center liq-justify-center liq-gap-1", children: [
|
|
22
|
+
!l.isConnected && /* @__PURE__ */ t("div", { className: "liq-ml-2 liq-flex liq-items-center liq-gap-1", children: /* @__PURE__ */ t("span", { className: "liq-text-primary-200", children: l.isConnecting ? "Connecting..." : "Connect" }) }),
|
|
23
|
+
e && /* @__PURE__ */ t(
|
|
21
24
|
"img",
|
|
22
25
|
{
|
|
23
|
-
src:
|
|
26
|
+
src: s(e.pngUrl),
|
|
24
27
|
alt: "",
|
|
25
28
|
className: "liq-z-10 liq-flex liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
26
29
|
}
|
|
27
30
|
),
|
|
28
|
-
(e == null ? void 0 : e.networkName) && /* @__PURE__ */
|
|
31
|
+
(e == null ? void 0 : e.networkName) && /* @__PURE__ */ t("span", { className: "liq-inline liq-truncate", children: m(e) })
|
|
29
32
|
] })
|
|
30
33
|
}
|
|
31
34
|
);
|
|
32
35
|
};
|
|
33
36
|
export {
|
|
34
|
-
|
|
37
|
+
N as BridgeConnectButton
|
|
35
38
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ServerTransaction } from '../../types/transaction';
|
|
2
2
|
import { TokenType } from '../../types/token';
|
|
3
3
|
import { ProviderType } from '../../types/providerType';
|
|
4
|
+
import { ChainType } from '../../types/chainType';
|
|
4
5
|
import { RateRequestResponse } from '../../types';
|
|
5
6
|
|
|
6
7
|
export declare enum BridgeFormikValuesEnum {
|
|
@@ -19,7 +20,7 @@ export interface TradeFormikValuesType {
|
|
|
19
20
|
fromChainId?: string;
|
|
20
21
|
toChainId?: string;
|
|
21
22
|
}
|
|
22
|
-
export declare const useBridgeFormik: ({ sender, receiver, firstToken, firstAmount, secondToken, secondAmount, fromChainId, toChainId, setForceRefetchRate, rate, onSubmit, isMvxConnected }: {
|
|
23
|
+
export declare const useBridgeFormik: ({ sender, receiver, firstToken, firstAmount, secondToken, secondAmount, fromChainId, toChainId, setForceRefetchRate, rate, onSubmit, isMvxConnected, senderChainType, receiverChainType }: {
|
|
23
24
|
sender: string;
|
|
24
25
|
receiver: string;
|
|
25
26
|
firstAmount?: string;
|
|
@@ -29,6 +30,8 @@ export declare const useBridgeFormik: ({ sender, receiver, firstToken, firstAmou
|
|
|
29
30
|
firstToken?: TokenType;
|
|
30
31
|
secondToken?: TokenType;
|
|
31
32
|
isMvxConnected: boolean;
|
|
33
|
+
senderChainType?: ChainType;
|
|
34
|
+
receiverChainType?: ChainType;
|
|
32
35
|
setForceRefetchRate?: (value: (previous: number) => number) => void;
|
|
33
36
|
rate?: RateRequestResponse;
|
|
34
37
|
onSubmit: ({ transactions, provider }: {
|
|
@@ -89,6 +92,8 @@ export declare const useBridgeFormik: ({ sender, receiver, firstToken, firstAmou
|
|
|
89
92
|
firstAmountError: string | undefined;
|
|
90
93
|
secondAmountError: string | undefined;
|
|
91
94
|
fromChainError: string | undefined;
|
|
95
|
+
senderAddressError: string | undefined;
|
|
96
|
+
receiverAddressError: string | undefined;
|
|
92
97
|
handleBlur: {
|
|
93
98
|
(e: React.FocusEvent<any, Element>): void;
|
|
94
99
|
<T = any>(fieldOrEvent: T): T extends string ? (e: any) => void : void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("formik"),d=require("react"),u=require("yup"),G=require("./validation/useAmountSchema.js"),H=require("./validation/useSecondAmountSchema.js"),J=require("../../api/confirmRate.js"),K=require("../../helpers/assertRateConfirmationMatchesIntent.js"),Q=require("../../helpers/getApiURL.js"),y=require("../../helpers/isValidAddressForChainType.js"),j=require("../../types/providerType.js"),X=require("../context/useWeb3App.js");var E=(o=>(o.firstToken="firstToken",o.firstAmount="firstAmount",o.secondToken="secondToken",o.secondAmount="secondAmount",o.fromChainId="fromChainId",o.toChainId="toChainId",o))(E||{});const Y=({sender:o,receiver:c,firstToken:m,firstAmount:h,secondToken:l,secondAmount:A,fromChainId:p,toChainId:I,setForceRefetchRate:C,rate:n,onSubmit:M,isMvxConnected:O,senderChainType:v,receiverChainType:S})=>{const i=d.useRef(),{nativeAuthToken:P}=X.useWeb3App(),q=!o||!v?!0:y.isValidAddressForChainType(o,v),T=!c||!S?!0:y.isValidAddressForChainType(c,S),V=o&&!q?`Invalid ${v} sender address`:void 0,$=c&&!T?`Invalid ${S} receiver address`:void 0,w={firstAmount:"",secondAmount:"",fromChainId:p??"",toChainId:I??""},_=()=>{a.setTouched({},!1),a.setErrors({}),e("firstAmount",""),e("secondAmount","")},F=async s=>{var b,g;if(!i.current){i.current=!0;try{if(!q||!T){i.current=!1;return}const{data:k}=await J.confirmRate({url:Q.getApiURL(),nativeAuthToken:P??"",body:{tokenIn:((b=s.firstToken)==null?void 0:b.address)??"",amountIn:(h==null?void 0:h.toString())??"",fromChainId:s.fromChainId??"",tokenOut:((g=s.secondToken)==null?void 0:g.address)??"",toChainId:s.toChainId??"",amountOut:(A==null?void 0:A.toString())??"",sender:o??"",receiver:c??"",fee:(n==null?void 0:n.fee)??"0",provider:(n==null?void 0:n.provider)??j.ProviderType.None,orderId:(n==null?void 0:n.orderId)??""}}),t=k;if(!t||t.length===0){i.current=!1;return}K.assertRateConfirmationMatchesIntent({fromChainId:s.fromChainId??"",sender:o??""},t),_(),M({transactions:t,provider:(n==null?void 0:n.provider)??j.ProviderType.None})}catch(k){console.error("Error confirming rate:",k),C==null||C(t=>t+1)}finally{i.current=!1}}},a=D.useFormik({initialValues:w,validationSchema:u.object().shape({firstAmount:G.useAmountSchema({isMvxConnected:O}),firstToken:u.object().required(),secondAmount:H.useSecondAmountSchema(),secondToken:u.object().required(),fromChainId:u.string().required(),toChainId:u.string().required()}),onSubmit:F}),{errors:r,touched:f,handleBlur:L,handleSubmit:N,handleChange:R,setFieldValue:e,setFieldTouched:U}=a;d.useEffect(()=>{e("firstToken",m,!0)},[m]),d.useEffect(()=>{e("secondToken",l,!0)},[l]),d.useEffect(()=>{e("fromChainId",p,!0)},[p]),d.useEffect(()=>{e("toChainId",I,!0)},[I]);const W="secondAmount"in r&&"secondAmount"in f?r.secondAmount:void 0,x="firstAmount"in r&&"firstAmount"in f?r.firstAmount:void 0,z="fromChainId"in r&&"fromChainId"in f?r.fromChainId:void 0;return{formik:a,errors:r,touched:f,firstToken:m,secondToken:l,firstAmountError:x,secondAmountError:W,fromChainError:z,senderAddressError:V,receiverAddressError:$,handleBlur:L,handleChange:R,handleSubmit:N,setFieldValue:e,resetSwapForm:_,setFieldTouched:U}};exports.BridgeFormikValuesEnum=E;exports.useBridgeFormik=Y;
|
|
@@ -1,122 +1,131 @@
|
|
|
1
|
-
import { useFormik as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { object as
|
|
4
|
-
import { useAmountSchema as
|
|
5
|
-
import { useSecondAmountSchema as
|
|
6
|
-
import { confirmRate as
|
|
7
|
-
import { assertRateConfirmationMatchesIntent as
|
|
8
|
-
import { getApiURL as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useFormik as K } from "formik";
|
|
2
|
+
import { useRef as Q, useEffect as u } from "react";
|
|
3
|
+
import { object as k, string as w } from "yup";
|
|
4
|
+
import { useAmountSchema as V } from "./validation/useAmountSchema.mjs";
|
|
5
|
+
import { useSecondAmountSchema as X } from "./validation/useSecondAmountSchema.mjs";
|
|
6
|
+
import { confirmRate as Y } from "../../api/confirmRate.mjs";
|
|
7
|
+
import { assertRateConfirmationMatchesIntent as Z } from "../../helpers/assertRateConfirmationMatchesIntent.mjs";
|
|
8
|
+
import { getApiURL as _ } from "../../helpers/getApiURL.mjs";
|
|
9
|
+
import { isValidAddressForChainType as y } from "../../helpers/isValidAddressForChainType.mjs";
|
|
10
|
+
import { ProviderType as N } from "../../types/providerType.mjs";
|
|
11
|
+
import { useWeb3App as F } from "../context/useWeb3App.mjs";
|
|
12
|
+
var R = /* @__PURE__ */ ((o) => (o.firstToken = "firstToken", o.firstAmount = "firstAmount", o.secondToken = "secondToken", o.secondAmount = "secondAmount", o.fromChainId = "fromChainId", o.toChainId = "toChainId", o))(R || {});
|
|
13
|
+
const co = ({
|
|
14
|
+
sender: o,
|
|
15
|
+
receiver: e,
|
|
16
|
+
firstToken: c,
|
|
17
|
+
firstAmount: a,
|
|
17
18
|
secondToken: h,
|
|
18
|
-
secondAmount:
|
|
19
|
+
secondAmount: I,
|
|
19
20
|
fromChainId: p,
|
|
20
|
-
toChainId:
|
|
21
|
-
setForceRefetchRate:
|
|
22
|
-
rate:
|
|
23
|
-
onSubmit:
|
|
24
|
-
isMvxConnected:
|
|
21
|
+
toChainId: A,
|
|
22
|
+
setForceRefetchRate: l,
|
|
23
|
+
rate: r,
|
|
24
|
+
onSubmit: O,
|
|
25
|
+
isMvxConnected: $,
|
|
26
|
+
senderChainType: C,
|
|
27
|
+
receiverChainType: S
|
|
25
28
|
}) => {
|
|
26
|
-
const d =
|
|
29
|
+
const d = Q(), { nativeAuthToken: j } = F(), T = !o || !C ? !0 : y(o, C), b = !e || !S ? !0 : y(e, S), x = o && !T ? `Invalid ${C} sender address` : void 0, L = e && !b ? `Invalid ${S} receiver address` : void 0, M = {
|
|
27
30
|
firstAmount: "",
|
|
28
31
|
secondAmount: "",
|
|
29
32
|
fromChainId: p ?? "",
|
|
30
|
-
toChainId:
|
|
31
|
-
},
|
|
33
|
+
toChainId: A ?? ""
|
|
34
|
+
}, g = () => {
|
|
32
35
|
m.setTouched({}, !1), m.setErrors({}), i("firstAmount", ""), i("secondAmount", "");
|
|
33
|
-
},
|
|
34
|
-
var
|
|
36
|
+
}, P = async (s) => {
|
|
37
|
+
var q, E;
|
|
35
38
|
if (!d.current) {
|
|
36
39
|
d.current = !0;
|
|
37
40
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (!T || !b) {
|
|
42
|
+
d.current = !1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { data: v } = await Y({
|
|
46
|
+
url: _(),
|
|
47
|
+
nativeAuthToken: j ?? "",
|
|
41
48
|
body: {
|
|
42
|
-
tokenIn: ((
|
|
43
|
-
amountIn: (
|
|
44
|
-
fromChainId:
|
|
45
|
-
tokenOut: ((
|
|
46
|
-
toChainId:
|
|
47
|
-
amountOut: (
|
|
48
|
-
sender:
|
|
49
|
-
receiver:
|
|
50
|
-
fee: (
|
|
51
|
-
provider: (
|
|
52
|
-
orderId: (
|
|
49
|
+
tokenIn: ((q = s.firstToken) == null ? void 0 : q.address) ?? "",
|
|
50
|
+
amountIn: (a == null ? void 0 : a.toString()) ?? "",
|
|
51
|
+
fromChainId: s.fromChainId ?? "",
|
|
52
|
+
tokenOut: ((E = s.secondToken) == null ? void 0 : E.address) ?? "",
|
|
53
|
+
toChainId: s.toChainId ?? "",
|
|
54
|
+
amountOut: (I == null ? void 0 : I.toString()) ?? "",
|
|
55
|
+
sender: o ?? "",
|
|
56
|
+
receiver: e ?? "",
|
|
57
|
+
fee: (r == null ? void 0 : r.fee) ?? "0",
|
|
58
|
+
provider: (r == null ? void 0 : r.provider) ?? N.None,
|
|
59
|
+
orderId: (r == null ? void 0 : r.orderId) ?? ""
|
|
53
60
|
}
|
|
54
|
-
}), t =
|
|
61
|
+
}), t = v;
|
|
55
62
|
if (!t || t.length === 0) {
|
|
56
63
|
d.current = !1;
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
|
-
|
|
60
|
-
{ fromChainId:
|
|
66
|
+
Z(
|
|
67
|
+
{ fromChainId: s.fromChainId ?? "", sender: o ?? "" },
|
|
61
68
|
t
|
|
62
|
-
),
|
|
69
|
+
), g(), O({
|
|
63
70
|
transactions: t,
|
|
64
|
-
provider: (
|
|
71
|
+
provider: (r == null ? void 0 : r.provider) ?? N.None
|
|
65
72
|
});
|
|
66
|
-
} catch (
|
|
67
|
-
console.error("Error confirming rate:",
|
|
73
|
+
} catch (v) {
|
|
74
|
+
console.error("Error confirming rate:", v), l == null || l((t) => t + 1);
|
|
68
75
|
} finally {
|
|
69
76
|
d.current = !1;
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
|
-
}, m =
|
|
73
|
-
initialValues:
|
|
74
|
-
validationSchema:
|
|
75
|
-
firstAmount:
|
|
76
|
-
firstToken:
|
|
77
|
-
secondAmount:
|
|
78
|
-
secondToken:
|
|
79
|
-
fromChainId:
|
|
80
|
-
toChainId:
|
|
79
|
+
}, m = K({
|
|
80
|
+
initialValues: M,
|
|
81
|
+
validationSchema: k().shape({
|
|
82
|
+
firstAmount: V({ isMvxConnected: $ }),
|
|
83
|
+
firstToken: k().required(),
|
|
84
|
+
secondAmount: X(),
|
|
85
|
+
secondToken: k().required(),
|
|
86
|
+
fromChainId: w().required(),
|
|
87
|
+
toChainId: w().required()
|
|
81
88
|
}),
|
|
82
|
-
onSubmit:
|
|
89
|
+
onSubmit: P
|
|
83
90
|
}), {
|
|
84
|
-
errors:
|
|
85
|
-
touched:
|
|
86
|
-
handleBlur:
|
|
87
|
-
handleSubmit:
|
|
88
|
-
handleChange:
|
|
91
|
+
errors: n,
|
|
92
|
+
touched: f,
|
|
93
|
+
handleBlur: U,
|
|
94
|
+
handleSubmit: W,
|
|
95
|
+
handleChange: z,
|
|
89
96
|
setFieldValue: i,
|
|
90
|
-
setFieldTouched:
|
|
97
|
+
setFieldTouched: D
|
|
91
98
|
} = m;
|
|
92
|
-
|
|
93
|
-
i("firstToken",
|
|
94
|
-
}, [
|
|
99
|
+
u(() => {
|
|
100
|
+
i("firstToken", c, !0);
|
|
101
|
+
}, [c]), u(() => {
|
|
95
102
|
i("secondToken", h, !0);
|
|
96
|
-
}, [h]),
|
|
103
|
+
}, [h]), u(() => {
|
|
97
104
|
i("fromChainId", p, !0);
|
|
98
|
-
}, [p]),
|
|
99
|
-
i("toChainId",
|
|
100
|
-
}, [
|
|
101
|
-
const
|
|
105
|
+
}, [p]), u(() => {
|
|
106
|
+
i("toChainId", A, !0);
|
|
107
|
+
}, [A]);
|
|
108
|
+
const G = "secondAmount" in n && "secondAmount" in f ? n.secondAmount : void 0, H = "firstAmount" in n && "firstAmount" in f ? n.firstAmount : void 0, J = "fromChainId" in n && "fromChainId" in f ? n.fromChainId : void 0;
|
|
102
109
|
return {
|
|
103
110
|
formik: m,
|
|
104
|
-
errors:
|
|
105
|
-
touched:
|
|
106
|
-
firstToken:
|
|
111
|
+
errors: n,
|
|
112
|
+
touched: f,
|
|
113
|
+
firstToken: c,
|
|
107
114
|
secondToken: h,
|
|
108
|
-
firstAmountError:
|
|
109
|
-
secondAmountError:
|
|
110
|
-
fromChainError:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
firstAmountError: H,
|
|
116
|
+
secondAmountError: G,
|
|
117
|
+
fromChainError: J,
|
|
118
|
+
senderAddressError: x,
|
|
119
|
+
receiverAddressError: L,
|
|
120
|
+
handleBlur: U,
|
|
121
|
+
handleChange: z,
|
|
122
|
+
handleSubmit: W,
|
|
114
123
|
setFieldValue: i,
|
|
115
|
-
resetSwapForm:
|
|
116
|
-
setFieldTouched:
|
|
124
|
+
resetSwapForm: g,
|
|
125
|
+
setFieldTouched: D
|
|
117
126
|
};
|
|
118
127
|
};
|
|
119
128
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
R as BridgeFormikValuesEnum,
|
|
130
|
+
co as useBridgeFormik
|
|
122
131
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@reown/appkit/react"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@reown/appkit/react"),u=require("@tanstack/react-query"),a=require("react");require("yup");require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");require("bignumber.js");require("wagmi");const f=require("../hooks/useBalances.js");require("formik");require("axios");require("@solana/web3.js");require("bitcoinjs-lib");require("viem");require("../context/Web3AppProvider.js");require("../constants/index.js");require("@reown/appkit-adapter-solana/react");require("@reown/appkit-controllers");const v=({tokens:e,chainId:s})=>{const{address:o}=y.useAppKitAccount(),{getBalances:i}=f.useBalances(),c=a.useMemo(()=>e.map(r=>r.address),[e]),l=async()=>{try{if(!o)throw new Error("User address is required");if(!s)throw new Error("Chain ID is required");return(await i({tokens:e,chainId:s})).map(t=>{const n=e.find(d=>d.address.toLowerCase()===t.tokenId.toLowerCase());if(!n)throw new Error("Token not found");return{...n,balance:t.balance.toString()}})}catch(r){throw r}},q=(r,t)=>{var n;return((n=t.response)==null?void 0:n.status)===404};return u.useQuery({queryKey:["non-mvx-tokens-balances",o,s,c],queryFn:l,retry:q,enabled:!!o&&!!s,refetchOnWindowFocus:!1,refetchIntervalInBackground:!0,refetchInterval:2e4,refetchOnReconnect:"always",gcTime:0})};function w(){const e=u.useQueryClient();return a.useCallback(()=>{e.invalidateQueries({queryKey:["non-mvx-tokens-balances"]})},[e])}exports.useGetNonMvxTokensBalancesQuery=v;exports.useInvalidateEvmTokensBalances=w;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAppKitAccount as c } from "@reown/appkit/react";
|
|
2
|
-
import { useQuery as m, useQueryClient as
|
|
3
|
-
import { useMemo as
|
|
2
|
+
import { useQuery as m, useQueryClient as p } from "@tanstack/react-query";
|
|
3
|
+
import { useMemo as l, useCallback as f } from "react";
|
|
4
4
|
import "yup";
|
|
5
5
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
6
6
|
import "bignumber.js";
|
|
@@ -8,16 +8,18 @@ import "wagmi";
|
|
|
8
8
|
import { useBalances as d } from "../hooks/useBalances.mjs";
|
|
9
9
|
import "formik";
|
|
10
10
|
import "axios";
|
|
11
|
+
import "@solana/web3.js";
|
|
12
|
+
import "bitcoinjs-lib";
|
|
13
|
+
import "viem";
|
|
11
14
|
import "../context/Web3AppProvider.mjs";
|
|
12
15
|
import "../constants/index.mjs";
|
|
13
16
|
import "@reown/appkit-adapter-solana/react";
|
|
14
|
-
import "@solana/web3.js";
|
|
15
17
|
import "@reown/appkit-controllers";
|
|
16
|
-
const
|
|
18
|
+
const M = ({
|
|
17
19
|
tokens: e,
|
|
18
20
|
chainId: o
|
|
19
21
|
}) => {
|
|
20
|
-
const { address: s } = c(), { getBalances: a } = d(), i =
|
|
22
|
+
const { address: s } = c(), { getBalances: a } = d(), i = l(
|
|
21
23
|
() => e.map((r) => r.address),
|
|
22
24
|
[e]
|
|
23
25
|
);
|
|
@@ -59,8 +61,8 @@ const A = ({
|
|
|
59
61
|
gcTime: 0
|
|
60
62
|
});
|
|
61
63
|
};
|
|
62
|
-
function
|
|
63
|
-
const e =
|
|
64
|
+
function O() {
|
|
65
|
+
const e = p();
|
|
64
66
|
return f(() => {
|
|
65
67
|
e.invalidateQueries({
|
|
66
68
|
queryKey: ["non-mvx-tokens-balances"]
|
|
@@ -68,6 +70,6 @@ function L() {
|
|
|
68
70
|
}, [e]);
|
|
69
71
|
}
|
|
70
72
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
M as useGetNonMvxTokensBalancesQuery,
|
|
74
|
+
O as useInvalidateEvmTokensBalances
|
|
73
75
|
};
|