From a901e2379e6d455eedea5491c64ecf076a6da49f Mon Sep 17 00:00:00 2001 From: Patrick Tajima Date: Thu, 5 May 2022 16:13:01 -0700 Subject: [PATCH] fix: Handle failed importZeroBalanceAccount --- .../accounts/RecoverAccountSeedPhrase.js | 17 +++++++++++++---- .../frontend/src/translations/en.global.json | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/accounts/RecoverAccountSeedPhrase.js b/packages/frontend/src/components/accounts/RecoverAccountSeedPhrase.js index 793df6ec5c..20cfa1faa3 100644 --- a/packages/frontend/src/components/accounts/RecoverAccountSeedPhrase.js +++ b/packages/frontend/src/components/accounts/RecoverAccountSeedPhrase.js @@ -158,10 +158,19 @@ class RecoverAccountSeedPhrase extends Component { const { secretKey } = parseSeedPhrase(seedPhrase); const recoveryKeyPair = KeyPair.fromString(secretKey); const implicitAccountId = Buffer.from(recoveryKeyPair.publicKey.data).toString('hex'); - await wallet.importZeroBalanceAccount(implicitAccountId, recoveryKeyPair); - this.props.refreshAccount(); - this.props.redirectTo('/'); - this.props.clearGlobalAlert(); + try { + await wallet.importZeroBalanceAccount(implicitAccountId, recoveryKeyPair); + this.props.refreshAccount(); + this.props.redirectTo('/'); + this.props.clearGlobalAlert(); + } catch (e) { + this.props.showCustomAlert({ + success: false, + messageCodeHeader: 'error', + messageCode: 'walletErrorCodes.recoverAccountSeedPhrase.errorNotAbleToImportAccount', + errorMessage: e.message + }); + } }} onClose={() => this.setState({ showCouldNotFindAccountModal: false })} isOpen={showCouldNotFindAccountModal} diff --git a/packages/frontend/src/translations/en.global.json b/packages/frontend/src/translations/en.global.json index 515ef2a381..06e8496a89 100644 --- a/packages/frontend/src/translations/en.global.json +++ b/packages/frontend/src/translations/en.global.json @@ -1708,7 +1708,8 @@ }, "recoverAccountSeedPhrase": { "errorInvalidSeedPhrase": "No accounts were found for this passphrase.", - "errorSeedPhraseNotValid": "The provided passphrase is not valid. Please check your passphrase and try again." + "errorSeedPhraseNotValid": "The provided passphrase is not valid. Please check your passphrase and try again.", + "errorNotAbleToImportAccount": "Import of your account failed. Please try again or contact support for assistance." }, "recoveryMethods": { "lastMethod": "Cannot delete your last recovery method. Unless you have Ledger enabled, you need to keep at least one recovery method active to ensure recoverability of your account.",