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

fix: remove nevm minimum amount when foundation funding is available #29

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion components/Bridge/WalletSwitchV2/NEVMConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import WalletSwitchConfirmCard from "./ConfirmCard";
import { ITransfer } from "@contexts/Transfer/types";
import { useNevmBalance } from "utils/balance-hooks";
import { MIN_AMOUNT } from "@constants";
import { useFeatureFlags } from "../v3/hooks/useFeatureFlags";

type NEVMConnectProps = {
transfer: ITransfer;
Expand All @@ -16,6 +17,7 @@ const minAmount = MIN_AMOUNT;

const NEVMConnect: React.FC<NEVMConnectProps> = ({ setNevm, transfer }) => {
const { account, connect } = useNEVM();
const { isEnabled } = useFeatureFlags();
const { isBitcoinBased, switchTo, changeAccount, isEVMInjected } =
usePaliWalletV2();
const balance = useNevmBalance(transfer.nevmAddress);
Expand All @@ -41,8 +43,13 @@ const NEVMConnect: React.FC<NEVMConnectProps> = ({ setNevm, transfer }) => {
if (isNaN(balanceNum)) {
balanceNum = 0;
}
const foundationFundingAvailable =
isEnabled("foundationFundingAvailable") &&
transfer.type === "sys-to-nevm";
const faucetLink =
balance.isFetched && balanceNum < minAmount ? (
balance.isFetched &&
balanceNum < minAmount &&
!foundationFundingAvailable ? (
<Alert severity="warning">
<Typography variant="body2">
You don&apos;t have enough balance. Please go to&nbsp;
Expand Down
11 changes: 8 additions & 3 deletions components/Bridge/v3/Steps/ConnectValidate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import NEVMConnect from "components/Bridge/WalletSwitchV2/NEVMConnect";
import { useNevmBalance, useUtxoBalance } from "utils/balance-hooks";
import { ITransfer, TransferStatus } from "@contexts/Transfer/types";
import { useRouter } from "next/router";
import NextLink from "next/link";
import CompareArrows from "@mui/icons-material/CompareArrows";
import { MIN_AMOUNT } from "@constants";
import { useFeatureFlags } from "../hooks/useFeatureFlags";

const ErrorMessage = ({ message }: { message: string }) => (
<Box sx={{ display: "flex", mb: 2 }}>
Expand Down Expand Up @@ -49,6 +48,7 @@ const BridgeV3ConnectValidateStep: React.FC<
const { replace } = useRouter();
const { transfer, isSaving, saveTransfer } = useTransfer();
const { isLoading } = usePaliWalletV2();
const { isEnabled } = useFeatureFlags();
const {
register,
setValue,
Expand Down Expand Up @@ -79,7 +79,11 @@ const BridgeV3ConnectValidateStep: React.FC<
utxoBalance.data !== undefined &&
utxoBalance.data < minAmount;

const foundationFundingAvailable =
isEnabled("foundationFundingAvailable") && transfer.type === "sys-to-nevm";

const isNevmNotEnoughGas =
!foundationFundingAvailable &&
Boolean(nevmAddress) &&
nevmBalance.isFetched &&
nevmBalance.data !== undefined &&
Expand All @@ -98,7 +102,8 @@ const BridgeV3ConnectValidateStep: React.FC<

const isUtxoValid = isValidSYSAddress(utxoAddress, 57) && !isUtxoNotEnoughGas;
const isNevmValid =
isValidEthereumAddress(nevmAddress) && !isNevmNotEnoughGas;
isValidEthereumAddress(nevmAddress) &&
(!isNevmNotEnoughGas || foundationFundingAvailable);
const isAmountValid = errors.amount === undefined;
const balanceFetched = utxoBalance.isFetched && nevmBalance.isFetched;
const isReady = isUtxoValid && isNevmValid && isAmountValid && balanceFetched;
Expand Down