Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Jun 13, 2024
1 parent 59dbada commit b1fbc2a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Deed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Button, Card, Typography } from "@ensdomains/thorin";
import { type Address, type Hex, encodeFunctionData, formatEther, getAddress } from "viem";
import { useAccount, useEnsName, usePrepareTransactionRequest, useSendTransaction, useWaitForTransactionReceipt } from "wagmi";
import {
useAccount,
useEnsName,
usePrepareTransactionRequest,
useSendTransaction,
useWaitForTransactionReceipt,
} from "wagmi";
import { registrarAbi } from "./abis/registrar";
import { REGISTRAR_ADDRESS } from "./constants";

Expand Down Expand Up @@ -33,7 +39,7 @@ export const DeedComponent = ({ id, name, value, owner, isExact }: Props) => {

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

const { data: transactionReceipt } = useWaitForTransactionReceipt({ hash })
const { data: transactionReceipt } = useWaitForTransactionReceipt({ hash });

const claim = () => preparedRequest && sendTransaction({ ...preparedRequest, to: REGISTRAR_ADDRESS });

Expand All @@ -45,17 +51,19 @@ export const DeedComponent = ({ id, name, value, owner, isExact }: Props) => {
if (!isMatchingOwner) return { disabled: true, children: "Cannot claim" } as const;

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

if (isPending) return { disabled: true, children: "Waiting for wallet", loading: true } as const;
if (transactionReceipt) {
if (transactionReceipt.status === 'reverted') return { disabled: false, children: "Try again", onClick: () => claim(), colorStyle: "redPrimary" } as const;
if (transactionReceipt.status === "reverted")
return { disabled: false, children: "Try again", onClick: () => claim(), colorStyle: "redPrimary" } as const;
return { disabled: true, children: "Claimed" } as const;
}
if (hash) return { disabled: true, children: "Claiming", loading: true } as const;

return { disabled: false, children: "Claim", onClick: () => claim(), colorStyle: "accentPrimary" } as const;
})()
})();

return (
<Card className="deed-card">
Expand Down

0 comments on commit b1fbc2a

Please sign in to comment.