Skip to content

Commit c9b9d73

Browse files
authored
fix: fix addy length for znam in transfer source (#2324)
1 parent fa6dc95 commit c9b9d73

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

apps/namadillo/src/App/Transfer/TransferSource.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { Asset } from "@chain-registry/types";
22
import { AmountInput, Tooltip } from "@namada/components";
3+
import { copyToClipboard, shortenAddress } from "@namada/utils";
34
import BigNumber from "bignumber.js";
45
import clsx from "clsx";
56
import { wallets } from "integrations";
7+
import { useState } from "react";
8+
import { GoCheck } from "react-icons/go";
69
import { Address } from "types";
710
import namadaShieldedIcon from "./assets/namada-shielded.svg";
811
import namadaTransparentIcon from "./assets/namada-transparent.svg";
@@ -80,11 +83,21 @@ export const TransferSource = ({
8083
openAssetSelector,
8184
onChangeAmount,
8285
}: TransferSourceProps): JSX.Element => {
86+
const [isCopied, setIsCopied] = useState(false);
87+
8388
const selectedTokenType =
8489
isTransparentAddress(sourceAddress ?? "") ? "transparent"
8590
: isShieldedAddress(sourceAddress ?? "") ? "shielded"
8691
: "keplr";
8792

93+
const handleCopyAddress = (): void => {
94+
if (sourceAddress) {
95+
copyToClipboard(sourceAddress);
96+
setIsCopied(true);
97+
setTimeout(() => setIsCopied(false), 500);
98+
}
99+
};
100+
88101
return (
89102
<div
90103
className={clsx(
@@ -108,10 +121,17 @@ export const TransferSource = ({
108121
<img
109122
src={getWalletIcon(sourceAddress, selectedTokenType)}
110123
alt="Wallet icon"
111-
className="w-7 h-7"
124+
className="cursor-pointer w-7 h-7"
125+
onClick={handleCopyAddress}
126+
title="Copy address"
112127
/>
113128
<Tooltip position="top" className="z-50">
114-
{sourceAddress}
129+
{isCopied ?
130+
<>
131+
Copied
132+
<GoCheck className="mt-0.5 ml-1 text-green-500" />
133+
</>
134+
: shortenAddress(sourceAddress)}
115135
</Tooltip>
116136
</div>
117137
</div>

0 commit comments

Comments
 (0)