Skip to content

chore(evm-address): Option to copy the address for evm contracts and copy feedback #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions components/CopyAddress.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import copy from "copy-to-clipboard";
import CopyIcon from "./icons/CopyIcon";
import { useCopyToClipboard } from "../utils/useCopyToClipboard";

const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
const { copiedText, copyToClipboard } = useCopyToClipboard();
const isCopied = copiedText === address;

return (
<div
className="-ml-1 inline-flex cursor-pointer items-center px-1 font-mono hover:bg-light hover:text-dark dark:hover:bg-dark dark:hover:text-light"
onClick={() => {
copy(address);
copyToClipboard(address);
}}
>
<span className="mr-2 hidden lg:block">
Expand All @@ -26,8 +29,12 @@ const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
) : (
address.slice(0, 6) + "..." + address.slice(-6)
)}
</span>{" "}
<CopyIcon className="shrink-0" />
</span>
{isCopied ? (
<span className="text-green-500 text-xs font-bold">✓</span>
) : (
<CopyIcon className="shrink-0" />
)}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worthwhile to make a <CopyButton> component since it seems like you're reusing it a lot, I have that in the Pyth component library that we're using on newer projects but since this project doesn't use the component library you don't have access to it unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, going to do in a separate PR as we will have to replace the usage with the new component in other places as well.

Want to keep this PR focused on copy functionality for EVM address.

);
};
Expand Down
Loading
Loading