Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
form.validateFields(async (err, values) => {
if (err || !values || !values.password || !values.keystore) {
this.setState({ isDecrypting: false });
return;
}
const { password, keystore } = values;
try {
const keyObj = JSON.parse(keystore);
const { privateKey } = decrypt(keyObj, password);
const antenna = getAntenna(true);
const account = await antenna.iotx.accounts.privateKeyToAccount(
privateKey
);
this.props.dispatch(setAccount(account));
} catch (e) {
const msg = String(e);
if (msg.indexOf("SyntaxError") !== -1) {
notification.error({
message: t("input.error.keystore.invalid"),
duration: 5
});
} else if (msg.indexOf("derivation failed")) {
notification.error({
message: t("input.error.keystore.failed_to_derive"),
duration: 5