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