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