summaryrefslogtreecommitdiff
path: root/src/core/utils/address.js
blob: c545d34b9764f27710907e76d3372178daa50277 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const getAddress = () => {
  if (typeof window !== 'undefined') {
    const address = localStorage.getItem('address')
    if (address) return JSON.parse(address)
  }
  return {}
}

const setAddress = (address) => {
  if (typeof window !== 'undefined') {
    localStorage.setItem('address', JSON.stringify(address))
  }
  return
}

const getItemAddress = (key) => {
  let address = getAddress()
  return address[key]
}

const updateItemAddress = (key, value) => {
  let address = getAddress()
  address[key] = value
  setAddress(address)
  return
}

export { getItemAddress, updateItemAddress }