Skip to content

Commit 245b628

Browse files
lukaw3dlukaw3d
authored andcommitted
Format token IDs in ERC721 events
ERC721 mint 0xc6a0b7f768153623819582a51ab629e97a1c2ff66a35e573fb4e708ff8293b5a
1 parent 55128f5 commit 245b628

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.changelog/1845.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Format token amounts in events

src/app/components/RuntimeEvents/RuntimeEventDetails.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EvmAbiParam, RuntimeEvent, RuntimeEventType } from '../../../oasis-nexus/api'
22
import { FC } from 'react'
33
import { TFunction } from 'i18next'
4-
import { useTranslation } from 'react-i18next'
4+
import { Trans, useTranslation } from 'react-i18next'
55
import { StyledDescriptionList } from '../StyledDescriptionList'
66
import { useScreenSize } from '../../hooks/useScreensize'
77
import Table from '@mui/material/Table'
@@ -33,6 +33,7 @@ import { MethodIcon } from '../ConsensusTransactionMethod'
3333
import { TransactionLink } from '../Transactions/TransactionLink'
3434
import Tooltip from '@mui/material/Tooltip'
3535
import { tooltipDelay } from '../../../styles/theme'
36+
import { PlaceholderLabel } from '../../utils/PlaceholderLabel'
3637

3738
const getRuntimeEventMethodLabel = (t: TFunction, method: string | undefined) => {
3839
switch (method) {
@@ -134,7 +135,7 @@ const EvmEventParamData: FC<{
134135
<AccountLink address={address} scope={scope} alwaysTrimOnTablet={alwaysTrimOnTable} />
135136
) : null
136137
case 'uint256':
137-
if (param.evm_token) {
138+
if (param.evm_token?.type === 'ERC20') {
138139
return (
139140
<Tooltip
140141
arrow
@@ -152,6 +153,18 @@ const EvmEventParamData: FC<{
152153
</Tooltip>
153154
)
154155
}
156+
if (param.evm_token?.type === 'ERC721') {
157+
return (
158+
<Trans
159+
t={t}
160+
i18nKey="common.tokenInstance"
161+
components={{
162+
InstanceLink: <PlaceholderLabel label={param.value as string} />,
163+
TickerLink: <PlaceholderLabel label={param.evm_token.symbol ?? t('common.missing')} />,
164+
}}
165+
/>
166+
)
167+
}
155168
return (
156169
<span>
157170
{t('common.valueLong', {

src/oasis-nexus/api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,14 @@ const addTokenToParams = (event: generated.RuntimeEvent) => {
910910
}
911911
}
912912
}
913+
if (event.evm_token?.type === 'ERC721') {
914+
if (event.evm_log_name === 'Transfer' || event.evm_log_name === 'Approval') {
915+
const tokenParam = event.evm_log_params?.[2]
916+
if (tokenParam?.evm_type === 'uint256' && typeof tokenParam.value === 'string') {
917+
tokenParam.evm_token = event.evm_token
918+
}
919+
}
920+
}
913921
return event
914922
}
915923

0 commit comments

Comments
 (0)