diff --git a/kinode/src/register-ui/src/App.tsx b/kinode/src/register-ui/src/App.tsx index efe69a86..73e76ebf 100644 --- a/kinode/src/register-ui/src/App.tsx +++ b/kinode/src/register-ui/src/App.tsx @@ -10,9 +10,6 @@ import KinodeHome from "./pages/KinodeHome" import ImportKeyfile from "./pages/ImportKeyfile"; import { UnencryptedIdentity } from "./lib/types"; import Header from "./components/Header"; -import { bytesToHex } from "viem"; - - function App() { const params = useParams() @@ -38,8 +35,6 @@ function App() { const openConnect = () => setConnectOpen(true) const closeConnect = () => setConnectOpen(false) - const commitSecret = bytesToHex(crypto.getRandomValues(new Uint8Array(32))) - useEffect(() => setAppSizeOnLoad( (window.performance.getEntriesByType('navigation') as any)[0].transferSize ), []); @@ -100,7 +95,6 @@ function App() { tcp_port, setTcpPort, routers, setRouters, nodeChainId, - commitSecret, } return ( diff --git a/kinode/src/register-ui/src/lib/types.ts b/kinode/src/register-ui/src/lib/types.ts index fb658c76..14392ab3 100644 --- a/kinode/src/register-ui/src/lib/types.ts +++ b/kinode/src/register-ui/src/lib/types.ts @@ -23,7 +23,6 @@ export interface PageProps { setPw: React.Dispatch>, appSizeOnLoad: number, nodeChainId: string, - commitSecret: `0x${string}`, } export type NetworkingInfo = { diff --git a/kinode/src/register-ui/src/pages/CommitDotOsName.tsx b/kinode/src/register-ui/src/pages/CommitDotOsName.tsx index b1e69783..051080ba 100644 --- a/kinode/src/register-ui/src/pages/CommitDotOsName.tsx +++ b/kinode/src/register-ui/src/pages/CommitDotOsName.tsx @@ -23,7 +23,6 @@ function CommitDotOsName({ setWsPort, setTcpPort, setRouters, - commitSecret, }: RegisterOsNameProps) { let { address } = useAccount(); let navigate = useNavigate(); @@ -62,18 +61,18 @@ function CommitDotOsName({ return } console.log("committing to .os name: ", name) + const commitSecret = keccak256(stringToHex(name)) + const commit = keccak256( + encodeAbiParameters( + parseAbiParameters('bytes32, bytes32'), + [keccak256(stringToHex(name)), commitSecret] + ) + ) writeContract({ abi: dotOsAbi, address: DOTOS, functionName: 'commit', - args: [ - keccak256( - encodeAbiParameters( - parseAbiParameters('bytes memory, bytes32'), - [keccak256(stringToHex(name)), commitSecret] - ) - ) - ], + args: [commit], gas: 1000000n, }) diff --git a/kinode/src/register-ui/src/pages/MintDotOsName.tsx b/kinode/src/register-ui/src/pages/MintDotOsName.tsx index 52cbd526..daf94bef 100644 --- a/kinode/src/register-ui/src/pages/MintDotOsName.tsx +++ b/kinode/src/register-ui/src/pages/MintDotOsName.tsx @@ -6,7 +6,7 @@ import { PageProps } from "../lib/types"; import { useAccount, useWaitForTransactionReceipt, useSendTransaction } from "wagmi"; import { useConnectModal, useAddRecentTransaction } from "@rainbow-me/rainbowkit" import { dotOsAbi, generateNetworkingKeys, KINO_ACCOUNT_IMPL, DOTOS } from "../abis"; -import { encodePacked, parseAbi, encodeFunctionData, stringToHex } from "viem"; +import { encodePacked, encodeFunctionData, stringToHex, keccak256 } from "viem"; interface RegisterOsNameProps extends PageProps { } @@ -18,7 +18,6 @@ function MintDotOsName({ setWsPort, setTcpPort, setRouters, - commitSecret, }: RegisterOsNameProps) { let { address } = useAccount(); let navigate = useNavigate(); @@ -70,13 +69,10 @@ function MintDotOsName({ // strip .os suffix const name = knsName.replace(/\.os$/, ''); - - const abi = parseAbi([ - 'function mint(address,bytes,bytes,bytes,address,bytes32)', - ]) + const commitSecret = keccak256(stringToHex(name)) const data = encodeFunctionData({ - abi, + abi: dotOsAbi, functionName: 'mint', args: [ address, @@ -88,8 +84,6 @@ function MintDotOsName({ ], }) - console.log("data: ", data) - // use data to write to contract -- do NOT use writeContract // writeContract will NOT generate the correct selector for some reason // probably THEIR bug.. no abi works @@ -99,11 +93,8 @@ function MintDotOsName({ data: data, gas: 1000000n, }) - console.log('Transaction sent?') - // You might want to add some state management here to track the transaction } catch (error) { console.error('Failed to send transaction:', error) - // Handle the error appropriately, maybe set an error state } }, [direct, address, sendTransaction, setNetworkingKey, setIpAddress, setWsPort, setTcpPort, setRouters, openConnectModal])