Skip to content

Commit

Permalink
chore: remove twelveWordMnemonicEnabled remote config (valora-inc#5018)
Browse files Browse the repository at this point in the history
### Description

As the title

### Test plan

n/a

### Related issues

- Fixes RET-879

### Backwards compatibility

y

### Network scalability

y
  • Loading branch information
kathaypacific authored and shottah committed May 15, 2024
1 parent 1bfea8c commit 5770cef
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 50 deletions.
4 changes: 2 additions & 2 deletions locales/base/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@
"protectWallet": {
"title": "Protect Your Wallet",
"subtitle": "Protect your wallet",
"body": "If your phone is lost or stolen, your {{mnemonicLength}} word recovery phrase is the only way you can access your funds.",
"body": "If your phone is lost or stolen, your 12 word recovery phrase is the only way you can access your funds.",
"recoveryPhrase": {
"title": "Use Recovery Phrase",
"subtitle": "Write down your recovery phrase"
}
},
"recoveryPhrase": {
"title": "Your recovery phrase",
"body": "Write these {{mnemonicLength}} words down somewhere safe, where it cannot be stolen or damaged.",
"body": "Write these 12 words down somewhere safe, where it cannot be stolen or damaged.",
"continue": "I've saved it",
"copy": "Copy to clipboard",
"mnemonicCopied": "Recovery phrase copied to clipboard",
Expand Down
1 change: 0 additions & 1 deletion src/app/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ export interface RemoteConfigValues {
maxSwapSlippagePercentage: number
networkTimeoutSeconds: number
celoNews: CeloNewsConfig
twelveWordMnemonicEnabled: boolean
priceImpactWarningThreshold: number
superchargeRewardContractAddress: string
}
Expand Down
1 change: 0 additions & 1 deletion src/firebase/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ export async function fetchRemoteConfigValues(): Promise<RemoteConfigValues | nu
maxSwapSlippagePercentage: flags.maxSwapSlippagePercentage.asNumber(),
networkTimeoutSeconds: flags.networkTimeoutSeconds.asNumber(),
celoNews: celoNewsString ? JSON.parse(celoNewsString) : {},
twelveWordMnemonicEnabled: flags.twelveWordMnemonicEnabled.asBoolean(),
// Convert to percentage, so we're consistent with the price impact value returned by our swap API
priceImpactWarningThreshold: flags.priceImpactWarningThreshold.asNumber() * 100,
superchargeRewardContractAddress: flags.superchargeRewardContractAddress.asString(),
Expand Down
1 change: 0 additions & 1 deletion src/firebase/remoteConfigValuesDefaults.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
maxSwapSlippagePercentage: 2,
networkTimeoutSeconds: 30,
celoNews: JSON.stringify({} as RemoteConfigValues['celoNews']),
twelveWordMnemonicEnabled: true,
priceImpactWarningThreshold: 0.04,
superchargeRewardContractAddress: '',
superchargeTokenConfigByToken: JSON.stringify(
Expand Down
1 change: 0 additions & 1 deletion src/firebase/remoteConfigValuesDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const REMOTE_CONFIG_VALUES_DEFAULTS: Omit<
maxSwapSlippagePercentage: 2,
networkTimeoutSeconds: 30,
celoNews: JSON.stringify({} as RemoteConfigValues['celoNews']),
twelveWordMnemonicEnabled: false,
priceImpactWarningThreshold: 0.04,
superchargeRewardContractAddress: '',
superchargeTokenConfigByToken: JSON.stringify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const mockScreenProps = getMockStackScreenProps(Screens.OnboardingRecoveryPhrase
describe('OnboardingRecoveryPhraseScreen', () => {
const store = createMockStore({
web3: {
twelveWordMnemonicEnabled: true,
account: '0xaccount',
},
})
Expand Down
9 changes: 2 additions & 7 deletions src/onboarding/registration/OnboardingRecoveryPhrase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useLayoutEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ScrollView, StyleSheet, Text, View } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import { useDispatch, useSelector } from 'react-redux'
import { useDispatch } from 'react-redux'
import { recoveryPhraseInOnboardingCompleted } from 'src/account/actions'
import { OnboardingEvents } from 'src/analytics/Events'
import ValoraAnalytics from 'src/analytics/ValoraAnalytics'
Expand All @@ -30,13 +30,10 @@ import { default as useTypedSelector } from 'src/redux/useSelector'
import colors from 'src/styles/colors'
import fontStyles from 'src/styles/fonts'
import Logger from 'src/utils/Logger'
import { twelveWordMnemonicEnabledSelector } from 'src/web3/selectors'

type Props = NativeStackScreenProps<StackParamList, Screens.OnboardingRecoveryPhrase>

function OnboardingRecoveryPhrase({ navigation }: Props) {
const twelveWordMnemonicEnabled = useSelector(twelveWordMnemonicEnabledSelector)
const mnemonicLength = twelveWordMnemonicEnabled ? '12' : '24'
const onboardingProps = useTypedSelector(onboardingPropsSelector)
const { step, totalSteps } = getOnboardingStepValues(Screens.ProtectWallet, onboardingProps)
const accountKey = useAccountKey()
Expand Down Expand Up @@ -89,9 +86,7 @@ function OnboardingRecoveryPhrase({ navigation }: Props) {
<SafeAreaView style={styles.container}>
<ScrollView contentContainerStyle={styles.contentContainer}>
<Text style={styles.recoveryPhraseTitle}>{t('recoveryPhrase.title')}</Text>
<Text style={styles.recoveryPhraseBody}>
{t('recoveryPhrase.body', { mnemonicLength })}
</Text>
<Text style={styles.recoveryPhraseBody}>{t('recoveryPhrase.body')}</Text>
<BackupPhraseContainer
readOnlyStyle={styles.backupPhrase}
value={accountKey}
Expand Down
2 changes: 0 additions & 2 deletions src/onboarding/registration/ProtectWallet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const mockScreenProps = getMockStackScreenProps(Screens.ProtectWallet)
describe('ProtectWalletScreen', () => {
const store = createMockStore({
web3: {
twelveWordMnemonicEnabled: true,
account: '0xaccount',
},
})
Expand All @@ -62,7 +61,6 @@ describe('ProtectWalletScreen', () => {
it('does not dispatch event if recoveryPhraseInOnboardingStatus is not NotStarted', async () => {
const mockStore = createMockStore({
web3: {
twelveWordMnemonicEnabled: true,
account: '0xaccount',
},
account: {
Expand Down
8 changes: 2 additions & 6 deletions src/onboarding/registration/ProtectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import colors from 'src/styles/colors'
import fontStyles from 'src/styles/fonts'
import variables from 'src/styles/variables'
import Logger from 'src/utils/Logger'
import { twelveWordMnemonicEnabledSelector, walletAddressSelector } from 'src/web3/selectors'
import { walletAddressSelector } from 'src/web3/selectors'

const TAG = 'ProtectWallet'

type Props = NativeStackScreenProps<StackParamList, Screens.ProtectWallet>

function ProtectWallet({ navigation }: Props) {
const twelveWordMnemonicEnabled = useSelector(twelveWordMnemonicEnabledSelector)
const mnemonicLength = twelveWordMnemonicEnabled ? '12' : '24'
const onboardingProps = useTypedSelector(onboardingPropsSelector)
const { step, totalSteps } = getOnboardingStepValues(Screens.ProtectWallet, onboardingProps)
const address = useSelector(walletAddressSelector)
Expand Down Expand Up @@ -91,9 +89,7 @@ function ProtectWallet({ navigation }: Props) {
<GuideKeyIcon />
</View>
<Text style={styles.protectWalletTitle}>{t('protectWallet.subtitle')}</Text>
<Text style={styles.protectWalletBody}>
{t('protectWallet.body', { mnemonicLength })}
</Text>
<Text style={styles.protectWalletBody}>{t('protectWallet.body')}</Text>
</View>
<View style={styles.cardSection}>
<OnboardingCard
Expand Down
4 changes: 4 additions & 0 deletions src/redux/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1601,4 +1601,8 @@ export const migrations = {
claimStatus: 'idle',
},
}),
197: (state: any) => ({
...state,
web3: _.omit(state.web3, 'twelveWordMnemonicEnabled'),
}),
}
3 changes: 1 addition & 2 deletions src/redux/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('store state', () => {
{
"_persist": {
"rehydrated": true,
"version": 196,
"version": 197,
},
"account": {
"acceptedTerms": false,
Expand Down Expand Up @@ -353,7 +353,6 @@ describe('store state', () => {
"dataEncryptionKey": "0x0000000000000000000000000000000000008F68",
"isDekRegistered": false,
"mtwAddress": null,
"twelveWordMnemonicEnabled": false,
},
}
`)
Expand Down
2 changes: 1 addition & 1 deletion src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const persistConfig: PersistConfig<RootState> = {
key: 'root',
// default is -1, increment as we make migrations
// See https://github.com/valora-inc/wallet/tree/main/WALLET.md#redux-state-migration
version: 196,
version: 197,
keyPrefix: `reduxStore-`, // the redux-persist default is `persist:` which doesn't work with some file systems.
storage: FSStorage(),
blacklist: ['networkInfo', 'alert', 'imports', 'keylessBackup', 'jumpstart'],
Expand Down
14 changes: 3 additions & 11 deletions src/web3/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Actions as AppActions, UpdateConfigValuesAction } from 'src/app/actions'
import { REMOTE_CONFIG_VALUES_DEFAULTS } from 'src/firebase/remoteConfigValuesDefaults'
import { getRehydratePayload, REHYDRATE, RehydrateAction } from 'src/redux/persist-helper'
import { Actions, ActionTypes } from 'src/web3/actions'
import { UpdateConfigValuesAction } from 'src/app/actions'
import { REHYDRATE, RehydrateAction, getRehydratePayload } from 'src/redux/persist-helper'
import { ActionTypes, Actions } from 'src/web3/actions'

export interface State {
account: string | null // this is the wallet address (EOA)
Expand All @@ -11,7 +10,6 @@ export interface State {
dataEncryptionKey: string | null
// Has the data encryption key been registered in the Accounts contract
isDekRegistered: boolean | undefined
twelveWordMnemonicEnabled: boolean
}

const initialState: State = {
Expand All @@ -20,7 +18,6 @@ const initialState: State = {
accountInWeb3Keystore: null,
dataEncryptionKey: null,
isDekRegistered: false,
twelveWordMnemonicEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.twelveWordMnemonicEnabled,
}

export const reducer = (
Expand Down Expand Up @@ -60,11 +57,6 @@ export const reducer = (
...state,
isDekRegistered: true,
}
case AppActions.UPDATE_REMOTE_CONFIG_VALUES:
return {
...state,
twelveWordMnemonicEnabled: action.configValues.twelveWordMnemonicEnabled,
}
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/web3/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe(getOrCreateAccount, () => {
])
.call(
generateMnemonic,
MnemonicStrength.s256_24words,
MnemonicStrength.s128_12words,
MnemonicLanguages[expectedMnemonicLang] as unknown as MnemonicLanguages,
bip39
)
Expand Down
6 changes: 1 addition & 5 deletions src/web3/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { createAccountDek } from 'src/web3/dataEncryptionKey'
import {
currentAccountSelector,
mtwAddressSelector,
twelveWordMnemonicEnabledSelector,
walletAddressSelector,
} from 'src/web3/selectors'
import { call, delay, put, select, spawn, take } from 'typed-redux-saga'
Expand Down Expand Up @@ -61,10 +60,7 @@ export function* getOrCreateAccount() {
try {
Logger.debug(TAG + '@getOrCreateAccount', 'Creating a new account')

const twelveWordMnemonicEnabled = yield* select(twelveWordMnemonicEnabledSelector)
const mnemonicBitLength = twelveWordMnemonicEnabled
? MnemonicStrength.s128_12words
: MnemonicStrength.s256_24words
const mnemonicBitLength = MnemonicStrength.s128_12words
const mnemonicLanguage = getMnemonicLanguage(yield* select(currentLanguageSelector))
let mnemonic: string = yield* call(generateMnemonic, mnemonicBitLength, mnemonicLanguage, bip39)

Expand Down
2 changes: 0 additions & 2 deletions src/web3/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export const currentAccountInWeb3KeystoreSelector = (state: RootState) =>
state.web3.accountInWeb3Keystore
export const dataEncryptionKeySelector = (state: RootState) => state.web3.dataEncryptionKey
export const isDekRegisteredSelector = (state: RootState) => state.web3.isDekRegistered
export const twelveWordMnemonicEnabledSelector = (state: RootState) =>
state.web3.twelveWordMnemonicEnabled
6 changes: 1 addition & 5 deletions test/RootStateSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4394,18 +4394,14 @@
"null",
"string"
]
},
"twelveWordMnemonicEnabled": {
"type": "boolean"
}
},
"required": [
"account",
"accountInWeb3Keystore",
"dataEncryptionKey",
"isDekRegistered",
"mtwAddress",
"twelveWordMnemonicEnabled"
"mtwAddress"
],
"type": "object"
},
Expand Down
11 changes: 10 additions & 1 deletion test/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3121,6 +3121,15 @@ export const v196Schema = {
},
}

export const v197Schema = {
...v196Schema,
_persist: {
...v196Schema._persist,
version: 197,
},
web3: _.omit(v196Schema.web3, 'twelveWordMnemonicEnabled'),
}

export function getLatestSchema(): Partial<RootState> {
return v196Schema as Partial<RootState>
return v197Schema as Partial<RootState>
}

0 comments on commit 5770cef

Please sign in to comment.