Merge branch 'dev' into myf-dev
This commit is contained in:
commit
6b965eef3c
|
|
@ -18,6 +18,12 @@ export const unstakeBoard = async (masterChefContract) => {
|
|||
return receipt.status
|
||||
}
|
||||
|
||||
export const unstakeForceBoard = async (masterChefContract) => {
|
||||
const tx = await masterChefContract.emergencyWithdrawHCC(options)
|
||||
const receipt = await tx.wait()
|
||||
return receipt.status
|
||||
}
|
||||
|
||||
export const harvestBoard = async (masterChefContract) => {
|
||||
const tx = await masterChefContract.harvest(options)
|
||||
const receipt = await tx.wait()
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ interface NodeCardProps {
|
|||
account?: string
|
||||
}
|
||||
|
||||
const NodeCard: React.FC<NodeCardProps> = ({ board, account }) => {
|
||||
const BoardCard: React.FC<NodeCardProps> = ({ board, account }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const [showExpandableSection, setShowExpandableSection] = useState(false)
|
||||
|
|
@ -116,4 +116,4 @@ const NodeCard: React.FC<NodeCardProps> = ({ board, account }) => {
|
|||
)
|
||||
}
|
||||
|
||||
export default NodeCard
|
||||
export default BoardCard
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { useTranslation } from 'contexts/Localization'
|
|||
import useToast from 'hooks/useToast'
|
||||
import DepositModal from '../DepositModal'
|
||||
import useStakeBoard from '../../hooks/useStakeBoard'
|
||||
import useUnstakeBoard from '../../hooks/useUnstakeBoard'
|
||||
import useUnstakeBoard, { useUnstakeForceBoard } from '../../hooks/useUnstakeBoard'
|
||||
import WithdrawModal from '../WithdrawModal'
|
||||
|
||||
interface NodeCardActionsProps {
|
||||
|
|
@ -31,6 +31,7 @@ const StakeAction: React.FC<NodeCardActionsProps> = ({ stakedBalance, tokenBalan
|
|||
const { toastWarning } = useToast()
|
||||
const { onStake } = useStakeBoard(pid)
|
||||
const { onUnstake } = useUnstakeBoard(pid)
|
||||
const { onUnstake: onUnstakeForce } = useUnstakeForceBoard(pid)
|
||||
const { tokenDecimals = 18, minStakeAmount, userData } = useBoardsFromPid(pid)
|
||||
const rawStakedBalance = getBalanceNumber(stakedBalance, tokenDecimals, 8)
|
||||
const minStakedAmount = useMemo(() => {
|
||||
|
|
@ -52,11 +53,11 @@ const StakeAction: React.FC<NodeCardActionsProps> = ({ stakedBalance, tokenBalan
|
|||
const handleUnstake = () => {
|
||||
const unlockTime = userData.unlockTime * 1000
|
||||
if (unlockTime > new Date().getTime()) {
|
||||
toastWarning(t('Unlock time %unlockTime%', { unlockTime: dayjs(unlockTime).format('YYYY-MM-DD HH:mm') }))
|
||||
return
|
||||
}
|
||||
onUnstakeForce()
|
||||
} else {
|
||||
onUnstake()
|
||||
}
|
||||
}
|
||||
const renderStakingButtons = () => {
|
||||
return rawStakedBalance === 0 ? (
|
||||
<Button onClick={onPresentDeposit}>{t(`pledge`)}</Button>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useCallback } from 'react'
|
||||
import { unstakeBoard } from 'utils/calls'
|
||||
import { unstakeBoard, unstakeForceBoard } from 'utils/calls'
|
||||
import { useBoardchef } from 'hooks/useContract'
|
||||
|
||||
const useUnstakeBoard = (pid: number) => {
|
||||
|
|
@ -12,4 +12,14 @@ const useUnstakeBoard = (pid: number) => {
|
|||
return { onUnstake: handleUnstake }
|
||||
}
|
||||
|
||||
export const useUnstakeForceBoard = (pid: number) => {
|
||||
const boardChefContract = useBoardchef(pid)
|
||||
|
||||
const handleUnstake = useCallback(async () => {
|
||||
await unstakeForceBoard(boardChefContract)
|
||||
}, [boardChefContract, pid])
|
||||
|
||||
return { onUnstake: handleUnstake }
|
||||
}
|
||||
|
||||
export default useUnstakeBoard
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import Page from 'components/Layout/Page'
|
|||
import { useBoards } from 'state/hooks'
|
||||
import useRefresh from 'hooks/useRefresh'
|
||||
import { fetchBoardUserDataAsync, fetchBoardsPublicDataAsync } from 'state/actions'
|
||||
import { fetchBoardUserInfo } from 'state/boards/fetchBoardsUser'
|
||||
import { useAccount } from 'state/userInfo/hooks'
|
||||
import { useTranslation } from 'contexts/Localization'
|
||||
import BoardCard from './components/BoardCard/BoardCard'
|
||||
import HeaderItem from './components/HeaderItem'
|
||||
|
|
@ -43,8 +43,7 @@ const FlexLayoutMain = styled(FlexLayout)`
|
|||
const Boards: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const boardsList = useBoards()
|
||||
const [query, setQuery] = useState('')
|
||||
const { account } = useWeb3React()
|
||||
const account = useAccount()
|
||||
|
||||
const dispatch = useDispatch()
|
||||
const { fastRefresh } = useRefresh()
|
||||
|
|
|
|||
Loading…
Reference in New Issue