Skip to content

Commit 39a92d8

Browse files
committed
fix: wallet privatekey import fix
1 parent fb65c22 commit 39a92d8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/keyring-controller/src/KeyringController.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,19 @@ export class KeyringController extends BaseController<
941941
privateKey = remove0x(prefixed);
942942
break;
943943
case 'json':
944-
let wallet;
945-
const [input, password] = args;
946-
try {
947-
wallet = importers.fromEtherWallet(input, password);
948-
} catch (e) {
949-
wallet = wallet || (await Wallet.fromV3(input, password, true));
944+
{
945+
const getWallet = async (): Promise<Wallet> => {
946+
const [input, password] = args;
947+
try {
948+
return importers.fromEtherWallet(input, password);
949+
} catch (e) {
950+
return Wallet.fromV3(input, password, true);
951+
}
950952
}
953+
const wallet = await getWallet();
951954
privateKey = bytesToHex(wallet.getPrivateKey());
952955
break;
956+
}
953957
default:
954958
throw new Error(`Unexpected import strategy: '${strategy}'`);
955959
}

0 commit comments

Comments
 (0)