Skip to content

Commit de92563

Browse files
authored
Merge pull request #29 from syscoin/sponsor-wallet-implementation
fix: remove nevm minimum amount when foundation funding is available
2 parents ad64b0b + b8d7eb8 commit de92563

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

components/Bridge/WalletSwitchV2/NEVMConnect.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import WalletSwitchConfirmCard from "./ConfirmCard";
66
import { ITransfer } from "@contexts/Transfer/types";
77
import { useNevmBalance } from "utils/balance-hooks";
88
import { MIN_AMOUNT } from "@constants";
9+
import { useFeatureFlags } from "../v3/hooks/useFeatureFlags";
910

1011
type NEVMConnectProps = {
1112
transfer: ITransfer;
@@ -16,6 +17,7 @@ const minAmount = MIN_AMOUNT;
1617

1718
const NEVMConnect: React.FC<NEVMConnectProps> = ({ setNevm, transfer }) => {
1819
const { account, connect } = useNEVM();
20+
const { isEnabled } = useFeatureFlags();
1921
const { isBitcoinBased, switchTo, changeAccount, isEVMInjected } =
2022
usePaliWalletV2();
2123
const balance = useNevmBalance(transfer.nevmAddress);
@@ -41,8 +43,13 @@ const NEVMConnect: React.FC<NEVMConnectProps> = ({ setNevm, transfer }) => {
4143
if (isNaN(balanceNum)) {
4244
balanceNum = 0;
4345
}
46+
const foundationFundingAvailable =
47+
isEnabled("foundationFundingAvailable") &&
48+
transfer.type === "sys-to-nevm";
4449
const faucetLink =
45-
balance.isFetched && balanceNum < minAmount ? (
50+
balance.isFetched &&
51+
balanceNum < minAmount &&
52+
!foundationFundingAvailable ? (
4653
<Alert severity="warning">
4754
<Typography variant="body2">
4855
You don&apos;t have enough balance. Please go to&nbsp;

components/Bridge/v3/Steps/ConnectValidate.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import NEVMConnect from "components/Bridge/WalletSwitchV2/NEVMConnect";
1919
import { useNevmBalance, useUtxoBalance } from "utils/balance-hooks";
2020
import { ITransfer, TransferStatus } from "@contexts/Transfer/types";
2121
import { useRouter } from "next/router";
22-
import NextLink from "next/link";
23-
import CompareArrows from "@mui/icons-material/CompareArrows";
2422
import { MIN_AMOUNT } from "@constants";
23+
import { useFeatureFlags } from "../hooks/useFeatureFlags";
2524

2625
const ErrorMessage = ({ message }: { message: string }) => (
2726
<Box sx={{ display: "flex", mb: 2 }}>
@@ -49,6 +48,7 @@ const BridgeV3ConnectValidateStep: React.FC<
4948
const { replace } = useRouter();
5049
const { transfer, isSaving, saveTransfer } = useTransfer();
5150
const { isLoading } = usePaliWalletV2();
51+
const { isEnabled } = useFeatureFlags();
5252
const {
5353
register,
5454
setValue,
@@ -79,7 +79,11 @@ const BridgeV3ConnectValidateStep: React.FC<
7979
utxoBalance.data !== undefined &&
8080
utxoBalance.data < minAmount;
8181

82+
const foundationFundingAvailable =
83+
isEnabled("foundationFundingAvailable") && transfer.type === "sys-to-nevm";
84+
8285
const isNevmNotEnoughGas =
86+
!foundationFundingAvailable &&
8387
Boolean(nevmAddress) &&
8488
nevmBalance.isFetched &&
8589
nevmBalance.data !== undefined &&
@@ -98,7 +102,8 @@ const BridgeV3ConnectValidateStep: React.FC<
98102

99103
const isUtxoValid = isValidSYSAddress(utxoAddress, 57) && !isUtxoNotEnoughGas;
100104
const isNevmValid =
101-
isValidEthereumAddress(nevmAddress) && !isNevmNotEnoughGas;
105+
isValidEthereumAddress(nevmAddress) &&
106+
(!isNevmNotEnoughGas || foundationFundingAvailable);
102107
const isAmountValid = errors.amount === undefined;
103108
const balanceFetched = utxoBalance.isFetched && nevmBalance.isFetched;
104109
const isReady = isUtxoValid && isNevmValid && isAmountValid && balanceFetched;

0 commit comments

Comments
 (0)