From f688a8d3dffa484719134ef77f48352aff7291a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Mon, 22 Mar 2021 19:46:49 -0300 Subject: [PATCH] bugfix/delete wallet with random password (#2422) * datenow * strinh * checkunlocked * setLocked * ok * p * gobackfirst * locale * mounted --- app/components/Views/Login/index.js | 3 ++- app/components/Views/QRScanner/index.js | 10 ++++++++++ locales/languages/en.json | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/components/Views/Login/index.js b/app/components/Views/Login/index.js index 35746a6ad0b..9ea55a275af 100644 --- a/app/components/Views/Login/index.js +++ b/app/components/Views/Login/index.js @@ -333,7 +333,8 @@ class Login extends PureComponent { const { KeyringController } = Engine.context; try { await Engine.resetState(); - await KeyringController.createNewVaultAndKeychain(''); + await KeyringController.createNewVaultAndKeychain(`${Date.now()}`); + await KeyringController.setLocked(); this.deleteExistingUser(); } catch (error) { Logger.log(error, `Failed to createNewVaultAndKeychain: ${error}`); diff --git a/app/components/Views/QRScanner/index.js b/app/components/Views/QRScanner/index.js index 9babcc8ccb3..f3ec800ea95 100644 --- a/app/components/Views/QRScanner/index.js +++ b/app/components/Views/QRScanner/index.js @@ -10,6 +10,7 @@ import { strings } from '../../../../locales/i18n'; import SharedDeeplinkManager from '../../../core/DeeplinkManager'; import AppConstants from '../../../core/AppConstants'; import { failedSeedPhraseRequirements, isValidMnemonic } from '../../../util/validators'; +import Engine from '../../../core/Engine'; const styles = StyleSheet.create({ container: { @@ -103,6 +104,15 @@ export default class QrScanner extends PureComponent { this.props.navigation.goBack(); } } else { + const { KeyringController } = Engine.context; + const isUnlocked = KeyringController.isUnlocked(); + + if (!isUnlocked) { + this.props.navigation.goBack(); + Alert.alert(strings('qr_scanner.error'), strings('qr_scanner.attempting_to_scan_with_wallet_locked')); + this.mounted = false; + return; + } // Let ethereum:address go forward if (content.split('ethereum:').length > 1 && !parse(content).function_name) { this.shouldReadBarCode = false; diff --git a/locales/languages/en.json b/locales/languages/en.json index 9e1c8a2c5b2..4cb6cdb65a2 100644 --- a/locales/languages/en.json +++ b/locales/languages/en.json @@ -579,6 +579,7 @@ "ok": "Ok", "cancel": "Cancel", "error": "Error", + "attempting_to_scan_with_wallet_locked": "Looks like you're trying to scan a QR code, you need to unlock your wallet to be able to use it.", "attempting_sync_from_wallet_error": "Looks like you're trying to sync with the extension. In order to do so, you will need to erase your current wallet. \n\nOnce you've erased or reinstalled a fresh version of the app, select the option to \"Sync with MetaMask Extension\". Important! Before erasing your wallet, make sure you've backed up your recovery phrase." }, "action_view": {