Skip to content

Commit

Permalink
problem: SignTx dialog renders wrong tx value
Browse files Browse the repository at this point in the history
  • Loading branch information
gagarin55 committed Jun 12, 2018
1 parent 43dc2a9 commit a8aa083
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/components/tx/SendTx/CreateTx/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const CreateTx = connect(
to: data.to,
gas: data.gas,
gasPrice: data.gasPrice,
value: convert.toBigNumber(data.value),
};

let nativeTx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,23 @@ const displayFlexCenter = {
alignItems: 'center',
};

const SignTx = muiThemeable()((props) => {
const { value, fiatRate, fiatCurrency, fee, tx } = props;
const { onCancel, handleSubmit } = props;
export const SignTx = ((props) => {
const { fiatRate, fiatCurrency, fee, tx, nativeTx } = props;
const { onCancel, handleSubmit, muiTheme } = props;

// const USDValue = Currency.format(Currency.convert(value, fiatRate, 2), fiatCurrency);

console.error(typeof tx.value);
console.error(tx);
console.error(nativeTx);
return (
<div>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: '50px' }}>
<HorizontalAddressWithIdentity accountId={tx.from} />
<div style={{ display: 'flex', alignItems: 'center', flexDirection: 'column', justifyContent: 'space-between' }}>
<div style={{ ...displayFlexCenter, flexDirection: 'column' }}>
{/* <div>{USDValue} USD</div> */}
<div style={{fontSize: '28px'}}>{trimEnd(value, '0')} {tx.symbol}</div>
<div style={{fontSize: '28px'}}>{tx.value.toFixed()} {tx.symbol}</div>
</div>
<div style={{display: 'flex'}}>
<ArrowRight />
Expand All @@ -75,7 +78,7 @@ const SignTx = muiThemeable()((props) => {
<HorizontalAddressWithIdentity accountId={tx.to} />
</div>
<div style={{ paddingTop: '35px', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: props.muiTheme.palette.secondaryTextColor }}>
<span style={{ color: muiTheme.palette.secondaryTextColor }}>
Plus a {trimEnd(fee.getDecimalized(), '0')} ETC fee for 21000 GAS
</span>
</div>
Expand All @@ -102,6 +105,6 @@ const SignTxForm = reduxForm({
destroyOnUnmount: false,
enableReinitialize: true,
forceUnregisterOnUnmount: true,
})(SignTx);
})(muiThemeable()(SignTx));

export default SignTxForm;
32 changes: 32 additions & 0 deletions src/components/tx/SendTx/SignTx/SignTx.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { shallow } from 'enzyme';
import { convert } from 'emerald-js';
import { SignTx } from './SignTx';
import TokenUnits from '../../../../lib/tokenUnits';

const mockMuiTheme = {
palette: {
secondTextColor: 'red',
},
};

describe('SignTx', () => {
it('should render tx value correctly', () => {
let tx = {
value: convert.toBigNumber('100.0000'),
};
const fee = new TokenUnits(2000, 18);

let component = shallow(<SignTx muiTheme={mockMuiTheme} tx={tx} fee={fee} />);
expect(component).toBeDefined();
expect(component.findWhere((n) => n.text() === '100')).toHaveLength(1);

tx = {
value: convert.toBigNumber('100.0120'),
};

component = shallow(<SignTx muiTheme={mockMuiTheme} tx={tx} fee={fee} />);
expect(component).toBeDefined();
expect(component.findWhere((n) => n.text() === '100.012')).toHaveLength(1);
});
});
2 changes: 1 addition & 1 deletion src/components/tx/SendTx/SignTx/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default} from './SignTxForm';
export {default} from './SignTx';

0 comments on commit a8aa083

Please sign in to comment.