diff --git a/src/components/AdvancedOptions/RippleKind.js b/src/components/AdvancedOptions/RippleKind.js index b87cff5f..74b0b5a4 100644 --- a/src/components/AdvancedOptions/RippleKind.js +++ b/src/components/AdvancedOptions/RippleKind.js @@ -1,5 +1,6 @@ // @flow -import React from 'react' +import React, { Component } from 'react' +import { BigNumber } from 'bignumber.js' import { translate } from 'react-i18next' import Box from 'components/base/Box' @@ -13,24 +14,37 @@ type Props = { t: *, } -export default translate()(({ tag, onChangeTag, t }: Props) => ( - - - - - - - { - const tag = parseInt(str, 10) - if (!isNaN(tag) && isFinite(tag)) onChangeTag(tag) - else onChangeTag(undefined) - }} - /> - - - -)) +const uint32maxPlus1 = BigNumber(2).pow(32) + +class RippleKind extends Component { + onChange = str => { + const { onChangeTag } = this.props + const tag = BigNumber(str.replace(/[^0-9]/g, '')) + if (!tag.isNaN() && tag.isFinite()) { + if (tag.isInteger() && tag.isPositive() && tag.lt(uint32maxPlus1)) { + onChangeTag(tag.toNumber()) + } + } else { + onChangeTag(undefined) + } + } + render() { + const { tag, t } = this.props + return ( + + + + + + + + + + + ) + } +} + +export default translate()(RippleKind)