@@ -9,14 +9,15 @@ import Button from "~/components/ui/Button.vue"
99
1010/** Shared Components */
1111import MessageTypeBadge from " @/components/shared/MessageTypeBadge.vue"
12+ import MessagesTable from " @/components/modules/tx/MessagesTable.vue"
1213
1314/** Services */
1415import { comma , tia , splitAddress } from " @/services/utils"
1516import { MessageIconMap } from " @/services/constants/mapping"
1617import amp from " @/services/amp"
1718
1819/** API */
19- import { fetchTxEvents } from " @/services/api/tx"
20+ import { fetchTxEvents , fetchTxMessages } from " @/services/api/tx"
2021
2122/** Store */
2223import { useModalsStore } from " @/store/modals"
@@ -54,22 +55,29 @@ const bookmarkText = computed(() => {
5455 return isBookmarked .value ? " Saved" : " Save"
5556})
5657
58+ const activeTab = ref (" messages" )
59+
5760const showAll = ref (false )
5861const handleShowAll = () => {
5962 showAll .value = ! showAll .value
6063
6164 amp .log (" toggleShowAll" )
6265}
6366
67+ const messages = ref ([])
68+
6469const events = ref ([])
6570const filteredEvents = computed (() => (showAll .value ? events .value : events .value .slice (0 , 10 )))
6671
6772const { data: rawEvents } = await fetchTxEvents (props .tx .hash )
6873events .value = rawEvents .value .sort ((a , b ) => a .position - b .position )
6974cacheStore .current .events = events .value
7075
71- onMounted (() => {
76+ onMounted (async () => {
7277 isBookmarked .value = !! bookmarksStore .bookmarks .txs .find ((t ) => t .id === props .tx .hash )
78+
79+ const data = await fetchTxMessages (props .tx .hash )
80+ messages .value = data
7381})
7482
7583const handleBookmark = () => {
@@ -123,6 +131,12 @@ const handleViewRawEvents = () => {
123131 cacheStore .current ._target = " events"
124132 modalsStore .open (" rawData" )
125133}
134+
135+ const handleViewRawEvent = (event ) => {
136+ cacheStore .current ._target = " event"
137+ cacheStore .current .event = event
138+ modalsStore .open (" rawData" )
139+ }
126140 </script >
127141
128142<template >
@@ -282,30 +296,41 @@ const handleViewRawEvents = () => {
282296 </Flex >
283297 </Flex >
284298
285- <Flex direction =" column" gap =" 16" wide :class =" $style.events_wrapper" >
286- <Text size =" 13" weight =" 600" color =" primary" > Events </Text >
287-
288- <Flex direction =" column" >
289- <Flex align =" center" gap =" 8" :class =" $style.message_types" >
290- <template v-if =" tx .message_types .length " >
291- <Icon
292- :name ="
293- MessageIconMap[tx.message_types[0].replace('Msg', '').toLowerCase()]
294- ? MessageIconMap[tx.message_types[0].replace('Msg', '').toLowerCase()]
295- : 'zap'
296- "
297- size =" 14"
298- color =" secondary"
299- />
300- <Text size =" 12" weight =" 600" color =" primary" >
301- {{ tx.message_types.map((type) => type.replace("Msg", "")).join(", ") }}
302- </Text >
303- </template >
299+ <Flex direction =" column" gap =" 4" wide :class =" $style.events_wrapper" >
300+ <Flex align =" center" justify =" between" :class =" $style.tabs_wrapper" >
301+ <Flex gap =" 4" :class =" $style.tabs" >
302+ <Flex
303+ @click =" activeTab = 'messages'"
304+ align =" center"
305+ gap =" 6"
306+ :class =" [$style.tab, activeTab === 'messages' && $style.active]"
307+ >
308+ <Icon name =" message" size =" 12" color =" secondary" />
304309
305- <Text v-else size =" 12" weight =" 600" color =" tertiary" >No Message Types</Text >
310+ <Text size =" 13" weight =" 600" >Messages</Text >
311+ </Flex >
312+
313+ <Flex
314+ @click =" activeTab = 'events'"
315+ align =" center"
316+ gap =" 6"
317+ :class =" [$style.tab, activeTab === 'events' && $style.active]"
318+ >
319+ <Icon name =" zap" size =" 12" color =" secondary" />
320+
321+ <Text size =" 13" weight =" 600" >Events</Text >
322+ </Flex >
306323 </Flex >
324+ </Flex >
307325
308- <Flex v-for =" (event, idx) in filteredEvents" align =" center" gap =" 12" :class =" $style.event" >
326+ <Flex v-if =" activeTab === 'events'" direction =" column" :class =" [$style.inner, $style.events]" >
327+ <Flex
328+ v-for =" (event, idx) in filteredEvents"
329+ @click =" handleViewRawEvent(event)"
330+ align =" center"
331+ gap =" 12"
332+ :class =" $style.event"
333+ >
309334 <Flex
310335 direction =" column"
311336 align =" center"
@@ -583,6 +608,9 @@ const handleViewRawEvents = () => {
583608 </Flex >
584609 </Flex >
585610 </Flex >
611+ <Flex v-if =" activeTab === 'messages'" :class =" $style.inner" >
612+ <MessagesTable :messages =" messages" />
613+ </Flex >
586614
587615 <Button v-if =" events.length > 10" @click =" handleShowAll" type =" secondary" size =" mini" >
588616 {{ !showAll ? "View More" : "Hide" }}
@@ -655,10 +683,61 @@ const handleViewRawEvents = () => {
655683
656684.events_wrapper {
657685 min-width : 0 ;
686+ }
687+
688+ .tabs_wrapper {
689+ min-height : 44px ;
690+ overflow-x : auto ;
691+
692+ border-radius : 4px ;
693+ background : var (--card-background );
694+
695+ padding : 0 8px ;
696+ }
697+
698+ .tabs_wrapper ::-webkit-scrollbar {
699+ display : none ;
700+ }
701+
702+ .tab {
703+ height : 28px ;
704+
705+ cursor : pointer ;
706+ border-radius : 6px ;
707+
708+ padding : 0 8px ;
709+
710+ transition : all 0.1s ease ;
711+
712+ & span {
713+ color : var (--txt-tertiary );
714+
715+ transition : all 0.1s ease ;
716+ }
717+
718+ &:hover {
719+ & span {
720+ color : var (--txt-secondary );
721+ }
722+ }
723+ }
724+
725+ .tab.active {
726+ background : var (--op-8 );
727+
728+ & span {
729+ color : var (--txt-primary );
730+ }
731+ }
732+
733+ .inner {
734+ height : 100% ;
658735
659736 border-radius : 4px 4px 8px 4px ;
660737 background : var (--card-background );
738+ }
661739
740+ .events {
662741 padding : 16px ;
663742}
664743
@@ -676,6 +755,8 @@ const handleViewRawEvents = () => {
676755.event {
677756 height : 36px ;
678757
758+ cursor : pointer ;
759+
679760 & .left {
680761 height : 100% ;
681762
@@ -753,4 +834,14 @@ const handleViewRawEvents = () => {
753834 }
754835 }
755836}
837+
838+ @media (max-width : 400px ) {
839+ .tabs_wrapper {
840+ overflow-x : auto ;
841+
842+ &::-webkit-scrollbar {
843+ display: none ;
844+ }
845+ }
846+ }
756847 </style >
0 commit comments