diff --git a/lib/components/SwapCard/CardDialog.tsx b/lib/components/SwapCard/CardDialog.tsx index a4099c5..f9beb9b 100644 --- a/lib/components/SwapCard/CardDialog.tsx +++ b/lib/components/SwapCard/CardDialog.tsx @@ -1,4 +1,4 @@ -import clsx from "clsx"; +import clsx from 'clsx'; import { CSSProperties, Dispatch, @@ -7,36 +7,36 @@ import { useEffect, useRef, useState, -} from "react"; -import { IoClose } from "react-icons/io5"; -import { MdOutlineSearch } from "react-icons/md"; -import { AnimatePresence, motion } from "framer-motion"; -import Token from "./Token"; -import InfiniteScroll from "react-infinite-scroll-component"; -import { useSwapStore } from "../../store/swap.store"; -import { Asset } from "@mytonswap/sdk"; -import sortAssets from "../../utils/sortAssets"; -import { CgSpinnerTwo } from "react-icons/cg"; -import { address } from "@ton/ton"; -import { TiWarning } from "react-icons/ti"; -import "./CardDialog.scss"; -import { useMediaQuery, useOnClickOutside } from "usehooks-ts"; -import { modalAnimationDesktop, modalAnimationMobile } from "../../constants"; -import catchError from "../../utils/catchErrors"; +} from 'react'; +import { IoClose } from 'react-icons/io5'; +import { MdOutlineSearch } from 'react-icons/md'; +import { AnimatePresence, motion } from 'framer-motion'; +import Token from './Token'; +import InfiniteScroll from 'react-infinite-scroll-component'; +import { useSwapStore } from '../../store/swap.store'; +import { Asset } from '@mytonswap/sdk'; +import sortAssets from '../../utils/sortAssets'; +import { CgSpinnerTwo } from 'react-icons/cg'; +import { address } from '@ton/ton'; +import { TiWarning } from 'react-icons/ti'; +import './CardDialog.scss'; +import { useMediaQuery, useOnClickOutside } from 'usehooks-ts'; +import { modalAnimationDesktop, modalAnimationMobile } from '../../constants'; +import catchError from '../../utils/catchErrors'; -import { reportErrorWithToast } from "../../services/errorAnalytics"; -import { useTranslation } from "react-i18next"; -import FavList from "./FavList"; +import { reportErrorWithToast } from '../../services/errorAnalytics'; +import { useTranslation } from 'react-i18next'; +import FavList from './FavList'; type CardDialogProps = { isSelectVisible: boolean; setIsSelectVisible: Dispatch>; - type: "pay" | "receive"; + type: 'pay' | 'receive'; onTokenSelect: (asset: Asset) => void; }; enum TABS { - ALL = "ALL", - FAVORITES = "FAVORITES", + ALL = 'ALL', + FAVORITES = 'FAVORITES', } const CardDialog: FC = ({ @@ -60,15 +60,15 @@ const CardDialog: FC = ({ const [activeTab, setActiveTab] = useState(TABS.ALL); const [page, setPage] = useState(1); const [hasMore, setHasMore] = useState(true); - const [searchInput, setSearchInput] = useState(""); + const [searchInput, setSearchInput] = useState(''); const [contractCommunity, setContractCommunity] = useState( null ); const [promptForCommunity, setPromptForCommunity] = useState(false); - const isDesktop = useMediaQuery("(min-width: 768px)"); + const isDesktop = useMediaQuery('(min-width: 768px)'); const ref = useRef(null); const onNextPage = async (currPage: number) => { - if (type === "pay") { + if (type === 'pay') { const result = await catchError(() => client.assets.getPaginatedAssets( currPage, @@ -79,19 +79,20 @@ const CardDialog: FC = ({ if (result.error) { reportErrorWithToast( result.error, - "Failed to fetch assets", - "CardDialog.tsx onNextPage pay :86" + 'Failed to fetch assets', + 'CardDialog.tsx onNextPage pay :86' ); return; } + console.log(result); const { assets, meta } = result.data; setPage(currPage + 1); addToAssets(assets); setHasMore(!meta.isLastPage); return; } - if (type === "receive" && !pay_token) return; - if (type === "receive") { + if (type === 'receive' && !pay_token) return; + if (type === 'receive') { const newAssets = await catchError(() => client.assets.getPairs( pay_token!.address, @@ -103,8 +104,8 @@ const CardDialog: FC = ({ if (newAssets.error) { reportErrorWithToast( newAssets.error, - "Failed to fetch assets", - "CardDialog.tsx onNextPage receive :105" + 'Failed to fetch assets', + 'CardDialog.tsx onNextPage receive :105' ); return; } @@ -130,7 +131,7 @@ const CardDialog: FC = ({ } }; useEffect(() => { - if (pay_token && type === "pay") { + if (pay_token && type === 'pay') { return; } @@ -158,7 +159,7 @@ const CardDialog: FC = ({ } }, [searchInput]); - const assetList = type === "pay" ? assets : receiveAssets; + const assetList = type === 'pay' ? assets : receiveAssets; const handleOnTokenSelect = (asset: Asset) => { if (!communityTokens && asset.warning) { @@ -168,7 +169,7 @@ const CardDialog: FC = ({ if (promptForCommunity) { setPromptForCommunity(false); } - setSearchInput(""); + setSearchInput(''); onTokenSelect(asset); setPage(1); setHasMore(true); @@ -181,8 +182,8 @@ const CardDialog: FC = ({ .sort(sortAssets) .filter((item) => { if ( - searchInput.toLowerCase() === "usdt" && - item.symbol === "USD₮" + searchInput.toLowerCase() === 'usdt' && + item.symbol === 'USD₮' ) { return true; } @@ -199,7 +200,7 @@ const CardDialog: FC = ({ const handleOnClose = () => { setIsSelectVisible(false); - setSearchInput(""); + setSearchInput(''); }; useEffect(() => { @@ -215,8 +216,8 @@ const CardDialog: FC = ({ if (assetByAddrResult.error) { reportErrorWithToast( assetByAddrResult.error, - "Failed to fetch asset", - "CardDialog.tsx getToken :197" + 'Failed to fetch asset', + 'CardDialog.tsx getToken :197' ); return; } @@ -260,20 +261,20 @@ const CardDialog: FC = ({ initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} - className={clsx("card-dialog-container")} + className={clsx('card-dialog-container')} > { e.stopPropagation(); }} >
-
{t("select_a_token")}
+
{t('select_a_token')}
} endMessage={ -
- {t("token_notfound")} - + filteredAssets.length === + 0 ? ( +
{t( - "not_found_desc" + 'token_notfound' )} - -
+ + {t( + 'not_found_desc' + )} + +
+ ) : ( +
+ {t( + 'no_more_tokens' + )} +
+ ) } > {filteredAssets?.map((item) => ( @@ -430,12 +445,12 @@ const CardDialog: FC = ({

{t( - "trade_warning.trade_title" + 'trade_warning.trade_title' )}

{t( - "trade_warning.trade_description" + 'trade_warning.trade_description' )}

@@ -463,7 +478,7 @@ const CardDialog: FC = ({ ); }} > - {t("trade_warning.agree")} + {t('trade_warning.agree')} )} diff --git a/lib/components/SwapDetails/SwapDetails.tsx b/lib/components/SwapDetails/SwapDetails.tsx index 3d3ccfa..6e25f22 100644 --- a/lib/components/SwapDetails/SwapDetails.tsx +++ b/lib/components/SwapDetails/SwapDetails.tsx @@ -110,17 +110,15 @@ const SwapDetails = () => { background: `url(${ bestRoute .selected_pool - .dex === - 'dedust' - ? 'https://dedust.io/favicon-32x32.png' - : 'https://ston.fi/images/tild3432-3236-4431-b139-376231383134__favicon.svg' + .dex_details + .icon_url })`, }} > - {bestRoute.selected_pool.dex === - 'dedust' - ? 'Dedust' - : 'Ston.fi'} + { + bestRoute.selected_pool + .dex_details.name + } ((set, get) => ({ client: new MyTonSwapClient({ + baseUrl: 'https://devtest.mytonswap.com/api/', headers: { 'widget-version': WIDGET_VERSION }, }), refetchInterval: null, diff --git a/lib/store/wallet.store.ts b/lib/store/wallet.store.ts index abdf490..b64532d 100644 --- a/lib/store/wallet.store.ts +++ b/lib/store/wallet.store.ts @@ -1,10 +1,10 @@ -import { create } from "zustand"; -import { Balance, MyTonSwapClient } from "@mytonswap/sdk"; -import { Wallet } from "@tonconnect/ui-react"; -import { useSwapStore } from "./swap.store"; -import catchError from "../utils/catchErrors"; -import { WIDGET_VERSION } from "../constants"; -import { reportErrorWithToast } from "../services/errorAnalytics"; +import { create } from 'zustand'; +import { Balance, MyTonSwapClient } from '@mytonswap/sdk'; +import { Wallet } from '@tonconnect/ui-react'; +import { useSwapStore } from './swap.store'; +import catchError from '../utils/catchErrors'; +import { WIDGET_VERSION } from '../constants'; +import { reportErrorWithToast } from '../services/errorAnalytics'; type WalletStates = { client: MyTonSwapClient; wallet: Wallet | null; @@ -21,7 +21,8 @@ type WalletActions = { export const useWalletStore = create( (set, get) => ({ client: new MyTonSwapClient({ - headers: { "widget-version": WIDGET_VERSION }, + headers: { 'widget-version': WIDGET_VERSION }, + baseUrl: 'https://devtest.mytonswap.com/api/', }), wallet: null, walletConnected: false, @@ -45,8 +46,8 @@ export const useWalletStore = create( if (balancesResult.error) { reportErrorWithToast( balancesResult.error, - "Failed to fetch balances", - "wallet.store.ts setWallet getWalletAssets :45" + 'Failed to fetch balances', + 'wallet.store.ts setWallet getWalletAssets :45' ); return; } @@ -59,8 +60,8 @@ export const useWalletStore = create( if (assetsResult.error) { reportErrorWithToast( assetsResult.error, - "Failed to fetch assets", - "wallet.store.ts setWallet getAssets :59" + 'Failed to fetch assets', + 'wallet.store.ts setWallet getAssets :59' ); return; } @@ -81,8 +82,8 @@ export const useWalletStore = create( if (balancesResult.error) { reportErrorWithToast( balancesResult.error, - "Failed to fetch balances", - "wallet.store.ts refetch getWalletAssets :81" + 'Failed to fetch balances', + 'wallet.store.ts refetch getWalletAssets :81' ); return; } diff --git a/lib/utils/swap.ts b/lib/utils/swap.ts index 0c60de0..ade2bdb 100644 --- a/lib/utils/swap.ts +++ b/lib/utils/swap.ts @@ -19,6 +19,7 @@ export default async function swap( ) { const client = new MyTonSwapClient({ headers: { 'widget-version': WIDGET_VERSION }, + baseUrl: 'https://devtest.mytonswap.com/api/', }); const app_id = useOptionsStore.getState().options.app_id; const rawMessageResult = await catchError(() => diff --git a/package.json b/package.json index 650a7ec..a0a1e0e 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ ] }, "dependencies": { - "@mytonswap/sdk": "^1.1.0", + "@mytonswap/sdk": "^1.1.2", "@r2wc/react-to-web-component": "^2.0.3", "@sentry/react": "^8.42.0", "@sentry/vite-plugin": "^2.22.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ea5620..f00ca4f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@mytonswap/sdk': - specifier: ^1.1.0 - version: 1.1.0(@ton/core@0.59.0(@ton/crypto@3.3.0))(@ton/crypto@3.3.0)(typescript@5.6.2) + specifier: ^1.1.2 + version: 1.1.2(@ton/core@0.59.0(@ton/crypto@3.3.0))(@ton/crypto@3.3.0)(typescript@5.6.2) '@r2wc/react-to-web-component': specifier: ^2.0.3 version: 2.0.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -685,9 +685,6 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@lifeomic/attempt@3.1.0': - resolution: {integrity: sha512-QZqem4QuAnAyzfz+Gj5/+SLxqwCAw2qmt7732ZXodr6VDWGeYLG6w1i/vYLa55JQM9wRuBKLmXmiZ2P0LtE5rw==} - '@mdx-js/react@3.0.1': resolution: {integrity: sha512-9ZrPIU4MGf6et1m1ov3zKf+q9+deetI51zprKB1D/z3NOb+rUxxtEl3mCjW5wTGh6VhRdwPueh1oRzi6ezkA8A==} peerDependencies: @@ -707,8 +704,8 @@ packages: '@microsoft/tsdoc@0.15.0': resolution: {integrity: sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==} - '@mytonswap/sdk@1.1.0': - resolution: {integrity: sha512-3GQ0Yo0cgtDdXaY6wYV3kyqtjIoAPmQnbd7eyNliXnabM9aG6iRgAHMcVpVPS4YsAX7gF+umQTPxSbpNtB/PpA==} + '@mytonswap/sdk@1.1.2': + resolution: {integrity: sha512-MKIi8jCiyWb74v8VsHi14x2vk8IZY1IgwN8cKv03DodqZdE4IoxXMBf8NLZRC0hv2q16p+CDrjU1OcE4YIgwgg==} peerDependencies: typescript: ^5.0.0 @@ -4818,8 +4815,6 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@lifeomic/attempt@3.1.0': {} - '@mdx-js/react@3.0.1(@types/react@18.3.11)(react@18.3.1)': dependencies: '@types/mdx': 2.0.13 @@ -4861,11 +4856,11 @@ snapshots: '@microsoft/tsdoc@0.15.0': {} - '@mytonswap/sdk@1.1.0(@ton/core@0.59.0(@ton/crypto@3.3.0))(@ton/crypto@3.3.0)(typescript@5.6.2)': + '@mytonswap/sdk@1.1.2(@ton/core@0.59.0(@ton/crypto@3.3.0))(@ton/crypto@3.3.0)(typescript@5.6.2)': dependencies: - '@lifeomic/attempt': 3.1.0 '@ton/ton': 15.1.0(@ton/core@0.59.0(@ton/crypto@3.3.0))(@ton/crypto@3.3.0) axios: 1.7.7 + axios-retry: 4.5.0(axios@1.7.7) lodash: 4.17.21 typescript: 5.6.2 transitivePeerDependencies: