Skip to content

Commit

Permalink
chore(dcellar-web-ui): add some log points
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed Oct 12, 2023
1 parent 6942e9e commit ad1ab0e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ export const ConnectWallet = memo<Partial<ConnectWalletProps>>(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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -24,10 +25,10 @@ export const WrongNetworkModal = ({ isOpen, onClose }: any) => {
<IconFont w={120} type={'error-network'} />
</Flex>
<Text fontSize={'24px'} fontWeight={600} lineHeight="150%" marginY={'16px'}>
Wrong Network
Switch Network
</Text>
<Text color="#76808F" fontSize={'18px'} fontWeight="400" lineHeight={'22px'}>
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]}.
</Text>
</ModalBody>
<ModalFooter flexDirection={'column'} mt={24} gap={16}>
Expand All @@ -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]}
</DCButton>
<DCButton
size={'lg'}
Expand Down
6 changes: 3 additions & 3 deletions apps/dcellar-web-ui/src/context/LoginContext/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
});

const { pathname } = useRouter();
const { address: walletAddress, connector } = useAccount();
const { address: walletAddress, isConnected } = useAccount();

useEffect(() => {
if (pathname === '/' || inline) return;
Expand All @@ -63,15 +63,15 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
// to avoid errors when using the connector, we treat this situation as logout.
const timer = setTimeout(() => {
console.log('invoke not connector')
if (!connector) {
if (!isConnected) {
logout();
}
}, 1000);

return () => {
clearTimeout(timer);
};
}, [connector, inline, loginAccount, logout, pathname, walletAddress]);
}, [inline, isConnected, loginAccount, logout, pathname, walletAddress]);

useAsyncEffect(async () => {
// ssr pages loginAccount initial value ''
Expand Down
6 changes: 3 additions & 3 deletions apps/dcellar-web-ui/src/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ad1ab0e

Please sign in to comment.