@@ -9,14 +9,15 @@ import Button from "~/components/ui/Button.vue"
9
9
10
10
/** Shared Components */
11
11
import MessageTypeBadge from " @/components/shared/MessageTypeBadge.vue"
12
+ import MessagesTable from " @/components/modules/tx/MessagesTable.vue"
12
13
13
14
/** Services */
14
15
import { comma , tia , splitAddress } from " @/services/utils"
15
16
import { MessageIconMap } from " @/services/constants/mapping"
16
17
import amp from " @/services/amp"
17
18
18
19
/** API */
19
- import { fetchTxEvents } from " @/services/api/tx"
20
+ import { fetchTxEvents , fetchTxMessages } from " @/services/api/tx"
20
21
21
22
/** Store */
22
23
import { useModalsStore } from " @/store/modals"
@@ -54,22 +55,29 @@ const bookmarkText = computed(() => {
54
55
return isBookmarked .value ? " Saved" : " Save"
55
56
})
56
57
58
+ const activeTab = ref (" messages" )
59
+
57
60
const showAll = ref (false )
58
61
const handleShowAll = () => {
59
62
showAll .value = ! showAll .value
60
63
61
64
amp .log (" toggleShowAll" )
62
65
}
63
66
67
+ const messages = ref ([])
68
+
64
69
const events = ref ([])
65
70
const filteredEvents = computed (() => (showAll .value ? events .value : events .value .slice (0 , 10 )))
66
71
67
72
const { data: rawEvents } = await fetchTxEvents (props .tx .hash )
68
73
events .value = rawEvents .value .sort ((a , b ) => a .position - b .position )
69
74
cacheStore .current .events = events .value
70
75
71
- onMounted (() => {
76
+ onMounted (async () => {
72
77
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
73
81
})
74
82
75
83
const handleBookmark = () => {
@@ -123,6 +131,12 @@ const handleViewRawEvents = () => {
123
131
cacheStore .current ._target = " events"
124
132
modalsStore .open (" rawData" )
125
133
}
134
+
135
+ const handleViewRawEvent = (event ) => {
136
+ cacheStore .current ._target = " event"
137
+ cacheStore .current .event = event
138
+ modalsStore .open (" rawData" )
139
+ }
126
140
</script >
127
141
128
142
<template >
@@ -282,30 +296,41 @@ const handleViewRawEvents = () => {
282
296
</Flex >
283
297
</Flex >
284
298
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" />
304
309
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 >
306
323
</Flex >
324
+ </Flex >
307
325
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
+ >
309
334
<Flex
310
335
direction =" column"
311
336
align =" center"
@@ -583,6 +608,9 @@ const handleViewRawEvents = () => {
583
608
</Flex >
584
609
</Flex >
585
610
</Flex >
611
+ <Flex v-if =" activeTab === 'messages'" :class =" $style.inner" >
612
+ <MessagesTable :messages =" messages" />
613
+ </Flex >
586
614
587
615
<Button v-if =" events.length > 10" @click =" handleShowAll" type =" secondary" size =" mini" >
588
616
{{ !showAll ? "View More" : "Hide" }}
@@ -655,10 +683,61 @@ const handleViewRawEvents = () => {
655
683
656
684
.events_wrapper {
657
685
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% ;
658
735
659
736
border-radius : 4px 4px 8px 4px ;
660
737
background : var (--card-background );
738
+ }
661
739
740
+ .events {
662
741
padding : 16px ;
663
742
}
664
743
@@ -676,6 +755,8 @@ const handleViewRawEvents = () => {
676
755
.event {
677
756
height : 36px ;
678
757
758
+ cursor : pointer ;
759
+
679
760
& .left {
680
761
height : 100% ;
681
762
@@ -753,4 +834,14 @@ const handleViewRawEvents = () => {
753
834
}
754
835
}
755
836
}
837
+
838
+ @media (max-width : 400px ) {
839
+ .tabs_wrapper {
840
+ overflow-x : auto ;
841
+
842
+ &::-webkit-scrollbar {
843
+ display: none ;
844
+ }
845
+ }
846
+ }
756
847
</style >
0 commit comments