Skip to content

Commit

Permalink
feat(namadillo): improving fee component
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrorezende committed Jul 3, 2024
1 parent 4d2eb6e commit be50b4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions apps/namadillo/src/App/Common/TransactionFees.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gasLimitsAtom, minimumGasPriceAtom } from "atoms/fees";
import clsx from "clsx";
import { useAtomValue } from "jotai";
import { TxKind, gasLimitsAtom, minimumGasPriceAtom } from "slices/fees";
import { TxKind } from "types";
import { NamCurrency } from "./NamCurrency";
import { TextLink } from "./TextLink";

type TransactionFeesProps = {
txKind: TxKind;
Expand All @@ -18,15 +18,17 @@ export const TransactionFees = ({
const gasLimits = useAtomValue(gasLimitsAtom);
const gasPrice = useAtomValue(minimumGasPriceAtom);

if (!gasLimits.isSuccess || !gasPrice.isSuccess) return <></>;
if (!gasLimits.isSuccess || !gasPrice.isSuccess || numberOfTransactions === 0)
return <></>;

return (
<div className={clsx("text-white text-sm", className)}>
<TextLink>Transaction fee:</TextLink>{" "}
Transaction fee:{" "}
<NamCurrency
className="font-medium"
forceBalanceDisplay={true}
amount={gasLimits.data[txKind].native.multipliedBy(
numberOfTransactions
amount={gasPrice.data.multipliedBy(
gasLimits.data[txKind].native.multipliedBy(numberOfTransactions)
)}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion apps/namadillo/src/atoms/fees/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const fetchMinimumGasPrice = async (
({ token }) => token === nativeToken
);
invariant(!!nativeTokenCost, "Error querying minimum gas price");
const asBigNumber = new BigNumber(nativeTokenCost.amount);
// TODO: this should be removed after indexer error is fixed!
const asBigNumber = new BigNumber(nativeTokenCost.amount).dividedBy(100000);
invariant(
!asBigNumber.isNaN(),
"Error converting minimum gas price to BigNumber"
Expand Down

0 comments on commit be50b4a

Please sign in to comment.