mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 00:21:38 +03:00
mint WORKING
This commit is contained in:
parent
8f81279535
commit
6b47043ffd
@ -10,9 +10,6 @@ import KinodeHome from "./pages/KinodeHome"
|
|||||||
import ImportKeyfile from "./pages/ImportKeyfile";
|
import ImportKeyfile from "./pages/ImportKeyfile";
|
||||||
import { UnencryptedIdentity } from "./lib/types";
|
import { UnencryptedIdentity } from "./lib/types";
|
||||||
import Header from "./components/Header";
|
import Header from "./components/Header";
|
||||||
import { bytesToHex } from "viem";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
@ -38,8 +35,6 @@ function App() {
|
|||||||
const openConnect = () => setConnectOpen(true)
|
const openConnect = () => setConnectOpen(true)
|
||||||
const closeConnect = () => setConnectOpen(false)
|
const closeConnect = () => setConnectOpen(false)
|
||||||
|
|
||||||
const commitSecret = bytesToHex(crypto.getRandomValues(new Uint8Array(32)))
|
|
||||||
|
|
||||||
useEffect(() => setAppSizeOnLoad(
|
useEffect(() => setAppSizeOnLoad(
|
||||||
(window.performance.getEntriesByType('navigation') as any)[0].transferSize
|
(window.performance.getEntriesByType('navigation') as any)[0].transferSize
|
||||||
), []);
|
), []);
|
||||||
@ -100,7 +95,6 @@ function App() {
|
|||||||
tcp_port, setTcpPort,
|
tcp_port, setTcpPort,
|
||||||
routers, setRouters,
|
routers, setRouters,
|
||||||
nodeChainId,
|
nodeChainId,
|
||||||
commitSecret,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -23,7 +23,6 @@ export interface PageProps {
|
|||||||
setPw: React.Dispatch<React.SetStateAction<string>>,
|
setPw: React.Dispatch<React.SetStateAction<string>>,
|
||||||
appSizeOnLoad: number,
|
appSizeOnLoad: number,
|
||||||
nodeChainId: string,
|
nodeChainId: string,
|
||||||
commitSecret: `0x${string}`,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NetworkingInfo = {
|
export type NetworkingInfo = {
|
||||||
|
@ -23,7 +23,6 @@ function CommitDotOsName({
|
|||||||
setWsPort,
|
setWsPort,
|
||||||
setTcpPort,
|
setTcpPort,
|
||||||
setRouters,
|
setRouters,
|
||||||
commitSecret,
|
|
||||||
}: RegisterOsNameProps) {
|
}: RegisterOsNameProps) {
|
||||||
let { address } = useAccount();
|
let { address } = useAccount();
|
||||||
let navigate = useNavigate();
|
let navigate = useNavigate();
|
||||||
@ -62,18 +61,18 @@ function CommitDotOsName({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log("committing to .os name: ", name)
|
console.log("committing to .os name: ", name)
|
||||||
|
const commitSecret = keccak256(stringToHex(name))
|
||||||
|
const commit = keccak256(
|
||||||
|
encodeAbiParameters(
|
||||||
|
parseAbiParameters('bytes32, bytes32'),
|
||||||
|
[keccak256(stringToHex(name)), commitSecret]
|
||||||
|
)
|
||||||
|
)
|
||||||
writeContract({
|
writeContract({
|
||||||
abi: dotOsAbi,
|
abi: dotOsAbi,
|
||||||
address: DOTOS,
|
address: DOTOS,
|
||||||
functionName: 'commit',
|
functionName: 'commit',
|
||||||
args: [
|
args: [commit],
|
||||||
keccak256(
|
|
||||||
encodeAbiParameters(
|
|
||||||
parseAbiParameters('bytes memory, bytes32'),
|
|
||||||
[keccak256(stringToHex(name)), commitSecret]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
gas: 1000000n,
|
gas: 1000000n,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { PageProps } from "../lib/types";
|
|||||||
import { useAccount, useWaitForTransactionReceipt, useSendTransaction } from "wagmi";
|
import { useAccount, useWaitForTransactionReceipt, useSendTransaction } from "wagmi";
|
||||||
import { useConnectModal, useAddRecentTransaction } from "@rainbow-me/rainbowkit"
|
import { useConnectModal, useAddRecentTransaction } from "@rainbow-me/rainbowkit"
|
||||||
import { dotOsAbi, generateNetworkingKeys, KINO_ACCOUNT_IMPL, DOTOS } from "../abis";
|
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 { }
|
interface RegisterOsNameProps extends PageProps { }
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ function MintDotOsName({
|
|||||||
setWsPort,
|
setWsPort,
|
||||||
setTcpPort,
|
setTcpPort,
|
||||||
setRouters,
|
setRouters,
|
||||||
commitSecret,
|
|
||||||
}: RegisterOsNameProps) {
|
}: RegisterOsNameProps) {
|
||||||
let { address } = useAccount();
|
let { address } = useAccount();
|
||||||
let navigate = useNavigate();
|
let navigate = useNavigate();
|
||||||
@ -70,13 +69,10 @@ function MintDotOsName({
|
|||||||
|
|
||||||
// strip .os suffix
|
// strip .os suffix
|
||||||
const name = knsName.replace(/\.os$/, '');
|
const name = knsName.replace(/\.os$/, '');
|
||||||
|
const commitSecret = keccak256(stringToHex(name))
|
||||||
const abi = parseAbi([
|
|
||||||
'function mint(address,bytes,bytes,bytes,address,bytes32)',
|
|
||||||
])
|
|
||||||
|
|
||||||
const data = encodeFunctionData({
|
const data = encodeFunctionData({
|
||||||
abi,
|
abi: dotOsAbi,
|
||||||
functionName: 'mint',
|
functionName: 'mint',
|
||||||
args: [
|
args: [
|
||||||
address,
|
address,
|
||||||
@ -88,8 +84,6 @@ function MintDotOsName({
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("data: ", data)
|
|
||||||
|
|
||||||
// use data to write to contract -- do NOT use writeContract
|
// use data to write to contract -- do NOT use writeContract
|
||||||
// writeContract will NOT generate the correct selector for some reason
|
// writeContract will NOT generate the correct selector for some reason
|
||||||
// probably THEIR bug.. no abi works
|
// probably THEIR bug.. no abi works
|
||||||
@ -99,11 +93,8 @@ function MintDotOsName({
|
|||||||
data: data,
|
data: data,
|
||||||
gas: 1000000n,
|
gas: 1000000n,
|
||||||
})
|
})
|
||||||
console.log('Transaction sent?')
|
|
||||||
// You might want to add some state management here to track the transaction
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to send transaction:', 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])
|
}, [direct, address, sendTransaction, setNetworkingKey, setIpAddress, setWsPort, setTcpPort, setRouters, openConnectModal])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user