diff --git a/package-lock.json b/package-lock.json
index 0f560da..38ae288 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4266,6 +4266,8 @@
},
"node_modules/@parcel/watcher-wasm/node_modules/napi-wasm": {
"version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/napi-wasm/-/napi-wasm-1.1.0.tgz",
+ "integrity": "sha512-lHwIAJbmLSjF9VDRm9GoVOy9AGp3aIvkjv+Kvz9h16QR3uSVYH78PNQUnT2U4X53mhlnV2M7wrhibQ3GHicDmg==",
"inBundle": true,
"license": "MIT"
},
diff --git a/src/pages/Nova/NovaDetails.tsx b/src/pages/Nova/NovaDetails.tsx
index c185043..39ed672 100644
--- a/src/pages/Nova/NovaDetails.tsx
+++ b/src/pages/Nova/NovaDetails.tsx
@@ -432,6 +432,20 @@ const NovaDetails = () => {
}
}, [nova]);
+ const canSeeRegisterDomain = useMemo(() => {
+ if (!nova) {
+ return false;
+ }
+ if (!address) {
+ return false;
+ }
+
+ return (
+ address.toLowerCase() === nova?.properties.deployer.toLowerCase() &&
+ !nova?.properties.domain
+ );
+ }, [address, nova]);
+
return (
<>
{nova && (
@@ -471,13 +485,13 @@ const NovaDetails = () => {
onClose={() => setOpenDomainDialog(false)}
onRegister={async (domain: string) => {
const result = await registerDomain({
- domain,
+ domain: `${domain}.hub`,
novaAddress: nova.properties.address,
metadataUri: nova.properties.metadataUri
});
if ((result as any)?.data?.success) {
// hack cause query fails to refetch
- setDomain(domain);
+ setDomain(`${domain}.hub`);
}
}}
>
@@ -957,26 +971,24 @@ const NovaDetails = () => {
)}
- {address.toLowerCase() ===
- nova.properties.deployer.toLowerCase() &&
- !nova.properties.domain && (
-
- setOpenDomainDialog(true)}
- type="button"
- color="primary"
- variant="outlined"
+ {canSeeRegisterDomain && (
+
+ setOpenDomainDialog(true)}
+ type="button"
+ color="primary"
+ variant="outlined"
+ >
+
-
- Register Domain
-
-
-
- )}
+ Register Domain
+
+
+
+ )}
diff --git a/src/pages/Nova/RegisterDomainDialog.tsx b/src/pages/Nova/RegisterDomainDialog.tsx
index 8514635..c38331c 100644
--- a/src/pages/Nova/RegisterDomainDialog.tsx
+++ b/src/pages/Nova/RegisterDomainDialog.tsx
@@ -7,7 +7,8 @@ import {
TextField,
Typography,
Box,
- styled
+ styled,
+ InputAdornment
} from "@mui/material";
import { AutOsButton } from "@components/AutButton";
@@ -59,26 +60,27 @@ const DomainRegistrationDialog = ({ open, onClose, onRegister }) => {
}, [domain]);
const validateDomain = (value) => {
- const domainRegex =
- /^[a-zA-Z0-9](?:[a-zA-Z0-9]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;
- const hubEndingRegex = /\.hub$/i;
+ // Domain regex breakdown:
+ // ^[a-zA-Z0-9] - Start with a letter or number
+ // (?:[a-zA-Z0-9]{0,61} - Followed by 0 to 61 letters or numbers
+ // [a-zA-Z0-9])? - Ending with a letter or number (optional group)
+ const domainRegex = /^[a-zA-Z0-9](?:[a-zA-Z0-9]{0,61}[a-zA-Z0-9])?$/;
const trimmedValue = value.trim().toLowerCase();
if (trimmedValue === "") {
setIsValid(false);
- setErrorMessage("Domain name is required");
+ setErrorMessage("Please enter a domain name");
} else if (trimmedValue.includes("-")) {
setIsValid(false);
- setErrorMessage("Domain name cannot contain dashes");
+ setErrorMessage("Domain name cannot contain hyphens");
} else if (!domainRegex.test(trimmedValue)) {
setIsValid(false);
- setErrorMessage("Invalid domain format");
+ setErrorMessage(
+ "Please enter a valid domain name (Cannot contain symbols or spaces)"
+ );
} else if (trimmedValue.length > 253) {
setIsValid(false);
- setErrorMessage("Domain name is too long (max 253 characters)");
- } else if (!hubEndingRegex.test(trimmedValue)) {
- setIsValid(false);
- setErrorMessage("Domain must end with '.hub'");
+ setErrorMessage("Domain name exceeds maximum length of 253 characters");
} else {
setIsValid(true);
setErrorMessage("");
@@ -102,13 +104,22 @@ const DomainRegistrationDialog = ({ open, onClose, onRegister }) => {
Enter a domain name for your Nova.
+
+ .hub
+
+
+ )
+ }}
autoFocus
margin="dense"
label="Domain"
type="text"
fullWidth
value={domain}
- onChange={(e) => setDomain(e.target.value)}
+ onChange={(e) => setDomain(e.target.value.toLowerCase())}
helperText={errorMessage || " "}
error={Boolean(errorMessage)}
/>