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 { 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 (
|
||||
|
@ -23,7 +23,6 @@ export interface PageProps {
|
||||
setPw: React.Dispatch<React.SetStateAction<string>>,
|
||||
appSizeOnLoad: number,
|
||||
nodeChainId: string,
|
||||
commitSecret: `0x${string}`,
|
||||
}
|
||||
|
||||
export type NetworkingInfo = {
|
||||
|
@ -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,
|
||||
})
|
||||
|
||||
|
@ -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])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user