Skip to content

Commit

Permalink
Merge branch 'main' into feat/kn-protocol-classic
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold committed Oct 18, 2023
2 parents ce63f46 + 07b4c4b commit 2c4e14a
Show file tree
Hide file tree
Showing 55 changed files with 1,592 additions and 1,598 deletions.
10 changes: 10 additions & 0 deletions cypress/e2e/pages/limit-order.po.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ export const LimitOder = {
getCurrentTokenBuy(text: myCallbackType<string>) {
cy.getContent(LimitOrderLocators.dropdownTokenBuy, text)
},

setSellingRate(text: string) {
cy.get(LimitOrderLocators.txtSellingRate).click().type(text)
},

getSellingRate() {
return cy.get(LimitOrderLocators.txtSellingRate).invoke('val').then(value => {
return value
})
}
}
10 changes: 5 additions & 5 deletions cypress/e2e/selectors/constants.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export enum TAG {
}

export const TOKEN_SYMBOLS = {
'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC'],
'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e'],
'Optimism': ['BOB', 'DAI', 'USDT', 'USDC'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e'],
'BNB': ['RICE', 'DAI', 'USDT', 'USDC']
'Ethereum': ['BAND', 'DAI', 'USDT', 'USDC', '1INCH'],
'Arbitrum': ['ANGLE', 'DAI', 'USDT', 'USDC.e', 'MAI'],
'Optimism': ['BOB', 'DAI', 'USDT', 'USDC', 'MAI'],
'Avalanche': ['AAVE.e', 'sAVAX', 'USDT.e', 'USDC.e', 'MAI'],
'BNB': ['RICE', 'DAI', 'USDT', 'USDC', 'MAI']
}

export const UNWHITELIST_TOKENS = {
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/selectors/selectors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const SwapPageLocators = {
export const LimitOrderLocators = {
dropdownTokenSell: '[data-testid=limit-order-input-tokena] [data-testid=token-symbol-container]',
dropdownTokenBuy: '[data-testid=limit-order-input-tokenb] [data-testid=token-symbol-container]',
btnLimit: '[data-testid=limit-button]'
btnLimit: '[data-testid=limit-button]',
txtSellingRate: '[data-testid=input-selling-rate]'
}

export const WalletLocators = {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/specs/connect-wallet.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ describe('Metamask Extension tests', { tags: TAG.regression }, () => {
SwapPage.connectWallet()
})

it('Redirects to swap page when a user has already connected a wallet', () => {
it.skip('Redirects to swap page when a user has already connected a wallet', () => {
cy.acceptMetamaskAccess()
SwapPage.getStatusConnectedWallet()
cy.url().should('include', '/swap')
})

it('Should approve permission to switch network', () => {
it.skip('Should approve permission to switch network', () => {
if (NETWORK !== DEFAULT_NETWORK) {
SwapPage.getStatusConnectedWallet()
wallet.selectNetwork(NETWORK)
Expand Down
33 changes: 19 additions & 14 deletions cypress/e2e/specs/limit-order.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { LimitOder } from "../pages/limit-order.po.cy"
import { SwapPage, TokenCatalog } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, NOTOKENS_TEXT, TAG, TOKEN_SYMBOLS, UNWHITELIST_SYMBOL_TOKENS, UNWHITELIST_TOKENS } from "../selectors/constants.cy"

const unWhitelistTokens = UNWHITELIST_TOKENS[NETWORK]
const tokenSymbols = TOKEN_SYMBOLS[NETWORK]

const arrAddress = [unWhitelistTokens[0].address, unWhitelistTokens[1].address, unWhitelistTokens[2].address]
const arrSymbol = [unWhitelistTokens[0].symbol, unWhitelistTokens[1].symbol, unWhitelistTokens[2].symbol]


const tokenCatalog = new TokenCatalog();

Expand All @@ -20,14 +16,14 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {

describe('Add/remove/select token with favorite tokens list', () => {
it('Should be added, selected and removed favorite token sell', () => {
LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]])
LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[1]])
expect(list).to.include.members([tokenSymbols[4]])
})

tokenCatalog.selectFavoriteToken(tokenSymbols[1])
tokenCatalog.selectFavoriteToken(tokenSymbols[4])
LimitOder.getCurrentTokenSell((text) => {
expect(text).to.equal(tokenSymbols[1])
expect(text).to.equal(tokenSymbols[4])
})
LimitOder.selectTokenSell()
tokenCatalog.removeFavoriteToken(tokenSymbols[0])
Expand All @@ -37,14 +33,14 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
})

it('Should be added, selected and removed favorite token buy', () => {
LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]])
LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[4]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[1]])
expect(list).to.include.members([tokenSymbols[4]])
})

