Skip to content

Commit

Permalink
fix: do not connect wallet from remember me in restricted geo (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy authored Oct 4, 2024
1 parent 77e2e58 commit 0cec083
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/hooks/useAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const useAccountsContext = () => {

const { ready, authenticated } = usePrivy();

const blockedGeo = useMemo(() => {
return geo && isBlockedGeo(geo) && checkForGeo;
}, [geo, checkForGeo]);

const [previousAddress, setPreviousAddress] = useState(sourceAccount.address);
useEffect(() => {
const { address, chain } = sourceAccount;
Expand Down Expand Up @@ -187,7 +191,7 @@ const useAccountsContext = () => {
log('useAccounts/decryptSignature', error);
dispatch(clearSavedEncryptedSignature());
}
} else if (sourceAccount.encryptedSignature) {
} else if (sourceAccount.encryptedSignature && geo && !blockedGeo) {
try {
const signature = decryptSignature(sourceAccount.encryptedSignature);

Expand All @@ -205,7 +209,7 @@ const useAccountsContext = () => {
if (!localDydxWallet) {
dispatch(setOnboardingState(OnboardingState.WalletConnected));

if (sourceAccount?.encryptedSignature) {
if (sourceAccount?.encryptedSignature && geo && !blockedGeo) {
try {
const signature = decryptSignature(sourceAccount.encryptedSignature);
await setWalletFromSignature(signature);
Expand All @@ -223,7 +227,7 @@ const useAccountsContext = () => {
dispatch(setOnboardingState(OnboardingState.Disconnected));
}
})();
}, [signerWagmi, isConnectedGraz, sourceAccount, localDydxWallet]);
}, [signerWagmi, isConnectedGraz, sourceAccount, localDydxWallet, blockedGeo]);

// abacus
useEffect(() => {
Expand Down Expand Up @@ -288,10 +292,10 @@ const useAccountsContext = () => {
}, [dispatch, dydxSubaccounts]);

useEffect(() => {
if (geo && isBlockedGeo(geo) && checkForGeo) {
if (blockedGeo) {
disconnect();
}
}, [checkForGeo, geo]);
}, [blockedGeo]);

// Disconnect wallet / accounts
const disconnectLocalDydxWallet = () => {
Expand Down

0 comments on commit 0cec083

Please sign in to comment.