diff --git a/apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx b/apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx index 4c092170..382d5b23 100644 --- a/apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx +++ b/apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx @@ -18,12 +18,13 @@ export const ConnectWallet = memo>(function ConnectB const dispatch = useDispatch(); const router = useRouter(); const { loginAccount } = useAppSelector((root) => root.persist); - const { isConnected } = useAccount(); + const { isConnecting, isConnected, connector } = useAccount(); const { icon, text, ...restProps } = props; const onOpen = () => { + console.log('invoke connect wallet', isConnected, connector); // The window.trustwallet.request method is undefined when the app is loaded. So add a delay to avoid. setTimeout(() => { - if (loginAccount && isConnected) { + if (loginAccount && isConnected && !isConnecting) { const originPathname = decodeURIComponent(router.query.originAsPath as string); return router.push( !!originPathname && originPathname !== 'undefined' diff --git a/apps/dcellar-web-ui/src/components/WrongNetworkModal/index.tsx b/apps/dcellar-web-ui/src/components/WrongNetworkModal/index.tsx index 694c4680..cbbbd1af 100644 --- a/apps/dcellar-web-ui/src/components/WrongNetworkModal/index.tsx +++ b/apps/dcellar-web-ui/src/components/WrongNetworkModal/index.tsx @@ -7,6 +7,7 @@ import { DCButton } from '../common/DCButton'; import { useWalletSwitchNetWork } from '@/context/WalletConnectContext'; import { useLogin } from '@/hooks/useLogin'; import { IconFont } from '@/components/IconFont'; +import { CHAIN_NAMES } from '@/utils/constant'; export const WrongNetworkModal = ({ isOpen, onClose }: any) => { const { logout } = useLogin(); @@ -24,10 +25,10 @@ export const WrongNetworkModal = ({ isOpen, onClose }: any) => { - Wrong Network + Switch Network - You are on the wrong network. Switch your wallet to BNB Greenfield first. + To complete the action, you need to switch to {CHAIN_NAMES[GREENFIELD_CHAIN_ID]}. @@ -39,7 +40,7 @@ export const WrongNetworkModal = ({ isOpen, onClose }: any) => { switchNetwork?.(GREENFIELD_CHAIN_ID); }} > - Switch to BNB Greenfield + Switch to {CHAIN_NAMES[GREENFIELD_CHAIN_ID]} { if (pathname === '/' || inline) return; @@ -63,7 +63,7 @@ export function LoginContextProvider(props: PropsWithChildren { console.log('invoke not connector') - if (!connector) { + if (!isConnected) { logout(); } }, 1000); @@ -71,7 +71,7 @@ export function LoginContextProvider(props: PropsWithChildren { clearTimeout(timer); }; - }, [connector, inline, loginAccount, logout, pathname, walletAddress]); + }, [inline, isConnected, loginAccount, logout, pathname, walletAddress]); useAsyncEffect(async () => { // ssr pages loginAccount initial value '' diff --git a/apps/dcellar-web-ui/src/utils/constant.ts b/apps/dcellar-web-ui/src/utils/constant.ts index 9a0b639e..d83ec2a4 100644 --- a/apps/dcellar-web-ui/src/utils/constant.ts +++ b/apps/dcellar-web-ui/src/utils/constant.ts @@ -11,9 +11,9 @@ export const reverseVisibilityType = convertVisibility(); export const CHAIN_NAMES: { [key: number | string]: string } = { 56: 'BNB Smart Chain Mainnet', 97: 'BNB Smart Chain Testnet', - 9000: 'Greenfield Devnet', - 5600: 'Greenfield Testnet', - 1017: 'Greenfield Mainnet', + 9000: 'BNB Greenfield Devnet', + 5600: 'BNB Greenfield Testnet', + 1017: 'BNB Greenfield Mainnet', }; export const GNFD_TESTNET = 5600;