Skip to content

Commit c2acfd1

Browse files
committed
fix: only trigger SIWE auto sign in for IAW
1 parent 322a014 commit c2acfd1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { LockIcon } from "./icons/LockIcon.js";
3030
import { useConnectLocale } from "./locale/getConnectLocale.js";
3131
import type { ConnectLocale } from "./locale/types.js";
3232
import { SignatureScreen } from "./screens/SignatureScreen.js";
33+
import { useAdminWallet } from "src/exports/react.native.js";
3334

3435
const TW_CONNECT_WALLET = "tw-connect-wallet";
3536

@@ -400,6 +401,7 @@ function ConnectButtonInner(
400401
) {
401402
const activeWallet = useActiveWallet();
402403
const activeAccount = useActiveAccount();
404+
const adminWallet = useAdminWallet();
403405
const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
404406
const [showSignatureModal, setShowSignatureModal] = useState(false);
405407

@@ -410,13 +412,15 @@ function ConnectButtonInner(
410412
}
411413
}, [activeAccount]);
412414

413-
// if the wallet is connected and auth is required, trigger a login attempt automatically
415+
// if an IAW wallet is connected and auth is required, trigger a login attempt automatically
414416
useEffect(() => {
417+
const isIAW = activeWallet?.id === "inApp" || adminWallet?.id === "inApp";
415418
if (
416419
activeAccount &&
417420
siweAuth.requiresAuth &&
418421
!siweAuth.isLoggedIn &&
419-
!siweAuth.isLoggingIn
422+
!siweAuth.isLoggingIn &&
423+
isIAW
420424
) {
421425
siweAuth.doLogin();
422426
}
@@ -426,6 +430,8 @@ function ConnectButtonInner(
426430
siweAuth.doLogin,
427431
siweAuth.isLoggedIn,
428432
siweAuth.isLoggingIn,
433+
activeWallet,
434+
adminWallet,
429435
]);
430436

431437
const theme = props.theme || "dark";

0 commit comments

Comments
 (0)