-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: connects user wallet while creating profile
- Loading branch information
1 parent
695cc34
commit 5659ffa
Showing
2 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useSIWE, useModal, SIWESession } from "connectkit"; | ||
import { useAccount } from "wagmi"; | ||
|
||
export const useConnectWallet = () => { | ||
const { setOpen } = useModal(); | ||
const { isConnected } = useAccount(); | ||
|
||
const { data, isReady, isRejected, isLoading, isSignedIn, signOut, signIn } = | ||
useSIWE({ | ||
onSignIn: (session?: SIWESession) => { | ||
// Do something with the data | ||
}, | ||
onSignOut: () => { | ||
// Do something when signed out | ||
}, | ||
}); | ||
|
||
const handleSignIn = async () => { | ||
await signIn()?.then((session?: SIWESession) => { | ||
// Do something when signed in | ||
}); | ||
}; | ||
|
||
const handleSignOut = async () => { | ||
await signOut()?.then(() => { | ||
// Do something when signed out | ||
}); | ||
}; | ||
|
||
return { | ||
isSignedIn, | ||
isConnected, | ||
handleSignIn, | ||
handleSignOut, | ||
isReady, | ||
isRejected, | ||
isLoading, | ||
handleConnectWallet: function () { | ||
setOpen(true); | ||
}, | ||
data, | ||
}; | ||
}; |