Skip to content

Commit

Permalink
Add basic handling for new event types
Browse files Browse the repository at this point in the history
Mostly just placeholders, in order to avoid syntax errors
with latest API wrapper code.

This is going to be flushed out later.
(Custom icons, proper data fields displayed, etc.)
  • Loading branch information
csillag committed Sep 27, 2023
1 parent de3887e commit 3ce1089
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/893.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add basic handling of new event types
10 changes: 10 additions & 0 deletions src/app/components/RuntimeTransactionLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const getRuntimeTransactionLabel = (t: TFunction, method: string | undefined) =>
return t('transactions.method.consensus.deposit')
case 'consensus.Withdraw':
return t('transactions.method.consensus.withdraw')
case 'consensus.Delegate':
return t('transactions.method.consensus.delegate')
case 'consensus.Undelegate':
return t('transactions.method.consensus.undelegate')
case 'accounts.Transfer':
return t('transactions.method.accounts.transfer')
default:
Expand All @@ -42,6 +46,10 @@ const getRuntimeTransactionIcon = (method: string | undefined) => {
return <ContractCreationIcon sx={iconStyles} />
case 'consensus.Deposit':
return <DepositIcon sx={iconStyles} />
case 'consensus.Delegate':
return <UnknownIcon sx={iconStyles} /> // TODO: use the correct icon
case 'consensus.Undelegate':
return <UnknownIcon sx={iconStyles} /> // TODO: use the correct icon
case 'consensus.Withdraw':
return <WithdrawIcon sx={iconStyles} />
case 'accounts.Transfer':
Expand All @@ -62,6 +70,8 @@ type RuntimeTransactionLabelProps = {
* - "accounts.Transfer"
* - "consensus.Deposit"
* - "consensus.Withdraw"
* - "consensus.Delegate"
* - "consensus.Undelegate"
* - "evm.Create"
* - "evm.Call"
*/
Expand Down
10 changes: 10 additions & 0 deletions src/app/components/Transactions/LogEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { COLORS } from '../../../styles/theme/colors'
import StreamIcon from '@mui/icons-material/Stream'
import LocalFireDepartmentIcon from '@mui/icons-material/LocalFireDepartment'
import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
import { UnknownIcon } from '../CustomIcons/Unknown'

export const EventTypeIcon: FC<{
eventType: RuntimeEventType
Expand All @@ -37,6 +38,9 @@ export const EventTypeIcon: FC<{
[RuntimeEventType.coregas_used]: <></>,
[RuntimeEventType.consensus_accountswithdraw]: <WithdrawIcon fontSize="inherit" />,
[RuntimeEventType.consensus_accountsdeposit]: <DepositIcon fontSize="inherit" />,
[RuntimeEventType.consensus_accountsdelegate]: <UnknownIcon fontSize="inherit" />, // TODO: use correct icon
[RuntimeEventType.consensus_accountsundelegate_start]: <UnknownIcon fontSize="inherit" />, // TODO: use correct icon
[RuntimeEventType.consensus_accountsundelegate_done]: <UnknownIcon fontSize="inherit" />, // TODO: use correct icon
[RuntimeEventType.accountsmint]: <StreamIcon fontSize="inherit" htmlColor={COLORS.eucalyptus} />,
[RuntimeEventType.accountsburn]: (
<LocalFireDepartmentIcon fontSize="inherit" htmlColor={COLORS.eucalyptus} />
Expand Down Expand Up @@ -138,6 +142,9 @@ const LogEvent: FC<{
[RuntimeEventType.coregas_used]: t('transactionEvent.gasUsed'),
[RuntimeEventType.consensus_accountswithdraw]: t('transactionEvent.consensusWithdrawal'),
[RuntimeEventType.consensus_accountsdeposit]: t('transactionEvent.consensusDeposit'),
[RuntimeEventType.consensus_accountsdelegate]: t('transactionEvent.consensusDelegate'),
[RuntimeEventType.consensus_accountsundelegate_start]: t('transactionEvent.consensusUndelegateStart'),
[RuntimeEventType.consensus_accountsundelegate_done]: t('transactionEvent.consensusUndelegateDone'),
[RuntimeEventType.accountsmint]: t('transactionEvent.accountsmint'),
[RuntimeEventType.accountsburn]: t('transactionEvent.accountsburn'),
}
Expand Down Expand Up @@ -231,6 +238,9 @@ const LogEvent: FC<{
case RuntimeEventType.accountstransfer:
case RuntimeEventType.consensus_accountsdeposit:
case RuntimeEventType.consensus_accountswithdraw:
case RuntimeEventType.consensus_accountsdelegate: // TODO show this properly
case RuntimeEventType.consensus_accountsundelegate_start: // TODO show this properly
case RuntimeEventType.consensus_accountsundelegate_done: // TODO show this properly
return (
<div>
<EventTypeIcon eventType={event.type} eventName={eventName} />
Expand Down
7 changes: 6 additions & 1 deletion src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@
},
"consensus": {
"deposit": "Consensus Deposit",
"withdraw": "Consensus Withdraw"
"withdraw": "Consensus Withdraw",
"delegate": "Consensus delegate",
"undelegate": "Consensus undelegate"
},
"evm": {
"call": "Contract Call",
Expand Down Expand Up @@ -289,6 +291,9 @@
"accountstransfer": "Transfer",
"consensusDeposit": "Deposit from consensus",
"consensusWithdrawal": "Withdrawal to consensus",
"consensusDelegate": "Delegate to consensus",
"consensusUndelegateStart": "Start to undelegate from consensus",
"consensusUndelegateDone": "Undelegate from consensus finished",
"evmLog": "EVM log message",
"gasUsed": "Gas used",
"fields": {
Expand Down

0 comments on commit 3ce1089

Please sign in to comment.