diff --git a/kinode/src/register-ui/src/pages/CommitDotOsName.tsx b/kinode/src/register-ui/src/pages/CommitDotOsName.tsx index e5125267..0e8018e6 100644 --- a/kinode/src/register-ui/src/pages/CommitDotOsName.tsx +++ b/kinode/src/register-ui/src/pages/CommitDotOsName.tsx @@ -95,7 +95,7 @@ function CommitDotOsName({ return (
- +
{
diff --git a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx index 735cccbb..6d3e5d30 100644 --- a/kinode/src/register-ui/src/pages/ImportKeyfile.tsx +++ b/kinode/src/register-ui/src/pages/ImportKeyfile.tsx @@ -83,7 +83,7 @@ function ImportKeyfile({ return (
- +
{loading ? ( diff --git a/kinode/src/register-ui/src/pages/MintCustom.tsx b/kinode/src/register-ui/src/pages/MintCustom.tsx index 6e40f277..b3456abc 100644 --- a/kinode/src/register-ui/src/pages/MintCustom.tsx +++ b/kinode/src/register-ui/src/pages/MintCustom.tsx @@ -118,7 +118,7 @@ function MintCustom({ return (
- +
{ diff --git a/kinode/src/register-ui/src/pages/MintDotOsName.tsx b/kinode/src/register-ui/src/pages/MintDotOsName.tsx index a60e14bb..5114f83c 100644 --- a/kinode/src/register-ui/src/pages/MintDotOsName.tsx +++ b/kinode/src/register-ui/src/pages/MintDotOsName.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, FormEvent, useCallback } from "react"; +import { useState, useEffect, useCallback } from "react"; import { useNavigate } from "react-router-dom"; import Loader from "../components/Loader"; import { PageProps } from "../lib/types"; @@ -36,28 +36,28 @@ function MintDotOsName({ }); const addRecentTransaction = useAddRecentTransaction(); - const [triggerNameCheck, setTriggerNameCheck] = useState(false) + const [hasMinted, setHasMinted] = useState(false); useEffect(() => { document.title = "Mint" }, []) - useEffect(() => setTriggerNameCheck(!triggerNameCheck), [address]) - useEffect(() => { if (!address) { openConnectModal?.(); } }, [address, openConnectModal]); - let handleMint = useCallback(async (e: FormEvent) => { - e.preventDefault() - e.stopPropagation() - + const handleMint = useCallback(async () => { if (!address) { openConnectModal?.() return } + if (hasMinted) { + return + } + + setHasMinted(true); const initCall = await generateNetworkingKeys({ direct, @@ -71,8 +71,6 @@ function MintDotOsName({ reset: false, }); - console.log("minting name: ", knsName) - // strip .os suffix const name = knsName.replace(/\.os$/, ''); const commitSecret = keccak256(stringToHex(name)) @@ -101,8 +99,15 @@ function MintDotOsName({ }) } catch (error) { console.error('Failed to send transaction:', error) + setHasMinted(false); } - }, [direct, address, sendTransaction, setNetworkingKey, setIpAddress, setWsPort, setTcpPort, setRouters, openConnectModal]) + }, [direct, address, sendTransaction, setNetworkingKey, setIpAddress, setWsPort, setTcpPort, setRouters, openConnectModal, knsName, hasMinted]) + + useEffect(() => { + if (address && !isPending && !isConfirming) { + handleMint(); + } + }, [address, handleMint, isPending, isConfirming]); useEffect(() => { if (isConfirmed) { @@ -113,26 +118,18 @@ function MintDotOsName({ return (
- { - - {isPending || isConfirming ? ( - - ) : ( - <> -
- -
- - )} - {isError && ( -

- Error: {error?.message || 'There was an error minting your name, please try again.'} -

- )} - - } +
+ {isPending || isConfirming ? ( + + ) : ( + + )} + {isError && ( +

+ Error: {error?.message || 'There was an error minting your name, please try again.'} +

+ )} +
);