Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Bitcoin Please
Causes Cash
Commits
f10cc5b4
Commit
f10cc5b4
authored
Jul 06, 2020
by
Bitcoin Please
Browse files
Refactored store to use "hex" strings for persistent storage.
parent
f7ddf799
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
26 additions
and
93 deletions
+26
-93
src/store/modules/campaigns/getters/getAsset.js
src/store/modules/campaigns/getters/getAsset.js
+1
-1
src/store/modules/campaigns/mutations/setAsset.js
src/store/modules/campaigns/mutations/setAsset.js
+1
-1
src/store/modules/profile/actions/initProfile.js
src/store/modules/profile/actions/initProfile.js
+1
-1
src/store/modules/profile/getters/getEmail.js
src/store/modules/profile/getters/getEmail.js
+1
-1
src/store/modules/profile/getters/getMasterSeed.js
src/store/modules/profile/getters/getMasterSeed.js
+5
-1
src/store/modules/profile/getters/getNickname.js
src/store/modules/profile/getters/getNickname.js
+1
-1
src/store/modules/profile/mutations/setEmail.js
src/store/modules/profile/mutations/setEmail.js
+1
-1
src/store/modules/profile/mutations/setMasterSeed.js
src/store/modules/profile/mutations/setMasterSeed.js
+1
-4
src/store/modules/profile/mutations/setNickname.js
src/store/modules/profile/mutations/setNickname.js
+1
-1
src/store/modules/system.js
src/store/modules/system.js
+0
-18
src/store/modules/system/actions/displayError.js
src/store/modules/system/actions/displayError.js
+0
-15
src/store/modules/system/actions/displayNotification.js
src/store/modules/system/actions/displayNotification.js
+0
-15
src/store/modules/system/getters/getAssetSource.js
src/store/modules/system/getters/getAssetSource.js
+1
-1
src/store/modules/system/getters/getFlags.js
src/store/modules/system/getters/getFlags.js
+1
-1
src/store/modules/system/getters/getLocale.js
src/store/modules/system/getters/getLocale.js
+1
-1
src/store/modules/system/mutations/setAssetSource.js
src/store/modules/system/mutations/setAssetSource.js
+1
-1
src/store/modules/system/mutations/setError.js
src/store/modules/system/mutations/setError.js
+0
-10
src/store/modules/system/mutations/setFlags.js
src/store/modules/system/mutations/setFlags.js
+1
-1
src/store/modules/system/mutations/setLocale.js
src/store/modules/system/mutations/setLocale.js
+1
-1
src/store/modules/system/mutations/setNotification.js
src/store/modules/system/mutations/setNotification.js
+0
-10
src/store/modules/wallet/getters/getChangeAddress.js
src/store/modules/wallet/getters/getChangeAddress.js
+1
-1
src/store/modules/wallet/getters/getMeta.js
src/store/modules/wallet/getters/getMeta.js
+1
-1
src/store/modules/wallet/getters/getOutbox.js
src/store/modules/wallet/getters/getOutbox.js
+1
-1
src/store/modules/wallet/getters/getWallet.js
src/store/modules/wallet/getters/getWallet.js
+1
-1
src/store/modules/wallet/mutations/setMeta.js
src/store/modules/wallet/mutations/setMeta.js
+1
-1
src/store/modules/wallet/mutations/setOutbox.js
src/store/modules/wallet/mutations/setOutbox.js
+1
-1
src/store/modules/wallet/mutations/setWallet.js
src/store/modules/wallet/mutations/setWallet.js
+1
-1
No files found.
src/store/modules/campaigns/getters/getAsset.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/campaigns/mutations/setAsset.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/profile/actions/initProfile.js
View file @
f10cc5b4
...
...
@@ -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
)
...
...
src/store/modules/profile/getters/getEmail.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/profile/getters/getMasterSeed.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/profile/getters/getNickname.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/profile/mutations/setEmail.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/profile/mutations/setMasterSeed.js
View file @
f10cc5b4
/* 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. */
...
...
src/store/modules/profile/mutations/setNickname.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/system.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/system/actions/displayError.js
deleted
100644 → 0
View file @
f7ddf799
/**
* 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
src/store/modules/system/actions/displayNotification.js
deleted
100644 → 0
View file @
f7ddf799
/**
* 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
src/store/modules/system/getters/getAssetSource.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/system/getters/getFlags.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/system/getters/getLocale.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/system/mutations/setAssetSource.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/system/mutations/setError.js
deleted
100644 → 0
View file @
f7ddf799
/**
* Set Application Error
*/
const
SetError
=
(
state
,
_error
)
=>
{
/* Set error message. */
state
.
errorMsg
=
_error
}
/* Export module. */
export
default
SetError
src/store/modules/system/mutations/setFlags.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/system/mutations/setLocale.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/system/mutations/setNotification.js
deleted
100644 → 0
View file @
f7ddf799
/**
* Set Application Notification
*/
const
setNotification
=
(
state
,
_notification
)
=>
{
/* Set notification message. */
state
.
notifMsg
=
_notification
}
/* Export module. */
export
default
setNotification
src/store/modules/wallet/getters/getChangeAddress.js
View file @
f10cc5b4
...
...
@@ -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
.
a
ccount
,
'
hex
'
))
/* Validate (wallet) accounts. */
if
(
!
getters
.
getAccountsByWallet
(
_wallet
))
{
...
...
src/store/modules/wallet/getters/getMeta.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/wallet/getters/getOutbox.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/wallet/getters/getWallet.js
View file @
f10cc5b4
...
...
@@ -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
...
...
src/store/modules/wallet/mutations/setMeta.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/wallet/mutations/setOutbox.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
src/store/modules/wallet/mutations/setWallet.js
View file @
f10cc5b4
...
...
@@ -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. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment