Skip to content

Commit

Permalink
Merge pull request #2082 from oasisprotocol/lw/discourage-cipher
Browse files Browse the repository at this point in the history
Discourage mistaken ParaTime deposits into Cipher
  • Loading branch information
lukaw3d authored Nov 4, 2024
2 parents 0102d94 + 4ff3783 commit 8871626
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions .changelog/2082.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Discourage mistaken ParaTime deposits into Cipher
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ exports[`<ParaTimeSelection /> should render component 1`] = `
class="c12"
>
<span>
paraTimes.common.cipher
paraTimes.common.cipher paraTimes.common.discouragedType
</span>
</div>
<input
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/ParaTimesPage/ParaTimeSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next'
import { ParaTimeContent } from '../ParaTimeContent'
import { ParaTimeFormFooter } from '../ParaTimeFormFooter'
import { useParaTimes } from '../useParaTimes'
import { getParaTimeName } from '../getParaTimeName'
import { useParaTimesNavigation } from '../useParaTimesNavigation'
import { ThemeContext } from 'styled-components'
import { ThemeType } from 'grommet/es6/themes'
Expand Down Expand Up @@ -41,7 +42,7 @@ export const ParaTimeSelection = () => {
} = useParaTimes()
const { navigateToRecipient } = useParaTimesNavigation()
const options = availableParaTimesForSelectedNetwork.map(item => ({
label: <ParaTimeOption label={t(`paraTimes.common.${item.value}`)} isEvm={item.isEvm} />,
label: <ParaTimeOption label={getParaTimeName(t, item.value)} isEvm={item.isEvm} />,
value: item.value,
}))

Expand Down
24 changes: 24 additions & 0 deletions src/app/pages/ParaTimesPage/getParaTimeName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TFunction } from 'i18next'
import { ExhaustedTypeError } from 'types/errors'
import { ParaTime } from '../../../config'

export const getParaTimeName = (t: TFunction, paraTime: ParaTime) => {
switch (paraTime) {
case ParaTime.Cipher:
return `${t('paraTimes.common.cipher', 'Cipher')} ${t(
'paraTimes.common.discouragedType',
// Discourage mistaken ParaTime deposits into Cipher accounts controlled
// by Binance. That requires contacting support to recover it.
'(experimental)',
)}`
case ParaTime.Emerald:
return t('paraTimes.common.emerald', 'Emerald')
case ParaTime.Sapphire:
return t('paraTimes.common.sapphire', 'Sapphire')
default:
throw new ExhaustedTypeError(
t('paraTimes.validation.unsupportedParaTime', 'Unsupported ParaTime'),
paraTime,
)
}
}
2 changes: 1 addition & 1 deletion src/app/pages/ParaTimesPage/useParaTimes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe('useParaTimes', () => {

const { result } = renderHook(() => useParaTimes())

expect(result.current.paraTimeName).toEqual('paraTimes.common.cipher')
expect(result.current.paraTimeName).toEqual('paraTimes.common.cipher paraTimes.common.discouragedType')
})
})

Expand Down
20 changes: 2 additions & 18 deletions src/app/pages/ParaTimesPage/useParaTimes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { TFunction } from 'i18next'
import { paraTimesActions } from 'app/state/paratimes'
import { TransactionForm, TransactionTypes } from 'app/state/paratimes/types'
import { selectSelectedNetwork, selectTicker } from 'app/state/network/selectors'
import { selectAccountAvailableBalance, selectAccountIsLoading } from 'app/state/account/selectors'
import { selectAddress } from 'app/state/wallet/selectors'
import { selectParaTimes } from 'app/state/paratimes/selectors'
import { StringifiedBigInt } from 'types/StringifiedBigInt'
import { ErrorPayload, ExhaustedTypeError } from 'types/errors'
import { ErrorPayload } from 'types/errors'
import { paraTimesConfig, RuntimeTypes, ParaTime, type ParaTimeConfig } from '../../../config'
import { selectEvmAccounts } from 'app/state/evmAccounts/selectors'
import { EvmAccount } from 'app/state/evmAccounts/types'
import { getParaTimeName } from './getParaTimeName'

type AvailableParaTimesForNetwork = {
isEvm: boolean
Expand Down Expand Up @@ -45,22 +45,6 @@ export type ParaTimesHook = {
usesOasisAddress: boolean
}

const getParaTimeName = (t: TFunction, paraTime: ParaTime) => {
switch (paraTime) {
case ParaTime.Cipher:
return t('paraTimes.common.cipher', 'Cipher')
case ParaTime.Emerald:
return t('paraTimes.common.emerald', 'Emerald')
case ParaTime.Sapphire:
return t('paraTimes.common.sapphire', 'Sapphire')
default:
throw new ExhaustedTypeError(
t('paraTimes.validation.unsupportedParaTime', 'Unsupported ParaTime'),
paraTime,
)
}
}

export const useParaTimes = (): ParaTimesHook => {
const { t } = useTranslation()
const dispatch = useDispatch()
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"common": {
"cipher": "Cipher",
"depositHeader": "Deposit to ParaTime",
"discouragedType": "(experimental)",
"emerald": "Emerald",
"evmcType": "(EVMc)",
"header": "ParaTime Transfers",
Expand Down

0 comments on commit 8871626

Please sign in to comment.