From 4cd4876ac31f3b3264f843fd111bcddd112d2b0f Mon Sep 17 00:00:00 2001
From: Bran <52735957+brancoder@users.noreply.github.com>
Date: Fri, 13 Sep 2024 16:56:16 +0200
Subject: [PATCH] feat(wallet): rebrand tx details page (#2350)
* feat: rework Validator Logo
* fix: update stake amount and key value info on stak tx card
* feat: rework TxnAmount component
* feat: rework GasSummary and add StakeTxnInfo panel
* fix: remove unused components
* feat: adjust stlying of stakeTxCard
* fix: styling of the unstake transaction
* fix: rename receipt components
* fix: add panel to unstakeTx component
* feat: update transaction status component
* fix: rebrand Balance Changes component
* fix: rebrand Object Changes component
* fix: resolve comments
* fix: add full width to stake/unstake panel
* fix: rebrand ObjectChangeDisplay component
* fix: Delegation Details styling
* fix: revert number hash in Epoch string
* fix: remove stale comment
* fix: typo
* fix: rebrand gas fees component
* fix: add missing keys to the for loops in templates
* fix: rework gas component
* fix: show gas only if sent transaction recepit
* fix: rebrand show more/less button in expandable list
* fix: remove unused components
* fix: undefined timestamp
* fix: extract elxporer link card to const
* fix: styling and add InfoBox component
* fix: remove unused imports
---
.../components/receipt-card/StatusIcon.tsx | 33 --
.../ui/app/components/receipt-card/index.tsx | 58 ++--
.../components/transactions-card/TxnImage.tsx | 43 ---
.../transaction-request/GasFees.tsx | 84 +++--
.../transaction-request/index.tsx | 9 +-
.../src/ui/app/shared/ExpandableList.tsx | 37 +-
.../src/ui/app/shared/collapse/index.tsx | 2 -
.../src/ui/app/shared/date-card/index.tsx | 25 --
.../app/shared/transaction-summary/Card.tsx | 60 ----
.../transaction-summary/OwnerFooter.tsx | 39 ---
.../cards/BalanceChanges.tsx | 115 +++----
.../transaction-summary/cards/CoinStack.tsx | 30 --
.../transaction-summary/cards/GasSummary.tsx | 21 +-
.../cards/ObjectChanges.tsx | 317 +++++++++---------
.../transaction-summary/cards/SummaryCard.tsx | 51 ---
.../transaction-summary/cards/TotalAmount.tsx | 35 --
.../objectSummary/ObjectChangeDisplay.tsx | 42 +--
.../app/shared/transaction-summary/index.tsx | 41 +--
18 files changed, 356 insertions(+), 686 deletions(-)
delete mode 100644 apps/wallet/src/ui/app/components/receipt-card/StatusIcon.tsx
delete mode 100644 apps/wallet/src/ui/app/components/transactions-card/TxnImage.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/date-card/index.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/Card.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/OwnerFooter.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/cards/CoinStack.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/cards/SummaryCard.tsx
delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/cards/TotalAmount.tsx
diff --git a/apps/wallet/src/ui/app/components/receipt-card/StatusIcon.tsx b/apps/wallet/src/ui/app/components/receipt-card/StatusIcon.tsx
deleted file mode 100644
index 2dde1c6a873..00000000000
--- a/apps/wallet/src/ui/app/components/receipt-card/StatusIcon.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { ThumbUpFill32 } from '@iota/icons';
-import cl from 'clsx';
-
-interface StatusIconProps {
- status: boolean;
-}
-
-export function StatusIcon({ status }: StatusIconProps) {
- return (
-
- );
-}
diff --git a/apps/wallet/src/ui/app/components/receipt-card/index.tsx b/apps/wallet/src/ui/app/components/receipt-card/index.tsx
index 88ddd1b34ef..10401f5e340 100644
--- a/apps/wallet/src/ui/app/components/receipt-card/index.tsx
+++ b/apps/wallet/src/ui/app/components/receipt-card/index.tsx
@@ -3,15 +3,22 @@
// SPDX-License-Identifier: Apache-2.0
import { useRecognizedPackages } from '_src/ui/app/hooks/useRecognizedPackages';
-import { useTransactionSummary, STAKING_REQUEST_EVENT, UNSTAKING_REQUEST_EVENT } from '@iota/core';
+import {
+ useTransactionSummary,
+ STAKING_REQUEST_EVENT,
+ UNSTAKING_REQUEST_EVENT,
+ formatDate,
+} from '@iota/core';
import { type IotaTransactionBlockResponse } from '@iota/iota-sdk/client';
-import { DateCard } from '../../shared/date-card';
import { TransactionSummary } from '../../shared/transaction-summary';
import { StakeTxn } from './StakeTxn';
-import { StatusIcon } from './StatusIcon';
import { UnStakeTxn } from './UnstakeTxn';
+import { InfoBox, InfoBoxStyle, InfoBoxType } from '@iota/apps-ui-kit';
+import { CheckmarkFilled } from '@iota/ui-icons';
+import cl from 'clsx';
import { ExplorerLinkCard } from '../../shared/transaction-summary/cards/ExplorerLink';
+import { GasFees } from '../../pages/approval-request/transaction-request/GasFees';
interface TransactionStatusProps {
success: boolean;
@@ -19,14 +26,19 @@ interface TransactionStatusProps {
}
function TransactionStatus({ success, timestamp }: TransactionStatusProps) {
+ const txnDate = timestamp ? formatDate(Number(timestamp)) : '';
return (
-
-
-
- {success ? 'Transaction Success' : 'Transaction Failed'}
-
- {timestamp && }
-
+
+ }
+ >
);
}
@@ -43,6 +55,7 @@ export function ReceiptCard({ txn, activeAddress }: ReceiptCardProps) {
currentAddress: activeAddress,
recognizedPackagesList,
});
+ const isSender = txn.transaction?.data.sender === activeAddress;
if (!summary) return null;
@@ -50,26 +63,31 @@ export function ReceiptCard({ txn, activeAddress }: ReceiptCardProps) {
const unstakeTxn = events?.find(({ type }) => type === UNSTAKING_REQUEST_EVENT);
+ const renderExplorerLinkCard = () => (
+
+ );
+
// todo: re-using the existing staking cards for now
if (stakedTxn || unstakeTxn)
return (
{stakedTxn ? : null}
{unstakeTxn ? : null}
-
+ {renderExplorerLinkCard()}
);
return (
-
-
-
+
+
+
+
+ {isSender && }
+
+
{renderExplorerLinkCard()}
);
}
diff --git a/apps/wallet/src/ui/app/components/transactions-card/TxnImage.tsx b/apps/wallet/src/ui/app/components/transactions-card/TxnImage.tsx
deleted file mode 100644
index eb33c3daa5a..00000000000
--- a/apps/wallet/src/ui/app/components/transactions-card/TxnImage.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { useGetNFTMeta } from '@iota/core';
-import { Text } from '_app/shared/text';
-import { NftImage } from '_components';
-import { cx } from 'class-variance-authority';
-
-interface TxnImageProps {
- id: string;
- actionLabel?: string;
-}
-
-//TODO merge all NFT image displays
-export function TxnImage({ id, actionLabel }: TxnImageProps) {
- const { data: nftMeta } = useGetNFTMeta(id);
-
- return nftMeta?.imageUrl ? (
-
- {actionLabel ? (
-
- {actionLabel}
-
- ) : null}
-
-
-
- {nftMeta.name && (
-
- {nftMeta.name}
-
- )}
- {nftMeta.description && (
-
- {nftMeta.description}
-
- )}
-
-
-
- ) : null;
-}
diff --git a/apps/wallet/src/ui/app/pages/approval-request/transaction-request/GasFees.tsx b/apps/wallet/src/ui/app/pages/approval-request/transaction-request/GasFees.tsx
index e8d61a7a23c..2460016d0fb 100644
--- a/apps/wallet/src/ui/app/pages/approval-request/transaction-request/GasFees.tsx
+++ b/apps/wallet/src/ui/app/pages/approval-request/transaction-request/GasFees.tsx
@@ -2,56 +2,52 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-import { useTransactionData, useTransactionGasBudget } from '_src/ui/app/hooks';
-import { GAS_SYMBOL } from '_src/ui/app/redux/slices/iota-objects/Coin';
-import { type TransactionBlock } from '@iota/iota-sdk/transactions';
-import { formatAddress } from '@iota/iota-sdk/utils';
-
-import { DescriptionItem, DescriptionList } from './DescriptionList';
-import { SummaryCard } from './SummaryCard';
+import { TitleSize, Badge, BadgeType, Title, Panel } from '@iota/apps-ui-kit';
+import { Collapsible } from '_src/ui/app/shared/collapse';
+import { GasSummary } from '_src/ui/app/shared/transaction-summary/cards/GasSummary';
+import { type GasSummaryType } from '@iota/core';
interface GasFeesProps {
sender?: string;
- transaction: TransactionBlock;
+ gasSummary?: GasSummaryType;
+ isEstimate?: boolean;
+ isPending?: boolean;
+ isError?: boolean;
}
+const DEFAULT_TITLE = 'Gas Fees';
-export function GasFees({ sender, transaction }: GasFeesProps) {
- const { data: transactionData } = useTransactionData(sender, transaction);
- const { data: gasBudget, isPending, isError } = useTransactionGasBudget(sender, transaction);
- const isSponsored =
- transactionData?.gasConfig.owner &&
- transactionData.sender !== transactionData.gasConfig.owner;
+export function GasFees({ sender, gasSummary, isEstimate, isPending, isError }: GasFeesProps) {
+ const title = isEstimate ? `Est. ${DEFAULT_TITLE}` : DEFAULT_TITLE;
+ const trailingElement =
+ gasSummary?.isSponsored && gasSummary.owner ? (
+
+
+
+ ) : null;
return (
-
- Sponsored
+
+
+
(
+
+ )}
+ >
+
+
- ) : null
- }
- initialExpanded
- >
-
-
- {isPending
- ? 'Estimating...'
- : isError
- ? 'Gas estimation failed'
- : `${isSponsored ? 0 : gasBudget} ${GAS_SYMBOL}`}
-
- {isSponsored && (
- <>
-
- {gasBudget ? `${gasBudget} ${GAS_SYMBOL}` : '-'}
-
-
- {formatAddress(transactionData!.gasConfig.owner!)}
-
- >
- )}
-
-
+
+
+
);
}
diff --git a/apps/wallet/src/ui/app/pages/approval-request/transaction-request/index.tsx b/apps/wallet/src/ui/app/pages/approval-request/transaction-request/index.tsx
index 4c4645f8591..a430c6fd180 100644
--- a/apps/wallet/src/ui/app/pages/approval-request/transaction-request/index.tsx
+++ b/apps/wallet/src/ui/app/pages/approval-request/transaction-request/index.tsx
@@ -100,13 +100,18 @@ export function TransactionRequest({ txRequest }: TransactionRequestProps) {
isDryRun
isLoading={isDryRunLoading}
isError={isDryRunError}
- showGasSummary={false}
summary={summary}
/>
-
+
{item}
))}
{items.length > defaultItemsToShow && (
-
-
+
)}
>
diff --git a/apps/wallet/src/ui/app/shared/collapse/index.tsx b/apps/wallet/src/ui/app/shared/collapse/index.tsx
index 40bf27ba342..c44607bc686 100644
--- a/apps/wallet/src/ui/app/shared/collapse/index.tsx
+++ b/apps/wallet/src/ui/app/shared/collapse/index.tsx
@@ -9,7 +9,6 @@ interface CollapsibleProps {
title?: string;
defaultOpen?: boolean;
children: ReactNode | ReactNode[];
- shade?: 'lighter' | 'darker';
isOpen?: boolean;
onOpenChange?: (isOpen: boolean) => void;
titleSize?: TitleSize;
@@ -24,7 +23,6 @@ export function Collapsible({
defaultOpen,
isOpen,
onOpenChange,
- shade = 'lighter',
titleSize = TitleSize.Small,
render,
hideArrow,
diff --git a/apps/wallet/src/ui/app/shared/date-card/index.tsx b/apps/wallet/src/ui/app/shared/date-card/index.tsx
deleted file mode 100644
index 36530d589d2..00000000000
--- a/apps/wallet/src/ui/app/shared/date-card/index.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { Text } from '_app/shared/text';
-import { formatDate } from '_helpers';
-
-interface DateCardProps {
- timestamp: number;
- size: 'sm' | 'md';
-}
-
-export function DateCard({ timestamp, size }: DateCardProps) {
- const txnDate = formatDate(timestamp, ['month', 'day', 'hour', 'minute']);
-
- return (
-
- {txnDate}
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/Card.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/Card.tsx
deleted file mode 100644
index ce9b6e3ba5e..00000000000
--- a/apps/wallet/src/ui/app/shared/transaction-summary/Card.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-import { Heading } from '_src/ui/app/shared/heading';
-import { cva, type VariantProps } from 'class-variance-authority';
-import { type AnchorHTMLAttributes, type ElementType, type ReactNode } from 'react';
-
-const cardStyles = cva(
- ['bg-white relative flex flex-col p-4.5 w-full shadow-card-soft rounded-2xl'],
- {
- variants: {
- as: {
- div: '',
- a: 'no-underline text-hero-dark hover:text-hero visited:text-hero-dark',
- },
- },
- },
-);
-
-interface CardProps extends VariantProps {
- heading?: string;
- after?: ReactNode;
- children: ReactNode;
- footer?: ReactNode;
-}
-
-type ExtendedCardProps = CardProps & AnchorHTMLAttributes;
-
-export function SummaryCardFooter({ children }: { children: ReactNode }) {
- return (
-
- {children}
-
- );
-}
-
-export function Card({
- as = 'div',
- heading,
- children,
- after,
- footer = null,
- ...props
-}: ExtendedCardProps) {
- const Component = as as ElementType;
- return (
-
- {heading && (
-
-
- {heading}
-
- {after &&
{after}
}
-
- )}
- {children}
- {footer}
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/OwnerFooter.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/OwnerFooter.tsx
deleted file mode 100644
index 29169f50e95..00000000000
--- a/apps/wallet/src/ui/app/shared/transaction-summary/OwnerFooter.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { ExplorerLink, ExplorerLinkType } from '_components';
-import { useActiveAddress } from '_src/ui/app/hooks';
-import { getOwnerDisplay } from '@iota/core';
-
-import { Text } from '../text';
-import { SummaryCardFooter } from './Card';
-
-export function OwnerFooter({ owner, ownerType }: { owner?: string; ownerType?: string }) {
- const address = useActiveAddress();
- const { ownerDisplay, isOwner } = getOwnerDisplay(owner, ownerType, address);
-
- return (
-
-
- Owner
-
-
- {isOwner ? (
-
- {ownerDisplay}
-
- ) : (
-
- {ownerDisplay}
-
- )}
-
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/BalanceChanges.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/BalanceChanges.tsx
index 980264dd8fb..e6858f10121 100644
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/BalanceChanges.tsx
+++ b/apps/wallet/src/ui/app/shared/transaction-summary/cards/BalanceChanges.tsx
@@ -1,21 +1,17 @@
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-import { Alert, CoinIcon } from '_components';
-import { Text } from '_src/ui/app/shared/text';
+
import {
- CoinFormat,
getRecognizedUnRecognizedTokenChanges,
- useCoinMetadata,
- useFormatCoin,
type BalanceChange,
type BalanceChangeSummary,
} from '@iota/core';
-import classNames from 'clsx';
import { useMemo } from 'react';
-import { Card } from '../Card';
-import { OwnerFooter } from '../OwnerFooter';
+import { Badge, BadgeType, Divider, Header, KeyValueInfo, Panel } from '@iota/apps-ui-kit';
+import { useAddressLink } from '_src/ui/app/hooks/useAddressLink';
+import { CoinItem } from '_src/ui/app/components';
interface BalanceChangesProps {
changes?: BalanceChangeSummary;
@@ -23,41 +19,16 @@ interface BalanceChangesProps {
function BalanceChangeEntry({ change }: { change: BalanceChange }) {
const { amount, coinType, unRecognizedToken } = change;
- const isPositive = BigInt(amount) > 0n;
- const [formatted, symbol] = useFormatCoin(amount, coinType, CoinFormat.FULL);
- const { data: coinMetaData } = useCoinMetadata(coinType);
return (
-
-
-
-
-
-
-
-
- {coinMetaData?.name || symbol}
-
- {unRecognizedToken && (
-
-
- Unrecognized
-
-
- )}
-
-
-
-
- {isPositive ? '+' : ''}
- {formatted} {symbol}
-
-
-
-
+
+ ) : undefined
+ }
+ />
);
}
@@ -68,39 +39,47 @@ function BalanceChangeEntries({ changes }: { changes: BalanceChange[] }) {
);
return (
-
-
- {recognizedTokenChanges.map((change) => (
-
- ))}
- {unRecognizedTokenChanges.length > 0 && (
-
- {unRecognizedTokenChanges.map((change, index) => (
-
- ))}
-
- )}
-
-
+ <>
+ {recognizedTokenChanges.map((change) => (
+
+ ))}
+ {unRecognizedTokenChanges.length > 0 && (
+ <>
+ {unRecognizedTokenChanges.map((change, index) => (
+
+ ))}
+ >
+ )}
+ >
);
}
export function BalanceChanges({ changes }: BalanceChangesProps) {
if (!changes) return null;
+
return (
<>
- {Object.entries(changes).map(([owner, changes]) => (
- }>
-
-
-
-
- ))}
+ {Object.entries(changes).map(([owner, changes]) => {
+ const ownerAddress = useAddressLink(owner);
+
+ return (
+
+
+
+ );
+ })}
>
);
}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/CoinStack.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/CoinStack.tsx
deleted file mode 100644
index 39937a31606..00000000000
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/CoinStack.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { CoinIcon } from '_components';
-
-import { Text } from '../../text';
-
-export interface CoinsStackProps {
- coinTypes: string[];
-}
-
-const MAX_COINS_TO_DISPLAY = 4;
-
-export function CoinsStack({ coinTypes }: CoinsStackProps) {
- return (
-
- {coinTypes.length > MAX_COINS_TO_DISPLAY && (
-
- +{coinTypes.length - MAX_COINS_TO_DISPLAY}
-
- )}
- {coinTypes.slice(0, MAX_COINS_TO_DISPLAY).map((coinType, i) => (
-
-
-
- ))}
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/GasSummary.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/GasSummary.tsx
index 13941c5b185..7d4022ed3c7 100644
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/GasSummary.tsx
+++ b/apps/wallet/src/ui/app/shared/transaction-summary/cards/GasSummary.tsx
@@ -2,22 +2,32 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-import { useActiveAddress } from '_src/ui/app/hooks';
import { useFormatCoin, type GasSummaryType } from '@iota/core';
import { formatAddress, IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { KeyValueInfo } from '@iota/apps-ui-kit';
import { useAddressLink } from '_src/ui/app/hooks/useAddressLink';
+import { useActiveAddress } from '_src/ui/app/hooks';
interface GasSummaryProps {
+ sender?: string | null;
gasSummary?: GasSummaryType;
+ isPending?: boolean;
+ isError?: boolean;
}
-export function GasSummary({ gasSummary }: GasSummaryProps) {
+export function GasSummary({ sender, gasSummary, isPending, isError }: GasSummaryProps) {
+ const activeAddress = useActiveAddress();
+ const address = sender || activeAddress;
const [gas, symbol] = useFormatCoin(gasSummary?.totalGas, IOTA_TYPE_ARG);
- const address = useActiveAddress();
const gasOwnerLink = useAddressLink(gasSummary?.owner || null);
+ const gasValueText = isPending
+ ? 'Estimating...'
+ : isError
+ ? 'Gas estimation failed'
+ : `${gasSummary?.isSponsored ? 0 : gas}`;
+
if (!gasSummary)
return ;
@@ -26,8 +36,9 @@ export function GasSummary({ gasSummary }: GasSummaryProps) {
{address === gasSummary?.owner && (
)}
{gasSummary?.isSponsored && gasSummary.owner && (
@@ -36,11 +47,13 @@ export function GasSummary({ gasSummary }: GasSummaryProps) {
keyText="Sponsored fee"
valueText={gas}
supportingLabel={symbol}
+ fullwidth
/>
>
)}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/ObjectChanges.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/ObjectChanges.tsx
index cd922bf76c6..9457ba4a6be 100644
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/ObjectChanges.tsx
+++ b/apps/wallet/src/ui/app/shared/transaction-summary/cards/ObjectChanges.tsx
@@ -1,9 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-import { ExplorerLink, ExplorerLinkType } from '_components';
-import { Text } from '_src/ui/app/shared/text';
-import { Disclosure } from '@headlessui/react';
+import { ExplorerLinkType } from '_components';
import {
getObjectChangeLabel,
type ObjectChangesByOwner,
@@ -11,26 +9,26 @@ import {
type IotaObjectChangeTypes,
type IotaObjectChangeWithDisplay,
} from '@iota/core';
-import { ChevronDown12, ChevronRight12 } from '@iota/icons';
import { formatAddress } from '@iota/iota-sdk/utils';
import cx from 'clsx';
import { ExpandableList } from '../../ExpandableList';
-import { Card } from '../Card';
-import { OwnerFooter } from '../OwnerFooter';
import { ObjectChangeDisplay } from './objectSummary/ObjectChangeDisplay';
-
-interface ChevronDownProps {
- expanded: boolean;
-}
-
-function ChevronDown({ expanded }: ChevronDownProps) {
- return expanded ? (
-
- ) : (
-
- );
-}
+import { Collapsible } from '../../collapse';
+import {
+ Badge,
+ BadgeType,
+ Divider,
+ KeyValueInfo,
+ Panel,
+ Title,
+ TitleSize,
+} from '@iota/apps-ui-kit';
+import { useAddressLink } from '_src/ui/app/hooks/useAddressLink';
+import { useState } from 'react';
+import { useExplorerLink } from '_src/ui/app/hooks/useExplorerLink';
+import { Link } from 'react-router-dom';
+import { TriangleDown } from '@iota/ui-icons';
interface ObjectDetailProps {
change: IotaObjectChangeWithDisplay;
@@ -42,95 +40,80 @@ export function ObjectDetail({ change, display }: ObjectDetailProps) {
if (change.type === 'transferred' || change.type === 'published') {
return null;
}
+ const [open, setOpen] = useState(false);
+
+ const objectLink = useExplorerLink({
+ type: ExplorerLinkType.Object,
+ objectID: change.objectId || '',
+ });
const [packageId, moduleName, typeName] = change.objectType?.split('<')[0]?.split('::') || [];
+ const packageIdLink = useExplorerLink({
+ type: ExplorerLinkType.Object,
+ objectID: packageId || '',
+ });
+ const moduleLink = useExplorerLink({
+ type: ExplorerLinkType.Object,
+ objectID: packageId || '',
+ moduleName,
+ });
return (
-
- {({ open }) => (
-
-
-
-
- Object
-
- {open ? (
-
- ) : (
-
- )}
-
- {change.objectId && (
-
-
-
- {formatAddress(change.objectId)}
-
-
-
- )}
+
setOpen(isOpen)}
+ hideArrow
+ render={() => (
+
+
+ }
+ />
+
+
+
+ {formatAddress(change.objectId)}
+
-
-
-
-
- Package
-
-
-
-
- {packageId}
-
-
-
-
-
-
- Module
-
-
-
-
- {moduleName}
-
-
-
-
-
-
- Type
-
-
-
-
- {typeName}
-
-
-
-
-
-
)}
-
+ >
+
+
+
+
+
+
);
}
@@ -143,77 +126,77 @@ export function ObjectChangeEntry({ changes, type }: ObjectChangeEntryProps) {
return (
<>
{Object.entries(changes).map(([owner, changes]) => {
+ const ownerAddress = useAddressLink(owner);
+ const label = getObjectChangeLabel(type);
+ const [open, setOpen] = useState(true);
+
return (
-
}
- key={`${type}-${owner}`}
- heading="Changes"
- >
-
- {({ open }) => (
-
-
-
-
+
+ setOpen(isOpen)}
+ render={() => (
+
+
+
+ }
+ />
+ )}
+ >
+ <>
+ {!!changes.changesWithDisplay.length && (
+
+
(
+
+ ),
+ )
+ : []
}
- >
- {getObjectChangeLabel(type)}
-
-
-
+ />
-
-
- <>
- {!!changes.changesWithDisplay.length && (
-
- (
-
- ),
- )
- : []
- }
- />
-
- )}
+ )}
-
- (
-
- ))
- : []
- }
- />
-
- >
-
-
- )}
-
-
+
+ (
+
+ ))
+ : []
+ }
+ />
+
+ >
+
+
+
+
);
})}
>
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/SummaryCard.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/SummaryCard.tsx
deleted file mode 100644
index 29309677f6b..00000000000
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/SummaryCard.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-import { ChevronDown16, ChevronRight16 } from '@iota/icons';
-import clsx from 'clsx';
-import { useState, type ReactNode } from 'react';
-
-import { Text } from '../../../shared/text';
-
-interface SummaryCardProps {
- header: ReactNode;
- children: ReactNode;
- badge?: ReactNode;
- initialExpanded?: boolean;
-}
-
-export function SummaryCard({
- children,
- header,
- badge,
- initialExpanded = false,
-}: SummaryCardProps) {
- const [expanded, setExpanded] = useState(initialExpanded);
-
- return (
-
-
- {expanded &&
{children}
}
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/TotalAmount.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/TotalAmount.tsx
deleted file mode 100644
index f5a3be5cc29..00000000000
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/TotalAmount.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) Mysten Labs, Inc.
-// Modifications Copyright (c) 2024 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-import { Heading } from '_src/ui/app/shared/heading';
-import { Text } from '_src/ui/app/shared/text';
-import { useFormatCoin } from '@iota/core';
-
-import { Card } from '../Card';
-
-interface TotalAmountProps {
- amount?: string;
- coinType?: string;
-}
-
-export function TotalAmount({ amount, coinType }: TotalAmountProps) {
- const [formatted, symbol] = useFormatCoin(amount, coinType);
- if (!amount) return null;
- return (
-
-
-
- Total Amount
-
-
-
- {formatted}
-
-
- {symbol}
-
-
-
-
- );
-}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/cards/objectSummary/ObjectChangeDisplay.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/cards/objectSummary/ObjectChangeDisplay.tsx
index e07060e6ada..a45ad65bc68 100644
--- a/apps/wallet/src/ui/app/shared/transaction-summary/cards/objectSummary/ObjectChangeDisplay.tsx
+++ b/apps/wallet/src/ui/app/shared/transaction-summary/cards/objectSummary/ObjectChangeDisplay.tsx
@@ -2,33 +2,37 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-import { ExplorerLink, ExplorerLinkType, NftImage } from '_components';
+import { ExplorerLinkType } from '_components';
import { type IotaObjectChangeWithDisplay } from '@iota/core';
-import { formatAddress } from '@iota/iota-sdk/utils';
-import { Text } from '../../../text';
+import { Card, CardAction, CardActionType, CardBody, CardImage, CardType } from '@iota/apps-ui-kit';
+import { ImageIcon } from '../../../image-icon';
+import { ArrowTopRight } from '@iota/ui-icons';
+import { useExplorerLink } from '_src/ui/app/hooks/useExplorerLink';
export function ObjectChangeDisplay({ change }: { change: IotaObjectChangeWithDisplay }) {
const display = change?.display?.data;
+ const name = display?.name ?? '';
const objectId = 'objectId' in change && change?.objectId;
+ const explorerHref = useExplorerLink({
+ type: ExplorerLinkType.Object,
+ objectID: objectId?.toString() ?? '',
+ });
if (!display) return null;
+
+ function handleOpen() {
+ const newWindow = window.open(explorerHref!, '_blank', 'noopener,noreferrer');
+ if (newWindow) newWindow.opener = null;
+ }
+
return (
-
-
- {objectId && (
-
-
-
- {formatAddress(objectId)}
-
-
-
- )}
-
+
+
+
+
+
+ {objectId && } />}
+
);
}
diff --git a/apps/wallet/src/ui/app/shared/transaction-summary/index.tsx b/apps/wallet/src/ui/app/shared/transaction-summary/index.tsx
index ceb45223314..2c9b5f519f3 100644
--- a/apps/wallet/src/ui/app/shared/transaction-summary/index.tsx
+++ b/apps/wallet/src/ui/app/shared/transaction-summary/index.tsx
@@ -2,58 +2,43 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
import { type TransactionSummary as TransactionSummaryType } from '@iota/core';
-import clsx from 'clsx';
-import { LoadingIndicator } from '_components';
import { Heading } from '../heading';
import { BalanceChanges } from './cards/BalanceChanges';
-import { ExplorerLinkCard } from './cards/ExplorerLink';
-import { GasSummary } from './cards/GasSummary';
import { ObjectChanges } from './cards/ObjectChanges';
+import { Loader } from '@iota/ui-icons';
export function TransactionSummary({
summary,
isLoading,
isError,
isDryRun = false,
- /* todo: remove this, we're using it until we update tx approval page */
- showGasSummary = false,
}: {
summary: TransactionSummaryType;
isLoading?: boolean;
isDryRun?: boolean;
isError?: boolean;
- showGasSummary?: boolean;
}) {
if (isError) return null;
return (
-
+ <>
{isLoading ? (
-
+
) : (
-
-
-
- {isDryRun && (
-
-
- Do you approve these actions?
-
-
- )}
-
-
- {showGasSummary &&
}
-
+
+ {isDryRun && (
+
+
+ Do you approve these actions?
+
-
+ )}
+
+
)}
-
+ >
);
}