Skip to content

Commit

Permalink
Merge pull request #3031 from near/account-export-wrong-key
Browse files Browse the repository at this point in the history
Bug fix on account export sending wrong private key
  • Loading branch information
andy-haynes authored Mar 29, 2023
2 parents 9b6c5d2 + 4dd2371 commit 8ac57c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const WalletMigration = ({ open, onClose }) => {
};

const navigateToMigrateAccounts = () => {
setMigrationStep(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS);
handleSetActiveView(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS);
};

Expand Down Expand Up @@ -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 && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
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 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: localKey,
accountId,
privateKey,
};
}));
setAccounts(accountsWithKey);
Expand Down

0 comments on commit 8ac57c3

Please sign in to comment.