Skip to content

Commit

Permalink
Fix for missing termination flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sshmatrix committed Feb 3, 2024
1 parent 8b3dab7 commit 13f6c2d
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 1,143 deletions.
5 changes: 4 additions & 1 deletion components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ListItem {
interface ListProps {
label: string;
items: ListItem[];
disabled: boolean;
onItemClickStealth: (value: string) => void;
onItemClickPreview: (value: string) => void;
}
Expand All @@ -29,6 +30,7 @@ const numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
const List: React.FC<ListProps> = ({
label,
items,
disabled,
onItemClickStealth,
onItemClickPreview,
}) => {
Expand Down Expand Up @@ -274,7 +276,7 @@ const List: React.FC<ListProps> = ({
width: "40px",
}}
onClick={() => onItemClickStealth(item.name + ".eth")}
disabled={["0"].includes(item.migrated) || label === "view"}
disabled={["0"].includes(item.migrated) || label === "view" || disabled}
data-tooltip={`Stealth Payments`}
>
<div className="flex-sans-direction">
Expand Down Expand Up @@ -302,6 +304,7 @@ const List: React.FC<ListProps> = ({
}}
onClick={() => onItemClickPreview(item.name + ".eth")}
data-tooltip={`${label} Your Records`}
disabled={disabled}
>
<div className="flex-sans-direction">
{}
Expand Down
122 changes: 80 additions & 42 deletions components/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from "wagmi"; // Legacy Wagmi 1.6
import { Resolver } from "@ethersproject/providers";
import { formatsByName } from "@ensdomains/address-encoder";
import { zeroAddress } from "viem";

// Modal data to pass back to homepage
interface ModalProps {
Expand Down Expand Up @@ -101,6 +102,7 @@ const Preview: React.FC<ModalProps> = ({
const [namehashLegacy, setNamehashLegacy] = React.useState(""); // Legacy Namehash of ENS Domain
const [tokenIDLegacy, setTokenIDLegacy] = React.useState(""); // Legacy Token ID of ENS Domain
const [tokenIDWrapper, setTokenIDWrapper] = React.useState(""); // Wrapper Token ID of ENS Domain
const [recordEditor, setRecordEditor] = React.useState(C.zeroAddress); // Sets in-app record editor
const [managers, setManagers] = React.useState<string[]>([]); // Manager of ENS Domain
const [contenthash, setContenthash] = React.useState(""); // Contenthash record for ENS Domain
const [saltModal, setSaltModal] = React.useState(false); // Salt (password/key-identifier) for IPNS keygen
Expand Down Expand Up @@ -211,6 +213,7 @@ const Preview: React.FC<ModalProps> = ({
// Read Legacy ENS Registry for ENS domain Owner
const {
data: _OwnerLegacy_,
refetch: readLegacyOwner,
isLoading: legacyOwnerLoading,
isError: legacyOwnerError,
} = useContractRead({
Expand All @@ -222,6 +225,7 @@ const Preview: React.FC<ModalProps> = ({
// Read Legacy ENS Registry for ENS domain Manager
const {
data: _ManagerLegacy_,
refetch: readLegacyManager,
isLoading: legacyManagerLoading,
isError: legacyManagerError,
} = useContractRead({
Expand All @@ -230,22 +234,10 @@ const Preview: React.FC<ModalProps> = ({
functionName: "owner",
args: [namehashLegacy],
});
// Read CCIP2 for ENS domain on-chain manager
const { data: _CCIP2Manager_ } = useContractRead({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "isApprovedSigner",
args: [
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner && keypairSigner[0]
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
: C.zeroAddress,
],
});
// Read ownership of a domain from ENS Wrapper
const {
data: _OwnerWrapped_,
refetch: readWrapperManager,
isLoading: wrapperOwnerLoading,
isError: wrapperOwnerError,
} = useContractRead({
Expand All @@ -254,20 +246,33 @@ const Preview: React.FC<ModalProps> = ({
functionName: "ownerOf",
args: [tokenIDWrapper],
});
// Read Ownerhash from CCIP2 Resolver
const { data: _Ownerhash_ } = useContractRead({
// Read CCIP2 for ENS domain on-chain manager
const { data: _CCIP2Manager_, refetch: readOnChainSigner } = useContractRead({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "getRecordhash",
args: [ethers.utils.hexZeroPad(getRecordEditor(), 32).toLowerCase()],
functionName: "isApprovedSigner",
args: [
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner && keypairSigner[0]
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
: C.zeroAddress,
],
});
// Read Recordhash from CCIP2 Resolver
const { data: _Recordhash_ } = useContractRead({
const { data: _Recordhash_, refetch: readRecordhash } = useContractRead({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "getRecordhash",
args: [ethers.utils.namehash(ENS)],
});
// Read Ownerhash from CCIP2 Resolver
const { data: _Ownerhash_, refetch: readOwnerhash } = useContractRead({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "getRecordhash",
args: [ethers.utils.hexZeroPad(getRecordEditor(), 32).toLowerCase()],
});

// Sets new ENS Resolver
const {
Expand Down Expand Up @@ -1875,19 +1880,45 @@ const Preview: React.FC<ModalProps> = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Triggers upon Preview load and attempts to get Resolver for ENS domain
// Triggers upon Preview load and attempts to get token and name data
React.useEffect(() => {
if (browser && ENS) {
let namehash = ethers.utils.namehash(ENS);
let labelhash = C.calculateLabelhash(ENS);
setNamehashLegacy(namehash);
setTokenIDLegacy(String(ethers.BigNumber.from(labelhash)));
setTokenIDWrapper(String(ethers.BigNumber.from(namehash)));
setConclude(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [browser, ENS]);

// Triggers reading ownership and controller details for a name after getting token and name data
React.useEffect(() => {
if (namehashLegacy && tokenIDLegacy && tokenIDWrapper && ENS) {
readRecordhash();
readLegacyOwner();
readLegacyManager();
readWrapperManager();
setConclude(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [namehashLegacy, tokenIDLegacy, tokenIDWrapper, ENS]);

// Enables querying Ownerhash
React.useEffect(() => {
if (recordEditor && recordEditor !== C.zeroAddress) {
readOwnerhash();
readOnChainSigner();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [recordEditor]);

// Sets in-app record editor
React.useEffect(() => {
setRecordEditor(getRecordEditor());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [_OwnerLegacy_, _ManagerLegacy_, _OwnerWrapped_]);

// Handles setting setRecordhash on CCIP2 Resolver
React.useEffect(() => {
if (preCache) {
Expand Down Expand Up @@ -3437,7 +3468,7 @@ const Preview: React.FC<ModalProps> = ({
</div>
</button>
</div>
<div style={{ margin: "-5px 0 1px 0" }}>
<div style={{ margin: "-5px 0 1px 0" }} className="flex-row">
<span
className="mono"
id="metaOwner"
Expand All @@ -3454,21 +3485,25 @@ const Preview: React.FC<ModalProps> = ({
</span>
{(!_OwnerLegacy_ ||
String(_OwnerLegacy_) === C.zeroAddress) && (
<span
<button
className="button-micro"
style={{
padding: "0 0 0 7.5px",
margin: "-2px 0 0 7.5px",
}}
data-tooltip={`Name in Grace Period or Expired`}
>
<span
className="material-icons-round smoller"
style={{
color: "orange",
fontSize: "15px",
}}
>
{"report_problem"}
</span>
</span>
<div>
<span
className="material-icons-round smoller"
style={{
color: "orange",
fontSize: "15px",
}}
>
{"report_problem"}
</span>
</div>
</button>
)}
{C.ensContracts.includes(String(_OwnerLegacy_)) && (
<img
Expand All @@ -3478,16 +3513,19 @@ const Preview: React.FC<ModalProps> = ({
style={{ margin: `0 -15px -1px 7.5px` }}
/>
)}
{!wrapped && (
<img
alt="logo-2"
src="logo.png"
width={"15px"}
style={{ margin: `0 -15px -1px 7.5px` }}
/>
)}
{!wrapped &&
!["undefined", C.zeroAddress].includes(
String(_OwnerLegacy_)
) && (
<img
alt="logo-2"
src="logo.png"
width={"15px"}
style={{ margin: `-5px -15px 0 7.5px` }}
/>
)}
</div>
<div style={{ margin: "-3px 0 1px 0" }}>
<div style={{ margin: "0 0 1px 0" }}>
<span className="mono" id="metaManager" onClick={() => {}}>
{isMobile
? C.truncateHexString(getManager())
Expand Down
7 changes: 5 additions & 2 deletions components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { isMobile } from "react-device-detect";

interface SearchBoxProps {
onSearch: (query: string) => void;
disabled: boolean;
}

export const SearchBox: React.FC<SearchBoxProps> = ({ onSearch }) => {
export const SearchBox: React.FC<SearchBoxProps> = ({ onSearch, disabled }) => {
const [query, setQuery] = useState("");

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -40,6 +41,7 @@ export const SearchBox: React.FC<SearchBoxProps> = ({ onSearch }) => {
required
pattern=".*\.eth$"
title="❗ Input must end with '.eth'"
disabled={disabled}
/>
<button
className="button"
Expand Down Expand Up @@ -67,7 +69,7 @@ export const SearchBox: React.FC<SearchBoxProps> = ({ onSearch }) => {
);
};

export const BigSearch: React.FC<SearchBoxProps> = ({ onSearch }) => {
export const BigSearch: React.FC<SearchBoxProps> = ({ onSearch, disabled }) => {
const [query, setQuery] = useState("");

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -123,6 +125,7 @@ export const BigSearch: React.FC<SearchBoxProps> = ({ onSearch }) => {
paddingTop: query ? "8px" : "17px",
paddingBottom: query ? "8px" : "15px",
}}
disabled={disabled}
/>
<button
className="button"
Expand Down
Loading

0 comments on commit 13f6c2d

Please sign in to comment.