Skip to content

Commit f5dafca

Browse files
committed
fix: prefer message-specific events over system events in tx detail
getEventAttribute() now filters by msg_index to avoid returning fee transfer amounts instead of actual message transfer amounts.
1 parent 8e21373 commit f5dafca

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/MessageDetails.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ interface MessageDetailsProps {
8989
metadata?: MessageMetadata
9090
events?: Array<{
9191
event_type: string
92+
msg_index?: number | null
9293
attributes: Array<{ key: string; value: string }>
9394
}>
9495
}
@@ -140,9 +141,13 @@ function normalizeAmounts(amount?: CoinAmount | CoinAmount[]): CoinAmount[] {
140141
return Array.isArray(amount) ? amount : [amount]
141142
}
142143

143-
function getEventAttribute(events: Array<{ event_type: string; attributes: Array<{ key: string; value: string }> }>, eventType: string, key: string): string | null {
144-
const event = events?.find(e => e.event_type === eventType)
145-
if (!event) return null
144+
function getEventAttribute(events: Array<{ event_type: string; msg_index?: number | null; attributes: Array<{ key: string; value: string }> }>, eventType: string, key: string): string | null {
145+
const candidates = events?.filter(e => e.event_type === eventType) || []
146+
if (candidates.length === 0) return null
147+
148+
// Prefer events with explicit msg_index over system events (null msg_index)
149+
// to avoid picking up fee transfers instead of actual message transfers
150+
const event = candidates.find(e => e.msg_index != null) || candidates[0]
146151

147152
const attr = event.attributes.find(a => a.key === key)
148153
return attr?.value || null

0 commit comments

Comments
 (0)