From c3c1d529635bb232ad75cea2677cfff266869296 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 22 Aug 2024 04:40:21 +0200 Subject: [PATCH 1/2] Refactor RuntimeTransactionMethod --- .../RuntimeTransactionMethod/index.tsx | 39 ++++++++++--------- .../Transactions/RuntimeTransactions.tsx | 2 +- .../RuntimeTransactionDetailPage/index.tsx | 2 +- src/stories/Icons.stories.tsx | 4 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/app/components/RuntimeTransactionMethod/index.tsx b/src/app/components/RuntimeTransactionMethod/index.tsx index 6d7a163bc..b8fb4eac3 100644 --- a/src/app/components/RuntimeTransactionMethod/index.tsx +++ b/src/app/components/RuntimeTransactionMethod/index.tsx @@ -10,6 +10,7 @@ import QuestionMarkIcon from '@mui/icons-material/QuestionMark' import LanIcon from '@mui/icons-material/Lan' import LanOutlinedIcon from '@mui/icons-material/LanOutlined' import { MethodIcon } from '../ConsensusTransactionMethod' +import { RuntimeTransaction } from '../../../oasis-nexus/api' const getRuntimeTransactionLabel = (t: TFunction, method: string | undefined) => { switch (method) { @@ -35,6 +36,21 @@ const getRuntimeTransactionLabel = (t: TFunction, method: string | undefined) => } } +/** + * The method call body. Defined by the runtime. + * + * May be undefined if the transaction was malformed. + * + * In theory, this could be any string as the runtimes evolve. + * In practice, the nexus currently expects only the following methods: + * - "accounts.Transfer" + * - "consensus.Deposit" + * - "consensus.Withdraw" + * - "consensus.Delegate" + * - "consensus.Undelegate" + * - "evm.Create" + * - "evm.Call" + */ const getRuntimeTransactionIcon = (method: string | undefined, label: string, truncate?: boolean) => { const props = { border: false, @@ -63,28 +79,13 @@ const getRuntimeTransactionIcon = (method: string | undefined, label: string, tr } type RuntimeTransactionLabelProps = { - /** - * The method call body. Defined by the runtime. - * - * May be undefined if the transaction was malformed. - * - * In theory, this could be any string as the runtimes evolve. - * In practice, the nexus currently expects only the following methods: - * - "accounts.Transfer" - * - "consensus.Deposit" - * - "consensus.Withdraw" - * - "consensus.Delegate" - * - "consensus.Undelegate" - * - "evm.Create" - * - "evm.Call" - */ - method?: string + transaction: RuntimeTransaction truncate?: boolean } -export const RuntimeTransactionMethod: FC = ({ method, truncate }) => { +export const RuntimeTransactionMethod: FC = ({ transaction, truncate }) => { const { t } = useTranslation() - const label = getRuntimeTransactionLabel(t, method) + const label = getRuntimeTransactionLabel(t, transaction.method) - return <>{getRuntimeTransactionIcon(method, label, truncate)} + return <>{getRuntimeTransactionIcon(transaction.method, label, truncate)} } diff --git a/src/app/components/Transactions/RuntimeTransactions.tsx b/src/app/components/Transactions/RuntimeTransactions.tsx index 7ef26f907..7c77d4895 100644 --- a/src/app/components/Transactions/RuntimeTransactions.tsx +++ b/src/app/components/Transactions/RuntimeTransactions.tsx @@ -103,7 +103,7 @@ export const RuntimeTransactions: FC = ({ ...(verbose ? [ { - content: , + content: , key: 'type', }, { diff --git a/src/app/pages/RuntimeTransactionDetailPage/index.tsx b/src/app/pages/RuntimeTransactionDetailPage/index.tsx index 0b609678e..e7fe55c32 100644 --- a/src/app/pages/RuntimeTransactionDetailPage/index.tsx +++ b/src/app/pages/RuntimeTransactionDetailPage/index.tsx @@ -183,7 +183,7 @@ export const RuntimeTransactionDetailView: FC<{
{t('common.type')}
- +
{t('transactions.encryption.format')}
diff --git a/src/stories/Icons.stories.tsx b/src/stories/Icons.stories.tsx index d15faa6e3..70d39d564 100644 --- a/src/stories/Icons.stories.tsx +++ b/src/stories/Icons.stories.tsx @@ -5,7 +5,7 @@ import { ConsensusTransactionMethod } from '../app/components/ConsensusTransacti import { RuntimeTransactionMethod } from '../app/components/RuntimeTransactionMethod' import { TokenTransferIcon } from '../app/components/Tokens/TokenTransferIcon' import { EventTypeIcon } from '../app/components/RuntimeEvents/RuntimeEventDetails' -import { ConsensusTxMethod, RuntimeEventType } from '../oasis-nexus/api' +import { ConsensusTxMethod, RuntimeEventType, RuntimeTransaction } from '../oasis-nexus/api' import { COLORS } from '../styles/theme/colors' export default { @@ -53,7 +53,7 @@ const RuntimeTemplate: StoryFn = () => { gap={4} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', paddingBottom: 4 }} > - + ({method}) ))} From f4849d5eb421c1a6d2b890134019f2a1a239ab02 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Tue, 8 Oct 2024 06:15:35 +0200 Subject: [PATCH 2/2] Display EVM function name in verified contract calls --- .changelog/1565.feature.md | 1 + src/app/components/ConsensusTransactionMethod/index.tsx | 1 - src/app/components/RuntimeTransactionMethod/index.tsx | 9 ++++++++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changelog/1565.feature.md diff --git a/.changelog/1565.feature.md b/.changelog/1565.feature.md new file mode 100644 index 000000000..5f9e8eeb3 --- /dev/null +++ b/.changelog/1565.feature.md @@ -0,0 +1 @@ +Display EVM function name in verified contract calls diff --git a/src/app/components/ConsensusTransactionMethod/index.tsx b/src/app/components/ConsensusTransactionMethod/index.tsx index 4fd20658b..75e680bd6 100644 --- a/src/app/components/ConsensusTransactionMethod/index.tsx +++ b/src/app/components/ConsensusTransactionMethod/index.tsx @@ -103,7 +103,6 @@ const MethodIconContent: FC = ({ = ({ transaction, truncate }) => { const { t } = useTranslation() - const label = getRuntimeTransactionLabel(t, transaction.method) + let label = getRuntimeTransactionLabel(t, transaction.method) + if (transaction.evm_fn_name) { + if (truncate) { + label = `${transaction.evm_fn_name}` + } else { + label += `: ${transaction.evm_fn_name}` + } + } return <>{getRuntimeTransactionIcon(transaction.method, label, truncate)} }