Skip to content

Commit 3290b23

Browse files
committed
Change blobstream API
1 parent dfd7f7a commit 3290b23

3 files changed

Lines changed: 49 additions & 36 deletions

File tree

pages/blobstream.vue

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const sort = ref("desc")
8282
8383
const getNetworks = async () => {
8484
const { data } = await fetchNetworks()
85-
networks.value = data.value
85+
networks.value = data.value.filter(n => n.last_height > 0)
8686
}
8787
8888
const getCommitments = async () => {
@@ -281,39 +281,35 @@ getCommitments()
281281
</td>
282282
<td>
283283
<Flex align="center" gap="6">
284-
<NuxtLink :to="`/block/${c.celestia_start_height}`">
285-
<Flex align="center">
286-
<Outline>
287-
<Flex align="center" gap="6">
288-
<Icon
289-
name="block"
290-
size="14"
291-
color="tertiary"
292-
/>
293-
294-
<Text size="13" weight="600" color="primary" tabular>{{ comma(c.celestia_start_height) }}</Text>
295-
</Flex>
296-
</Outline>
297-
</Flex>
298-
</NuxtLink>
284+
<Flex align="center">
285+
<Outline @click.prevent.stop="router.push(`/block/${c.celestia_start_height}`)">
286+
<Flex align="center" gap="6">
287+
<Icon
288+
name="block"
289+
size="14"
290+
color="tertiary"
291+
/>
292+
293+
<Text size="13" weight="600" color="primary" tabular>{{ comma(c.celestia_start_height) }}</Text>
294+
</Flex>
295+
</Outline>
296+
</Flex>
299297

300298
<Text size="12" weight="600" color="primary">—</Text>
301299

302-
<NuxtLink :to="`/block/${c.celestia_end_height}`">
303-
<Flex align="center">
304-
<Outline>
305-
<Flex align="center" gap="6">
306-
<Icon
307-
name="block"
308-
size="14"
309-
color="tertiary"
310-
/>
311-
312-
<Text size="13" weight="600" color="primary" tabular>{{ comma(c.celestia_end_height) }}</Text>
313-
</Flex>
314-
</Outline>
315-
</Flex>
316-
</NuxtLink>
300+
<Flex align="center">
301+
<Outline @click.prevent.stop="router.push(`/block/${c.celestia_end_height}`)">
302+
<Flex align="center" gap="6">
303+
<Icon
304+
name="block"
305+
size="14"
306+
color="tertiary"
307+
/>
308+
309+
<Text size="13" weight="600" color="primary" tabular>{{ comma(c.celestia_end_height) }}</Text>
310+
</Flex>
311+
</Outline>
312+
</Flex>
317313
</Flex>
318314
</td>
319315
<td>

services/api/blobstream.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useBlobstreamURL } from "@/services/config"
33

44
export const fetchNetworks = async () => {
55
try {
6-
const url = new URL(`${useBlobstreamURL}/network`)
6+
const url = new URL(`${useBlobstreamURL()}/network`)
77

88
const data = await useFetch(url.href)
99
return data
@@ -14,7 +14,7 @@ export const fetchNetworks = async () => {
1414

1515
export const fetchCommitments = async ({ limit, offset, sort }) => {
1616
try {
17-
const url = new URL(`${useBlobstreamURL}/commitments`)
17+
const url = new URL(`${useBlobstreamURL()}/commitments`)
1818

1919
if (limit) url.searchParams.append("limit", limit)
2020
if (offset) url.searchParams.append("offset", offset)
@@ -29,7 +29,7 @@ export const fetchCommitments = async ({ limit, offset, sort }) => {
2929

3030
export const fetchCommitmentsByNetwork = async ({ network, limit, offset, sort }) => {
3131
try {
32-
const url = new URL(`${useBlobstreamURL}/network/${network}/commitments`)
32+
const url = new URL(`${useBlobstreamURL()}/network/${network}/commitments`)
3333

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

4545
export const fetchContracts = async (address) => {
4646
try {
47-
const url = new URL(`${useBlobstreamURL}/contracts`)
47+
const url = new URL(`${useBlobstreamURL()}/contracts`)
4848

4949
if (address) url + `/${address}`
5050

services/config.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export const Server = {
1111
arabica: "wss://api-arabica-11.celenium.io/v1/ws",
1212
dev: "wss://api-dev.celenium.io/v1/ws",
1313
},
14+
BLOBSTREAM: {
15+
mainnet: "https://api-blobstream.celenium.io/v1",
16+
testnet: "https://api-blobstream-testnet.celenium.io/v1",
17+
}
1418
}
1519

1620
export const useServerURL = () => {
@@ -61,4 +65,17 @@ export const useSocketURL = () => {
6165
}
6266
}
6367

64-
export const useBlobstreamURL = "https://api-blobstream.celenium.io/v1"
68+
export const useBlobstreamURL = () => {
69+
const requestURL = useRequestURL()
70+
71+
switch (requestURL.hostname) {
72+
case "mocha-4.celenium.io":
73+
return Server.BLOBSTREAM.testnet
74+
75+
case "mocha.celenium.io":
76+
return Server.BLOBSTREAM.testnet
77+
78+
default:
79+
return Server.BLOBSTREAM.mainnet
80+
}
81+
}

0 commit comments

Comments
 (0)