diff --git a/src/components/modal/DelistModal.tsx b/src/components/modal/DelistModal.tsx index a65a222..acbbe61 100755 --- a/src/components/modal/DelistModal.tsx +++ b/src/components/modal/DelistModal.tsx @@ -26,6 +26,7 @@ import { useDelist } from '../../hooks/useDelist'; import { useHasRole } from '../../hooks/useHasRole'; import { useModal } from '../../hooks/useModal'; import { defaultImg, divide10Exp, formatDateUTC, roundFun } from '../../utils'; +import { getWeb3 } from '../../base/contract/getWeb3'; export const DelistModal = (props: any) => { const modalData = useModal(); @@ -63,13 +64,17 @@ export const DelistModal = (props: any) => { if (!groupId) return; const estimate = async () => { - const gasPrice = BSC_SEND_GAS_FEE || ''; + const web3 = getWeb3(); + const gasPrice = await web3.eth.getGasPrice(); + // const gasPrice = BSC_SEND_GAS_FEE || ''; + console.log('gasPrice', gasPrice); const gasLimit = await MarketPlaceContract() .methods.delist(groupId) .estimateGas({ from: address, - gas: BSC_SEND_GAS_FEE, + // gas: BSC_SEND_GAS_FEE, }); + console.log('gasLimit', gasLimit); const tmp = BigInt(gasPrice) * BigInt(gasLimit); const estimateGasRes = divide10Exp(new BN(tmp.toString(), 10), 18); diff --git a/src/hooks/useDelist.ts b/src/hooks/useDelist.ts index 5b35d36..219fc18 100755 --- a/src/hooks/useDelist.ts +++ b/src/hooks/useDelist.ts @@ -5,15 +5,19 @@ import { useCallback } from 'react'; import { useAccount } from 'wagmi'; import { MarketPlaceContract } from '../base/contract/marketPlaceContract'; import { BSC_SEND_GAS_FEE } from '../env'; +import { getWeb3 } from '../base/contract/getWeb3'; export const useDelist = () => { const { address } = useAccount(); const delist = useCallback( async (groupId: string) => { + const web3 = getWeb3(); + const gasPrice = await web3.eth.getGasPrice(); + return await MarketPlaceContract() .methods.delist(groupId) - .send({ from: address, gasPrice: BSC_SEND_GAS_FEE }); + .send({ from: address, gasPrice: gasPrice }); }, [address], ); diff --git a/src/pages/R.tsx b/src/pages/R.tsx index ad0efc5..f277620 100644 --- a/src/pages/R.tsx +++ b/src/pages/R.tsx @@ -42,9 +42,12 @@ export const R = () => { useEffect(() => { let url = ''; - if (accountStatus !== 'SAME_ACCOUNT') { + if (accountStatus === 'ACCOUNT_IS_NOT_SAME') { url = '/'; - } else { + } else if ( + accountStatus === 'NOT_LOGIN' || + accountStatus === 'SAME_ACCOUNT' + ) { if (!_.isEmpty(resourceBid)) { url = `/resource?id=${resourceBid.id}`; } else if (!_.isEmpty(resourceOid) && resourceOid.id !== 0) { @@ -54,12 +57,12 @@ export const R = () => { if (detailBid.bucketInfo && !detailOid?.objectInfo) { url = `/detail?bid=${detailBid.bucketInfo.id}`; - if (!bucketIsListed) { + if (!bucketIsListed && accountStatus === 'SAME_ACCOUNT') { url += '&openModal=1'; } } else { url = `/detail?bid=${detailBid.bucketInfo.id}&oid=${detailOid?.objectInfo.id}`; - if (!objectIsListed) { + if (!objectIsListed && accountStatus === 'SAME_ACCOUNT') { url += '&openModal=1'; } }