2023-09-19 13:39:14 +00:00
|
|
|
import useSWR from 'swr'
|
|
|
|
|
|
|
|
import getAccountIds from 'api/wallets/getAccountIds'
|
|
|
|
|
2023-11-16 10:16:16 +00:00
|
|
|
export default function useAccountIdsAndKinds(address?: string, suspense = true, noHls = false) {
|
2023-10-30 11:47:52 +00:00
|
|
|
return useSWR(
|
|
|
|
`wallets/${address}/account-ids`,
|
2023-11-16 10:16:16 +00:00
|
|
|
() =>
|
|
|
|
getAccountIds(address).then((accountIdsAndKinds) => {
|
|
|
|
if (noHls) {
|
|
|
|
return accountIdsAndKinds
|
|
|
|
.filter((accountIdAndKind) => accountIdAndKind.kind !== 'high_levered_strategy')
|
|
|
|
.map((a) => a.id)
|
|
|
|
}
|
|
|
|
return accountIdsAndKinds.map((a) => a.id)
|
|
|
|
}),
|
2023-10-30 11:47:52 +00:00
|
|
|
{
|
|
|
|
suspense: suspense,
|
|
|
|
fallback: [] as string[],
|
|
|
|
revalidateOnFocus: false,
|
|
|
|
},
|
|
|
|
)
|
2023-09-19 13:39:14 +00:00
|
|
|
}
|