This commit is contained in:
Bill He 2024-01-18 10:37:08 -08:00
parent 20585c8ac9
commit 3ec7fab2f2
No known key found for this signature in database
GPG Key ID: 73AEEF9D79E5BBF8
2 changed files with 5 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import { useWalletConnection } from './useWalletConnection';
import { useSignTypedData } from 'wagmi';
import { getSelectedNetwork } from '@/state/appSelectors';
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
import { usePrivy } from '@privy-io/react-auth';
const AccountsContext = createContext<ReturnType<typeof useAccountsContext> | undefined>(undefined);
@ -199,6 +200,7 @@ const useAccountsContext = () => {
chainId,
},
});
const { ready, authenticated } = usePrivy();
useEffect(() => {
(async () => {
@ -216,7 +218,7 @@ const useAccountsContext = () => {
const evmDerivedAccount = evmDerivedAddresses[evmAddress];
if (walletConnectionType === WalletConnectionType.Privy) {
if (walletConnectionType === WalletConnectionType.Privy && authenticated && ready) {
try {
const signature = await signTypedDataAsync();

View File

@ -105,7 +105,7 @@ export const useWalletConnection = () => {
[walletConnectConfig, walletType, walletConnectionType]
);
const { connectAsync: connectWagmi } = useConnectWagmi({ connector: wagmiConnector })
const { connectAsync: connectWagmi } = useConnectWagmi({ connector: wagmiConnector });
const { suggestAndConnect: connectGraz } = useConnectGraz();
const { login, ready, authenticated } = usePrivy();
const { logout } = useLogout();
@ -118,6 +118,7 @@ export const useWalletConnection = () => {
if (!walletConnection) {
throw new Error('Onboarding: No wallet connection found.');
} else if (walletConnection.type === WalletConnectionType.Privy) {
console.log({ isConnectedWagmi, authenticated, ready });
if (!isConnectedWagmi && !authenticated && ready) {
login();
}