Skip to content

Commit

Permalink
feat: not login will enter page
Browse files Browse the repository at this point in the history
  • Loading branch information
ybgbob committed Nov 22, 2023
1 parent 9a7ec36 commit f45531c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/components/modal/DelistModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useDelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down
11 changes: 7 additions & 4 deletions src/pages/R.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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';
}
}
Expand Down

0 comments on commit f45531c

Please sign in to comment.