Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kinode/packages/homepage/pkg/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-DBttdE6k.js"></script>
<script type="module" crossorigin src="/assets/index-Gt0JAj27.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BS5LP50I.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion kinode/packages/homepage/ui/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-DBttdE6k.js"></script>
<script type="module" crossorigin src="/assets/index-Gt0JAj27.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BS5LP50I.css">
</head>

Expand Down
6 changes: 3 additions & 3 deletions kinode/packages/homepage/ui/src/components/AppDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from "classnames"
import { HomepageApp } from "../store/homepageStore"
import { FaHeart, FaRegHeart } from "react-icons/fa6"
import { FaHeart, FaRegHeart, } from "react-icons/fa6"
import { useState } from "react"
import usePersistentStore from "../store/persistentStore"
import { isMobileCheck } from "../utils/dimensions"
Expand All @@ -11,7 +11,7 @@ interface AppDisplayProps {
}

const AppDisplay: React.FC<AppDisplayProps> = ({ app }) => {
const { favoriteApp } = usePersistentStore();
const { favoriteApp, favoriteApps } = usePersistentStore();
const [isHovered, setIsHovered] = useState(false)
const isMobile = isMobileCheck()

Expand Down Expand Up @@ -46,7 +46,7 @@ const AppDisplay: React.FC<AppDisplayProps> = ({ app }) => {
favoriteApp(app.package_name)
}}
>
{app.is_favorite ? <FaHeart /> : <FaRegHeart />}
{favoriteApps[app.package_name]?.favorite ? <FaHeart /> : <FaRegHeart />}
</button>}
</a>
}
Expand Down
13 changes: 9 additions & 4 deletions kinode/packages/homepage/ui/src/components/AppsDock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const AppsDock: React.FC = () => {

useEffect(() => {
let final: HomepageApp[] = []
const dockedApps = Object.keys(favoriteApps)
.map(name => ({ ...apps.find(a => a.package_name === name), order: favoriteApps[name].order }))
const dockedApps = Object.entries(favoriteApps)
.filter(([_, { favorite }]) => favorite)
.map(([name, { order }]) => ({ ...apps.find(a => a.package_name === name), order }))
.filter(a => a) as HomepageApp[]
const orderedApps = dockedApps.filter(a => a.order !== undefined && a.order !== null)
const unorderedApps = dockedApps.filter(a => a.order === undefined || a.order === null)
Expand Down Expand Up @@ -85,12 +86,15 @@ const AppsDock: React.FC = () => {
ref={provided.innerRef}
{...provided.droppableProps}
className={classNames('flex-center flex-wrap border border-orange bg-orange/25 p-2 rounded !rounded-xl', {
'gap-8 mb-4': !isMobile,
'gap-8': !isMobile && dockedApps.length > 0,
'gap-4': !isMobile && dockedApps.length === 0,
'mb-4': !isMobile,
'gap-4 mb-2': isMobile,
'flex-col': dockedApps.length === 0
})}
>
{dockedApps.length === 0
? <div>Favorite an app to pin it to your dock.</div>
? <AppDisplay app={apps.find(app => app.package_name === 'app_store')!} />
: dockedApps.map(app => <Draggable
key={app.package_name}
draggableId={app.package_name}
Expand All @@ -107,6 +111,7 @@ const AppsDock: React.FC = () => {
)}
</Draggable>)}
{provided.placeholder}
{dockedApps.length === 0 && <div>Favorite an app to pin it to your dock.</div>}
</div>
)}
</Droppable>
Expand Down
1 change: 0 additions & 1 deletion kinode/packages/homepage/ui/src/store/homepageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface HomepageApp {
path: string
label: string,
base64_icon?: string,
is_favorite: boolean,
state?: {
our_version: string
}
Expand Down
130 changes: 0 additions & 130 deletions kinode/src/register-ui/build/assets/index-DexQTHZb.js

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kinode/src/register-ui/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-DexQTHZb.js"></script>
<script type="module" crossorigin src="/assets/index-iKMNbHhl.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B00cPdAQ.css">
</head>

Expand Down
67 changes: 19 additions & 48 deletions kinode/src/register-ui/src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { FormEvent, useCallback, useEffect, useState } from "react";
import { namehash } from "ethers/lib/utils";
import { BytesLike, utils } from "ethers";
import { utils } from "ethers";
import KinodeHeader from "../components/KnsHeader";
import { NetworkingInfo, PageProps, UnencryptedIdentity } from "../lib/types";
import { PageProps, UnencryptedIdentity } from "../lib/types";
import Loader from "../components/Loader";
import { hooks } from "../connectors/metamask";
import { ipToNumber } from "../utils/ipToNumber";
import { downloadKeyfile } from "../utils/download-keyfile";
import DirectCheckbox from "../components/DirectCheckbox";
import { useNavigate } from "react-router-dom";
import { Tooltip } from "../components/Tooltip";
import { KinodeTitle } from "../components/KinodeTitle";
import { isMobileCheck } from "../utils/dimensions";
import classNames from "classnames";
import { generateNetworkingKeys, getNetworkName } from "../utils/chain";

const { useProvider } = hooks;

Expand All @@ -28,6 +28,10 @@ function Login({
appSizeOnLoad,
closeConnect,
routers,
setNetworkingKey,
setIpAddress,
setWsPort,
setTcpPort,
setRouters,
knsName,
setOsName,
Expand Down Expand Up @@ -88,51 +92,18 @@ function Login({
}

// Generate keys on server that are stored temporarily
const {
networking_key,
routing: {
Both: {
ip: ip_address,
ports: {
ws: ws_port,
tcp: tcp_port
},
routers: allowed_routers
}
},
} = (await fetch("/generate-networking-info", {
method: "POST",
}).then((res) => res.json())) as NetworkingInfo;

setLoading("Please confirm the transaction in your wallet");

const ipAddress = ipToNumber(ip_address);

const data: BytesLike[] = [
direct
? (
await kns.populateTransaction.setAllIp(
namehash(knsName),
ipAddress,
ws_port || 0, // ws
0, // wt
tcp_port || 0, // tcp
0 // udp
)
).data!
: (
await kns.populateTransaction.setRouters(
namehash(knsName),
allowed_routers.map((x) => namehash(x))
)
).data!,
(
await kns.populateTransaction.setKey(
namehash(knsName),
networking_key
)
).data!,
];
const data = await generateNetworkingKeys({
direct,
kns,
nodeChainId,
chainName: getNetworkName(nodeChainId),
nameToSet: namehash(knsName),
setNetworkingKey,
setIpAddress,
setWsPort,
setTcpPort,
setRouters,
})

setLoading("Please confirm the transaction");

Expand Down
86 changes: 19 additions & 67 deletions kinode/src/register-ui/src/pages/RegisterEthName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { useState, useEffect, FormEvent, useCallback } from "react";
import { hooks } from "../connectors/metamask";
import { useNavigate } from "react-router-dom";
import { toDNSWireFormat } from "../utils/dnsWire";
import { BytesLike, utils } from "ethers";
import { utils } from "ethers";
import EnterEthName from "../components/EnterEthName";
import Loader from "../components/Loader";
import KinodeHeader from "../components/KnsHeader";
import { NetworkingInfo, PageProps } from "../lib/types";
import { ipToNumber } from "../utils/ipToNumber";
import { getNetworkName, setChain } from "../utils/chain";
import { PageProps } from "../lib/types";
import { generateNetworkingKeys, getNetworkName, setChain } from "../utils/chain";
import { hash } from "@ensdomains/eth-ens-namehash";
import DirectCheckbox from "../components/DirectCheckbox";
import { MAINNET_OPT_HEX, OPTIMISM_OPT_HEX } from "../constants/chainId";
Expand Down Expand Up @@ -69,83 +68,36 @@ function RegisterEthName({

if (!provider) return openConnect();

setLoading("Please confirm the transaction in your wallet");
try {
setLoading("Please confirm the transaction in your wallet");

const {
networking_key,
routing: {
Both: {
ip: ip_address,
ports: {
ws: ws_port,
tcp: tcp_port
},
routers: allowed_routers
}
}
} = (await fetch("/generate-networking-info", { method: "POST" }).then(
(res) => res.json()
)) as NetworkingInfo;

const ipAddress = ipToNumber(ip_address);

setNetworkingKey(networking_key);
setIpAddress(ipAddress);
setWsPort(ws_port || 0);
setTcpPort(tcp_port || 0);
setRouters(allowed_routers);

const cleanedName = name.trim().replace(".eth", "");

const nameToSet = utils.namehash(`${cleanedName}.eth`);
const targetChainId = nodeChainId === OPTIMISM_OPT_HEX ? MAINNET_OPT_HEX : nodeChainId;

try {
await setChain(targetChainId);
} catch (error) {
window.alert(
`You must connect to the ${getNetworkName(targetChainId)} network to continue. Please connect and try again.`
);
throw new Error(`${getNetworkName(targetChainId)} not connected`);
}

const data: BytesLike[] = [
direct
? (
await kns.populateTransaction.setAllIp(
utils.namehash(`${cleanedName}.eth`),
ipAddress,
ws_port || 0, // ws
0, // wt
tcp_port || 0, // tcp
0 // udp
)
).data!
: (
await kns.populateTransaction.setRouters(
utils.namehash(`${cleanedName}.eth`),
allowed_routers.map((x) => utils.namehash(x))
)
).data!,
(
await kns.populateTransaction.setKey(
utils.namehash(`${cleanedName}.eth`),
networking_key
)
).data!,
];
const data = await generateNetworkingKeys({
direct,
kns,
nodeChainId: targetChainId,
chainName,
nameToSet,
setNetworkingKey,
setIpAddress,
setWsPort,
setTcpPort,
setRouters,
});

setLoading("Please confirm the transaction in your wallet");

// console.log("node chain id", nodeChainId);

const dnsFormat = toDNSWireFormat(`${cleanedName}.eth`);
const namehash = hash(`${cleanedName}.eth`);
const hashedName = hash(`${cleanedName}.eth`);

const tx = await knsEnsEntry.setKNSRecords(dnsFormat, data, { gasLimit: 300000 });

const onRegistered = (node: any, _name: any) => {
if (node === namehash) {
if (node === hashedName) {
kns.off("NodeRegistered", onRegistered);
setLoading("");
setOsName(`${cleanedName}.eth`);
Expand Down
Loading