diff --git a/apps/wallet/src/ui/app/hooks/useAddressLink.ts b/apps/wallet/src/ui/app/hooks/useAddressLink.ts new file mode 100644 index 00000000000..ccafb941778 --- /dev/null +++ b/apps/wallet/src/ui/app/hooks/useAddressLink.ts @@ -0,0 +1,23 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { useExplorerLink } from '_app/hooks/useExplorerLink'; +import { ExplorerLinkType } from '_components'; +import { formatAddress } from '@iota/iota-sdk/utils'; +import { useResolveIotaNSName } from '@iota/dapp-kit'; +import { isIotaNSName } from '@iota/core'; + +export function useAddressLink(inputAddress: string | null) { + const { data: domainName } = useResolveIotaNSName(inputAddress); + const outputAddress = domainName ?? (inputAddress || ''); + const explorerHref = useExplorerLink({ + type: ExplorerLinkType.Address, + address: outputAddress || undefined, + }); + + return { + explorerHref: explorerHref || '', + addressFull: inputAddress || '', + address: isIotaNSName(outputAddress) ? outputAddress : formatAddress(outputAddress), + }; +} diff --git a/apps/wallet/src/ui/app/pages/home/transfer-coin/PreviewTransfer.tsx b/apps/wallet/src/ui/app/pages/home/transfer-coin/PreviewTransfer.tsx index 2f7bab6fd23..f9b17e7e6de 100644 --- a/apps/wallet/src/ui/app/pages/home/transfer-coin/PreviewTransfer.tsx +++ b/apps/wallet/src/ui/app/pages/home/transfer-coin/PreviewTransfer.tsx @@ -2,11 +2,22 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Text } from '_app/shared/text'; -import { TxnAddress, TxnAmount } from '_components'; +import { CoinIcon } from '_components'; import { useActiveAddress } from '_src/ui/app/hooks/useActiveAddress'; import { GAS_SYMBOL } from '_src/ui/app/redux/slices/iota-objects/Coin'; -import { parseAmount, useCoinMetadata } from '@iota/core'; +import { parseAmount, useCoinMetadata, useFormatCoin } from '@iota/core'; +import { + Card, + CardAction, + CardActionType, + CardBody, + CardImage, + CardType, + Divider, + ImageType, + KeyValueInfo, +} from '@iota/apps-ui-kit'; +import { useAddressLink } from '_app/hooks/useAddressLink'; export type PreviewTransferProps = { coinType: string; @@ -26,26 +37,42 @@ export function PreviewTransfer({ const accountAddress = useActiveAddress(); const { data: metadata } = useCoinMetadata(coinType); const amountWithoutDecimals = parseAmount(amount, metadata?.decimals ?? 0); + const [formatted, symbol] = useFormatCoin( + Math.abs(Number(amountWithoutDecimals.toString())), + coinType, + ); + + const addrFrom = useAddressLink(accountAddress); + const addrTo = useAddressLink(to); return ( -