Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 7781ec7

Browse files
authored
fix: disable staking when user has no baby (#1286)
* fix: disable staking when user has no BABY
1 parent 689e559 commit 7781ec7

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/ui/common/state/MultistakingState.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function MultistakingState({ children }: PropsWithChildren) {
7373
? networkInfo.params.bbnStakingParams.latestParam.maxFinalityProviders
7474
: DEFAULT_MAX_FINALITY_PROVIDERS;
7575

76-
const { stakableBtcBalance } = useBalanceState();
76+
const { stakableBtcBalance, bbnBalance } = useBalanceState();
7777
const { stakingInfo } = useStakingState();
7878

7979
const formFields: FieldOptions[] = useMemo(
@@ -135,10 +135,13 @@ export function MultistakingState({ children }: PropsWithChildren) {
135135
"Staking amount must have no more than 8 decimal points.",
136136
(_, context) => validateDecimalPoints(context.originalValue),
137137
)
138-
// ???
139-
.test("insufficientFunds", "Insufficient BTC", () => true),
138+
.test(
139+
"insufficientBabyBalance",
140+
"Insufficient BABY Balance",
141+
() => bbnBalance > 0,
142+
),
140143
errors: {
141-
invalidFormat: { level: "error" },
144+
invalidFormat: { level: "error" },
142145
},
143146
},
144147
{
@@ -166,7 +169,7 @@ export function MultistakingState({ children }: PropsWithChildren) {
166169
.moreThan(0, "Staking fee amount must be greater than 0."),
167170
},
168171
] as const,
169-
[stakingInfo, stakableBtcBalance, maxFinalityProviders],
172+
[stakingInfo, stakableBtcBalance, bbnBalance, maxFinalityProviders],
170173
);
171174

172175
const validationSchema = useMemo(() => {

src/ui/legacy/state/MultistakingState.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function MultistakingState({ children }: PropsWithChildren) {
5959
const [stakingModalPage, setStakingModalPage] = useState<StakingModalPage>(
6060
StakingModalPage.DEFAULT,
6161
);
62-
const { stakableBtcBalance } = useBalanceState();
62+
const { stakableBtcBalance, bbnBalance } = useBalanceState();
6363
const { stakingInfo } = useStakingState();
6464

6565
const formFields: FieldOptions[] = useMemo(
@@ -118,10 +118,13 @@ export function MultistakingState({ children }: PropsWithChildren) {
118118
"Staking amount must have no more than 8 decimal points.",
119119
(_, context) => validateDecimalPoints(context.originalValue),
120120
)
121-
// ???
122-
.test("insufficientFunds", "Insufficient BTC", () => true),
121+
.test(
122+
"insufficientBabyBalance",
123+
"Insufficient BABY Balance",
124+
() => bbnBalance > 0,
125+
),
123126
errors: {
124-
invalidFormat: { level: "error" },
127+
invalidFormat: { level: "error" },
125128
},
126129
},
127130
{
@@ -149,7 +152,7 @@ export function MultistakingState({ children }: PropsWithChildren) {
149152
.moreThan(0, "Staking fee amount must be greater than 0."),
150153
},
151154
] as const,
152-
[stakingInfo, stakableBtcBalance],
155+
[stakingInfo, stakableBtcBalance, bbnBalance],
153156
);
154157

155158
const validationSchema = useMemo(() => {

0 commit comments

Comments
 (0)