Skip to content

Commit

Permalink
fix: bug in amount input
Browse files Browse the repository at this point in the history
  • Loading branch information
anondev2323 committed Sep 8, 2023
1 parent e7a3f50 commit e78efab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
27 changes: 7 additions & 20 deletions wormhole-connect/src/views/Bridge/Inputs/AmountInput.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { RootState } from '../../../store';
import { validate } from '../../../utils/transferValidation';
import { toFixedDecimals } from '../../../utils/balance';
import { NO_INPUT } from '../../../utils/style';
import { RootState } from 'store';
import { validate } from 'utils/transferValidation';
import { toFixedDecimals } from 'utils/balance';
import { NO_INPUT } from 'utils/style';

import InputTransparent from '../../../components/InputTransparent';
import InputTransparent from 'components/InputTransparent';
import Input from './Input';

type Props = {
Expand All @@ -31,21 +31,8 @@ function AmountInput(props: Props) {
) {
let value = e!.target.value;
const index = value.indexOf('.');
switch (true) {
case index === 0: {
value = '0.';
break;
}
case Number.isInteger(Number.parseFloat(value)): {
break;
}
case index >= 0 && index < value.length - 1: {
value = toFixedDecimals(value, 8);
break;
}
default: {
break;
}
if (index > 0 && value.length - index - 8 > 0) {
value = toFixedDecimals(value, 8);
}

props.handleAmountChange(value);
Expand Down
3 changes: 2 additions & 1 deletion wormhole-connect/src/views/Bridge/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ function Preview(props: { collapsed: boolean }) {

useEffect(() => {
const computeRelayerFee = async () => {
if (!token || !fromChain || !toChain || !route) return;

try {
if (!token || !fromChain || !toChain || !route) return;
const tokenConfig = token && TOKENS[token];
if (!tokenConfig) return;

Expand Down

0 comments on commit e78efab

Please sign in to comment.