@@ -4,12 +4,15 @@ import { Button } from "#src/components/primitives/button/Button"
44import { useTurnstile } from "#src/hooks/useTurnstile"
55import { userAtom } from "#src/state/user"
66import UserNotFoundWarning from "./UserNotFoundWarning"
7+ import { getBalanceQueryKey } from 'wagmi/query'
8+ import { useQueryClient } from '@tanstack/react-query'
79
810const TURNSTILE_SITEKEY = import . meta. env . VITE_TURNSTILE_SITEKEY !
911const FAUCET_ENDPOINT = import . meta. env . VITE_FAUCET_ENDPOINT !
1012
1113const FaucetView = ( ) => {
1214 const user = useAtomValue ( userAtom )
15+ const queryClient = useQueryClient ( )
1316 const [ status , setStatus ] = useState < "idle" | "loading" | "success" | "error" > ( "idle" )
1417 const [ message , setMessage ] = useState ( "" )
1518 const turnstileRef = useRef < HTMLDivElement | null > ( null )
@@ -37,6 +40,11 @@ const FaucetView = () => {
3740 if ( ! res . ok ) throw new Error ( data ?. message || "Unknown error" )
3841 setStatus ( "success" )
3942 setMessage ( data ?. message || "Tokens sent!" )
43+
44+ queryClient . invalidateQueries ( {
45+ queryKey : getBalanceQueryKey ( { address : user . address } ) ,
46+ } )
47+
4048 } catch ( err : unknown ) {
4149 if ( err instanceof Error ) {
4250 setStatus ( "error" )
@@ -47,7 +55,7 @@ const FaucetView = () => {
4755 }
4856 }
4957 } ,
50- [ getToken , user , turnstileLoading ] ,
58+ [ getToken , user , turnstileLoading , queryClient ] ,
5159 )
5260
5361 if ( ! user ) return < UserNotFoundWarning />
0 commit comments