From 3736bba361e5535e03e30aff239c2900e5bc60fd Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 18 Apr 2024 23:57:41 +0000 Subject: [PATCH] fix: wallet privatekey import fix-n --- .../keyring-controller/src/KeyringController.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 9b1d1d26a50..aa9b73eafe7 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -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: