-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a8a76c
commit bec868c
Showing
8 changed files
with
113 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ | |
{ | ||
id: 'configuration', | ||
label: 'Configuration' | ||
}, | ||
{ | ||
id: 'holders', | ||
label: 'Top Holders' | ||
} | ||
] | ||
]} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
apps/dashboard/src/routes/(search-pages)/resource/[resource]/holders/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<script lang="ts"> | ||
import Row from '@components/info-box/Row.svelte' | ||
import Link from '@components/_base/link/Link.svelte' | ||
import type { PageData } from './$types' | ||
import LoadingSpinner from '@components/_base/button/loading-spinner/LoadingSpinner.svelte' | ||
import { formatTokenValue } from '@utils' | ||
import type { ResourceHoldersCollectionItem } from '@common/gateway-sdk' | ||
import { callApi } from '@api/gateway' | ||
import InfiniteScroll from '@components/infinite-scroll/InfiniteScroll.svelte' | ||
export let data: PageData | ||
let holders: ResourceHoldersCollectionItem[] = [] | ||
data.holders.then(({ items }) => { | ||
holders = [...holders, ...items] | ||
}) | ||
let cursor: string | undefined | ||
data.holders.then((holders) => (cursor = holders.next_cursor ?? undefined)) | ||
const loadMore = async () => { | ||
if (!cursor) return | ||
const result = await callApi( | ||
'getResourceHolders', | ||
data.resource.address, | ||
cursor ?? undefined | ||
) | ||
let items: ResourceHoldersCollectionItem[] = [] | ||
if (result.isOk()) { | ||
cursor = result.value.next_cursor ?? undefined | ||
items = result.value.items | ||
} | ||
holders = [...holders, ...items] | ||
} | ||
</script> | ||
|
||
<div class="card info-card"> | ||
{#await data.holders} | ||
<div class="loading-container"> | ||
<div class="loading"> | ||
<LoadingSpinner /> | ||
</div> | ||
</div> | ||
{:then _} | ||
{#each holders as holder} | ||
<Row> | ||
<div slot="left"> | ||
<Link | ||
url="/account/{holder.holder_address}" | ||
text={holder.holder_address} | ||
/> | ||
</div> | ||
|
||
<div slot="right"> | ||
{holder.type === 'FungibleResource' | ||
? formatTokenValue(holder.amount).displayValue | ||
: holder.non_fungible_ids_count} | ||
</div> | ||
</Row> | ||
{/each} | ||
|
||
<InfiniteScroll | ||
on:thresholdReached={() => { | ||
loadMore() | ||
}} | ||
/> | ||
{/await} | ||
</div> | ||
|
||
<style> | ||
.loading-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
.loading { | ||
height: 5rem; | ||
width: 5rem; | ||
} | ||
.pagination { | ||
margin-top: var(--spacing-lg); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters