classic-ui/modules/account/store/actions/recoverAccountFromChain/decryptAccount.js

15 lines
524 B
JavaScript
Raw Normal View History

2022-04-21 23:05:56 -04:00
import { getEncryptionPublicKey } from 'eth-sig-util'
export async function decryptAccount({ dispatch }, encryptedAccount) {
try {
const privateKey = await dispatch('metamask/ethDecrypt', encryptedAccount, { root: true })
const publicKey = getEncryptionPublicKey(privateKey)
const { address } = await this.$provider.web3.eth.accounts.privateKeyToAccount(privateKey)
return { address, publicKey, privateKey }
} catch (err) {
throw new Error(`Method decryptAccount has error: ${err.message}`)
}
}