diff --git a/features/flags.json b/features/flags.json index 0e368546d5..769b9e7c97 100644 --- a/features/flags.json +++ b/features/flags.json @@ -285,7 +285,6 @@ "enabled": false, "lastEditedBy": "Patrick Tajima", "lastEditedAt": "2022-05-06T17:30:49.430Z" - }, "testnet_STAGING": { "enabled": false, diff --git a/packages/frontend/src/components/profile/zero_balance/ZeroBalanceAccountWrapper.js b/packages/frontend/src/components/profile/zero_balance/ZeroBalanceAccountWrapper.js index 708db81057..6f2fa15b92 100644 --- a/packages/frontend/src/components/profile/zero_balance/ZeroBalanceAccountWrapper.js +++ b/packages/frontend/src/components/profile/zero_balance/ZeroBalanceAccountWrapper.js @@ -30,7 +30,7 @@ export function ZeroBalanceAccountWrapper() { if (isLedgerKey) { handleCheckLedgerStatus(); } else { - handleAddLocalAccessKeyPhrase(); + handleAddLocalAccessKey('phrase'); } } }, [accountExists]); @@ -42,44 +42,24 @@ export function ZeroBalanceAccountWrapper() { } }; - const handleAddLocalAccessKeyLedger = async () => { - try { - await dispatch(finishLocalSetupForZeroBalanceAccount({ - implicitAccountId: accountId, - recoveryMethod: 'ledger', - })); - dispatch(showCustomAlert({ - success: true, - messageCodeHeader: 'zeroBalance.addLedgerKey.success.header', - messageCode: 'zeroBalance.addLedgerKey.success.message' - })); - } catch (e) { - dispatch(showCustomAlert({ - success: false, - messageCodeHeader: 'zeroBalance.addLedgerKey.error.header', - messageCode: 'zeroBalance.addLedgerKey.error.message', - })); - } - - dispatch(refreshAccount()); - }; + const handleAddLocalAccessKey = async (recoveryMethod) => { + const translationId = recoveryMethod === 'ledger' ? 'addLedgerKey' : 'addPhraseKey'; - const handleAddLocalAccessKeyPhrase = async () => { try { await dispatch(finishLocalSetupForZeroBalanceAccount({ implicitAccountId: accountId, - recoveryMethod: 'phrase', + recoveryMethod, })); dispatch(showCustomAlert({ success: true, - messageCodeHeader: 'zeroBalance.addPhraseKey.success.header', - messageCode: 'zeroBalance.addPhraseKey.success.message' + messageCodeHeader: `zeroBalance.${translationId}.success.header`, + messageCode: `zeroBalance.${translationId}.success.message` })); } catch (e) { dispatch(showCustomAlert({ success: false, - messageCodeHeader: 'zeroBalance.addPhraseKey.error.header', - messageCode: 'zeroBalance.addPhraseKey.error.message', + messageCodeHeader: `zeroBalance.${translationId}.error.header`, + messageCode: `zeroBalance.${translationId}.error.message`, })); } @@ -97,7 +77,7 @@ export function ZeroBalanceAccountWrapper() { dispatch(handleShowConnectModal()); } else { setFinishingLedgerKeySetup(true); - await handleAddLocalAccessKeyLedger(); + await handleAddLocalAccessKey('ledger'); setShowAddLedgerKeyModal(false); setFinishingLedgerKeySetup(false); }