From ec71d775940e0db3e03e4e80b5c895827550670f Mon Sep 17 00:00:00 2001 From: esaminu Date: Fri, 21 Jan 2022 05:01:19 +0400 Subject: [PATCH] fix: redirect to fund-with-existing-account if active implicit account --- .../frontend/src/redux/actions/account.js | 10 ++++-- .../frontend/src/translations/en.global.json | 32 +++++++++---------- packages/frontend/src/utils/account.js | 5 ++- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/packages/frontend/src/redux/actions/account.js b/packages/frontend/src/redux/actions/account.js index 9e664d1957..c4e427aa38 100644 --- a/packages/frontend/src/redux/actions/account.js +++ b/packages/frontend/src/redux/actions/account.js @@ -4,9 +4,11 @@ import { } from 'connected-react-router'; import { PublicKey, KeyType } from 'near-api-js/lib/utils/key_pair'; import { parse, stringify } from 'query-string'; +import { compose } from 'redux'; import { createActions, createAction } from 'redux-actions'; import { DISABLE_CREATE_ACCOUNT } from '../../config'; +import { isImplicitAccount } from '../../utils/account'; import { showAlert, dispatchWithAlert @@ -470,9 +472,13 @@ const handleFundCreateAccountRedirect = ({ accountId, implicitAccountId, recoveryMethod -}) => (dispatch) => { +}) => (dispatch, getState) => { + const hasActiveImplicitAccount = compose(isImplicitAccount, selectAccountId, getState); + if (ENABLE_IDENTITY_VERIFIED_ACCOUNT) { - dispatch(redirectTo(`/verify-account?accountId=${accountId}&implicitAccountId=${implicitAccountId}&recoveryMethod=${recoveryMethod}`)); + const route = hasActiveImplicitAccount() ? '/fund-with-existing-account' : '/verify-account'; + const search = `?accountId=${accountId}&implicitAccountId=${implicitAccountId}&recoveryMethod=${recoveryMethod}`; + dispatch(redirectTo(route + search)); } else { dispatch(redirectTo(`/fund-create-account/${accountId}/${implicitAccountId}/${recoveryMethod}`)); } diff --git a/packages/frontend/src/translations/en.global.json b/packages/frontend/src/translations/en.global.json index 17512a3d0e..32f1b5df81 100644 --- a/packages/frontend/src/translations/en.global.json +++ b/packages/frontend/src/translations/en.global.json @@ -66,18 +66,18 @@ } }, "createImplicitAccount": { + "createCustomNameModal": { + "desc": "Unlike your default address, a custom address can be anything you like, making it easier to remember and share!", + "title": "Add a Custom Address to Your Wallet" + }, + "customAddress": "A custom address can be anything you like, making it easier to remember and share!", "customAmount": "Custom", - "sendFrom": "Send from an", "exchange": "exchange", "orAskFriend": "or ask a friend!", - "title": "Almost there! To get started, buy some NEAR using MoonPay...", - "titleAlt": "Almost there! To get started, send at least ${amount} NEAR to your wallet address.", "orSendNear": "...or send at least ${amount} NEAR to your wallet address.", - "customAddress": "A custom address can be anything you like, making it easier to remember and share!", - "createCustomNameModal": { - "desc": "Unlike your default address, a custom address can be anything you like, making it easier to remember and share!", - "title": "Add a Custom Address to Your Wallet" - } + "sendFrom": "Send from an", + "title": "Almost there! To get started, buy some NEAR using MoonPay...", + "titleAlt": "Almost there! To get started, send at least ${amount} NEAR to your wallet address." }, "fundedStatus": { "active": "Active", @@ -184,6 +184,7 @@ }, "button": { "acceptAndContinue": "Accept & Continue", + "addACustomAddress": "Add a Custom Address", "addFunds": "Add Funds", "addNode": "Add Node", "allow": "Allow", @@ -206,8 +207,8 @@ "continue": "Continue", "continueSetup": "Continue to Setup", "continueToMyAccount": "Continue to My Account", - "copyImplicitAddress": "Copy Funding Address", "copy": "Copy", + "copyImplicitAddress": "Copy Funding Address", "copyPhrase": "Copy Phrase", "copyUrl": "Copy URL", "createAccount": "Create Account", @@ -244,7 +245,6 @@ "recoverAccount": "Recover Account", "recovering": "Finding Account", "recoverYourAccount": "Recover your Account", - "addACustomAddress": "Add a Custom Address", "removeNode": "Remove Node", "removingKeys": "Removing Keys", "reserveMyAccountId": "Reserve My Account ID", @@ -1119,10 +1119,10 @@ "pageTitle": "Recovery Setup is Complete" }, "setupSeedPhraseVerify": { + "inputError": "Please check your passphrase and try again.", "pageText": "Enter the following word from your recovery phrase to complete the setup process.", "pageTitle": "Verify Phrase", - "startOverText": "Didn't write it down?", - "inputError": "Please check your passphrase and try again." + "startOverText": "Didn't write it down?" }, "sign": { "ActionWarrning": { @@ -1160,12 +1160,12 @@ "networkFees": "Network Fees", "nothingHasBeenTransferred": "Nothing has been transferred.", "retry": { + "estimatedFees": "Estimated Fees", + "feeLimit": "Fee Limit", "link": "What is the fee limit?", "networkFees": "Network Fees", "text": "The default network fee was not enough to cover the cost of your transaction.

You may resubmit the transaction to have its fee limit automatically increased.", - "title": "Insufficient Network Fee", - "estimatedFees": "Estimated Fees", - "feeLimit": "Fee Limit" + "title": "Insufficient Network Fee" }, "transactionCancelled": "Transaction cancelled", "transactionDetails": "Transaction Details", @@ -1531,4 +1531,4 @@ } }, "warning": "Warning" -} \ No newline at end of file +} diff --git a/packages/frontend/src/utils/account.js b/packages/frontend/src/utils/account.js index 7b9539b4a8..8383959813 100644 --- a/packages/frontend/src/utils/account.js +++ b/packages/frontend/src/utils/account.js @@ -3,4 +3,7 @@ export const validateEmail = (email) => { /* Checks for anystring@anystring.anystring */ let re = /\S+@\S+\.\S+/; return re.test(email); -}; \ No newline at end of file +}; + +export const isImplicitAccount = (accountId) => + accountId && accountId.length === 64 && !accountId.includes(".") || true; \ No newline at end of file