diff --git a/src/config/abi/purchase.json b/src/config/abi/purchase.json new file mode 100644 index 0000000..f6f4bbd --- /dev/null +++ b/src/config/abi/purchase.json @@ -0,0 +1,131 @@ +[ + { + "inputs": [{ "internalType": "contract IERC20", "name": "_HCC", "type": "address" }], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "round", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "total", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "price", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "name": "AddRound", + "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": "uint256", "name": "round", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "total", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "price", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "name": "SetRound", + "type": "event" + }, + { + "inputs": [], + "name": "HCC", + "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "round", "type": "uint256" }, + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "name": "addRound", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "round", "type": "uint256" }], + "name": "getRound", + "outputs": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "remaining", "type": "uint256" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "round", "type": "uint256" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "purchase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "purchaseInfo", + "outputs": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "purchasedAmount", "type": "uint256" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { "inputs": [], "name": "setPause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "uint256", "name": "round", "type": "uint256" }, + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "beginTime", "type": "uint256" }, + { "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "name": "setRound", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts index 2a752c6..8e9c3dc 100644 --- a/src/config/constants/contracts.ts +++ b/src/config/constants/contracts.ts @@ -31,6 +31,10 @@ export default { 97: '0x86a510e82aceb27ed9e9880fb981d4b42ff16cb4', 56: '0x88F46EF2Ee08494D84942DCA3bd24cDEf7C88Ae2', // NEED CHANGE 邀请或则军团长收益 }, + idoPurchase: { + 97: '0x3d437b81f8080c11d0e7c6b8a6c8185d8b92afee', + 56: '0x3d437b81f8080c11d0e7c6b8a6c8185d8b92afee', // NEED CHANGE IDO兑换 + }, lotteryV2: { 97: '0x5790c3534F30437641541a0FA04C992799602998', 56: '0x5aF6D33DE2ccEC94efb1bDF8f92Bd58085432d2c', diff --git a/src/hooks/useContract.ts b/src/hooks/useContract.ts index 2e9ab77..03e5c29 100644 --- a/src/hooks/useContract.ts +++ b/src/hooks/useContract.ts @@ -27,6 +27,7 @@ import { getReferralchefContract, getBoardchefContract, getReferralRewardchefContract, + getIdoPurchaseContract, } from 'utils/contractHelpers' // Imports below migrated from Exchange useContract.ts @@ -109,6 +110,10 @@ export const useReferralchef = () => { const { library } = useActiveWeb3React() return useMemo(() => getReferralchefContract(library.getSigner()), [library]) } +export const useIdoPurchase = () => { + const { library } = useActiveWeb3React() + return useMemo(() => getIdoPurchaseContract(library.getSigner()), [library]) +} export const useReferralRewardchef = () => { const { library } = useActiveWeb3React() return useMemo(() => getReferralRewardchefContract(library.getSigner()), [library]) diff --git a/src/utils/addressHelpers.ts b/src/utils/addressHelpers.ts index 30cb2ea..7f58f0d 100644 --- a/src/utils/addressHelpers.ts +++ b/src/utils/addressHelpers.ts @@ -74,3 +74,6 @@ export const getBunnySpecialCakeVaultAddress = () => { export const getBunnySpecialPredictionAddress = () => { return getAddress(addresses.bunnySpecialPrediction) } +export const getIdoPurchaseAddress = () => { + return getAddress(addresses.idoPurchase) +} diff --git a/src/utils/contractHelpers.ts b/src/utils/contractHelpers.ts index 3e3abbe..4c07a56 100644 --- a/src/utils/contractHelpers.ts +++ b/src/utils/contractHelpers.ts @@ -27,6 +27,7 @@ import { getBoardAddress, getReferralAddress, getReferralRewardAddress, + getIdoPurchaseAddress, } from 'utils/addressHelpers' // ABI @@ -59,6 +60,7 @@ import chainlinkOracleAbi from 'config/abi/chainlinkOracle.json' import MultiCallAbi from 'config/abi/Multicall.json' import bunnySpecialCakeVaultAbi from 'config/abi/bunnySpecialCakeVault.json' import bunnySpecialPredictionAbi from 'config/abi/bunnySpecialPrediction.json' +import idoPurchase from 'config/abi/purchase.json' import { ChainLinkOracleContract, PredictionsContract } from './types' const getContract = (abi: any, address: string, signer?: ethers.Signer | ethers.providers.Provider) => { @@ -156,3 +158,6 @@ export const getBunnySpecialCakeVaultContract = (signer?: ethers.Signer | ethers export const getBunnySpecialPredictionContract = (signer?: ethers.Signer | ethers.providers.Provider) => { return getContract(bunnySpecialPredictionAbi, getBunnySpecialPredictionAddress(), signer) } +export const getIdoPurchaseContract = (signer?: ethers.Signer | ethers.providers.Provider) => { + return getContract(idoPurchase, getIdoPurchaseAddress(), signer) +} diff --git a/src/views/Exchange/components/ExchangeCard.tsx b/src/views/Exchange/components/ExchangeCard.tsx index 67a2c1a..74651d2 100644 --- a/src/views/Exchange/components/ExchangeCard.tsx +++ b/src/views/Exchange/components/ExchangeCard.tsx @@ -2,6 +2,7 @@ import React, { useMemo, useState, useEffect } from 'react' import styled, { keyframes } from 'styled-components' import { useTranslation } from 'contexts/Localization' import { Flex, Text, Button } from '@pancakeswap/uikit' +import { useIdoPurchase } from 'hooks/useContract' import { useAccount } from 'state/userInfo/hooks' import UnlockButton from 'components/UnlockButton' @@ -48,6 +49,12 @@ const ExchangeCard: React.FC = () => { const account = useAccount() + const useBuyTransaction = () => { + return useIdoPurchase() + } + console.log(useBuyTransaction()) + // useEffect(() => {}, []) + return ( {t('IDO exchange in the first phase')}