|
|
@ -16,6 +16,7 @@ import { |
|
|
|
WalletsNativeSendFormRender, |
|
|
|
_WalletsNativeSendFormRender |
|
|
|
} from './walletsNativeSend.render'; |
|
|
|
import { isPositiveNumber } from "../../../util/number"; |
|
|
|
|
|
|
|
class WalletsNativeSend extends React.Component { |
|
|
|
constructor(props) { |
|
|
@ -269,6 +270,10 @@ class WalletsNativeSend extends React.Component { |
|
|
|
} |
|
|
|
|
|
|
|
handleSubmit() { |
|
|
|
if (!this.validateSendFormData()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Store.dispatch( |
|
|
|
sendNativeTx( |
|
|
|
this.props.ActiveCoin.coin, |
|
|
@ -348,6 +353,55 @@ class WalletsNativeSend extends React.Component { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
checkTotalBalance() { |
|
|
|
let _balance = 0; |
|
|
|
if (this.props.ActiveCoin.balance && |
|
|
|
this.props.ActiveCoin.balance.total) { |
|
|
|
_balance = this.props.ActiveCoin.balance.total; |
|
|
|
} |
|
|
|
|
|
|
|
return _balance; |
|
|
|
} |
|
|
|
|
|
|
|
validateSendFormData() { |
|
|
|
let valid = true; |
|
|
|
if (!this.state.sendTo || this.state.sendTo.length < 34) { |
|
|
|
Store.dispatch( |
|
|
|
triggerToaster( |
|
|
|
translate('SEND.SEND_TO_ADDRESS_MIN_LENGTH'), |
|
|
|
'', |
|
|
|
'error' |
|
|
|
) |
|
|
|
); |
|
|
|
valid = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!isPositiveNumber(this.state.amount)) { |
|
|
|
Store.dispatch( |
|
|
|
triggerToaster( |
|
|
|
translate('SEND.AMOUNT_POSITIVE_NUMBER'), |
|
|
|
'', |
|
|
|
'error' |
|
|
|
) |
|
|
|
); |
|
|
|
valid = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.state.amount > this.checkTotalBalance()) { |
|
|
|
Store.dispatch( |
|
|
|
triggerToaster( |
|
|
|
translate('SEND.INSUFFICIENT_FUNDS'), |
|
|
|
'', |
|
|
|
'error' |
|
|
|
) |
|
|
|
); |
|
|
|
valid = false; |
|
|
|
} |
|
|
|
|
|
|
|
return valid; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
if (this.props && |
|
|
|
this.props.ActiveCoin && |
|
|
|