copy changes, kinomap->kimap

This commit is contained in:
dr-frmr 2024-08-13 23:55:36 +03:00
parent c9f0566955
commit 652dc76063
No known key found for this signature in database
14 changed files with 61 additions and 58 deletions

View File

@ -170,7 +170,7 @@ button:disabled {
} }
button.secondary { button.secondary {
background-color: white; background-color: light-dark(var(--off-white), var(--off-black));
color: var(--orange); color: var(--orange);
border: 2px solid var(--orange); border: 2px solid var(--orange);
} }

View File

@ -1,9 +1,9 @@
import { multicallAbi, kinomapAbi, mechAbi, KINOMAP, MULTICALL, KINO_ACCOUNT_IMPL } from "./"; import { multicallAbi, kimapAbi, mechAbi, KIMAP, MULTICALL, KINO_ACCOUNT_IMPL } from "./";
import { encodeFunctionData, encodePacked, stringToHex } from "viem"; import { encodeFunctionData, encodePacked, stringToHex } from "viem";
export function encodeMulticalls(metadataUri: string, metadataHash: string) { export function encodeMulticalls(metadataUri: string, metadataHash: string) {
const metadataHashCall = encodeFunctionData({ const metadataHashCall = encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~metadata-hash")]), encodePacked(["bytes"], [stringToHex("~metadata-hash")]),
@ -12,7 +12,7 @@ export function encodeMulticalls(metadataUri: string, metadataHash: string) {
}) })
const metadataUriCall = encodeFunctionData({ const metadataUriCall = encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~metadata-uri")]), encodePacked(["bytes"], [stringToHex("~metadata-uri")]),
@ -21,8 +21,8 @@ export function encodeMulticalls(metadataUri: string, metadataHash: string) {
}) })
const calls = [ const calls = [
{ target: KINOMAP, callData: metadataHashCall }, { target: KIMAP, callData: metadataHashCall },
{ target: KINOMAP, callData: metadataUriCall }, { target: KIMAP, callData: metadataUriCall },
]; ];
const multicall = encodeFunctionData({ const multicall = encodeFunctionData({
@ -46,7 +46,7 @@ export function encodeIntoMintCall(multicalls: `0x${string}`, our_address: `0x${
}); });
const mintCall = encodeFunctionData({ const mintCall = encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'mint', functionName: 'mint',
args: [ args: [
our_address, our_address,

View File

@ -2,7 +2,7 @@ import { parseAbi } from "viem";
export { encodeMulticalls, encodeIntoMintCall } from "./helpers"; export { encodeMulticalls, encodeIntoMintCall } from "./helpers";
export const KINOMAP: `0x${string}` = "0xAfA2e57D3cBA08169b416457C14eBA2D6021c4b5"; export const KIMAP: `0x${string}` = "0xAfA2e57D3cBA08169b416457C14eBA2D6021c4b5";
export const MULTICALL: `0x${string}` = "0xcA11bde05977b3631167028862bE2a173976CA11"; export const MULTICALL: `0x${string}` = "0xcA11bde05977b3631167028862bE2a173976CA11";
export const KINO_ACCOUNT_IMPL: `0x${string}` = "0xd30217e86A4910f4D7cB3E73fC3CfD28a2C33e4e"; export const KINO_ACCOUNT_IMPL: `0x${string}` = "0xd30217e86A4910f4D7cB3E73fC3CfD28a2C33e4e";
@ -12,7 +12,7 @@ export const multicallAbi = parseAbi([
`struct Call { address target; bytes callData; }`, `struct Call { address target; bytes callData; }`,
]); ]);
export const kinomapAbi = parseAbi([ export const kimapAbi = parseAbi([
"function mint(address, bytes calldata, bytes calldata, bytes calldata, address) external returns (address tba)", "function mint(address, bytes calldata, bytes calldata, bytes calldata, address) external returns (address tba)",
"function note(bytes calldata,bytes calldata) external returns (bytes32)", "function note(bytes calldata,bytes calldata) external returns (bytes32)",
"function get(bytes32 node) external view returns (address tokenBoundAccount, address tokenOwner, bytes memory note)", "function get(bytes32 node) external view returns (address tokenBoundAccount, address tokenOwner, bytes memory note)",

View File

@ -3,7 +3,7 @@ import { useLocation } from "react-router-dom";
import { useAccount, useWriteContract, useWaitForTransactionReceipt, usePublicClient } from 'wagmi' import { useAccount, useWriteContract, useWaitForTransactionReceipt, usePublicClient } from 'wagmi'
import { ConnectButton, useConnectModal } from '@rainbow-me/rainbowkit'; import { ConnectButton, useConnectModal } from '@rainbow-me/rainbowkit';
import { keccak256, toBytes } from 'viem'; import { keccak256, toBytes } from 'viem';
import { mechAbi, KINOMAP, encodeIntoMintCall, encodeMulticalls, kinomapAbi, MULTICALL } from "../abis"; import { mechAbi, KIMAP, encodeIntoMintCall, encodeMulticalls, kimapAbi, MULTICALL } from "../abis";
import { kinohash } from '../utils/kinohash'; import { kinohash } from '../utils/kinohash';
import useAppsStore from "../store"; import useAppsStore from "../store";
import { AppInfo } from "../types/Apps"; import { AppInfo } from "../types/Apps";
@ -71,8 +71,8 @@ export default function PublishPage() {
try { try {
// Check if the package already exists and get its TBA // Check if the package already exists and get its TBA
let data = await publicClient.readContract({ let data = await publicClient.readContract({
abi: kinomapAbi, abi: kimapAbi,
address: KINOMAP, address: KIMAP,
functionName: 'get', functionName: 'get',
args: [kinohash(`${packageName}.${publisherId}`)] args: [kinohash(`${packageName}.${publisherId}`)]
}); });
@ -84,8 +84,8 @@ export default function PublishPage() {
// If the package doesn't exist, check for the publisher's TBA // If the package doesn't exist, check for the publisher's TBA
if (!currentTBA) { if (!currentTBA) {
data = await publicClient.readContract({ data = await publicClient.readContract({
abi: kinomapAbi, abi: kimapAbi,
address: KINOMAP, address: KIMAP,
functionName: 'get', functionName: 'get',
args: [kinohash(publisherId)] args: [kinohash(publisherId)]
}); });
@ -108,10 +108,10 @@ export default function PublishPage() {
writeContract({ writeContract({
abi: mechAbi, abi: mechAbi,
address: currentTBA || KINOMAP, address: currentTBA || KIMAP,
functionName: 'execute', functionName: 'execute',
args: [ args: [
isUpdate ? MULTICALL : KINOMAP, isUpdate ? MULTICALL : KIMAP,
BigInt(0), BigInt(0),
args, args,
isUpdate ? 1 : 0 isUpdate ? 1 : 0
@ -141,8 +141,8 @@ export default function PublishPage() {
} }
const data = await publicClient.readContract({ const data = await publicClient.readContract({
abi: kinomapAbi, abi: kimapAbi,
address: KINOMAP, address: KIMAP,
functionName: 'get', functionName: 'get',
args: [kinohash(`${packageName}.${publisherName}`)] args: [kinohash(`${packageName}.${publisherName}`)]
}); });
@ -161,7 +161,7 @@ export default function PublishPage() {
address: tba as `0x${string}`, address: tba as `0x${string}`,
functionName: 'execute', functionName: 'execute',
args: [ args: [
KINOMAP, KIMAP,
BigInt(0), BigInt(0),
multicall, multicall,
1 1

View File

@ -2,7 +2,7 @@
import { NetworkingInfo } from "../lib/types"; import { NetworkingInfo } from "../lib/types";
import { kinohash } from "../utils/kinohash"; import { kinohash } from "../utils/kinohash";
import { ipToBytes, portToBytes } from "../utils/kns_encoding"; import { ipToBytes, portToBytes } from "../utils/kns_encoding";
import { multicallAbi, kinomapAbi, mechAbi, KINOMAP, MULTICALL } from "./"; import { multicallAbi, kimapAbi, mechAbi, KIMAP, MULTICALL } from "./";
import { encodeFunctionData, encodePacked, stringToHex, bytesToHex } from "viem"; import { encodeFunctionData, encodePacked, stringToHex, bytesToHex } from "viem";
// Function to encode router names into keccak256 hashes // Function to encode router names into keccak256 hashes
@ -58,7 +58,7 @@ export const generateNetworkingKeys = async ({
console.log("networking_key: ", networking_key); console.log("networking_key: ", networking_key);
const netkeycall = encodeFunctionData({ const netkeycall = encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~net-key")]), encodePacked(["bytes"], [stringToHex("~net-key")]),
@ -68,7 +68,7 @@ export const generateNetworkingKeys = async ({
const ws_port_call = const ws_port_call =
encodeFunctionData({ encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~ws-port")]), encodePacked(["bytes"], [stringToHex("~ws-port")]),
@ -78,7 +78,7 @@ export const generateNetworkingKeys = async ({
const tcp_port_call = const tcp_port_call =
encodeFunctionData({ encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~tcp-port")]), encodePacked(["bytes"], [stringToHex("~tcp-port")]),
@ -88,7 +88,7 @@ export const generateNetworkingKeys = async ({
const ip_address_call = const ip_address_call =
encodeFunctionData({ encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~ip")]), encodePacked(["bytes"], [stringToHex("~ip")]),
@ -100,7 +100,7 @@ export const generateNetworkingKeys = async ({
const router_call = const router_call =
encodeFunctionData({ encodeFunctionData({
abi: kinomapAbi, abi: kimapAbi,
functionName: 'note', functionName: 'note',
args: [ args: [
encodePacked(["bytes"], [stringToHex("~routers")]), encodePacked(["bytes"], [stringToHex("~routers")]),
@ -111,13 +111,13 @@ export const generateNetworkingKeys = async ({
}); });
const calls = direct ? [ const calls = direct ? [
{ target: KINOMAP, callData: netkeycall }, { target: KIMAP, callData: netkeycall },
{ target: KINOMAP, callData: ws_port_call }, { target: KIMAP, callData: ws_port_call },
{ target: KINOMAP, callData: tcp_port_call }, { target: KIMAP, callData: tcp_port_call },
{ target: KINOMAP, callData: ip_address_call }, { target: KIMAP, callData: ip_address_call },
] : [ ] : [
{ target: KINOMAP, callData: netkeycall }, { target: KIMAP, callData: netkeycall },
{ target: KINOMAP, callData: router_call }, { target: KIMAP, callData: router_call },
]; ];
const multicalls = encodeFunctionData({ const multicalls = encodeFunctionData({
@ -143,7 +143,7 @@ export const generateNetworkingKeys = async ({
// to mint a subname of your own, you would do something like this. // to mint a subname of your own, you would do something like this.
// const mintCall = encodeFunctionData({ // const mintCall = encodeFunctionData({
// abi: kinomapAbi, // abi: kimapAbi,
// functionName: 'mint', // functionName: 'mint',
// args: [ // args: [
// our_address, // our_address,

View File

@ -3,7 +3,7 @@ import { parseAbi } from "viem";
export { generateNetworkingKeys } from "./helpers"; export { generateNetworkingKeys } from "./helpers";
// move to constants? // also for anvil/optimism // move to constants? // also for anvil/optimism
export const KINOMAP: `0x${string}` = "0xcA92476B2483aBD5D82AEBF0b56701Bb2e9be658"; export const KIMAP: `0x${string}` = "0xcA92476B2483aBD5D82AEBF0b56701Bb2e9be658";
export const MULTICALL: `0x${string}` = "0xcA11bde05977b3631167028862bE2a173976CA11"; export const MULTICALL: `0x${string}` = "0xcA11bde05977b3631167028862bE2a173976CA11";
export const KINO_ACCOUNT_IMPL: `0x${string}` = "0x38766C70a4FB2f23137D9251a1aA12b1143fC716"; export const KINO_ACCOUNT_IMPL: `0x${string}` = "0x38766C70a4FB2f23137D9251a1aA12b1143fC716";
export const DOTOS: `0x${string}` = "0x9BD054E4c7753791FA0C138b9713319F62ed235D"; export const DOTOS: `0x${string}` = "0x9BD054E4c7753791FA0C138b9713319F62ed235D";
@ -13,7 +13,7 @@ export const multicallAbi = parseAbi([
`struct Call { address target; bytes callData; }`, `struct Call { address target; bytes callData; }`,
]); ]);
export const kinomapAbi = parseAbi([ export const kimapAbi = parseAbi([
"function mint(address, bytes calldata, bytes calldata, bytes calldata, address) external returns (address tba)", "function mint(address, bytes calldata, bytes calldata, bytes calldata, address) external returns (address tba)",
"function note(bytes calldata,bytes calldata) external returns (bytes32)", "function note(bytes calldata,bytes calldata) external returns (bytes32)",
"function get(bytes32 node) external view returns (address tokenBoundAccount, address tokenOwner, bytes memory note)", "function get(bytes32 node) external view returns (address tokenBoundAccount, address tokenOwner, bytes memory note)",

View File

@ -3,7 +3,7 @@ import isValidDomain from "is-valid-domain";
import { toAscii } from "idna-uts46-hx"; import { toAscii } from "idna-uts46-hx";
import { usePublicClient } from 'wagmi' import { usePublicClient } from 'wagmi'
import { KINOMAP, kinomapAbi } from '../abis' import { KIMAP, kimapAbi } from '../abis'
import { kinohash } from "../utils/kinohash"; import { kinohash } from "../utils/kinohash";
export const NAME_URL = "Name must contain only valid characters (a-z, 0-9, and -)"; export const NAME_URL = "Name must contain only valid characters (a-z, 0-9, and -)";
@ -80,8 +80,8 @@ function EnterKnsName({
// maybe separate into helper function for readability? // maybe separate into helper function for readability?
// also note picking the right chain ID & address! // also note picking the right chain ID & address!
const data = await client?.readContract({ const data = await client?.readContract({
address: KINOMAP, address: KIMAP,
abi: kinomapAbi, abi: kimapAbi,
functionName: "get", functionName: "get",
args: [namehash] args: [namehash]
}) })

View File

@ -102,7 +102,7 @@ function CommitDotOsName({
<> <>
<h3 className="form-label"> <h3 className="form-label">
<Tooltip text="Kinodes need an onchain node identity in order to communicate with other nodes in the network."> <Tooltip text="Kinodes need an onchain node identity in order to communicate with other nodes in the network.">
Choose a name for your computer Choose a name for your node
</Tooltip> </Tooltip>
</h3> </h3>
<EnterKnsName {...enterOsNameProps} /> <EnterKnsName {...enterOsNameProps} />

View File

@ -118,13 +118,13 @@ function ImportKeyfile({
required required
minLength={6} minLength={6}
name="password" name="password"
placeholder="Min 6 characters" placeholder=""
value={pw} value={pw}
onChange={(e) => setPw(e.target.value)} onChange={(e) => setPw(e.target.value)}
/> />
{pwErr && <p className="error-message">{pwErr}</p>} {pwErr && <p className="error-message">{pwErr}</p>}
{pwDebounced && !pwVet && 6 <= pw.length && ( {pwDebounced && !pwVet && 6 <= pw.length && (
<p className="error-message">Password is incorrect</p> <p className="error-message">Password is incorrect!</p>
)} )}
</div> </div>
@ -132,7 +132,7 @@ function ImportKeyfile({
{keyErrs.map((x, i) => ( {keyErrs.map((x, i) => (
<p key={i} className="error-message">{x}</p> <p key={i} className="error-message">{x}</p>
))} ))}
<button type="submit" className="button">Import Keyfile</button> <button type="submit" className="button">Boot Node</button>
</div> </div>
<p className="text-sm mt-2"> <p className="text-sm mt-2">
Please note: if the original node was booted as a direct node Please note: if the original node was booted as a direct node

View File

@ -32,7 +32,7 @@ function KinodeHome({ knsName }: OsHomeProps) {
) : ( ) : (
<> <>
<h2 className="text-center mb-2">Welcome to Kinode</h2> <h2 className="text-center mb-2">Welcome to Kinode</h2>
<h4 className="text-center mb-2">New here? Register a username to get started</h4> <h4 className="text-center mb-2">New here? Register a name to get started</h4>
<div className="button-group"> <div className="button-group">
<button onClick={registerRedir} className="button"> <button onClick={registerRedir} className="button">
Register .os Name Register .os Name
@ -40,14 +40,14 @@ function KinodeHome({ knsName }: OsHomeProps) {
</div> </div>
<h4 className="text-center mt-2 mb-2">Other options</h4> <h4 className="text-center mt-2 mb-2">Other options</h4>
<div className="button-group"> <div className="button-group">
<button onClick={resetRedir} className="button secondary">
Reset Kinode Name
</button>
<button onClick={importKeyfileRedir} className="button secondary"> <button onClick={importKeyfileRedir} className="button secondary">
Import Keyfile Import Keyfile
</button> </button>
<button onClick={resetRedir} className="button secondary">
Reset Existing Name
</button>
<button onClick={customRegisterRedir} className="button secondary"> <button onClick={customRegisterRedir} className="button secondary">
Register non-.os Name (Advanced) Register Non-.os Name (Advanced)
</button> </button>
</div> </div>
</> </>

View File

@ -122,7 +122,7 @@ function Login({
className="secondary" className="secondary"
onClick={() => navigate('/reset')} onClick={() => navigate('/reset')}
> >
Reset Node & Networking Info Reset Password & Networking Info
</button> </button>
</div> </div>
</form> </form>

View File

@ -125,6 +125,9 @@ function MintCustom({
<Loader msg={isConfirming ? 'Minting name...' : 'Please confirm the transaction in your wallet'} /> <Loader msg={isConfirming ? 'Minting name...' : 'Please confirm the transaction in your wallet'} />
) : ( ) : (
<> <>
<p className="form-label">
Register a name on a different top-level zone -- this will likely fail if that zone's requirements are not met
</p>
<input type="text" name="name" placeholder="Enter kimap name" /> <input type="text" name="name" placeholder="Enter kimap name" />
<input type="text" name="full-kns-name" placeholder="Enter full KNS name" /> <input type="text" name="full-kns-name" placeholder="Enter full KNS name" />
<input type="text" name="tba" placeholder="Enter TBA to mint under" /> <input type="text" name="tba" placeholder="Enter TBA to mint under" />

View File

@ -116,19 +116,19 @@ function MintDotOsName({
{ {
<form className="form" onSubmit={handleMint}> <form className="form" onSubmit={handleMint}>
{isPending || isConfirming ? ( {isPending || isConfirming ? (
<Loader msg={isConfirming ? 'Minting .os name...' : 'Please confirm the transaction in your wallet'} /> <Loader msg={isConfirming ? 'Minting name...' : 'Please confirm the transaction in your wallet'} />
) : ( ) : (
<> <>
<div className="button-group"> <div className="button-group">
<button type="submit" className="button"> <button type="submit" className="button">
Mint pre-committed .os name Mint name {knsName}
</button> </button>
</div> </div>
</> </>
)} )}
{isError && ( {isError && (
<p className="error-message"> <p className="error-message">
Error: {error?.message || 'There was an error minting your dot-os-name, please try again.'} Error: {error?.message || 'There was an error minting your name, please try again.'}
</p> </p>
)} )}
</form> </form>

View File

@ -4,7 +4,7 @@ import { downloadKeyfile } from "../utils/download-keyfile";
import { Tooltip } from "../components/Tooltip"; import { Tooltip } from "../components/Tooltip";
import { sha256, toBytes } from "viem"; import { sha256, toBytes } from "viem";
import { useSignTypedData, useAccount, useChainId } from 'wagmi' import { useSignTypedData, useAccount, useChainId } from 'wagmi'
import { KINOMAP } from "../abis"; import { KIMAP } from "../abis";
type SetPasswordProps = { type SetPasswordProps = {
direct: boolean; direct: boolean;
@ -61,7 +61,7 @@ function SetPassword({
name: "Kimap", name: "Kimap",
version: "1", version: "1",
chainId: chainId, chainId: chainId,
verifyingContract: KINOMAP, verifyingContract: KIMAP,
}, },
types: { types: {
Boot: [ Boot: [
@ -131,8 +131,8 @@ function SetPassword({
) : ( ) : (
<form className="form" onSubmit={handleSubmit}> <form className="form" onSubmit={handleSubmit}>
<div className="form-group"> <div className="form-group">
<Tooltip text="This password will be used to log in if you restart your node or switch browsers."> <Tooltip text="This password will be used to log in when you restart your node or switch browsers.">
<label className="form-label" htmlFor="password">New Password</label> <label className="form-label" htmlFor="password">Set Password</label>
</Tooltip> </Tooltip>
<input <input
type="password" type="password"
@ -140,7 +140,7 @@ function SetPassword({
required required
minLength={6} minLength={6}
name="password" name="password"
placeholder="Min 6 characters" placeholder="6 characters minimum"
value={pw} value={pw}
onChange={(e) => setPw(e.target.value)} onChange={(e) => setPw(e.target.value)}
autoFocus autoFocus
@ -154,7 +154,7 @@ function SetPassword({
required required
minLength={6} minLength={6}
name="confirm-password" name="confirm-password"
placeholder="Min 6 characters" placeholder="6 characters minimum"
value={pw2} value={pw2}
onChange={(e) => setPw2(e.target.value)} onChange={(e) => setPw2(e.target.value)}
/> />