|
| 1 | +<script setup> |
| 2 | +/** Vendor */ |
| 3 | +import { DateTime } from "luxon" |
| 4 | +
|
| 5 | +/** UI */ |
| 6 | +import Modal from "@/components/ui/Modal.vue" |
| 7 | +import Button from "@/components/ui/Button.vue" |
| 8 | +import Tooltip from "@/components/ui/Tooltip.vue" |
| 9 | +
|
| 10 | +/** Components */ |
| 11 | +import ConnectionCard from "@/components/modules/ibc/ConnectionCard" |
| 12 | +
|
| 13 | +/** Services */ |
| 14 | +import { comma } from "@/services/utils" |
| 15 | +import { IbcChainName } from "@/services/constants/ibc" |
| 16 | +
|
| 17 | +/** API */ |
| 18 | +import { fetchIbcConnections } from "@/services/api/ibc" |
| 19 | +
|
| 20 | +/** Stores */ |
| 21 | +import { useAppStore } from "@/store/app.store" |
| 22 | +import { useCacheStore } from "@/store/cache.store" |
| 23 | +const appStore = useAppStore() |
| 24 | +const cacheStore = useCacheStore() |
| 25 | +
|
| 26 | +const emit = defineEmits(["onClose"]) |
| 27 | +const props = defineProps({ |
| 28 | + show: Boolean, |
| 29 | +}) |
| 30 | +
|
| 31 | +const client = computed(() => cacheStore.current.client) |
| 32 | +
|
| 33 | +const connections = ref([]) |
| 34 | +
|
| 35 | +const getConnections = async () => { |
| 36 | + connections.value = await fetchIbcConnections({ client_id: client.value.id }) |
| 37 | +} |
| 38 | +
|
| 39 | +watch( |
| 40 | + () => props.show, |
| 41 | + async () => { |
| 42 | + if (props.show) { |
| 43 | + await getConnections() |
| 44 | + } else { |
| 45 | + connections.value = [] |
| 46 | + } |
| 47 | + }, |
| 48 | +) |
| 49 | +
|
| 50 | +const handleNavigate = (target) => { |
| 51 | + emit("onClose") |
| 52 | + navigateTo(target) |
| 53 | +} |
| 54 | +</script> |
| 55 | + |
| 56 | +<template> |
| 57 | + <Modal :show="show" @onClose="emit('onClose')" width="500" disable-trap> |
| 58 | + <Flex align="center" direction="column" gap="16"> |
| 59 | + <Flex wide align="center" gap="6"> |
| 60 | + <Icon name="address" size="14" color="primary" /> |
| 61 | + <Text size="14" weight="600" color="primary">IBC Client</Text> |
| 62 | + </Flex> |
| 63 | + |
| 64 | + <Flex wide gap="8" :class="$style.card"> |
| 65 | + <Icon name="address" size="16" color="secondary" :class="$style.icon" /> |
| 66 | + |
| 67 | + <Flex direction="column" gap="4"> |
| 68 | + <Text size="12" weight="600" color="primary"> |
| 69 | + {{ client.id }} |
| 70 | + </Text> |
| 71 | + <Text size="12" weight="600" color="tertiary" mono> |
| 72 | + {{ client.type }} |
| 73 | + </Text> |
| 74 | + </Flex> |
| 75 | + </Flex> |
| 76 | + |
| 77 | + <Flex wide direction="column" gap="16" :class="$style.card"> |
| 78 | + <Text size="12" weight="600" color="secondary">Details</Text> |
| 79 | + |
| 80 | + <Flex align="center" justify="between"> |
| 81 | + <Text size="12" weight="600" color="tertiary">Chain</Text> |
| 82 | + <Text size="12" weight="600" color="primary"> |
| 83 | + {{ IbcChainName[client.chain_id] ? IbcChainName[client.chain_id] : "Unknown Chain" }} |
| 84 | + <Text color="tertiary" mono>({{ client.chain_id }})</Text> |
| 85 | + </Text> |
| 86 | + </Flex> |
| 87 | + |
| 88 | + <Flex align="center" justify="between"> |
| 89 | + <Text size="12" weight="600" color="tertiary">Updated at</Text> |
| 90 | + |
| 91 | + <Tooltip position="end"> |
| 92 | + <Text size="12" weight="600" color="primary"> |
| 93 | + {{ DateTime.fromISO(client.updated_at).toRelative() }} |
| 94 | + </Text> |
| 95 | + |
| 96 | + <template #content> {{ DateTime.fromISO(client.updated_at).setLocale("en").toFormat("LLL d, t") }}</template> |
| 97 | + </Tooltip> |
| 98 | + </Flex> |
| 99 | + |
| 100 | + <Flex align="center" justify="between"> |
| 101 | + <Text size="12" weight="600" color="tertiary">Created at</Text> |
| 102 | + |
| 103 | + <Tooltip position="end"> |
| 104 | + <Text size="12" weight="600" color="primary"> |
| 105 | + {{ DateTime.fromISO(client.created_at).toRelative() }} |
| 106 | + </Text> |
| 107 | + |
| 108 | + <template #content> {{ DateTime.fromISO(client.created_at).setLocale("en").toFormat("LLL d, t") }}</template> |
| 109 | + </Tooltip> |
| 110 | + </Flex> |
| 111 | + |
| 112 | + <Flex align="center" justify="between"> |
| 113 | + <Text size="12" weight="600" color="tertiary">Height</Text> |
| 114 | + <Text @click="handleNavigate(`/block/${client.height}`)" size="12" weight="600" color="primary" class="clickable"> |
| 115 | + {{ comma(client.height) }} |
| 116 | + </Text> |
| 117 | + </Flex> |
| 118 | + |
| 119 | + <Flex align="center" justify="between"> |
| 120 | + <Text size="12" weight="600" color="tertiary">Created by</Text> |
| 121 | + |
| 122 | + <Flex @click="handleNavigate(`/address/${client.creator.hash}`)" align="center" gap="6" class="clickable"> |
| 123 | + <Text size="12" weight="600" color="primary" mono>celestia</Text> |
| 124 | + <Flex align="center" gap="4"> |
| 125 | + <div v-for="dot in 3" class="dot" /> |
| 126 | + </Flex> |
| 127 | + <Text size="12" weight="600" color="primary" mono> |
| 128 | + {{ client.creator.hash.slice(-4) }} |
| 129 | + </Text> |
| 130 | + </Flex> |
| 131 | + </Flex> |
| 132 | + |
| 133 | + <Flex align="center" justify="between"> |
| 134 | + <Text size="12" weight="600" color="tertiary">Known connections</Text> |
| 135 | + <Text size="12" weight="600" color="primary"> |
| 136 | + {{ client.connection_count }} |
| 137 | + </Text> |
| 138 | + </Flex> |
| 139 | + </Flex> |
| 140 | + |
| 141 | + <Flex wide direction="column" gap="8"> |
| 142 | + <Text size="12" weight="600" color="secondary">Client connections</Text> |
| 143 | + <ConnectionCard v-for="connection in connections" :connection @onClose="emit('onClose')" /> |
| 144 | + </Flex> |
| 145 | + |
| 146 | + <Flex wide direction="column" gap="8"> |
| 147 | + <Button @click="emit('onClose')" wide type="tertiary" size="small">Close</Button> |
| 148 | + </Flex> |
| 149 | + </Flex> |
| 150 | + </Modal> |
| 151 | +</template> |
| 152 | + |
| 153 | +<style module> |
| 154 | +.card { |
| 155 | + border-radius: 8px; |
| 156 | + background: var(--op-5); |
| 157 | +
|
| 158 | + padding: 8px 12px 8px 8px; |
| 159 | +} |
| 160 | +
|
| 161 | +.address_text { |
| 162 | + flex: 1; |
| 163 | +} |
| 164 | +
|
| 165 | +.icon { |
| 166 | + border-radius: 50px; |
| 167 | + border: 2px solid var(--op-5); |
| 168 | + box-sizing: content-box; |
| 169 | +
|
| 170 | + padding: 2px; |
| 171 | +} |
| 172 | +</style> |
0 commit comments