* Fix balances saved to localStorage not in format [tokenAdd, balance] but [balance] * Updates localStorage version value
This commit is contained in:
parent
d028da662e
commit
2d282c511b
|
@ -25,17 +25,24 @@ const activateTokensByBalance = (safeAddress: string) => async (
|
||||||
// balances: tokens' balance returned by the backend
|
// balances: tokens' balance returned by the backend
|
||||||
const { addresses, balances } = result.data.reduce((acc, { tokenAddress, balance }) => ({
|
const { addresses, balances } = result.data.reduce((acc, { tokenAddress, balance }) => ({
|
||||||
addresses: [...acc.addresses, tokenAddress],
|
addresses: [...acc.addresses, tokenAddress],
|
||||||
balances: [...acc.balances, balance],
|
balances: [[tokenAddress, balance]],
|
||||||
}), { addresses: [], balances: [] })
|
}), {
|
||||||
|
addresses: [],
|
||||||
|
balances: [],
|
||||||
|
})
|
||||||
|
|
||||||
// update balance list for the safe
|
// 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
|
// active tokens by balance, excluding those already blacklisted and the `null` address
|
||||||
const activeByBalance = addresses.filter((address) => address !== null && !blacklistedTokens.includes(address))
|
const activeByBalance = addresses.filter((address) => address !== null && !blacklistedTokens.includes(address))
|
||||||
|
|
||||||
// need to persist those already active tokens, despite its balances
|
// 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
|
// update list of active tokens
|
||||||
dispatch(updateActiveTokens(safeAddress, activeTokens))
|
dispatch(updateActiveTokens(safeAddress, activeTokens))
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { getNetwork } from '~/config'
|
||||||
const stores = [IndexedDbStore, LocalStorageStore]
|
const stores = [IndexedDbStore, LocalStorageStore]
|
||||||
export const storage = new ImmortalStorage(stores)
|
export const storage = new ImmortalStorage(stores)
|
||||||
|
|
||||||
const PREFIX = `v1_${getNetwork()}`
|
const PREFIX = `v2_${getNetwork()}`
|
||||||
|
|
||||||
export const loadFromStorage = async (key: string): Promise<*> => {
|
export const loadFromStorage = async (key: string): Promise<*> => {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue