message: fix narrow cases of possible NaN/Infinity values in Add Offer window form
diff: @@ -18,7 +18,7 @@ import SelectGroup from './SelectGroup/SelectGroup'
  import Button from 'components/controls/Button/Button'
  import Toggle from 'components/controls/Toggle/Toggle'
  -import { areFloatsEqual } from 'helpers/math.js'
  +import { areFloatsEqual, isNumberValid, isNumberStringFormatCorrect } from 'helpers/math.js'
  const minAmount = {
  @@ -81,18 +81,32 @@ export default class AddOffer extends Component {
  handleExchangeRateChange = (value) => {
  let { buyAmount, sellAmount } = this.state
  - if (areFloatsEqual(value, 0) || value.lastIndexOf(0, '.') || !value) {
  - return
  + if (!isNumberStringFormatCorrect(value)) {
  + return undefined
  + }
  +
  + if (areFloatsEqual(value, 0) || !value) {
  + return undefined
  }
  - buyAmount = new BigNumber(Number(sellAmount)).multipliedBy(value)
  - sellAmount = new BigNumber(Number(buyAmount)).dividedBy(value)
  + buyAmount = new BigNumber(String(sellAmount)).multipliedBy(value)
  + sellAmount = new BigNumber(String(buyAmount)).dividedBy(value)
  +
  + if (!isNumberValid(buyAmount)) {
  + buyAmount = new BigNumber('0')
  + }
  +
  + if (!isNumberValid(sellAmount)) {
  + sellAmount = new BigNumber('0')
  + }
  this.setState({
  buyAmount,
  sellAmount,
  })
  +
  + return value
  }
  handleBuyCurrencySelect = async ({ value }) => {
  @@ -158,10 +172,7 @@ export default class AddOffer extends Component {
  handleBuyAmountChange = (value, prev) => {
  const { exchangeRate, sellAmount, manualRate } = this.state
  - const firstDot = value.indexOf('.')
  - const secondDot = value.lastIndexOf('.')
  -
  - if (firstDot !== secondDot) {
  + if (!isNumberStringFormatCorrect(value)) {
  return undefined
  }
  @@ -173,7 +184,7 @@ export default class AddOffer extends Component {
  if (manualRate) {
  let newRate = new BigNumber(String(value)).dividedBy(new BigNumber(String(sellAmount)))
  this.setState({
  - exchangeRate: Number.isNaN(newRate) ? '' : newRate,
  + exchangeRate: isNumberValid(newRate) ? newRate : '',
  buyAmount: new BigNumber(String(value)),
  })
  } else {
  @@ -189,10 +200,8 @@ export default class AddOffer extends Component {
  handleSellAmountChange = (value) => {
  const { exchangeRate, manualRate, buyAmount } = this.state
  - const firstDot = value.toString().indexOf('.')
  - const secondDot = value.toString().lastIndexOf('.')
  - if (firstDot !== secondDot) {
  + if (!isNumberStringFormatCorrect(value)) {
  return undefined
  }
  @@ -203,8 +212,8 @@ export default class AddOffer extends Component {
  if (manualRate) {
  let newRate = new BigNumber(String(buyAmount)).dividedBy(new BigNumber(String(value)))
  this.setState({
  + exchangeRate: isNumberValid(newRate) ? newRate : '',
  sellAmount: new BigNumber(String(value)),
  - exchangeRate: Number.isNaN(newRate) ? '' : newRate,
  })
  } else {
  this.setState({
  @@ -260,7 +269,7 @@ export default class AddOffer extends Component {
  <Fragment>
  <ExchangeRateGroup
  label="Exchange rate"
  - inputValueLink={linked.exchangeRate.onChange(this.handleExchangeRateChange)}
  + inputValueLink={linked.exchangeRate.pipe(this.handleExchangeRateChange)}
  currency={false}
  disabled={!manualRate}
  id="exchangeRate"
  