Skip to content

Commit

Permalink
Fix estimating fees nonstop spinning
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed Aug 11, 2024
1 parent d298701 commit 27c45c2
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/keychain/src/components/Execute/Fees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import { EthereumIcon } from "@cartridge/ui";

export function Fees({
fees,
balance,
approved,
}: {
fees?: { base: bigint; max: bigint };
balance: string;
approved?: string;
}) {
const chainId = useChainId();
Expand All @@ -21,24 +19,24 @@ export function Fees({
}>();

useEffect(() => {
if (!fees || !balance) {
if (!fees) {
return;
}
async function compute() {
setFormattedFee(
fees.max > 10000000000000n
? {
base: `~${parseFloat(formatUnits(fees.base, 18)).toFixed(5)} eth`,
max: `~${parseFloat(formatUnits(fees.max, 18)).toFixed(5)} eth`,
}
base: `~${parseFloat(formatUnits(fees.base, 18)).toFixed(5)} eth`,
max: `~${parseFloat(formatUnits(fees.max, 18)).toFixed(5)} eth`,
}
: {
base: "<0.00001",
max: "<0.00001",
},
base: "<0.00001",
max: "<0.00001",
},
);
}
compute();
}, [chainId, fees, balance, approved]);
}, [chainId, fees, approved]);

return (
<VStack
Expand Down

0 comments on commit 27c45c2

Please sign in to comment.