Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'JSON File': (input, password) => {
let wallet
try {
wallet = importers.fromEtherWallet(input, password)
} catch (e) {
console.log('Attempt to import as EtherWallet format failed, trying V3...')
}
if (!wallet) {
wallet = Wallet.fromV3(input, password, true)
}
return walletToPrivateKey(wallet)
},
},
const MewV1Wallet = (keystore, password) => signWrapper(fromEtherWallet(keystore, password));
const MewV1Wallet = (keystore: string, password: string) =>
signWrapper(fromEtherWallet(keystore, password));
case 'privateKey':
const [importedKey] = args;
if (!importedKey) {
throw new Error('Cannot import an empty key.');
}
const prefixed = ethUtil.addHexPrefix(importedKey);
if (!ethUtil.isValidPrivate(ethUtil.toBuffer(prefixed))) {
throw new Error('Cannot import invalid private key.');
}
privateKey = ethUtil.stripHexPrefix(prefixed);
break;
case 'json':
let wallet;
const [input, password] = args;
try {
wallet = importers.fromEtherWallet(input, password);
} catch (e) {
wallet = wallet || Wallet.fromV3(input, password, true);
}
privateKey = ethUtil.bufferToHex(wallet.getPrivateKey());
break;
}
const newKeyring = await privates.get(this).keyring.addNewKeyring(KeyringTypes.simple, [privateKey]);
const accounts = await newKeyring.getAccounts();
const allAccounts = await privates.get(this).keyring.getAccounts();
preferences.updateIdentities(allAccounts);
preferences.update({ selectedAddress: accounts[0] });
return this.fullUpdate();
}
const MewV1Wallet = (keystore: string, password: string) =>
signWrapper(fromEtherWallet(keystore, password));