mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
produce mint transaction manually
This commit is contained in:
parent
f5cc1371d4
commit
8f81279535
4927
kinode/src/register-ui/package-lock.json
generated
4927
kinode/src/register-ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,8 +17,8 @@
|
|||||||
"react-icons": "^5.0.1",
|
"react-icons": "^5.0.1",
|
||||||
"react-modal": "^3.16.1",
|
"react-modal": "^3.16.1",
|
||||||
"react-router-dom": "^6.16.0",
|
"react-router-dom": "^6.16.0",
|
||||||
"viem": "^2.15.1",
|
"viem": "^2.19.0",
|
||||||
"wagmi": "^2.10.3"
|
"wagmi": "^2.12.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
@ -25,8 +25,28 @@ export const mechAbi = parseAbi([
|
|||||||
"function token() external view returns (uint256,address,uint256)"
|
"function token() external view returns (uint256,address,uint256)"
|
||||||
])
|
])
|
||||||
|
|
||||||
export const dotOsAbi = parseAbi([
|
export const dotOsAbi = [
|
||||||
"function commit(bytes32)",
|
{
|
||||||
"function getCommit(bytes memory, bytes32)",
|
type: 'function',
|
||||||
"function mint(address,bytes,bytes,bytes,address,bytes32)",
|
name: 'commit',
|
||||||
])
|
stateMutability: 'nonpayable',
|
||||||
|
inputs: [
|
||||||
|
{ name: '_commit', type: 'bytes32' },
|
||||||
|
],
|
||||||
|
outputs: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'function',
|
||||||
|
name: 'mint',
|
||||||
|
stateMutability: 'nonpayable',
|
||||||
|
inputs: [
|
||||||
|
{ name: 'who', type: 'address' },
|
||||||
|
{ name: 'name', type: 'bytes' },
|
||||||
|
{ name: 'initialization', type: 'bytes' },
|
||||||
|
{ name: 'erc721Data', type: 'bytes' },
|
||||||
|
{ name: 'implementation', type: 'address' },
|
||||||
|
{ name: 'secret', type: 'bytes32' },
|
||||||
|
],
|
||||||
|
outputs: [{ type: 'address' }],
|
||||||
|
},
|
||||||
|
] as const
|
@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
background-color: var(--tasteful-dark);
|
background-color: light-dark(var(--off-white), var(--tasteful-dark));
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
@ -3,10 +3,10 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import Loader from "../components/Loader";
|
import Loader from "../components/Loader";
|
||||||
import { PageProps } from "../lib/types";
|
import { PageProps } from "../lib/types";
|
||||||
|
|
||||||
import { useAccount, useWaitForTransactionReceipt, useWriteContract } 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, getFunctionSelector, stringToHex } from "viem";
|
import { encodePacked, parseAbi, encodeFunctionData, stringToHex } from "viem";
|
||||||
|
|
||||||
interface RegisterOsNameProps extends PageProps { }
|
interface RegisterOsNameProps extends PageProps { }
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ function MintDotOsName({
|
|||||||
let navigate = useNavigate();
|
let navigate = useNavigate();
|
||||||
let { openConnectModal } = useConnectModal();
|
let { openConnectModal } = useConnectModal();
|
||||||
|
|
||||||
const { data: hash, writeContract, isPending, isError, error } = useWriteContract({
|
const { data: hash, sendTransaction, isPending, isError, error } = useSendTransaction({
|
||||||
mutation: {
|
mutation: {
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
addRecentTransaction({ hash: data, description: `Mint ${knsName}` });
|
addRecentTransaction({ hash: data, description: `Mint ${knsName}` });
|
||||||
@ -71,13 +71,12 @@ function MintDotOsName({
|
|||||||
// strip .os suffix
|
// strip .os suffix
|
||||||
const name = knsName.replace(/\.os$/, '');
|
const name = knsName.replace(/\.os$/, '');
|
||||||
|
|
||||||
const selector = getFunctionSelector('function mint(address,bytes,bytes,bytes,address,bytes32)')
|
const abi = parseAbi([
|
||||||
|
'function mint(address,bytes,bytes,bytes,address,bytes32)',
|
||||||
|
])
|
||||||
|
|
||||||
console.log("selector: ", selector)
|
const data = encodeFunctionData({
|
||||||
|
abi,
|
||||||
writeContract({
|
|
||||||
abi: dotOsAbi,
|
|
||||||
address: DOTOS,
|
|
||||||
functionName: 'mint',
|
functionName: 'mint',
|
||||||
args: [
|
args: [
|
||||||
address,
|
address,
|
||||||
@ -87,10 +86,26 @@ function MintDotOsName({
|
|||||||
KINO_ACCOUNT_IMPL,
|
KINO_ACCOUNT_IMPL,
|
||||||
commitSecret
|
commitSecret
|
||||||
],
|
],
|
||||||
gas: 1000000n,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}, [direct, address, writeContract, setNetworkingKey, setIpAddress, setWsPort, setTcpPort, setRouters, openConnectModal])
|
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
|
||||||
|
try {
|
||||||
|
sendTransaction({
|
||||||
|
to: DOTOS,
|
||||||
|
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])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isConfirmed) {
|
if (isConfirmed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user