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

37 lines
1.1 KiB
JavaScript

export async function decryptNotes({ commit, dispatch }) {
try {
dispatch('loading/enable', { message: this.app.i18n.t('startDecryptingNotes') }, { root: true })
const privateKey = await dispatch('getRecoveryKey', false)
if (!privateKey) {
return
}
const events = await dispatch('application/getEncryptedNotes', {}, { root: true })
const { transactions, statistic, unSpent } = await dispatch('_encryptFormatTx', { events, privateKey })
const checkedTxs = await dispatch('_checkCurrentTx', transactions)
checkedTxs.forEach((tx) => {
commit('txHashKeeper/SAVE_TX_HASH', tx, { root: true })
})
dispatch('createMutation', { type: 'SET_STATISTIC', payload: { statistic } })
return {
unSpent,
spent: checkedTxs.length ? checkedTxs.length - unSpent : 0,
all: events.length ? events.length - 1 : 0
}
} catch (err) {
dispatch('createMutation', {
type: 'SET_DOMAIN_FAILED',
payload: { key: 'decryptNotes', errorMessage: err.message }
})
} finally {
dispatch('loading/disable', {}, { root: true })
}
}