init
This commit is contained in:
commit
44f31f8b9f
402 changed files with 47865 additions and 0 deletions
24
utils/storeUtils.js
Normal file
24
utils/storeUtils.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { cloneDeep } from 'lodash'
|
||||
import { CHAIN_IDS } from '@/constants'
|
||||
|
||||
const netIdWrapper = (initialState) => (acc, netId) => ({
|
||||
...acc,
|
||||
[netId]: Object.assign({}, cloneDeep(initialState))
|
||||
})
|
||||
|
||||
export function createChainIdState(initialState) {
|
||||
return CHAIN_IDS.reduce(netIdWrapper(initialState), {})
|
||||
}
|
||||
|
||||
export function isStorageAvailable(type) {
|
||||
try {
|
||||
const test = '__test__'
|
||||
const storage = window[type]
|
||||
|
||||
storage.setItem(test, test)
|
||||
storage.removeItem(test)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue