diff --git a/index.html b/index.html index 2a070db6e..e6b1cc0a6 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,6 @@ diff --git a/package.json b/package.json index 41ace2eca..633e58422 100644 --- a/package.json +++ b/package.json @@ -25,28 +25,19 @@ "@oraichain/orai-bitcoin": "2.0.0", "@oraichain/oraidex-common-ui": "1.0.11", "@oraichain/oraidex-contracts-sdk": "1.0.55", - "@oraichain/oraidex-universal-swap": "1.1.22-beta.9", - "@oraichain/ton-bridge-contracts": "^0.15.8", - "@oraichain/tonbridge-contracts-sdk": "^1.3.1", - "@oraichain/tonbridge-sdk": "^1.3.6", - "@orbs-network/ton-access": "^2.3.3", + "@oraichain/oraidex-universal-swap": "1.1.23", "@react-spring/web": "^9.7.5", "@reduxjs/toolkit": "^1.9.3", "@sentry/react": "7.99.0", "@tanstack/react-query": "^4.32.6", "@tharsis/proto": "^0.1.17", "@tippyjs/react": "^4.2.0", - "@ton/core": "^0.56.3", - "@ton/crypto": "^3.3.0", - "@ton/ton": "^14.0.0", - "@tonconnect/protocol": "^2.2.6", - "@tonconnect/ui-react": "^2.0.6", + "@vitejs/plugin-react": "^4.3.1", "@visx/curve": "^2.17.0", "@visx/gradient": "^3.3.0", "@visx/responsive": "^2.17.0", "@visx/scale": "^2.18.0", "@visx/xychart": "^3.11.0", - "@vitejs/plugin-react": "^4.3.1", "@walletconnect/browser-utils": "^1.8.0", "@walletconnect/ethereum-provider": "^1.7.8", "axios": "^0.26.1", @@ -120,15 +111,15 @@ "ts-jest": "^29.1.1", "typed-scss-modules": "^7.1.4", "typescript": "^5.1.6", - "vite": "^5.4.10", "vite-plugin-node-polyfills": "^0.22.0", + "vite": "^5.4.10", "vite-plugin-wasm": "^3.3.0", "vitest": "2.0.2" }, "scripts": { "analyze": "source-map-explorer 'build/static/js/*.js'", "start": "vite", - "build": "NODE_OPTIONS='--max-old-space-size=12288' vite build", + "build": "vite build", "serve": "vite serve", "ts-check": "tsc --noEmit", "postinstall": "patch-package", @@ -159,7 +150,7 @@ "bitcoinjs-lib": "5.2.0", "axios": "0.26.1", "@sentry/react": "7.99.0", - "@oraichain/oraidex-common": "1.1.32-beta.7" + "@oraichain/oraidex-common": "1.1.34" }, "engines": { "node": "^18 || ^20" diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 2005f7544..000000000 --- a/public/manifest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "url": "https://oraidex.io", - "name": "OraiDex", - "iconUrl": "https://oraidex.io/favicon.svg" -} diff --git a/src/assets/icons/solana.svg b/src/assets/icons/solana.svg new file mode 100644 index 000000000..7cb4588eb --- /dev/null +++ b/src/assets/icons/solana.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/CheckBox.module.scss b/src/components/CheckBox.module.scss index bb7a11d69..7fec28f6c 100644 --- a/src/components/CheckBox.module.scss +++ b/src/components/CheckBox.module.scss @@ -30,11 +30,8 @@ left: 0; height: 16px; width: 16px; + border: 1px solid $blue-color; transform: translateY(-50%); - - @include theme { - border: 1px solid theme-get('primary-surface-default-dark-3'); - } } .radioBox { @@ -43,16 +40,14 @@ /* On mouse-over, add a grey background color */ .container:hover input ~ .checkmark { - @include theme { - border-color: theme-get('primary-surface-default-dark-3'); - } + border-color: $blue-color; } /* When the checkbox is checked, add a blue background */ .container input:checked ~ .checkmark { - @include theme { - border-color: theme-get('primary-surface-default-dark-3'); - background-color: theme-get('neutral-6'); + border-color: $blue-color; + @include theme() { + background-color: theme-get('bg-color'); } } @@ -74,11 +69,9 @@ top: 1px; width: 5px; height: 10px; + border: solid $blue-color; + border-width: 0 2px 2px 0; -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); - @include theme { - border: solid theme-get('primary-surface-default-dark-3'); - border-width: 0 2px 2px 0; - } } diff --git a/src/components/Modals/SelectTokenModal/SelectTokenModal.module.scss b/src/components/Modals/SelectTokenModal/SelectTokenModal.module.scss index 263019a4b..4c6e1aa08 100644 --- a/src/components/Modals/SelectTokenModal/SelectTokenModal.module.scss +++ b/src/components/Modals/SelectTokenModal/SelectTokenModal.module.scss @@ -1,5 +1,5 @@ @import 'src/styles/themes'; -@import 'src/styles/mixins'; +@import "src/styles/mixins"; .select { background: #141416; @@ -28,7 +28,7 @@ /* aiRight/White */ &.light { - color: #6f767e; + color: #6F767E; } } @@ -42,10 +42,11 @@ .item { &.light { &.light { - color: #6f767e; - } + color: #6F767E; + } } + border-radius: 8px; display: flex; gap: 10px; @@ -68,13 +69,12 @@ &:hover { cursor: pointer; - background: #232521; - opacity: 0.7; + background: #333642; } &.light:hover { - background-color: #f7f7f7; - opacity: 0.7; + background-color: $blue-color; + color: #fff; } .logo { @@ -99,4 +99,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/components/Modals/SelectTokenModal/SelectTokenModal.tsx b/src/components/Modals/SelectTokenModal/SelectTokenModal.tsx index 7e0a8effd..48221efe9 100644 --- a/src/components/Modals/SelectTokenModal/SelectTokenModal.tsx +++ b/src/components/Modals/SelectTokenModal/SelectTokenModal.tsx @@ -45,80 +45,63 @@ export const SelectTokenModal: FC = ({
{type === 'token' ? 'Select a token' : 'Select a network'}
- {items - ?.map((item: TokenItemType | CustomChainInfo) => { - let key: string, title: string, balance: string, rawBalance: string; - let tokenAndChainIcons; - if (type === 'token') { - const token = item as TokenItemType; - key = token.denom; - title = token.name; - let sumAmountDetails: AmountDetails = {}; - // by default, we only display the amount that matches the token denom - sumAmountDetails[token.denom] = amounts[token.denom]; - let sumAmount: number = toSumDisplay(sumAmountDetails); - // if there are sub-denoms, we get sub amounts & calculate sum display of both sub & main amount - if (token.evmDenoms) { - const subAmounts = getSubAmountDetails(amounts, token); - sumAmountDetails = { ...sumAmountDetails, ...subAmounts }; - sumAmount = toSumDisplay(sumAmountDetails); - } - tokenAndChainIcons = tokensIcon.find((tokenIcon) => tokenIcon.coinGeckoId === token.coinGeckoId); - balance = sumAmount > 0 ? sumAmount.toFixed(truncDecimals) : '0'; - rawBalance = balance; - } else { - const network = item as CustomChainInfo; - key = network.chainId.toString(); - title = network.chainName; - const subAmounts = Object.fromEntries( - Object.entries(amounts).filter( - ([denom]) => tokenMap[denom] && tokenMap[denom].chainId === network.chainId - ) - ); - const totalUsd = getTotalUsd(subAmounts, prices); - tokenAndChainIcons = chainIcons.find((chainIcon) => chainIcon.chainId === network.chainId); - rawBalance = totalUsd > 0 ? totalUsd.toFixed(2) : '0'; - balance = '$' + rawBalance; + {items?.map((item: TokenItemType | CustomChainInfo) => { + let key: string, title: string, balance: string; + let tokenAndChainIcons; + if (type === 'token') { + const token = item as TokenItemType; + key = token.denom; + title = token.name; + let sumAmountDetails: AmountDetails = {}; + // by default, we only display the amount that matches the token denom + sumAmountDetails[token.denom] = amounts[token.denom]; + let sumAmount: number = toSumDisplay(sumAmountDetails); + // if there are sub-denoms, we get sub amounts & calculate sum display of both sub & main amount + if (token.evmDenoms) { + const subAmounts = getSubAmountDetails(amounts, token); + sumAmountDetails = { ...sumAmountDetails, ...subAmounts }; + sumAmount = toSumDisplay(sumAmountDetails); } - const icon = - tokenAndChainIcons && theme === 'light' ? ( - - ) : ( - - ); + tokenAndChainIcons = tokensIcon.find((tokenIcon) => tokenIcon.coinGeckoId === token.coinGeckoId); + balance = sumAmount > 0 ? sumAmount.toFixed(truncDecimals) : '0'; + } else { + const network = item as CustomChainInfo; + key = network.chainId.toString(); + title = network.chainName; + const subAmounts = Object.fromEntries( + Object.entries(amounts).filter(([denom]) => tokenMap[denom] && tokenMap[denom].chainId === network.chainId) + ); + const totalUsd = getTotalUsd(subAmounts, prices); + tokenAndChainIcons = chainIcons.find((chainIcon) => chainIcon.chainId === network.chainId); + balance = '$' + (totalUsd > 0 ? totalUsd.toFixed(2) : '0'); + } + const icon = + tokenAndChainIcons && theme === 'light' ? ( + + ) : ( + + ); - return { - ...item, - key, - title, - balance, - rawBalance, - icon - }; - }) - .sort((a, b) => Number(b.rawBalance || 0) - Number(a.rawBalance || 0)) - .map((item, idx) => { - const { key, title, balance, icon } = item; - return ( -
{ - setToken(key, type === 'token' && (item as TokenItemType).contractAddress); - if (setSymbol) { - setSymbol(title); - } - close(); - }} - > - {icon} -
-
{title}
-
-
{balance}
+ return ( +
{ + setToken(key, type === 'token' && (item as TokenItemType).contractAddress); + if (setSymbol) { + setSymbol(title); + } + close(); + }} + > + {icon} +
+
{title}
- ); - })} +
{balance}
+
+ ); + })}
diff --git a/src/components/Modals/SlippageModal/SlippageModal.module.scss b/src/components/Modals/SlippageModal/SlippageModal.module.scss index 3246454a6..45c67e4bb 100644 --- a/src/components/Modals/SlippageModal/SlippageModal.module.scss +++ b/src/components/Modals/SlippageModal/SlippageModal.module.scss @@ -1,9 +1,9 @@ -@import 'src/styles/mixins'; +@import "src/styles/mixins"; .setting { border-radius: 8px; padding: 20px 24px 24px; - border: 1px solid #a871df; + border: 1px solid #A871DF; .header { display: flex; @@ -21,7 +21,7 @@ line-height: 100%; /* identical to box height, or 18px */ text-align: center; - color: #f0b90b; + color: #F0B90B; img { margin-right: 10px; @@ -34,13 +34,14 @@ height: 18px; path { - fill: #777e91; + fill: #777E91; } } } + .subtitle { - color: #a871df; + color: #A871DF; font-size: 16px; font-style: normal; font-weight: 500; @@ -69,7 +70,7 @@ border-radius: 4px; padding: 6px 14px; margin: 0 4px; - color: #a871df; + color: #A871DF; .input { max-width: 40px; @@ -87,7 +88,7 @@ } .isChosen { - border: 1px solid #a871df; + border: 1px solid #A871DF; opacity: 1; } } @@ -114,22 +115,22 @@ } .light-modal { - background-color: #fcfcfc; + background-color: #FCFCFC; box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.05); .options { .item { - background: #eee7ff; + background: #EEE7FF; } } } .dark-modal { - background-color: #232521; + background-color: #2B2D3B; .options { .item { - background: #423a56; + background: #423A56; } } -} +} \ No newline at end of file diff --git a/src/components/WalletManagement/ModalChooseWallet/WalletByNetwork/WalletByNetwork.tsx b/src/components/WalletManagement/ModalChooseWallet/WalletByNetwork/WalletByNetwork.tsx index b3ca5d1ae..c79811cb5 100644 --- a/src/components/WalletManagement/ModalChooseWallet/WalletByNetwork/WalletByNetwork.tsx +++ b/src/components/WalletManagement/ModalChooseWallet/WalletByNetwork/WalletByNetwork.tsx @@ -8,15 +8,13 @@ import useTheme from 'hooks/useTheme'; import useWalletReducer from 'hooks/useWalletReducer'; import Keplr from 'libs/keplr'; import { initClient } from 'libs/utils'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { WalletItem } from '../WalletItem'; import styles from './WalletByNetwork.module.scss'; import { useInactiveConnect } from 'hooks/useMetamask'; import Metamask from 'libs/metamask'; import DefaultIcon from 'assets/icons/tokens.svg?react'; import { ChainEnableByNetwork, triggerUnlockOwalletInEvmNetwork } from 'components/WalletManagement/wallet-helper'; -import { useTonConnectModal, useTonConnectUI } from '@tonconnect/ui-react'; -import useTonConnectAddress from 'hooks/useTonConnectAddress'; export type ConnectStatus = 'init' | 'confirming-switch' | 'confirming-disconnect' | 'loading' | 'failed' | 'success'; export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProvider }) => { @@ -27,14 +25,11 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv const [, setOraiAddress] = useConfigReducer('address'); const [, setTronAddress] = useConfigReducer('tronAddress'); const [, setBtcAddress] = useConfigReducer('btcAddress'); - const [, setTonAddress] = useConfigReducer('tonAddress'); const [, setMetamaskAddress] = useConfigReducer('metamaskAddress'); const [, setCosmosAddress] = useConfigReducer('cosmosAddress'); const [walletByNetworks, setWalletByNetworks] = useWalletReducer('walletsByNetwork'); const connect = useInactiveConnect(); - const { handleConnectTon, handleDisconnectTon } = useTonConnectAddress(); - const handleConfirmSwitch = async () => { setConnectStatus('loading'); await handleConnectWalletByNetwork(currentWalletConnecting); @@ -91,14 +86,6 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv setBtcAddress(btcAddress); }; - const handleConnectWalletInTONNetwork = async (walletType: WalletType) => { - if (walletType === 'owallet') { - // TODO: need check when use multi wallet support bitcoin - } - - handleConnectTon(); - }; - const handleConnectWalletByNetwork = async (wallet: WalletNetwork) => { try { setConnectStatus('loading'); @@ -115,20 +102,14 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv case 'bitcoin': await handleConnectWalletInBtcNetwork(wallet.nameRegistry); break; - case 'ton': - await handleConnectWalletInTONNetwork(wallet.nameRegistry); - break; default: setConnectStatus('init'); break; } - - if (networkType !== 'ton') { - setWalletByNetworks({ - ...walletByNetworks, - [networkType]: wallet.nameRegistry - }); - } + setWalletByNetworks({ + ...walletByNetworks, + [networkType]: wallet.nameRegistry + }); setCurrentWalletConnecting(null); setConnectStatus('init'); } catch (error) { @@ -177,10 +158,6 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv case 'bitcoin': setBtcAddress(undefined); break; - case 'ton': - setTonAddress(undefined); - handleDisconnectTon(); - break; default: break; } diff --git a/src/components/WalletManagement/ModalChooseWallet/WalletItem/WalletItem.module.scss b/src/components/WalletManagement/ModalChooseWallet/WalletItem/WalletItem.module.scss index c4aa48472..20bfc2787 100644 --- a/src/components/WalletManagement/ModalChooseWallet/WalletItem/WalletItem.module.scss +++ b/src/components/WalletManagement/ModalChooseWallet/WalletItem/WalletItem.module.scss @@ -1,77 +1,74 @@ .walletItem { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - gap: 8px; - padding: 10px; - border-radius: 8px; - cursor: pointer; - - .loadingIcon { - flex: 1; display: flex; - align-items: center; + flex-direction: column; justify-content: center; + align-items: center; + gap: 8px; + padding: 10px; + border-radius: 8px; + cursor: pointer; - div { - background-color: #aee67f; - padding: 8px; - border-radius: 50%; - width: 40px; - height: 40px; - } - } + .loadingIcon { + flex: 1; + display: flex; + align-items: center; + justify-content: center; - &:hover { - background-color: #dfe0de; - } + div { + background-color: #aee67f; + padding: 8px; + border-radius: 50%; + width: 40px; + height: 40px; + } + } - & > button { - padding: 5px 10px; - font-size: 14px; - } + &:hover { + background-color: #DFE0DE; + } - .walletIcon { - display: flex; - width: 40px; - height: 40px; + &>button { + padding: 5px 10px; + font-size: 14px; + } - svg { - width: 40px; - height: 40px; + .walletIcon { + display: flex; + width: 40px; + height: 40px; } - } - .walletName { - color: #232521; - font-size: 14px; - font-weight: 500; - line-height: 150%; - text-align: center; - } + .walletName { + color: #232521; + font-size: 14px; + font-weight: 500; + line-height: 150%; + text-align: center; + } } .dark { - &:hover { - background-color: #494949; - } + &:hover { + background-color: #494949; + } - .walletName { - color: #f7f7f7; - } + .walletName { + color: #f7f7f7; + } } .disabled { - opacity: 0.5; - cursor: not-allowed; - pointer-events: none; + opacity: 0.5; + cursor: not-allowed; + pointer-events: none; } .connecting { - flex: 1; - display: flex; - flex-direction: column; - align-items: center; - width: 100%; -} + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + width: 100%; + + +} \ No newline at end of file diff --git a/src/components/WalletManagement/ModalDisconnect/ModalDisconnect.tsx b/src/components/WalletManagement/ModalDisconnect/ModalDisconnect.tsx index ea817a001..7495f431f 100644 --- a/src/components/WalletManagement/ModalDisconnect/ModalDisconnect.tsx +++ b/src/components/WalletManagement/ModalDisconnect/ModalDisconnect.tsx @@ -8,7 +8,6 @@ import styles from './ModalDisconnect.module.scss'; import useWalletReducer from 'hooks/useWalletReducer'; import { reduceString } from 'libs/utils'; import { useCopyClipboard } from 'hooks/useCopyClipboard'; -import useTonConnectAddress from 'hooks/useTonConnectAddress'; import SuccessIcon from 'assets/icons/toast_success.svg?react'; const cx = cn.bind(styles); @@ -22,11 +21,9 @@ export const ModalDisconnect: React.FC<{ const [walletByNetworks, setWalletByNetworks] = useWalletReducer('walletsByNetwork'); const [oraiAddress, setOraiAddress] = useConfigReducer('address'); const [tronAddress, setTronAddress] = useConfigReducer('tronAddress'); - const [tonAddress, setTonAddress] = useConfigReducer('tonAddress'); const [btcAddress, setBtcAddress] = useConfigReducer('btcAddress'); const [metamaskAddress, setMetamaskAddress] = useConfigReducer('metamaskAddress'); const { isCopied, copiedValue, handleCopy } = useCopyClipboard(); - const { handleDisconnectTon } = useTonConnectAddress(); const chains = walletProvider.find((provider) => provider.networkType === currentDisconnectingNetwork)?.networks || []; @@ -50,9 +47,6 @@ export const ModalDisconnect: React.FC<{ case 'tron': choosedAddressDisplayByNetwork = tronAddress; break; - case 'ton': - choosedAddressDisplayByNetwork = tonAddress; - break; default: break; } @@ -81,9 +75,6 @@ export const ModalDisconnect: React.FC<{ case 'tron': setTronAddress(undefined); break; - case 'ton': - handleDisconnectTon(); - break; default: break; } diff --git a/src/components/WalletManagement/MyWallet/MyWallet.tsx b/src/components/WalletManagement/MyWallet/MyWallet.tsx index 2cded4f38..8b22298dc 100644 --- a/src/components/WalletManagement/MyWallet/MyWallet.tsx +++ b/src/components/WalletManagement/MyWallet/MyWallet.tsx @@ -12,16 +12,14 @@ import { evmWallets, btcWallets, type NetworkType, - WalletNetwork, - tonWallets + WalletNetwork } from 'components/WalletManagement/walletConfig'; import { tronNetworksWithIcon, cosmosNetworksWithIcon, evmNetworksIconWithoutTron, getListAddressCosmos, - btcNetworksWithIcon, - tonNetworksWithIcon + btcNetworksWithIcon } from 'helper'; import { useCoinGeckoPrices } from 'hooks/useCoingecko'; import useConfigReducer from 'hooks/useConfigReducer'; @@ -48,7 +46,6 @@ export const MyWallet: React.FC<{ const [oraiAddress] = useConfigReducer('address'); const [tronAddress] = useConfigReducer('tronAddress'); const [btcAddress] = useConfigReducer('btcAddress'); - const [tonAddress] = useConfigReducer('tonAddress'); const [metamaskAddress] = useConfigReducer('metamaskAddress'); const [cosmosAddresses, setCosmosAddress] = useConfigReducer('cosmosAddress'); @@ -172,17 +169,6 @@ export const MyWallet: React.FC<{ return renderWalletAddress(btcNetworks, btcWalletConnected, (_network) => btcAddress); }; - const renderTonAddresses = () => { - if (!tonAddress) return null; - const tonWalletConnected = tonWallets.find((item) => item.nameRegistry === walletByNetworks.ton); - - if (!tonWalletConnected) return <>; - - const tonNetworks = tonNetworksWithIcon.map((evm) => ({ ...evm, typeChain: 'ton' })); - - return renderWalletAddress(tonNetworks, tonWalletConnected, (_network) => tonAddress); - }; - return (
diff --git a/src/components/WalletManagement/WalletManagement.tsx b/src/components/WalletManagement/WalletManagement.tsx index 5b555abbe..e5fdf4e1d 100644 --- a/src/components/WalletManagement/WalletManagement.tsx +++ b/src/components/WalletManagement/WalletManagement.tsx @@ -22,7 +22,6 @@ export const WalletManagement: FC<{}> = () => { const [theme] = useConfigReducer('theme'); const [oraiAddress] = useConfigReducer('address'); const [tronAddress] = useConfigReducer('tronAddress'); - const [tonAddress] = useConfigReducer('tonAddress'); const [btcAddress] = useConfigReducer('btcAddress'); const [metamaskAddress] = useConfigReducer('metamaskAddress'); const [walletByNetworks] = useWalletReducer('walletsByNetwork'); @@ -66,9 +65,6 @@ export const WalletManagement: FC<{}> = () => { case 'bitcoin': isActive = isCheckOwallet; break; - case 'ton': - isActive = true; - break; } return { ...wallet, isActive }; } @@ -89,7 +85,7 @@ export const WalletManagement: FC<{}> = () => { // load balance every time change address useEffect(() => { - const addresses = { oraiAddress, tronAddress, metamaskAddress, btcAddress, tonAddress }; + const addresses = { oraiAddress, tronAddress, metamaskAddress, btcAddress }; const filteredAddresses = {}; for (const key in addresses) { @@ -101,21 +97,20 @@ export const WalletManagement: FC<{}> = () => { loadTokenAmounts(filteredAddresses); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [oraiAddress, tronAddress, metamaskAddress, btcAddress, tonAddress]); + }, [oraiAddress, tronAddress, metamaskAddress, btcAddress]); // reset balance when disconnect useEffect(() => { - if (!metamaskAddress || !tronAddress || !oraiAddress || !btcAddress || !tonAddress) { + if (!metamaskAddress || !tronAddress || !oraiAddress || !btcAddress) { let arrResetBalance: WalletResetType[] = []; if (!metamaskAddress) arrResetBalance.push('metamask'); if (!tronAddress) arrResetBalance.push('tron'); if (!oraiAddress) arrResetBalance.push('keplr'); if (!btcAddress) arrResetBalance.push('bitcoin'); - if (!tonAddress) arrResetBalance.push('ton'); arrResetBalance.length && handleResetBalance(arrResetBalance); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [oraiAddress, tronAddress, metamaskAddress, btcAddress, tonAddress]); + }, [oraiAddress, tronAddress, metamaskAddress, btcAddress]); const isAnyWalletConnected = Object.values(walletByNetworks).some((wallet) => wallet !== null); useEffect(() => { diff --git a/src/components/WalletManagement/useResetBalance.ts b/src/components/WalletManagement/useResetBalance.ts index b80873e28..12cedf18f 100644 --- a/src/components/WalletManagement/useResetBalance.ts +++ b/src/components/WalletManagement/useResetBalance.ts @@ -1,9 +1,9 @@ -import { EVM_CHAIN_ID_COMMON, WalletType, cosmosTokens, flattenTokens, TonChainId } from '@oraichain/oraidex-common'; +import { EVM_CHAIN_ID_COMMON, WalletType, cosmosTokens, flattenTokens } from '@oraichain/oraidex-common'; import { btcTokens } from 'config/bridgeTokens'; import { useDispatch } from 'react-redux'; import { updateAmounts } from 'reducer/token'; -export type Wallet = WalletType | 'metamask' | 'tron' | 'bitcoin' | 'ton'; +export type Wallet = WalletType | 'metamask' | 'tron' | 'bitcoin'; export const useResetBalance = () => { const dispatch = useDispatch(); @@ -36,9 +36,6 @@ export const useResetBalance = () => { case 'tron': updatedAmounts = resetBalanceTron(); break; - case 'ton': - updatedAmounts = resetBalanceTon(); - break; default: break; } @@ -66,10 +63,5 @@ export const useResetBalance = () => { return Object.fromEntries(tronTokens.map((t) => [t.denom, '0'])); }; - const resetBalanceTon = () => { - const tronTokens = flattenTokens.filter((token) => token.chainId === 'ton'); - return Object.fromEntries(tronTokens.map((t) => [t.denom, '0'])); - }; - return { handleResetBalance }; }; diff --git a/src/components/WalletManagement/walletConfig.ts b/src/components/WalletManagement/walletConfig.ts index de453d383..23bbf2269 100644 --- a/src/components/WalletManagement/walletConfig.ts +++ b/src/components/WalletManagement/walletConfig.ts @@ -1,19 +1,12 @@ import { WalletType as WalletCosmosType } from '@oraichain/oraidex-common/build/constant'; -import { - cosmosNetworksWithIcon, - evmNetworksIconWithoutTron, - tronNetworksWithIcon, - btcNetworksWithIcon, - tonNetworksWithIcon -} from 'helper'; -import TonIcon from 'assets/icons/ton.svg?react'; import KeplrIcon from 'assets/icons/keplr-icon.svg?react'; import MetamaskIcon from 'assets/icons/metamask-icon.svg?react'; import OwalletIcon from 'assets/icons/owallet-icon.svg?react'; import TronIcon from 'assets/icons/tron-icon.svg?react'; +import { cosmosNetworksWithIcon, evmNetworksIconWithoutTron, tronNetworksWithIcon, btcNetworksWithIcon } from 'helper'; -export type NetworkType = 'cosmos' | 'evm' | 'tron' | 'bitcoin' | 'ton'; -export type WalletType = WalletCosmosType | 'metamask' | 'tronLink' | 'eip191' | 'bitcoin' | 'ton'; +export type NetworkType = 'cosmos' | 'evm' | 'tron' | 'bitcoin'; +export type WalletType = WalletCosmosType | 'metamask' | 'tronLink' | 'eip191' | 'bitcoin'; export type WalletNetwork = { icon: React.FunctionComponent< React.SVGProps & { @@ -101,22 +94,7 @@ export const btcWallets: WalletNetwork[] = [ } ]; -export const tonWallets: WalletNetwork[] = [ - { - icon: TonIcon, - name: 'TonConnect', - nameRegistry: 'ton', - isActive: true - } -]; - -export const allWallets: WalletNetwork[] = [ - ...cosmosWallets, - ...tronWallets, - ...evmWallets, - ...btcWallets, - ...tonWallets -]; +export const allWallets: WalletNetwork[] = [...cosmosWallets, ...tronWallets, ...evmWallets, ...btcWallets]; export const walletProvider: WalletProvider[] = [ { @@ -138,10 +116,5 @@ export const walletProvider: WalletProvider[] = [ networkType: 'bitcoin', networks: btcNetworksWithIcon, wallets: btcWallets - }, - { - networkType: 'ton', - networks: tonNetworksWithIcon, - wallets: tonWallets } ]; diff --git a/src/config/chainInfos.ts b/src/config/chainInfos.ts index 0a36d51ee..c642bfb09 100644 --- a/src/config/chainInfos.ts +++ b/src/config/chainInfos.ts @@ -5,23 +5,13 @@ import { ChainIdEnum, BridgeAppCurrency, CustomChainInfo, - defaultBech32Config, - getTokensFromNetwork, - TON_ORAICHAIN_DENOM, - HMSTR_ORAICHAIN_DENOM, - TON_ALL_OSMOSIS_CONTRACT, - TON_OSMOSIS_CONTRACT + defaultBech32Config } from '@oraichain/oraidex-common'; -import HamsterIcon from 'assets/icons/hmstr.svg?react'; import BitcoinIcon from 'assets/icons/bitcoin.svg?react'; import OraiIcon from 'assets/icons/oraichain.svg?react'; import BTCIcon from 'assets/icons/btc-icon.svg?react'; import OraiLightIcon from 'assets/icons/oraichain_light.svg?react'; -import UsdtIcon from 'assets/icons/tether.svg?react'; -import UsdcIcon from 'assets/icons/usd_coin.svg?react'; -import TonIcon from 'assets/icons/ton.svg?react'; import flatten from 'lodash/flatten'; -import { TON_SCAN, TonChainId, TonNetwork } from 'context/ton-provider'; import { chainIconsInfos, tokensIconInfos, mapListWithIcon } from './iconInfos'; import { CWBitcoinFactoryDenom } from 'helper/constants'; @@ -29,11 +19,6 @@ import { CWBitcoinFactoryDenom } from 'helper/constants'; export const tokensIcon = tokensIconInfos; export const chainIcons = chainIconsInfos; -export const TON_ZERO_ADDRESS = 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'; -export const USDT_TON_CONTRACT = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; -export const jUSDC_TON_CONTRACT = 'EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728'; -export const HMSTR_TON_CONTRACT = 'EQAJ8uWd7EBqsmpSWaRdf_I-8R8-XHwh3gsNKhy-UrdrPcUo'; - const [otherChainTokens, oraichainTokens] = tokens; const OraiBTCToken: BridgeAppCurrency = { coinDenom: 'ORAIBTC', @@ -46,137 +31,6 @@ const OraiBTCToken: BridgeAppCurrency = { } }; -export type AlloyedPool = { - poolId: string; - alloyedToken: string; - sourceToken: string; -}; - -export const OsmosisAlloyedPools: AlloyedPool[] = [ - { - poolId: '2161', - alloyedToken: TON_ALL_OSMOSIS_CONTRACT, - sourceToken: TON_OSMOSIS_CONTRACT - } -]; - -export const OsmosisTokenDenom = { - allTon: TON_ALL_OSMOSIS_CONTRACT, - ton: TON_OSMOSIS_CONTRACT -}; - -export const OsmosisTokenList = [ - { - chainId: 'osmosis-1', - bridgeTo: [TonChainId], - coinDenom: 'TON.orai', - name: 'TON', - symbol: 'TON.orai', - Icon: TonIcon, - contractAddress: null, - denom: OsmosisTokenDenom.ton, - coinMinimalDenom: OsmosisTokenDenom.ton, - coinGeckoId: 'the-open-network', - decimal: 9, - coinDecimals: 9 - }, - { - chainId: 'osmosis-1', - bridgeTo: [TonChainId], - coinDenom: 'TON', - name: 'TON', - symbol: 'TON', - Icon: TonIcon, - contractAddress: null, - denom: OsmosisTokenDenom.allTon, - coinMinimalDenom: OsmosisTokenDenom.allTon, - coinGeckoId: 'the-open-network', - decimal: 9, - coinDecimals: 9, - alloyedToken: true - } -]; - -export const tonNetworkMainnet: CustomChainInfo = { - rest: 'https://toncenter.com/api/v2/jsonRPC', - rpc: 'https://toncenter.com/api/v2/jsonRPC', - chainId: TonChainId, - chainName: 'TON' as any, - bip44: { - coinType: 607 as any - }, - coinType: 607, - Icon: TonIcon, - IconLight: TonIcon, - stakeCurrency: { - coinDenom: 'TON', - coinMinimalDenom: 'ton', - coinDecimals: 9, - coinGeckoId: 'the-open-network', - coinImageUrl: 'https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png' - }, - bech32Config: defaultBech32Config('bc'), - networkType: 'ton' as any, - currencies: [ - { - coinDenom: 'TON', - coinMinimalDenom: 'ton', - coinDecimals: 9, - bridgeTo: ['Oraichain', 'osmosis-1'], - prefixToken: 'ton20_', - contractAddress: TON_ZERO_ADDRESS, - Icon: TonIcon, - coinGeckoId: 'the-open-network', - coinImageUrl: 'https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png', - gasPriceStep: { - low: 0, - average: 0, - high: 0 - } - }, - { - coinDenom: 'USDT', - coinMinimalDenom: 'ton20_usdt', - coinDecimals: 6, - Icon: UsdtIcon, - bridgeTo: ['Oraichain'], - contractAddress: USDT_TON_CONTRACT, - prefixToken: 'ton20_', - coinGeckoId: 'tether' - }, - { - coinDenom: 'HMSTR', - coinMinimalDenom: 'ton20_hamster_kombat', - coinDecimals: 9, - Icon: HamsterIcon, - bridgeTo: ['Oraichain'], - contractAddress: HMSTR_TON_CONTRACT, - prefixToken: 'ton20_', - coinGeckoId: 'hamster-kombat' - }, - { - coinDenom: 'jUSDC', - coinMinimalDenom: 'ton20_usdc', - coinDecimals: 6, - Icon: UsdcIcon, - bridgeTo: ['Oraichain'], - contractAddress: jUSDC_TON_CONTRACT, - prefixToken: 'ton20_', - coinGeckoId: 'usd-coin' - } - ], - get feeCurrencies() { - return this.currencies; - }, - // features: ['isBtc'], - - txExplorer: { - name: 'BlockStream', - txUrl: `${TON_SCAN}/transaction/{txHash}`, - accountUrl: `${TON_SCAN}/{address}` - } -}; - const oraibtcNetwork = { rpc: 'https://btc.rpc.orai.io', rest: 'https://btc.lcd.orai.io/', @@ -267,9 +121,9 @@ export const bitcoinMainnet: CustomChainInfo = { } }; +export const chainInfosWithIcon = mapListWithIcon([...customChainInfos, bitcoinMainnet], chainIcons, 'chainId'); export const oraichainTokensWithIcon = mapListWithIcon(oraichainTokens, tokensIcon, 'coinGeckoId'); export const otherTokensWithIcon = mapListWithIcon(otherChainTokens, tokensIcon, 'coinGeckoId'); -export const tonNetworkTokens = getTokensFromNetwork(tonNetworkMainnet); export const tokensWithIcon = [otherTokensWithIcon, oraichainTokensWithIcon]; export const flattenTokensWithIcon = flatten(tokensWithIcon); @@ -290,7 +144,18 @@ export const OraiToken: BridgeAppCurrency = { }; export const oraichainNetwork: CustomChainInfo = { - ...customOraichainNetwork + ...customOraichainNetwork, + currencies: [ + ...customOraichainNetwork.currencies + // { + // coinDenom: 'BTC V2', + // coinGeckoId: 'bitcoin', + // coinMinimalDenom: CWBitcoinFactoryDenom, + // bridgeTo: ['bitcoin'] as any, + // coinDecimals: 14 as any, + // coinImageUrl: 'https://s2.coinmarketcap.com/static/img/coins/64x64/1.png' + // } + ] }; export const OraiBTCBridgeNetwork = { @@ -347,12 +212,7 @@ export const OraiBTCBridgeNetwork = { } }; -export const chainInfosWithSdk = [ - ...customChainInfos, - bitcoinMainnet, - oraibtcNetwork - // tonNetworkMainnet -]; +export const chainInfosWithSdk = [...customChainInfos, bitcoinMainnet, oraibtcNetwork]; export const chainInfos = mapListWithIcon(chainInfosWithSdk, chainIcons, 'chainId'); // exclude kawaiverse subnet and other special evm that has different cointype @@ -360,6 +220,4 @@ export const evmChains = chainInfos.filter( (c) => c.networkType === 'evm' && c.bip44.coinType === 60 && c.chainId !== '0x1ae6' ); -export const chainInfosWithIcon = mapListWithIcon(chainInfosWithSdk, chainIcons, 'chainId'); - -export const btcChains = chainInfos.filter((c) => c.networkType === 'bitcoin'); +export const btcChains = chainInfos.filter((c) => c.networkType === ('bitcoin' as any)); diff --git a/src/config/iconInfos.ts b/src/config/iconInfos.ts index 8c002a4ca..d47cbc70f 100644 --- a/src/config/iconInfos.ts +++ b/src/config/iconInfos.ts @@ -28,9 +28,9 @@ import PepeIcon from 'assets/icons/pepe.svg?react'; import CatIcon from 'assets/icons/icon-simoncat.svg?react'; import HmstrIcon from 'assets/icons/hmstr.svg?react'; import DogecoinIcon from 'assets/icons/dogecoin.svg?react'; +import SolanaIcon from 'assets/icons/solana.svg?react'; import { CustomChainInfo, TokenItemType } from '@oraichain/oraidex-common'; import { bitcoinChainId } from 'helper/constants'; -import { TonChainId } from 'context/ton-provider'; export type TokenIcon = Pick; export type ChainIcon = Pick; @@ -170,6 +170,11 @@ export const tokensIconInfos: TokenIcon[] = [ coinGeckoId: 'dogecoin', Icon: DogecoinIcon, IconLight: DogecoinIcon + }, + { + coinGeckoId: 'solana', + Icon: SolanaIcon, + IconLight: SolanaIcon } ]; @@ -243,11 +248,6 @@ export const chainIconsInfos: ChainIcon[] = [ chainId: 'celestia', Icon: CelestiaIcon, IconLight: CelestiaIcon - }, - { - chainId: TonChainId, - Icon: TonIcon, - IconLight: TonIcon } ]; diff --git a/src/config/networks.ts b/src/config/networks.ts index e0af84e6e..ba8d01b4e 100644 --- a/src/config/networks.ts +++ b/src/config/networks.ts @@ -15,10 +15,8 @@ import { CW20_STAKING_CONTRACT, AMM_V3_CONTRACT } from '@oraichain/oraidex-common'; -import { CW_TON_BRIDGE, TOKEN_FACTORY } from 'context/ton-provider'; -export const network: CustomChainInfo & - NetworkConfig & { pool_v3: string; indexer_v3: string; CW_TON_BRIDGE: string; TOKEN_FACTORY: string } = { +export const network: CustomChainInfo & NetworkConfig & { pool_v3: string; indexer_v3: string } = { ...oraichainNetwork, prefix: oraichainNetwork.bech32Config.bech32PrefixAccAddr, denom: 'orai', @@ -37,7 +35,6 @@ export const network: CustomChainInfo & multicall: MULTICALL_CONTRACT, explorer: 'https://scan.orai.io', pool_v3: AMM_V3_CONTRACT, - CW_TON_BRIDGE: CW_TON_BRIDGE, - TOKEN_FACTORY: TOKEN_FACTORY, indexer_v3: 'https://ammv3-indexer.oraidex.io/' }; + \ No newline at end of file diff --git a/src/context/ton-provider.tsx b/src/context/ton-provider.tsx deleted file mode 100644 index 493aaa3fb..000000000 --- a/src/context/ton-provider.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { TonConnectUIProvider } from '@tonconnect/ui-react'; - -export const TonChainId: any = 'ton'; - -export enum TonNetwork { - Mainnet = 'mainnet', - Testnet = 'testnet' -} - -export const TonInteractionContract = { - [TonNetwork.Mainnet]: { - lightClient: 'EQDzy_POlimFDyzrHd3OQsb9sZCngyG3O7Za4GRFzM-rrO93', - whitelist: 'EQATDM6mfPZjPDMD9TVa6D9dlbmAKY5w6xOJiTXJ9Nqj_dsu', - bridgeAdapter: 'EQC-aFP0rJXwTgKZQJPbPfTSpBFc8wxOgKHWD9cPvOl_DnaY' - }, - [TonNetwork.Testnet]: { - lightClient: 'EQDzy_POlimFDyzrHd3OQsb9sZCngyG3O7Za4GRFzM-rrO93', - whitelist: 'EQAbJI3NZKGcVu-ec_z_LcmXca9ZOtzkgCW5H9glnWBDpaFg', - bridgeAdapter: 'EQA3ISho4fpW3wmCkKEwsyXulIw7vLf-2jxso40ul3QQJ_O7' - } -}; - -export const TON_SCAN = 'https://tonviewer.com'; -export const MANIFEST_URL = `${window.location?.origin}/manifest.json`; - -export const CW_TON_BRIDGE = 'orai159l8l9c5ckhqpuwdfgs9p4v599nqt3cjlfahalmtrhfuncnec2ms5mz60e'; -export const TOKEN_FACTORY = 'orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9'; - -export const TonProvider = (props: React.PropsWithChildren<{}>) => { - return {props.children}; -}; diff --git a/src/helper/index.tsx b/src/helper/index.tsx index 707807833..cac45fbc6 100644 --- a/src/helper/index.tsx +++ b/src/helper/index.tsx @@ -11,8 +11,7 @@ import { MULTIPLIER, TRON_SCAN, EVM_CHAIN_ID_COMMON, - WalletType as WalletCosmosType, - oraichainNetwork + WalletType as WalletCosmosType } from '@oraichain/oraidex-common'; import { network } from 'config/networks'; import { serializeError } from 'serialize-error'; @@ -30,12 +29,8 @@ import { MetamaskOfflineSigner } from 'libs/eip191'; import Keplr from 'libs/keplr'; import { WalletsByNetwork } from 'reducer/wallet'; import { evmChainInfos } from 'config/evmChainInfos'; -import { TonChainId } from 'context/ton-provider'; -import { toUserFriendlyAddress, useTonAddress } from '@tonconnect/ui-react'; import DefaultIcon from 'assets/icons/tokens.svg?react'; import { numberWithCommas } from './format'; -import { getHttpEndpoint } from '@orbs-network/ton-access'; -import { TonClient } from '@ton/ton'; export interface Tokens { denom?: string; @@ -74,17 +69,12 @@ export const evmNetworksIconWithoutTron = chainInfosWithIcon.filter( export const tronNetworks = chainInfos.filter((c) => c.chainId === '0x2b6653dc'); export const tronNetworksWithIcon = chainInfosWithIcon.filter((c) => c.chainId === '0x2b6653dc'); export const btcNetworksWithIcon = chainInfosWithIcon.filter((c) => c.chainId === bitcoinChainId); -export const tonNetworksWithIcon = chainInfosWithIcon.filter((c) => c.chainId === TonChainId); export const filterChainBridge = (token: Tokens, item: CustomChainInfo) => { const tokenCanBridgeTo = token.bridgeTo ?? ['Oraichain']; return tokenCanBridgeTo.includes(item.chainId); }; -export const findChainByChainId = (chainId: string) => { - return networks.find((n) => n.chainId === chainId) || oraichainNetwork; -}; - export const getDenomEvm = (): EvmDenom => { switch (Number(window.ethereumDapp?.chainId)) { case Networks.bsc: @@ -108,10 +98,6 @@ export const getSpecialCoingecko = (fromCoingecko: string, toCoingecko: string) }; export const getTransactionUrl = (chainId: NetworkChainId, transactionHash: string) => { - if (chainId === 'ton') { - return `https://tonscan.org/address/${transactionHash}`; - } - switch (Number(chainId)) { case Networks.bsc: return `${BSC_SCAN}/tx/${transactionHash}`; @@ -417,11 +403,7 @@ export const getAddressTransferForEvm = async (walletByNetworks: WalletsByNetwor export const getAddressTransfer = async (network: CustomChainInfo, walletByNetworks: WalletsByNetwork) => { try { let address = ''; - if (network.networkType === 'ton') { - address = JSON.parse(JSON.parse(localStorage.getItem('persist:root'))?.config)?.tonAddress; - // address = useTonAddress(); - // address = toUserFriendlyAddress(window.Ton?.account?.address); - } else if (network.networkType === 'evm') { + if (network.networkType === 'evm') { address = await getAddressTransferForEvm(walletByNetworks, network); } else if (isConnectSpecificNetwork(walletByNetworks.cosmos)) { address = await window.Keplr.getKeplrAddr(network.chainId); @@ -680,40 +662,6 @@ export const getIconToken = ({ isLightTheme, denom, width = 18, height = 18 }) = return ; }; -export const retryOrbs = async (fn, retryTimes = 30, delay = 2000) => { - try { - return await fn(); - } catch (error) { - let response = error?.response; - let message = response?.data?.error; - if (message?.includes('No working liteservers')) { - await sleep(delay * 2); - return await retryOrbs(fn, retryTimes, delay); - } - if (retryTimes > 0) { - await sleep(delay * 5); - return await retryOrbs(fn, retryTimes - 1, delay); - } - } -}; - -export const getTonClient = async () => { - try { - const endpoint = await getHttpEndpoint({ - network: 'mainnet' - }); - const client = new TonClient({ - endpoint - }); - return client; - } catch (err) { - return new TonClient({ - endpoint: - 'https://ton.access.orbs.network/55013c0ff5Bd3F8B62C092Ab4D238bEE463E5501/1/mainnet/toncenter-api-v2/jsonRPC' - }); - } -}; - export const handleErrorRateLimit = (errorMsg: string) => { if (!errorMsg) { return; diff --git a/src/hooks/useLoadTokens.ts b/src/hooks/useLoadTokens.ts index bfdd8229a..09321829d 100644 --- a/src/hooks/useLoadTokens.ts +++ b/src/hooks/useLoadTokens.ts @@ -25,17 +25,14 @@ import { getEvmAddress, tronToEthAddress } from '@oraichain/oraidex-common'; -import { chainInfos, evmChains, TON_ZERO_ADDRESS, tonNetworkMainnet } from 'config/chainInfos'; import { UniversalSwapHelper } from '@oraichain/oraidex-universal-swap'; +import { chainInfos, evmChains } from 'config/chainInfos'; import { network } from 'config/networks'; import { ethers } from 'ethers'; import axios from 'rest/request'; import { reduce } from 'lodash'; import { getUtxos } from 'pages/Balance/helpers'; import { bitcoinChainId } from 'helper/constants'; -import { getHttpEndpoint } from '@orbs-network/ton-access'; -import { Address, TonClient } from '@ton/ton'; -import { JettonMinter, JettonWallet } from '@oraichain/ton-bridge-contracts'; export type LoadTokenParams = { refresh?: boolean; @@ -43,7 +40,6 @@ export type LoadTokenParams = { oraiAddress?: string; tronAddress?: string; btcAddress?: string; - tonAddress?: string; }; async function loadNativeBalance(dispatch: Dispatch, address: string, tokenInfo: { chainId: string; rpc: string }) { @@ -76,7 +72,7 @@ const timer = {}; async function loadTokens( dispatch: Dispatch, - { oraiAddress, metamaskAddress, tronAddress, btcAddress, tonAddress }: LoadTokenParams + { oraiAddress, metamaskAddress, tronAddress, btcAddress }: LoadTokenParams ) { try { if (oraiAddress) { @@ -135,13 +131,6 @@ async function loadTokens( ); }, 2000); } - - if (tonAddress) { - clearTimeout(timer[btcAddress]); - timer[tonAddress] = setTimeout(() => { - loadAllBalanceTonToken(dispatch, tonAddress); - }, 2000); - } } catch (error) { console.log('error load balance: ', error); } @@ -324,6 +313,7 @@ async function loadBtcEntries( } async function loadEvmAmounts(dispatch: Dispatch, evmAddress: string, chains: CustomChainInfo[]) { + console.log('---', chains); const amountDetails = Object.fromEntries( flatten(await Promise.all(chains.map((chain) => loadEvmEntries(evmAddress, chain)))) ); @@ -355,93 +345,6 @@ async function loadKawaiiSubnetAmount(dispatch: Dispatch, kwtAddress: string) { dispatch(updateAmounts(amountDetails)); } -const loadBalanceByToken = async (dispatch: Dispatch, addressTon: string, addressToken?: string) => { - try { - // get the decentralized RPC endpoint - const endpoint = await getHttpEndpoint(); - const client = new TonClient({ - endpoint - }); - if (addressToken === TON_ZERO_ADDRESS) { - const balance = await client.getBalance(Address.parse(addressTon)); - - return { ton: balance || '0' }; - } - - const token = tonNetworkMainnet.currencies.find((e) => e.contractAddress === addressToken); - - const jettonMinter = JettonMinter.createFromAddress(Address.parse(addressToken)); - const jettonMinterContract = client.open(jettonMinter); - const jettonWalletAddress = await jettonMinterContract.getWalletAddress(Address.parse(addressTon)); - const jettonWallet = JettonWallet.createFromAddress(jettonWalletAddress); - const jettonWalletContract = client.open(jettonWallet); - const balance = await jettonWalletContract.getBalance(); - - dispatch(updateAmounts({ [token.coinMinimalDenom]: (balance.amount || '0').toString() })); - return { [token.coinMinimalDenom]: balance.amount || '0' }; - } catch (error) { - console.log('error load ton balance', error); - return {}; - } -}; - -const loadAllBalanceTonToken = async (dispatch: Dispatch, tonAddress: string, listToken?: string[]) => { - if (!tonAddress) return; - - const allTokens = !listToken?.length - ? tonNetworkMainnet.currencies - : tonNetworkMainnet.currencies.filter((e) => listToken.includes(e.contractAddress)); - - const endpoint = await getHttpEndpoint(); - const client = new TonClient({ - endpoint - }); - - const fullData = await Promise.all( - allTokens.map(async (item) => { - if (item.contractAddress === TON_ZERO_ADDRESS) { - // native token: TON - const balance = await client.getBalance(Address.parse(tonAddress)); - - return { - balance: balance, - jettonWalletAddress: '', - token: item - }; - } - const jettonMinter = JettonMinter.createFromAddress(Address.parse(item.contractAddress)); - - const jettonMinterContract = client.open(jettonMinter); - - const jettonWalletAddress = await jettonMinterContract.getWalletAddress(Address.parse(tonAddress)); - - const jettonWallet = JettonWallet.createFromAddress(jettonWalletAddress); - const jettonWalletContract = client.open(jettonWallet); - const balance = await jettonWalletContract.getBalance(); - - return { - balance: balance.amount, - jettonWalletAddress, - token: item - }; - }) - ); - - let amountDetail: AmountDetails = {}; - fullData?.map((data) => { - const token = tonNetworkMainnet.currencies.find((e) => e.contractAddress === data.token.contractAddress); - - amountDetail = { - ...amountDetail, - [token.coinMinimalDenom]: (data.balance || '0').toString() - }; - }); - - dispatch(updateAmounts(amountDetail)); - - return amountDetail; -}; - export default function useLoadTokens(): (params: LoadTokenParams) => Promise { const dispatch = useDispatch(); return loadTokens.bind(null, dispatch); diff --git a/src/hooks/useTokenFee.ts b/src/hooks/useTokenFee.ts index d6e2400cd..95b1a3e18 100644 --- a/src/hooks/useTokenFee.ts +++ b/src/hooks/useTokenFee.ts @@ -85,14 +85,6 @@ export const useRelayerFeeToken = (originalFromToken: TokenItemType, originalToT () => { const routerClient = new OraiswapRouterQueryClient(window.client, network.router); const oraiToken = oraichainTokens.find((token) => token.coinGeckoId === 'oraichain-token'); - - if (!oraiToken || !originalToToken) { - return { - displayAmount: 0, - amount: '0' - }; - } - return UniversalSwapHelper.handleSimulateSwap({ originalFromInfo: oraiToken, originalToInfo: originalToToken, @@ -154,12 +146,6 @@ export const useUsdtToBtc = (amount) => { const { data } = useQuery( ['convert-btc-to-usdt', originalFromToken, originalToToken], () => { - if (!originalToToken || !originalFromToken) { - return { - displayAmount: 0, - amount: '0' - }; - } return UniversalSwapHelper.handleSimulateSwap({ originalFromInfo: originalToToken, originalToInfo: originalFromToken, diff --git a/src/hooks/useTonConnectAddress.ts b/src/hooks/useTonConnectAddress.ts deleted file mode 100644 index 4cc2103ac..000000000 --- a/src/hooks/useTonConnectAddress.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { useTonAddress, useTonConnectModal, useTonConnectUI, useTonWallet } from '@tonconnect/ui-react'; -import { useEffect } from 'react'; -import useConfigReducer from './useConfigReducer'; -import useWalletReducer from './useWalletReducer'; - -const useTonConnectAddress = () => { - const userFriendlyAddress = useTonAddress(); - const wallet = useTonWallet(); - const { open: openConnect } = useTonConnectModal(); - const [tonConnectUI] = useTonConnectUI(); - const [tonAddress, setTonAddress] = useConfigReducer('tonAddress'); - const [walletByNetworks, setWalletByNetworks] = useWalletReducer('walletsByNetwork'); - - useEffect(() => { - if (!(userFriendlyAddress && wallet)) { - setTonAddress(undefined); - setWalletByNetworks({ - ...walletByNetworks, - ton: null - }); - return; - } - - setTonAddress(userFriendlyAddress); - - setWalletByNetworks({ - ...walletByNetworks, - ton: 'ton' - }); - - // handleSetTonWallet({ - // tonWallet: - // wallet?.["appName"] || - // (wallet?.device?.appName?.toLowerCase() as TonWallet), - // }); - }, [userFriendlyAddress, wallet]); - - const handleDisconnectTon = async () => { - try { - if (tonConnectUI.connected) { - await tonConnectUI.disconnect(); - } - - if (tonAddress && walletByNetworks.ton) { - // && walletType === tonWallet - // handleSetTonAddress({ tonAddress: undefined }); - // handleSetTonWallet({ tonWallet: undefined }); - - setTonAddress(undefined); - } - } catch (error) { - console.log('error disconnect TON :>>', error); - } - }; - - const handleConnectTon = () => { - try { - openConnect(); - } catch (error) { - console.log('error', error); - } - }; - - return { - handleConnectTon, - handleDisconnectTon - }; -}; - -export default useTonConnectAddress; diff --git a/src/index.tsx b/src/index.tsx index 36535e1de..e287ec025 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -19,7 +19,11 @@ import { persistor, store } from 'store/configure'; import './index.scss'; import App from './layouts/App'; import ScrollToTop from './layouts/ScrollToTop'; -import { TonProvider } from 'context/ton-provider'; + +// const client = new Client({ +// url: 'http://10.10.20.72:3000/', +// exchanges: [cacheExchange, fetchExchange] +// }); const queryClient = new QueryClient(); @@ -69,9 +73,7 @@ const initApp = async () => { - - - + diff --git a/src/layouts/App.tsx b/src/layouts/App.tsx index 1f735ddba..724efc7c9 100644 --- a/src/layouts/App.tsx +++ b/src/layouts/App.tsx @@ -26,21 +26,16 @@ import './index.scss'; import Menu from './Menu'; import { NoticeBanner } from './NoticeBanner'; import Sidebar from './Sidebar'; -import { useTonConnectUI } from '@tonconnect/ui-react'; import SingletonOraiswapV3 from 'libs/contractSingleton'; import { getCosmWasmClient } from 'libs/cosmjs'; -import { useLoadWalletsTon } from 'pages/Balance/hooks/useLoadWalletsTon'; -import { TonNetwork } from 'context/ton-provider'; const App = () => { const [address, setOraiAddress] = useConfigReducer('address'); const [, setTronAddress] = useConfigReducer('tronAddress'); - const [tonAddress] = useConfigReducer('tonAddress'); const [, setMetamaskAddress] = useConfigReducer('metamaskAddress'); const [, setBtcAddress] = useConfigReducer('btcAddress'); const [, setStatusChangeAccount] = useConfigReducer('statusChangeAccount'); const loadTokenAmounts = useLoadTokens(); - const [tonConnectUI] = useTonConnectUI(); const [persistVersion, setPersistVersion] = useConfigReducer('persistVersion'); const [theme] = useConfigReducer('theme'); const [walletByNetworks] = useWalletReducer('walletsByNetwork'); @@ -53,15 +48,6 @@ const App = () => { useTronEventListener(); - // init TON - useEffect(() => { - window.Ton = tonConnectUI; - }, [tonConnectUI]); - - useLoadWalletsTon({ - tonNetwork: TonNetwork.Mainnet - }); - useEffect(() => { (async () => { if (address) { @@ -262,7 +248,6 @@ const App = () => { return tronAddress; }; - // TODO: owallet not support TON. need to update in next time const keplrHandler = async () => { try { polyfillForMobileMode(); @@ -275,8 +260,7 @@ const App = () => { oraiAddress, metamaskAddress, tronAddress, - btcAddress, - tonAddress + btcAddress }); } catch (error) { console.log('Error: ', error.message); diff --git a/src/libs/duckdb.ts b/src/libs/duckdb.ts index 8e36515d7..21a248dbc 100644 --- a/src/libs/duckdb.ts +++ b/src/libs/duckdb.ts @@ -1,24 +1,7 @@ import { NetworkChainId } from '@oraichain/oraidex-common'; import * as duckdb from '@duckdb/duckdb-wasm'; -import duckdb_wasm from '@duckdb/duckdb-wasm/dist/duckdb-mvp.wasm?url'; -import mvp_worker from '@duckdb/duckdb-wasm/dist/duckdb-browser-mvp.worker.js?url'; -import duckdb_wasm_next from '@duckdb/duckdb-wasm/dist/duckdb-eh.wasm?url'; -import eh_worker from '@duckdb/duckdb-wasm/dist/duckdb-browser-eh.worker.js?url'; import { get, set } from 'idb-keyval'; - -const MANUAL_BUNDLES = { - mvp: { - mainModule: duckdb_wasm, - mainWorker: mvp_worker - }, - eh: { - mainModule: duckdb_wasm_next, - // mainWorker: new URL('@duckdb/duckdb-wasm/dist/duckdb-browser-eh.worker.js', import.meta.url).toString(), - mainWorker: eh_worker - } -}; -// Select a bundle based on browser checks -const bundle = await duckdb.selectBundle(MANUAL_BUNDLES); +import eh_worker from '@duckdb/duckdb-wasm/dist/duckdb-eh.wasm?url'; export type TransactionHistory = { initialTxHash: string; @@ -65,9 +48,6 @@ const decompress = async (buf: Uint8Array) => { } }; -const worker = new Worker(bundle.mainWorker); -const logger = import.meta.env.NODE_ENV === 'development' ? new duckdb.ConsoleLogger() : new duckdb.VoidLogger(); - export class DuckDb { static instance: DuckDb; @@ -77,8 +57,11 @@ export class DuckDb { if (!DuckDb.instance) { // Select a bundle based on browser checks // Instantiate the asynchronus version of DuckDB-Wasm - const db = new duckdb.AsyncDuckDB(logger, worker); - await db.instantiate(bundle.mainModule, bundle.pthreadWorker); + const db = new duckdb.AsyncDuckDB( + import.meta.env.NODE_ENV === 'development' ? new duckdb.ConsoleLogger() : new duckdb.VoidLogger(), + new Worker(new URL('@duckdb/duckdb-wasm/dist/duckdb-browser-eh.worker.js', import.meta.url).toString()) + ); + await db.instantiate(eh_worker); const conn = await db.connect(); DuckDb.instance = new DuckDb(conn, db); } diff --git a/src/libs/utils.ts b/src/libs/utils.ts index c4dcb1fd4..c31c8feb8 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -75,7 +75,7 @@ export const toSumDisplay = (amounts: AmountDetails): number => { // update later const balance = amounts[denom]; if (!balance) continue; - amount += toDisplay(balance, tokenMap[denom]?.decimals); + amount += toDisplay(balance, tokenMap[denom].decimals); } return amount; }; diff --git a/src/pages/Balance/Balance.module.scss b/src/pages/Balance/Balance.module.scss index a15f7ad3f..642f89073 100644 --- a/src/pages/Balance/Balance.module.scss +++ b/src/pages/Balance/Balance.module.scss @@ -94,8 +94,10 @@ width: 100%; } - @include theme { - background: theme-get('neutral-surface-bg-btn-disabled'); + background: #2b2d3b; + + &.light { + background-color: $light-bg-primary-box; } text-align: center; @@ -129,7 +131,7 @@ &_form { width: 420px; - background: #232521; + background: #2b2d3b; border-radius: 8px; padding: 12px; height: 56px; @@ -171,9 +173,9 @@ flex-direction: row; .tfBtn { - background-color: $primary-bg-btn; @include theme() { - color: theme-get('neutral-text-text-btn-default'); + background-color: theme-get('bg-btn-primary'); + box-shadow: theme-get('shadow-btn'); } border-radius: 8px; @@ -271,11 +273,11 @@ &_element { margin-bottom: 20px; - background-color: #232521; + background-color: #191b21; border-radius: 16px; &.light { - background-color: #f7f7f7; + background-color: $light-bg-primary-box; } } } @@ -283,11 +285,11 @@ .balances { display: flex; justify-content: center; - padding: 12px 8px 0 8px; + padding-top: 12px; width: 100%; - @include theme { - color: theme-get('colors-neutral-text-text-token-name'); + .light { + color: #a871df; } .box { @@ -318,16 +320,7 @@ } :hover { - text-decoration: underline; - filter: brightness(1.5); - } - - svg { - path { - @include theme { - fill: theme-get('primary-surface-default-dark-3'); - } - } + color: #a871df; } } } diff --git a/src/pages/Balance/StuckOraib/style.module.scss b/src/pages/Balance/StuckOraib/style.module.scss index d76284e25..6afd0a774 100644 --- a/src/pages/Balance/StuckOraib/style.module.scss +++ b/src/pages/Balance/StuckOraib/style.module.scss @@ -1,56 +1,56 @@ @import 'src/styles/mixins'; -.icon { - margin-right: 20px; +.icon{ + margin-right: 20px; } .bridgeBalances { - padding: 9px 12px; - border-radius: 8px; - background-color: #232521; - display: flex; - align-items: center; - justify-content: space-between; - border: 1px solid transparent; - position: sticky; - top: 0; - float: right; - - &:hover { - border-color: #a871df; - } - - .stuckText { - margin: 0 10px; - cursor: pointer; - } - - .loading { - @include desktop { - width: 50%; - height: 180px; + padding: 9px 12px; + border-radius: 8px; + background-color: #2B2D3B; + display: flex; + align-items: center; + justify-content: space-between; + border: 1px solid transparent; + position: sticky; + top: 0; + float: right; + &:hover { + border-color: #A871DF; } - @include flex(); - } -} + .stuckText { + margin: 0 10px; + cursor: pointer; + } -.stuckToken { - display: flex; - justify-content: space-between; - align-items: center; - padding: 7px 10px; - &:hover { - background-color: #232521; - } + .loading { + @include desktop { + width: 50%; + height: 180px; + } + + @include flex(); + } +} - & > div { +.stuckToken { display: flex; + justify-content: space-between; align-items: center; - } + padding: 7px 10px; - .name { - margin-left: 10px; - } -} + &:hover { + background-color: #2B2D3B; + } + + &>div { + display: flex; + align-items: center; + } + + .name { + margin-left: 10px; + } +} \ No newline at end of file diff --git a/src/pages/Balance/TokenItem/index.module.scss b/src/pages/Balance/TokenItem/index.module.scss index 4a0523237..da2da0dbb 100644 --- a/src/pages/Balance/TokenItem/index.module.scss +++ b/src/pages/Balance/TokenItem/index.module.scss @@ -70,9 +70,7 @@ font-size: 14px; line-height: 150%; text-align: center; - @include theme() { - color: theme-get('neutral-8'); - } + color: #777e90; align-self: flex-start; margin: 8px 8px 8px 0; } @@ -89,13 +87,13 @@ } .tokenWrapper:hover { - background: #232521a5; + background: #2b2d3b; box-sizing: border-box; } .tokenWrapper.light:hover { background-color: #fcfcfc; - border: 1px solid $primary-surface-default-light; + border: 1px solid $blue-color; } .tokenWrapper { @@ -129,11 +127,11 @@ } &.active { - background: #131412; + background: #191b21; &.light { - background-color: #f7f7f7; + background-color: #fcfcfc; } - border: 1px solid #2f5711; + border: 1px solid #a871df; box-sizing: border-box; border-radius: 12px; @@ -189,10 +187,7 @@ font-weight: 600; font-size: 16px; line-height: 100%; - - @include theme { - color: theme-get('neutral-8'); - } + color: #777e90; &.token { align-self: flex-end; @@ -213,39 +208,24 @@ .balanceBtn { cursor: pointer; + background: #191b21; border-radius: 8px; padding: 8px; margin-left: 4px; margin-right: 4px; - - @include theme { - border: 1px solid transparent; - background: theme-get('primary-surface-default-subtle'); - color: theme-get('primary-surface-default-dark-3'); - } - - &:hover { - @include theme { - border: 1px solid theme-get('primary-surface-default-dark-3'); - } - } + color: #a871df; } } .amount { text-align: right; + background: #1e1e21; border-radius: 8px; height: 48px; width: 180px; padding: 12px; box-sizing: border-box; - // background: #1e1e21; - // color: #505665; - - @include theme { - background: theme-get('neutral-surface-bg-box'); - color: theme-get('colors-neutral-text-text-token-name'); - } + color: #505665; font-weight: 600; font-size: 24px; diff --git a/src/pages/Balance/TokenItem/index.tsx b/src/pages/Balance/TokenItem/index.tsx index 1faf64712..e052dc847 100644 --- a/src/pages/Balance/TokenItem/index.tsx +++ b/src/pages/Balance/TokenItem/index.tsx @@ -24,7 +24,6 @@ export interface TokenItemProps { isBtcToken?: boolean; isFastMode?: boolean; setIsFastMode?: Function; - setToNetworkChainId: Function; } const TokenItem: React.FC = ({ @@ -40,8 +39,7 @@ const TokenItem: React.FC = ({ isBtcOfOwallet, isBtcToken, isFastMode, - setIsFastMode, - setToNetworkChainId + setIsFastMode }) => { let tokenIcon = tokensIcon.find((tok) => tok.coinGeckoId === token.coinGeckoId); if (!tokenIcon) { @@ -96,7 +94,6 @@ const TokenItem: React.FC = ({ convertKwt={convertKwt} isFastMode={isFastMode} setIsFastMode={setIsFastMode} - setToNetwork={setToNetworkChainId} /> )} diff --git a/src/pages/Balance/TransferConvertToken/index.module.scss b/src/pages/Balance/TransferConvertToken/index.module.scss index 477301413..190bc933e 100644 --- a/src/pages/Balance/TransferConvertToken/index.module.scss +++ b/src/pages/Balance/TransferConvertToken/index.module.scss @@ -4,6 +4,12 @@ .fastMode { margin-top: 8px; + + .switch { + &::before { + background-color: #8363c9; + } + } } .transferTab { @@ -11,11 +17,12 @@ margin-top: 20px; .tfBtn { - background-color: $primary-bg-btn; @include theme() { - color: theme-get('neutral-text-text-btn-default'); + background-color: theme-get('bg-btn-primary'); + box-shadow: theme-get('shadow-btn'); } + color: $white-color; border-radius: 8px; padding: 16px; @include flex(); @@ -51,9 +58,7 @@ font-size: 14px; line-height: 150%; text-align: center; - @include theme() { - color: theme-get('neutral-8'); - } + color: #777e90; align-self: flex-start; margin: 8px 8px 8px 0; } @@ -91,10 +96,7 @@ font-weight: 600; font-size: 16px; line-height: 100%; - - @include theme { - color: theme-get('neutral-8'); - } + color: #777e90; &.token { align-self: flex-end; @@ -118,19 +120,8 @@ } .balanceBtn { - @include theme { - border: 1px solid transparent; - background: theme-get('primary-surface-default-subtle'); - color: theme-get('primary-surface-default-dark-3'); - } - - &:hover { - @include theme { - border: 1px solid theme-get('primary-surface-default-dark-3'); - } - } - cursor: pointer; + background: #191b21; border-radius: 8px; width: 66px; padding: 10px; @@ -146,22 +137,26 @@ margin-left: 8px; padding: 6px; } + + color: #a871df; } } .amount { text-align: left; + background: #2b2d3b; border-radius: 8px; height: 48px; width: 180px; padding: 12px; box-sizing: border-box; + color: #ebebeb; font-weight: 600; font-size: 24px; - @include theme { - background: theme-get('neutral-surface-bg-btn-disabled'); - color: theme-get('colors-neutral-text-text-token-name'); + &.light { + background: #efefef; + color: $light-text-color; } @include mobile { @@ -193,21 +188,14 @@ } .balanceBtn { - @include theme { - border: 1px solid transparent; - background: theme-get('primary-surface-default-subtle'); - color: theme-get('primary-surface-default-dark-3'); - } - - &:hover { - @include theme { - border: 1px solid theme-get('primary-surface-default-dark-3'); - } - } - + background: #2e283d; font-weight: 500; border-radius: 8px; + &.light { + background-color: #efe6f8; + } + @include desktop { width: 66px; font-size: 16px; @@ -219,6 +207,7 @@ } height: 48px; + color: #a871df; text-align: center; } @@ -229,9 +218,8 @@ display: flex; gap: 10px; - background-color: $primary-bg-btn; - @include theme() { - color: theme-get('neutral-text-text-btn-default'); + &.light { + background-color: $blue-color; } } } @@ -282,15 +270,12 @@ .address { margin-left: 10px; border-radius: 8px; + border: 1px solid #777e90; padding: 2px 8px; + color: #777e90; font-size: 13px; display: flex; justify-content: center; - - @include theme { - color: theme-get('neutral-8'); - border: 1px solid theme-get('neutral-8'); - } } } } @@ -301,13 +286,13 @@ cursor: pointer; &_filter { + background: #2b2d3b; text-align: center; border-radius: 8px; padding: 12px; - @include theme { - background: theme-get('neutral-surface-bg-btn-disabled'); - color: theme-get('neutral-8'); + &.light { + background: #efefef; } } @@ -371,8 +356,8 @@ .items { position: absolute; width: 100%; - background: #232521; - box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.1); + background: #2b2d3b; + border: 1.5px solid #5a5270; z-index: 1; &_chain { @@ -390,19 +375,13 @@ li { padding: 12px 24px 12px 24px; - border-radius: 8px; } li:hover { - @include theme { - background-color: theme-get('neutral-6'); - } - filter: brightness(1.25); + background-color: #703cde; div { - @include theme { - color: theme-get('neutral-8'); - } + color: $white-color; } } diff --git a/src/pages/Balance/TransferConvertToken/index.tsx b/src/pages/Balance/TransferConvertToken/index.tsx index 75c540018..826100a1c 100644 --- a/src/pages/Balance/TransferConvertToken/index.tsx +++ b/src/pages/Balance/TransferConvertToken/index.tsx @@ -1,6 +1,5 @@ import { BigDecimal, - getTokensFromNetwork, // flattenTokens NetworkChainId, toDisplay, @@ -18,9 +17,9 @@ import PowerByOBridge from 'components/PowerByOBridge'; import { displayToast, TToastType } from 'components/Toasts/Toast'; import TokenBalance from 'components/TokenBalance'; import { cosmosTokens, flattenTokens, tokenMap } from 'config/bridgeTokens'; -import { btcChains, evmChains, OsmosisTokenList, tonNetworkMainnet } from 'config/chainInfos'; +import { btcChains, evmChains } from 'config/chainInfos'; import copy from 'copy-to-clipboard'; -import { filterChainBridge, findChainByChainId, getAddressTransfer, networks } from 'helper'; +import { filterChainBridge, getAddressTransfer, networks } from 'helper'; import { useCoinGeckoPrices } from 'hooks/useCoingecko'; import useConfigReducer from 'hooks/useConfigReducer'; import useTokenFee, { useRelayerFeeToken } from 'hooks/useTokenFee'; @@ -40,9 +39,6 @@ import styles from './index.module.scss'; import { useGetContractConfig } from 'pages/BitcoinDashboardV2/hooks'; import ToggleSwitch from 'components/ToggleSwitch'; import { CWBitcoinFactoryDenom } from 'helper/constants'; -import useGetFee from '../hooks/useGetFee'; -import useTonBridgeHandler, { EXTERNAL_MESSAGE_FEE } from '../hooks/useTonBridgeHandler'; -import { TonChainId } from 'context/ton-provider'; interface TransferConvertProps { token: TokenItemType; @@ -52,7 +48,6 @@ interface TransferConvertProps { subAmounts?: object; isFastMode?: boolean; setIsFastMode?: Function; - setToNetwork: Function; } const TransferConvertToken: FC = ({ @@ -62,14 +57,9 @@ const TransferConvertToken: FC = ({ onClickTransfer, subAmounts, isFastMode, - setIsFastMode, - setToNetwork + setIsFastMode }) => { - // const bridgeNetworks = networks.filter((item) => filterChainBridge(token, item)); - const bridgeNetworks = [...(token?.bridgeTo || ['Oraichain'])].map((chainId) => { - const net = findChainByChainId(chainId); - return net; - }); + const bridgeNetworks = networks.filter((item) => filterChainBridge(token, item)); const [[convertAmount, convertUsd], setConvertAmount] = useState([undefined, 0]); const [transferLoading, setTransferLoading] = useState(false); const [copied, setCopied] = useState(false); @@ -94,7 +84,6 @@ const TransferConvertToken: FC = ({ const address = await getAddressTransfer(findNetwork, walletByNetworks); setAddressTransfer(address); setToNetworkChainId(defaultToChainId); - setToNetwork(defaultToChainId); } })(); }, [token.chainId]); @@ -161,20 +150,8 @@ const TransferConvertToken: FC = ({ const remoteTokenDenomTo = getRemoteTokenDenom(to); // token fee - const fromTokenFee = useTokenFee(remoteTokenDenomFrom) || 0; - const toTokenFee = useTokenFee(remoteTokenDenomTo) || 0; - - const { bridgeFee: bridgeFeeTon, tokenFee: tonTokenFee } = useGetFee({ - token, - fromNetwork: token.chainId, - toNetwork: toNetworkChainId - }); - - const { deductNativeAmount, checkBalanceBridgeByNetwork } = useTonBridgeHandler({ - token, - fromNetwork: token.chainId, - toNetwork: toNetworkChainId - }); + const fromTokenFee = useTokenFee(remoteTokenDenomFrom); + const toTokenFee = useTokenFee(remoteTokenDenomTo); // bridge fee & relayer fee let bridgeFee = fromTokenFee + toTokenFee; @@ -220,49 +197,12 @@ const TransferConvertToken: FC = ({ toDisplayBTCFee = new BigDecimal(withdrawalFeeBtc.withdrawal_fees ?? 0).div(1e14).toNumber(); } - let receivedAmount = convertAmount - ? convertAmount * (1 - bridgeFee / 100) - relayerFeeTokenFee - toDisplayBTCFee - (bridgeFeeTon || 0) - : 0; + let receivedAmount = convertAmount ? convertAmount * (1 - bridgeFee / 100) - relayerFeeTokenFee - toDisplayBTCFee : 0; const renderBridgeFee = () => { - const [balanceMax, setBalanceMax] = useState(0); - - useEffect(() => { - (async () => { - if (toNetworkChainId === TonChainId) { - const tokenOnTon = [...getTokensFromNetwork(tonNetworkMainnet)].find( - (tk) => tk.chainId === toNetworkChainId && tk.coinGeckoId === token.coinGeckoId - ); - - const maxBalance = await checkBalanceBridgeByNetwork(token.chainId, tokenOnTon); - setBalanceMax(maxBalance || 0); - } - })(); - }, [token, toNetworkChainId]); - return (
- {bridgeFeeTon ? ( - <> - Bridge fee:{' '} - - {bridgeFeeTon} {token.name}{' '} - - - ) : ( - <> - Bridge fee: {bridgeFee}% - - )} - {tonTokenFee > 0 ? ( -
- - Token fee:{' '} - - {' '} - {tonTokenFee} {token.name}{' '} - -
- ) : null}{' '} + Bridge fee: {bridgeFee}% {relayerFeeTokenFee > 0 ? (
- Relayer fee:{' '} @@ -275,7 +215,7 @@ const TransferConvertToken: FC = ({ - Received amount: {' '} - {(receivedAmount > 0 ? receivedAmount : 0).toFixed(6)} {token.name} + {receivedAmount.toFixed(6)} {token.name} {!!toDisplayBTCFee && ( <> @@ -283,14 +223,6 @@ const TransferConvertToken: FC = ({ - BTC fee: {toDisplayBTCFee} BTC )} - {toNetworkChainId === TonChainId && ( -

- Available amount:{' '} - - {balanceMax.toFixed(6)} {token.name} - -

- )}
); }; @@ -382,31 +314,31 @@ const TransferConvertToken: FC = ({ {isOpen && (
    - {[...(token?.bridgeTo || ['Oraichain'])].map((chainId) => { - const net = findChainByChainId(chainId); - return ( -
  • { - e.stopPropagation(); - const address = await getAddressTransfer(net, walletByNetworks); - setAddressTransfer(address); - setToNetworkChainId(net.chainId); - setToNetwork(net.chainId); - setIsOpen(false); - }} - > - {net && ( -
    -
    - + {networks + .filter((item) => filterChainBridge(token, item)) + .map((net) => { + return ( +
  • { + e.stopPropagation(); + const address = await getAddressTransfer(net, walletByNetworks); + setAddressTransfer(address); + setToNetworkChainId(net.chainId); + setIsOpen(false); + }} + > + {net && ( +
    +
    + +
    +
    {net.chainName}
    -
    {net.chainName}
    -
- )} - - ); - })} + )} + + ); + })}
)} @@ -445,22 +377,13 @@ const TransferConvertToken: FC = ({ className={classNames(styles.balanceBtn, styles[theme])} onClick={(event) => { event.stopPropagation(); - if (token.chainId === TonChainId && token.coinGeckoId === 'the-open-network') { - const finalAmount = new BigDecimal(maxAmount) - .sub(toDisplay(deductNativeAmount || 0n, token.decimals)) - .sub(deductNativeAmount > 0n ? EXTERNAL_MESSAGE_FEE : 0) - .toNumber(); - - setConvertAmount([finalAmount * coeff, amountDetail.usd * coeff]); - } else { - const finalAmount = calcMaxAmount({ - maxAmount, - token, - coeff - }); + const finalAmount = calcMaxAmount({ + maxAmount, + token, + coeff + }); - setConvertAmount([finalAmount * coeff, amountDetail.usd * coeff]); - } + setConvertAmount([finalAmount * coeff, amountDetail.usd * coeff]); }} > {text} diff --git a/src/pages/Balance/helpers.ts b/src/pages/Balance/helpers.ts index bd9386ea0..eb8c29947 100644 --- a/src/pages/Balance/helpers.ts +++ b/src/pages/Balance/helpers.ts @@ -29,6 +29,7 @@ import { cosmosNetworks, feeEstimate, getNetworkGasPrice } from 'helper'; import { CwIcs20LatestClient } from '@oraichain/common-contracts-sdk'; import { TransferBackMsg } from '@oraichain/common-contracts-sdk/build/CwIcs20Latest.types'; import { OraiswapRouterQueryClient, OraiswapTokenClient } from '@oraichain/oraidex-contracts-sdk'; +import { Long } from 'cosmjs-types/helpers'; import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx'; import CosmJs, { collectWallet, connectWithSigner, getCosmWasmClient } from 'libs/cosmjs'; import KawaiiverseJs from 'libs/kawaiiversejs'; @@ -70,7 +71,7 @@ export const transferIBC = async (data: { sender: fromAddress, receiver: toAddress, memo, - timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout)), + timeoutTimestamp: Long.fromString(calculateTimeoutTimestamp(ibcInfo.timeout)), timeoutHeight: undefined }; let feeDenom = fromToken.denom; @@ -188,15 +189,10 @@ export const transferIBCMultiple = async ( })); const offlineSigner = await collectWallet(fromChainId); // Initialize the gaia api with the offline signer that is injected by Keplr extension. - const client = await connectWithSigner( - rpc, - offlineSigner as any, - fromChainId === 'injective-1' ? 'injective' : 'cosmwasm', - { - gasPrice: GasPrice.fromString(`${await getNetworkGasPrice(fromChainId)}${feeDenom}`), - broadcastPollIntervalMs: 600 - } - ); + const client = await connectWithSigner(rpc, offlineSigner, fromChainId === 'injective-1' ? 'injective' : 'cosmwasm', { + gasPrice: GasPrice.fromString(`${await getNetworkGasPrice(fromChainId)}${feeDenom}`), + broadcastPollIntervalMs: 600 + }); // hardcode fix bug osmosis let fee: 'auto' | number = 'auto'; if (fromChainId === 'osmosis-1') fee = 3; @@ -238,7 +234,7 @@ export const transferTokenErc20Cw20Map = async ({ sender: fromAddress, receiver: toAddress, memo: ibcMemo, - timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout)) + timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout) }) }; @@ -384,17 +380,9 @@ export const transferIbcCustom = async ( export const findDefaultToToken = (from: TokenItemType) => { if (!from.bridgeTo) return; - - const defaultToken = flattenTokens.find((t) => { - const defaultChain = from.bridgeTo[0]; - return defaultChain === t.chainId && from.coinGeckoId === t.coinGeckoId && from.chainId !== t.chainId; - }); - - return defaultToken; - - // return flattenTokens.find( - // (t) => from.bridgeTo.includes(t.chainId) && from.name.includes(t.name) && from.chainId !== t.chainId - // ); + return flattenTokens.find( + (t) => from.bridgeTo.includes(t.chainId) && from.name.includes(t.name) && from.chainId !== t.chainId + ); }; export const convertKwt = async (transferAmount: number, fromToken: TokenItemType): Promise => { @@ -498,9 +486,9 @@ export const calcMaxAmount = ({ if (!token) return maxAmount; let finalAmount = maxAmount; - if (token.chainId === 'ton') return finalAmount; const feeCurrencyOfToken = token.feeCurrencies?.find((e) => e.coinMinimalDenom === token.denom); + if (feeCurrencyOfToken) { const useFeeEstimate = feeEstimate(token, gas); diff --git a/src/pages/Balance/hooks/useGetFee.ts b/src/pages/Balance/hooks/useGetFee.ts deleted file mode 100644 index 807538d2d..000000000 --- a/src/pages/Balance/hooks/useGetFee.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { BigDecimal, toDisplay, TokenItemType } from '@oraichain/oraidex-common'; -import { TonbridgeBridgeClient } from '@oraichain/tonbridge-contracts-sdk'; -import { tonNetworkMainnet } from 'config/chainInfos'; -import { network } from 'config/networks'; -import { TonChainId } from 'context/ton-provider'; -import useConfigReducer from 'hooks/useConfigReducer'; -import { useEffect, useState } from 'react'; - -const useGetFee = ({ - token, - fromNetwork, - toNetwork -}: { - token: TokenItemType; - fromNetwork: string; - toNetwork: string; -}) => { - const [oraiAddress] = useConfigReducer('address'); - const [bridgeFee, setBridgeFee] = useState(0); - const [tokenFee, setTokenFee] = useState(0); - const [walletsTon] = useConfigReducer('walletsTon'); - - useEffect(() => { - (async () => { - try { - if (![fromNetwork, toNetwork].includes(TonChainId)) { - return setTokenFee(0); - } - - if (token && fromNetwork && toNetwork) { - const tokenInTon = tonNetworkMainnet.currencies.find((tk) => tk.coinGeckoId === token.coinGeckoId); - if (!tokenInTon) { - return; - } - const walletTon = walletsTon[tokenInTon.coinMinimalDenom]; - - if (!walletTon) { - return; - } - - const tonBridgeClient = new TonbridgeBridgeClient(window.client, oraiAddress, network.CW_TON_BRIDGE); - - const tokenFeeConfig = await tonBridgeClient.tokenFee({ - remoteTokenDenom: walletTon - }); - - if (tokenFeeConfig) { - const { nominator, denominator } = tokenFeeConfig; - const fee = new BigDecimal(nominator).div(denominator).toNumber(); - - setTokenFee(fee); - } - } - } catch (error) { - if (error.message.toString().includes('type: tonbridge_bridge::state::Ratio; key:')) { - setTokenFee(0); - } else { - console.log(error); - } - } - })(); - }, [token, oraiAddress, walletsTon, fromNetwork, toNetwork]); - - useEffect(() => { - (async () => { - if (![fromNetwork, toNetwork].includes(TonChainId)) { - return setBridgeFee(0); - } - - if (token && fromNetwork && toNetwork) { - const tokenInTon = tonNetworkMainnet.currencies.find((tk) => tk.coinGeckoId === token.coinGeckoId); - if (!tokenInTon) { - return; - } - - const walletTon = walletsTon[tokenInTon.coinMinimalDenom]; - if (!walletTon) { - return; - } - - const tonBridgeClient = new TonbridgeBridgeClient(window.client, oraiAddress, network.CW_TON_BRIDGE); - - const config = await tonBridgeClient.pairMapping({ - key: walletTon - }); - const pairMapping = config.pair_mapping; - - setBridgeFee(parseInt(pairMapping.relayer_fee) / 10 ** pairMapping.remote_decimals); - } - })(); - }, [token, oraiAddress, walletsTon, fromNetwork, toNetwork]); - - return { - bridgeFee, - tokenFee - }; -}; - -export default useGetFee; diff --git a/src/pages/Balance/hooks/useGetStateData.ts b/src/pages/Balance/hooks/useGetStateData.ts deleted file mode 100644 index f0b3b3186..000000000 --- a/src/pages/Balance/hooks/useGetStateData.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { TonbridgeBridgeClient } from '@oraichain/tonbridge-contracts-sdk'; -import { network } from 'config/networks'; -import useConfigReducer from 'hooks/useConfigReducer'; -import { useEffect, useState } from 'react'; - -const useGetStateData = () => { - const [oraiAddress] = useConfigReducer('address'); - const [balances, setBalances] = useState([]); - - const getChanelStateData = async () => { - const tonBridgeClient = new TonbridgeBridgeClient(window.client, oraiAddress, network.CW_TON_BRIDGE); - - const config = await tonBridgeClient.channelStateData(); - if (config) { - const { balances } = config; - setBalances(balances); - } - }; - - useEffect(() => { - getChanelStateData(); - }, []); - - return { balances, getChanelStateData }; -}; - -export default useGetStateData; diff --git a/src/pages/Balance/hooks/useLoadWalletsTon.ts b/src/pages/Balance/hooks/useLoadWalletsTon.ts deleted file mode 100644 index 23b24a33e..000000000 --- a/src/pages/Balance/hooks/useLoadWalletsTon.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { JettonMinter } from '@oraichain/ton-bridge-contracts'; -import { Address } from '@ton/ton'; -import { TON_ZERO_ADDRESS, tonNetworkMainnet } from 'config/chainInfos'; -import { TonInteractionContract, TonNetwork } from 'context/ton-provider'; -import useConfigReducer from 'hooks/useConfigReducer'; -import { useEffect } from 'react'; -import { getTonClient, retryOrbs } from './../../../helper/index'; - -// dev: use to load wallet jetton address of bridge adapter -export const useLoadWalletsTon = ({ tonNetwork = TonNetwork.Mainnet }: { tonNetwork?: TonNetwork }) => { - const [, handleSetWalletsTonCache] = useConfigReducer('walletsTon'); - - const loadWalletsTon = async () => { - let tokenOnTons = tonNetworkMainnet.currencies || []; - - let walletsTon = {}; - for (const tokenOnTon of tokenOnTons) { - if (tokenOnTon.contractAddress == TON_ZERO_ADDRESS) { - walletsTon = { - ...walletsTon, - [tokenOnTon.coinMinimalDenom]: TON_ZERO_ADDRESS - }; - continue; - } - - await retryOrbs(async () => { - const client = await getTonClient(); - - const jettonMinter = JettonMinter.createFromAddress(Address.parse(tokenOnTon.contractAddress)); - const jettonMinterContract = client.open(jettonMinter); - const jettonWalletAddress = await jettonMinterContract.getWalletAddress( - Address.parse(TonInteractionContract[tonNetwork].bridgeAdapter) - ); - walletsTon = { - ...walletsTon, - [tokenOnTon.coinMinimalDenom]: jettonWalletAddress.toString() - }; - }); - } - handleSetWalletsTonCache(walletsTon); - }; - - useEffect(() => { - loadWalletsTon(); - }, [tonNetwork]); - - return { - loadWalletsTon - }; -}; diff --git a/src/pages/Balance/hooks/useTonBridgeHandler.ts b/src/pages/Balance/hooks/useTonBridgeHandler.ts deleted file mode 100644 index 941c1823a..000000000 --- a/src/pages/Balance/hooks/useTonBridgeHandler.ts +++ /dev/null @@ -1,735 +0,0 @@ -import { ExecuteInstruction, toBinary } from '@cosmjs/cosmwasm-stargate'; -import { fromBech32 } from '@cosmjs/encoding'; -import { coin, Coin, coins, GasPrice } from '@cosmjs/stargate'; -import { - BigDecimal, - calculateTimeoutTimestamp, - CosmosChainId, - cosmosChains, - CW20_DECIMALS, - getCosmosGasPrice, - getEncodedExecuteContractMsgs, - handleSentFunds, - IBC_WASM_CONTRACT, - OSMOSIS_ROUTER_CONTRACT, - toAmount, - toDisplay, - TokenItemType -} from '@oraichain/oraidex-common'; -import { buildUniversalSwapMemo, SwapAndAction, UniversalSwapHelper } from '@oraichain/oraidex-universal-swap'; -import { BridgeAdapter, JettonMinter, JettonWallet } from '@oraichain/ton-bridge-contracts'; -import { TonbridgeBridgeClient } from '@oraichain/tonbridge-contracts-sdk'; -import { getHttpEndpoint } from '@orbs-network/ton-access'; -import { Address, beginCell, Cell, toNano } from '@ton/core'; -import { TonClient } from '@ton/ton'; -import { Base64 } from '@tonconnect/protocol'; -import { useTonConnectUI } from '@tonconnect/ui-react'; -import { displayToast, TToastType } from 'components/Toasts/Toast'; -import { - AlloyedPool, - chainInfos, - oraichainTokensWithIcon, - OsmosisAlloyedPools, - OsmosisTokenDenom, - OsmosisTokenList, - TON_ZERO_ADDRESS, - tonNetworkTokens -} from 'config/chainInfos'; -import { network } from 'config/networks'; -import { TON_SCAN, TonChainId, TonInteractionContract, TonNetwork } from 'context/ton-provider'; -import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx'; -import { getTransactionUrl, handleErrorTransaction } from 'helper'; -import { numberWithCommas } from 'helper/format'; -import { useCoinGeckoPrices } from 'hooks/useCoingecko'; -import useConfigReducer from 'hooks/useConfigReducer'; -import useLoadTokens from 'hooks/useLoadTokens'; -import { getCosmWasmClient } from 'libs/cosmjs'; -import { useEffect, useState } from 'react'; -import { useSelector } from 'react-redux'; -import { RootState } from 'store/configure'; -import useGetFee from './useGetFee'; -import useGetStateData from './useGetStateData'; - -const FWD_AMOUNT = toNano(0.15); -const TON_MESSAGE_VALID_UNTIL = 100000; -const BRIDGE_TON_TO_ORAI_MINIMUM_GAS = toNano(1); -const EXTERNAL_MESSAGE_FEE = 0.01; -const MINIMUM_BRIDGE_PER_USD = 1; // 10; // TODO: update for product is 10 - -export { - BRIDGE_TON_TO_ORAI_MINIMUM_GAS, - EXTERNAL_MESSAGE_FEE, - FWD_AMOUNT, - MINIMUM_BRIDGE_PER_USD, - TON_MESSAGE_VALID_UNTIL -}; - -const useTonBridgeHandler = ({ - token, - fromNetwork, - toNetwork -}: { - token: TokenItemType; - fromNetwork: string; - toNetwork: string; -}) => { - const [tonAddress, setTonAddress] = useConfigReducer('tonAddress'); - const [oraiAddress, setOraiAddress] = useConfigReducer('address'); - const [walletsTon] = useConfigReducer('walletsTon'); - const amounts = useSelector((state: RootState) => state.token.amounts); - - const { balances: sentBalance, getChanelStateData } = useGetStateData(); - const loadTokenAmounts = useLoadTokens(); - - const [tonConnectUI] = useTonConnectUI(); - const { data: prices } = useCoinGeckoPrices(); - const [tokenInfo, setTokenInfo] = useState({ - jettonWalletAddress: null - }); - const [deductNativeAmount, setDeductNativeAmount] = useState(0n); - - const { bridgeFee, tokenFee } = useGetFee({ - token, - fromNetwork, - toNetwork - }); - - useEffect(() => { - if (token?.chainId === TonChainId && token?.contractAddress === TON_ZERO_ADDRESS) { - setDeductNativeAmount(BRIDGE_TON_TO_ORAI_MINIMUM_GAS); - return; - } - setDeductNativeAmount(0n); - }, [token]); - - // @dev: this function will changed based on token minter address (which is USDT, USDC, bla bla bla) - useEffect(() => { - try { - (async () => { - if (token?.chainId !== TonChainId) return; - - // get the decentralized RPC endpoint - const endpoint = await getHttpEndpoint(); - const client = new TonClient({ - endpoint - }); - if (token?.contractAddress === TON_ZERO_ADDRESS) { - setDeductNativeAmount(BRIDGE_TON_TO_ORAI_MINIMUM_GAS); - setTokenInfo({ - jettonWalletAddress: '' - }); - return; - } - - const jettonMinter = JettonMinter.createFromAddress(Address.parse(token.contractAddress)); - const jettonMinterContract = client.open(jettonMinter); - const jettonWalletAddress = await jettonMinterContract.getWalletAddress(Address.parse(tonAddress)); - - setTokenInfo({ - jettonWalletAddress - }); - setDeductNativeAmount(0n); - })(); - } catch (error) { - console.log('error :>>', error); - } - }, [token]); // toNetwork, tonAddress - - const handleCheckBalanceBridgeOfTonNetwork = async (token: TokenItemType) => { - try { - // get the decentralized RPC endpoint - const endpoint = await getHttpEndpoint(); - const client = new TonClient({ - endpoint - }); - const bridgeAdapter = TonInteractionContract[TonNetwork.Mainnet].bridgeAdapter; - - if (token.contractAddress === TON_ZERO_ADDRESS) { - const balance = await client.getBalance(Address.parse(bridgeAdapter)); - - return { - balance: balance - }; - } - - const jettonWallet = JettonWallet.createFromAddress(Address.parse(walletsTon[token.denom])); - const jettonWalletContract = client.open(jettonWallet); - const balance = await jettonWalletContract.getBalance(); - return { - balance: balance.amount - }; - } catch (error) { - console.log('error :>> handleCheckBalanceBridgeOfTonNetwork', error); - } - }; - - const handleCheckBalanceBridgeOfOraichain = async (token: TokenItemType) => { - try { - if (token) { - if (!token.contractAddress) { - const data = await window.client.getBalance(network.CW_TON_BRIDGE, token.denom); - - return { - balance: data.amount - }; - } - - const tx = await window.client.queryContractSmart(token.contractAddress, { - balance: { address: network.CW_TON_BRIDGE } - }); - - return { - balance: tx?.balance || 0 - }; - } - } catch (error) { - console.log('error :>> handleCheckBalanceBridgeOfOraichain', error); - } - }; - - const handleCheckBalanceBridgeOfOsmosis = async (token: TokenItemType, fromChainId: string) => { - try { - if (token) { - if (!token.contractAddress) { - const findCosmosChain = chainInfos.find((chain) => chain.chainId === fromChainId); - const { client } = await getCosmWasmClient( - { chainId: fromChainId, rpc: findCosmosChain.rpc }, - { - gasPrice: GasPrice.fromString( - `${getCosmosGasPrice(findCosmosChain.feeCurrencies[0].gasPriceStep)}${ - findCosmosChain.feeCurrencies[0].coinMinimalDenom - }` - ) - } - ); - const data = await client.getBalance(network.CW_TON_BRIDGE, token.denom); - - return { - balance: data.amount - }; - } - } - } catch (error) { - console.log('error :>> handleCheckBalanceBridgeOfOsmosis', error); - } - }; - - const checkBalanceBridgeByNetwork = async (networkFrom: string, token: TokenItemType) => { - const handler = { - ['Oraichain']: handleCheckBalanceBridgeOfTonNetwork, - [TonChainId]: handleCheckBalanceBridgeOfOraichain, - ['osmosis-1']: handleCheckBalanceBridgeOfTonNetwork - }; - - const { balance } = handler[networkFrom] ? (await handler[networkFrom](token)) || { balance: 0 } : { balance: 0 }; - - return toDisplay(balance || 0, token.decimals || token.decimals || CW20_DECIMALS); - }; - - const validatePrice = (token: TokenItemType, amount: number) => { - let totalFee = - Number.parseFloat( - numberWithCommas(bridgeFee || 0, undefined, { - maximumFractionDigits: CW20_DECIMALS - }) - ) + - Number.parseFloat( - numberWithCommas(new BigDecimal(tokenFee).mul(amount || 0).toNumber(), undefined, { maximumFractionDigits: 6 }) - ); - - if (amount < totalFee) { - throw Error(`Minimum bridge is ${totalFee} ${token['coinDenom'] || token.name}`); - } - }; - - const buildOsorSwapMsg = ( - { user_swap, min_asset, timeout_timestamp, post_swap_action, affiliates }: SwapAndAction, - isInitial: boolean, - fromAddress?: string, - funds?: Coin[] - ) => { - const msg = { - msg: { - swap_and_action: { - user_swap, - min_asset, - timeout_timestamp, - post_swap_action, - affiliates - } - } - }; - - if (isInitial) { - if (!fromAddress) { - throw new Error('Missing fromAddress'); - } - return { - msgActionSwap: { - sender: fromAddress, - contractAddress: OSMOSIS_ROUTER_CONTRACT, - funds, - ...msg - } - }; - } - - return { - msgActionSwap: { - wasm: { - contract: OSMOSIS_ROUTER_CONTRACT, - ...msg - } - } - }; - }; - - const handleBridgeFromTon = async (amount: number | string) => { - try { - if (!oraiAddress) throw 'Please connect OWallet or Kelpr!'; - - if (!tonAddress) throw 'Please connect Ton Wallet'; - - if (!token || !amount) throw 'Not valid!'; - - if (toDisplay(amounts?.[token.denom] || '0', token['coinDecimals'] || token.decimals) < Number(amount)) - throw 'Insufficient funds'; - - validatePrice(token, Number(amount)); - - // setLoading(true); - - const tokenInOrai = oraichainTokensWithIcon.find((tk) => tk.coinGeckoId === token.coinGeckoId); - const balanceMax = await checkBalanceBridgeByNetwork(TonChainId, tokenInOrai); - - const isMintBurn = ['hamster-kombat', 'the-open-network'].includes(tokenInOrai?.coinGeckoId); - - if (!isMintBurn && Number(balanceMax) < Number(amount)) { - // setLoading(false); - throw `The bridge contract does not have enough balance to process this bridge transaction. Wanted ${amount} ${ - token['coinDenom'] || token.name - }, have ${balanceMax} ${token['coinDenom'] || token.name}`; - } - const bridgeAdapterAddress = Address.parse(TonInteractionContract[TonNetwork.Mainnet].bridgeAdapter); - const fmtAmount = new BigDecimal(10).pow(token.decimals || token['coinDecimals']).mul(amount); - const isNativeTon: boolean = token.contractAddress === TON_ZERO_ADDRESS; - const toAddress: string = isNativeTon - ? bridgeAdapterAddress.toString() - : tokenInfo.jettonWalletAddress?.toString(); - console.log('THIS IS TO ADDRESS:', { toAddress }, { walletsTon }); - const oraiAddressBech32 = fromBech32(oraiAddress).data; - const gasAmount = isNativeTon - ? fmtAmount.add(BRIDGE_TON_TO_ORAI_MINIMUM_GAS).toString() - : BRIDGE_TON_TO_ORAI_MINIMUM_GAS.toString(); - const timeout = BigInt(Math.floor(new Date().getTime() / 1000) + 3600); - - let memo = beginCell().endCell(); - - if (toNetwork === 'osmosis-1') { - const osmosisAddress = await window.Keplr.getKeplrAddr(toNetwork); - let osmosisReceiver = osmosisAddress; - if (!osmosisAddress) throw 'Please connect OWallet or Kelpr!'; - - let osorRouterMemo = ''; - let hasAlloyedPool = canConvertToAlloyedToken(token.coinGeckoId); - if (hasAlloyedPool) { - osmosisReceiver = OSMOSIS_ROUTER_CONTRACT; - let { msgActionSwap } = buildOsorSwapMsg( - { - user_swap: { - swap_exact_asset_in: { - swap_venue_name: 'osmosis-poolmanager', - operations: [ - { - pool: hasAlloyedPool.poolId, - denom_in: hasAlloyedPool.sourceToken, - denom_out: hasAlloyedPool.alloyedToken - } - ] - } - }, - min_asset: { - native: { - denom: hasAlloyedPool.alloyedToken, - amount: '0' - } - }, // consider add minimum receive (Currently, alloy pool is swap 1-1, so no't need to add min_asset - timeout_timestamp: Number(calculateTimeoutTimestamp(3600)), - post_swap_action: { - transfer: { - to_address: osmosisAddress - } - }, - affiliates: [] - }, - false - ); - osorRouterMemo = JSON.stringify(msgActionSwap); - } - - const buildMemoSwap = buildUniversalSwapMemo( - { - minimumReceive: '0', - recoveryAddr: oraiAddress - }, - undefined, - undefined, - undefined, - { - sourceChannel: 'channel-13', - sourcePort: 'transfer', - receiver: osmosisReceiver, - memo: osorRouterMemo, - recoverAddress: oraiAddress - }, - undefined - ); - memo = beginCell().storeStringRefTail(buildMemoSwap).endCell(); - } - - const getNativeBridgePayload = () => - BridgeAdapter.buildBridgeTonBody( - { - amount: BigInt(fmtAmount.toString()), - memo, - remoteReceiver: oraiAddress, - timeout - }, - oraiAddressBech32, - { - queryId: 0, - value: toNano(0) // don't care this - } - ).toBoc(); - - const getOtherBridgeTokenPayload = () => - JettonWallet.buildSendTransferPacket( - Address.parse(tonAddress), - { - fwdAmount: FWD_AMOUNT, - jettonAmount: BigInt(fmtAmount.toString()), - jettonMaster: Address.parse(token.contractAddress), - remoteReceiver: oraiAddress, - timeout, - memo, - toAddress: bridgeAdapterAddress - }, - 0 - ).toBoc(); - - const boc = isNativeTon ? getNativeBridgePayload() : getOtherBridgeTokenPayload(); - - console.log('Debug', { - address: toAddress, // dia chi token - amount: gasAmount, // gas - payload: Base64.encode(boc) - }); - - const tx = await tonConnectUI.sendTransaction({ - validUntil: TON_MESSAGE_VALID_UNTIL, - messages: [ - { - address: toAddress, // dia chi token - amount: gasAmount, // gas - payload: Base64.encode(boc) - } - ] - }); - - const txHash = Cell.fromBoc(Buffer.from(tx.boc, 'base64'))[0].hash().toString('hex'); - - if (txHash) { - displayToast(TToastType.TX_SUCCESSFUL, { - customLink: `${TON_SCAN}/transaction/${txHash}` - }); - - loadTokenAmounts({ oraiAddress, tonAddress }); - getChanelStateData(); - } - } catch (error) { - console.log('error Bridge from TON :>>', error); - - handleErrorTransaction(error, { - tokenName: token['coindDenom'], - chainName: toNetwork - }); - } - }; - - const handleBridgeFromCosmos = async (amount: number | string) => { - try { - if (!oraiAddress) throw 'Please connect OWallet or Kelpr!'; - - if (!tonAddress) throw 'Please connect Ton Wallet'; - - if (!token || !amount) throw 'Not valid!'; - - // setLoading(true); - const isFromOsmosisToOraichain = fromNetwork === 'osmosis-1' && toNetwork === 'Oraichain'; - const isFromOraichainToOsmosis = fromNetwork === 'Oraichain' && toNetwork === 'osmosis-1'; - const isFromOsmosisToTon = fromNetwork === 'osmosis-1' && toNetwork === TonChainId; - - // Osmosis <-> Oraichain - // Oraichain <-> Osmosis - // Osmosis -> Ton - if (isFromOsmosisToOraichain || isFromOraichainToOsmosis || isFromOsmosisToTon) { - if (isFromOsmosisToTon) { - console.log('470', token, amount, bridgeFee, token, fromNetwork, toNetwork); - validatePrice(token, Number(amount)); - } - const timeout = Math.floor(new Date().getTime() / 1000) + 3600; - const fromChainId = fromNetwork as CosmosChainId; - const toChainId = isFromOsmosisToTon ? ('Oraichain' as CosmosChainId) : (toNetwork as CosmosChainId); - - let [fromAddress, toAddress] = await Promise.all([ - window.Keplr.getKeplrAddr(fromChainId), - window.Keplr.getKeplrAddr(toChainId) - ]); - - if (!fromAddress || !toAddress) throw 'Please connect OWallet or Kelpr!'; - - let memo = ''; - if (isFromOsmosisToTon) { - toAddress = IBC_WASM_CONTRACT; - - const memoUniversal = buildUniversalSwapMemo( - { minimumReceive: '0', recoveryAddr: oraiAddress }, - undefined, - undefined, - { - contractAddress: network.CW_TON_BRIDGE, - msg: toBinary({ - bridge_to_ton: { - to: tonAddress, - denom: tonNetworkTokens.find((tk) => tk.coinGeckoId === token.coinGeckoId).contractAddress, - timeout, - recovery_addr: oraiAddress - } - }) - }, - undefined, - undefined - ); - - memo = JSON.stringify({ - wasm: { - contract: IBC_WASM_CONTRACT, - msg: { - ibc_hooks_receive: { - func: 'universal_swap', - orai_receiver: oraiAddress, - args: memoUniversal - } - } - } - }); - } - if (isFromOraichainToOsmosis) { - let hasAlloyedPool = canConvertToAlloyedToken(token.coinGeckoId); - if (hasAlloyedPool) { - let { msgActionSwap } = buildOsorSwapMsg( - { - user_swap: { - swap_exact_asset_in: { - swap_venue_name: 'osmosis-poolmanager', - operations: [ - { - pool: hasAlloyedPool.poolId, - denom_in: hasAlloyedPool.sourceToken, - denom_out: hasAlloyedPool.alloyedToken - } - ] - } - }, - min_asset: { - native: { - denom: hasAlloyedPool.alloyedToken, - amount: '0' - } - }, // consider add minimum receive (Currently, alloy pool is swap 1-1, so no't need to add min_asset - timeout_timestamp: Number(calculateTimeoutTimestamp(3600)), - post_swap_action: { - transfer: { - to_address: toAddress - } - }, - affiliates: [] - }, - false - ); - memo = JSON.stringify(msgActionSwap); - toAddress = OSMOSIS_ROUTER_CONTRACT; - } - } - - const ibcInfo = UniversalSwapHelper.getIbcInfo(fromChainId, toChainId); - let executeMsg; - if (fromNetwork === 'osmosis-1' && token.denom === OsmosisTokenDenom.allTon) { - let hasAlloyedPool = canConvertToAlloyedToken(token.coinGeckoId); - if (!hasAlloyedPool) throw new Error('AlloyPool does not exist!'); - // need convert from alloyed first - let { msgActionSwap } = buildOsorSwapMsg( - { - user_swap: { - swap_exact_asset_in: { - swap_venue_name: 'osmosis-poolmanager', - operations: [ - { - pool: hasAlloyedPool.poolId, - denom_in: hasAlloyedPool.alloyedToken, - denom_out: hasAlloyedPool.sourceToken - } - ] - } - }, - min_asset: { - native: { - denom: hasAlloyedPool.sourceToken, - amount: '0' - } - }, // consider add minimum receive (Currently, alloy pool is swap 1-1, so no't need to add min_asset - timeout_timestamp: Number(calculateTimeoutTimestamp(3600)), - post_swap_action: { - ibc_transfer: { - ibc_info: { - source_channel: ibcInfo.channel, - receiver: toAddress, - memo, - recover_address: fromAddress - } - } - }, - affiliates: [] - }, - true, - fromAddress, - coins(toAmount(amount, token.decimals).toString(), token.denom) - ); - - executeMsg = getEncodedExecuteContractMsgs(fromAddress, [msgActionSwap as ExecuteInstruction]); - } else - executeMsg = [ - { - typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', - value: MsgTransfer.fromPartial({ - sourcePort: ibcInfo.source, - sourceChannel: ibcInfo.channel, - token: coin(toAmount(amount, token.decimals).toString(), token.denom), - sender: fromAddress, - receiver: toAddress, - memo, - timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout)) - }) - } - ]; - - const findCosmosChain = cosmosChains.find((chain) => chain.chainId === fromNetwork); - - const { client } = await getCosmWasmClient( - { chainId: fromChainId, rpc: findCosmosChain.rpc }, - { - gasPrice: GasPrice.fromString( - `${getCosmosGasPrice(findCosmosChain.feeCurrencies[0].gasPriceStep)}${ - findCosmosChain.feeCurrencies[0].coinMinimalDenom - }` - ) - } - ); - const tx = await client.signAndBroadcast(fromAddress, executeMsg, 'auto'); - - if (tx?.transactionHash) { - displayToast(TToastType.TX_SUCCESSFUL, { - customLink: getTransactionUrl(fromNetwork as any, tx.transactionHash) - }); - loadTokenAmounts({ oraiAddress, tonAddress }); - } - return; - } - validatePrice(token, Number(amount)); - - const tokenInTon = tonNetworkTokens.find((tk) => tk.coinGeckoId === token.coinGeckoId); - const bridgeJettonWallet = walletsTon[tokenInTon.denom]; - if (!bridgeJettonWallet) throw 'Bridge wallet not found!'; - - const balanceMax = (sentBalance || []).find((b) => b.native.denom === bridgeJettonWallet)?.native.amount; - - const displayBalance = toDisplay(balanceMax, tokenInTon?.decimals || CW20_DECIMALS); - - if (displayBalance < Number(amount) && token.contractAddress !== null) { - // setLoading(false); - throw `The bridge contract does not have enough balance to process this bridge transaction. Wanted ${amount} ${token.name}, have ${displayBalance} ${token.name}`; - } - - const tonBridgeClient = new TonbridgeBridgeClient(window.client, oraiAddress, network.CW_TON_BRIDGE); - - let tx; - - const timeout = Math.floor(new Date().getTime() / 1000) + 3600; - - const msg = { - // crcSrc: ARG_BRIDGE_TO_TON.CRC_SRC, - denom: bridgeJettonWallet, - timeout, - to: tonAddress - }; - - const funds = handleSentFunds({ - denom: token.denom, - amount: toAmount(amount, token.decimals || token['coinDecimals']).toString() - }); - - // native token - if (!token.contractAddress) { - tx = await tonBridgeClient.bridgeToTon(msg, 'auto', null, funds); - } - // cw20 token - else { - tx = await window.client.execute( - oraiAddress, - token.contractAddress, - { - send: { - contract: network.CW_TON_BRIDGE, - amount: toAmount(amount, token.decimals || token['coinDecimals']).toString(), - msg: toBinary({ - denom: msg.denom, - timeout, - to: msg.to - }) - } - }, - 'auto' - ); - } - - if (tx?.transactionHash) { - displayToast(TToastType.TX_SUCCESSFUL, { - customLink: getTransactionUrl(fromNetwork as any, tx.transactionHash) - }); - loadTokenAmounts({ oraiAddress, tonAddress }); - } - } catch (error) { - console.log('error Bridge from Oraichain :>>', error); - handleErrorTransaction(error, { - tokenName: token.name || token['coinDenom'], - chainName: toNetwork - }); - } - }; - - return { - deductNativeAmount, - checkBalanceBridgeByNetwork, - handleBridgeFromCosmos, - handleBridgeFromTon - }; -}; - -export default useTonBridgeHandler; - -export const canConvertToAlloyedToken = (coinGeckoId: string): AlloyedPool | undefined => { - const hasAlloyed = OsmosisTokenList.find( - (token) => token.coinGeckoId == coinGeckoId && token.denom === OsmosisTokenDenom.allTon - ); - return hasAlloyed ? OsmosisAlloyedPools.find((pool) => pool.alloyedToken == hasAlloyed.denom) : undefined; -}; diff --git a/src/pages/Balance/index.tsx b/src/pages/Balance/index.tsx index f41992a78..b23cad06c 100644 --- a/src/pages/Balance/index.tsx +++ b/src/pages/Balance/index.tsx @@ -87,30 +87,26 @@ import StuckOraib from './StuckOraib'; import useGetOraiBridgeBalances from './StuckOraib/useGetOraiBridgeBalances'; import TokenItem, { TokenItemProps } from './TokenItem'; import { TokenItemBtc } from './TokenItem/TokenItemBtc'; -import { TonChainId } from 'context/ton-provider'; -import useTonBridgeHandler from './hooks/useTonBridgeHandler'; import DepositBtcModalV2 from './DepositBtcModalV2'; import { CwBitcoinContext } from 'context/cw-bitcoin-context'; import { AppBitcoinClient } from '@oraichain/bitcoin-bridge-contracts-sdk'; +import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx'; +import { MsgTransfer as MsgTransferInjective } from '@injectivelabs/sdk-ts/node_modules/cosmjs-types/ibc/applications/transfer/v1/tx'; +import { collectWallet, connectWithSigner, getCosmWasmClient } from 'libs/cosmjs'; -interface BalanceProps {} +interface BalanceProps { } export const isMaintainBridge = false; const Balance: React.FC = () => { - //@ts-ignore - const isOwallet = window.owallet?.isOwallet; - // hook const [searchParams] = useSearchParams(); - const ref = useRef(null); - const navigate = useNavigate(); const tokenUrl = searchParams.get('token'); + const navigate = useNavigate(); const amounts = useSelector((state: RootState) => state.token.amounts); const feeConfig = useSelector((state: RootState) => state.token.feeConfigs); const nomic = useContext(NomicContext); const cwBitcoinContext = useContext(CwBitcoinContext); - const [walletByNetworks] = useWalletReducer('walletsByNetwork'); // state internal const [loadingRefresh, setLoadingRefresh] = useState(false); @@ -118,32 +114,27 @@ const Balance: React.FC = () => { const [isDepositBtcModal, setIsDepositBtcModal] = useState(false); const [, setTxHash] = useState(''); const [[from, to], setTokenBridge] = useState([]); - const [toNetworkChainId, setToNetworkChainId] = useState(); const [[otherChainTokens, oraichainTokens], setTokens] = useState([[], []]); - const [addressRecovery, setAddressRecovery] = useState(''); - const [isFastMode, setIsFastMode] = useState(true); + const [walletByNetworks] = useWalletReducer('walletsByNetwork'); const [theme] = useConfigReducer('theme'); - - const [filterNetworkUI, setFilterNetworkUI] = useConfigReducer('filterNetwork'); + const [oraiAddress] = useConfigReducer('address'); const [hideOtherSmallAmount, setHideOtherSmallAmount] = useConfigReducer('hideOtherSmallAmount'); - const [metamaskAddress] = useConfigReducer('metamaskAddress'); - const [oraiAddress] = useConfigReducer('address'); + const [filterNetworkUI, setFilterNetworkUI] = useConfigReducer('filterNetwork'); const [tronAddress] = useConfigReducer('tronAddress'); - const [tonAddress] = useConfigReducer('tonAddress'); const [btcAddress] = useConfigReducer('btcAddress'); - const { handleBridgeFromCosmos, handleBridgeFromTon } = useTonBridgeHandler({ - token: from, - fromNetwork: from?.chainId, - toNetwork: toNetworkChainId - }); + const [addressRecovery, setAddressRecovery] = useState(''); + const [isFastMode, setIsFastMode] = useState(true); const depositV2Fee = useDepositFeesBitcoinV2(true); const withdrawV2Fee = useGetWithdrawlFeesBitcoinV2({ enabled: true, bitcoinAddress: btcAddress }); + const ref = useRef(null); + //@ts-ignore + const isOwallet = window.owallet?.isOwallet; const getAddress = async () => { try { await nomic.generateAddress(); @@ -167,7 +158,6 @@ const Balance: React.FC = () => { getAddress(); } }, [oraiAddress, isOwallet]); - useOnClickOutside(ref, () => { setTokenBridge([undefined, undefined]); }); @@ -257,6 +247,30 @@ const Balance: React.FC = () => { [otherChainTokens, oraichainTokens, from, to] ); + const refreshBalances = async () => { + try { + if (loadingRefresh) return; + setLoadingRefresh(true); + await loadTokenAmounts({ metamaskAddress, tronAddress, oraiAddress, btcAddress }); + } catch (err) { + console.log({ err }); + } finally { + setTimeout(() => { + setLoadingRefresh(false); + }, 2000); + } + }; + + const handleTransferIBC = async (fromToken: TokenItemType, toToken: TokenItemType, transferAmount: number) => { + let transferAddress = metamaskAddress; + // check tron network and convert address + if (toToken.prefix === ORAI_BRIDGE_EVM_TRON_DENOM_PREFIX) { + transferAddress = tronToEthAddress(tronAddress); + } + const result = await transferIbcCustom(fromToken, toToken, transferAmount, amounts, transferAddress); + processTxResult(fromToken.rpc, result); + }; + const handleTransferBTCToOraichain = async (fromToken: TokenItemType, transferAmount: number, btcAddr: string) => { const isV2 = fromToken.name === 'BTC'; const utxos = await getUtxos(btcAddr, fromToken.rpc); @@ -315,7 +329,7 @@ const Balance: React.FC = () => { customLink: `/bitcoin-dashboard${isV2 ? '-v2' : ''}?tab=pending_deposits` }); setTimeout(async () => { - await loadTokenAmounts({ metamaskAddress, tronAddress, oraiAddress, btcAddress: btcAddr, tonAddress }); + await loadTokenAmounts({ metamaskAddress, tronAddress, oraiAddress, btcAddress: btcAddr }); }, 5000); return; } @@ -416,35 +430,6 @@ const Balance: React.FC = () => { } }; - const checkTransferTon = async (toNetworkChainId: string) => { - const isFromTon = from.chainId === TonChainId && !!toNetworkChainId; - const isFromCosmosToTON = !!from.chainId && toNetworkChainId === TonChainId; - const isBridgeWithOraiAndOsmo = - [from.chainId, to.chainId].includes('Oraichain') && [from.chainId, to.chainId].includes('osmosis-1'); - - const isFromCosmos = isFromCosmosToTON || isBridgeWithOraiAndOsmo; - - if (isFromCosmos || isFromTon) { - return { - isTonBridge: true, - isFromTon - }; - } - return { - isTonBridge: false, - isFromTon - }; - }; - - const handleTransferTon = async ({ isTonToCosmos, transferAmount }) => { - const tonAddress = window.Ton.account?.address; - if (!tonAddress) throw Error('Not found your ton address!'); - if (isTonToCosmos) { - return await handleBridgeFromTon(transferAmount); - } - return await handleBridgeFromCosmos(transferAmount); - }; - const checkTransferBtc = () => { const isBTCtoOraichain = from.chainId === bitcoinChainId && to.chainId === 'Oraichain'; const isOraichainToBTC = from.chainId === 'Oraichain' && to.chainId === bitcoinChainId; @@ -463,6 +448,14 @@ const Balance: React.FC = () => { return handleTransferOraichainToBTC(fromToken, transferAmount, btcAddr); }; + const checkTransferKwt = async (fromAmount: number) => { + let result: DeliverTxResponse | string | any; + // convert erc20 to native ==> ORAICHAIN + if (from.contractAddress) result = await convertTransferIBCErc20Kwt(from, to, fromAmount); + else result = await transferIBCKwt(from, to, fromAmount, amounts); + processTxResult(from.rpc, result, `${KWT_SCAN}/tx/${result.transactionHash}`); + }; + const getLatestEvmAddress = async (toNetworkChainId: NetworkChainId) => { const isFromEvmNotTron = from.chainId !== '0x2b6653dc' && EVM_CHAIN_ID.includes(from.chainId); const isToNetworkEvmNotTron = toNetworkChainId !== '0x2b6653dc' && EVM_CHAIN_ID.includes(toNetworkChainId); @@ -487,6 +480,8 @@ const Balance: React.FC = () => { ) => { try { await handleCheckWallet(); + + console.log(from, to); assert(from && to, 'Please choose both from and to tokens'); // get & check balance @@ -503,6 +498,12 @@ const Balance: React.FC = () => { displayToast(TToastType.TX_BROADCASTING); let result: DeliverTxResponse | string | any; + // [(ERC20)KWT, (ERC20)MILKY] ==> ORAICHAIN + if (from.chainId === 'kawaii_6886-1' && to.chainId === 'Oraichain') { + await checkTransferKwt(fromAmount); + return; + } + // [BTC Native] <==> ORAICHAIN let [isBTCToOraichain, isBtcBridge] = checkTransferBtc(); if (isBtcBridge) { @@ -522,15 +523,6 @@ const Balance: React.FC = () => { assert(newToToken, 'Cannot find newToToken token that matches from token to bridge!'); } - // check transfer TON <=> ORAICHAIN - const { isTonBridge, isFromTon } = await checkTransferTon(toNetworkChainId); - if (isTonBridge) { - return await handleTransferTon({ - isTonToCosmos: isFromTon, - transferAmount: fromAmount - }); - } - assert( newToToken.coinGeckoId === from.coinGeckoId, `From token ${from.coinGeckoId} is different from to token ${newToToken.coinGeckoId}` @@ -585,6 +577,52 @@ const Balance: React.FC = () => { ); if (findRelayerFee) relayerFee.relayerAmount = findRelayerFee.amount; + + //------------------------------------------------------- + // FIXME: need remove after fix ibc hooks + if (from.cosmosBased && from.chainId !== 'noble-1' && to.chainId === 'Oraichain') { + const ibcInfo = UniversalSwapHelper.getIbcInfo(from.chainId as CosmosChainId, to.chainId); + if (!ibcInfo) + throw generateError(`Could not find the ibc info given the from token with coingecko id ${from.coinGeckoId}`); + + const offlineSigner = await collectWallet(from.chainId); + const client = await connectWithSigner( + from.rpc, + offlineSigner as any, + from.chainId === 'injective-1' ? 'injective' : 'cosmwasm', + { + gasPrice: GasPrice.fromString( + `${getCosmosGasPrice(from.gasPriceStep)}${from.feeCurrencies[0].coinMinimalDenom}` + ), + broadcastPollIntervalMs: 600 + } + ); + + const receiver = await handleCheckAddress(to.chainId); + const msgTransferObj = { + sourcePort: ibcInfo.source, + receiver, + sourceChannel: ibcInfo.channel, + token: coin(toAmount(fromAmount, from.decimals).toString(), from.denom), + sender: cosmosAddress, + memo: '', + timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout) + }; + let msgTransfer: any = MsgTransfer.fromPartial(msgTransferObj as any); + if (from.chainId === 'injective-1') { + msgTransfer = MsgTransferInjective.fromPartial(msgTransferObj); + } + + const msgTransferEncodeObj = { + typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', + value: msgTransfer + }; + + result = await client.signAndBroadcast(cosmosAddress, [msgTransferEncodeObj], 'auto'); + return processTxResult(from.rpc, result, getTransactionUrl(from.chainId, result.transactionHash)); + } + //------------------------------------------------------- + const universalSwapHandler = new UniversalSwapHandler( { sender: { cosmos: cosmosAddress, evm: latestEvmAddress, tron: tronAddress }, @@ -705,22 +743,7 @@ const Balance: React.FC = () => {
-
{ - try { - if (loadingRefresh) return; - setLoadingRefresh(true); - await loadTokenAmounts({ metamaskAddress, tronAddress, oraiAddress, btcAddress, tonAddress }); - } catch (err) { - console.log({ err }); - } finally { - setTimeout(() => { - setLoadingRefresh(false); - }, 2000); - } - }} - > +
Refresh balances
@@ -749,7 +772,6 @@ const Balance: React.FC = () => { window?.owallet?.isOwallet; const isBtcToken = t.chainId === bitcoinChainId && t?.coinGeckoId === 'bitcoin'; - const isV2 = false; const TokenItemELement: React.FC = isBtcToken && isV2 ? TokenItemBtc : TokenItem; return ( @@ -795,7 +817,6 @@ const Balance: React.FC = () => { }} isFastMode={isFastMode} setIsFastMode={setIsFastMode} - setToNetworkChainId={setToNetworkChainId} />
); diff --git a/src/pages/BitcoinDashboardV2/components/ConvertBitcoinV2/index.module.scss b/src/pages/BitcoinDashboardV2/components/ConvertBitcoinV2/index.module.scss index d3484e43f..48ff95638 100644 --- a/src/pages/BitcoinDashboardV2/components/ConvertBitcoinV2/index.module.scss +++ b/src/pages/BitcoinDashboardV2/components/ConvertBitcoinV2/index.module.scss @@ -37,7 +37,7 @@ .title { @include theme { - color: theme-get('neutral-8'); + color: theme-get('neutral-9'); } font-size: 14px; @@ -119,7 +119,7 @@ .usd { @include theme { - color: theme-get('neutral-8'); + color: theme-get('neutral-9'); } font-size: 14px; font-weight: 400; diff --git a/src/pages/BitcoinDashboardV2/components/Header/Header.module.scss b/src/pages/BitcoinDashboardV2/components/Header/Header.module.scss index e12d94146..af9b5d6b6 100644 --- a/src/pages/BitcoinDashboardV2/components/Header/Header.module.scss +++ b/src/pages/BitcoinDashboardV2/components/Header/Header.module.scss @@ -13,6 +13,7 @@ flex-wrap: wrap; margin-bottom: 16px; + &_text { display: flex; align-items: flex-end; @@ -27,7 +28,7 @@ .priceOrai { @include theme() { - color: theme-get('neutral-8'); + color: theme-get('neutral-9'); } font-size: 24px; font-weight: 500; @@ -117,6 +118,7 @@ flex-direction: column; flex: 1 0 0; + color: $neutron-text-body-light; font-size: 16px; font-weight: 500; diff --git a/src/pages/Pool-V3/components/PoolList/PoolItemTData.tsx b/src/pages/Pool-V3/components/PoolList/PoolItemTData.tsx index 95bf9005e..fd7ebd34a 100644 --- a/src/pages/Pool-V3/components/PoolList/PoolItemTData.tsx +++ b/src/pages/Pool-V3/components/PoolList/PoolItemTData.tsx @@ -43,6 +43,8 @@ const PoolItemTData = ({ } = item; const isInactive = tokenXinfo?.name === 'BTC (Legacy)' || tokenYinfo?.name === 'BTC (Legacy)'; + const isOraiBtcPoolV2 = tokenXinfo?.name === 'ORAI' && tokenYinfo?.name === 'BTC (Legacy)' && type === 'Pool V2'; + return ( <> @@ -52,7 +54,7 @@ const PoolItemTData = ({ - {tokenXinfo?.name} / {tokenYinfo?.name} + {tokenXinfo?.name} / {isOraiBtcPoolV2 ? 'BTC' : tokenYinfo?.name} {type === POOL_TYPE.V3 ? 'V3' : 'V2'} @@ -102,7 +104,7 @@ const PoolItemTData = ({
Swap fee - {aprInfo.swapFee.min === aprInfo.swapFee.max + {aprInfo.swapFee.min === aprInfo.swapFee.max ? `${numberWithCommas(aprInfo.swapFee.min * 100, undefined, { maximumFractionDigits: 1 })}` : `${numberWithCommas(aprInfo.swapFee.min * 100, undefined, { maximumFractionDigits: 1 diff --git a/src/pages/Pools/PoolDetail.tsx b/src/pages/Pools/PoolDetail.tsx index 3517674da..493ff5195 100644 --- a/src/pages/Pools/PoolDetail.tsx +++ b/src/pages/Pools/PoolDetail.tsx @@ -7,7 +7,7 @@ import useConfigReducer from 'hooks/useConfigReducer'; import useLoadTokens from 'hooks/useLoadTokens'; import useTheme from 'hooks/useTheme'; import Content from 'layouts/Content'; -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; import { useNavigate, useParams } from 'react-router-dom'; import { updateLpPools } from 'reducer/token'; @@ -29,7 +29,8 @@ import { Button } from 'components/Button'; import AddIcon from 'assets/icons/Add.svg?react'; import { parseAssetOnlyDenom } from './helpers'; import { AddLiquidityModal } from './components/AddLiquidityModal'; -import { numberWithCommas } from 'helper/format'; +import { formatNumberKMB, numberWithCommas } from 'helper/format'; +import { BTC_CONTRACT, fetchRetry, toDisplay } from '@oraichain/oraidex-common'; const PoolDetail: React.FC = () => { const theme = useTheme(); @@ -46,6 +47,7 @@ const PoolDetail: React.FC = () => { const { refetchPairAmountInfo, refetchLpTokenInfoData } = useGetPairInfo(poolDetailData); const queryClient = useQueryClient(); const [pairDenomsDeposit, setPairDenomsDeposit] = useState(''); + const [ratioOraiBtc, setRatioOraiBtc] = useState(0); const { lpBalanceInfoData, refetchLpBalanceInfoData } = useGetLpBalance(poolDetailData); const lpTokenBalance = BigInt(lpBalanceInfoData?.balance || '0'); @@ -118,6 +120,34 @@ const PoolDetail: React.FC = () => { const isInactive = baseToken?.name === 'BTC (Legacy)' || quoteToken?.name === 'BTC (Legacy)'; + const listBTCAddresses = [ + BTC_CONTRACT, + 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/obtc' + ]; + useEffect(() => { + if (!poolDetailData) return; + const { token2 } = poolDetailData; + async function getOraiBtcAllocation() { + const res = await fetchRetry( + 'https://lcd.orai.io/cosmos/bank/v1beta1/balances/orai1fv5kwdv4z0gvp75ht378x8cg2j7prlywa0g35qmctez9q8u4xryspn6lrd' + ); + return await res.json(); + } + + if (listBTCAddresses.includes(token2.denom) || listBTCAddresses.includes(token2.contractAddress)) { + getOraiBtcAllocation().then((data) => { + const balances = data.balances; + const oraiBalance = balances.find((item) => item.denom === 'orai'); + const btcBalance = balances.find( + (item) => item.denom === 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/obtc' + ); + const oraiBalanceDisplay = formatNumberKMB(toDisplay(oraiBalance?.amount || '0'), false); + const btcBalanceDisplay = formatNumberKMB(toDisplay(btcBalance?.amount || '0', 14), false); + setRatioOraiBtc(Number(oraiBalanceDisplay) / Number(btcBalanceDisplay)); + }); + } + }, [poolDetailData]); + return (
@@ -136,17 +166,30 @@ const PoolDetail: React.FC = () => { {QuoteTokenIcon && }
- {baseToken?.name?.toUpperCase()} / {quoteToken?.name?.toUpperCase()} + {baseToken?.name?.toUpperCase()} /{' '} + {quoteToken?.name === 'BTC (Legacy)' ? 'BTC' : quoteToken?.name?.toUpperCase()} V2
+
- 1 {baseToken?.name} = {numberWithCommas(priceChange?.price || 0, undefined, { maximumFractionDigits: 6 })}{' '} - {quoteToken?.name} - {isMobileMode ?
:
|
}1 {quoteToken?.name} ={' '} - {numberWithCommas(1 / (priceChange?.price || 1), undefined, { maximumFractionDigits: 6 })}{' '} - {baseToken?.name} + {/* TODO: remove after pool close */} + {ratioOraiBtc + ? `1 ${baseToken?.name} = ${numberWithCommas(1 / (ratioOraiBtc || 1), undefined, { + maximumFractionDigits: 6 + })}` + : `1 ${baseToken?.name} = ${numberWithCommas(priceChange?.price || 0, undefined, { + maximumFractionDigits: 6 + })}`} + {/* TODO: remove after pool close */} {quoteToken?.name === 'BTC (Legacy)' ? 'BTC' : quoteToken?.name} + {isMobileMode ?
:
|
}1{' '} + {quoteToken?.name === 'BTC (Legacy)' ? 'BTC' : quoteToken?.name} ={' '} + {ratioOraiBtc + ? `${numberWithCommas(ratioOraiBtc || 0, undefined, { maximumFractionDigits: 6 })} ${baseToken?.name}` + : `${numberWithCommas(1 / (priceChange?.price || 1) || 0, undefined, { maximumFractionDigits: 6 })} ${ + baseToken?.name + }`}
diff --git a/src/pages/Pools/components/OverviewPool/OverviewPool.tsx b/src/pages/Pools/components/OverviewPool/OverviewPool.tsx index 854c4135c..ba7d01711 100644 --- a/src/pages/Pools/components/OverviewPool/OverviewPool.tsx +++ b/src/pages/Pools/components/OverviewPool/OverviewPool.tsx @@ -1,11 +1,11 @@ -import { CW20_DECIMALS, toDisplay } from '@oraichain/oraidex-common'; +import { BTC_CONTRACT, CW20_DECIMALS, fetchRetry, toDisplay } from '@oraichain/oraidex-common'; import DefaultIcon from 'assets/icons/tokens.svg?react'; import classNames from 'classnames'; import TokenBalance from 'components/TokenBalance'; import useTheme from 'hooks/useTheme'; import { toFixedIfNecessary } from 'pages/Pools/helpers'; import { useGetPairInfo } from 'pages/Pools/hooks/useGetPairInfo'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { PoolDetail } from 'types/pool'; import BootsIconDark from 'assets/icons/boost-icon-dark.svg?react'; import BootsIcon from 'assets/icons/boost-icon.svg?react'; @@ -19,6 +19,10 @@ export const OverviewPool = ({ poolDetailData }: { poolDetailData: PoolDetail }) const { pairAmountInfoData, lpTokenInfoData } = useGetPairInfo(poolDetailData); const { token1, token2 } = poolDetailData; + const [oraiBtcAllocation, setOraiBtcAllocation] = useState({ + oraiBalanceDisplay: '0', + btcBalanceDisplay: '0' + }); const [isShowMore] = useState(false); const isLight = theme === 'light'; const IconBoots = isLight ? BootsIcon : BootsIconDark; @@ -41,6 +45,37 @@ export const OverviewPool = ({ poolDetailData }: { poolDetailData: PoolDetail }) poolReward = cachedReward.find((item) => item.liquidity_token === stakingToken); } + const listBTCAddresses = [ + BTC_CONTRACT, + 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/obtc' + ]; + + useEffect(() => { + if (!poolDetailData) return; + const { token2 } = poolDetailData; + async function getOraiBtcAllocation() { + const res = await fetchRetry( + 'https://lcd.orai.io/cosmos/bank/v1beta1/balances/orai1fv5kwdv4z0gvp75ht378x8cg2j7prlywa0g35qmctez9q8u4xryspn6lrd' + ); + return await res.json(); + } + if (listBTCAddresses.includes(token2.denom) || listBTCAddresses.includes(token2.contractAddress)) { + getOraiBtcAllocation().then((data) => { + const balances = data.balances; + const oraiBalance = balances.find((item) => item.denom === 'orai'); + const btcBalance = balances.find( + (item) => item.denom === 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/obtc' + ); + const oraiBalanceDisplay = formatNumberKMB(toDisplay(oraiBalance?.amount || '0'), false); + const btcBalanceDisplay = formatNumberKMB(toDisplay(btcBalance?.amount || '0', 14), false); + setOraiBtcAllocation({ + oraiBalanceDisplay, + btcBalanceDisplay + }); + }); + } + }, [poolDetailData]); + return (
@@ -61,20 +96,33 @@ export const OverviewPool = ({ poolDetailData }: { poolDetailData: PoolDetail })

Liquidity Allocation

-
-
- {BaseTokenIcon && } - - {formatNumberKMB(toDisplay(pairAmountInfoData?.token1Amount || '0'), false)} - + {listBTCAddresses.includes(token2.denom) || listBTCAddresses.includes(token2.contractAddress) ? ( +
+
+ {BaseTokenIcon && } + {oraiBtcAllocation.oraiBalanceDisplay} +
+
+ {QuoteTokenIcon && } + {oraiBtcAllocation.btcBalanceDisplay} +
-
- {QuoteTokenIcon && } - - {formatNumberKMB(toDisplay(pairAmountInfoData?.token2Amount || '0'), false)} - + ) : ( +
+
+ {BaseTokenIcon && } + + {formatNumberKMB(toDisplay(pairAmountInfoData?.token1Amount || '0'), false)} + +
+
+ {QuoteTokenIcon && } + + {formatNumberKMB(toDisplay(pairAmountInfoData?.token2Amount || '0'), false)} + +
-
+ )}
diff --git a/src/pages/Pools/components/TransactionHistory/index.tsx b/src/pages/Pools/components/TransactionHistory/index.tsx index bb009f84d..05817fe1d 100644 --- a/src/pages/Pools/components/TransactionHistory/index.tsx +++ b/src/pages/Pools/components/TransactionHistory/index.tsx @@ -203,7 +203,12 @@ const TransactionHistory = ({ baseToken, quoteToken }: { baseToken: TokenItemTyp {numberWithCommas(toDisplay(item.offerAmount), undefined, { maximumFractionDigits: 6 })} - {offerToken.name} + + {/* {offerToken.name} */} + {/* TODO: remove after pool close */} + + {offerToken?.name === 'BTC (Legacy)' ? 'BTC' : offerToken?.name} +
@@ -216,7 +221,10 @@ const TransactionHistory = ({ baseToken, quoteToken }: { baseToken: TokenItemTyp maximumFractionDigits: 6 })} - {returnToken.name} + {/* {returnToken.name} */} + + {returnToken?.name === 'BTC (Legacy)' ? 'BTC' : returnToken?.name} +
diff --git a/src/pages/Pools/components/WithdrawLiquidityModal/WithdrawLiquidityModal.tsx b/src/pages/Pools/components/WithdrawLiquidityModal/WithdrawLiquidityModal.tsx index 9c24c0654..49d4d36da 100644 --- a/src/pages/Pools/components/WithdrawLiquidityModal/WithdrawLiquidityModal.tsx +++ b/src/pages/Pools/components/WithdrawLiquidityModal/WithdrawLiquidityModal.tsx @@ -1,4 +1,4 @@ -import { ORAI, toAmount } from '@oraichain/oraidex-common'; +import { BTC_CONTRACT, ORAI, toAmount } from '@oraichain/oraidex-common'; import CloseIcon from 'assets/icons/ic_close_modal.svg?react'; import cn from 'classnames/bind'; import { Button } from 'components/Button'; @@ -90,7 +90,13 @@ export const WithdrawLiquidityModal: FC = ({ const lp1BurnAmount = totalSupply === BigInt(0) || !lpAmountBurn ? BigInt(0) : (token1Amount * BigInt(lpAmountBurn)) / totalSupply; const lp2BurnAmount = - totalSupply === BigInt(0) || !lpAmountBurn ? BigInt(0) : (token2Amount * BigInt(lpAmountBurn)) / totalSupply; + // TOODO: remove after pool ORAI/BTC close + totalSupply === BigInt(0) || !lpAmountBurn + ? BigInt(0) + : (token2.contractAddress === BTC_CONTRACT + ? (token2Amount / BigInt(10 ** 8)) * BigInt(lpAmountBurn) + : token2Amount * BigInt(lpAmountBurn)) / totalSupply; + const lpAmountBurnUsdt = !myLpBalance ? 0 : (Number(lpAmountBurn) / Number(myLpBalance)) * Number(myLpUsdt); return ( @@ -144,7 +150,8 @@ export const WithdrawLiquidityModal: FC = ({
{Token2Icon && }
-
{token2?.name}
+ {/* TODO: remove after pool close */} +
{token2?.name === 'BTC (Legacy)' ? 'BTC' : token2?.name}
Oraichain
diff --git a/src/pages/UniversalSwap/Component/AssetsTab.tsx b/src/pages/UniversalSwap/Component/AssetsTab.tsx index 88246e17b..cd0be5110 100644 --- a/src/pages/UniversalSwap/Component/AssetsTab.tsx +++ b/src/pages/UniversalSwap/Component/AssetsTab.tsx @@ -40,12 +40,12 @@ export const AssetsTab: FC<{ networkFilter: string }> = ({ networkFilter }) => { stakerAddress: address }); let totalUsd: number = getTotalUsd(amounts, prices); - // if (networkFilter) { - // const subAmounts = Object.fromEntries( - // Object.entries(amounts).filter(([denom]) => tokenMap?.[denom]?.chainId === networkFilter) - // ); - // totalUsd = getTotalUsd(subAmounts, prices); - // } + if (networkFilter) { + const subAmounts = Object.fromEntries( + Object.entries(amounts).filter(([denom]) => tokenMap?.[denom]?.chainId === networkFilter) + ); + totalUsd = getTotalUsd(subAmounts, prices); + } useEffect(() => { dispatch(updateTotalLpv3(totalLpV3Info || 0)); @@ -56,12 +56,12 @@ export const AssetsTab: FC<{ networkFilter: string }> = ({ networkFilter }) => { label?: string; balance?: number | string; }[] = [ - { - src: WalletIcon, - label: 'Total balance', - balance: formatDisplayUsdt(totalUsd) - } - ]; + { + src: WalletIcon, + label: 'Total balance', + balance: formatDisplayUsdt(totalUsd) + } + ]; if (!networkFilter || networkFilter === 'Oraichain') { listAsset = [ diff --git a/src/pages/UniversalSwap/Component/HistoryTab.tsx b/src/pages/UniversalSwap/Component/HistoryTab.tsx index 0fa7c64a3..f1cc34913 100644 --- a/src/pages/UniversalSwap/Component/HistoryTab.tsx +++ b/src/pages/UniversalSwap/Component/HistoryTab.tsx @@ -115,6 +115,8 @@ export const HistoryTab: React.FC<{ }> = ({ networkFilter }) => { const { transHistory } = useGetTransHistory(); const [selectedData, setSelectedData] = useState(null); + console.log({ selectedData }); + const headers: TableHeaderProps = { assets: { name: '', diff --git a/src/pages/UniversalSwap/Swap/components/SelectToken/SelectToken.tsx b/src/pages/UniversalSwap/Swap/components/SelectToken/SelectToken.tsx index 3b354c0c4..97f7a6835 100644 --- a/src/pages/UniversalSwap/Swap/components/SelectToken/SelectToken.tsx +++ b/src/pages/UniversalSwap/Swap/components/SelectToken/SelectToken.tsx @@ -84,10 +84,6 @@ export default function SelectToken({ (textSearch ? item.name.toLowerCase().includes(textSearch.toLowerCase()) : true) ); - console.log({ - listItems - }); - return ( <>
diff --git a/src/pages/UniversalSwap/Swap/hooks/useHandleEffectTokenChange.ts b/src/pages/UniversalSwap/Swap/hooks/useHandleEffectTokenChange.ts index a0994fdbb..d1d11e878 100644 --- a/src/pages/UniversalSwap/Swap/hooks/useHandleEffectTokenChange.ts +++ b/src/pages/UniversalSwap/Swap/hooks/useHandleEffectTokenChange.ts @@ -26,7 +26,6 @@ const useHandleEffectTokenChange = ({ fromTokenDenomSwap, toTokenDenomSwap }) => const [metamaskAddress] = useConfigReducer('metamaskAddress'); const [tronAddress] = useConfigReducer('tronAddress'); - const [tonAddress] = useConfigReducer('tonAddress'); const [oraiAddress] = useConfigReducer('address'); const [addressTransfer, setAddressTransfer] = useState(''); @@ -54,23 +53,19 @@ const useHandleEffectTokenChange = ({ fromTokenDenomSwap, toTokenDenomSwap }) => useEffect(() => { (async () => { if (!isMobile()) { - const isNetworkSupported = - walletByNetworks.evm || walletByNetworks.cosmos || walletByNetworks.tron || walletByNetworks.ton; + if (!walletByNetworks.evm && !walletByNetworks.cosmos && !walletByNetworks.tron) { + return setAddressTransfer(''); + } - if (!isNetworkSupported) { + if (originalToToken.cosmosBased && !walletByNetworks.cosmos) { return setAddressTransfer(''); } - const isCosmosBased = originalToToken.cosmosBased; - const chainId = originalToToken.chainId; + if (!originalToToken.cosmosBased && originalToToken.chainId === '0x2b6653dc' && !walletByNetworks.tron) { + return setAddressTransfer(''); + } - if ( - (isCosmosBased && !walletByNetworks.cosmos) || - (!isCosmosBased && - ((chainId === '0x2b6653dc' && !walletByNetworks.tron) || - (chainId === 'ton' && !walletByNetworks.ton) || - (['0x01', '0x38'].includes(chainId) && !walletByNetworks.evm))) - ) { + if (!originalToToken.cosmosBased && !walletByNetworks.evm) { return setAddressTransfer(''); } } @@ -88,14 +83,11 @@ const useHandleEffectTokenChange = ({ fromTokenDenomSwap, toTokenDenomSwap }) => oraiAddress, metamaskAddress, tronAddress, - tonAddress, walletByNetworks.evm, walletByNetworks.cosmos, walletByNetworks.tron, - walletByNetworks.ton, window?.ethereumDapp, - window?.tronWebDapp, - window?.Ton + window?.tronWebDapp ]); useEffect(() => { @@ -121,7 +113,7 @@ const useHandleEffectTokenChange = ({ fromTokenDenomSwap, toTokenDenomSwap }) => }, [originalFromToken, fromToken]); const isConnectedWallet = - walletByNetworks.cosmos || walletByNetworks.bitcoin || walletByNetworks.evm || walletByNetworks.tron || window.Ton; + walletByNetworks.cosmos || walletByNetworks.bitcoin || walletByNetworks.evm || walletByNetworks.tron; let validAddress = { isValid: true diff --git a/src/pages/UniversalSwap/Swap/hooks/useSimulate.ts b/src/pages/UniversalSwap/Swap/hooks/useSimulate.ts index 71716a1da..a61dcc6ed 100644 --- a/src/pages/UniversalSwap/Swap/hooks/useSimulate.ts +++ b/src/pages/UniversalSwap/Swap/hooks/useSimulate.ts @@ -16,7 +16,7 @@ export const getRouterConfig = (options?: { ignoreFee?: boolean; }) => { return { - url: 'https://osor-staging.oraidex.io', + url: 'https://osor.oraidex.io', path: options?.path ?? '/smart-router/alpha-router', protocols: options?.protocols ?? ['Oraidex', 'OraidexV3'], dontAllowSwapAfter: options?.dontAllowSwapAfter ?? ['Oraidex', 'OraidexV3'], diff --git a/src/pages/UniversalSwap/Swap/index.tsx b/src/pages/UniversalSwap/Swap/index.tsx index 2792a9032..8629b7893 100644 --- a/src/pages/UniversalSwap/Swap/index.tsx +++ b/src/pages/UniversalSwap/Swap/index.tsx @@ -85,7 +85,6 @@ import useCalculateDataSwap, { SIMULATE_INIT_AMOUNT } from './hooks/useCalculate import { useFillToken } from './hooks/useFillToken'; import useHandleEffectTokenChange from './hooks/useHandleEffectTokenChange'; import styles from './index.module.scss'; -import TonWallet from '@oraichain/tonbridge-sdk/build/wallet'; const cx = cn.bind(styles); @@ -98,7 +97,6 @@ const SwapComponent: React.FC<{ const [metamaskAddress] = useConfigReducer('metamaskAddress'); const [tronAddress] = useConfigReducer('tronAddress'); const [oraiAddress] = useConfigReducer('address'); - const [tonAddress] = useConfigReducer('tonAddress'); const [walletByNetworks] = useWalletReducer('walletsByNetwork'); const [theme] = useConfigReducer('theme'); const isLightMode = theme === 'light'; @@ -322,25 +320,8 @@ const SwapComponent: React.FC<{ const isCustomRecipient = validAddress.isValid && addressTransfer !== initAddressTransfer; const alphaSmartRoutes = simulateData?.routes; - let tonWallet = undefined; - if ([originalFromToken.chainId, originalToToken.chainId].includes('ton') && !!walletByNetworks.ton) { - tonWallet = await TonWallet.create('mainnet', { - mnemonicData: { - mnemonic: undefined, - tonWalletVersion: 'V4' - }, - tonConnector: window?.Ton as any - }); - } - - const tonAddress = tonWallet?.sender?.address?.toString(); const swapData = { - sender: { - cosmos: cosmosAddress, - evm: checksumMetamaskAddress, - tron: tronAddress, - ton: tonAddress - }, + sender: { cosmos: cosmosAddress, evm: checksumMetamaskAddress, tron: tronAddress }, originalFromToken, originalToToken, fromAmount: fromAmountToken, @@ -354,10 +335,10 @@ const SwapComponent: React.FC<{ alphaSmartRoutes }; + // @ts-ignore const univeralSwapHandler = new UniversalSwapHandler(swapData, { cosmosWallet: window.Keplr, evmWallet: new Metamask(window.tronWebDapp), - tonWallet, swapOptions: { isAlphaIbcWasm: useAlphaIbcWasm, isIbcWasm: useIbcWasm, @@ -367,14 +348,12 @@ const SwapComponent: React.FC<{ } }); - const result = await univeralSwapHandler.processUniversalSwap(); - let transactionHash = result?.transactionHash; - + const { transactionHash } = await univeralSwapHandler.processUniversalSwap(); if (transactionHash) { displayToast(TToastType.TX_SUCCESSFUL, { customLink: getTransactionUrl(originalFromToken.chainId, transactionHash) }); - loadTokenAmounts({ oraiAddress, metamaskAddress, tronAddress, tonAddress }); + loadTokenAmounts({ oraiAddress, metamaskAddress, tronAddress }); setSwapLoading(false); // save to duckdb @@ -691,7 +670,7 @@ const SwapComponent: React.FC<{ loadingRefresh, setLoadingRefresh, // TODO: need add bitcoinAddress when universal swap support bitcoin - { metamaskAddress, tronAddress, oraiAddress, tonAddress }, + { metamaskAddress, tronAddress, oraiAddress }, loadTokenAmounts ) } diff --git a/src/pages/UniversalSwap/helpers.ts b/src/pages/UniversalSwap/helpers.ts index c91e1e6ee..a3648c048 100644 --- a/src/pages/UniversalSwap/helpers.ts +++ b/src/pages/UniversalSwap/helpers.ts @@ -193,8 +193,6 @@ export const getExplorerScan = (chainId: NetworkChainId) => { return 'https://scan.kawaii.global/tx'; case 'noble-1': return 'https://www.mintscan.io/noble/tx'; - case 'ton': - return 'https://tonscan.org/address'; default: return 'https://scan.orai.io/txs'; } @@ -281,13 +279,13 @@ export const getTokenIcon = (token: TokenItemType, theme: string) => { export const refreshBalances = async ( loadingRefresh: boolean, setLoadingRefresh: (boolean) => void, - { metamaskAddress, tronAddress, oraiAddress, tonAddress }, + { metamaskAddress, tronAddress, oraiAddress }, callback ) => { try { if (loadingRefresh) return; setLoadingRefresh(true); - await callback({ metamaskAddress, tronAddress, oraiAddress, tonAddress }); + await callback({ metamaskAddress, tronAddress, oraiAddress }); } catch (err) { console.log({ err }); } finally { @@ -340,6 +338,11 @@ export const getDisableSwap = ({ simulateData, isLoadingSimulate }) => { + const mobileMode = isMobile(); + const canSwapToCosmos = !mobileMode && originalToToken.cosmosBased && !walletByNetworks.cosmos; + const canSwapToEvm = !mobileMode && !originalToToken.cosmosBased && !walletByNetworks.evm; + const canSwapToTron = !mobileMode && originalToToken.chainId === '0x2b6653dc' && !walletByNetworks.tron; + const canSwapTo = canSwapToCosmos || canSwapToEvm || canSwapToTron; const disabledSwapBtn = swapLoading || !fromAmountToken || @@ -347,11 +350,15 @@ export const getDisableSwap = ({ fromAmountTokenBalance > fromTokenBalance || // insufficent fund !addressTransfer || !validAddress.isValid || - isLoadingSimulate; + isLoadingSimulate || + canSwapTo; let disableMsg: string; if (!validAddress.isValid) disableMsg = `Recipient address not found`; if (!addressTransfer) disableMsg = `Recipient address not found`; + if (canSwapToCosmos) disableMsg = `Please connect cosmos wallet`; + if (canSwapToEvm) disableMsg = `Please connect evm wallet`; + if (canSwapToTron) disableMsg = `Please connect tron wallet`; if (!simulateData || simulateData.displayAmount <= 0) disableMsg = 'Enter an amount'; if (fromAmountTokenBalance > fromTokenBalance) disableMsg = `Insufficient funds`; if (isLoadingSimulate) disableMsg = `Swap`; @@ -372,7 +379,7 @@ export const getProtocolsSmartRoute = ( ) => { const protocols = ['Oraidex', 'OraidexV3']; if (useIbcWasm && !useAlphaIbcWasm) return protocols; - if (fromToken?.chainId === 'noble-1' || toToken?.chainId === 'noble-1') return protocols; + if (fromToken.chainId === 'noble-1' || toToken.chainId === 'noble-1') return protocols; const allowOsmosisProtocols = ['injective-1', 'Neutaro-1', 'noble-1', 'osmosis-1', 'cosmoshub-4', 'celestia']; const isAllowOsmosisProtocol = diff --git a/src/reducer/config.ts b/src/reducer/config.ts index 8c12f55b1..39322d7ab 100644 --- a/src/reducer/config.ts +++ b/src/reducer/config.ts @@ -20,15 +20,11 @@ export type RewardPoolType = { liquidity_token: string; }; -type WalletTonDetails = { [denom: string]: string }; - export interface ConfigState { address: string; metamaskAddress: string | null; tronAddress: string | null; btcAddress: string | null; - tonAddress: string | null; - walletsTon: WalletTonDetails; // ton wallets for bridge adapter cosmosAddress: { [key: string]: string }; allPendingDeposits: { [key: string]: DepositInfo[] }; chainId: string; @@ -74,9 +70,7 @@ const initialState: ConfigState = { metamaskAddress: '', bannerTime: 0, btcAddress: '', - tonAddress: '', tronAddress: '', - walletsTon: {}, walletTypeStore: 'owallet', cosmosAddress: {}, allPendingDeposits: {}, diff --git a/src/reducer/wallet.ts b/src/reducer/wallet.ts index 9a3902058..c060ffaf3 100644 --- a/src/reducer/wallet.ts +++ b/src/reducer/wallet.ts @@ -6,7 +6,6 @@ export type WalletsByNetwork = { evm: 'owallet' | 'metamask' | null; tron: 'owallet' | 'tronLink' | null; bitcoin: 'owallet' | null; - ton: 'ton' | null; }; export interface WalletState { @@ -18,8 +17,7 @@ const initialState: WalletState = { cosmos: null, evm: null, tron: null, - bitcoin: null, - ton: null + bitcoin: null } }; diff --git a/src/rest/api.ts b/src/rest/api.ts index 615df025a..e930abb32 100644 --- a/src/rest/api.ts +++ b/src/rest/api.ts @@ -3,6 +3,7 @@ import { Coin, coin } from '@cosmjs/stargate'; import { CwIcs20LatestQueryClient, MulticallQueryClient, Uint128 } from '@oraichain/common-contracts-sdk'; import { ConfigResponse, RelayerFeeResponse } from '@oraichain/common-contracts-sdk/build/CwIcs20Latest.types'; import { + BTC_CONTRACT, IBCInfo, IBC_WASM_CONTRACT, KWT_DENOM, @@ -99,6 +100,17 @@ async function fetchTokenInfos(tokens: TokenItemType[]): Promise { } function parsePoolAmount(poolInfo: OraiswapPairTypes.PoolResponse, trueAsset: AssetInfo): bigint { + // TODO: remove when pool orai/btc close + if ('token' in trueAsset && trueAsset.token.contract_addr === BTC_CONTRACT) { + return BigInt( + poolInfo.assets.find( + (asset) => + 'native_token' in asset.info && + asset.info.native_token.denom === + 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/obtc' + )?.amount || '0' + ); + } return BigInt(poolInfo.assets.find((asset) => isEqual(asset.info, trueAsset))?.amount || '0'); } diff --git a/src/styles/_reboot.scss b/src/styles/_reboot.scss index cb0298b94..512ec48d8 100644 --- a/src/styles/_reboot.scss +++ b/src/styles/_reboot.scss @@ -117,8 +117,3 @@ textarea { [type='number']::-webkit-outer-spin-button { -webkit-appearance: none; } - -#tc-widget-root { - position: absolute; - z-index: 1022; // set for zindex above react-modal (1021) -} diff --git a/src/styles/_themes.scss b/src/styles/_themes.scss index 89ed6c368..8259cc75c 100644 --- a/src/styles/_themes.scss +++ b/src/styles/_themes.scss @@ -159,8 +159,7 @@ $themes: ( 'neutral-text-btn-default': #152703, 'neutral-surface-bg-3': #f7f7f7, 'neutral-surface-bg-swap': #1b1d19, - 'neutral-surface-bg-strong': #131412, - 'neutral-surface-bg-box': #232521 + 'neutral-surface-bg-strong': #131412 ), light: ( 'warning-surface-default-subtle': #fffdeb, @@ -267,7 +266,6 @@ $themes: ( 'bg-overlay-section': rgba(255, 255, 255, 0.5), 'neutral-surface-bg-3': #181a17, 'neutral-surface-bg-swap': #fff, - 'neutral-surface-bg-strong': #f2f4f0, - 'neutral-surface-bg-box': #f2f4f0 + 'neutral-surface-bg-strong': #f2f4f0 ) ); diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 469e39451..47943cb0d 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -10,7 +10,6 @@ import { Networks as _Networks } from 'libs/ethereum-multicall/enums'; import { DuckDb } from 'libs/duckdb'; import { Class } from '@oraichain/common-contracts-sdk/build/CwIcs721Bridge.types'; import Bitcoin, { IBitcoin } from 'libs/bitcoin'; -import { TonConnectUI } from '@tonconnect/ui-react'; declare global { type AmountDetails = { [denom: string]: string }; @@ -118,7 +117,6 @@ declare global { Wallet: Wallet; Keplr: Keplr; Bitcoin: Bitcoin; - Ton: TonConnectUI; tronWeb: _TronWeb; tronLink: TronLink; ethereum: MetaMaskEthereumProvider; diff --git a/vite.config.ts b/vite.config.ts index 655f94288..510f52d48 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -37,10 +37,5 @@ export default defineConfig({ commonjsOptions: { transformMixedEsModules: true }, outDir: path.resolve(__dirname, 'build'), rollupOptions: {} - }, - esbuild: { - supported: { - 'top-level-await': true //browsers can handle top-level-await features - } } }); diff --git a/yarn.lock b/yarn.lock index 72c06965f..187ed0be2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3025,13 +3025,6 @@ long "^4.0.0" secretjs "^0.17.0" -"@keplr-wallet/types@0.12.141": - version "0.12.141" - resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.12.141.tgz#341cc45882a86a39701d726edc8febdc42cafcb3" - integrity sha512-och1uUeqL6bUgWGLBSlV87rwXUDZMDUOJaARue65mRzfD6ohp9WBVFZfFgpyxU3M6S6UnzQQ6HuKUnWh4WuDjw== - dependencies: - long "^4.0.0" - "@keplr-wallet/types@^0.11.38": version "0.11.64" resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.11.64.tgz#5a308c8c019b4e18f894e0f35f0904b60134d605" @@ -3224,11 +3217,12 @@ integrity sha512-s8H20RXy5gCnu3DnM7L5ClQyj2mdQpbSBpZrXCpIAX9qY0LKsDdZG3sYaDQ8+VN333jz9Pp/qGWdFSYD+6PBsg== "@oraichain/common@^1.0.3": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.0.tgz#201dddcff7bbb0dd90a04cacf82dc3f6b9480788" - integrity sha512-gMTBSkLtHOMUfC5d3VJmEUtN17z5wL2YUrHLXCTcE6VA/K8nZ4jRt8yoO4JU/Lzy8LhZecQ2vM8r6kgLUpg8lw== + version "1.0.3" + resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.0.3.tgz#c6746473deed39622a1368a8f8f733a13f628a7e" + integrity sha512-4Rwwl8DF3bMNh5XSlP44LjUIKCOglDc/R1bUCeVFifZlrTGaz6Zo7Fdw6xwych7b4doxcuQBBh2gr7AZE6jQyQ== dependencies: - "@keplr-wallet/types" "0.12.141" + "@cosmjs/cosmwasm-stargate" "0.31.3" + "@cosmjs/tendermint-rpc" "^0.31.3" axios "0.21.4" axios-extensions "3.1.6" bech32 "^1.1.4" @@ -3347,10 +3341,10 @@ react-use "^17.4.0" react-use-websocket "^4.5.0" -"@oraichain/oraidex-common@1.1.32-beta.7", "@oraichain/oraidex-common@^1.1.32", "@oraichain/oraidex-common@^1.1.32-beta.7", "@oraichain/oraidex-common@^1.1.6": - version "1.1.32-beta.7" - resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.32-beta.7.tgz#acc48b8fe003d639e7550edc8a3b9e4a6c3ee743" - integrity sha512-73sKbCZUO6pn+/g14V5A9FaGmcl7QkrysFz1A7EiluZajMOFYMNqc1GHDHWpHCepwkfS8Qi+hgAPu8pJtJUYgA== +"@oraichain/oraidex-common@1.1.34", "@oraichain/oraidex-common@^1.1.27", "@oraichain/oraidex-common@^1.1.32": + version "1.1.34" + resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.34.tgz#257d25408450c438dc2bf0870fa8de9125af92ed" + integrity sha512-3PzjIS7+QlhSl/5w1NDXr5hZ8LXgJP0IqMWK/ZwJNM7yySeWRui6pwzFwariW2AQ/raU/z1Umr1Bh13idfeQ4Q== dependencies: "@cosmjs/amino" "^0.32.4" "@cosmjs/cosmwasm-stargate" "^0.32.4" @@ -3389,13 +3383,13 @@ resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.45.tgz#42dae0fdd9e005f920ba305b987009f791acc365" integrity sha512-/nYztdxEX5LQM4DMJQmi9HvZrBVoY3nLAmYqSKZGZ0U1h1SxU7O/o22R3/pQwB+sAJdcibaI8ygC0ov7jC8paA== -"@oraichain/oraidex-universal-swap@1.1.22-beta.9": - version "1.1.22-beta.9" - resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.22-beta.9.tgz#442b41e94e056ad30d90c23dfcb12c9811d03d32" - integrity sha512-I6hlUQ6LkTgA1ZAUmSqmkis1kHf3OxWepPwuYdN7xvMIvxihfxCfLYRzcZA3VXHfGbGS7Tp4y2rNqpds2F2+pw== +"@oraichain/oraidex-universal-swap@1.1.23": + version "1.1.23" + resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.23.tgz#2f6c5485728f096cbc11fba517376737c899e610" + integrity sha512-gSk4B84kT2qGx7Nc2uqiRQevS1447DWgmNAOdx4mNDUB4a6nJ79ie/hYGYemddEv6UQ1T/ppao9oxVjWmBecmQ== dependencies: "@oraichain/common" "^1.0.3" - "@oraichain/oraidex-common" "^1.1.32-beta.7" + "@oraichain/oraidex-common" "^1.1.27" "@oraichain/oraidex-contracts-sdk" "^1.0.49" "@oraichain/osor-api-contracts-sdk" "^1.0.2" bech32 "1.1.4" @@ -3422,49 +3416,11 @@ "@cosmjs/crypto" "0.31.3" "@cosmjs/proto-signing" "0.31.3" -"@oraichain/ton-bridge-contracts@^0.15.8": - version "0.15.9" - resolved "https://registry.yarnpkg.com/@oraichain/ton-bridge-contracts/-/ton-bridge-contracts-0.15.9.tgz#279f78ac434d5df69ccf2e51c01e57484789e91e" - integrity sha512-M4ukzlCkPRS+3S+05g/P+82fXjBCe05kBqpJiaZkUDAN7UDbRQJH480AZWl8HotPiM1Ae2TKNl8GPivNmzmwRA== - dependencies: - "@cosmjs/tendermint-rpc" "^0.32.4" - "@orbs-network/ton-access" "^2.3.3" - "@types/varstruct" "^6.1.3" - cosmjs-types "^0.9.0" - dotenv "^16.4.5" - varstruct "^6.1.3" - -"@oraichain/tonbridge-contracts-sdk@^1.3.1", "@oraichain/tonbridge-contracts-sdk@^1.3.6": - version "1.3.6" - resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-contracts-sdk/-/tonbridge-contracts-sdk-1.3.6.tgz#1ee1309e6bb8e186eaa5d706c7d32276ef976402" - integrity sha512-k1DgzfYg3nQNPn2dLiXbkDHXd1WREQA9Dl0ezQ5kPtnlbNK9XjmxSco2gmaJwql0tE3cbBExUflfG0MaRF0dWw== - -"@oraichain/tonbridge-sdk@^1.3.6": - version "1.4.2" - resolved "https://registry.yarnpkg.com/@oraichain/tonbridge-sdk/-/tonbridge-sdk-1.4.2.tgz#05722298dfd0bdbc4feaa45eb652d98361619638" - integrity sha512-pMj/y76S87b/GT4cNjp0oZ+J86tb/vPE0Kcm9vfi9SIMMYeWsk/H5AVlzoYevPrZflkzIA6l/vx+oHkMxpoVyQ== - dependencies: - "@oraichain/common-contracts-sdk" "^1.0.31" - "@oraichain/oraidex-common" "^1.1.6" - "@oraichain/ton-bridge-contracts" "^0.15.8" - "@oraichain/tonbridge-contracts-sdk" "^1.3.6" - "@orbs-network/ton-access" "^2.3.3" - "@ton/core" "^0.56.3" - "@ton/ton" "^14.0.0" - "@tonconnect/ui-react" "^2.0.9" - "@oraichain/wasm-json-toolkit@^1.0.24": version "1.0.24" resolved "https://registry.yarnpkg.com/@oraichain/wasm-json-toolkit/-/wasm-json-toolkit-1.0.24.tgz#e9a431560e8e946fbb7ec257e5f13d9320ffd23a" integrity sha512-j+8gN3dE3rqaiEUVVblt0dfJrE6RIsSkfqF08ISxRvHkH9Pe9exIOgxpCyd2Qn3liHj27hwth6R0ELw7y3QcLg== -"@orbs-network/ton-access@^2.3.3": - version "2.3.3" - resolved "https://registry.yarnpkg.com/@orbs-network/ton-access/-/ton-access-2.3.3.tgz#20292f83b52a75f451f185821180a7d9b829bcd3" - integrity sha512-b1miCPts7wBG9JKYgzXIRZQm/LMy5Uk1mNK8NzlcXHL3HRHJkkFbuYJGuj3IkWCiIicW3Ipp4sYnn3Fwo4oB0g== - dependencies: - isomorphic-fetch "^3.0.0" - "@peculiar/asn1-schema@^2.3.8": version "2.3.8" resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.8.tgz#04b38832a814e25731232dd5be883460a156da3b" @@ -4121,114 +4077,6 @@ dependencies: tippy.js "^6.3.1" -"@ton/core@^0.56.3": - version "0.56.3" - resolved "https://registry.yarnpkg.com/@ton/core/-/core-0.56.3.tgz#1162764573abb76032eba70f8497e5cb2ea532ee" - integrity sha512-HVkalfqw8zqLLPehtq0CNhu5KjVzc7IrbDwDHPjGoOSXmnqSobiWj8a5F+YuWnZnEbQKtrnMGNOOjVw4LG37rg== - dependencies: - symbol.inspect "1.0.1" - -"@ton/crypto-primitives@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@ton/crypto-primitives/-/crypto-primitives-2.1.0.tgz#8c9277c250b59aae3c819e0d6bd61e44d998e9ca" - integrity sha512-PQesoyPgqyI6vzYtCXw4/ZzevePc4VGcJtFwf08v10OevVJHVfW238KBdpj1kEDQkxWLeuNHEpTECNFKnP6tow== - dependencies: - jssha "3.2.0" - -"@ton/crypto@^3.3.0": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@ton/crypto/-/crypto-3.3.0.tgz#019103df6540fbc1d8102979b4587bc85ff9779e" - integrity sha512-/A6CYGgA/H36OZ9BbTaGerKtzWp50rg67ZCH2oIjV1NcrBaCK9Z343M+CxedvM7Haf3f/Ee9EhxyeTp0GKMUpA== - dependencies: - "@ton/crypto-primitives" "2.1.0" - jssha "3.2.0" - tweetnacl "1.0.3" - -"@ton/ton@^14.0.0": - version "14.0.0" - resolved "https://registry.yarnpkg.com/@ton/ton/-/ton-14.0.0.tgz#a66fbbfb159200892557442039a0341cda71fc2d" - integrity sha512-xb2CY6U0AlHUKc7DV7xK/K4Gqn6YoR253yUrM2E7L5WegVFsDF0CQRUIfpYACCuj1oUywQc5J2oMolYNu/uGkA== - dependencies: - axios "^1.6.7" - dataloader "^2.0.0" - symbol.inspect "1.0.1" - teslabot "^1.3.0" - zod "^3.21.4" - -"@tonconnect/isomorphic-eventsource@^0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@tonconnect/isomorphic-eventsource/-/isomorphic-eventsource-0.0.2.tgz#e58c44cf9953e090f2c35da9a638946ddb614be5" - integrity sha512-B4UoIjPi0QkvIzZH5fV3BQLWrqSYABdrzZQSI9sJA9aA+iC0ohOzFwVVGXanlxeDAy1bcvPbb29f6sVUk0UnnQ== - dependencies: - eventsource "^2.0.2" - -"@tonconnect/isomorphic-fetch@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@tonconnect/isomorphic-fetch/-/isomorphic-fetch-0.0.3.tgz#31978e04ddc4428eff532c23d20229ed5ddb6417" - integrity sha512-jIg5nTrDwnite4fXao3dD83eCpTvInTjZon/rZZrIftIegh4XxyVb5G2mpMqXrVGk1e8SVXm3Kj5OtfMplQs0w== - dependencies: - node-fetch "^2.6.9" - -"@tonconnect/protocol@^2.2.6": - version "2.2.6" - resolved "https://registry.yarnpkg.com/@tonconnect/protocol/-/protocol-2.2.6.tgz#24b3fbcde6003e65fb5840a190072db5378699db" - integrity sha512-kyoDz5EqgsycYP+A+JbVsAUYHNT059BCrK+m0pqxykMODwpziuSAXfwAZmHcg8v7NB9VKYbdFY55xKeXOuEd0w== - dependencies: - tweetnacl "^1.0.3" - tweetnacl-util "^0.15.1" - -"@tonconnect/sdk@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@tonconnect/sdk/-/sdk-3.0.3.tgz#0cc6a570817194c648193f7a1db525419c570e3f" - integrity sha512-ElVre1DPixzQLgLtQIa8Wu5xS8nozlgblZTJhFFPrk82M2rZ+sawyF+LAVwt9wZRN7+htWnJrNz0+bBr4b3geA== - dependencies: - "@tonconnect/isomorphic-eventsource" "^0.0.2" - "@tonconnect/isomorphic-fetch" "^0.0.3" - "@tonconnect/protocol" "^2.2.6" - -"@tonconnect/sdk@3.0.5": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@tonconnect/sdk/-/sdk-3.0.5.tgz#08a202bdc8ea897c37221fd69925c35cd2106323" - integrity sha512-ow0qnN4s3iQ/r2uXobZ7YzdQBtan/36CgCT9IP35G07g38UxsUXwzw8ANmJTDj/JPiQcIKuYBMfIwIX9zLM0wg== - dependencies: - "@tonconnect/isomorphic-eventsource" "^0.0.2" - "@tonconnect/isomorphic-fetch" "^0.0.3" - "@tonconnect/protocol" "^2.2.6" - -"@tonconnect/ui-react@^2.0.6": - version "2.0.6" - resolved "https://registry.yarnpkg.com/@tonconnect/ui-react/-/ui-react-2.0.6.tgz#9adadda97da0c8ff2e40eee5dbaa1693aa6662b5" - integrity sha512-9VRYP2o/YW4ti+rOMSptIYaRO39V5UFmzdUl18AmDFDdynjacAIht/IInO+AGAKfrnF9bUk/J5NgLcbxVqvZww== - dependencies: - "@tonconnect/ui" "2.0.6" - -"@tonconnect/ui-react@^2.0.9": - version "2.0.9" - resolved "https://registry.yarnpkg.com/@tonconnect/ui-react/-/ui-react-2.0.9.tgz#c226b81110e05b7e259bbf965ad5da42318a5dd3" - integrity sha512-wN7tEZpQiRYSUcdNAxFsDkk5TYo8krIu00ZLE1R5kXyr+XpO120jOmTEweBSXvIzTgEVkD/PxDZbBQQxRTXsUw== - dependencies: - "@tonconnect/ui" "2.0.9" - -"@tonconnect/ui@2.0.6": - version "2.0.6" - resolved "https://registry.yarnpkg.com/@tonconnect/ui/-/ui-2.0.6.tgz#4cf092b3ff138238fa7ae7d4754d8bfed549d892" - integrity sha512-JMTSxgbnpDjpHi9g0s7w3tpAiLHa8BHUpaBrbSTDcKGQVEm7+NtqhN+gQkGkm8pV7NYRqiS/sKUpRQ1MyjtTBQ== - dependencies: - "@tonconnect/sdk" "3.0.3" - classnames "^2.3.2" - deepmerge "^4.2.2" - ua-parser-js "^1.0.35" - -"@tonconnect/ui@2.0.9": - version "2.0.9" - resolved "https://registry.yarnpkg.com/@tonconnect/ui/-/ui-2.0.9.tgz#589285c9b8f4b0d94c10b3feadfae266bf086503" - integrity sha512-ZxofTBf81NqrxyD0ybI8AuFHN11uKVg/00xTDFhP5FoPB8rYC7En9qE2VJ6IvwvtTpmh8jspi2ancOHUMBoCQA== - dependencies: - "@tonconnect/sdk" "3.0.5" - classnames "^2.3.2" - deepmerge "^4.2.2" - ua-parser-js "^1.0.35" - "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -4687,13 +4535,6 @@ resolved "https://registry.yarnpkg.com/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz#b6725d5f4af24ace33b36fafd295136e75509f43" integrity sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA== -"@types/varstruct@^6.1.3": - version "6.1.3" - resolved "https://registry.yarnpkg.com/@types/varstruct/-/varstruct-6.1.3.tgz#dad39ad875eef0a9b9d63ae4e503cc3d5c456955" - integrity sha512-LgivtaEn0RHmVk+CHnIS95CtkV0xMAT6u1hPlr6qXNmYnDUU7ZhXM5fM7/byytaqXk7fNX8B/ibN1xpxe+X+hg== - dependencies: - "@types/node" "*" - "@types/ws@8.5.9": version "8.5.9" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.9.tgz#384c489f99c83225a53f01ebc3eddf3b8e202a8c" @@ -6654,7 +6495,7 @@ cjson@^0.3.1: dependencies: json-parse-helpfulerror "^1.0.3" -classnames@*, classnames@^2.2.6, classnames@^2.3.1, classnames@^2.3.2: +classnames@*, classnames@^2.2.6, classnames@^2.3.1: version "2.5.1" resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.5.1.tgz#ba774c614be0f016da105c858e7159eae8e7687b" integrity sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow== @@ -7410,7 +7251,7 @@ data-urls@^5.0.0: whatwg-mimetype "^4.0.0" whatwg-url "^14.0.0" -dataloader@^2.0.0, dataloader@^2.2.2: +dataloader@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-2.2.2.tgz#216dc509b5abe39d43a9b9d97e6e5e473dfbe3e0" integrity sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g== @@ -7508,7 +7349,7 @@ deep-is@^0.1.3, deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -deepmerge@^4.2.2, deepmerge@^4.3.1: +deepmerge@^4.3.1: version "4.3.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== @@ -7678,7 +7519,7 @@ dot-prop@^5.2.0: dependencies: is-obj "^2.0.0" -dotenv@^16.0.0, dotenv@^16.3.1, dotenv@^16.4.5: +dotenv@^16.0.0, dotenv@^16.3.1: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== @@ -8341,11 +8182,6 @@ events@^3.0.0, events@^3.3.0: resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== -eventsource@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-2.0.2.tgz#76dfcc02930fb2ff339520b6d290da573a9e8508" - integrity sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA== - evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" @@ -9665,11 +9501,6 @@ install-artifact-from-github@^1.3.5: resolved "https://registry.yarnpkg.com/install-artifact-from-github/-/install-artifact-from-github-1.3.5.tgz#88c96fe40e5eb21d45586d564208c648a1dbf38d" integrity sha512-gZHC7f/cJgXz7MXlHFBxPVMsvIbev1OQN1uKQYKVJDydGNm9oYf9JstbU4Atnh/eSvk41WtEovoRm+8IF686xg== -int53@^0.2.4: - version "0.2.4" - resolved "https://registry.yarnpkg.com/int53/-/int53-0.2.4.tgz#5ed8d7aad6c5c6567cae69aa7ffc4a109ee80f86" - integrity sha512-a5jlKftS7HUOhkUyYD7j2sJ/ZnvWiNlZS1ldR+g1ifQ+/UuZXIE+YTc/lK1qGj/GwAU5F8Z0e1eVq2t1J5Ob2g== - "internmap@1 - 2", internmap@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/internmap/-/internmap-2.0.3.tgz#6685f23755e43c524e251d29cbc97248e3061009" @@ -10408,11 +10239,6 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" -jssha@3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/jssha/-/jssha-3.2.0.tgz#88ec50b866dd1411deaddbe6b3e3692e4c710f16" - integrity sha512-QuruyBENDWdN4tZwJbQq7/eAK85FqrI4oDbXjy5IBhYD+2pTJyBUWZe8ctWaCkrV0gy6AaelgOZZBMeswEa/6Q== - jwa@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.1.tgz#743c32985cb9e98655530d53641b66c8645b039a" @@ -13670,7 +13496,7 @@ string-env-interpolation@^1.0.1: resolved "https://registry.yarnpkg.com/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz#ad4397ae4ac53fe6c91d1402ad6f6a52862c7152" integrity sha512-78lwMoCcn0nNu8LszbP1UA7g55OeE4v7rCeWnM5B453rnNr4aq+5it3FEYtZrSEiMvHZOZ9Jlqb0OD0M2VInqg== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -13688,6 +13514,15 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" +string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -13716,7 +13551,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -13737,6 +13572,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -13877,11 +13719,6 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -symbol.inspect@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/symbol.inspect/-/symbol.inspect-1.0.1.tgz#e13125b8038c4996eb0dfa1567332ad4dcd0763f" - integrity sha512-YQSL4duoHmLhsTD1Pw8RW6TZ5MaTX5rXJnqacJottr2P2LZBF/Yvrc3ku4NUpMOm8aM0KOCqM+UAkMA5HWQCzQ== - table-layout@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-3.0.2.tgz#69c2be44388a5139b48c59cf21e73b488021769a" @@ -13934,11 +13771,6 @@ temp@^0.9.4: mkdirp "^0.5.1" rimraf "~2.6.2" -teslabot@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/teslabot/-/teslabot-1.5.0.tgz#70f544516699ca5f696d8ae94f3d12cd495d5cd6" - integrity sha512-e2MmELhCgrgZEGo7PQu/6bmYG36IDH+YrBI1iGm6jovXkeDIGa3pZ2WSqRjzkuw2vt1EqfkZoV5GpXgqL8QJVg== - test-exclude@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-7.0.1.tgz#20b3ba4906ac20994e275bbcafd68d510264c2a2" @@ -14251,16 +14083,16 @@ tweetnacl-util@^0.15.1: resolved "https://registry.yarnpkg.com/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz#b80fcdb5c97bcc508be18c44a4be50f022eea00b" integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw== -tweetnacl@1.0.3, tweetnacl@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== +tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -14612,14 +14444,6 @@ value-or-promise@^1.0.11, value-or-promise@^1.0.12: resolved "https://registry.yarnpkg.com/value-or-promise/-/value-or-promise-1.0.12.tgz#0e5abfeec70148c78460a849f6b003ea7986f15c" integrity sha512-Z6Uz+TYwEqE7ZN50gwn+1LCVo9ZVrpxRPOhOLnncYkY1ZzOYtrX8Fwf/rFktZ8R5mJms6EZf5TqNOMeZmnPq9Q== -varstruct@^6.1.3: - version "6.1.3" - resolved "https://registry.yarnpkg.com/varstruct/-/varstruct-6.1.3.tgz#45a8a073e41fb88adb10bc71158c945e20c57fbe" - integrity sha512-4l1Q7uxrVUBZXsMcb2cakrZL6gd4G+Ykn/m9cGnT4EY8iRBPkxOxKVDwOnL9AsIPKmREBx5BDqjfNMKKP6Zy2w== - dependencies: - int53 "^0.2.4" - safe-buffer "^5.1.1" - varuint-bitcoin@^1.0.4, varuint-bitcoin@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/varuint-bitcoin/-/varuint-bitcoin-1.1.2.tgz#e76c138249d06138b480d4c5b40ef53693e24e92" @@ -14933,7 +14757,7 @@ wordwrapjs@^5.1.0: resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-5.1.0.tgz#4c4d20446dcc670b14fa115ef4f8fd9947af2b3a" integrity sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -14960,6 +14784,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" @@ -15212,8 +15045,3 @@ zip-stream@^4.1.0: archiver-utils "^3.0.4" compress-commons "^4.1.2" readable-stream "^3.6.0" - -zod@^3.21.4: - version "3.23.8" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" - integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==