remove eth from list of active tokens
This commit is contained in:
parent
5f142bcc75
commit
3530d2f305
|
@ -4,19 +4,14 @@ import { List, Map } from 'immutable'
|
||||||
import { type TokenProps, type Token, makeToken } from '~/logic/tokens/store/model/token'
|
import { type TokenProps, type Token, makeToken } from '~/logic/tokens/store/model/token'
|
||||||
import { type GlobalState } from '~/store/index'
|
import { type GlobalState } from '~/store/index'
|
||||||
import { getActiveTokens } from '~/logic/tokens/utils/tokensStorage'
|
import { getActiveTokens } from '~/logic/tokens/utils/tokensStorage'
|
||||||
import { getEthAsToken } from '~/logic/tokens/utils/tokenHelpers'
|
|
||||||
import saveTokens from './saveTokens'
|
import saveTokens from './saveTokens'
|
||||||
|
|
||||||
const loadActiveTokens = (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
const loadActiveTokens = (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||||
try {
|
try {
|
||||||
const tokens: List<TokenProps> = await getActiveTokens(safeAddress)
|
const tokens: List<TokenProps> = await getActiveTokens(safeAddress)
|
||||||
|
|
||||||
// ETH is active by default and cannot be disabled
|
|
||||||
const eth = await getEthAsToken(safeAddress)
|
|
||||||
|
|
||||||
const tokenRecords: Map<string, Token> = Map().withMutations((map) => {
|
const tokenRecords: Map<string, Token> = Map().withMutations((map) => {
|
||||||
tokens.forEach(token => map.set(token.address, makeToken(token)))
|
tokens.forEach(token => map.set(token.address, makeToken(token)))
|
||||||
map.set(eth.address, eth)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
dispatch(saveTokens(safeAddress, tokenRecords))
|
dispatch(saveTokens(safeAddress, tokenRecords))
|
||||||
|
|
|
@ -7,20 +7,20 @@ import { makeToken, type Token } from '~/logic/tokens/store/model/token'
|
||||||
export const ETH_ADDRESS = '0x000'
|
export const ETH_ADDRESS = '0x000'
|
||||||
export const isEther = (symbol: string) => symbol === 'ETH'
|
export const isEther = (symbol: string) => symbol === 'ETH'
|
||||||
|
|
||||||
export const getEthAsToken = async (safeAddress: string) => {
|
// export const getEthAsToken = async (safeAddress: string) => {
|
||||||
const balance = await getBalanceInEtherOf(safeAddress)
|
// const balance = await getBalanceInEtherOf(safeAddress)
|
||||||
|
|
||||||
const ethBalance = makeToken({
|
// const ethBalance = makeToken({
|
||||||
address: ETH_ADDRESS,
|
// address: ETH_ADDRESS,
|
||||||
name: 'Ether',
|
// name: 'Ether',
|
||||||
symbol: 'ETH',
|
// symbol: 'ETH',
|
||||||
decimals: 18,
|
// decimals: 18,
|
||||||
logoUri: logo,
|
// logoUri: logo,
|
||||||
funds: balance,
|
// funds: balance,
|
||||||
})
|
// })
|
||||||
|
|
||||||
return ethBalance
|
// return ethBalance
|
||||||
}
|
// }
|
||||||
|
|
||||||
export const calculateActiveErc20TokensFrom = (tokens: List<Token>) => {
|
export const calculateActiveErc20TokensFrom = (tokens: List<Token>) => {
|
||||||
const activeTokens = List().withMutations(list => tokens.forEach((token: Token) => {
|
const activeTokens = List().withMutations(list => tokens.forEach((token: Token) => {
|
||||||
|
|
Loading…
Reference in New Issue