Skip to content

Commit

Permalink
Merge pull request #75 from DarkFlorist/small-fixes
Browse files Browse the repository at this point in the history
some renaming, remove token blocking (just warn), fix locale,
  • Loading branch information
KillariDev authored Jan 23, 2024
2 parents 8f9084f + 88724a8 commit 4411e0f
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 70 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/wallet-dropdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ describe('Wallet Dropdown', () => {

function itChangesLocale() {
it('should change locale', () => {
cy.contains('Uniswap available in: English').should('not.exist')
cy.contains('Horswap available in: English').should('not.exist')

cy.get(getTestSelector('wallet-language-item')).contains('Afrikaans').click({ force: true })
cy.location('search').should('match', /\?lng=af-ZA$/)
cy.contains('Uniswap available in: English')
cy.contains('Horswap available in: English')

cy.get(getTestSelector('wallet-language-item')).contains('English').click({ force: true })
cy.location('search').should('match', /\?lng=en-US$/)
cy.contains('Uniswap available in: English').should('not.exist')
cy.contains('Horswap available in: English').should('not.exist')
})
}

Expand Down
4 changes: 2 additions & 2 deletions cypress/staging/t9n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('translations', () => {
it('loads locale from the query param', () => {
cy.visit('/?lng=fr-FR')
cy.contains('Échanger')
cy.contains('Uniswap disponible en : English')
cy.contains('Horswap disponible en : English')
})

it('loads locale from menu', () => {
Expand All @@ -14,6 +14,6 @@ describe('translations', () => {
cy.get(getTestSelector('wallet-language-item')).contains('français').click({ force: true })
cy.location('search').should('match', /\?lng=fr-FR$/)
cy.contains('Échanger')
cy.contains('Uniswap disponible en : English')
cy.contains('Horswap disponible en : English')
})
})
2 changes: 1 addition & 1 deletion src/components/SwitchLocaleLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function SwitchLocaleLink() {
return (
<Container>
<Trans>
Uniswap available in:{' '}
Horswap available in:{' '}
<StyledInternalLink onClick={onClick} to={to}>
{LOCALE_LABEL[targetLocale]}
</StyledInternalLink>
Expand Down
13 changes: 1 addition & 12 deletions src/components/TokenSafety/TokenSafetyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Warning, WARNING_LEVEL } from 'constants/tokenSafety'
import { AlertTriangle, Slash } from 'react-feather'
import { AlertTriangle } from 'react-feather'
import styled, { css } from 'styled-components'

const WarningContainer = styled.div`
Expand All @@ -18,19 +18,8 @@ const WarningIcon = styled(AlertTriangle)`
color: ${({ theme }) => theme.neutral3};
`

const BlockedIcon = styled(Slash)`
${WarningIconStyle}
color: ${({ theme }) => theme.neutral2};
`

export default function TokenSafetyIcon({ warning }: { warning: Warning | null }) {
switch (warning?.level) {
case WARNING_LEVEL.BLOCKED:
return (
<WarningContainer>
<BlockedIcon data-cy="blocked-icon" strokeWidth={2.5} />
</WarningContainer>
)
case WARNING_LEVEL.UNKNOWN:
return (
<WarningContainer>
Expand Down
6 changes: 3 additions & 3 deletions src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MetaMask } from '@web3-react/metamask'
import { Network } from '@web3-react/network'
import { Connector } from '@web3-react/types'
import GNOSIS_ICON from 'assets/images/gnosis.png'
import UNISWAP_LOGO from 'assets/svg/logo.svg'
import HORSWAP_LOGO from 'assets/svg/logo.svg'
import COINBASE_ICON from 'assets/wallets/coinbase-icon.svg'
import { isMobile } from 'utils/userAgent'

Expand Down Expand Up @@ -83,8 +83,8 @@ const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<Coinba
actions,
options: {
url: RPC_URLS[ChainId.MAINNET][0],
appName: 'Uniswap',
appLogoUrl: UNISWAP_LOGO,
appName: 'Horswap',
appLogoUrl: HORSWAP_LOGO,
reloadOnDisconnect: false,
},
onError,
Expand Down
20 changes: 1 addition & 19 deletions src/constants/tokenSafety.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const TOKEN_SAFETY_ARTICLE = 'https://support.uniswap.org/hc/en-us/articl
export enum WARNING_LEVEL {
MEDIUM,
UNKNOWN,
BLOCKED,
}

export function getWarningCopy(warning: Warning | null, plural = false) {
Expand Down Expand Up @@ -37,15 +36,6 @@ export function getWarningCopy(warning: Warning | null, plural = false) {
)
description = <Trans>Always conduct your own research before trading.</Trans>
break
case WARNING_LEVEL.BLOCKED:
description = (
<Plural
value={plural ? 2 : 1}
_1="You can't trade this token using the Uniswap App."
other="You can't trade these tokens using the Uniswap App."
/>
)
break
}
}
return { heading, description }
Expand All @@ -70,12 +60,6 @@ const StrongWarning: Warning = {
canProceed: true,
}

const BlockedWarning: Warning = {
level: WARNING_LEVEL.BLOCKED,
message: <Trans>Not available</Trans>,
canProceed: false,
}

export const NotFoundWarning: Warning = {
level: WARNING_LEVEL.UNKNOWN,
message: <Trans>Token not found</Trans>,
Expand All @@ -93,10 +77,8 @@ export function checkWarning(tokenAddress: string, chainId?: number | null) {
return MediumWarning
case TOKEN_LIST_TYPES.UNKNOWN:
return StrongWarning
case TOKEN_LIST_TYPES.BLOCKED:
return BlockedWarning
case TOKEN_LIST_TYPES.BROKEN:
return BlockedWarning
return StrongWarning
}
}

Expand Down
1 change: 0 additions & 1 deletion src/constants/tokenSafetyLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export enum TOKEN_LIST_TYPES {
UNI_DEFAULT = 1,
UNI_EXTENDED,
UNKNOWN,
BLOCKED,
BROKEN,
}

Expand Down
9 changes: 2 additions & 7 deletions src/hooks/useAssetLogoSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tokenLogoLookup from 'constants/tokenLogoLookup'
import { isCelo, nativeOnChain } from 'constants/tokens'
import { checkWarning, WARNING_LEVEL } from 'constants/tokenSafety'
import { chainIdToNetworkName, getNativeLogoURI } from 'lib/hooks/useCurrencyLogoURIs'
import uriToHttp from 'lib/utils/uriToHttp'
import { useCallback, useEffect, useState } from 'react'
Expand Down Expand Up @@ -66,17 +65,13 @@ export default function useAssetLogoSource(
isNative?: boolean,
backupImg?: string | null
): [string | undefined, () => void] {
const hideLogo = Boolean(address && checkWarning(address, chainId)?.level === WARNING_LEVEL.BLOCKED)
const [current, setCurrent] = useState<string | undefined>(
hideLogo ? undefined : getInitialUrl(address, chainId, isNative, backupImg)
)
const [current, setCurrent] = useState<string | undefined>(getInitialUrl(address, chainId, isNative, backupImg))
const [fallbackSrcs, setFallbackSrcs] = useState<string[] | undefined>(undefined)

useEffect(() => {
if (hideLogo) return
setCurrent(getInitialUrl(address, chainId, isNative))
setFallbackSrcs(undefined)
}, [address, chainId, hideLogo, isNative])
}, [address, chainId, isNative])

const nextSrc = useCallback(() => {
if (current) {
Expand Down
10 changes: 0 additions & 10 deletions src/hooks/useTokenWarningColor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ describe('Token Warning Colors', () => {
const { result } = renderHook(() => useTokenWarningColor(WARNING_LEVEL.UNKNOWN))
expect(result.current).toEqual(lightDeprecatedTheme.deprecated_accentFailureSoft)
})

it('blocked', () => {
const { result } = renderHook(() => useTokenWarningColor(WARNING_LEVEL.BLOCKED))
expect(result.current).toEqual(lightTheme.surface3)
})
})

describe('useTokenWarningTextColor', () => {
Expand All @@ -33,10 +28,5 @@ describe('Token Warning Colors', () => {
const { result } = renderHook(() => useTokenWarningTextColor(WARNING_LEVEL.UNKNOWN))
expect(result.current).toEqual(lightTheme.critical)
})

it('blocked', () => {
const { result } = renderHook(() => useTokenWarningTextColor(WARNING_LEVEL.BLOCKED))
expect(result.current).toEqual(lightTheme.neutral2)
})
})
})
3 changes: 0 additions & 3 deletions src/hooks/useTokenWarningColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const useTokenWarningTextColor = (level: WARNING_LEVEL) => {
return theme.deprecated_accentWarning
case WARNING_LEVEL.UNKNOWN:
return theme.critical
case WARNING_LEVEL.BLOCKED:
return theme.neutral2
}
}

Expand All @@ -19,7 +17,6 @@ export const useTokenWarningColor = (level: WARNING_LEVEL) => {

switch (level) {
case WARNING_LEVEL.MEDIUM:
case WARNING_LEVEL.BLOCKED:
return theme.surface3
case WARNING_LEVEL.UNKNOWN:
return theme.deprecated_accentFailureSoft
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Landing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ArrowDownCircle } from 'react-feather'
import { Navigate, useLocation, useNavigate } from 'react-router-dom'
import { Link as NativeLink } from 'react-router-dom'
import { useAppSelector } from 'state/hooks'
import { AppState } from 'state/reducer'
import styled, { css } from 'styled-components'
import { BREAKPOINTS } from 'theme'
import { useIsDarkMode } from 'theme/components/ThemeToggle'
Expand Down Expand Up @@ -327,7 +326,6 @@ export default function Landing() {
const isDarkMode = useIsDarkMode()
const cardsRef = useRef<HTMLDivElement>(null)
const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
const originCountry = useAppSelector((state: AppState) => state.user.originCountry)
const cards = MAIN_CARDS
const extraCards = MORE_CARDS

Expand Down Expand Up @@ -360,10 +358,10 @@ export default function Landing() {
<Glow />
</GlowContainer>
<ContentContainer isDarkMode={isDarkMode}>
<TitleText isDarkMode={isDarkMode} $visible={!!originCountry}>
<TitleText isDarkMode={isDarkMode} $visible={true}>
<Trans>Trade crypto with confidence</Trans>
</TitleText>
<SubTextContainer $visible={!!originCountry}>
<SubTextContainer $visible={true}>
<SubText>
<Trans>Buy, sell, and explore tokens</Trans>
</SubText>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/WhatIsHorswap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Here are the significant changes:
- Removed claim UNI tokens popup
- Added docker building and deployment to IPFS
You can see all the changes by [comparing Horseswap to Uniswap Interface V4.266.2](https://github.com/Uniswap/interface/compare/v4.266.2...DarkFlorist:Horswap:main). You can also find the whole codebase in [GitHub](https://github.com/DarkFlorist/Horswap/).
You can see all the changes by [comparing Horswap to Uniswap Interface V4.266.2](https://github.com/Uniswap/interface/compare/v4.266.2...DarkFlorist:Horswap:main). You can also find the whole codebase in [GitHub](https://github.com/DarkFlorist/Horswap/).
`.replace(/[\n\r]/g, '\n')}
/>
</MarkDownWrapper>
Expand Down
1 change: 0 additions & 1 deletion src/state/reducerTypeTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ interface ExpectedUserState {
timestamp: number
hideBaseWalletBanner: boolean
showSurveyPopup?: boolean
originCountry?: string
}

assert<Equals<UserState, ExpectedUserState>>()
Expand Down
3 changes: 0 additions & 3 deletions src/state/user/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export interface UserState {
hideBaseWalletBanner: boolean
// undefined means has not gone through A/B split yet
showSurveyPopup?: boolean

originCountry?: string
}

function pairKey(token0Address: string, token1Address: string) {
Expand All @@ -66,7 +64,6 @@ export const initialState: UserState = {
timestamp: currentTimestamp(),
hideBaseWalletBanner: false,
showSurveyPopup: undefined,
originCountry: undefined,
}

const userSlice = createSlice({
Expand Down

0 comments on commit 4411e0f

Please sign in to comment.