diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts index ded3014..ba6164d 100644 --- a/src/config/constants/contracts.ts +++ b/src/config/constants/contracts.ts @@ -16,7 +16,7 @@ export default { 56: '0xD34871F12ace1BB8034E18009104b9dA60B84250', // NEED CHANGE 持币人 }, referralChef: { - 97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4', + 97: '0x8a5dc1e8262d6a3de664624fdc13a533ba64e60d', 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长 }, referralRewardChef: { diff --git a/src/state/boards/fetchBoardsUser.ts b/src/state/boards/fetchBoardsUser.ts index ed2b299..9eef142 100644 --- a/src/state/boards/fetchBoardsUser.ts +++ b/src/state/boards/fetchBoardsUser.ts @@ -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], }, diff --git a/src/state/referral/index.ts b/src/state/referral/index.ts index 766d4de..3dea59d 100644 --- a/src/state/referral/index.ts +++ b/src/state/referral/index.ts @@ -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 || {}, }), diff --git a/src/views/Referral/components/BuyActions.tsx b/src/views/Referral/components/BuyActions.tsx index 5916940..950f259 100644 --- a/src/views/Referral/components/BuyActions.tsx +++ b/src/views/Referral/components/BuyActions.tsx @@ -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' })} )} - {allowanceList?.usdt && allowanceList.hcc ? {t('Buy It Now')} : null} + {allowanceList?.usdt && allowanceList.hcc ? ( + + {t('Buy It Now')} + + ) : null} ) } diff --git a/src/views/Referral/hooks/index.ts b/src/views/Referral/hooks/index.ts index 25f5a16..c30ef9d 100644 --- a/src/views/Referral/hooks/index.ts +++ b/src/views/Referral/hooks/index.ts @@ -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 }