Skip to content

Commit

Permalink
fix(wallet): fix tx fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Dec 14, 2023
1 parent 57267fe commit 11215db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/features/src/common/hooks/useTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import { useAppStore } from '../store/app'

export const useTransaction = ({ hash }: { hash: string }) => {
const currentWallet = useVault((state) => state.getCurrentWallet())
const _syncTransactions = useVault((state) => state._syncTransactions)
const getTransaction = useVault((state) => state.getTransaction)
const { publicKey } = currentWallet.accountInfo
const network = useAppStore((state) => state.network)
const syncAndGetTransaction = async () => {
await _syncTransactions(network, currentWallet?.credential.credential)
return getTransaction(network, publicKey, hash)
}
return useSWR(
publicKey
? [
Expand All @@ -17,6 +22,6 @@ export const useTransaction = ({ hash }: { hash: string }) => {
Mina.Networks[network.toUpperCase() as keyof typeof Mina.Networks]
]
: null,
() => getTransaction(network, publicKey, hash)
async () => await syncAndGetTransaction()
)
}
7 changes: 6 additions & 1 deletion packages/features/src/common/hooks/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import { useAppStore } from '../store/app'

export const useTransactions = () => {
const currentWallet = useVault((state) => state.getCurrentWallet())
const _syncTransactions = useVault((state) => state._syncTransactions)
const getTransactions = useVault((state) => state.getTransactions)
const { publicKey } = currentWallet.accountInfo
const network = useAppStore((state) => state.network)
const syncAndGetTransactions = async () => {
await _syncTransactions(network, currentWallet?.credential.credential)
return getTransactions(network, publicKey)
}
return useSWR(
publicKey
? [
Expand All @@ -17,6 +22,6 @@ export const useTransactions = () => {
Mina.Networks[network.toUpperCase() as keyof typeof Mina.Networks]
]
: null,
() => getTransactions(network, publicKey)
async () => await syncAndGetTransactions()
)
}

0 comments on commit 11215db

Please sign in to comment.