diff --git a/components/data/LatestPFBTable.vue b/components/data/LatestPFBTable.vue index aaf94f4f..5abae02d 100644 --- a/components/data/LatestPFBTable.vue +++ b/components/data/LatestPFBTable.vue @@ -13,31 +13,16 @@ import { useServerURL } from "@/services/config" import { comma, space, splitAddress, tia } from "@/services/utils" /** API */ -// import { fetchLatestPFBs } from "@/services/api/tx" +import { fetchLatestPFBs } from "@/services/api/tx" const router = useRouter() const isLoading = ref(true) const pfbs = ref([]) -const fetchLatestPFBs = async (height) => { - try { - return await $fetch(`${useServerURL()}/tx?msg_type=MsgPayForBlobs&sort=desc&limit=5`) - } catch (error) { - console.error(error) - } -} - -// pfbs.value = await fetchLatestPFBs() -// pfbs.value = data.value - -onBeforeMount(async() => { - isLoading.value = true - - pfbs.value = await fetchLatestPFBs() - - isLoading.value = false -}) +const { data } = await fetchLatestPFBs() +pfbs.value = data.value +isLoading.value = false diff --git a/components/data/RecentNamespacesTable.vue b/components/data/RecentNamespacesTable.vue index 27eb4068..88f92f7a 100644 --- a/components/data/RecentNamespacesTable.vue +++ b/components/data/RecentNamespacesTable.vue @@ -12,7 +12,7 @@ import { useServerURL } from "@/services/config" import { comma, space, formatBytes, getNamespaceID } from "@/services/utils" /** API */ -// import { fetchNamespaces } from "@/services/api/namespace" +import { fetchNamespaces } from "@/services/api/namespace" const router = useRouter() @@ -24,36 +24,16 @@ const sort = reactive({ dir: "desc", }) -const fetchNamespaces = async ({ limit, offset, sort, sort_by }) => { - try { - const url = new URL(`${useServerURL()}/namespace`) - - if (limit) url.searchParams.append("limit", limit) - if (offset) url.searchParams.append("offset", offset) - if (sort) url.searchParams.append("sort", sort) - if (sort_by) url.searchParams.append("sort_by", sort_by) - - - return await $fetch(url.href) - } catch (error) { - console.error(error) - } -} - const getNamespaces = async () => { isLoading.value = true - namespaces.value = await fetchNamespaces({ limit: 5, sort: sort.dir, sort_by: sort.by }) - // namespaces.value = data.value + const { data } = await fetchNamespaces({ limit: 5, sort: sort.dir, sort_by: sort.by }) + namespaces.value = data.value isLoading.value = false } -// await getNamespaces() - -onBeforeMount(async() => { - await getNamespaces() -}) +await getNamespaces() const handleSort = async (by) => { switch (sort.dir) { diff --git a/components/widgets/StakingWidget.vue b/components/widgets/StakingWidget.vue index 2a7ef8b5..76857323 100644 --- a/components/widgets/StakingWidget.vue +++ b/components/widgets/StakingWidget.vue @@ -7,7 +7,7 @@ import { useServerURL } from "@/services/config" import { abbreviate, capitilize, numToPercent, shareOfTotal } from "@/services/utils" /** API */ -// import { fetchValidatorsCount } from "@/services/api/validator" +import { fetchValidatorsCount } from "@/services/api/validator" /** Store */ import { useAppStore } from "@/store/app" @@ -27,7 +27,7 @@ const totalVotingPowerUSD = computed(() => totalVotingPower.value * currentPrice const bondedShare = computed(() => shareOfTotal(lastHead?.value.total_voting_power * 1_000_000, lastHead?.value.total_supply, 2)) -const isRefetching = ref(false) +const isRefetching = ref(true) const totalValidators = ref(0) const activeValidators = ref(0) const validatorsGraph = ref([ @@ -51,26 +51,16 @@ const validatorsGraph = ref([ }, ]) -const fetchValidatorsCount = async () => { - try { - const url = new URL(`${useServerURL()}/validators/count`) - - return await $fetch(url.href) - } catch (error) { - console.error(error) - } -} - const getValidatorsStats = async () => { isRefetching.value = true - const data = await fetchValidatorsCount() - if (data?.total) { - totalValidators.value = data.total - activeValidators.value = data.active + const { data } = await fetchValidatorsCount() + if (data.value?.total) { + totalValidators.value = data.value.total + activeValidators.value = data.value.active for (let item of validatorsGraph.value) { - let value = data[item.title] + let value = data.value[item.title] if (value) { item.count = value @@ -82,11 +72,7 @@ const getValidatorsStats = async () => { isRefetching.value = false } -// await getValidatorsStats() - -onBeforeMount(async() => { - await getValidatorsStats() -}) +await getValidatorsStats() onMounted( async () => { wrapperWidth.value = wrapperEl.value.wrapper.offsetWidth diff --git a/nuxt.config.ts b/nuxt.config.ts index 8e84f44c..e4d28779 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -144,7 +144,7 @@ export default defineNuxtConfig({ plugins: [wasm(), topLevelAwait(), nodePolyfills()], worker: { format: "es", - plugins: [wasm(), topLevelAwait()], + plugins: () => [wasm(), topLevelAwait()], }, }, }) diff --git a/package.json b/package.json index 64853ccb..127f34db 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "packageManager": "pnpm@8.7.4", "homepage": "https://celenium.io/", "license": "MIT", + "type": "module", "scripts": { "build": "nuxt build", "dev": "cross-env PORT=9090 nuxt dev", diff --git a/pages/blobstream.vue b/pages/blobstream.vue index 1bc957da..073c5fb3 100644 --- a/pages/blobstream.vue +++ b/pages/blobstream.vue @@ -181,8 +181,8 @@ const handleViewCommitment = (commitment) => { modalsStore.open("commitment") } -getNetworks() -getCommitments() +await getNetworks() +await getCommitments()