Skip to content

Commit

Permalink
Add decimals as a factor to validate invest input
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomg committed Feb 27, 2018
1 parent 4198f36 commit 1399659
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/invest/index.js
Expand Up @@ -11,7 +11,7 @@ import {
getJoinedTiers,
initializeAccumulativeData
} from '../crowdsale/utils'
import { getQueryVariable, toast } from '../../utils/utils'
import { countDecimalPlaces, getQueryVariable, toast } from '../../utils/utils'
import { getWhiteListWithCapCrowdsaleAssets } from '../../stores/utils'
import {
invalidCrowdsaleAddrAlert,
Expand Down Expand Up @@ -247,7 +247,7 @@ export class Invest extends React.Component {
}

isValidToken(token) {
return +token > 0
return +token > 0 && countDecimalPlaces(token) <= this.props.tokenStore.decimals
}

renderPieTracker () {
Expand Down Expand Up @@ -310,7 +310,11 @@ export class Invest extends React.Component {

let invalidTokenDescription = null
if (!pristineTokenInput && !this.isValidToken(tokensToInvest)) {
invalidTokenDescription = <p className="error">Number of tokens to buy should be positive</p>
invalidTokenDescription = (
<p className="error">
Number of tokens to buy should be positive and should not exceed {decimals} decimals.
</p>
)
}

const QRPaymentProcessElement = investThrough === INVESTMENT_OPTIONS.QR ?
Expand Down

0 comments on commit 1399659

Please sign in to comment.