import NP from 'number-precision'

export const mutations = {
  setScatter (state, scatter) {
    state.scatter = scatter
  },
  setEos (state, eosjs) {
    state.eos = eosjs
  },
  setAccount (state, account) {
    state.account = account
    window.EOS_VUE.$getEosInfo();
  },
  setToAccount (state, name) {
    state.toAccount = name
  },
  setBalance (state, balance) {
    state.balance = balance
    window.EOS_VUE.$getCoin({ coin: { balance: state.balance } })
  },
  setMoney (state, money) {
    state.money = money
    window.EOS_VUE.$getCoin({ coin: { money: state.money } })
  },
  setGt (state, gt) {
    state.gt = gt
    window.EOS_VUE.$getCoin({ coin: { gt: state.gt } })
  },
  updateBalance (state, amount) {
    state.balance = NP.plus(state.balance, amount)
    window.EOS_VUE.$getCoin({ coin: { balance: state.balance } })
  },
  updateMoney (state, amount) {
    state.money = NP.plus(state.money, amount)
    window.EOS_VUE.$getCoin({ coin: { money: state.money } })
  },
  updateGt (state, amount) {
    state.gt = NP.plus(state.gt, amount)
    window.EOS_VUE.$getCoin({ coin: { gt: state.gt } })
  },
  setMainnet (state, mainnet) {
    state.mainnet = mainnet
  },
  setAuction (state, auctionInfo) {
    state.auctionInfo = auctionInfo
  },
  setNewOpen (state, newOpen) {
    state.newOpen = newOpen
  },
  setNewGame (state, newGame) {
    state.newGame = newGame
  },
  setNewOffer (state, newOffer) {
    state.newOffer = newOffer
  },
  setNewPlayer (state, newPlayer) {
    state.newPlayer = newPlayer
  },
  setNewClose (state, newClose) {
    state.newClose = newClose
  },
  setInvitee (state, invitee) {
    state.invitee = invitee
  },
  setGTError (state, count) {
    state.gtErrorCount = count
  },
  setEOSError (state, count) {
    state.eosErrorCount = count
  },
  setLimit (state, data) {
    state.limit = {
      cpu: data.cpu,
      net: data.net
    }
  },
  setPublicKey (state, string) {
    state.publicKey = string
  }
}
