* feat: do not redirect to wallet on portfolio page * fix: use connected wallet for AccountMenu * fix: fixed ghost AccountDetails * feat: created ShareBar and share functionality * fix: don’t show shareBar if no address is present * fix: stupid 'next/navigation' * tidy: format * fix: fixed tests * ✨ routing and pages for HLS (#538) * 🐛 use useAccountIds * fix: fixed the tests * fix: accountIds is now a suspense --------- Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com>
30 lines
882 B
TypeScript
30 lines
882 B
TypeScript
import { getAccountNftQueryClient } from 'api/cosmwasm-client'
|
|
import { ITEM_LIMIT_PER_QUERY } from 'constants/query'
|
|
|
|
export default async function getAccountIds(
|
|
address?: string,
|
|
previousResults?: string[],
|
|
): Promise<string[]> {
|
|
if (!address) return []
|
|
try {
|
|
const accountNftQueryClient = await getAccountNftQueryClient()
|
|
|
|
const lastItem = previousResults && previousResults.at(-1)
|
|
const results = await accountNftQueryClient.tokens({
|
|
limit: ITEM_LIMIT_PER_QUERY,
|
|
startAfter: lastItem,
|
|
owner: address,
|
|
})
|
|
|
|
const accumulated = (previousResults ?? []).concat(results.tokens)
|
|
|
|
if (results.tokens.length < ITEM_LIMIT_PER_QUERY) {
|
|
return accumulated.sort((a, b) => parseInt(a) - parseInt(b))
|
|
}
|
|
|
|
return await getAccountIds(address, accumulated)
|
|
} catch {
|
|
return new Promise((_, reject) => reject('No data'))
|
|
}
|
|
}
|