Skip to content

Commit 3736bba

Browse files
committed
fix: wallet privatekey import fix-n
1 parent 346de6a commit 3736bba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/keyring-controller/src/KeyringController.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1055,13 +1055,15 @@ export class KeyringController extends BaseController<
10551055
privateKey = remove0x(prefixed);
10561056
break;
10571057
case 'json':
1058-
let wallet;
10591058
const [input, password] = args;
1060-
try {
1061-
wallet = importers.fromEtherWallet(input, password);
1062-
} catch (e) {
1063-
wallet = wallet || (await Wallet.fromV3(input, password, true));
1064-
}
1059+
const getWallet = async () => {
1060+
try {
1061+
return await importers.fromEtherWallet(input, password);
1062+
} catch (e) {
1063+
return await Wallet.fromV3(input, password, true);
1064+
}
1065+
};
1066+
const wallet: Wallet = await getWallet();
10651067
privateKey = bytesToHex(wallet.getPrivateKey());
10661068
break;
10671069
default:

0 commit comments

Comments
 (0)