Skip to content

Commit

Permalink
removed the 'max delegator' rule for the validator field from the Und…
Browse files Browse the repository at this point in the history
…elegate flow
  • Loading branch information
ost-ptk committed Dec 19, 2023
1 parent 8a5f8fb commit 93e2d57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/libs/ui/forms/form-validation-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ export const useCSPRStakeAmountRule = (
});
};

export const useValidatorPublicKeyRule = (delegatorsNumber?: number) => {
export const useValidatorPublicKeyRule = (
stakesType: AuctionManagerEntryPoint,
delegatorsNumber?: number
) => {
const { t } = useTranslation();

return Yup.string()
Expand All @@ -381,7 +384,16 @@ export const useValidatorPublicKeyRule = (delegatorsNumber?: number) => {
})
.test({
name: 'maxDelegators',
test: () => !(delegatorsNumber && delegatorsNumber >= MAX_DELEGATORS),
test: () => {
if (stakesType === AuctionManagerEntryPoint.undelegate) {
return true;
}
if (delegatorsNumber) {
return delegatorsNumber < MAX_DELEGATORS;
}

return false;
},
message: t(
'This validator has reached the network limit for total delegators and therefore cannot be delegated to by new accounts. Please select another validator with fewer than 1200 total delegators'
)
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ui/forms/stakes-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useStakesForm = (
delegatorsNumber?: number
) => {
const validatorFormSchema = Yup.object().shape({
validatorPublicKey: useValidatorPublicKeyRule(delegatorsNumber)
validatorPublicKey: useValidatorPublicKeyRule(stakesType, delegatorsNumber)
});

const validatorFormOptions: UseFormProps<StakeValidatorFormValues> = {
Expand Down

0 comments on commit 93e2d57

Please sign in to comment.