diff --git a/src/components/ManaCalculator/components/OtherParametersSection.tsx b/src/components/ManaCalculator/components/OtherParametersSection.tsx index 5d60e49610d..47168441cc1 100644 --- a/src/components/ManaCalculator/components/OtherParametersSection.tsx +++ b/src/components/ManaCalculator/components/OtherParametersSection.tsx @@ -35,6 +35,8 @@ export function OtherParametersSection() { handleInitialEpochChange(Number(e.target.value))} > @@ -42,6 +44,8 @@ export function OtherParametersSection() { handleFinalEpochChange(Number(e.target.value))} > diff --git a/src/components/ManaCalculator/components/RoleSection.tsx b/src/components/ManaCalculator/components/RoleSection.tsx index 48c4bc26f21..b01b96f3d9a 100644 --- a/src/components/ManaCalculator/components/RoleSection.tsx +++ b/src/components/ManaCalculator/components/RoleSection.tsx @@ -37,6 +37,8 @@ export function RoleSection() { handleOwnHoldChange(toMicro(Number(e.target.value)))} > @@ -46,6 +48,8 @@ export function RoleSection() { handleOwnStakeChange(toMicro(Number(e.target.value))) @@ -72,6 +76,8 @@ export function RoleSection() { handleOwnStakeChange(toMicro(Number(e.target.value))) diff --git a/src/components/ManaCalculator/components/ValidatorCard.tsx b/src/components/ManaCalculator/components/ValidatorCard.tsx index 517a5293a46..d35772cd7b3 100644 --- a/src/components/ManaCalculator/components/ValidatorCard.tsx +++ b/src/components/ManaCalculator/components/ValidatorCard.tsx @@ -22,11 +22,14 @@ export function ValidatorCard({
Validator {id + 1}
handleStakeChange(toMicro(Number(e.target.value)), id)} > handleDelegatedStakeChange(toMicro(Number(e.target.value)), id) @@ -36,12 +39,15 @@ export function ValidatorCard({ className='col col--2 align-right horizontal-spaced' type='number' step='0.01' + min='0' + max='1' value={validator.performanceFactor} onChange={(e) => handlePFChange(Number(e.target.value), id)} > handleFCChange(Number(e.target.value), id)} diff --git a/src/components/ManaCalculator/components/ValidatorSettings.tsx b/src/components/ManaCalculator/components/ValidatorSettings.tsx index 95be4df6508..f8c6e951ded 100644 --- a/src/components/ManaCalculator/components/ValidatorSettings.tsx +++ b/src/components/ManaCalculator/components/ValidatorSettings.tsx @@ -27,6 +27,8 @@ export function ValidatorSettings() { Fixed costs handleShareOfYourStakeLockedChange(Number(e.target.value)) } @@ -56,6 +62,8 @@ export function ValidatorSettings() { handleAttractedNewDelegatedStakeChange(Number(e.target.value)) @@ -67,6 +75,10 @@ export function ValidatorSettings() { handleAttractedDelegatedStakeFromOtherPoolsChange( diff --git a/src/components/ManaCalculator/hooks/useManaState.ts b/src/components/ManaCalculator/hooks/useManaState.ts index 92f5c47b90c..167475f72ce 100644 --- a/src/components/ManaCalculator/hooks/useManaState.ts +++ b/src/components/ManaCalculator/hooks/useManaState.ts @@ -64,6 +64,7 @@ export function useGivenManaState( } function handlePFChange(value: number, id: number) { + if (value < 0 || value > 1) return; setState({ ...state, validators: state.validators.map((validator, i) => { @@ -88,6 +89,7 @@ export function useGivenManaState( } function handleOwnStakeChange(value: number) { + if (value > state.heldTokens) return; setState({ ...state, [getStakedOrDelegated(state.userType)]: value, @@ -109,6 +111,7 @@ export function useGivenManaState( } function handleOwnPFChange(value: number) { + if (value < 0 || value > 1) return; setState({ ...state, validator: { ...state.validator, performanceFactor: value }, @@ -147,6 +150,7 @@ export function useGivenManaState( } function handleInitialEpochChange(value: number) { + if (value > state.finalEpoch) return; setState({ ...state, initialEpoch: value, @@ -154,6 +158,7 @@ export function useGivenManaState( } function handleFinalEpochChange(value: number) { + if (state.initialEpoch > value) return; setState({ ...state, finalEpoch: value,