import { CheckIcon, ReloadIcon } from "@radix-ui/react-icons"; import React, { useState, useEffect } from 'react'; interface NIP05Props { nip05: string; pubkey: string; } const NIP05: React.FC = ({ nip05, pubkey }) => { const [isLoading, setIsLoading] = useState(true); const [isValid, setIsValid] = useState(false); let name = nip05.split('@')[0] let domain = nip05.split('@')[1] useEffect(() => { if(nip05.length > 0) { fetch(`https://${domain}/.well-known/nostr.json?name=${name}`) .then(response => response.json()) .then(data => { if (data.names[name] === pubkey) { setIsValid(true); } else { setIsValid(false); } setIsLoading(false); }) } }, [nip05, pubkey]); return ( <>
{nip05.length > 0 && <> { name === "_" ? domain : nip05 } {isLoading ? : isValid ? : } }
); } export default NIP05;