diff --git a/.env.adpr b/.env.adpr
index 66271cd8e5..1ef74f455f 100644
--- a/.env.adpr
+++ b/.env.adpr
@@ -1,45 +1,42 @@
-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
+VITE_PRICE_ALERT_API=https://price-alert.stg.kyberengineering.io/api
# oauth
-VITE_ENV=development
-VITE_OAUTH_CLIENT_ID=a2f76ad4-895f-401a-ba75-952a929d782c
-
-VITE_PRICE_ALERT_API=https://price-alert.dev.kyberengineering.io/api
-VITE_BFF_API=https://kyberswap-bff.dev.kyberengineering.io/api
+VITE_ENV=staging
+VITE_OAUTH_CLIENT_ID=bce9bf52-b788-4c25-9c6c-a07dff080403
+VITE_BFF_API=https://kyberswap-bff.stg.kyberengineering.io/api
VITE_KYBER_AI_REFERRAL_ID=1
-VITE_KYBER_AI_TOPIC_ID=14
+VITE_KYBER_AI_TOPIC_ID=11
-VITE_BUCKET_NAME=ks-setting-a3aa20b7
\ No newline at end of file
+VITE_BUCKET_NAME=ks-setting-6d114fd1
\ No newline at end of file
diff --git a/package.json b/package.json
index 66dafdedf6..09b0e97334 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"@apollo/client": "^3.7.1",
"@datadog/browser-rum": "^4.23.3",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
- "@kybernetwork/oauth2": "0.0.3",
+ "@kybernetwork/oauth2": "0.0.5-rc.6",
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "^1.0.5",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
diff --git a/src/components/ProtectedRoute.tsx b/src/components/ProtectedRoute.tsx
index 839d08e97d..66aece6d29 100644
--- a/src/components/ProtectedRoute.tsx
+++ b/src/components/ProtectedRoute.tsx
@@ -1,10 +1,7 @@
import { useEffect, useRef } from 'react'
import { Navigate } from 'react-router-dom'
-import kyberAIApi from 'services/kyberAISubscription'
-import { useInvalidateTags } from 'components/Announcement/helper'
import LocalLoader from 'components/LocalLoader'
-import { RTK_QUERY_TAGS } from 'constants/index'
import { useSessionInfo } from 'state/authen/hooks'
import { useIsWhiteListKyberAI } from 'state/user/hooks'
@@ -26,16 +23,17 @@ export const ProtectedRouteKyberAI = ({
}: Props & {
waitUtilAuthenEndOnly?: boolean
}) => {
- const { loading, isWhiteList } = useIsWhiteListKyberAI()
+ const { loading, isWhiteList, refetch } = useIsWhiteListKyberAI()
const { userInfo } = useSessionInfo()
- const invalidate = useInvalidateTags(kyberAIApi.reducerPath)
const loadedPage = useRef(false)
const canAccessPage = isWhiteList || waitUtilAuthenEndOnly
useEffect(() => {
// change account sign in => refresh participant info
- invalidate(RTK_QUERY_TAGS.GET_PARTICIPANT_INFO_KYBER_AI)
- }, [userInfo?.identityId, invalidate])
+ try {
+ refetch()
+ } catch (error) {}
+ }, [userInfo?.identityId, refetch])
if (loading && !loadedPage.current) return
if (!canAccessPage) return
diff --git a/src/hooks/useLogin.tsx b/src/hooks/useLogin.tsx
index f368ec332b..fc9e774974 100644
--- a/src/hooks/useLogin.tsx
+++ b/src/hooks/useLogin.tsx
@@ -76,6 +76,7 @@ const useLogin = () => {
}
if (requestingSession.current !== walletAddress) {
requestingSession.current = walletAddress
+ setLoading(true)
await KyberOauth2.getSession({ method: LoginMethod.ETH, walletAddress })
await getProfile(walletAddress)
setLoading(false)
diff --git a/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx b/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
index f5bea32f6e..891318729a 100644
--- a/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
+++ b/src/pages/TrueSightV2/pages/RegisterWhitelist/index.tsx
@@ -31,7 +31,7 @@ export default function RegisterWhitelist({ showForm = true }: { showForm?: bool
const toggleWalletModal = useWalletModalToggle()
const { isLogin } = useSessionInfo()
- const { isWhiteList, isWaitList } = useIsWhiteListKyberAI()
+ const { isWhiteList, isWaitList, loading: isCheckingPermission } = useIsWhiteListKyberAI()
const [verifyModalState, setVerifyModalState] = useState({
isOpen: false,
@@ -92,10 +92,13 @@ export default function RegisterWhitelist({ showForm = true }: { showForm?: bool
)
- if (!isLogin)
+ if (!isLogin || isCheckingPermission)
return (
- KyberOauth2.authenticate({ wallet_address: account ?? '' })}>
- Sign-In to Continue
+ KyberOauth2.authenticate({ wallet_address: account ?? '' })}
+ disabled={isCheckingPermission}
+ >
+ {isCheckingPermission ? Checking data... : Sign-In to Continue}
)
diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx
index 6b1201a477..bf0bfb50fd 100644
--- a/src/state/user/hooks.tsx
+++ b/src/state/user/hooks.tsx
@@ -13,6 +13,7 @@ import {
useOldStaticFeeFactoryContract,
useStaticFeeFactoryContract,
} from 'hooks/useContract'
+import useDebounce from 'hooks/useDebounce'
import { ParticipantInfo, ParticipantStatus } from 'pages/TrueSightV2/types'
import { AppDispatch, AppState } from 'state'
import { useSessionInfo } from 'state/authen/hooks'
@@ -520,16 +521,18 @@ export const useIsWhiteListKyberAI = () => {
data: rawData,
isFetching,
isError,
+ refetch,
} = useGetParticipantInfoQuery(undefined, {
skip: !userInfo,
})
- const participantInfo = isError ? participantDefault : rawData
-
+ const participantInfo = isError || pendingAuthentication ? participantDefault : rawData
+ const isLoading = useDebounce(isFetching || pendingAuthentication, 100)
return {
- loading: isFetching || pendingAuthentication,
+ loading: isLoading,
isWhiteList:
isLogin && (participantInfo?.status === ParticipantStatus.WHITELISTED || userInfo?.data?.hasAccessToKyberAI),
isWaitList: isLogin && participantInfo?.status === ParticipantStatus.WAITLISTED,
+ refetch,
}
}
diff --git a/yarn.lock b/yarn.lock
index c9218ae38e..3a5918c678 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2303,10 +2303,10 @@
bs58 "^5.0.0"
uuid "^8.3.2"
-"@kybernetwork/oauth2@0.0.3":
- version "0.0.3"
- resolved "https://npm.pkg.github.com/download/@kybernetwork/oauth2/0.0.3/6a555baf6b62a781d532d06186ca8faf6eeef923#6a555baf6b62a781d532d06186ca8faf6eeef923"
- integrity sha512-SvTpvVPeiGNau13abVX5v7ItC5ZtCb7+Qx2AbK7L2G8kNLH8IEpr9C0w8sSMOGi8CEU6UDaUI02RjtxVOPyN4A==
+"@kybernetwork/oauth2@0.0.5-rc.6":
+ version "0.0.5-rc.6"
+ resolved "https://npm.pkg.github.com/download/@kybernetwork/oauth2/0.0.5-rc.6/ff3722c3724165be81789cf08cdb50912075b359#ff3722c3724165be81789cf08cdb50912075b359"
+ integrity sha512-EdjdH2iDNhiEyuahnfmRPkdY2RGkpL4MyYX5crfLlqMlAcbtvpoUBwi+0oOHjZ1rJh0Bsm5rfzUa5iT1PZNiSw==
dependencies:
axios "1.2.1"
client-oauth2 "^4.3.3"