diff --git a/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx b/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx index d6e9929..be9e823 100644 --- a/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx +++ b/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx @@ -2,6 +2,7 @@ import {useState} from 'react'; import {useOpenfort} from '../../hooks/useOpenfort'; import Loading from '../Loading'; import { Button } from '../ui/button'; +import { polygonAmoy } from 'viem/chains'; const AccountRecovery: React.FC = () => { const {handleRecovery} = useOpenfort(); @@ -33,7 +34,7 @@ const AccountRecovery: React.FC = () => { ) as HTMLInputElement ).value; setLoadingPwd(true); - await handleRecovery('password', password); + await handleRecovery({method: 'password', password, chainId: polygonAmoy.id}); setLoadingPwd(false); }} > @@ -56,7 +57,7 @@ const AccountRecovery: React.FC = () => { className="bg-white text-black p-2.5 border border-gray-200 rounded-lg w-full hover:bg-gray-100" onClick={async () => { setLoadingAut(true); - await handleRecovery('automatic'); + await handleRecovery({method:'automatic', chainId: polygonAmoy.id}); setLoadingAut(false); }} > diff --git a/examples/apps/auth-sample/src/hooks/useOpenfort.tsx b/examples/apps/auth-sample/src/hooks/useOpenfort.tsx index bcfeb1c..8b20655 100644 --- a/examples/apps/auth-sample/src/hooks/useOpenfort.tsx +++ b/examples/apps/auth-sample/src/hooks/useOpenfort.tsx @@ -26,10 +26,15 @@ import { Chain, createPublicClient, http } from 'viem'; interface ContextType { state: EmbeddedState; getEvmProvider: () => Provider; - handleRecovery: ( - method: 'password' | 'automatic', - pin?: string - ) => Promise; + handleRecovery: ({ + method, + password, + chainId +}:{ + method: 'password' | 'automatic', + chainId:number + password?: string, +}) => Promise; auth: (accessToken: string) => Promise; setWalletRecovery: ( recoveryMethod: RecoveryMethod, @@ -211,9 +216,8 @@ export const OpenfortProvider: React.FC> = ({ ); const handleRecovery = useCallback( - async (method: 'password' | 'automatic', pin?: string) => { + async ({method, password, chainId}:{method: 'password' | 'automatic', password?: string, chainId: number}) => { try { - const chainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID); const shieldAuth: ShieldAuthentication = { auth: ShieldAuthType.OPENFORT, token: openfort.getAccessToken()!, @@ -222,10 +226,10 @@ export const OpenfortProvider: React.FC> = ({ if (method === 'automatic') { await openfort.configureEmbeddedSigner(chainId, shieldAuth); } else if (method === 'password') { - if (!pin || pin.length < 4) { + if (!password || password.length < 4) { throw new Error('Password recovery must be at least 4 characters'); } - await openfort.configureEmbeddedSigner(chainId, shieldAuth, pin); + await openfort.configureEmbeddedSigner(chainId, shieldAuth, password); } } catch (err) { console.error('Error handling recovery with Openfort:', err); diff --git a/examples/apps/auth-sample/src/pages/index.tsx b/examples/apps/auth-sample/src/pages/index.tsx index 735918b..2e04d97 100644 --- a/examples/apps/auth-sample/src/pages/index.tsx +++ b/examples/apps/auth-sample/src/pages/index.tsx @@ -24,7 +24,7 @@ import { Wallet } from 'lucide-react'; import AccountActions from '@/components/AccountActions/AccountActions'; const HomePage: NextPage = () => { - const {state} = useOpenfort(); + const {state, handleRecovery} = useOpenfort(); const [user, setUser] = useState(null); const router = useRouter(); const [message, setMessage] = useState(''); @@ -48,12 +48,6 @@ const HomePage: NextPage = () => { if (!user) fetchUser(); }, [openfort]); - useEffect(() => { - if (textareaRef.current) { - textareaRef.current.scrollTop = textareaRef.current.scrollHeight; - } - }, [message]); - const linkedAccount = useMemo(() => { const linkedAccount = user?.linkedAccounts?.find( (account: any) => account.provider === 'email' @@ -71,7 +65,7 @@ const HomePage: NextPage = () => { return ( }>
-

+

Welcome, {user?.player?.name ?? user?.id}!

@@ -97,10 +91,22 @@ const HomePage: NextPage = () => { <>
- - - - +
+ + + + - +

+ Embedded Smart Wallet +

+
+ + {'Get started with Openfort ->'} +
@@ -109,14 +115,23 @@ const HomePage: NextPage = () => {

Console

-
+