Skip to content

Commit

Permalink
fix: BNInput
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelylovas committed Sep 12, 2024
1 parent 84cca37 commit b5edf48
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/common/BNInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CircularProgress,
} from '@avalabs/core-k2-components';
import { TokenUnit } from '@avalabs/core-utils-sdk';
import { stringToBigint } from '@src/utils/stringToBigint';

Big.PE = 99;
Big.NE = -18;
Expand Down Expand Up @@ -90,13 +91,21 @@ export function BNInput({
const [, endValue] = splitBN(newValueString); // renamed callback param

if (!endValue || endValue.length <= denomination) {
const newValue = new TokenUnit(newValueString || '0', denomination, '');
const newValue = new TokenUnit(
stringToBigint(newValueString || '0', denomination),
denomination,
''
);

if (newValue.toSubUnit() < min) {
return;
}

const oldValue = new TokenUnit(valStr || '', denomination, '');
const oldValue = new TokenUnit(
stringToBigint(valStr || '0', denomination),
denomination,
''
);
if (!newValue.eq(oldValue)) {
onChange?.({
amount: newValue.toDisplay(),
Expand Down

0 comments on commit b5edf48

Please sign in to comment.