-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from threshold-network/min-stake-validation
Minimum Stake validation This PR adds validation to the staking form. To stake in T network the minimum stake amount is required. Currently it is 40,000 T. Main changes: - set the placeholder for input in staking form- Minimum stake <amount> T, - create a hook that returns the min stake amount- it fetches the min stake amount if needed and saves in a redux store. If a value already exists in redux store a hook will return a value from redux store, otherwise fetches the value from chain, - update the TokenAmountForm - allow to set the placeholder for an input and set the required minimum amount to submit a form.
- Loading branch information
Showing
6 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useEffect } from "react" | ||
import { useDispatch } from "react-redux" | ||
import { setMinStake } from "../store/staking" | ||
import { useTStakingContract } from "../web3/hooks" | ||
import { useStakingState } from "./useStakingState" | ||
|
||
export const useMinStakeAmount = () => { | ||
const tStakingContract = useTStakingContract() | ||
const { minStakeAmount } = useStakingState() | ||
const dispatch = useDispatch() | ||
|
||
useEffect(() => { | ||
const fetchMinStakeAmount = async () => { | ||
try { | ||
const minStakeAmount = await tStakingContract?.minTStakeAmount() | ||
dispatch(setMinStake({ amount: minStakeAmount.toString() })) | ||
} catch (error) { | ||
console.error("Could not fetch the min stake amount: ", error) | ||
} | ||
} | ||
if (minStakeAmount === "0" && tStakingContract) fetchMinStakeAmount() | ||
}, [tStakingContract, dispatch, minStakeAmount]) | ||
|
||
return minStakeAmount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters