Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: new wallets only created with english mnemonics #5064

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/web3/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ describe(getOrCreateAccount, () => {
it.each`
appLang | expectedMnemonicLang
${'en-US'} | ${MnemonicLanguages[MnemonicLanguages.english]}
${'es-419'} | ${MnemonicLanguages[MnemonicLanguages.spanish]}
${'pt-BR'} | ${MnemonicLanguages[MnemonicLanguages.portuguese]}
${'es-419'} | ${MnemonicLanguages[MnemonicLanguages.english]}
${'pt-BR'} | ${MnemonicLanguages[MnemonicLanguages.english]}
${'incorrect-lang'} | ${MnemonicLanguages[MnemonicLanguages.english]}
`(
'creates an account with a mnemonic in $expectedMnemonicLang when app language is $appLang',
Expand Down
14 changes: 9 additions & 5 deletions src/web3/saga.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { generateMnemonic, MnemonicStrength } from '@celo/cryptographic-utils'
import { generateMnemonic, MnemonicLanguages, MnemonicStrength } from '@celo/cryptographic-utils'
import { privateKeyToAddress } from '@celo/utils/lib/address'
import { UnlockableWallet } from '@celo/wallet-base'
import { RpcWalletErrors } from '@celo/wallet-rpc/lib/rpc-wallet'
import * as bip39 from 'react-native-bip39'
import { setAccountCreationTime } from 'src/account/actions'
import { generateSignedMessage } from 'src/account/saga'
import { ErrorMessages } from 'src/app/ErrorMessages'
import { generateKeysFromMnemonic, getMnemonicLanguage, storeMnemonic } from 'src/backup/utils'
import { currentLanguageSelector } from 'src/i18n/selectors'
import { generateKeysFromMnemonic, storeMnemonic } from 'src/backup/utils'
import {
CANCELLED_PIN_INPUT,
getPasswordSaga,
Expand Down Expand Up @@ -61,8 +60,13 @@ export function* getOrCreateAccount() {
Logger.debug(TAG + '@getOrCreateAccount', 'Creating a new account')

const mnemonicBitLength = MnemonicStrength.s128_12words
const mnemonicLanguage = getMnemonicLanguage(yield* select(currentLanguageSelector))
let mnemonic: string = yield* call(generateMnemonic, mnemonicBitLength, mnemonicLanguage, bip39)
const mnemonicLanguage = MnemonicLanguages.english
let mnemonic: string = yield* call(
generateMnemonic,
mnemonicBitLength,
MnemonicLanguages.english,
bip39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be set to mnemonicLanguage? since it is set as english in the lines above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b9d9e56!

)

// Ensure no duplicates in mnemonic
const checkDuplicate = (someString: string) => {
Expand Down
Loading