A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/app/components/send/send-content/send-from-row/send-from-row.component.js

64 lines
1.5 KiB

7 years ago
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import SendRowWrapper from '../send-row-wrapper/'
import FromDropdown from './from-dropdown/'
7 years ago
export default class SendFromRow extends Component {
static propTypes = {
closeFromDropdown: PropTypes.func,
conversionRate: PropTypes.number,
from: PropTypes.object,
7 years ago
fromAccounts: PropTypes.array,
fromDropdownOpen: PropTypes.bool,
openFromDropdown: PropTypes.func,
tokenContract: PropTypes.object,
updateSendFrom: PropTypes.func,
setSendTokenBalance: PropTypes.func,
7 years ago
};
static contextTypes = {
t: PropTypes.func,
};
7 years ago
async handleFromChange (newFrom) {
const {
updateSendFrom,
tokenContract,
setSendTokenBalance,
7 years ago
} = this.props
if (tokenContract) {
const usersToken = await tokenContract.balanceOf(newFrom.address)
setSendTokenBalance(usersToken)
7 years ago
}
updateSendFrom(newFrom)
}
render () {
const {
closeFromDropdown,
conversionRate,
7 years ago
from,
fromAccounts,
fromDropdownOpen,
openFromDropdown,
} = this.props
7 years ago
return (
<SendRowWrapper label={`${this.context.t('from')}:`}>
<FromDropdown
accounts={fromAccounts}
closeDropdown={() => closeFromDropdown()}
conversionRate={conversionRate}
dropdownOpen={fromDropdownOpen}
onSelect={newFrom => this.handleFromChange(newFrom)}
openDropdown={() => openFromDropdown()}
selectedAccount={from}
7 years ago
/>
</SendRowWrapper>
)
7 years ago
}
}