Skip to content

Commit 7ca3c78

Browse files
committed
Hide cEUR on Mainnet
Fix two minor bugs
1 parent 66648dc commit 7ca3c78

8 files changed

Lines changed: 47 additions & 25 deletions

File tree

src/components/buttons/ClickToCopy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import { trimToLength } from 'src/utils/string'
77

88
interface ButtonProps {
99
text: string
10+
copyText?: string
1011
maxLength?: number
1112
styles?: Styles
1213
}
1314

1415
export function ClickToCopy(props: ButtonProps) {
15-
const { text, maxLength, styles } = props
16+
const { text, copyText, maxLength, styles } = props
1617

1718
const onClick = async () => {
18-
await tryClipboardSet(text)
19+
await tryClipboardSet(copyText ?? text)
1920
}
2021

2122
const displayText = maxLength ? trimToLength(text, maxLength) : text

src/components/buttons/CopiableAddress.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export function CopiableAddress(props: ButtonProps) {
1313
const text =
1414
length === 'full' ? address.toUpperCase() : shortenAddress(address, true).toUpperCase()
1515

16-
return <ClickToCopy text={text} styles={styles} />
16+
return <ClickToCopy text={text} copyText={address} styles={styles} />
1717
}

src/components/header/BalanceSummary.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { BigNumber } from 'ethers'
22
import { useMemo } from 'react'
3-
import { useSelector } from 'react-redux'
43
import { useNavigate } from 'react-router-dom'
5-
import { RootState } from 'src/app/rootReducer'
64
import { transparentButtonStyles } from 'src/components/buttons/Button'
75
import { Box } from 'src/components/layout/Box'
86
import { MoneyValue } from 'src/components/MoneyValue'
7+
import { config } from 'src/config'
8+
import { useTokens } from 'src/features/wallet/utils'
99
import { Color } from 'src/styles/Color'
1010
import { Font } from 'src/styles/fonts'
1111
import { mq, useWindowSize } from 'src/styles/mediaQueries'
@@ -17,7 +17,15 @@ export function BalanceSummary() {
1717
if (windowWidth && windowWidth > 550) numItems = 3
1818
if (windowWidth && windowWidth > 1024) numItems = 4
1919

20-
const tokens = useSelector((s: RootState) => s.wallet.balances.tokens)
20+
let tokens = useTokens()
21+
// TODO-cEUR remove when activated
22+
if (config.chainId === 42220) {
23+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
24+
const { cEUR, ...rest } = tokens
25+
// @ts-ignore
26+
tokens = rest
27+
}
28+
2129
const { tokensToShow, hiddenTokens } = useMemo(() => {
2230
const sortedTokens = Object.values(tokens).sort((t1, t2) => {
2331
const t1Value = BigNumber.from(t1.value)

src/components/input/AmountAndCurrencyInput.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { ChangeEvent, useMemo } from 'react'
2-
import { useSelector } from 'react-redux'
3-
import { RootState } from 'src/app/rootReducer'
42
import { TokenIcon } from 'src/components/icons/tokens/TokenIcon'
53
import { NumberInput } from 'src/components/input/NumberInput'
64
import { SelectInput, SelectOption } from 'src/components/input/SelectInput'
75
import { Box } from 'src/components/layout/Box'
6+
import { config } from 'src/config'
7+
import { useTokens } from 'src/features/wallet/utils'
88
import { Font } from 'src/styles/fonts'
99
import { Stylesheet } from 'src/styles/types'
10-
import { isNativeToken } from 'src/tokens'
10+
import { cEUR, isNativeToken } from 'src/tokens'
1111
import { ErrorState } from 'src/utils/validation'
1212

1313
interface Props {
@@ -37,12 +37,14 @@ export const AmountAndCurrencyInput = (props: Props) => {
3737
nativeTokensOnly,
3838
} = props
3939

40-
const tokens = useSelector((state: RootState) => state.wallet.balances.tokens)
40+
const tokens = useTokens()
4141

4242
const selectOptions = useMemo(
4343
() =>
4444
Object.values(tokens)
4545
.filter((t) => (nativeTokensOnly ? isNativeToken(t.id) : true))
46+
// TODO-cEUR remove when activated
47+
.filter((t) => t.id !== cEUR.id || config.chainId === 44787)
4648
.map((t) => ({
4749
display: t.symbol,
4850
value: t.id,

src/features/pincode/ChangePincodeForm.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react'
1+
import { useLayoutEffect, useState } from 'react'
22
import { useDispatch } from 'react-redux'
33
import { useNavigate } from 'react-router'
44
import { Button } from 'src/components/buttons/Button'
@@ -61,6 +61,10 @@ export function ChangePincodeForm() {
6161
navigate(-1)
6262
}
6363

64+
useLayoutEffect(() => {
65+
dispatch(pincodeActions.reset())
66+
}, [])
67+
6468
const { showModalAsync } = useModal()
6569
const onSuccess = async () => {
6670
await showModalAsync(

src/features/settings/SettingsScreen.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import PlusIcon from 'src/components/icons/plus.svg'
1212
import { Box } from 'src/components/layout/Box'
1313
import { ScreenContentFrame } from 'src/components/layout/ScreenContentFrame'
1414
import { MAX_SEND_TOKEN_SIZE, MAX_SEND_TOKEN_SIZE_LEDGER } from 'src/consts'
15+
import { pincodeActions } from 'src/features/pincode/pincode'
1516
import { setTxSizeLimitEnabled } from 'src/features/settings/settingsSlice'
1617
import { Color } from 'src/styles/Color'
1718
import { Font } from 'src/styles/fonts'
@@ -23,6 +24,11 @@ export function SettingsScreen() {
2324
const dispatch = useDispatch()
2425
const navigate = useNavigate()
2526

27+
const onClickChangePassword = () => {
28+
dispatch(pincodeActions.reset())
29+
navigate('/change-pin')
30+
}
31+
2632
const onClickAddToken = () => {
2733
navigate('/balances')
2834
}
@@ -56,18 +62,16 @@ export function SettingsScreen() {
5662
</Box>
5763
</Link>
5864
</div>
59-
<div css={style.pageLinkBox}>
60-
<Link to="/change-pin">
61-
<Box direction="row" align="center">
62-
<img src={LockIcon} alt="change pin" css={style.pageLinkIcon} />
63-
<div>
64-
<h3 css={style.h3}>Change Password</h3>
65-
<div css={style.description}>
66-
Set the password used to unlock your account on this device.
67-
</div>
65+
<div css={style.pageLinkBox} onClick={onClickChangePassword}>
66+
<Box direction="row" align="center">
67+
<img src={LockIcon} alt="change pin" css={style.pageLinkIcon} />
68+
<div>
69+
<h3 css={style.h3}>Change Password</h3>
70+
<div css={style.description}>
71+
Set the password used to unlock your account on this device.
6872
</div>
69-
</Box>
70-
</Link>
73+
</div>
74+
</Box>
7175
</div>
7276
</Box>
7377
<HrDivider styles={style.divider} />
@@ -158,6 +162,7 @@ const style: Stylesheet = {
158162
margin: '2em 0',
159163
},
160164
pageLinkBox: {
165+
cursor: 'pointer',
161166
marginTop: '1em',
162167
width: '20em',
163168
padding: '1em',

src/features/wallet/BalanceDetailsScreen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Color } from 'src/styles/Color'
2121
import { Font } from 'src/styles/fonts'
2222
import { useIsMobile } from 'src/styles/mediaQueries'
2323
import { Stylesheet } from 'src/styles/types'
24-
import { isNativeToken, LockedCELO } from 'src/tokens'
24+
import { cEUR, isNativeToken, LockedCELO } from 'src/tokens'
2525
import { fromWeiRounded } from 'src/utils/amount'
2626
import { SagaStatus } from 'src/utils/saga'
2727

@@ -164,6 +164,8 @@ function balancesToTableData(balances: Balances): BalanceTableRow[] {
164164
: balances.tokens
165165

166166
for (const token of Object.values(tokens)) {
167+
// TODO-cEUR remove when activated
168+
if (config.chainId === 42220 && token.id === cEUR.id) continue
167169
tableRows.push({
168170
id: token.id,
169171
label: token.symbol,

src/features/wallet/fetchBalances.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ async function fetchTokenBalances(
6868
if (t.id === CELO.id) {
6969
fetchPromises.push(fetchCeloBalance(address))
7070
} else {
71-
// TODO remove when cEUR is live
72-
if (t.id === cEUR.id && config.chainId !== 44787) continue
71+
// TODO-cEUR remove when activated
72+
if (t.id === cEUR.id && config.chainId === 42220) continue
7373
fetchPromises.push(fetchTokenBalance(address, t))
7474
}
7575
}

0 commit comments

Comments
 (0)