Skip to content

Commit

Permalink
Merge pull request #319 from gagarin55/fix-tx-amount
Browse files Browse the repository at this point in the history
Fixed. Tx creation: incorrect entire balance calculation
  • Loading branch information
gagarin55 authored Aug 31, 2017
2 parents 1b58fda + 10fb4f4 commit a731356
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/tx/CreateTx/create.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Immutable from 'immutable';
import BigNumber from 'bignumber.js';
import log from 'electron-log';
import { change, formValueSelector, SubmissionError } from 'redux-form';

import { connect } from 'react-redux';
Expand All @@ -13,6 +12,9 @@ import { Wei } from 'lib/types';
import { address } from 'lib/validators';

import CreateTxForm from './createTxForm';
import createLogger from '../../../utils/logger';

const log = createLogger('CreateTx');

const DefaultGas = 21000;
const DefaultTokenGas = 23890;
Expand Down Expand Up @@ -149,9 +151,9 @@ const CreateTx = connect(
dispatch(change('createTx', 'balance', balance));
},
onEntireBalance: (value, fee) => {
// load account information for selected account
if (value) {
dispatch(change('createTx', 'value', value.sub(fee).getEther(8)));
const amount = new Wei(BigNumber.max(value.sub(fee).val, new BigNumber(0)));
dispatch(change('createTx', 'value', amount.getEther(8)));
}
},
onChangeGasLimit: (event, value) => {
Expand Down

0 comments on commit a731356

Please sign in to comment.