Skip to content

Commit

Permalink
fixup change denom
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Jan 4, 2024
1 parent 15e1291 commit bdf54b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { calculateReceiveAmount, calculateSendAmount } from "./utils/calculate";
import {
calculateDigits,
convertAmount,
denominations,
formatAmount,
getValidationRegex,
} from "./utils/denomination";
Expand All @@ -61,7 +62,7 @@ const Create = () => {

// if btc and amount > 100, switch to sat
// user failed to notice the non satoshi denomination
const changeDenomination = () => {
const changeDenomination = (amount: number) => {
if (denomination() === denominations.btc && amount > 99) {
setDenomination(denominations.sat);
}
Expand All @@ -70,6 +71,7 @@ const Create = () => {
const changeReceiveAmount = (evt: InputEvent) => {
const target = evt.currentTarget as HTMLInputElement;
const amount = Number(target.value.trim());
changeDenomination(amount);
const satAmount = convertAmount(amount, denomination());
const sendAmount = calculateSendAmount(satAmount);
setAmountChanged(sideReceive);
Expand All @@ -83,8 +85,8 @@ const Create = () => {
const changeSendAmount = (evt: InputEvent) => {
const target = evt.currentTarget as HTMLInputElement;
const amount = Number(target.value.trim());
changeDenomination(amount);
const satAmount = convertAmount(amount, denomination());
changeDenomination();
const receiveAmount = calculateReceiveAmount(satAmount);
setAmountChanged(sideSend);
setSendAmount(BigNumber(satAmount));
Expand Down

0 comments on commit bdf54b5

Please sign in to comment.