Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Check totalBalance > 0 // Better account selection (#3347)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotchac authored and gavofyork committed Nov 10, 2016
1 parent cb84e61 commit eb56b82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 (
Expand All @@ -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) => {
Expand Down
10 changes: 9 additions & 1 deletion js/src/dapps/tokenreg/Actions/Register/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default class RegisterAction extends Component {
className={ styles.dialog }
onRequestClose={ this.onClose }
actions={ this.renderActions() }
ref='dialog'
autoScrollBodyContent
>
{ this.renderContent() }
Expand Down Expand Up @@ -149,7 +150,9 @@ export default class RegisterAction extends Component {
renderForm () {
return (
<div>
<AccountSelector />
<AccountSelector
onAccountChange={ this.onAccountChange }
/>
{ this.renderInputs() }
</div>
);
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion js/src/dapps/tokenreg/Inputs/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb56b82

Please sign in to comment.