diff --git a/apps/explorer/src/pages/transaction-result/TransactionData.tsx b/apps/explorer/src/pages/transaction-result/TransactionData.tsx index 24eea304d00..604998be216 100644 --- a/apps/explorer/src/pages/transaction-result/TransactionData.tsx +++ b/apps/explorer/src/pages/transaction-result/TransactionData.tsx @@ -7,8 +7,6 @@ import { type ProgrammableTransaction, type IotaTransactionBlockResponse, } from '@iota/iota-sdk/client'; - -import { TransactionDetailCard } from './transaction-summary/TransactionDetailCard'; import { GasBreakdown } from '~/components'; import { useRecognizedPackages } from '~/hooks/useRecognizedPackages'; import { InputsCard } from '~/pages/transaction-result/programmable-transaction-view/InputsCard'; @@ -32,15 +30,8 @@ export function TransactionData({ transaction }: TransactionDataProps): JSX.Elem const programmableTxn = transaction.transaction!.data.transaction as ProgrammableTransaction; return ( -
-
- - +
+
{isProgrammableTransaction && (
@@ -49,7 +40,7 @@ export function TransactionData({ transaction }: TransactionDataProps): JSX.Elem
{isProgrammableTransaction && ( -
+
diff --git a/apps/explorer/src/pages/transaction-result/TransactionView.tsx b/apps/explorer/src/pages/transaction-result/TransactionView.tsx index 966a9e53e8e..2b65378e7e2 100644 --- a/apps/explorer/src/pages/transaction-result/TransactionView.tsx +++ b/apps/explorer/src/pages/transaction-result/TransactionView.tsx @@ -16,6 +16,9 @@ import { Signatures } from './Signatures'; import { LocalStorageSplitPaneKey } from '~/lib/enums'; import styles from './TransactionResult.module.css'; +import { TransactionDetails } from './transaction-summary/TransactionDetails'; +import { useTransactionSummary } from '@iota/core'; +import { useRecognizedPackages } from '~/hooks'; interface TabsContentContainerProps { value: string; @@ -91,10 +94,22 @@ export function TransactionView({ transaction }: TransactionViewProps): JSX.Elem minSize: 40, defaultSize: isProgrammableTransaction ? 65 : 50, }; - + const recognizedPackagesList = useRecognizedPackages(); + const summary = useTransactionSummary({ + transaction, + recognizedPackagesList, + }); return (
-
+
+
+ +
- - {label} - - - {value} - -
- ); -} - -interface TransactionDetailsProps { - sender?: string; - checkpoint?: string | null; - executedEpoch?: string; - timestamp?: string | null; -} - -export function TransactionDetailCard({ - sender, - checkpoint, - executedEpoch, - timestamp, -}: TransactionDetailsProps): JSX.Element { - const md = useBreakpoint('md'); - const { data: domainName } = useResolveIotaNSName(sender); - - return ( - - -
- {timestamp && ( - - {formatDate(Number(timestamp))} - - )} -
- {sender && ( - } - /> - )} - {checkpoint && ( - - } - /> - )} - {executedEpoch && ( - } - /> - )} -
-
-
-
- ); -} diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetails.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetails.tsx new file mode 100644 index 00000000000..a90d9f1cd3c --- /dev/null +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetails.tsx @@ -0,0 +1,51 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { DisplayStats } from '@iota/apps-ui-kit'; +import { formatDate, useResolveIotaNSName } from '@iota/core'; + +interface TransactionDetailsProps { + sender?: string; + checkpoint?: string | null; + executedEpoch?: string; + timestamp?: string | null; +} + +export function TransactionDetails({ + sender, + checkpoint, + executedEpoch, + timestamp, +}: TransactionDetailsProps): JSX.Element { + const { data: domainName } = useResolveIotaNSName(sender); + + return ( +
+ {sender && ( + + )} + {checkpoint && ( + + )} + {executedEpoch && ( + + )} + + {timestamp && } +
+ ); +} diff --git a/apps/ui-kit/src/lib/components/molecules/display-stats/DisplayStats.tsx b/apps/ui-kit/src/lib/components/molecules/display-stats/DisplayStats.tsx index 8293aa9a0dd..a33f350c637 100644 --- a/apps/ui-kit/src/lib/components/molecules/display-stats/DisplayStats.tsx +++ b/apps/ui-kit/src/lib/components/molecules/display-stats/DisplayStats.tsx @@ -56,6 +56,10 @@ interface DisplayStatsProps { * The value link is external. */ isExternalLink?: boolean; + /** + * The value is truncated + */ + isTruncated?: boolean; } export function DisplayStats({ @@ -69,6 +73,7 @@ export function DisplayStats({ icon, valueLink, isExternalLink = false, + isTruncated = false, }: DisplayStatsProps): React.JSX.Element { const backgroundClass = BACKGROUND_CLASSES[type]; const sizeClass = SIZE_CLASSES[size]; @@ -76,6 +81,11 @@ export function DisplayStats({ const valueTextClass = VALUE_TEXT_CLASSES[size]; const labelTextClass = LABEL_TEXT_CLASSES[size]; const supportingLabelTextClass = SUPPORTING_LABEL_TEXT_CLASSES[size]; + function truncate(value: string, startLength: number, endLength: number): string { + return value.length > startLength + endLength && isTruncated + ? `${value.slice(0, startLength)}...${value.slice(-endLength)}` + : value; + } return (
{icon && {icon}}
-
+
{valueLink ? ( - {value} + {truncate(value, 6, 6)} ) : ( <> - {value} + {truncate(value, 6, 6)} {supportingLabel && ( {supportingLabel} diff --git a/apps/ui-kit/src/storybook/stories/molecules/DisplayStats.stories.tsx b/apps/ui-kit/src/storybook/stories/molecules/DisplayStats.stories.tsx index 690c9c7a2cc..18a1c6a2c9b 100644 --- a/apps/ui-kit/src/storybook/stories/molecules/DisplayStats.stories.tsx +++ b/apps/ui-kit/src/storybook/stories/molecules/DisplayStats.stories.tsx @@ -66,5 +66,8 @@ export const Default: Story = { isExternalLink: { control: 'boolean', }, + isTruncated: { + control: 'boolean', + }, }, };