diff --git a/src/ui/common/state/MultistakingState.tsx b/src/ui/common/state/MultistakingState.tsx index 5a8afedbb..1f6d2c2ea 100644 --- a/src/ui/common/state/MultistakingState.tsx +++ b/src/ui/common/state/MultistakingState.tsx @@ -73,7 +73,7 @@ export function MultistakingState({ children }: PropsWithChildren) { ? networkInfo.params.bbnStakingParams.latestParam.maxFinalityProviders : DEFAULT_MAX_FINALITY_PROVIDERS; - const { stakableBtcBalance } = useBalanceState(); + const { stakableBtcBalance, bbnBalance } = useBalanceState(); const { stakingInfo } = useStakingState(); const formFields: FieldOptions[] = useMemo( @@ -135,10 +135,13 @@ export function MultistakingState({ children }: PropsWithChildren) { "Staking amount must have no more than 8 decimal points.", (_, context) => validateDecimalPoints(context.originalValue), ) - // ??? - .test("insufficientFunds", "Insufficient BTC", () => true), + .test( + "insufficientBabyBalance", + "Insufficient BABY Balance", + () => bbnBalance > 0, + ), errors: { - invalidFormat: { level: "error" }, + invalidFormat: { level: "error" }, }, }, { @@ -166,7 +169,7 @@ export function MultistakingState({ children }: PropsWithChildren) { .moreThan(0, "Staking fee amount must be greater than 0."), }, ] as const, - [stakingInfo, stakableBtcBalance, maxFinalityProviders], + [stakingInfo, stakableBtcBalance, bbnBalance, maxFinalityProviders], ); const validationSchema = useMemo(() => { diff --git a/src/ui/legacy/state/MultistakingState.tsx b/src/ui/legacy/state/MultistakingState.tsx index 5f4445940..d39de52bc 100644 --- a/src/ui/legacy/state/MultistakingState.tsx +++ b/src/ui/legacy/state/MultistakingState.tsx @@ -59,7 +59,7 @@ export function MultistakingState({ children }: PropsWithChildren) { const [stakingModalPage, setStakingModalPage] = useState( StakingModalPage.DEFAULT, ); - const { stakableBtcBalance } = useBalanceState(); + const { stakableBtcBalance, bbnBalance } = useBalanceState(); const { stakingInfo } = useStakingState(); const formFields: FieldOptions[] = useMemo( @@ -118,10 +118,13 @@ export function MultistakingState({ children }: PropsWithChildren) { "Staking amount must have no more than 8 decimal points.", (_, context) => validateDecimalPoints(context.originalValue), ) - // ??? - .test("insufficientFunds", "Insufficient BTC", () => true), + .test( + "insufficientBabyBalance", + "Insufficient BABY Balance", + () => bbnBalance > 0, + ), errors: { - invalidFormat: { level: "error" }, + invalidFormat: { level: "error" }, }, }, { @@ -149,7 +152,7 @@ export function MultistakingState({ children }: PropsWithChildren) { .moreThan(0, "Staking fee amount must be greater than 0."), }, ] as const, - [stakingInfo, stakableBtcBalance], + [stakingInfo, stakableBtcBalance, bbnBalance], ); const validationSchema = useMemo(() => {