const { LocalStorage } = require('node-localstorage')
let localStorage = new LocalStorage('./config')


module.exports = {
  setAccount: function(accounts) {

    localStorage.setItem('account', JSON.stringify(accounts))
  },
  getAccount: function() {
    let accounts = localStorage.getItem('account');

    return JSON.parse(accounts) || []
  },
  getRpcConfig: function() {
    let rpc = localStorage.getItem('rpc');

    return rpc && JSON.parse(rpc) || {}
  },
  setRpcConfig: function(config) {

    localStorage.setItem('rpc', JSON.stringify(config))
  },
  setMainAccount: function(account) {
    localStorage.setItem('main-account', JSON.stringify(account))
  },
  getMainAccount: function() {
    let account =  localStorage.getItem('main-account')
    return JSON.parse(account) || ""
  }
}
