classic-ui/modules/account/store/actions/recoverAccountFromChain/recoverAccountFromChain.js
FreezyEx b32527e057 Revert "minor fixes"
This reverts commit 7f8f7c2aa15c8b8c6a7449d177f46f8a417e2f67.
2022-10-13 16:03:54 +02:00

14 lines
567 B
JavaScript

export async function recoverAccountFromChain({ dispatch, rootState }) {
const { ethAccount } = rootState.metamask
try {
const { encryptedKey, backup } = await dispatch('getAccountFromAddress', ethAccount)
const { address, publicKey, privateKey } = await dispatch('decryptAccount', encryptedKey)
this.$sessionStorage.setItem(address, privateKey)
dispatch('saveAccount', { account: { publicKey, privateKey: encryptedKey }, address, backup })
} catch (err) {
throw new Error(`Method recoverAccountFromChain has error: ${err.message}`)
}
}