@@ -10,7 +10,7 @@ import Tooltip from "@/components/ui/Tooltip.vue"
1010import { tia , comma , space , formatBytes , getNamespaceID } from " @/services/utils"
1111
1212/** API */
13- import { fetchBlockNamespaces } from " @/services/api/block"
13+ import { fetchBlockBlobs } from " @/services/api/block"
1414import { fetchTransactionsByBlock } from " @/services/api/tx"
1515
1616/** Store */
@@ -27,7 +27,7 @@ const preview = reactive({
2727 transactions: [],
2828 pfbs: [],
2929
30- isLoadingPfbs : true ,
30+ isLoadingNamespaces : true ,
3131})
3232
3333const autoSelect = ref (true )
@@ -38,7 +38,7 @@ const handleSelectBlock = (b, isUser) => {
3838 if (preview .block .height === b .height ) return
3939
4040 preview .block = b
41- preview .pfbs = []
41+ preview .namespaces = []
4242}
4343
4444const getTransactionsByBlock = async () => {
@@ -104,7 +104,7 @@ watch(
104104 () => preview.block,
105105 async () => {
106106 if (preview.block.stats.tx_count) {
107- if (preview.block.stats.blobs_size) preview.isLoadingPfbs = true
107+ if (preview.block.stats.blobs_size) preview.isLoadingNamespaces = true
108108
109109 getTransactionsByBlock()
110110 }
@@ -115,13 +115,19 @@ watch(
115115 () => preview.transactions,
116116 async () => {
117117 if (preview.block.stats.blobs_size === 0) {
118- preview.isLoadingPfbs = false
118+ preview.isLoadingNamespaces = false
119119 return
120120 }
121121
122- const data = await fetchBlockNamespaces({ height: preview.block.height })
123- preview.pfbs = data
124- preview.isLoadingPfbs = false
122+ const data = await fetchBlockBlobs({ height: preview.block.height })
123+ let namespaces = []
124+
125+ data.forEach(blob => {
126+ namespaces.push(blob.namespace)
127+ });
128+
129+ preview.namespaces = Array.from(new Map(namespaces.map(item => [item.id, item])).values());
130+ preview.isLoadingNamespaces = false
125131 },
126132)
127133
@@ -283,7 +289,7 @@ watch(
283289 <td>
284290 <Flex align="center">
285291 <Text size="13" weight="600" color="primary">
286- {{ block.stats.tx_count }}
292+ {{ block.stats.blobs_count }}
287293 </Text>
288294 </Flex>
289295 </td>
@@ -460,12 +466,12 @@ watch(
460466 <Flex align="center" justify="between">
461467 <Text size="12" weight="600" color="tertiary">Namespaces</Text>
462468 <Text size="12" weight="600" color="secondary">
463- {{ preview.pfbs ?.length > 3 ? "3 /" : "" }} {{ preview.pfbs ?.length }}
469+ {{ preview.namespaces ?.length > 3 ? "3 /" : "" }} {{ preview.namespaces ?.length }}
464470 </Text>
465471 </Flex>
466472
467473 <Text
468- v-if="preview.isLoadingPfbs "
474+ v-if="preview.isLoadingNamespaces "
469475 size="12"
470476 weight="600"
471477 color="tertiary"
@@ -474,27 +480,27 @@ watch(
474480 >
475481 Loading namespaces..
476482 </Text>
477- <Flex v-else-if="preview.pfbs ?.length" direction="column" gap="8">
478- <NuxtLink v-for="pfb in preview.pfbs .slice(0, 3)" :to="` / namespace/ ${pfb . namespace .namespace_id }` ">
483+ <Flex v-else-if="preview.namespaces ?.length" direction="column" gap="8">
484+ <NuxtLink v-for="ns in preview.namespaces .slice(0, 3)" :to="` / namespace/ ${ns .namespace_id }` ">
479485 <Outline wide height="32" padding="8" radius="6">
480486 <Flex align="center" justify="between" wide>
481487 <Flex align="center" gap="8">
482488 <Icon name="folder" size="12" color="secondary" />
483489
484490 <Text size="13" weight="600" color="primary" mono>
485- {{ getNamespaceID(pfb.namespace .namespace_id).slice(0, 4) }}
491+ {{ getNamespaceID(ns .namespace_id).slice(0, 4) }}
486492 </Text>
487493
488494 <Flex align="center" gap="3">
489495 <div v-for="dot in 3" class="dot" />
490496 </Flex>
491497
492498 <Text size="13" weight="600" color="primary" mono>
493- {{ getNamespaceID(pfb.namespace .namespace_id).slice(-4) }}
499+ {{ getNamespaceID(ns .namespace_id).slice(-4) }}
494500 </Text>
495501 </Flex>
496502
497- <Text size="12" weight="600" color="tertiary">{{ formatBytes(pfb.namespace .size) }}</Text>
503+ <Text size="12" weight="600" color="tertiary">{{ formatBytes(ns .size) }}</Text>
498504 </Flex>
499505 </Outline>
500506 </NuxtLink>
0 commit comments