-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathNotableStats.vue
More file actions
134 lines (107 loc) · 3.79 KB
/
Copy pathNotableStats.vue
File metadata and controls
134 lines (107 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<script setup>
/** Vendor */
import { DateTime } from "luxon"
/** UI */
import Tooltip from "@/components/ui/Tooltip.vue"
/** Services */
import { comma } from "@/services/utils"
/** Constants */
import { IbcChainName } from "@/services/constants/ibc"
/** Store */
import { useModalsStore } from "@/store/modals.store"
import { useCacheStore } from "@/store/cache.store"
const modalsStore = useModalsStore()
const cacheStore = useCacheStore()
const props = defineProps({
ibcData: {
type: Object,
},
})
const largestChain = ref(props.ibcData.rawChainsStats[0])
props.ibcData.rawChainsStats.forEach((chainStats) => {
if (Number(chainStats.flow) > Number(largestChain.value.flow)) {
largestChain.value = chainStats
}
})
const largestTransfer = props.ibcData.rawSummary.largest_transfer
const busiestChannel = props.ibcData.rawSummary.busiest_channel
const handleOpenTransferModal = (transfer) => {
cacheStore.current.transfer = transfer
modalsStore.open("ibcTransfer")
}
const getChainName = (target) => {
return largestTransfer[target].hash.startsWith("celestia")
? "Celestia"
: IbcChainName[largestTransfer.chain_id] ?? largestTransfer.chain_id
}
</script>
<template>
<Flex align="center" gap="16" :class="$style.wrapper">
<Tooltip wide position="start">
<Flex wide direction="column" gap="12" :class="$style.card">
<Flex align="center" justify="between">
<Flex align="center" gap="8">
<Icon name="coins" size="14" color="orange" />
<Text size="13" weight="600" color="secondary">Largest connected chain</Text>
</Flex>
<Icon name="info" size="14" color="support" />
</Flex>
<Text size="15" weight="600" color="primary">{{ IbcChainName[largestChain?.chain] ?? "Unknown" }} </Text>
<Text size="13" weight="500" color="support">
<Text color="tertiary" mono>{{ comma(largestChain?.flow / 1_000_000) }} TIA</Text>
</Text>
</Flex>
<template #content> The amount shown is the chain flow, sent and received tokens </template>
</Tooltip>
<Flex @click="handleOpenTransferModal(largestTransfer)" wide direction="column" gap="12" :class="[$style.card, $style.hoverable]">
<Flex align="center" justify="between">
<Flex align="center" gap="8">
<Icon name="arrow-circle-broken-right" size="14" color="brand" />
<Text size="13" weight="600" color="secondary">Largest transfer today</Text>
</Flex>
<Icon name="arrow-narrow-up-right-circle" size="14" color="tertiary" />
</Flex>
<Text size="15" weight="600" color="primary"
>{{ getChainName("sender") }} <Text color="tertiary">-></Text> {{ getChainName("receiver") }}
</Text>
<Text size="13" weight="500" color="support">
<Text color="tertiary" mono>{{ comma(largestTransfer.amount / 1_000_000) }} TIA</Text>
</Text>
</Flex>
<Flex wide direction="column" gap="12" :class="$style.card">
<Flex align="center" justify="between">
<Flex align="center" gap="8">
<Icon name="zap" size="14" color="red" />
<Text size="13" weight="600" color="secondary">Busiest channel</Text>
</Flex>
<Text size="12" weight="600" color="tertiary">{{ DateTime.now().toFormat("MMMM") }}</Text>
</Flex>
<Text size="15" weight="600" color="primary">
{{ busiestChannel.channel_id }}
<Text size="12" color="tertiary">{{ IbcChainName[busiestChannel.chain_id] ?? "Unknown" }}</Text>
</Text>
<Text size="13" weight="500" color="support">
<Text color="tertiary" mono>{{ comma(busiestChannel.transfers_count) }} transfers</Text>
</Text>
</Flex>
</Flex>
</template>
<style module>
.card {
border-radius: 8px;
background: var(--card-background);
padding: 12px;
&.hoverable {
cursor: pointer;
transition: all 0.2s ease;
&:hover {
box-shadow: 0 0 0 2px var(--op-10);
}
}
}
@media (max-width: 800px) {
.wrapper {
flex-direction: column;
}
}
</style>