调整代码

This commit is contained in:
myf 2022-05-07 11:00:49 +08:00
parent 00767f6a4e
commit a7e33acf6f
11 changed files with 20 additions and 466 deletions

View File

@ -13,9 +13,7 @@ import useWeb3Provider from 'hooks/useActiveWeb3React'
import { clearUserInfo } from 'state/actions'
import config from './config'
const list = []
const Menu = (props) => {
console.log(props)
const account = useAccount()
const { login, logout } = useAuth()
const [hasWalletLogin, setHasWalletLogin] = useState(false)
@ -26,8 +24,6 @@ const Menu = (props) => {
const dispatch = useDispatch()
const { profile } = useProfile()
const userInfo = useUserInfo()
// const detail = useOutLink()
// console.log(userInfo)
const { currentLanguage, setLanguage, t } = useTranslation()
const inviteUrl = useMemo(() => {
return userInfo?.inviteCode ? `${window.location.origin}?inviteCode=${userInfo.inviteCode}` : window.location.origin
@ -42,18 +38,17 @@ const Menu = (props) => {
logout()
}
const [linkList, setLinkList] = useState([])
const [socialLink, setSocialLink] = useState([])
const getDetails = async () => {
const result = await indexInfo()
const { data } = result.data
data.externalLinkList.forEach((item) => {
const links = []
Object.keys(item.linkMap).forEach((key) => {
links.push({ name: key, link: item.linkMap[key], icon: item.iconResource.url })
const list = data.externalLinkList.map((item, index) => {
const links = Object.keys(item.linkMap).map((key) => {
return { name: key, link: item.linkMap[key], icon: item.iconResource.url }
})
list.push({ icon: item.iconResource.url, list: links })
return { icon: item.iconResource.url, list: links, key: index + item.name }
})
setLinkList(list)
setSocialLink(list)
}
// 钱包登录后
useEffect(() => {
@ -79,7 +74,7 @@ const Menu = (props) => {
setLang={setLanguage}
cakePriceUsd={hccPriceUsdt.toNumber()}
links={config(t)}
outLink={linkList}
socialLink={socialLink}
{...props}
/>
)

View File

@ -1,198 +0,0 @@
[
{
"inputs": [
{ "internalType": "contract IERC20", "name": "_HCC", "type": "address" },
{ "internalType": "address", "name": "_HCCBODReawardPool", "type": "address" },
{ "internalType": "uint256", "name": "_minStakeAmount", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "EmergencyWithdraw",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Harvest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "address", "name": "newHCCBODReawardPool", "type": "address" }],
"name": "SetHCCBODReawardPoolEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "newLockTime", "type": "uint256" }],
"name": "SetLockTimeEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "newMinStakeAmount", "type": "uint256" }],
"name": "SetMinStakeAmontEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Withdraw",
"type": "event"
},
{
"inputs": [],
"name": "HCC",
"outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "HCCBODReawardPool",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "_poolInfo",
"outputs": [
{ "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" },
{ "internalType": "uint256", "name": "totalAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "num", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "_userInfo",
"outputs": [
{ "internalType": "uint256", "name": "total", "type": "uint256" },
{ "internalType": "uint256", "name": "reward", "type": "uint256" },
{ "internalType": "uint256", "name": "lp", "type": "uint256" },
{ "internalType": "uint256", "name": "lockTime", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "emergencyWithdrawHCC", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [], "name": "harvest", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [],
"name": "lockTime",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "minStakeAmount",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paused",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "pendingHCC",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "_HCCBODReawardPool", "type": "address" }],
"name": "setHCCBODReawardPool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_lockTime", "type": "uint256" }],
"name": "setLockTime",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_minStakeAmount", "type": "uint256" }],
"name": "setMinStakeAmount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "setPause", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "updatePool", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "userInfo",
"outputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "uint256", "name": "rewardDebt", "type": "uint256" },
{ "internalType": "uint256", "name": "unLockTime", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "withdrawHCC", "outputs": [], "stateMutability": "nonpayable", "type": "function" }
]

View File

@ -1,182 +0,0 @@
[
{
"inputs": [
{ "internalType": "contract IERC20", "name": "_HCC", "type": "address" },
{ "internalType": "address", "name": "_HCCStakeReawardPool", "type": "address" },
{ "internalType": "uint256", "name": "_minStakeAmount", "type": "uint256" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "EmergencyWithdraw",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Harvest",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "address", "name": "newHCCStakeReawardPool", "type": "address" }],
"name": "SetHCCStakeReawardPoolEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "newLockTime", "type": "uint256" }],
"name": "SetLockTimeEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "newMinStakeAmount", "type": "uint256" }],
"name": "SetMinStakeAmontEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "user", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "Withdraw",
"type": "event"
},
{
"inputs": [],
"name": "HCC",
"outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "HCCStakeReawardPool",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "_poolInfo",
"outputs": [
{ "internalType": "uint256", "name": "accHCCPerShare", "type": "uint256" },
{ "internalType": "uint256", "name": "totalAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "num", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "_userInfo",
"outputs": [
{ "internalType": "uint256", "name": "total", "type": "uint256" },
{ "internalType": "uint256", "name": "reward", "type": "uint256" },
{ "internalType": "uint256", "name": "lp", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "emergencyWithdrawHCC", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{ "inputs": [], "name": "harvest", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [],
"name": "minStakeAmount",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paused",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "_user", "type": "address" }],
"name": "pendingHCC",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "_HCCStakeReawardPool", "type": "address" }],
"name": "setHCCStakeReawardPool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "_minStakeAmount", "type": "uint256" }],
"name": "setMinStakeAmount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "setPause", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "inputs": [], "name": "updatePool", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "userInfo",
"outputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "withdrawHCC", "outputs": [], "stateMutability": "nonpayable", "type": "function" }
]

View File

@ -1,8 +1,6 @@
import addresses from 'config/constants/contracts'
import boardAbi from 'config/abi/board.json'
import boardPoolAbi from 'config/abi/boardPool.json'
import holderAbi from 'config/abi/holder.json'
import holderPoolAbis from 'config/abi/holderPool.json'
import tokens from './tokens'
import { BoardConfig } from './types'
@ -17,7 +15,6 @@ const boardsList: BoardConfig[] = [
contractAddress: addresses.boardChef,
contractRewardAddress: addresses.boardRewardChef,
abi: boardAbi,
poolAbi: boardPoolAbi,
},
{
pid: 2,
@ -29,7 +26,6 @@ const boardsList: BoardConfig[] = [
contractAddress: addresses.holderChef,
contractRewardAddress: addresses.holderRewardChef,
abi: holderAbi,
poolAbi: holderPoolAbis,
},
]

View File

@ -188,6 +188,4 @@ export interface BoardConfig {
contractAddress: Address
contractRewardAddress: Address
abi: any
poolAbi: any
// rewardAbi: any
}

View File

@ -54,7 +54,6 @@ export const fetchBoardUserInfo = async (account: string) => {
},
]
const [userInfo, estimatedProfit] = await multicall(board.abi, calls)
console.log(userInfo)
return {
stakedBalance: new BigNumber(userInfo.amount._hex).toJSON(),
unLockTime: userInfo.unLockTime ? new BigNumber(userInfo.unLockTime._hex).toNumber() : 0,
@ -65,6 +64,5 @@ export const fetchBoardUserInfo = async (account: string) => {
}
}),
)
console.log('data:', data)
return data
}

View File

@ -54,7 +54,6 @@ export const fetchBoardUserDataAsync = (account) => async (dispatch) => {
rewardDebt: userInfo[index].rewardDebt,
}
})
console.log(arrayOfUserDataObjects)
dispatch(setBoardsUserData({ arrayOfUserDataObjects }))
}

View File

@ -19,7 +19,6 @@ const ContainerMain = styled.div`
const MainDiv = styled.div`
width: 100%;
min-height: calc(100vh - 64px);
/* background: ${({ theme }) => theme.colors.gradients.bubblegum}; */
box-sizing: border-box;
`
const TableDiv = styled.div`
@ -136,12 +135,7 @@ const Announcement: React.FC = () => {
setList([])
}
const data = await getAnnouncementPage({ page, size, title })
let dataList = []
if (type) {
dataList = data.content
} else {
dataList = [...list, ...data.content]
}
const dataList = type ? data.content : [...list, ...data.content]
setList(dataList)
if (data.content.length === 0 || !data.content) {
setTotalVisible(true)
@ -195,7 +189,6 @@ const Announcement: React.FC = () => {
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
const { value: inputValue } = evt.target
setSearchTitle(inputValue)
console.log(searchTitle)
}
return (
<ContainerMain>

View File

@ -56,22 +56,6 @@ const Boards: React.FC = () => {
const [boardNum, setBoardNum] = useState(0)
const [holderNum, setHolder] = useState(0)
// // 获取资金池总额
// const getCapital = async () => {
// const calls = boardsConfig.map((board) => {
// const contractAddress = getAddress(board.contractAddress)
// return {
// address: contractAddress,
// name: '_poolInfo',
// }
// })
// let total = 0
// const boardsPoolInfo = await multicall(boardABI, calls)
// boardsPoolInfo.forEach((item) => {
// total += new BigNumber(item.totalAmount._hex).toNumber()
// })
// setTotalAmount(total)
// }
// 获取分红总额
const fetchBoardShares = async () => {
const boardsData = await Promise.all(
@ -90,7 +74,7 @@ const Boards: React.FC = () => {
},
])
return {
name: boardConfig.name,
pid: boardConfig.pid,
totalAmount: getBalanceAmount(new BigNumber(boardPoolInfo.totalAmount._hex)).toNumber(),
num: new BigNumber(boardPoolInfo?.num?._hex).toNumber(),
waitWithdrawAmount: getBalanceAmount(new BigNumber(waitWithdrawAmount.balance._hex)).toNumber(),
@ -102,42 +86,19 @@ const Boards: React.FC = () => {
boardsData.forEach((item) => {
total += item.totalAmount
waitWithdrawAmountValue += item.waitWithdrawAmount
if (item.name === 'Board') {
if (item.pid === 1) {
setBoardNum(item.num)
} else if (item.name === 'Holder') {
} else if (item.pid === 2) {
setHolder(item.waitWithdrawAmount)
}
})
setTotalAmount(total)
setShareOutBonus(waitWithdrawAmountValue)
}
// 获取信息
// const fetchInfo = async () => {
// const boardsData = await Promise.all(
// boardsConfig.map(async (boardConfig) => {
// const [boardUserInfo] = await multicall(boardConfig.poolAbi, [
// {
// address: getAddress(boardConfig.contractAddress),
// name: 'userInfo',
// params: [account],
// },
// ])
// return {
// name: boardConfig.name,
// amount: getBalanceAmount(new BigNumber(boardUserInfo.amount?._hex)).toNumber(),
// rewardDebt: getBalanceAmount(new BigNumber(boardUserInfo.rewardDebt?._hex)).toNumber(),
// unLockTime: new BigNumber(boardUserInfo?.unLockTime?._hex).toNumber(),
// }
// }),
// )
// setBoardsDataList(boardsData)
// }
useEffect(() => {
dispatch(fetchBoardsPublicDataAsync())
fetchBoardShares()
if (account) {
// fetchInfo()
// const userInfo = fetchBoardUserInfo(account)
dispatch(fetchBoardUserDataAsync(account))
}
}, [account, dispatch, fastRefresh])

View File

@ -142,13 +142,11 @@ const FristCom: React.FC = () => {
const getDetail = async () => {
const data = await indexInfo()
const list = []
data.externalLinkList.forEach((item) => {
const links = []
Object.keys(item.linkMap).forEach((key) => {
links.push({ name: key, link: item.linkMap[key], icon: item.iconResource.url })
const list = data.externalLinkList.map((item, index) => {
const links = Object.keys(item.linkMap).map((key) => {
return { name: key, link: item.linkMap[key], icon: item.iconResource.url }
})
list.push({ icon: item.iconResource.url, name: item.name, list: links })
return { icon: item.iconResource.url, name: item.name, list: links, key: index + item.name }
})
setLinkList(list)
setDetail(data)
@ -157,9 +155,7 @@ const FristCom: React.FC = () => {
getDetail()
}, [])
const openLink = (link) => {
console.log('link:', link)
window.open(link)
// window.location.href = link
}
return (
<>
@ -178,11 +174,11 @@ const FristCom: React.FC = () => {
<RadiusBtn variant="primary" onClick={() => openLink('https://pancake.kiemtienonline360.com/#/swap')}>
{t('Exchange')}
</RadiusBtn>
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
<Flex>
{linkList?.map((item) => {
return (
{linkList?.map((item, index) => {
return index < 6 ? (
<BtnImage
key={item.key}
style={{ borderRadius: '50%' }}
src={item.icon}
title={item.name}
@ -191,10 +187,10 @@ const FristCom: React.FC = () => {
height={34}
onClick={() => openLink(item.list[0].link)}
/>
) : (
''
)
})}
{/* <BtnImage src="/images/home/fg.png" alt="" width={34} height={34} />
<BtnImage src="/images/home/fg.png" alt="" width={34} height={34} /> */}
</Flex>
</BtnFlex>
</InfoDiv>

View File

@ -57,9 +57,7 @@ const ConnectedCom: React.FC = () => {
const { t } = useTranslation()
const [onBuyModal] = useModal(<BuyNftModal />)
const referralNormalConfigInfo = useReferralNormalConfigInfo()
console.log('referralNormalConfigInfo:', referralNormalConfigInfo)
const referralRewardInfo = useReferralRewardInfo()
console.log('referralRewardInfo:', referralRewardInfo)
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
const [loading, setLoading] = useState(false)
const withdraw = useWithdraw()