profile.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { defineStore } from 'pinia'
  2. /**
  3. * Profile Store
  4. */
  5. export const useProfileStore = defineStore('profile', {
  6. state: () => ({
  7. /* Initialize session id. */
  8. sessionid: null,
  9. /* Initialize session. */
  10. session: null,
  11. /* Initialize (lazy dev) mnemonic phrase. */
  12. // FIXME: FOR LAZY DEVELOPMENT PURPOSES ONLY
  13. mnemonic: 'bacon mind chronic bean luxury endless ostrich festival bicycle dragon worth balcony',
  14. /* Initialize cash accounts. */
  15. cashAccounts: [],
  16. /* Initialize (Bitcoin Cash) test address. */
  17. // NOTE: HöS on EC
  18. bchTestAddress: 'bitcoincash:qqwsfram5cc87k2n26gshjnylg8gdjnauuum5sws3c',
  19. /* Initialize (Nexa) test address. */
  20. // NOTE: Source built
  21. nexaTestAddress: 'nexa:nqtsq5g57qupnngwws0rlvsevggu6zxqc0tmk7d3v5ulpfh6',
  22. // TBD
  23. }),
  24. getters: {
  25. //
  26. },
  27. actions: {
  28. /**
  29. * Set Cash Accounts
  30. *
  31. * @param {Object} _cashAccounts An array of accounts.
  32. */
  33. _setCashAccounts (_cashAccounts) {
  34. this.state.cashAccounts = _cashAccounts
  35. },
  36. /**
  37. * Set Session
  38. *
  39. * @param {String} _session A session id.
  40. */
  41. _setSession (_session) {
  42. /* Set session. */
  43. this.state.session = _session
  44. /* Validate session. */
  45. if (_session) {
  46. /* Set session id. */
  47. this.state.sessionid = _session._id
  48. } else {
  49. /* Set session id. */
  50. this.state.sessionid = null
  51. }
  52. },
  53. deleteSession() {
  54. /* Set session. */
  55. _setSession(null)
  56. /* Set cash accounts. */
  57. _setCashAccounts(null)
  58. },
  59. initSession (_session) {
  60. /* Set session. */
  61. _setSession(session)
  62. },
  63. updateCashAccounts (_cashAccounts) {
  64. /* Set cash accounts. */
  65. _setCashAccounts(_cashAccounts)
  66. },
  67. },
  68. })