tokenCatalog.selectFavoriteToken(tokenSymbols[1])
tokenCatalog.selectFavoriteToken(tokenSymbols[4])
LimitOder.getCurrentTokenBuy((text) => {
expect(text).to.equal(tokenSymbols[1])
expect(text).to.equal(tokenSymbols[4])
})
LimitOder.selectTokenBuy()
tokenCatalog.removeFavoriteToken(tokenSymbols[0])
Expand All @@ -69,18 +65,27 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
})
})

it('Should be unselected tokenIn not exist in whitelist', () => {
it('Should be unselected token sell not exist in whitelist', () => {
LimitOder.selectTokenSell().searchToken(UNWHITELIST_SYMBOL_TOKENS[0])
tokenCatalog.getNoResultsFound((text) => {
expect(text).to.equal(NORESULTS_TEXT)
})
})

it('Should be unselected tokenOut not exist in whitelist', () => {
it('Should be unselected token buy not exist in whitelist', () => {
LimitOder.selectTokenBuy().searchToken(UNWHITELIST_SYMBOL_TOKENS[0])
tokenCatalog.getNoResultsFound((text) => {
expect(text).to.equal(NORESULTS_TEXT)
})
})
})

describe('Sell rate', () => {
it('Able to set selling rate by number', () => {
LimitOder.setSellingRate('1.2345..67')
LimitOder.getSellingRate().then((value) => {
cy.wrap(value).should('eq', '1.234567')
})
})
})
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@kybernetwork/oauth2": "1.0.0",
"@kyberswap/krystal-walletconnect-v2": "0.0.1",
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.0.11",
"@kyberswap/ks-sdk-core": "1.0.13",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/ks-sdk-solana": "^1.0.2",
"@lingui/loader": "~3.14.0",
Expand Down Expand Up @@ -200,7 +200,7 @@
"vite-tsconfig-paths": "^4.0.8"
},
"resolutions": {
"@kyberswap/ks-sdk-core": "1.0.11",
"@kyberswap/ks-sdk-core": "1.0.13",
"babel-plugin-lodash/@babel/types": "~7.20.0",
"react-error-overlay": "6.0.9",
"@lingui/babel-plugin-extract-messages": "3.14.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ItemWrapper = styled.div`
gap: 8px;
`
export const TokenInfo = ({
showPrice = true,
showPrice = false,
logoSize = '12px',
token,
}: {
Expand Down Expand Up @@ -73,7 +73,7 @@ function InboxItemBridge({
}

return (
<InboxItemWrapper isRead={isRead} onClick={onClick} style={{ ...style, paddingTop: '8px', gap: '6px' }}>
<InboxItemWrapper isRead={isRead} onClick={onClick} style={style}>
<InboxItemRow>
<RowItem>
<InboxIcon type={templateType} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function AnnouncementItem({
{!expand &&
minimalAssets.map((token, i) => (
<Fragment key={i}>
<TokenInfo token={token} showPrice={false} key={i} logoSize={'14px'} />
<TokenInfo token={token} key={i} logoSize={'14px'} />
{i === minimalAssets.length - 1 ? (minimalAssets.length < slice ? '' : ', ...') : ', '}
</Fragment>
))}
Expand Down
20 changes: 0 additions & 20 deletions src/components/Announcement/helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { useCallback } from 'react'
import AnnouncementApi from 'services/announcement'

import { AnnouncementTemplatePopup, PopupContentAnnouncement, PopupItemType } from 'components/Announcement/type'
import { TIMES_IN_SECS } from 'constants/index'
import { useAppDispatch } from 'state/hooks'

const LsKey = 'ack-announcements'
export const getAnnouncementsAckMap = () => JSON.parse(localStorage[LsKey] || '{}')
Expand Down Expand Up @@ -42,20 +39,3 @@ export const isPopupCanShow = (
const isExpired = Date.now() < startAt * 1000 || Date.now() > endAt * 1000
return !isRead && !isExpired && isRightChain && isOwn
}

export const useInvalidateTags = (reducerPath: string) => {
const dispatch = useAppDispatch()
return useCallback(
(tag: string | string[]) => {
dispatch({
type: `${reducerPath}/invalidateTags`,
payload: Array.isArray(tag) ? tag : [tag],
})
},
[dispatch, reducerPath],
)
}

export const useInvalidateTagAnnouncement = () => {
return useInvalidateTags(AnnouncementApi.reducerPath)
}
3 changes: 2 additions & 1 deletion src/components/Announcement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import styled, { css } from 'styled-components'

import AnnouncementView, { Tab } from 'components/Announcement/AnnoucementView'
import DetailAnnouncementPopup from 'components/Announcement/Popups/DetailAnnouncementPopup'
import { formatNumberOfUnread, useInvalidateTagAnnouncement } from 'components/Announcement/helper'
import { formatNumberOfUnread } from 'components/Announcement/helper'
import { Announcement, PrivateAnnouncement } from 'components/Announcement/type'
import NotificationIcon from 'components/Icons/NotificationIcon'
import MenuFlyout from 'components/MenuFlyout'
import Modal from 'components/Modal'
import { RTK_QUERY_TAGS } from 'constants/index'
import useInterval from 'hooks/useInterval'
import { useInvalidateTagAnnouncement } from 'hooks/useInvalidateTags'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
import { ApplicationModal } from 'state/application/actions'
import { useDetailAnnouncement, useModalOpen, useToggleNotificationCenter } from 'state/application/hooks'
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClassicElasticTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ClassicElasticTab() {

const upToMedium = useMedia(`(max-width: ${MEDIA_WIDTHS.upToMedium}px)`)

const dontShowLegacy = [ChainId.ZKEVM, ChainId.BASE, ChainId.LINEA].includes(chainId)
const dontShowLegacy = [ChainId.ZKEVM, ChainId.BASE, ChainId.LINEA, ChainId.SCROLL].includes(chainId)

const showLegacyExplicit =
upToMedium || dontShowLegacy ? false : isFarmpage ? shouldShowFarmTab : shouldShowPositionTab
Expand Down
9 changes: 5 additions & 4 deletions src/components/Header/web3/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
useWalletModalToggle,
} from 'state/application/hooks'
import { useIsConnectingWallet } from 'state/authen/hooks'
import { ExternalLink } from 'theme'
import { isEVMWallet, isOverriddenWallet, isSolanaWallet } from 'utils'

import Option from './Option'
Expand Down Expand Up @@ -316,13 +317,13 @@ export default function WalletModal() {
<Text color={theme.subText}>
<Trans>
By connecting a wallet, you accept{' '}
<a href={TERM_FILES_PATH.KYBERSWAP_TERMS} onClick={e => e.stopPropagation()}>
<ExternalLink href={TERM_FILES_PATH.KYBERSWAP_TERMS} onClick={e => e.stopPropagation()}>
KyberSwap&lsquo;s Terms of Use
</a>{' '}
</ExternalLink>{' '}
and consent to its{' '}
<a href={TERM_FILES_PATH.PRIVACY_POLICY} onClick={e => e.stopPropagation()}>
<ExternalLink href={TERM_FILES_PATH.PRIVACY_POLICY} onClick={e => e.stopPropagation()}>
Privacy Policy
</a>
</ExternalLink>
. Last updated: {dayjs(TERM_FILES_PATH.VERSION).format('DD MMM YYYY')}
</Trans>
</Text>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export default function Menu() {
)}

<MenuItem>
<a
<ExternalLink
href={TERM_FILES_PATH.KYBERSWAP_TERMS}
onClick={() => {
toggle()
Expand All @@ -482,10 +482,10 @@ export default function Menu() {
>
<FileText />
<Trans>Terms</Trans>
</a>
</ExternalLink>
</MenuItem>
<MenuItem>
<a
<ExternalLink
href={TERM_FILES_PATH.PRIVACY_POLICY}
onClick={() => {
toggle()
Expand All @@ -494,7 +494,7 @@ export default function Menu() {
>
<FileText />
<Trans>Privacy Policy</Trans>
</a>
</ExternalLink>
</MenuItem>
<MenuItem>
<ExternalLink
Expand Down
14 changes: 4 additions & 10 deletions src/components/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Navigate } from 'react-router-dom'

import LocalLoader from 'components/LocalLoader'
import { RTK_QUERY_TAGS } from 'constants/index'
import kyberAIapi from 'pages/TrueSightV2/hooks/useKyberAIData'
import { useInvalidateTagKyberAi } from 'hooks/useInvalidateTags'
import { useSessionInfo } from 'state/authen/hooks'
import { useAppDispatch } from 'state/hooks'
import { useIsWhiteListKyberAI } from 'state/user/hooks'

type Props = {
Expand Down Expand Up @@ -33,20 +32,15 @@ export const ProtectedRouteKyberAI = ({
const { userInfo } = useSessionInfo()
const loadedPage = useRef(false)
const canAccessPage = isWhiteList || waitUtilAuthenEndOnly
const dispatch = useAppDispatch()
const invalidateTags = useInvalidateTagKyberAi()

useEffect(() => {
// change account sign in => refresh participant info
try {
refetch()
dispatch(
kyberAIapi.util.invalidateTags([
RTK_QUERY_TAGS.GET_WATCHLIST_TOKENS_KYBER_AI,
RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI,
]),
)
invalidateTags([RTK_QUERY_TAGS.GET_WATCHLIST_TOKENS_KYBER_AI, RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI])
} catch (error) {}
}, [userInfo?.identityId, refetch, dispatch])
}, [userInfo?.identityId, refetch, invalidateTags])

if (loading && !loadedPage.current) return <LocalLoader />
if (!canAccessPage) return <Navigate to={redirectUrl} replace />
Expand Down
Loading

0 comments on commit 2c4e14a

Please sign in to comment.