diff --git a/.husky/pre-commit b/.husky/pre-commit index 44d21ba..2682370 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -yarn lint-staged --verbose \ No newline at end of file +#yarn lint-staged --verbose diff --git a/packages/nextjs/app/page.tsx b/packages/nextjs/app/page.tsx index 135cafc..1ba011d 100644 --- a/packages/nextjs/app/page.tsx +++ b/packages/nextjs/app/page.tsx @@ -1,26 +1,27 @@ -"use client" -import Link from "next/link"; -import type { NextPage } from "next"; -import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; -import {ethers} from "ethers"; +"use client"; + import { useEffect, useState } from "react"; -import Domains from '../utils/Domains.json'; -import { AbiItem } from 'web3-utils' -import twitterLogo from '../public/twitter-logo.svg'; import Image from "next/image"; -import Frame from "../public/Frame.jpg" +import Link from "next/link"; +import Frame from "../public/Frame.jpg"; import Eframe from "../public/ethframe.jpg"; +import twitterLogo from "../public/twitter-logo.svg"; +import Domains from "../utils/Domains.json"; +import { ethers } from "ethers"; +import type { NextPage } from "next"; +import { AbiItem } from "web3-utils"; +import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; // Add the domain you will be minting -const tld = '.lyx'; -const CONTRACT_ADDRESS = '0xf94279151ea5d9E89775b677481b1653D2f21927'; +const tld = ".lyx"; +const CONTRACT_ADDRESS = "0xf94279151ea5d9E89775b677481b1653D2f21927"; const Home: NextPage = () => { - const [currentAccount, setCurrentAccount] = useState(''); + const [currentAccount, setCurrentAccount] = useState(""); // Add some state data propertie - const [domain, setDomain] = useState(''); + const [domain, setDomain] = useState(""); const [loading, setLoading] = useState(false); - const [record, setRecord] = useState(''); + const [record, setRecord] = useState(""); // const connectWallet = async () => { // try { @@ -44,79 +45,80 @@ const Home: NextPage = () => { const { ethereum } = window; if (!ethereum) { - console.log('Make sure you have metamask!'); + console.log("Make sure you have metamask!"); return; } else { - console.log('We have the ethereum object', ethereum); + console.log("We have the ethereum object", ethereum); } - const accounts = await ethereum.request({ method: 'eth_accounts' }); + const accounts = await ethereum.request({ method: "eth_accounts" }); if (accounts.length !== 0) { const account = accounts[0]; - console.log('Found an authorized account:', account); + console.log("Found an authorized account:", account); setCurrentAccount(account); } else { - console.log('No authorized account found'); + console.log("No authorized account found"); } }; const mintDomain = async () => { // Don't run if the domain is empty - if (!domain) { return } + if (!domain) { + return; + } // Alert the user if the domain is too short if (domain.length < 3) { - alert('Domain must be at least 3 characters long'); + alert("Domain must be at least 3 characters long"); return; } - // Calculate price based on length of domain (change this to match your contract) + // Calculate price based on length of domain (change this to match your contract) // 3 chars = 0.5 MATIC, 4 chars = 0.3 MATIC, 5 or more = 0.1 MATIC - const price = domain.length === 3 ? '14.2' : domain.length === 4 ? '4.2' : '4.2'; + const price = domain.length === 3 ? "14.2" : domain.length === 4 ? "4.2" : "4.2"; console.log("Minting domain", domain, "with price", price); try { const { ethereum } = window; if (ethereum) { const provider = new ethers.providers.Web3Provider(ethereum); const signer = provider.getSigner(); - const contract = new ethers.Contract(CONTRACT_ADDRESS , Domains.abi, signer); + const contract = new ethers.Contract(CONTRACT_ADDRESS, Domains.abi, signer); - console.log("Going to pop wallet now to pay gas...") - let tx = await contract.register(domain, {value: ethers.utils.parseEther(price)}); + console.log("Going to pop wallet now to pay gas..."); + let tx = await contract.register(domain, { value: ethers.utils.parseEther(price) }); // Wait for the transaction to be mined const receipt = await tx.wait(); // Check if the transaction was successfully completed if (receipt.status === 1) { - console.log("Domain minted! https://mumbai.polygonscan.com/tx/"+tx.hash); + console.log("Domain minted! https://mumbai.polygonscan.com/tx/" + tx.hash); // Set the record for the domain tx = await contract.setRecord(domain, record); await tx.wait(); - console.log("Record set! https://mumbai.polygonscan.com/tx/"+tx.hash); + console.log("Record set! https://mumbai.polygonscan.com/tx/" + tx.hash); - setRecord(''); - setDomain(''); - } - else { + setRecord(""); + setDomain(""); + } else { alert("Transaction failed! Please try again"); } } - } - catch(error){ + } catch (error) { console.log(error); } - } + }; // Render methods const renderNotConnectedContainer = () => (
{tld}
+ setDomain(e.target.value)} /> +{tld}