Skip to content

Commit

Permalink
fix(cashier): 🚑 crypto amounts not properly converted (#13735)
Browse files Browse the repository at this point in the history
  • Loading branch information
heorhi-deriv committed Feb 21, 2024
1 parent 76a4e8b commit 3e132ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type TCryptoFiatConverterProps = {
) => void;
onChangeConverterToAmount: (
event: TReactChangeEvent,
from_currency: string,
to_currency: string,
from_currency: string,
converted_amount?: number
) => void;
resetConverter: VoidFunction;
Expand Down Expand Up @@ -130,7 +130,7 @@ const CryptoFiatConverter = observer(
onChange={(e: TReactChangeEvent) => {
const rate = exchange_rates?.[to_currency]?.[from_currency] ?? 0;
const converted_amount = Number(e.target.value) * rate;
onChangeConverterToAmount(e, from_currency, to_currency, converted_amount);
onChangeConverterToAmount(e, to_currency, from_currency, converted_amount);
handleChange(e);
}}
type='text'
Expand Down
4 changes: 2 additions & 2 deletions packages/cashier/src/stores/crypto-fiat-converter-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export default class CryptoFiatConverterStore {

async onChangeConverterToAmount(
{ target }: { target: { value: string } },
from_currency: string,
to_currency: string,
from_currency: string,
converted_amount?: number
): Promise<void> {
const { account_transfer, general_store } = this.root_store.modules.cashier;
Expand All @@ -129,7 +129,7 @@ export default class CryptoFiatConverterStore {
this.setIsTimerVisible(false);
account_transfer.setAccountTransferAmount('');
} else {
const decimals = getDecimalPlaces(to_currency);
const decimals = getDecimalPlaces(from_currency);
const amount = converted_amount?.toFixed(decimals) || '1';
if (+amount || this.converter_to_amount) {
this.setConverterFromAmount(amount);
Expand Down

0 comments on commit 3e132ef

Please sign in to comment.