Skip to content

Commit

Permalink
fix: wallet privatekey import fix-n
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Apr 18, 2024
1 parent 346de6a commit 3736bba
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,13 +1055,15 @@ export class KeyringController extends BaseController<
privateKey = remove0x(prefixed);
break;
case 'json':
let wallet;
const [input, password] = args;
try {
wallet = importers.fromEtherWallet(input, password);
} catch (e) {
wallet = wallet || (await Wallet.fromV3(input, password, true));
}
const getWallet = async () => {
try {
return await importers.fromEtherWallet(input, password);
} catch (e) {
return await Wallet.fromV3(input, password, true);
}
};
const wallet: Wallet = await getWallet();
privateKey = bytesToHex(wallet.getPrivateKey());
break;
default:
Expand Down

0 comments on commit 3736bba

Please sign in to comment.