WA-232 set token's address as PK in redux
This commit is contained in:
parent
5d49bb946e
commit
95caa29f69
|
@ -105,7 +105,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
|
||||||
component: <SendToken
|
component: <SendToken
|
||||||
safe={safe}
|
safe={safe}
|
||||||
token={ercToken}
|
token={ercToken}
|
||||||
key={ercToken.get('symbol')}
|
key={ercToken.get('address')}
|
||||||
onReset={this.onListTransactions}
|
onReset={this.onListTransactions}
|
||||||
/>,
|
/>,
|
||||||
})
|
})
|
||||||
|
|
|
@ -42,7 +42,7 @@ const getTransferData = async (tokenAddress: string, to: string, amount: BigNumb
|
||||||
const processTokenTransfer = async (safe: Safe, token: Token, to: string, amount: number, userAddress: string) => {
|
const processTokenTransfer = async (safe: Safe, token: Token, to: string, amount: number, userAddress: string) => {
|
||||||
const symbol = token.get('symbol')
|
const symbol = token.get('symbol')
|
||||||
const nonce = Date.now()
|
const nonce = Date.now()
|
||||||
const name = `Send ${amount} ${token.get('symbol')} to ${to}`
|
const name = `Send ${amount} ${symbol} to ${to}`
|
||||||
const value = isEther(symbol) ? amount : 0
|
const value = isEther(symbol) ? amount : 0
|
||||||
const tokenAddress = token.get('address')
|
const tokenAddress = token.get('address')
|
||||||
const destination = isEther(symbol) ? to : tokenAddress
|
const destination = isEther(symbol) ? to : tokenAddress
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TokenLayout extends React.PureComponent<TokenProps, State> {
|
||||||
<Col sm={12} top="xs" md={5} margin="xl" overflow>
|
<Col sm={12} top="xs" md={5} margin="xl" overflow>
|
||||||
<MuiList style={listStyle}>
|
<MuiList style={listStyle}>
|
||||||
{tokens.map((token: Token) => (<TokenComponent
|
{tokens.map((token: Token) => (<TokenComponent
|
||||||
key={token.get('symbol')}
|
key={token.get('address')}
|
||||||
token={token}
|
token={token}
|
||||||
onDisableToken={this.onDisableToken}
|
onDisableToken={this.onDisableToken}
|
||||||
onEnableToken={this.onEnableToken}
|
onEnableToken={this.onEnableToken}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// @flow
|
||||||
|
import { createAction } from 'redux-actions'
|
||||||
|
import { type Token } from '~/routes/tokens/store/model/token'
|
||||||
|
|
||||||
|
export const ADD_TOKEN = 'ADD_TOKEN'
|
||||||
|
|
||||||
|
type AddTokenProps = {
|
||||||
|
safeAddress: string,
|
||||||
|
token: Token,
|
||||||
|
}
|
||||||
|
|
||||||
|
const addToken = createAction(
|
||||||
|
ADD_TOKEN,
|
||||||
|
(safeAddress: string, token: Token): AddTokenProps => ({
|
||||||
|
safeAddress,
|
||||||
|
token,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
export default addToken
|
|
@ -62,7 +62,7 @@ export const fetchTokens = (safeAddress: string) =>
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const balances: Map<string, Token> = Map().withMutations((map) => {
|
const balances: Map<string, Token> = Map().withMutations((map) => {
|
||||||
balancesRecords.forEach(record => map.set(record.get('symbol'), record))
|
balancesRecords.forEach(record => map.set(record.get('address'), record))
|
||||||
|
|
||||||
map.set('ETH', ethBalance)
|
map.set('ETH', ethBalance)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { List, Map } from 'immutable'
|
import { List, Map } from 'immutable'
|
||||||
import { handleActions, type ActionType } from 'redux-actions'
|
import { handleActions, type ActionType } from 'redux-actions'
|
||||||
|
import addToken, { ADD_TOKEN } from '~/routes/tokens/store/actions/addToken'
|
||||||
import addTokens, { ADD_TOKENS } from '~/routes/tokens/store/actions/addTokens'
|
import addTokens, { ADD_TOKENS } from '~/routes/tokens/store/actions/addTokens'
|
||||||
import { type Token } from '~/routes/tokens/store/model/token'
|
import { type Token } from '~/routes/tokens/store/model/token'
|
||||||
import disableToken, { DISABLE_TOKEN } from '~/routes/tokens/store/actions/disableToken'
|
import disableToken, { DISABLE_TOKEN } from '~/routes/tokens/store/actions/disableToken'
|
||||||
|
@ -30,6 +31,14 @@ export default handleActions({
|
||||||
return prevSafe.equals(tokens) ? prevSafe : tokens
|
return prevSafe.equals(tokens) ? prevSafe : tokens
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
[ADD_TOKEN]: (state: State, action: ActionType<typeof addToken>): State => {
|
||||||
|
const { safeAddress, token } = action.payload
|
||||||
|
const activeTokens = getTokens(safeAddress)
|
||||||
|
activeTokens.push(token.get('address'))
|
||||||
|
setTokens(activeTokens)
|
||||||
|
|
||||||
|
return state.setIn([safeAddress, token.get('address')], token)
|
||||||
|
},
|
||||||
[DISABLE_TOKEN]: (state: State, action: ActionType<typeof disableToken>): State => {
|
[DISABLE_TOKEN]: (state: State, action: ActionType<typeof disableToken>): State => {
|
||||||
const { address, safeAddress, symbol } = action.payload
|
const { address, safeAddress, symbol } = action.payload
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue