mirror of
https://github.com/luxfhe/example-smart-wallet.git
synced 2026-10-30 18:13:16 +00:00
22 lines
733 B
TypeScript
22 lines
733 B
TypeScript
import { useConnection } from "@account-kit/react";
|
|
import { useMemo } from "react";
|
|
import truncateAddress from "~~/utils/truncate-address";
|
|
|
|
export const UserAddressLink = ({ address }: { address: string | null }) => {
|
|
const connection = useConnection();
|
|
const truncatedAddress = truncateAddress(address ?? "");
|
|
const addressBlockExplorerUrl = useMemo(() => {
|
|
if (!address || !connection.chain.blockExplorers) {
|
|
return null;
|
|
}
|
|
|
|
return `${connection.chain.blockExplorers?.default.url}/address/${address}`;
|
|
}, [address, connection]);
|
|
|
|
return (
|
|
<a target="_blank" className="text-fg-primary underline text-md md:text-sm" href={addressBlockExplorerUrl ?? "#"}>
|
|
{truncatedAddress}
|
|
</a>
|
|
);
|
|
};
|