-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Update components to handle new session type
- Loading branch information
1 parent
f6a0d23
commit c189514
Showing
18 changed files
with
213 additions
and
115 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
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
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
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
34 changes: 34 additions & 0 deletions
34
packages/wallet/app/module/common/hook/useSyncPrivySession.ts
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,34 @@ | ||
import { | ||
privySessionAtom, | ||
sdkSessionAtom, | ||
sessionAtom, | ||
} from "@/module/common/atoms/session"; | ||
import { jotaiStore } from "@module/atoms/store"; | ||
import { useWallets } from "@privy-io/react-auth"; | ||
import { useAtomValue } from "jotai"; | ||
import { RESET } from "jotai/utils"; | ||
import { useEffect } from "react"; | ||
import { type Address, isAddressEqual } from "viem"; | ||
|
||
/** | ||
* Hook that synchronise the privy session | ||
*/ | ||
export function useSyncPrivySession() { | ||
const privySession = useAtomValue(privySessionAtom); | ||
const { wallets: privyWallets, ready } = useWallets(); | ||
|
||
useEffect(() => { | ||
if (!ready) return; | ||
if (!privySession) return; | ||
|
||
// Find a privy wallets that match the current session | ||
const wallet = privyWallets.find((w) => | ||
isAddressEqual(w.address as Address, privySession.publicKey) | ||
); | ||
if (wallet) return; | ||
|
||
// If no wallet match, we reset the current user session | ||
jotaiStore.set(sessionAtom, RESET); | ||
jotaiStore.set(sdkSessionAtom, RESET); | ||
}, [privySession, privyWallets, ready]); | ||
} |
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
47 changes: 0 additions & 47 deletions
47
packages/wallet/app/module/settings/component/BiometryInfo/index.tsx
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
Oops, something went wrong.