fix token balance updating
This commit is contained in:
parent
f486068778
commit
3c5d7fc7f1
|
@ -74,7 +74,7 @@ const extendedSafeTokensSelector: Selector<GlobalState, RouterProps, List<Token>
|
|||
const baseToken = tokensList.get(token.address)
|
||||
|
||||
if (baseToken) {
|
||||
map.set(token.address, baseToken.set(token.balance))
|
||||
map.set(token.address, baseToken.set('balance', token.balance))
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { Dispatch as ReduxDispatch } from 'redux'
|
|||
import { List, Map } from 'immutable'
|
||||
import { type GlobalState } from '~/store/index'
|
||||
import { makeOwner } from '~/routes/safe/store/models/owner'
|
||||
import { type SafeProps } from '~/routes/safe/store/models/safe'
|
||||
import type { SafeProps } from '~/routes/safe/store/models/safe'
|
||||
import { addSafe } from '~/routes/safe/store/actions/addSafe'
|
||||
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
||||
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
||||
|
|
|
@ -8,8 +8,13 @@ import SafeTokenRecord from '~/routes/safe/store/models/safeToken'
|
|||
import { getStandardTokenContract } from '~/logic/tokens/store/actions/fetchTokens'
|
||||
import type { Safe } from '~/routes/safe/store/models/safe'
|
||||
import updateSafe from './updateSafe'
|
||||
import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers';
|
||||
|
||||
export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => {
|
||||
if (tokenAddress === ETH_ADDRESS) {
|
||||
return '0'
|
||||
}
|
||||
|
||||
const erc20Token = await getStandardTokenContract()
|
||||
let balance = 0
|
||||
|
||||
|
|
|
@ -76,16 +76,14 @@ export default handleActions<State, *>(
|
|||
const { safeAddress, token: updatedToken } = action.payload
|
||||
|
||||
const tokens: List<SafeToken> = state.getIn([safeAddress, 'tokens'])
|
||||
console.log(tokens)
|
||||
const index = tokens.findIndex(token => token.address === updatedToken.address)
|
||||
console.log('called')
|
||||
|
||||
let newState
|
||||
if (index !== -1) {
|
||||
newState = state.setIn([safeAddress, 'tokens'], tokens.delete(index))
|
||||
} else {
|
||||
newState = state.setIn([safeAddress, 'tokens'], tokens.push(updatedToken))
|
||||
}
|
||||
console.log(newState.toJS())
|
||||
|
||||
return newState
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue