From c93b566c222768beadb895b62c383ae17dfd4d46 Mon Sep 17 00:00:00 2001 From: Danny Cho Date: Wed, 29 Mar 2023 14:03:51 +1300 Subject: [PATCH 1/2] fix: sending correct private key on export to another wallet --- .../components/wallet-migration/WalletMigration.jsx | 2 +- .../WalletSelectorModal/WalletSelectorModal.jsx | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/wallet-migration/WalletMigration.jsx b/packages/frontend/src/components/wallet-migration/WalletMigration.jsx index b566cfa56c..3db1089886 100644 --- a/packages/frontend/src/components/wallet-migration/WalletMigration.jsx +++ b/packages/frontend/src/components/wallet-migration/WalletMigration.jsx @@ -95,7 +95,6 @@ const WalletMigration = ({ open, onClose }) => { }; const navigateToMigrateAccounts = () => { - setMigrationStep(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS); handleSetActiveView(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS); }; @@ -173,6 +172,7 @@ const WalletMigration = ({ open, onClose }) => { onComplete={navigateToRedirect} migrationAccounts={accountWithDetails} network={NETWORK_ID === 'default' ? 'testnet': NETWORK_ID} + rotatedKeys={rotatedKeys} /> )} {state.activeView === WALLET_MIGRATION_VIEWS.REDIRECTING && ( diff --git a/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx b/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx index 7c7e962046..7b57c873c4 100644 --- a/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx +++ b/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx @@ -1,18 +1,21 @@ import React, { useEffect, useState } from 'react'; -import { wallet } from '../../../../utils/wallet'; import { WalletSelectorContent } from './WalletSelectorContent'; import { ExportAccountSelectorContextProvider } from './WalletSelectorExportContext'; -export const WalletSelectorModal = ({ onComplete, migrationAccounts, network }) => { +export const WalletSelectorModal = ({ onComplete, migrationAccounts, network, rotatedKeys }) => { const [accounts, setAccounts] = useState([]); useEffect(() => { const init = async () => { const accountsWithKey = await Promise.all(migrationAccounts.map(async (account) => { - const localKey = await wallet.getLocalSecretKey(account.accountId); + const privateKey = rotatedKeys[account.accountId]; + if (!privateKey) { + throw new Error('Unable to find a private key from the rotated keys'); + } + return { accountId: account.accountId, - privateKey: localKey, + privateKey: rotatedKeys[account.accountId], }; })); setAccounts(accountsWithKey); From 4dd237130969c156fa189d8602765f52471ed533 Mon Sep 17 00:00:00 2001 From: Danny Cho Date: Wed, 29 Mar 2023 14:11:30 +1300 Subject: [PATCH 2/2] chore: syntax improvement --- .../modals/WalletSelectorModal/WalletSelectorModal.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx b/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx index 7b57c873c4..f5781bfede 100644 --- a/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx +++ b/packages/frontend/src/components/wallet-migration/modals/WalletSelectorModal/WalletSelectorModal.jsx @@ -8,14 +8,15 @@ export const WalletSelectorModal = ({ onComplete, migrationAccounts, network, ro useEffect(() => { const init = async () => { const accountsWithKey = await Promise.all(migrationAccounts.map(async (account) => { - const privateKey = rotatedKeys[account.accountId]; + const accountId = account.accountId; + const privateKey = rotatedKeys[accountId]; if (!privateKey) { throw new Error('Unable to find a private key from the rotated keys'); } return { - accountId: account.accountId, - privateKey: rotatedKeys[account.accountId], + accountId, + privateKey, }; })); setAccounts(accountsWithKey);