From cd5167b3e4311ef3d4eae54807f5dfeb51761fa5 Mon Sep 17 00:00:00 2001 From: Patrick Tajima Date: Fri, 11 Mar 2022 17:27:16 -0800 Subject: [PATCH] fix: review changes --- .../accounts/import/ImportAccountWithLink.js | 4 ++-- .../src/routes/ImportAccountWithLinkWrapper.js | 16 ++++++---------- packages/frontend/src/utils/helper-api.js | 3 +-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/frontend/src/components/accounts/import/ImportAccountWithLink.js b/packages/frontend/src/components/accounts/import/ImportAccountWithLink.js index e350f7378b..459b3cad72 100644 --- a/packages/frontend/src/components/accounts/import/ImportAccountWithLink.js +++ b/packages/frontend/src/components/accounts/import/ImportAccountWithLink.js @@ -99,7 +99,7 @@ export default ({ const numberOfAccountsFound = accountsBySeedPhrase.length; const getAccountsStatus = () => { - if (numberOfAccountsFound === 1 && accountsBySeedPhrase[0].imported === true) { + if (numberOfAccountsFound === 1 && accountsBySeedPhrase[0].imported) { return

; } @@ -119,7 +119,7 @@ export default ({

  - +   diff --git a/packages/frontend/src/routes/ImportAccountWithLinkWrapper.js b/packages/frontend/src/routes/ImportAccountWithLinkWrapper.js index 469fa05320..fd7c4fa298 100644 --- a/packages/frontend/src/routes/ImportAccountWithLinkWrapper.js +++ b/packages/frontend/src/routes/ImportAccountWithLinkWrapper.js @@ -22,7 +22,7 @@ export function ImportAccountWithLinkWrapper() { const activeAccountId = useSelector(selectAccountId); const availableAccounts = useSelector(selectAvailableAccounts); const [accountIdsBySeedPhrase, setAccountIdsBySeedPhrase] = useState([]); - const [importingAccount, setImportingAccount] = useState(false); + const [importingAccount, setImportingAccount] = useState(null); useEffect(() => { const handleGetAccountsBySeedPhrase = async () => { @@ -32,14 +32,10 @@ export function ImportAccountWithLinkWrapper() { handleGetAccountsBySeedPhrase(); }, []); - let accountsBySeedPhrase = []; - - for (let accountId of accountIdsBySeedPhrase) { - let account = {}; - account.accountId = accountId; - account.imported = availableAccounts.includes(accountId); - accountsBySeedPhrase.push(account); - } + const accountsBySeedPhrase = accountIdsBySeedPhrase.map((accountId) => ({ + accountId, + imported: availableAccounts.includes(accountId), + })); return ( diff --git a/packages/frontend/src/utils/helper-api.js b/packages/frontend/src/utils/helper-api.js index 2b97b0084e..52c889dd1e 100644 --- a/packages/frontend/src/utils/helper-api.js +++ b/packages/frontend/src/utils/helper-api.js @@ -15,8 +15,7 @@ export async function getAccountIdsBySeedPhrase(seedPhrase) { const { secretKey } = parseSeedPhrase(seedPhrase); const keyPair = nearApiJs.KeyPair.fromString(secretKey); const publicKey = keyPair.publicKey.toString(); - const accountIdsByPublickKey = await getAccountIds(publicKey); - return accountIdsByPublickKey; + return getAccountIds(publicKey); } export function isUrlNotJavascriptProtocol(url) {