diff --git a/.changelog/1364.bugfix.md b/.changelog/1364.bugfix.md new file mode 100644 index 000000000..583ebb759 --- /dev/null +++ b/.changelog/1364.bugfix.md @@ -0,0 +1 @@ +Display EVM addresses in events diff --git a/src/app/components/Account/AccountLink.tsx b/src/app/components/Account/AccountLink.tsx index 5ae1e50ea..ddffd1e84 100644 --- a/src/app/components/Account/AccountLink.tsx +++ b/src/app/components/Account/AccountLink.tsx @@ -7,11 +7,13 @@ import { RouteUtils } from '../../utils/route-utils' import Typography from '@mui/material/Typography' import { SearchScope } from '../../../types/searchScope' -export const AccountLink: FC<{ +interface Props { scope: SearchScope address: string alwaysTrim?: boolean -}> = ({ scope, address, alwaysTrim }) => { +} + +export const AccountLink: FC = ({ scope, address, alwaysTrim }) => { const { isTablet } = useScreenSize() const to = RouteUtils.getAccountRoute(scope, address) return ( diff --git a/src/app/components/Account/AccountLinkWithAddressSwitch.tsx b/src/app/components/Account/AccountLinkWithAddressSwitch.tsx new file mode 100644 index 000000000..91c7ece86 --- /dev/null +++ b/src/app/components/Account/AccountLinkWithAddressSwitch.tsx @@ -0,0 +1,4 @@ +import { AccountLink } from './AccountLink' +import { withAddressSwitch } from './withAddressSwitch' + +export const AccountLinkWithAddressSwitch = withAddressSwitch(AccountLink) diff --git a/src/app/components/Account/withAddressSwitch.tsx b/src/app/components/Account/withAddressSwitch.tsx new file mode 100644 index 000000000..c1b29b1c6 --- /dev/null +++ b/src/app/components/Account/withAddressSwitch.tsx @@ -0,0 +1,32 @@ +import { FC } from 'react' +import { AddressSwitchOption } from '../AddressSwitch' +import { CopyToClipboard } from '../CopyToClipboard' + +interface WithAddressSwitchProps { + addressSwitchOption: AddressSwitchOption + ethAddress?: string + oasisAddress?: string +} + +interface WrappedComponentBaseProps { + address?: string +} + +export const withAddressSwitch = + (Component: FC) => + (props: Omit & WithAddressSwitchProps) => { + const { addressSwitchOption, ethAddress, oasisAddress, ...restProps } = props + + const addressesByType = { + [AddressSwitchOption.Oasis]: oasisAddress, + [AddressSwitchOption.ETH]: ethAddress, + } + const displayedAddress = addressesByType[addressSwitchOption] ?? ethAddress ?? oasisAddress + + return ( + <> + + {displayedAddress && } + + ) + } diff --git a/src/app/components/RuntimeEvents/RuntimeEventDetails.tsx b/src/app/components/RuntimeEvents/RuntimeEventDetails.tsx index 419401139..6ef733bb8 100644 --- a/src/app/components/RuntimeEvents/RuntimeEventDetails.tsx +++ b/src/app/components/RuntimeEvents/RuntimeEventDetails.tsx @@ -29,6 +29,7 @@ import { UndelegateStartIcon } from '../CustomIcons/UndelegateStart' import { UndelegateFinishIcon } from '../CustomIcons/UndelegateFinish' import { DelegateIcon } from '../CustomIcons/Delegate' import { MaybeEventErrorLine } from './EventError' +import { AccountLinkWithAddressSwitch } from '../Account/AccountLinkWithAddressSwitch' export const EventTypeIcon: FC<{ eventType: RuntimeEventType @@ -203,10 +204,12 @@ export const RuntimeEventDetails: FC<{
{t('runtimeEvent.fields.owner')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && ( - - )} +
{t('runtimeEvent.fields.amount')}
@@ -228,15 +231,21 @@ export const RuntimeEventDetails: FC<{
{t('common.from')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && ( - - )} +
{t('common.to')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && } +
{t('runtimeEvent.fields.amount')}
@@ -256,15 +265,21 @@ export const RuntimeEventDetails: FC<{
{t('common.from')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && ( - - )} +
{t('common.to')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && } +
{t('runtimeEvent.fields.amount')}
@@ -284,15 +299,21 @@ export const RuntimeEventDetails: FC<{
{t('common.from')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && ( - - )} +
{t('common.to')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && } +
{t('runtimeEvent.fields.activeShares')}
@@ -311,15 +332,21 @@ export const RuntimeEventDetails: FC<{
{t('common.from')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && ( - - )} +
{t('common.to')}
- - {addressSwitchOption === AddressSwitchOption.Oasis && } +
{t('runtimeEvent.fields.amount')}
diff --git a/src/app/components/RuntimeEvents/RuntimeEventsDetailedList.tsx b/src/app/components/RuntimeEvents/RuntimeEventsDetailedList.tsx index 705c0bff5..80535f561 100644 --- a/src/app/components/RuntimeEvents/RuntimeEventsDetailedList.tsx +++ b/src/app/components/RuntimeEvents/RuntimeEventsDetailedList.tsx @@ -3,7 +3,7 @@ import { SearchScope } from '../../../types/searchScope' import { RuntimeEvent } from '../../../oasis-nexus/api' import { AddressSwitchOption } from '../AddressSwitch' import { useTranslation } from 'react-i18next' -import { CardEmptyState } from '../../components/CardEmptyState' +import { CardEmptyState } from '../CardEmptyState' import { TextSkeleton } from '../Skeleton' import { RuntimeEventDetails } from './RuntimeEventDetails' import Divider from '@mui/material/Divider'