WA-232 Adding move tokens feature to Safe route view

This commit is contained in:
apanizo 2018-07-03 13:22:16 +02:00
parent 3fbf63e257
commit 731e591218
2 changed files with 18 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import Threshold from '~/routes/safe/component/Threshold'
import AddOwner from '~/routes/safe/component/AddOwner'
import RemoveOwner from '~/routes/safe/component/RemoveOwner'
import EditDailyLimit from '~/routes/safe/component/EditDailyLimit'
import SendToken from '~/routes/safe/component/SendToken'
import Address from './Address'
import BalanceInfo from './BalanceInfo'
@ -102,6 +103,14 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
this.setState({ component: <RemoveOwner safeAddress={safe.get('address')} threshold={safe.get('threshold')} safe={safe} name={name} userToRemove={address} /> })
}
onMoveTokens = (ercToken: Balance) => {
const { safe } = this.props
this.setState({
component: <SendToken safe={safe} balance={ercToken} onReset={this.onListTransactions} />,
})
}
render() {
const { safe, balances, userAddress } = this.props
const { component } = this.state
@ -111,7 +120,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
<Row grow>
<Col sm={12} top="xs" md={5} margin="xl" overflow>
<List style={listStyle}>
<BalanceInfo balances={balances} />
<BalanceInfo balances={balances} onMoveFunds={this.onMoveTokens} />
<Owners
owners={safe.owners}
onAddOwner={this.onAddOwner}

View File

@ -9,11 +9,18 @@ import { makeBalance, type Balance, type BalanceProps } from '~/routes/safe/stor
import logo from '~/assets/icons/icon_etherTokens.svg'
import addBalances from './addBalances'
export const calculateBalanceOf = async (tokenAddress: string, address: string) => {
export const getStandardTokenContract = async () => {
const web3 = getWeb3()
const erc20Token = await contract(StandardToken)
erc20Token.setProvider(web3.currentProvider)
return erc20Token
}
export const calculateBalanceOf = async (tokenAddress: string, address: string) => {
const erc20Token = await getStandardTokenContract()
return erc20Token.at(tokenAddress)
.then(instance => instance.balanceOf(address).then(funds => funds.toString()))
.catch(() => '0')