Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trivial] max button fix for erc20s #269

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions apps/bridge/src/components/BridgeInput/BridgeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export function BridgeInput({
});
const conversionRate =
conversionRateData && amount ? usdFormatter(conversionRateData * +amount) : '$0.00';
const networkLayer = networkToLayer(inputNetwork);
const selectedAssetSymbol =
networkLayer === 'L1' ? selectedAsset.L1symbol : selectedAsset.L2symbol;

function handleChangeAmount(e: { target: { value: SetStateAction<string> } }) {
const value = parseFloat(e.target.value.toString());
Expand Down Expand Up @@ -94,7 +97,11 @@ export function BridgeInput({
);

function setMaxBalance() {
setAmount((parseFloat(balance) * 0.99).toFixed(6).toString());
if (selectedAssetSymbol === 'ETH') {
setAmount((parseFloat(balance) * 0.99).toFixed(6).toString());
} else {
setAmount(balance);
}
}

const error =
Expand All @@ -108,10 +115,6 @@ export function BridgeInput({
input.current?.focus();
}

const networkLayer = networkToLayer(inputNetwork);
const selectedAssetSymbol =
networkLayer === 'L1' ? selectedAsset.L1symbol : selectedAsset.L2symbol;

return (
<div className="flex w-full max-w-xl flex-col p-6">
<span className="mb-4 font-mono text-sm font-medium text-white">NETWORK</span>
Expand Down