27cdd1c954
* tidy: added eslintrc and prettierrc rules * tidy: formated the files via ‚yarn format‘ * import sort improvements * format script regex fix * replace eslint import severity to warning * remove staged file Co-authored-by: Gustavo Mauricio <gustavo.mauricio58@gmail.com>
30 lines
681 B
TypeScript
30 lines
681 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import useWalletStore from 'stores/useWalletStore'
|
|
import { queryKeys } from 'types/query-keys-factory'
|
|
import { chain } from 'utils/chains'
|
|
|
|
type Result = {
|
|
balances: { amount: string; denom: string }[]
|
|
}
|
|
|
|
const useAllBalances = () => {
|
|
const address = useWalletStore((s) => s.address)
|
|
|
|
const result = useQuery<Result>(
|
|
queryKeys.allBalances(address),
|
|
() => fetch(`${chain.rest}/cosmos/bank/v1beta1/balances/${address}`).then((res) => res.json()),
|
|
{
|
|
enabled: !!address,
|
|
staleTime: Infinity,
|
|
},
|
|
)
|
|
|
|
return {
|
|
...result,
|
|
data: result?.data?.balances,
|
|
}
|
|
}
|
|
|
|
export default useAllBalances
|