Commit f10cc5b4 authored by Bitcoin Please's avatar Bitcoin Please
Browse files

Refactored store to use "hex" strings for persistent storage.

parent f7ddf799
......@@ -15,7 +15,7 @@ const getAsset = (state) => (_ownerSlug, _assetId) => {
}
/* Set owner. */
const owner = msgpack.decode(Buffer.from(state.assets[_ownerSlug]))
const owner = msgpack.decode(Buffer.from(state.assets[_ownerSlug], 'hex'))
// console.log('GET ASSET (owner):', owner)
/* Validate owner. */
......
......@@ -37,7 +37,7 @@ const setAsset = (state, _asset) => {
}
/* Update the asset resource. */
state.assets[ownerSlug][id] = msgpack.encode(body)
state.assets[ownerSlug][id] = msgpack.encode(body).toString('hex')
}
/* Export module. */
......
......@@ -24,7 +24,7 @@ const initProfile = async ({ state, commit }) => {
* We MUST properly evaluate ANY and ALL weaknesses with
* using randomBytes via a ("mobile") web browser.
*/
const masterSeed = Nito.Crypto.randomBytes(32).toString('hex')
const masterSeed = Nito.Crypto.randomBytes(32)
/* Set new master (private) key. */
commit('setMasterSeed', masterSeed)
......
......@@ -11,7 +11,7 @@ const getEmail = (state) => {
}
/* Return email. */
return msgpack.decode(Buffer.from(state.email))
return msgpack.decode(Buffer.from(state.email, 'hex'))
}
/* Export module. */
......
......@@ -11,7 +11,11 @@ const getMasterSeed = (state) => {
}
/* Return master seed. */
return msgpack.decode(Buffer.from(state.masterSeed))
try {
return Buffer.from(state.masterSeed, 'hex')
} catch (err) {
return msgpack.decode(Buffer.from(state.masterSeed)) // DEPRECATED on 2020.7.6
}
}
/* Export module. */
......
......@@ -11,7 +11,7 @@ const getNickname = (state) => {
}
/* Return nickname. */
return msgpack.decode(Buffer.from(state.nickname))
return msgpack.decode(Buffer.from(state.nickname, 'hex'))
}
/* Export module. */
......
......@@ -8,7 +8,7 @@ const msgpack = require('msgpack-lite')
*/
const setEmail = (state, _email) => {
/* Set email. */
state.email = msgpack.encode(_email)
state.email = msgpack.encode(_email).toString('hex')
}
/* Export module. */
......
/* Import modules. */
const msgpack = require('msgpack-lite')
/**
* Set Master Seed
*
......@@ -8,7 +5,7 @@ const msgpack = require('msgpack-lite')
*/
const setMasterSeed = (state, _seed) => {
/* Set master seed. */
state.masterSeed = msgpack.encode(_seed)
state.masterSeed = Buffer.from(_seed).toString('hex')
}
/* Export module. */
......
......@@ -8,7 +8,7 @@ const msgpack = require('msgpack-lite')
*/
const setNickname = (state, _nickname) => {
/* Set nickname. */
state.nickname = msgpack.encode(_nickname)
state.nickname = msgpack.encode(_nickname).toString('hex')
}
/* Export module. */
......
......@@ -9,8 +9,6 @@ import getHelp from './system/getters/getHelp'
import getLocale from './system/getters/getLocale'
/* Import modules (actions). */
import displayError from './system/actions/displayError'
import displayNotification from './system/actions/displayNotification'
import updateAssetSource from './system/actions/updateAssetSource'
import updateFlags from './system/actions/updateFlags'
import updateLocale from './system/actions/updateLocale'
......@@ -18,10 +16,8 @@ import updateLocale from './system/actions/updateLocale'
/* Import modules (mutations). */
import setAppStarts from './system/mutations/setAppStarts'
import setAssetSource from './system/mutations/setAssetSource'
import setError from './system/mutations/setError'
import setFlags from './system/mutations/setFlags'
import setLocale from './system/mutations/setLocale'
import setNotification from './system/mutations/setNotification'
/* Initialize state. */
const state = {
......@@ -52,11 +48,6 @@ const state = {
*/
authHashes: null,
/**
* Error Message
*/
errorMsg: null,
/**
* Flags
*
......@@ -85,11 +76,6 @@ const state = {
*/
notices: null,
/**
* Notification Message
*/
notifMsg: null,
/**
* Schema Version
*
......@@ -109,8 +95,6 @@ const getters = {
/* Actions. */
const actions = {
displayError,
displayNotification,
updateAssetSource,
updateFlags,
updateLocale,
......@@ -120,10 +104,8 @@ const actions = {
const mutations = {
setAppStarts,
setAssetSource,
setError,
setFlags,
setLocale,
setNotification,
}
/* Export. */
......
/**
* Make Error Message
*/
const displayError = ({ commit }, _error) => {
/* Commit error message. */
commit('setError', _error)
/* Set automatic dismiss delay. */
setTimeout(() => {
commit('setError', null)
}, 7000)
}
/* Export module. */
export default displayError
/**
* Make Notification Message
*/
const displayNotification = ({ commit }, _notification) => {
/* Commit notification message. */
commit('setNotification', _notification)
/* Set automatic dismiss delay. */
setTimeout(() => {
commit('setNotification', null)
}, 5000)
}
/* Export module. */
export default displayNotification
......@@ -17,7 +17,7 @@ const getAssetSource = (state, _assetType) => {
/* Set assets. */
try {
assets = msgpack.decode(Buffer.from(state.assets))
assets = msgpack.decode(Buffer.from(state.assets, 'hex'))
} catch (err) {
console.error(err) // eslint-disable-line no-console
assets = state.assets // DEPRECATED in June '20
......
......@@ -15,7 +15,7 @@ const getFlags = (state) => {
/* Initialize accounts. */
try {
flags = msgpack.decode(Buffer.from(state.flags))
flags = msgpack.decode(Buffer.from(state.flags, 'hex'))
} catch (err) {
console.error(err) // eslint-disable-line no-console
flags = state.flags // DEPRECATED in June '20
......
......@@ -15,7 +15,7 @@ const getLocale = (state) => {
/* Initialize accounts. */
try {
locale = msgpack.decode(Buffer.from(state.locale))
locale = msgpack.decode(Buffer.from(state.locale, 'hex'))
} catch (err) {
console.error(err) // eslint-disable-line no-console
locale = state.locale // DEPRECATED in June '20
......
......@@ -18,7 +18,7 @@ const setAssets = (state, _source) => {
console.log('SYSTEM ASSETS (updated):', updated)
/* Set updated (merged) assets. */
state.assets = msgpack.encode(updated)
state.assets = msgpack.encode(updated).toString('hex')
}
/* Export module. */
......
/**
* Set Application Error
*/
const SetError = (state, _error) => {
/* Set error message. */
state.errorMsg = _error
}
/* Export module. */
export default SetError
......@@ -6,7 +6,7 @@ const msgpack = require('msgpack-lite')
*/
const setFlags = (state, _flags) => {
/* Set flags. */
state.flags = msgpack.encode(_flags)
state.flags = msgpack.encode(_flags).toString('hex')
}
/* Export module. */
......
......@@ -6,7 +6,7 @@ const msgpack = require('msgpack-lite')
*/
const setLocale = (state, _locale) => {
/* Set locale. */
state.locale = msgpack.encode(_locale)
state.locale = msgpack.encode(_locale).toString('hex')
}
/* Export module. */
......
/**
* Set Application Notification
*/
const setNotification = (state, _notification) => {
/* Set notification message. */
state.notifMsg = _notification
}
/* Export module. */
export default setNotification
......@@ -19,7 +19,7 @@ const getChangeAddress = (state, getters) => (_wallet) => {
}
/* Initialize accounts. */
const accounts = msgpack.decode(Buffer.from(state.a))
const accounts = msgpack.decode(Buffer.from(state.account, 'hex'))
/* Validate (wallet) accounts. */
if (!getters.getAccountsByWallet(_wallet)) {
......
......@@ -11,7 +11,7 @@ const getMeta = (state) => {
}
/* Initialize metadata. */
const meta = msgpack.decode(Buffer.from(state.meta))
const meta = msgpack.decode(Buffer.from(state.meta, 'hex'))
/* Return metadata. */
return meta
......
......@@ -11,7 +11,7 @@ const getOutbox = (state) => {
}
/* Initialize outbox. */
const outbox = msgpack.decode(Buffer.from(state.outbox))
const outbox = msgpack.decode(Buffer.from(state.outbox, 'hex'))
/* Return outbox. */
return outbox
......
......@@ -13,7 +13,7 @@ const getWallet = (state) => {
}
/* Initialize wallet. */
const wallet = msgpack.decode(Buffer.from(state.wallet))
const wallet = msgpack.decode(Buffer.from(state.wallet, 'hex'))
/* Return wallet. */
return wallet
......
......@@ -6,7 +6,7 @@ const msgpack = require('msgpack-lite')
*/
const setMetadata = (state, _metadata) => {
/* Set metadata. */
state.meta = msgpack.encode(_metadata)
state.meta = msgpack.encode(_metadata).toString('hex')
}
/* Export module. */
......
......@@ -8,7 +8,7 @@ const msgpack = require('msgpack-lite')
*/
const setOutbox = (state, _outbox) => {
/* Set outbox. */
state.outbox = msgpack.encode(_outbox)
state.outbox = msgpack.encode(_outbox).toString('hex')
}
/* Export module. */
......
......@@ -6,7 +6,7 @@ const msgpack = require('msgpack-lite')
*/
const setWallet = (state, _wallet) => {
/* Set wallet. */
state.wallet = msgpack.encode(_wallet)
state.wallet = msgpack.encode(_wallet).toString('hex')
}
/* Export module. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment