Check totalBalance > 0 // Better account selection (#3347)
This commit is contained in:
parent
cb84e61d06
commit
eb56b82f43
@ -70,7 +70,8 @@ export default class AccountSelector extends Component {
|
||||
static propTypes = {
|
||||
list: PropTypes.array.isRequired,
|
||||
selected: PropTypes.object.isRequired,
|
||||
handleSetSelected: PropTypes.func.isRequired
|
||||
handleSetSelected: PropTypes.func.isRequired,
|
||||
onAccountChange: PropTypes.func
|
||||
};
|
||||
|
||||
state = {
|
||||
@ -85,7 +86,8 @@ export default class AccountSelector extends Component {
|
||||
nestedItems={ nestedAccounts }
|
||||
open={ this.state.open }
|
||||
onSelectAccount={ this.onToggleOpen }
|
||||
autoGenerateNestedIndicator={ false } />
|
||||
autoGenerateNestedIndicator={ false }
|
||||
nestedListStyle={ { maxHeight: '14em', overflow: 'auto' } } />
|
||||
);
|
||||
|
||||
return (
|
||||
@ -110,6 +112,10 @@ export default class AccountSelector extends Component {
|
||||
|
||||
onToggleOpen = () => {
|
||||
this.setState({ open: !this.state.open });
|
||||
|
||||
if (typeof this.props.onAccountChange === 'function') {
|
||||
this.props.onAccountChange();
|
||||
}
|
||||
}
|
||||
|
||||
onSelectAccount = (address) => {
|
||||
|
@ -81,6 +81,7 @@ export default class RegisterAction extends Component {
|
||||
className={ styles.dialog }
|
||||
onRequestClose={ this.onClose }
|
||||
actions={ this.renderActions() }
|
||||
ref='dialog'
|
||||
autoScrollBodyContent
|
||||
>
|
||||
{ this.renderContent() }
|
||||
@ -149,7 +150,9 @@ export default class RegisterAction extends Component {
|
||||
renderForm () {
|
||||
return (
|
||||
<div>
|
||||
<AccountSelector />
|
||||
<AccountSelector
|
||||
onAccountChange={ this.onAccountChange }
|
||||
/>
|
||||
{ this.renderInputs() }
|
||||
</div>
|
||||
);
|
||||
@ -175,6 +178,11 @@ export default class RegisterAction extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
onAccountChange = () => {
|
||||
const { dialog } = this.refs;
|
||||
dialog.forceUpdate();
|
||||
}
|
||||
|
||||
onChange (fieldKey, valid, value) {
|
||||
const { fields } = this.state;
|
||||
const field = fields[fieldKey];
|
||||
|
@ -75,7 +75,7 @@ const validateTokenAddress = (address, contract, simple) => {
|
||||
|
||||
return getTokenTotalSupply(address)
|
||||
.then(balance => {
|
||||
if (balance === null) {
|
||||
if (balance === null || balance.equals(0)) {
|
||||
return {
|
||||
error: ERRORS.invalidTokenAddress,
|
||||
valid: false
|
||||
|
Loading…
Reference in New Issue
Block a user