From 99f6a250cf8dcecb4442f070ee67c252aba1dafd Mon Sep 17 00:00:00 2001 From: gary <1032230992@qq.com> Date: Fri, 29 Apr 2022 15:19:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A2=86=E5=8F=96board=E6=94=B6?= =?UTF-8?q?=E7=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 19 +++-- src/utils/calls/boards.ts | 4 +- .../BoardCard/CardActionsContainer.tsx | 11 ++- .../components/BoardCard/HarvestAction.tsx | 69 +++++++++++++++++++ src/views/Board/hooks/useHarvestBoard.ts | 2 +- 5 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 src/views/Board/components/BoardCard/HarvestAction.tsx diff --git a/.env.production b/.env.production index 3a8a270..ba50e11 100644 --- a/.env.production +++ b/.env.production @@ -1,18 +1,23 @@ -REACT_APP_CHAIN_ID = "56" -REACT_APP_GTAG = "GTM-TLF66T4" +REACT_APP_CHAIN_ID = "97" +REACT_APP_GTAG = "GTM-PXLD3XW" # 10+ nodes balanced, US/EU -REACT_APP_NODE_1 = "https://bsc-dataseed1.ninicoin.io" +REACT_APP_NODE_1 = "https://data-seed-prebsc-1-s1.binance.org:8545" # 10+ nodes balanced, US/EU -REACT_APP_NODE_2 = "https://bsc-dataseed1.defibit.io" +REACT_APP_NODE_2 = "https://data-seed-prebsc-1-s1.binance.org:8545" # 10+ nodes balanced in each region, global -REACT_APP_NODE_3 = "https://bsc-dataseed.binance.org" +REACT_APP_NODE_3 = "https://data-seed-prebsc-1-s1.binance.org:8545" REACT_APP_GRAPH_API_PROFILE = "https://api.thegraph.com/subgraphs/name/pancakeswap/profile" REACT_APP_GRAPH_API_PREDICTION = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction" REACT_APP_GRAPH_API_LOTTERY = "https://api.thegraph.com/subgraphs/name/pancakeswap/lottery" -REACT_APP_SNAPSHOT_BASE_URL = "https://hub.snapshot.page" -REACT_APP_SNAPSHOT_VOTING_API = "https://voting-api.pancakeswap.info/api" +REACT_APP_SNAPSHOT_BASE_URL = "https://testnet.snapshot.org" +REACT_APP_SNAPSHOT_VOTING_API = "https://xtjyd0liqe.execute-api.ap-northeast-1.amazonaws.com/dev/api" + + + +REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090' +# REACT_APP_REQUEST_URL = 'http://192.168.2.210:8080' diff --git a/src/utils/calls/boards.ts b/src/utils/calls/boards.ts index db16f3b..f4b1e39 100644 --- a/src/utils/calls/boards.ts +++ b/src/utils/calls/boards.ts @@ -18,8 +18,8 @@ export const unstakeBoard = async (masterChefContract) => { return receipt.status } -export const harvestBoard = async (masterChefContract, pid) => { - const tx = await masterChefContract.harvest(pid, '0', options) +export const harvestBoard = async (masterChefContract) => { + const tx = await masterChefContract.harvest(options) const receipt = await tx.wait() return receipt.status } diff --git a/src/views/Board/components/BoardCard/CardActionsContainer.tsx b/src/views/Board/components/BoardCard/CardActionsContainer.tsx index 8a9de5f..cf28182 100644 --- a/src/views/Board/components/BoardCard/CardActionsContainer.tsx +++ b/src/views/Board/components/BoardCard/CardActionsContainer.tsx @@ -13,6 +13,7 @@ import { useERC20 } from 'hooks/useContract' import UnlockButton from 'components/UnlockButton' import useApproveBoard from '../../hooks/useApproveBoard' import StakeAction from './StakeAction' +import HarvestAction from './HarvestAction' const Action = styled.div` padding-top: 16px; @@ -57,14 +58,10 @@ const CardActions: React.FC = ({ board, account }) => { - - - {t('TotalProfit')} - - - - {getBalanceNumber(new BigNumber(estimatedProfit))} + + {t('TotalProfit')} + ) : ( diff --git a/src/views/Board/components/BoardCard/HarvestAction.tsx b/src/views/Board/components/BoardCard/HarvestAction.tsx new file mode 100644 index 0000000..4bd79e6 --- /dev/null +++ b/src/views/Board/components/BoardCard/HarvestAction.tsx @@ -0,0 +1,69 @@ +import React, { useState } from 'react' +import BigNumber from 'bignumber.js' +import { Button, Flex, Heading } from '@pancakeswap/uikit' +import { useTranslation } from 'contexts/Localization' +import { useAppDispatch } from 'state' +import { fetchFarmUserDataAsync } from 'state/farms' +import useToast from 'hooks/useToast' +import { getBalanceAmount } from 'utils/formatBalance' +import { BIG_ZERO } from 'utils/bigNumber' +import { useWeb3React } from '@web3-react/core' +import { usePriceCakeBusd } from 'state/hooks' +import Balance from 'components/Balance' +import { TOKEN_SYMBOL } from 'config/index' +import useHarvestBoard from '../../hooks/useHarvestBoard' + +interface FarmCardActionsProps { + earnings?: BigNumber + pid?: number +} + +const HarvestAction: React.FC = ({ earnings, pid }) => { + const { account } = useWeb3React() + const { toastSuccess, toastError } = useToast() + const { t } = useTranslation() + const [pendingTx, setPendingTx] = useState(false) + const { onReward } = useHarvestBoard(pid) + const cakePrice = usePriceCakeBusd() + const dispatch = useAppDispatch() + const rawEarningsBalance = account ? getBalanceAmount(earnings) : BIG_ZERO + const displayBalance = rawEarningsBalance.toFixed(3, BigNumber.ROUND_DOWN) + const earningsBusd = rawEarningsBalance ? rawEarningsBalance.multipliedBy(cakePrice).toNumber() : 0 + + return ( + + + {displayBalance} + {earningsBusd > 0 && ( + + )} + + + + ) +} + +export default HarvestAction diff --git a/src/views/Board/hooks/useHarvestBoard.ts b/src/views/Board/hooks/useHarvestBoard.ts index 5c003fe..bb80117 100644 --- a/src/views/Board/hooks/useHarvestBoard.ts +++ b/src/views/Board/hooks/useHarvestBoard.ts @@ -6,7 +6,7 @@ const useHarvestBoard = (boardPid: number) => { const boardChefContract = useBoardchef(boardPid) const handleHarvest = useCallback(async () => { - await harvestBoard(boardChefContract, boardPid) + await harvestBoard(boardChefContract) }, [boardPid, boardChefContract]) return { onReward: handleHarvest }