调整代码
This commit is contained in:
parent
6c0f6740b9
commit
ad457846d6
|
|
@ -60,11 +60,7 @@ const Menu = (props) => {
|
||||||
const [price, setPrice] = useState(0)
|
const [price, setPrice] = useState(0)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDetails()
|
getDetails()
|
||||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
setPrice(hccPriceUsdt)
|
||||||
setPrice(0)
|
|
||||||
} else {
|
|
||||||
setPrice(hccPriceUsdt.toNumber())
|
|
||||||
}
|
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
<UikitMenu
|
<UikitMenu
|
||||||
|
|
|
||||||
|
|
@ -373,9 +373,12 @@ export const usePriceCakeBusd = (): BigNumber => {
|
||||||
const cakeBnbFarm = useFarmFromPid(251)
|
const cakeBnbFarm = useFarmFromPid(251)
|
||||||
return new BigNumber(cakeBnbFarm.token.busdPrice)
|
return new BigNumber(cakeBnbFarm.token.busdPrice)
|
||||||
}
|
}
|
||||||
export const usePriceHccUsdt = (): BigNumber => {
|
export const usePriceHccUsdt = (): number => {
|
||||||
const hccUsdtFarm = useFarmFromPid(1000) // NEED CHANGE
|
const hccUsdtFarm = useFarmFromPid(1000) // NEED CHANGE
|
||||||
return new BigNumber(hccUsdtFarm.token.busdPrice)
|
return new BigNumber(hccUsdtFarm.token.busdPrice).toString() || !hccUsdtFarm.token.busdPrice
|
||||||
|
? 0
|
||||||
|
: new BigNumber(hccUsdtFarm.token.busdPrice).toNumber()
|
||||||
|
// return new BigNumber(hccUsdtFarm.token.busdPrice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,13 @@
|
||||||
import { createSlice } from '@reduxjs/toolkit'
|
import { createSlice } from '@reduxjs/toolkit'
|
||||||
import { getReferralRewardInfo, getReferralConfigInfo } from 'services/referral'
|
|
||||||
import { ReferralInfo, ReferralConfigType, ReferralConfigInfo } from 'types/referral'
|
|
||||||
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 multicall from 'utils/multicall'
|
import multicall from 'utils/multicall'
|
||||||
import tokens from 'config/constants/tokens'
|
import tokens from 'config/constants/tokens'
|
||||||
import { getAddress, getIdoPurchaseAddress } from 'utils/addressHelpers'
|
import { getAddress, getIdoPurchaseAddress } from 'utils/addressHelpers'
|
||||||
import { ReferralState } from '../types'
|
|
||||||
|
|
||||||
const initialState: ReferralState = {
|
|
||||||
commanderConfigInfo: {},
|
|
||||||
normalConfigInfo: {},
|
|
||||||
isCommander: false,
|
|
||||||
rewardInfo: {},
|
|
||||||
}
|
|
||||||
const payWayList = {
|
const payWayList = {
|
||||||
usdt: tokens.usdt,
|
usdt: tokens.usdt,
|
||||||
}
|
}
|
||||||
export const referralSlice = createSlice({
|
|
||||||
name: 'Ido',
|
|
||||||
initialState,
|
|
||||||
reducers: {
|
|
||||||
setReferralInfo: (state, action) => {
|
|
||||||
console.log(action)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
export const { setReferralInfo } = referralSlice.actions
|
|
||||||
// Thunks
|
|
||||||
// export const fetchReferralInfoAsync = (account) => async (dispatch) => {
|
|
||||||
// if (!account) {
|
|
||||||
// dispatch(setReferralInfo({}))
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// const data: ReferralInfo = await getReferralRewardInfo()
|
|
||||||
// const configInfo: ReferralConfigInfo[] = await getReferralConfigInfo()
|
|
||||||
// dispatch(
|
|
||||||
// setReferralInfo({
|
|
||||||
// commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER) || {},
|
|
||||||
// normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL) || {},
|
|
||||||
// isCommander: data.isCommander,
|
|
||||||
// rewardInfo: data.reward || {},
|
|
||||||
// }),
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const fetchIdoUserAllowances = async (account: string) => {
|
export const fetchIdoUserAllowances = async (account: string) => {
|
||||||
const calls = Object.values(payWayList).map((payWayItem) => {
|
const calls = Object.values(payWayList).map((payWayItem) => {
|
||||||
|
|
@ -63,4 +25,4 @@ export const fetchIdoUserAllowances = async (account: string) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default referralSlice.reducer
|
export default fetchIdoUserAllowances
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,7 @@ const CardActions: React.FC<NodeCardActionsProps> = ({ board, account }) => {
|
||||||
|
|
||||||
const [price, setPrice] = useState(0)
|
const [price, setPrice] = useState(0)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
setPrice(hccPriceUsdt)
|
||||||
setPrice(0)
|
|
||||||
} else {
|
|
||||||
setPrice(Number(hccPriceUsdt.toNumber().toFixed(3)))
|
|
||||||
}
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleApprove = useCallback(async () => {
|
const handleApprove = useCallback(async () => {
|
||||||
|
|
|
||||||
|
|
@ -156,11 +156,7 @@ const FristCom: React.FC = () => {
|
||||||
setDetail(data)
|
setDetail(data)
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
setPrice(hccPriceUsdt)
|
||||||
setPrice(0)
|
|
||||||
} else {
|
|
||||||
setPrice(hccPriceUsdt.toNumber())
|
|
||||||
}
|
|
||||||
getDetail()
|
getDetail()
|
||||||
}, [])
|
}, [])
|
||||||
const openLink = (link) => {
|
const openLink = (link) => {
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ interface RoundDetailProps {
|
||||||
token?: string
|
token?: string
|
||||||
total?: number
|
total?: number
|
||||||
}
|
}
|
||||||
interface Props {
|
interface HeaderStatusProps {
|
||||||
status?: string
|
status?: string
|
||||||
roundDetail?: RoundDetailProps
|
roundDetail?: RoundDetailProps
|
||||||
}
|
}
|
||||||
|
|
||||||
const HeaderStatus: React.FC<Props> = ({ status, roundDetail }) => {
|
const HeaderStatus: React.FC<HeaderStatusProps> = ({ status, roundDetail }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@ const CoinText = styled(Text)`
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
`
|
`
|
||||||
|
|
||||||
interface InputProps {
|
interface ExchangeInputProps {
|
||||||
name: string
|
name: string
|
||||||
value?: number | string
|
value?: number | string
|
||||||
isDisabled?: boolean
|
disabled?: boolean
|
||||||
onChange: (e: React.FormEvent<HTMLInputElement>) => void
|
onChange: (e: React.FormEvent<HTMLInputElement>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExchangeInput: React.FC<InputProps> = ({ name, value, onChange, isDisabled = true }) => {
|
const ExchangeInput: React.FC<ExchangeInputProps> = ({ name, value, onChange, disabled = true }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -37,7 +37,7 @@ const ExchangeInput: React.FC<InputProps> = ({ name, value, onChange, isDisabled
|
||||||
placeholder={t('Please enter the amount')}
|
placeholder={t('Please enter the amount')}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
type="number"
|
type="number"
|
||||||
disabled={isDisabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</PriceContent>
|
</PriceContent>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -153,9 +153,9 @@ const ExchangeCard: React.FC<Props> = ({ status, roundDetail, time }) => {
|
||||||
<FCard>
|
<FCard>
|
||||||
<HeaderText>{idoInfo?.name}</HeaderText>
|
<HeaderText>{idoInfo?.name}</HeaderText>
|
||||||
<HeaderStatus status={status} roundDetail={roundDetail} />
|
<HeaderStatus status={status} roundDetail={roundDetail} />
|
||||||
<ExchangeInput name="USDT" value={usdtPrice} onChange={handleUsdtChange} isDisabled={status !== 'proceed'} />
|
<ExchangeInput name="USDT" value={usdtPrice} onChange={handleUsdtChange} disabled={status !== 'proceed'} />
|
||||||
<RateText status={status} roundDetail={roundDetail} />
|
<RateText status={status} roundDetail={roundDetail} />
|
||||||
<ExchangeInput name="HCC" value={hccPrice} onChange={handleHccChange} isDisabled={status !== 'proceed'} />
|
<ExchangeInput name="HCC" value={hccPrice} onChange={handleHccChange} disabled={status !== 'proceed'} />
|
||||||
<FooterButton>
|
<FooterButton>
|
||||||
{account ? (
|
{account ? (
|
||||||
allowanceList.usdt ? (
|
allowanceList.usdt ? (
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export const useBuyTransaction = () => {
|
||||||
const transaction = async (amount) => {
|
const transaction = async (amount) => {
|
||||||
const data = await getPurchaseActivity()
|
const data = await getPurchaseActivity()
|
||||||
const { id } = data
|
const { id } = data
|
||||||
const params = [id, new BigNumber(amount).times(new BigNumber(10).pow(18)).toString()]
|
const params = [id, getDecimalAmount(amount).toString()]
|
||||||
const res = await idoPurchase.purchaseWithLock(...params)
|
const res = await idoPurchase.purchaseWithLock(...params)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue