Skip to content

Commit

Permalink
feat: improve wallet handling in ConnectButton and ensure proper logo…
Browse files Browse the repository at this point in the history
…ut flow in WalletProfile
  • Loading branch information
dipanshuhappy committed Nov 12, 2024
1 parent 7d65e64 commit 4013dd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions components/global/connect-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ const ConnectButton = () => {
const { login } = useLogin({
onComplete: async (user) => {
console.log("user logged in...", user);

if (user.wallet?.address && ready) {
const wallet = user.linkedAccounts.filter(a=>a.type === "wallet")[0]
console.log("wallet", wallet);
if (wallet.address) {
console.log("wallets", wallets);
const newActiveWallet = wallets.find(
(wallet) => wallet.address === user.wallet?.address,
);
if (newActiveWallet) {
console.log("newActiveWallet", newActiveWallet);
console.log("chainId", newActiveWallet.chainId);

await setActiveWallet(newActiveWallet);
const chainId = newActiveWallet.chainId;
if (chainId !== DEFAULT_CHAIN_ID.toString()) {
Expand All @@ -40,6 +44,7 @@ const ConnectButton = () => {
}
setIsLogin(true);
},

onError: (error) => {
console.log("error while logging in...", error);
setIsLogin(false);
Expand Down
3 changes: 2 additions & 1 deletion components/global/wallet-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ const WalletProfile = ({
<DropdownMenuItem
className="cursor-pointer"
onClick={async () => {
await logout.logout();
await disconnectAsync();
await logout.logout();

}}
>
Disconnect
Expand Down

0 comments on commit 4013dd6

Please sign in to comment.