From b7671ea7e6a0309c9d49f6e5f6b21ef97889aaf2 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Wed, 12 Jul 2023 01:02:39 +0200 Subject: [PATCH] Add icons to event names in event logs --- src/app/components/Transactions/LogEvent.tsx | 56 +++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/app/components/Transactions/LogEvent.tsx b/src/app/components/Transactions/LogEvent.tsx index 31b6a4ed9a..0fe4bb778b 100644 --- a/src/app/components/Transactions/LogEvent.tsx +++ b/src/app/components/Transactions/LogEvent.tsx @@ -16,6 +16,42 @@ import { AddressSwitchOption } from '../AddressSwitch' import { getOasisAddress } from '../../utils/helpers' import { exhaustedTypeWarning } from '../../../types/errors' import { LongDataDisplay } from '../LongDataDisplay' +import { parseEvmEvent } from '../../utils/parseEvmEvent' +import { TokenTransferIcon, TokenTransferLabel } from '../Tokens/TokenTransferIcon' +import Box from '@mui/material/Box' +import { TransferIcon } from './../CustomIcons/Transfer' +import { DepositIcon } from './../CustomIcons/Deposit' +import { WithdrawIcon } from './../CustomIcons/Withdraw' +import { COLORS } from '../../../styles/theme/colors' +import StreamIcon from '@mui/icons-material/Stream' +import LocalFireDepartmentIcon from '@mui/icons-material/LocalFireDepartment' + +const EventTypeIcon: FC<{ + event: RuntimeEvent + eventName: string +}> = ({ event, eventName }) => { + const eventTypeIcons: Record = { + [RuntimeEventType.accountstransfer]: , + [RuntimeEventType.evmlog]: <>, + [RuntimeEventType.coregas_used]: <>, + [RuntimeEventType.consensus_accountswithdraw]: , + [RuntimeEventType.consensus_accountsdeposit]: , + [RuntimeEventType.accountsmint]: , + [RuntimeEventType.accountsburn]: ( + + ), + } + + return ( + + {eventName} +   + + {eventTypeIcons[event.type]} + + + ) +} const EvmEventParamData: FC<{ scope: SearchScope @@ -112,7 +148,8 @@ const LogEvent: FC<{ {eventName}: {event.body.amount.toLocaleString()} ) - case RuntimeEventType.evmlog: + case RuntimeEventType.evmlog: { + const { parsedEvmLogName } = parseEvmEvent(event) if (!event.evm_log_name && !event.evm_log_params && event.body.data) { return (
@@ -128,10 +165,14 @@ const LogEvent: FC<{ } return (
-
+ {eventName}:   - {event.evm_log_name} -
+ + + +   + +
{event.evm_log_params && event.evm_log_params.length > 0 && ( @@ -157,13 +198,13 @@ const LogEvent: FC<{ )} ) + } case RuntimeEventType.accountsburn: case RuntimeEventType.accountsmint: return (
- {eventName} -
+
{t('transactionEvent.fields.owner')}
@@ -191,8 +232,7 @@ const LogEvent: FC<{ case RuntimeEventType.consensus_accountswithdraw: return (
- {eventName} -
+
{t('common.from')}