Skip to content

Commit

Permalink
only 1 prepared at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Jun 27, 2024
1 parent bc93737 commit 7d206fd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Deed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isEncodedLabelhash, truncateFormat } from "@ensdomains/ensjs/utils";
import { Button, Card, Typography } from "@ensdomains/thorin";
import { useQueryClient } from "@tanstack/react-query";
import { type Address, type Hex, encodeFunctionData, formatEther, getAddress } from "viem";
import {
useAccount,
Expand All @@ -20,6 +21,7 @@ type Props = {
};

export const DeedComponent = ({ id, name, value, owner, isExact }: Props) => {
const queryClient = useQueryClient();
const label = `${isExact ? "Exact Match: " : ""}${name}`;
const formattedEth = formatEther(value);
const { data: primaryName } = useEnsName({ address: owner });
Expand All @@ -38,6 +40,14 @@ export const DeedComponent = ({ id, name, value, owner, isExact }: Props) => {
query: { enabled: false },
});

const prepare = () => {
queryClient.resetQueries({
queryKey: ["prepareTransactionRequest"],
exact: false,
});
refetch();
};

const { sendTransaction, isPending, data: hash } = useSendTransaction();

const { data: transactionReceipt } = useWaitForTransactionReceipt({ hash });
Expand All @@ -53,7 +63,7 @@ export const DeedComponent = ({ id, name, value, owner, isExact }: Props) => {

if (isPrepareLoading) return { disabled: true, children: "Preparing", loading: true } as const;
if (!preparedRequest)
return { disabled: false, children: "Prepare", onClick: () => refetch(), colorStyle: "accentSecondary" } as const;
return { disabled: false, children: "Prepare", onClick: prepare, colorStyle: "accentSecondary" } as const;

if (isPending) return { disabled: true, children: "Waiting for wallet", loading: true } as const;
if (transactionReceipt) {
Expand Down

0 comments on commit 7d206fd

Please sign in to comment.