Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/namadillo/src/App/Transfer/TransferSource.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Asset } from "@chain-registry/types";
import { AmountInput, Tooltip } from "@namada/components";
import { copyToClipboard, shortenAddress } from "@namada/utils";
import BigNumber from "bignumber.js";
import clsx from "clsx";
import { wallets } from "integrations";
import { useState } from "react";
import { GoCheck } from "react-icons/go";
import { Address } from "types";
import namadaShieldedIcon from "./assets/namada-shielded.svg";
import namadaTransparentIcon from "./assets/namada-transparent.svg";
Expand Down Expand Up @@ -80,11 +83,21 @@ export const TransferSource = ({
openAssetSelector,
onChangeAmount,
}: TransferSourceProps): JSX.Element => {
const [isCopied, setIsCopied] = useState(false);

const selectedTokenType =
isTransparentAddress(sourceAddress ?? "") ? "transparent"
: isShieldedAddress(sourceAddress ?? "") ? "shielded"
: "keplr";

const handleCopyAddress = (): void => {
if (sourceAddress) {
copyToClipboard(sourceAddress);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 500);
}
};

return (
<div
className={clsx(
Expand All @@ -108,10 +121,17 @@ export const TransferSource = ({
<img
src={getWalletIcon(sourceAddress, selectedTokenType)}
alt="Wallet icon"
className="w-7 h-7"
className="cursor-pointer w-7 h-7"
onClick={handleCopyAddress}
title="Copy address"
/>
<Tooltip position="top" className="z-50">
{sourceAddress}
{isCopied ?
<>
Copied
<GoCheck className="mt-0.5 ml-1 text-green-500" />
</>
: shortenAddress(sourceAddress)}
</Tooltip>
</div>
</div>
Expand Down