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)
|
const baseToken = tokensList.get(token.address)
|
||||||
|
|
||||||
if (baseToken) {
|
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 { List, Map } from 'immutable'
|
||||||
import { type GlobalState } from '~/store/index'
|
import { type GlobalState } from '~/store/index'
|
||||||
import { makeOwner } from '~/routes/safe/store/models/owner'
|
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 { addSafe } from '~/routes/safe/store/actions/addSafe'
|
||||||
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
import { getOwners, getSafeName } from '~/logic/safe/utils'
|
||||||
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
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 { getStandardTokenContract } from '~/logic/tokens/store/actions/fetchTokens'
|
||||||
import type { Safe } from '~/routes/safe/store/models/safe'
|
import type { Safe } from '~/routes/safe/store/models/safe'
|
||||||
import updateSafe from './updateSafe'
|
import updateSafe from './updateSafe'
|
||||||
|
import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers';
|
||||||
|
|
||||||
export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => {
|
export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => {
|
||||||
|
if (tokenAddress === ETH_ADDRESS) {
|
||||||
|
return '0'
|
||||||
|
}
|
||||||
|
|
||||||
const erc20Token = await getStandardTokenContract()
|
const erc20Token = await getStandardTokenContract()
|
||||||
let balance = 0
|
let balance = 0
|
||||||
|
|
||||||
|
|
|
@ -76,16 +76,14 @@ export default handleActions<State, *>(
|
||||||
const { safeAddress, token: updatedToken } = action.payload
|
const { safeAddress, token: updatedToken } = action.payload
|
||||||
|
|
||||||
const tokens: List<SafeToken> = state.getIn([safeAddress, 'tokens'])
|
const tokens: List<SafeToken> = state.getIn([safeAddress, 'tokens'])
|
||||||
console.log(tokens)
|
|
||||||
const index = tokens.findIndex(token => token.address === updatedToken.address)
|
const index = tokens.findIndex(token => token.address === updatedToken.address)
|
||||||
console.log('called')
|
|
||||||
let newState
|
let newState
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
newState = state.setIn([safeAddress, 'tokens'], tokens.delete(index))
|
newState = state.setIn([safeAddress, 'tokens'], tokens.delete(index))
|
||||||
} else {
|
} else {
|
||||||
newState = state.setIn([safeAddress, 'tokens'], tokens.push(updatedToken))
|
newState = state.setIn([safeAddress, 'tokens'], tokens.push(updatedToken))
|
||||||
}
|
}
|
||||||
console.log(newState.toJS())
|
|
||||||
|
|
||||||
return newState
|
return newState
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue