Compare commits

...
Author SHA1 Message Date
Aleka Cheung 56ba69334a address feedback 2024-02-02 15:11:35 -05:00
Aleka Cheung f6e5469427 use updated isaccountconnected check 2024-02-01 16:23:00 -05:00
+13 -5
View File
@@ -115,7 +115,15 @@ export const useWalletConnection = () => {
}); });
const connectWallet = useCallback( const connectWallet = useCallback(
async ({ walletType, forceConnect }: { walletType?: WalletType; forceConnect?: boolean }) => { async ({
walletType,
forceConnect,
isAccountConnected,
}: {
walletType?: WalletType;
forceConnect?: boolean;
isAccountConnected?: boolean;
}) => {
if (!walletType) return { walletType, walletConnectionType }; if (!walletType) return { walletType, walletConnectionType };
const walletConnection = getWalletConnection({ walletType }); const walletConnection = getWalletConnection({ walletType });
@@ -143,9 +151,6 @@ export const useWalletConnection = () => {
} else if (walletConnection.type === WalletConnectionType.TestWallet) { } else if (walletConnection.type === WalletConnectionType.TestWallet) {
saveEvmAddress(STRING_KEYS.TEST_WALLET as EvmAddress); saveEvmAddress(STRING_KEYS.TEST_WALLET as EvmAddress);
} else { } else {
const isAccountConnected = Boolean(
evmAddress && evmDerivedAddresses[evmAddress]?.encryptedSignature
);
// if account connected (via remember me), do not show wagmi popup until forceConnect // if account connected (via remember me), do not show wagmi popup until forceConnect
if (!isConnectedWagmi && (forceConnect || !isAccountConnected)) { if (!isConnectedWagmi && (forceConnect || !isAccountConnected)) {
await connectWagmi({ await connectWagmi({
@@ -195,6 +200,9 @@ export const useWalletConnection = () => {
try { try {
const { walletType, walletConnectionType } = await connectWallet({ const { walletType, walletConnectionType } = await connectWallet({
walletType: selectedWalletType, walletType: selectedWalletType,
isAccountConnected: Boolean(
evmAddress && evmDerivedAddresses[evmAddress]?.encryptedSignature
),
}); });
setWalletType(walletType); setWalletType(walletType);
@@ -217,7 +225,7 @@ export const useWalletConnection = () => {
await disconnectWallet(); await disconnectWallet();
} }
})(); })();
}, [selectedWalletType, signerWagmi, signerGraz]); }, [selectedWalletType, signerWagmi, signerGraz, evmDerivedAddresses, evmAddress]);
const selectWalletType = async (walletType: WalletType | undefined) => { const selectWalletType = async (walletType: WalletType | undefined) => {
if (selectedWalletType) { if (selectedWalletType) {