Skip to content

Commit

Permalink
Inputting 0.000000001 into the send form creates 1e-9 #225
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiaszCudnik committed Jun 11, 2019
1 parent fbdc8a2 commit abf5602
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/content/SendCoinsDialogContent.tsx
Expand Up @@ -227,7 +227,7 @@ class SendCoinsDialogContent extends React.Component<DecoratedProps, State> {
handleAmountBlur = () => {
const amountInvalid = !!this.state.amount && !!this.amountError();
const amount = this.state.parsedAmount
? this.state.parsedAmount.unit.toNumber().toString()
? this.state.parsedAmount.unit.toString()
: '';
this.setState({
amountInvalid,
Expand Down
4 changes: 3 additions & 1 deletion src/utils/utils.ts
Expand Up @@ -7,6 +7,7 @@ import { RawAmount } from './amounts';

// magic...
const epoch = Date.UTC(2016, 4, 24, 17, 0, 0, 0) / 1000;
BigNumber.config({ EXPONENTIAL_AT: 1e+9 });

export function timestampToUnix(timestamp: number) {
return new Date((timestamp + epoch) * 1000).getTime();
Expand Down Expand Up @@ -78,7 +79,8 @@ export function normalizeNumber(intl: InjectedIntl, value: string): string {
if (isNaN(n.toNumber())) {
return '';
}
return n.toString();
const minSafe = BigNumber.max(n, new BigNumber(0.00000001));
return minSafe.toString();
} catch (e) {
return '';
}
Expand Down

0 comments on commit abf5602

Please sign in to comment.