feat: 军团长
This commit is contained in:
parent
091d628025
commit
4ac60dc05f
|
|
@ -16,7 +16,7 @@ export default {
|
|||
56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人
|
||||
},
|
||||
referralChef: {
|
||||
97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4',
|
||||
97: '0x8a5dc1e8262d6a3de664624fdc13a533ba64e60d',
|
||||
56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长
|
||||
},
|
||||
referralRewardChef: {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import BigNumber from 'bignumber.js'
|
||||
import erc20ABI from 'config/abi/erc20.json'
|
||||
import boardABI from 'config/abi/board.json'
|
||||
import multicall from 'utils/multicall'
|
||||
import boardsConfig from 'config/constants/boards'
|
||||
import { getAddress, getBoardAddress } from 'utils/addressHelpers'
|
||||
import { getAddress } from 'utils/addressHelpers'
|
||||
|
||||
export const fetchBoardUserAllowances = async (account: string) => {
|
||||
const calls = boardsConfig.map((board) => {
|
||||
|
|
@ -39,15 +38,15 @@ export const fetchBoardUserTokenBalances = async (account: string) => {
|
|||
export const fetchBoardUserInfo = async (account: string) => {
|
||||
const data = await Promise.all(
|
||||
boardsConfig.map(async (board) => {
|
||||
const boardChefAdress = getAddress(board.contractAddress)
|
||||
const boardChefAddress = getAddress(board.contractAddress)
|
||||
const calls = [
|
||||
{
|
||||
address: boardChefAdress,
|
||||
address: boardChefAddress,
|
||||
name: 'userInfo',
|
||||
params: [account],
|
||||
},
|
||||
{
|
||||
address: boardChefAdress,
|
||||
address: boardChefAddress,
|
||||
name: 'pendingHCC',
|
||||
params: [account],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ export const fetchReferralInfoAsync = (account) => async (dispatch) => {
|
|||
const configInfo: ReferralConfigInfo[] = await getReferralConfigInfo()
|
||||
dispatch(
|
||||
setReferralInfo({
|
||||
commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER),
|
||||
normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL),
|
||||
commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER) || {},
|
||||
normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL) || {},
|
||||
isCommander: data.isCommander,
|
||||
rewardInfo: data.reward || {},
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ import useRefresh from 'hooks/useRefresh'
|
|||
import tokens from 'config/constants/tokens'
|
||||
import { useCheckTokenBalance, useApproveReferral, useBuyTransaction } from '../hooks'
|
||||
|
||||
// interface BuyActionsProps {
|
||||
|
||||
// }
|
||||
|
||||
const Btn = styled(Button)`
|
||||
width: 50%;
|
||||
margin: 20px auto 0px auto;
|
||||
|
|
@ -30,7 +26,7 @@ const BuyActions: React.FC = () => {
|
|||
const usdtContract = useERC20(getAddress(tokens.usdt.address))
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [txId, setTxId] = useState()
|
||||
const { toastSuccess } = useToast()
|
||||
const { toastSuccess, toastError } = useToast()
|
||||
const { fastRefresh } = useRefresh()
|
||||
const hccContract = useERC20(getAddress(tokens.hcc.address))
|
||||
const { onApprove: onUsdtApprove } = useApproveReferral(usdtContract)
|
||||
|
|
@ -54,7 +50,14 @@ const BuyActions: React.FC = () => {
|
|||
})
|
||||
}
|
||||
const handleBuy = async () => {
|
||||
await buyTransaction()
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await buyTransaction()
|
||||
setTxId(res.hash)
|
||||
} catch (e: any) {
|
||||
setLoading(false)
|
||||
toastError(e?.error?.message || e.message)
|
||||
}
|
||||
}
|
||||
const getTransactionResult = async () => {
|
||||
const res = await checkBuyResult({ tx: txId })
|
||||
|
|
@ -101,7 +104,11 @@ const BuyActions: React.FC = () => {
|
|||
{t('Approve %coin% Contract', { coin: 'hcc' })}
|
||||
</Btn>
|
||||
)}
|
||||
{allowanceList?.usdt && allowanceList.hcc ? <Btn onClick={handleBuy}>{t('Buy It Now')}</Btn> : null}
|
||||
{allowanceList?.usdt && allowanceList.hcc ? (
|
||||
<Btn disabled={loading} onClick={handleBuy}>
|
||||
{t('Buy It Now')}
|
||||
</Btn>
|
||||
) : null}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ export const useBuyTransaction = () => {
|
|||
const referralContract = useReferralchef()
|
||||
const transaction = async () => {
|
||||
const data = await getBuyReferralParams()
|
||||
const { address, hccPrice, otherPaymentPirce, code, timestamp, sign } = data
|
||||
const params = [address, hccPrice, otherPaymentPirce, code, timestamp, sign]
|
||||
// const price = getDecimalAmountNumber(receive)
|
||||
const { to, hccPrice, otherPaymentPrice, timestamp, code, sign } = data
|
||||
const params = [to, hccPrice, otherPaymentPrice, timestamp, code, sign]
|
||||
const res = await referralContract.mint(...params)
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue