Skip to content

Commit

Permalink
Show sign in button if user address and active wallet address are mis…
Browse files Browse the repository at this point in the history
…-matched (#1886)
  • Loading branch information
edwardysun authored Nov 1, 2023
1 parent a9d32f3 commit 6fcd09d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-pens-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/react": patch
---

Fix for user address and active wallet address out of sync
9 changes: 6 additions & 3 deletions packages/react/src/wallet/ConnectWallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
const { user } = useUser();
const disconnect = useDisconnect();

const shouldSignIn = !!authConfig?.authUrl && !!address && !user?.address;
const addressAndUserAddressMismatched = address !== user?.address;

const requiresSignIn = props.auth?.loginOptional
? false
: !!authConfig?.authUrl && !!address && !user?.address;
: shouldSignIn || addressAndUserAddressMismatched;

const supportedTokens = useMemo(() => {
if (!props.supportedTokens) {
Expand All @@ -192,10 +195,10 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {

// if wallet gets disconnected, close the signature modal
useEffect(() => {
if (!activeWallet) {
if (!activeWallet && !addressAndUserAddressMismatched) {
setShowSignatureModal(false);
}
}, [activeWallet]);
}, [activeWallet, addressAndUserAddressMismatched]);

return (
<CustomThemeProvider theme={theme}>
Expand Down

0 comments on commit 6fcd09d

Please sign in to comment.