Skip to content

Commit

Permalink
remove wallet address
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Aug 4, 2023
1 parent 170a509 commit b4c5eba
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/pages/TrueSightV2/components/KyberAIWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default function Widget() {

const { data, isFetching, isError } = useTokenListQuery(
activeTab === WidgetTab.MyWatchlist
? { type: KyberAIListType.ALL, page: 1, pageSize: 5, wallet: account, watchlist: true }
? { type: KyberAIListType.ALL, page: 1, pageSize: 5, watchlist: true }
: {
type: {
[WidgetTab.Bearish]: KyberAIListType.BEARISH,
Expand All @@ -213,7 +213,6 @@ export default function Widget() {
chain: 'all',
page: 1,
pageSize: 5,
wallet: account,
},
{ refetchOnMountOrArgChange: true, skip: !isWhiteList },
)
Expand Down
8 changes: 2 additions & 6 deletions src/pages/TrueSightV2/components/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,7 @@ const WidgetTokenRow = ({
ranking_order: index,
option: 'remove',
})
Promise.all(
token.tokens.map(t => removeFromWatchlist({ wallet: account, tokenAddress: t.address, chain: t.chain })),
).then(() => {
Promise.all(token.tokens.map(t => removeFromWatchlist({ tokenAddress: t.address, chain: t.chain }))).then(() => {
setIsWatched(false)
setLoadingStar(false)
})
Expand All @@ -663,9 +661,7 @@ const WidgetTokenRow = ({
ranking_order: index,
option: 'add',
})
Promise.all(
token.tokens.map(t => addToWatchlist({ wallet: account, tokenAddress: t.address, chain: t.chain })),
).then(() => {
Promise.all(token.tokens.map(t => addToWatchlist({ tokenAddress: t.address, chain: t.chain }))).then(() => {
setIsWatched(true)
setLoadingStar(false)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { useMemo } from 'react'

import { useActiveWeb3React } from 'hooks'

import { ITokenList, KyberAIListType } from '../types'
import { useTokenListQuery } from './useKyberAIData'

const MAX_LIMIT_WATCHED_TOKEN = 30
export default function useIsReachMaxLimitWatchedToken(tokenCount?: number) {
const { account } = useActiveWeb3React()
const { data } = useTokenListQuery({
type: KyberAIListType.ALL,
chain: 'all',
page: 1,
pageSize: 30,
wallet: account,
watchlist: true,
})

Expand Down
11 changes: 4 additions & 7 deletions src/pages/TrueSightV2/hooks/useKyberAIData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ const kyberAIApi = createApi({
chain?: string
page?: number
pageSize?: number
wallet?: string
watchlist?: boolean
keywords?: string
}
>({
query: ({ type, chain, page, pageSize, wallet, watchlist, keywords }) => ({
query: ({ type, chain, page, pageSize, watchlist, keywords }) => ({
url: '/tokens',
params: {
type: type || 'all',
chain: chain || 'all',
page: page || 1,
size: pageSize || 10,
wallet,
watchlist: watchlist ? 'true' : undefined,
keywords,
},
Expand All @@ -57,12 +55,11 @@ const kyberAIApi = createApi({
}
throw new Error(res.msg)
},
providesTags: (result, error, arg) =>
arg.watchlist === true && !!arg.wallet ? ['myWatchList', 'tokenList'] : ['tokenList'],
providesTags: (result, error, arg) => (arg.watchlist === true ? ['myWatchList', 'tokenList'] : ['tokenList']),
}),
//2.
addToWatchlist: builder.mutation({
query: (params: { wallet: string; tokenAddress: string; chain: string }) => ({
query: (params: { tokenAddress: string; chain: string }) => ({
url: `/watchlist`,
method: 'POST',
params,
Expand All @@ -71,7 +68,7 @@ const kyberAIApi = createApi({
}),
//3.
removeFromWatchlist: builder.mutation({
query: (params: { wallet: string; tokenAddress: string; chain: string }) => ({
query: (params: { tokenAddress: string; chain: string }) => ({
url: `/watchlist`,
method: 'DELETE',
params,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/TrueSightV2/pages/SingleToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ const TokenNameGroup = ({ token, isLoading }: { token?: ITokenOverview; isLoadin
})

removeFromWatchlist({
wallet: account,
tokenAddress: token?.address,
chain,
}).then(() => setIsWatched(false))
Expand All @@ -266,7 +265,7 @@ const TokenNameGroup = ({ token, isLoading }: { token?: ITokenOverview; isLoadin
source: 'explore',
option: 'add',
})
addToWatchlist({ wallet: account, tokenAddress: token?.address, chain }).then(() => setIsWatched(true))
addToWatchlist({ tokenAddress: token?.address, chain }).then(() => setIsWatched(true))
}
}
}
Expand Down
11 changes: 2 additions & 9 deletions src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,7 @@ const TokenRow = ({
ranking_order: index,
option: 'remove',
})
Promise.all(
token.tokens.map(t => removeFromWatchlist({ wallet: account, tokenAddress: t.address, chain: t.chain })),
).then(() => {
Promise.all(token.tokens.map(t => removeFromWatchlist({ tokenAddress: t.address, chain: t.chain }))).then(() => {
setIsWatched(false)
setLoadingStar(false)
})
Expand All @@ -537,9 +535,7 @@ const TokenRow = ({
ranking_order: index,
option: 'add',
})
Promise.all(
token.tokens.map(t => addToWatchlist({ wallet: account, tokenAddress: t.address, chain: t.chain })),
).then(() => {
Promise.all(token.tokens.map(t => addToWatchlist({ tokenAddress: t.address, chain: t.chain }))).then(() => {
setIsWatched(true)
setLoadingStar(false)
})
Expand Down Expand Up @@ -773,7 +769,6 @@ const LoadingRowSkeleton = ({ hasExtraCol }: { hasExtraCol?: boolean }) => {
}
export default function TokenAnalysisList() {
const theme = useTheme()
const { account } = useActiveWeb3React()
const { mixpanelHandler } = useMixpanel()
const [showShare, setShowShare] = useState(false)
const [isScrolling, setIsScrolling] = useState(false)
Expand All @@ -795,15 +790,13 @@ export default function TokenAnalysisList() {
chain: (chain && SUPPORTED_NETWORK_KYBERAI[Number(chain) as ChainId]) || 'all',
page,
pageSize,
wallet: account,
watchlist: true,
}
: {
type: listTypeParam,
chain: (chain && SUPPORTED_NETWORK_KYBERAI[Number(chain) as ChainId]) || 'all',
page,
pageSize,
wallet: account,
},
)
const listData = data?.data || []
Expand Down

0 comments on commit b4c5eba

Please sign in to comment.