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 ( -
- - - -
-
- - Estimated Gas Fees - -
- - {gasBudget} {GAS_SYMBOL} - +
+ + +
+ +
+
+ + +
+
+ + + + +
); diff --git a/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx b/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx index ec3100909c5..79fa4e7d0a1 100644 --- a/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx +++ b/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx @@ -2,8 +2,6 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import BottomMenuLayout, { Content, Menu } from '_app/shared/bottom-menu-layout'; -import { Button } from '_app/shared/ButtonUI'; import { Text } from '_app/shared/text'; import { ActiveCoinsCard, Overlay } from '_components'; import { ampli } from '_src/shared/analytics/ampli'; @@ -12,16 +10,16 @@ import { useActiveAccount } from '_src/ui/app/hooks/useActiveAccount'; import { useSigner } from '_src/ui/app/hooks/useSigner'; import { useUnlockedGuard } from '_src/ui/app/hooks/useUnlockedGuard'; import { createTokenTransferTransaction, useCoinMetadata } from '@iota/core'; -import { ArrowLeft16, ArrowRight16 } from '@iota/icons'; // import * as Sentry from '@sentry/react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { useMemo, useState } from 'react'; import { toast } from 'react-hot-toast'; import { Navigate, useNavigate, useSearchParams } from 'react-router-dom'; +import { Button, ButtonType } from '@iota/apps-ui-kit'; import { PreviewTransfer } from './PreviewTransfer'; -import { SendTokenForm } from './SendTokenForm'; import type { SubmitProps } from './SendTokenForm'; +import { SendTokenForm } from './SendTokenForm'; function TransferCoinPage() { const [searchParams] = useSearchParams(); @@ -101,14 +99,15 @@ function TransferCoinPage() { return ( navigate('/')} + showBackButton >
{showTransactionPreview && formData ? ( - - + <> +
- - -
+
+ ) : ( <>