Bug #348: Safelist entries get removed (#358)

* Fix balances saved to localStorage not in format [tokenAdd, balance] but [balance]

* Updates localStorage version value
This commit is contained in:
Agustin Pane 2019-12-17 05:09:09 -03:00 committed by Mikhail Mikheev
parent d028da662e
commit 2d282c511b
2 changed files with 12 additions and 5 deletions

View File

@ -25,17 +25,24 @@ const activateTokensByBalance = (safeAddress: string) => async (
// balances: tokens' balance returned by the backend
const { addresses, balances } = result.data.reduce((acc, { tokenAddress, balance }) => ({
addresses: [...acc.addresses, tokenAddress],
balances: [...acc.balances, balance],
}), { addresses: [], balances: [] })
balances: [[tokenAddress, balance]],
}), {
addresses: [],
balances: [],
})
// update balance list for the safe
dispatch(updateSafe({ address: safeAddress, balances: Set(balances) }))
dispatch(updateSafe({
address: safeAddress,
balances: Set(balances),
}))
// active tokens by balance, excluding those already blacklisted and the `null` address
const activeByBalance = addresses.filter((address) => address !== null && !blacklistedTokens.includes(address))
// need to persist those already active tokens, despite its balances
const activeTokens = alreadyActiveTokens.toSet().union(activeByBalance)
const activeTokens = alreadyActiveTokens.toSet()
.union(activeByBalance)
// update list of active tokens
dispatch(updateActiveTokens(safeAddress, activeTokens))

View File

@ -8,7 +8,7 @@ import { getNetwork } from '~/config'
const stores = [IndexedDbStore, LocalStorageStore]
export const storage = new ImmortalStorage(stores)
const PREFIX = `v1_${getNetwork()}`
const PREFIX = `v2_${getNetwork()}`
export const loadFromStorage = async (key: string): Promise<*> => {
try {