Skip to content

Commit 5967ac2

Browse files
committed
init mainnet
1 parent 7596ecc commit 5967ac2

File tree

13 files changed

+94
-45
lines changed

13 files changed

+94
-45
lines changed

components/Feed.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ import { useAppStore } from "@/store/app"
1010
const appStore = useAppStore()
1111
1212
const head = computed(() => appStore.head)
13+
14+
const { hostname } = useRequestURL()
15+
16+
const getNetworkName = () => {
17+
switch (hostname) {
18+
case "celenium.io":
19+
return "Mainnet"
20+
21+
case "mocha-4.celenium.io":
22+
return "Mocha-4"
23+
24+
case "localhost":
25+
return "Local Environment"
26+
27+
default:
28+
return "Unknown"
29+
}
30+
}
1331
</script>
1432

1533
<template>
@@ -73,7 +91,7 @@ const head = computed(() => appStore.head)
7391

7492
<Flex align="center" gap="6">
7593
<Icon name="globe" size="12" color="tertiary" />
76-
<Text size="12" weight="500" color="tertiary"> Mocha-4 </Text>
94+
<Text size="12" weight="500" color="tertiary"> {{ getNetworkName() }} </Text>
7795
</Flex>
7896
</Flex>
7997
</Flex>

components/data/RecentNamespacesTable.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ const handleCopy = (target) => {
140140
}
141141
142142
.namespaces_body {
143+
flex: 1;
144+
143145
border-radius: 4px 4px 8px 8px;
144146
background: var(--card-background);
145147
@@ -204,6 +206,8 @@ const handleCopy = (target) => {
204206
}
205207
206208
.table_scroller {
209+
flex: 1;
210+
207211
overflow-x: auto;
208212
}
209213
</style>

components/widgets/NetworkWidget.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/** UI */
33
import Tooltip from "@/components/ui/Tooltip.vue"
44
5+
import { comma } from "@/services/utils"
6+
57
/** API */
68
import { fetchHistogram } from "@/services/api/histogram"
79
@@ -29,7 +31,7 @@ const pos = (100 * (tph - lowLevel)) / (highLevel - lowLevel)
2931
<Flex align="center" gap="6">
3032
<Icon name="zap-circle" size="20" color="primary" />
3133
<Flex gap="4" align="end">
32-
<Text size="20" weight="600" color="primary">{{ tph.toFixed(0) }}</Text>
34+
<Text size="20" weight="600" color="primary">{{ comma(tph.toFixed(0)) }}</Text>
3335
<Text size="14" weight="700" color="tertiary">TPH</Text>
3436
</Flex>
3537
</Flex>
@@ -92,11 +94,6 @@ const pos = (100 * (tph - lowLevel)) / (highLevel - lowLevel)
9294
</Flex>
9395
</template>
9496
</Tooltip>
95-
96-
<Flex align="center" justify="between" :class="$style.labels">
97-
<Text size="11" weight="600" color="tertiary">Min</Text>
98-
<Text size="11" weight="600" color="tertiary">Max</Text>
99-
</Flex>
10097
</Flex>
10198
</Flex>
10299

components/widgets/TransactionsWidget.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ const histogram = ref([])
1313
const { data } = await fetchHistogram({ table: "tx", func: "count", period: "hour" })
1414
histogram.value = data.value.slice(0, 24).reverse()
1515
16+
const isDataAvailable = ref(false)
17+
1618
let sectors = []
1719
histogram.value.forEach((item, idx) => {
1820
const rSix = Math.ceil((idx + 1) / 6) * 6
1921
if (rSix === idx + 1) {
2022
sectors.push(histogram.value.slice(rSix - 6, rSix))
2123
}
2224
})
25+
if (sectors.length !== 4) {
26+
isDataAvailable.value = false
27+
}
2328
2429
const min = Math.min(...histogram.value.map((item) => parseInt(item.value)))
2530
const max = Math.max(...histogram.value.map((item) => parseInt(item.value)))
@@ -54,11 +59,11 @@ const getSectorName = (idx) => {
5459
</Flex>
5560

5661
<!-- Chart -->
57-
<Flex gap="16" :class="$style.chart">
62+
<Flex v-if="isDataAvailable" gap="16" :class="$style.chart">
5863
<Flex direction="column" justify="between" :class="$style.yAxis">
59-
<Text size="12" weight="600" color="secondary">{{ roundedMax }}</Text>
60-
<Text size="12" weight="600" color="secondary">{{ Math.ceil(roundedMax / 2) }}</Text>
61-
<Text size="12" weight="600" color="secondary">{{ min }}</Text>
64+
<Text size="12" weight="600" color="secondary">{{ comma(roundedMax) }}</Text>
65+
<Text size="12" weight="600" color="secondary">{{ comma(Math.ceil(roundedMax / 2)) }}</Text>
66+
<Text size="12" weight="600" color="secondary">{{ comma(min) }}</Text>
6267
</Flex>
6368

6469
<Flex wide :class="$style.sectors">
@@ -79,6 +84,11 @@ const getSectorName = (idx) => {
7984
</Flex>
8085
</Flex>
8186
</Flex>
87+
88+
<Flex v-else align="center" justify="center" direction="column" gap="6" wide :class="$style.empty">
89+
<Text size="13" weight="600" color="secondary" align="center"> Data temporarily unavailable </Text>
90+
<Text size="12" weight="500" height="160" color="tertiary" align="center"> Transaction widget will be available soon </Text>
91+
</Flex>
8292
</Flex>
8393
</template>
8494

@@ -136,4 +146,8 @@ const getSectorName = (idx) => {
136146
border-radius: 50%;
137147
background: var(--op-5);
138148
}
149+
150+
.empty {
151+
height: 100%;
152+
}
139153
</style>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "celestia-explorer",
3-
"version": "0.1.5",
3+
"version": "1.0.0",
44
"packageManager": "[email protected]",
55
"homepage": "https://celenium.io/",
66
"license": "MIT",

services/api/address.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** Services */
2-
import { Server } from "@/services/config"
2+
import { useServerURL } from "@/services/config"
33

44
export const fetchAddresses = async ({ limit, offset, sort }) => {
55
try {
6-
const url = new URL(`${Server.API}/address`)
6+
const url = new URL(`${useServerURL()}/address`)
77

88
if (limit) url.searchParams.append("limit", limit)
99
if (offset) url.searchParams.append("offset", offset)
@@ -18,7 +18,7 @@ export const fetchAddresses = async ({ limit, offset, sort }) => {
1818

1919
export const fetchAddressesCount = async () => {
2020
try {
21-
const url = new URL(`${Server.API}/address/count`)
21+
const url = new URL(`${useServerURL()}/address/count`)
2222

2323
const data = await useFetch(url.href)
2424
return data
@@ -29,7 +29,7 @@ export const fetchAddressesCount = async () => {
2929

3030
export const fetchAddressByHash = async (hash) => {
3131
try {
32-
const url = new URL(`${Server.API}/address/${hash}`)
32+
const url = new URL(`${useServerURL()}/address/${hash}`)
3333

3434
const data = await useFetch(url.href)
3535
return data
@@ -40,7 +40,7 @@ export const fetchAddressByHash = async (hash) => {
4040

4141
export const fetchTxsByAddressHash = async ({ limit, offset, sort, hash }) => {
4242
try {
43-
const url = new URL(`${Server.API}/address/${hash}/txs`)
43+
const url = new URL(`${useServerURL()}/address/${hash}/txs`)
4444

4545
if (limit) url.searchParams.append("limit", limit)
4646
if (offset) url.searchParams.append("offset", offset)

services/api/block.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** Services */
2-
import { Server } from "@/services/config"
2+
import { useServerURL } from "@/services/config"
33

44
export const fetchBlocks = async ({ limit, offset }) => {
55
try {
6-
const url = new URL(`${Server.API}/block`)
6+
const url = new URL(`${useServerURL()}/block`)
77

88
url.searchParams.append("stats", true)
99
url.searchParams.append("sort", "desc")
@@ -20,7 +20,7 @@ export const fetchBlocks = async ({ limit, offset }) => {
2020

2121
export const fetchBlockByHeight = async (height) => {
2222
try {
23-
const data = await useFetch(`${Server.API}/block/${height}?stats=true`)
23+
const data = await useFetch(`${useServerURL()}/block/${height}?stats=true`)
2424
return data
2525
} catch (error) {
2626
console.error(error)
@@ -29,7 +29,7 @@ export const fetchBlockByHeight = async (height) => {
2929

3030
export const fetchBlockNamespaces = async ({ height, limit, offset, sort }) => {
3131
try {
32-
const url = new URL(`${Server.API}/block/${height}/namespace`)
32+
const url = new URL(`${useServerURL()}/block/${height}/namespace`)
3333

3434
if (limit) url.searchParams.append("limit", limit)
3535
if (offset) url.searchParams.append("offset", offset)
@@ -44,7 +44,7 @@ export const fetchBlockNamespaces = async ({ height, limit, offset, sort }) => {
4444

4545
export const fetchBlockNamespacesCount = async (height) => {
4646
try {
47-
const data = await useLazyFetch(`${Server.API}/block/${height}/namespace/count`)
47+
const data = await useLazyFetch(`${useServerURL()}/block/${height}/namespace/count`)
4848
if (data.status.value === "idle") await data.execute()
4949
return data
5050
} catch (error) {

services/api/histogram.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** Services */
2-
import { Server } from "@/services/config"
2+
import { useServerURL } from "@/services/config"
33

44
export const fetchHistogram = async ({ table, func, period }) => {
55
try {
6-
const url = new URL(`${Server.API}/stats/histogram/${table}/${func}/${period}`)
6+
const url = new URL(`${useServerURL()}/stats/histogram/${table}/${func}/${period}`)
77

88
const data = await useFetch(url.href)
99
return data

services/api/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** Services */
2-
import { Server } from "@/services/config"
2+
import { useServerURL } from "@/services/config"
33

44
export const fetchHead = async () => {
55
try {
6-
const data = await useFetch(`${Server.API}/head`)
6+
const data = await useFetch(`${useServerURL()}/head`)
77
return data
88
} catch (error) {
99
console.error(error)

services/api/namespace.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** Services */
2-
import { Server } from "@/services/config"
2+
import { useServerURL } from "@/services/config"
33

44
export const fetchNamespaces = async ({ limit, offset, sort }) => {
55
try {
6-
const url = new URL(`${Server.API}/namespace`)
6+
const url = new URL(`${useServerURL()}/namespace`)
77

88
if (limit) url.searchParams.append("limit", limit)
99
if (offset) url.searchParams.append("offset", offset)
@@ -18,7 +18,7 @@ export const fetchNamespaces = async ({ limit, offset, sort }) => {
1818

1919
export const fetchNamespacesCount = async () => {
2020
try {
21-
const url = new URL(`${Server.API}/namespace/count`)
21+
const url = new URL(`${useServerURL()}/namespace/count`)
2222

2323
const data = await useFetch(url.href)
2424
return data
@@ -29,7 +29,7 @@ export const fetchNamespacesCount = async () => {
2929

3030
export const fetchRecentNamespaces = async () => {
3131
try {
32-
const url = new URL(`${Server.API}/namespace/active`)
32+
const url = new URL(`${useServerURL()}/namespace/active`)
3333

3434
const data = await useFetch(url.href)
3535
return data
@@ -40,7 +40,7 @@ export const fetchRecentNamespaces = async () => {
4040

4141
export const fetchNamespaceByHash = async (hash) => {
4242
try {
43-
const url = new URL(`${Server.API}/namespace_by_hash/${hash}`)
43+
const url = new URL(`${useServerURL()}/namespace_by_hash/${hash}`)
4444

4545
const data = await useFetch(encodeURI(url.href))
4646
return data
@@ -51,7 +51,7 @@ export const fetchNamespaceByHash = async (hash) => {
5151

5252
export const fetchNamespaceMessagesById = async ({ id, version, limit, offset }) => {
5353
try {
54-
const url = new URL(`${Server.API}/namespace/${id}/${version}/messages`)
54+
const url = new URL(`${useServerURL()}/namespace/${id}/${version}/messages`)
5555

5656
if (limit) url.searchParams.append("limit", limit)
5757
if (offset) url.searchParams.append("offset", offset)
@@ -65,7 +65,7 @@ export const fetchNamespaceMessagesById = async ({ id, version, limit, offset })
6565

6666
export const fetchNamespaceByMetadata = async ({ hash, height, commitment }) => {
6767
try {
68-
const url = new URL(`${Server.API}/namespace_by_hash/${hash}/${height}/${commitment}`)
68+
const url = new URL(`${useServerURL()}/namespace_by_hash/${hash}/${height}/${commitment}`)
6969

7070
const data = await useFetch(encodeURI(url.href))
7171
return data

0 commit comments

Comments
 (0)