Skip to content

Commit 893ec93

Browse files
committed
feat: get wallet hook (used only in dev for now)
1 parent e9b0051 commit 893ec93

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { queryOptions, useQuery } from '@tanstack/react-query'
2+
3+
import { useAPI } from '../providers/api-client'
4+
5+
export const useGetWallet = (walletId: string, password: string) => {
6+
const api = useAPI()
7+
8+
const result = useQuery(
9+
queryOptions({
10+
enabled: Boolean(walletId && password),
11+
queryKey: ['get-wallet', walletId],
12+
queryFn: async () => {
13+
const { mnemonic } = await api.wallet.get.query({
14+
walletId,
15+
password,
16+
})
17+
18+
return mnemonic
19+
},
20+
staleTime: 60 * 60 * 1000, // 1 hour
21+
gcTime: 60 * 60 * 1000, // 1 hour
22+
refetchOnMount: false,
23+
refetchOnWindowFocus: false,
24+
refetchOnReconnect: false,
25+
}),
26+
)
27+
28+
return result
29+
}

0 commit comments

Comments
 (0)