From a1d8aafad89bc9492cba36967a1dd143e2a92a1f Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 13 Jul 2023 16:32:20 +0700 Subject: [PATCH 01/20] docs url --- src/pages/NotificationCenter/Profile/WarningSignMessage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/NotificationCenter/Profile/WarningSignMessage.tsx b/src/pages/NotificationCenter/Profile/WarningSignMessage.tsx index 02983da9cb..189673d167 100644 --- a/src/pages/NotificationCenter/Profile/WarningSignMessage.tsx +++ b/src/pages/NotificationCenter/Profile/WarningSignMessage.tsx @@ -27,7 +27,7 @@ const WarningWrapper = styled.div` padding: 12px 14px; `} ` -const DOC_URL = 'https://docs.kyberswap.com/kyberswap-solutions/kyberswap-interface/profiles/profile-customization' +const DOC_URL = 'https://docs.kyberswap.com/kyberswap-solutions/kyberswap-interface/profiles' const WarningSignMessage = () => { const { signIn } = useLogin() const { pendingAuthentication } = useSessionInfo() From 0a8ff6b82a1e8b64084bfc0d49cc4ae799bf33b6 Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 13 Jul 2023 17:09:53 +0700 Subject: [PATCH 02/20] refresh list noti when change profike --- src/components/Announcement/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Announcement/index.tsx b/src/components/Announcement/index.tsx index 6ca21f5c0d..af93fc0ec9 100644 --- a/src/components/Announcement/index.tsx +++ b/src/components/Announcement/index.tsx @@ -143,9 +143,9 @@ export default function AnnouncementComponent() { numberOfUnread, pagination: { totalItems: totalPrivateAnnouncement }, } = isError ? responseDefault : respPrivateAnnouncement - const refreshAnnouncement = () => { + const refreshAnnouncement = useCallback(() => { fetchAnnouncementsByTab(true) - } + }, [fetchAnnouncementsByTab]) const loadMoreAnnouncements = useCallback(() => { fetchAnnouncementsByTab() @@ -226,8 +226,9 @@ export default function AnnouncementComponent() { useEffect(() => { if (userInfo?.identityId) { invalidateTag(ANNOUNCEMENT_TAGS) + refreshAnnouncement() } - }, [userInfo?.identityId, invalidateTag]) + }, [userInfo?.identityId, invalidateTag, refreshAnnouncement]) useInterval(prefetchPrivateAnnouncements, 10_000) From d4a9f1e60b45a7bc87d615937d80ede74977b3bc Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 13 Jul 2023 17:56:58 +0700 Subject: [PATCH 03/20] add threast hold token search --- src/components/SearchModal/CurrencyList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SearchModal/CurrencyList.tsx b/src/components/SearchModal/CurrencyList.tsx index f6a55b37f2..43e39fdadf 100644 --- a/src/components/SearchModal/CurrencyList.tsx +++ b/src/components/SearchModal/CurrencyList.tsx @@ -304,7 +304,7 @@ function CurrencyList({
{({ height, width }) => ( - + {({ onItemsRendered, ref }) => ( Date: Thu, 13 Jul 2023 18:04:41 +0700 Subject: [PATCH 04/20] fix: loading. for ever --- .../NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx index 7b55a82e86..28f55b9fef 100644 --- a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx +++ b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx @@ -17,7 +17,7 @@ import SingleAlert from './SingleAlert' const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolean) => void }) => { const { userInfo } = useSessionInfo() const [page, setPage] = useState(1) - const { data, isLoading, refetch } = useGetListAlertsQuery({ + const { data, isFetching, refetch } = useGetListAlertsQuery({ page, pageSize: ITEMS_PER_PAGE, sort: 'is_enabled:desc,created_at:desc', @@ -51,8 +51,8 @@ const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolea const totalAlert = data?.alerts?.length ?? 0 - if (!totalAlert || isLoading) { - return + if (!totalAlert || isFetching) { + return } return ( From 1e5d0ef81e317a3f6de061634d7ce52ccbc8a53c Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 13 Jul 2023 18:17:29 +0700 Subject: [PATCH 05/20] add log --- src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx index 28f55b9fef..c438d7bc6f 100644 --- a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx +++ b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx @@ -50,6 +50,7 @@ const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolea }, [userInfo?.identityId, refetch, refetchStat]) const totalAlert = data?.alerts?.length ?? 0 + console.log({ isFetching }) if (!totalAlert || isFetching) { return From f50a353f7871b51161954016c74c8275f740b838 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 09:48:57 +0700 Subject: [PATCH 06/20] STG --- .env.adpr | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/.env.adpr b/.env.adpr index 74879a263b..326145bd06 100644 --- a/.env.adpr +++ b/.env.adpr @@ -1,46 +1,43 @@ -VITE_DEFAULT_AGGREGATOR_API=https://meta-aggregator.dev.kyberengineering.io -VITE_AGGREGATOR_API=https://aggregator-api.dev.kyberengineering.io -VITE_AGGREGATOR_STATS_API=https://aggregator-stats.dev.kyberengineering.io +VITE_DEFAULT_AGGREGATOR_API=https://meta-aggregator.stg.kyberengineering.io +VITE_AGGREGATOR_API=https://aggregator-api.stg.kyberengineering.io +VITE_AGGREGATOR_STATS_API=https://aggregator-stats.kyberswap.com VITE_SENTRY_DNS=https://d94ee2d3c22043bdaec966758680b5a8@sentry.ops.kyberengineering.io/4 -VITE_SERVICE_WORKER=true +VITE_SERVICE_WORKER=false +VITE_MIXPANEL_PROJECT_TOKEN=ff1eea26c19dcf4a7c35ebbc8631e714 +VITE_REWARD_SERVICE_API=https://reward.stg.kyberengineering.io/api/v1 -VITE_MIXPANEL_PROJECT_TOKEN=fca28a30cb98d872c2079f214955cd5e -VITE_REWARD_SERVICE_API=https://reward.dev.kyberengineering.io/api/v1 +VITE_PRICE_CHART_API=https://price-chart.kyberswap.com/api +VITE_PRICE_API=https://price.stg.kyberengineering.io -VITE_PRICE_CHART_API=https://price-chart.dev.kyberengineering.io/api -VITE_PRICE_API=https://price.dev.kyberengineering.io +VITE_NOTIFICATION_API=https://notification.stg.kyberengineering.io/api -VITE_NOTIFICATION_API=https://notification.dev.kyberengineering.io/api - -VITE_CAMPAIGN_BASE_URL=https://campaigns.dev.kyberengineering.io -VITE_TYPE_AND_SWAP_URL=https://type-swap.dev.kyberengineering.io/api +VITE_CAMPAIGN_BASE_URL=https://campaigns.stg.kyberengineering.io +VITE_TYPE_AND_SWAP_URL=https://type-swap.stg.kyberengineering.io/api VITE_TRANSAK_URL=https://staging-global.transak.com VITE_TRANSAK_API_KEY=327b8b63-626b-4376-baf2-70a304c48488 -VITE_KS_SETTING_API=https://ks-setting.dev.kyberengineering.io/api +VITE_KS_SETTING_API=https://ks-setting.stg.kyberengineering.io/api VITE_GTM_ID= VITE_GOOGLE_RECAPTCHA_KEY=6Lc7yg0iAAAAALhS4C4Ez5hqMBub8hKdFvvr9sfc -VITE_POOL_FARM_BASE_URL=https://pool-farm.dev.kyberengineering.io +VITE_POOL_FARM_BASE_URL=https://pool-farm.kyberswap.com -VITE_LIMIT_ORDER_API_WRITE=https://limit-order.dev.kyberengineering.io/write/api -VITE_LIMIT_ORDER_API_READ=https://limit-order.dev.kyberengineering.io/read-ks/api +VITE_LIMIT_ORDER_API_WRITE=https://limit-order.stg.kyberengineering.io/write/api +VITE_LIMIT_ORDER_API_READ=https://limit-order.stg.kyberengineering.io/read-ks/api VITE_BLOCK_SERVICE_API=https://block.kyberswap.com # Kyber DAO Apis -VITE_KYBER_DAO_STATS_API=https://kyberswap-dao-stats.dev.kyberengineering.io - +VITE_KYBER_DAO_STATS_API=https://kyberswap-dao-stats.stg.kyberengineering.io # oauth -VITE_ENV=development -VITE_OAUTH_CLIENT_ID=a2f76ad4-895f-401a-ba75-952a929d782c - -VITE_BFF_API=https://kyberswap-bff.dev.kyberengineering.io/api +VITE_ENV=staging +VITE_OAUTH_CLIENT_ID=bce9bf52-b788-4c25-9c6c-a07dff080403 VITE_KYBER_AI_REFERRAL_ID=1 -VITE_KYBER_AI_TOPIC_ID=14 -VITE_PRICE_ALERT_TOPIC_ID=13 -VITE_ELASTIC_POOL_TOPIC_ID=12 -VITE_BUCKET_NAME=ks-setting-a3aa20b7 +VITE_KYBER_AI_TOPIC_ID=11 +VITE_PRICE_ALERT_TOPIC_ID=9 +VITE_ELASTIC_POOL_TOPIC_ID=4,5 +VITE_BFF_API=https://kyberswap-bff.stg.kyberengineering.io/api +VITE_BUCKET_NAME=ks-setting-6d114fd1 VITE_WALLETCONNECT_PROJECT_ID=f218207428d6efc3863adab795a9f123 From cf9b9dbbb6c84236ff24e07ce1db57a2686c90d0 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 10:02:26 +0700 Subject: [PATCH 07/20] test --- .../NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx index c438d7bc6f..fff53a0b29 100644 --- a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx +++ b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx @@ -17,7 +17,7 @@ import SingleAlert from './SingleAlert' const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolean) => void }) => { const { userInfo } = useSessionInfo() const [page, setPage] = useState(1) - const { data, isFetching, refetch } = useGetListAlertsQuery({ + const { data, isFetching, isLoading, refetch } = useGetListAlertsQuery({ page, pageSize: ITEMS_PER_PAGE, sort: 'is_enabled:desc,created_at:desc', @@ -50,7 +50,7 @@ const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolea }, [userInfo?.identityId, refetch, refetchStat]) const totalAlert = data?.alerts?.length ?? 0 - console.log({ isFetching }) + console.log({ isFetching, data, isLoading }) if (!totalAlert || isFetching) { return From 7ecf93b2d9e9893c8162714827640491b59847ff Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 10:40:14 +0700 Subject: [PATCH 08/20] fix wrong address sign in --- src/hooks/useLogin.tsx | 24 +++++++++++++++--------- src/hooks/useSessionExpire.ts | 6 +++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/hooks/useLogin.tsx b/src/hooks/useLogin.tsx index 2bf245999f..b3c94ce5bf 100644 --- a/src/hooks/useLogin.tsx +++ b/src/hooks/useLogin.tsx @@ -165,6 +165,16 @@ const useLogin = (autoLogin = false) => { [setLoading, signInAnonymous, getProfile, saveSignedAccount, showSignInSuccess], ) + const redirectSignIn = useCallback( + (account: string) => { + setLoginRedirectUrl(window.location.href) + setTimeout(() => { + KyberOauth2.authenticate(isEVM ? { wallet_address: account } : {}) // navigate to login page + }, 1000) + }, + [isEVM, setLoginRedirectUrl], + ) + // check account info and redirect if needed const [, setAutoSignIn] = useIsAutoLoginAfterConnectWallet() const signIn = useCallback( @@ -186,26 +196,21 @@ const useLogin = (autoLogin = false) => { return } - const redirectSignIn = () => { - setLoginRedirectUrl(window.location.href) - setTimeout(() => { - KyberOauth2.authenticate(isEVM ? { wallet_address: desireAccount || account || '' } : {}) // navigate to login page - }, 1000) - } + const formatAccount = desireAccount || account || '' if (showSessionExpired && isSelectAccount && !isTokenExist) { showConfirm({ isOpen: true, content: t`Your session has expired. Please sign-in to continue.`, title: t`Session Expired`, confirmText: t`Sign-in`, - onConfirm: () => redirectSignIn(), + onConfirm: () => redirectSignIn(formatAccount), cancelText: t`Cancel`, }) return } - redirectSignIn() + redirectSignIn(formatAccount) }, - [account, isEVM, checkSessionSignIn, toggleWalletModal, showConfirm, setLoginRedirectUrl, setAutoSignIn], + [account, checkSessionSignIn, toggleWalletModal, showConfirm, setAutoSignIn, redirectSignIn], ) const showSignOutSuccess = useCallback(() => { @@ -307,6 +312,7 @@ const useLogin = (autoLogin = false) => { return { signOut: signOutWrapped, signIn: signInWrapped, + redirectSignIn, signOutAll, importGuestAccount, checkSessionSignIn, diff --git a/src/hooks/useSessionExpire.ts b/src/hooks/useSessionExpire.ts index 3f6bbb3d81..63f7ec24ea 100644 --- a/src/hooks/useSessionExpire.ts +++ b/src/hooks/useSessionExpire.ts @@ -12,7 +12,7 @@ import { useSignedAccountInfo } from 'state/profile/hooks' export default function useSessionExpiredGlobal() { const { pathname } = useLocation() const showConfirm = useShowConfirm() - const { signIn } = useLogin() + const { signIn, redirectSignIn } = useLogin() const navigate = useNavigate() const { signedAccount, signedMethod } = useSignedAccountInfo() @@ -25,7 +25,7 @@ export default function useSessionExpiredGlobal() { title: t`Session Expired`, confirmText: t`Sign-in`, cancelText: t`Cancel`, - onConfirm: () => signIn(), + onConfirm: () => redirectSignIn(accountId || signedAccount), } const isKyberAIPage = pathname.toLowerCase().startsWith(APP_PATHS.KYBERAI.toLowerCase()) && @@ -38,7 +38,7 @@ export default function useSessionExpiredGlobal() { } KyberOauth2.on(KyberOauth2Event.SESSION_EXPIRED, listener) return () => KyberOauth2.off(KyberOauth2Event.SESSION_EXPIRED, listener) - }, [pathname, showConfirm, signIn, navigate, signedAccount]) + }, [pathname, showConfirm, redirectSignIn, navigate, signedAccount]) useEffect(() => { const listener = () => { From 0546640d0ef8efeb1f34585bfb607db14500df16 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 11:32:28 +0700 Subject: [PATCH 09/20] fix infinite loading price alert --- .../PriceAlerts/ActiveAlerts/index.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx index fff53a0b29..17c0309009 100644 --- a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx +++ b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx @@ -1,11 +1,9 @@ import { t } from '@lingui/macro' import { useEffect, useState } from 'react' import { Flex } from 'rebass' -import priceAlertApi, { useGetAlertStatsQuery, useGetListAlertsQuery } from 'services/priceAlert' +import { useGetAlertStatsQuery, useGetListAlertsQuery } from 'services/priceAlert' -import { useInvalidateTags } from 'components/Announcement/helper' import { PrivateAnnouncementType } from 'components/Announcement/type' -import { RTK_QUERY_TAGS } from 'constants/index' import NoData from 'pages/NotificationCenter/NoData' import CommonPagination from 'pages/NotificationCenter/PriceAlerts/CommonPagination' import { ITEMS_PER_PAGE } from 'pages/NotificationCenter/const' @@ -25,12 +23,12 @@ const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolea const { data: alertStat, refetch: refetchStat } = useGetAlertStatsQuery() const isMaxQuotaActiveAlert = alertStat ? alertStat.totalActiveAlerts >= alertStat.maxActiveAlerts : false - const invalidateTag = useInvalidateTags(priceAlertApi.reducerPath) useEffect(() => { - if (userInfo?.identityId) { - invalidateTag([RTK_QUERY_TAGS.GET_ALERTS, RTK_QUERY_TAGS.GET_ALERTS_STAT]) - } - }, [userInfo?.identityId, invalidateTag]) + try { + refetch() + refetchStat() + } catch (error) {} + }, [userInfo?.identityId, refetch, refetchStat]) useEffect(() => { setDisabledClearAll(!data?.alerts?.length) From 5006057222bbf8bcdeb7e73d6700cbf27f037f1e Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 11:42:04 +0700 Subject: [PATCH 10/20] rm log --- .../PriceAlerts/ActiveAlerts/index.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx index 17c0309009..96f4076927 100644 --- a/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx +++ b/src/pages/NotificationCenter/PriceAlerts/ActiveAlerts/index.tsx @@ -4,6 +4,7 @@ import { Flex } from 'rebass' import { useGetAlertStatsQuery, useGetListAlertsQuery } from 'services/priceAlert' import { PrivateAnnouncementType } from 'components/Announcement/type' +import useDebounce from 'hooks/useDebounce' import NoData from 'pages/NotificationCenter/NoData' import CommonPagination from 'pages/NotificationCenter/PriceAlerts/CommonPagination' import { ITEMS_PER_PAGE } from 'pages/NotificationCenter/const' @@ -15,11 +16,12 @@ import SingleAlert from './SingleAlert' const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolean) => void }) => { const { userInfo } = useSessionInfo() const [page, setPage] = useState(1) - const { data, isFetching, isLoading, refetch } = useGetListAlertsQuery({ + const { data, isFetching, refetch } = useGetListAlertsQuery({ page, pageSize: ITEMS_PER_PAGE, sort: 'is_enabled:desc,created_at:desc', }) + const isLoading = useDebounce(isFetching, 300) const { data: alertStat, refetch: refetchStat } = useGetAlertStatsQuery() const isMaxQuotaActiveAlert = alertStat ? alertStat.totalActiveAlerts >= alertStat.maxActiveAlerts : false @@ -48,10 +50,9 @@ const ActiveAlerts = ({ setDisabledClearAll }: { setDisabledClearAll: (v: boolea }, [userInfo?.identityId, refetch, refetchStat]) const totalAlert = data?.alerts?.length ?? 0 - console.log({ isFetching, data, isLoading }) - if (!totalAlert || isFetching) { - return + if (!totalAlert || isLoading) { + return } return ( From 3c092ee2d7cd24bb402c09cb2ba3f792becbb39d Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 17:04:52 +0700 Subject: [PATCH 11/20] fix crosschain too long --- src/pages/Bridge/ComfirmBridgeModal.tsx | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/pages/Bridge/ComfirmBridgeModal.tsx b/src/pages/Bridge/ComfirmBridgeModal.tsx index 8260098b24..5d18de085c 100644 --- a/src/pages/Bridge/ComfirmBridgeModal.tsx +++ b/src/pages/Bridge/ComfirmBridgeModal.tsx @@ -426,16 +426,26 @@ export const ConfirmCrossChainModal = memo(function ConfirmCrossChainModal({ outputAmount && currencyIn && currencyOut && ( - - -   - {uint256ToFraction(inputAmount, currencyIn?.decimals).toSignificant(RESERVE_USD_DECIMALS)} - {currencyIn?.symbol} + + + +   + {uint256ToFraction(inputAmount, currencyIn?.decimals).toSignificant(RESERVE_USD_DECIMALS)} + {currencyIn?.symbol} + + - -   - {uint256ToFraction(outputAmount, currencyOut?.decimals).toSignificant(RESERVE_USD_DECIMALS)} - {currencyOut?.symbol} + + + +   + {uint256ToFraction(outputAmount, currencyOut?.decimals).toSignificant(RESERVE_USD_DECIMALS)} + {currencyOut?.symbol} + ) } From 1a3918b8d0673aee24da5068efaaf04f36e50fde Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 14 Jul 2023 17:37:53 +0700 Subject: [PATCH 12/20] fix ux session expired --- src/components/Header/web3/SignWallet/ProfileContent.tsx | 7 ++++++- src/hooks/useSessionExpire.ts | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/Header/web3/SignWallet/ProfileContent.tsx b/src/components/Header/web3/SignWallet/ProfileContent.tsx index 20824faf12..5514030ad2 100644 --- a/src/components/Header/web3/SignWallet/ProfileContent.tsx +++ b/src/components/Header/web3/SignWallet/ProfileContent.tsx @@ -226,7 +226,12 @@ const ProfileContent = ({ scroll, toggleModal }: { scroll?: boolean; toggleModal 1}> {!KyberOauth2.getConnectedAccounts().includes(account?.toLowerCase() ?? '') && isEVM && ( - signIn()}> + { + toggleModal() + signIn() + }} + > Add Account )} diff --git a/src/hooks/useSessionExpire.ts b/src/hooks/useSessionExpire.ts index 63f7ec24ea..82e8faa1c9 100644 --- a/src/hooks/useSessionExpire.ts +++ b/src/hooks/useSessionExpire.ts @@ -12,7 +12,7 @@ import { useSignedAccountInfo } from 'state/profile/hooks' export default function useSessionExpiredGlobal() { const { pathname } = useLocation() const showConfirm = useShowConfirm() - const { signIn, redirectSignIn } = useLogin() + const { signIn, redirectSignIn, signInAnonymous } = useLogin() const navigate = useNavigate() const { signedAccount, signedMethod } = useSignedAccountInfo() @@ -26,6 +26,9 @@ export default function useSessionExpiredGlobal() { confirmText: t`Sign-in`, cancelText: t`Cancel`, onConfirm: () => redirectSignIn(accountId || signedAccount), + onCancel: () => { + signInAnonymous(KyberOauth2.getConnectedAnonymousAccounts()[0]) + }, } const isKyberAIPage = pathname.toLowerCase().startsWith(APP_PATHS.KYBERAI.toLowerCase()) && @@ -38,7 +41,7 @@ export default function useSessionExpiredGlobal() { } KyberOauth2.on(KyberOauth2Event.SESSION_EXPIRED, listener) return () => KyberOauth2.off(KyberOauth2Event.SESSION_EXPIRED, listener) - }, [pathname, showConfirm, redirectSignIn, navigate, signedAccount]) + }, [pathname, showConfirm, redirectSignIn, navigate, signedAccount, signInAnonymous]) useEffect(() => { const listener = () => { From 39607b0413cc567b93b70b39fba847bc9e339cc6 Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 09:50:55 +0700 Subject: [PATCH 13/20] add space --- src/components/Header/index.tsx | 4 ++-- src/components/Header/web3/SelectWallet.tsx | 7 +++---- src/components/swapv2/LimitOrder/LimitOrderForm.tsx | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 93de1f68ff..bad526a90b 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -180,7 +180,7 @@ export default function Header() { const [holidayMode] = useHolidayMode() const theme = useTheme() const { mixpanelHandler } = useMixpanel() - const uptoSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToSmall}px)`) + const upToExtraSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToExtraSmall}px)`) const menu = ( @@ -228,7 +228,7 @@ export default function Header() { - {uptoSmall ? ( + {upToExtraSmall ? ( diff --git a/src/components/Header/web3/SelectWallet.tsx b/src/components/Header/web3/SelectWallet.tsx index ed7a83626f..02757c52c5 100644 --- a/src/components/Header/web3/SelectWallet.tsx +++ b/src/components/Header/web3/SelectWallet.tsx @@ -163,9 +163,8 @@ function Web3StatusInner() { text={ - You are not signed in with this wallet address. If you wish, you can - { e.stopPropagation() @@ -173,7 +172,7 @@ function Web3StatusInner() { }} > sign-in - + {' '} to link your wallet to a profile. This will allow us to offer you a better experience diff --git a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx index 222ef5dc08..7e08da9da1 100644 --- a/src/components/swapv2/LimitOrder/LimitOrderForm.tsx +++ b/src/components/swapv2/LimitOrder/LimitOrderForm.tsx @@ -653,7 +653,7 @@ const LimitOrderForm = function LimitOrderForm({ messages.push( - Your order may only be filled when market price of {currencyIn?.symbol} to {currencyOut?.symbol} is < + Your order may only be filled when market price of {currencyIn?.symbol} to {currencyOut?.symbol} is <{' '} {formattedNum(String(tradeInfo?.marketRate), true)}, as estimated gas fee to fill your order is ~${removeTrailingZero(tradeInfo?.gasFee?.toPrecision(6) ?? '0')}. From b1e10274a144959717901be0c9625e81c788266c Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 09:58:14 +0700 Subject: [PATCH 14/20] check wallet kyberai --- src/state/user/hooks.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index 39227c98bf..ff1dac0025 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -524,12 +524,14 @@ export const useIsWhiteListKyberAI = () => { const loadingDebounced = useDebounce(isLoading, 500) || connectingWallet const participantInfo = isError || loadingDebounced || !account ? participantDefault : rawData - + // isWhitelist, isWaitList check account is hotfix for now, will remove utils backend fixed bug return { loading: loadingDebounced, isWhiteList: - isLogin && (participantInfo?.status === ParticipantStatus.WHITELISTED || userInfo?.data?.hasAccessToKyberAI), - isWaitList: isLogin && participantInfo?.status === ParticipantStatus.WAITLISTED, + !!account && + isLogin && + (participantInfo?.status === ParticipantStatus.WHITELISTED || userInfo?.data?.hasAccessToKyberAI), + isWaitList: !!account && isLogin && participantInfo?.status === ParticipantStatus.WAITLISTED, refetch, } } From 0ee992ee1f1abbd7a38ffaa232735030bc0f3525 Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 10:19:56 +0700 Subject: [PATCH 15/20] add err desc --- src/utils/iamError.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/iamError.ts b/src/utils/iamError.ts index 5eab6bd7be..7160927d74 100644 --- a/src/utils/iamError.ts +++ b/src/utils/iamError.ts @@ -47,6 +47,8 @@ export const checkIamDown = (axiosErr: AxiosError) => { }, response, statusCode, + message: axiosErr?.message, + code: axiosErr?.code, } const apiUrl = axiosErr?.config?.url ?? '' From 9b802e2c085cefcd4d5ae57cc19ac309ba94f655 Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 12:59:51 +0700 Subject: [PATCH 16/20] black list bff --- src/utils/iamError.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/iamError.ts b/src/utils/iamError.ts index 7160927d74..e00f46b848 100644 --- a/src/utils/iamError.ts +++ b/src/utils/iamError.ts @@ -23,6 +23,9 @@ const sendError = (name: string, apiUrl: string, trackData: any) => { captureException(error, { level: 'fatal', extra: { args: JSON.stringify(trackData, null, 2) } }) } +// hot fix to prevent spam for now. +const blacklistPathBff = ['/v1/notification/me'] + /** * check error status: blocked, maybe cors issues or server down * only check bff api + 2 route apis @@ -55,7 +58,7 @@ export const checkIamDown = (axiosErr: AxiosError) => { const isRouteApiDie = isDie && (apiUrl.endsWith(AGGREGATOR_API_PATHS.GET_ROUTE) || apiUrl.endsWith(AGGREGATOR_API_PATHS.BUILD_ROUTE)) - const isIamDie = isDie && apiUrl.startsWith(BFF_API) + const isIamDie = isDie && apiUrl.startsWith(BFF_API) && !blacklistPathBff.some(path => apiUrl.endsWith(path)) if (isRouteApiDie) { ErrorInfo.routeApiError++ From 14946a586d979efbb031e03febbac2ce6e0d546f Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 13:02:51 +0700 Subject: [PATCH 17/20] css --- src/components/Menu/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index e61f75815b..c105986bf1 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -102,6 +102,7 @@ const NavLinkBetween = styled(MenuItem)` justify-content: space-between; position: unset !important; max-height: 40px; + cursor: pointer; svg { margin: 0; width: unset; From 1fff74fd50d3e4c4f7ea86f9648c9f183805f95f Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 14:36:07 +0700 Subject: [PATCH 18/20] env dev --- .env.adpr | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/.env.adpr b/.env.adpr index 326145bd06..74879a263b 100644 --- a/.env.adpr +++ b/.env.adpr @@ -1,43 +1,46 @@ -VITE_DEFAULT_AGGREGATOR_API=https://meta-aggregator.stg.kyberengineering.io -VITE_AGGREGATOR_API=https://aggregator-api.stg.kyberengineering.io -VITE_AGGREGATOR_STATS_API=https://aggregator-stats.kyberswap.com +VITE_DEFAULT_AGGREGATOR_API=https://meta-aggregator.dev.kyberengineering.io +VITE_AGGREGATOR_API=https://aggregator-api.dev.kyberengineering.io +VITE_AGGREGATOR_STATS_API=https://aggregator-stats.dev.kyberengineering.io VITE_SENTRY_DNS=https://d94ee2d3c22043bdaec966758680b5a8@sentry.ops.kyberengineering.io/4 -VITE_SERVICE_WORKER=false -VITE_MIXPANEL_PROJECT_TOKEN=ff1eea26c19dcf4a7c35ebbc8631e714 -VITE_REWARD_SERVICE_API=https://reward.stg.kyberengineering.io/api/v1 +VITE_SERVICE_WORKER=true -VITE_PRICE_CHART_API=https://price-chart.kyberswap.com/api -VITE_PRICE_API=https://price.stg.kyberengineering.io +VITE_MIXPANEL_PROJECT_TOKEN=fca28a30cb98d872c2079f214955cd5e +VITE_REWARD_SERVICE_API=https://reward.dev.kyberengineering.io/api/v1 -VITE_NOTIFICATION_API=https://notification.stg.kyberengineering.io/api +VITE_PRICE_CHART_API=https://price-chart.dev.kyberengineering.io/api +VITE_PRICE_API=https://price.dev.kyberengineering.io -VITE_CAMPAIGN_BASE_URL=https://campaigns.stg.kyberengineering.io -VITE_TYPE_AND_SWAP_URL=https://type-swap.stg.kyberengineering.io/api +VITE_NOTIFICATION_API=https://notification.dev.kyberengineering.io/api + +VITE_CAMPAIGN_BASE_URL=https://campaigns.dev.kyberengineering.io +VITE_TYPE_AND_SWAP_URL=https://type-swap.dev.kyberengineering.io/api VITE_TRANSAK_URL=https://staging-global.transak.com VITE_TRANSAK_API_KEY=327b8b63-626b-4376-baf2-70a304c48488 -VITE_KS_SETTING_API=https://ks-setting.stg.kyberengineering.io/api +VITE_KS_SETTING_API=https://ks-setting.dev.kyberengineering.io/api VITE_GTM_ID= VITE_GOOGLE_RECAPTCHA_KEY=6Lc7yg0iAAAAALhS4C4Ez5hqMBub8hKdFvvr9sfc -VITE_POOL_FARM_BASE_URL=https://pool-farm.kyberswap.com +VITE_POOL_FARM_BASE_URL=https://pool-farm.dev.kyberengineering.io -VITE_LIMIT_ORDER_API_WRITE=https://limit-order.stg.kyberengineering.io/write/api -VITE_LIMIT_ORDER_API_READ=https://limit-order.stg.kyberengineering.io/read-ks/api +VITE_LIMIT_ORDER_API_WRITE=https://limit-order.dev.kyberengineering.io/write/api +VITE_LIMIT_ORDER_API_READ=https://limit-order.dev.kyberengineering.io/read-ks/api VITE_BLOCK_SERVICE_API=https://block.kyberswap.com # Kyber DAO Apis -VITE_KYBER_DAO_STATS_API=https://kyberswap-dao-stats.stg.kyberengineering.io +VITE_KYBER_DAO_STATS_API=https://kyberswap-dao-stats.dev.kyberengineering.io + # oauth -VITE_ENV=staging -VITE_OAUTH_CLIENT_ID=bce9bf52-b788-4c25-9c6c-a07dff080403 +VITE_ENV=development +VITE_OAUTH_CLIENT_ID=a2f76ad4-895f-401a-ba75-952a929d782c + +VITE_BFF_API=https://kyberswap-bff.dev.kyberengineering.io/api VITE_KYBER_AI_REFERRAL_ID=1 -VITE_KYBER_AI_TOPIC_ID=11 -VITE_PRICE_ALERT_TOPIC_ID=9 -VITE_ELASTIC_POOL_TOPIC_ID=4,5 -VITE_BFF_API=https://kyberswap-bff.stg.kyberengineering.io/api -VITE_BUCKET_NAME=ks-setting-6d114fd1 +VITE_KYBER_AI_TOPIC_ID=14 +VITE_PRICE_ALERT_TOPIC_ID=13 +VITE_ELASTIC_POOL_TOPIC_ID=12 +VITE_BUCKET_NAME=ks-setting-a3aa20b7 VITE_WALLETCONNECT_PROJECT_ID=f218207428d6efc3863adab795a9f123 From 62ffe11344462ccc8c518ea91795198239ab9cd0 Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 16:27:14 +0700 Subject: [PATCH 19/20] update regex email --- src/utils/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/string.ts b/src/utils/string.ts index 20a14e8433..7b60feb49d 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -37,7 +37,7 @@ export const escapeScriptHtml = (str: string) => { return str.replace(/<.*?script.*?>.*?<\/.*?script.*?>/gim, '') } -export const isEmailValid = (value: string | undefined) => value?.match(/\S+@\S+\.\S+/) +export const isEmailValid = (value: string | undefined) => value?.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/) export const getChainIdFromSlug = (network: string | undefined) => { return Object.values(NETWORKS_INFO).find(n => n.route === network)?.chainId From e5667e54bd55b575c6a7051defa5a9cb46a84fff Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 17 Jul 2023 17:02:53 +0700 Subject: [PATCH 20/20] update regex email --- src/utils/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/string.ts b/src/utils/string.ts index 7b60feb49d..30d527cc8b 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -37,7 +37,7 @@ export const escapeScriptHtml = (str: string) => { return str.replace(/<.*?script.*?>.*?<\/.*?script.*?>/gim, '') } -export const isEmailValid = (value: string | undefined) => value?.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/) +export const isEmailValid = (value: string | undefined) => value?.match(/^\w+([\.-]?\w)*@\w+([\.-]?\w)*(\.\w{2,10})+$/) export const getChainIdFromSlug = (network: string | undefined) => { return Object.values(NETWORKS_INFO).find(n => n.route === network)?.chainId