Skip to content

Commit

Permalink
Fixed some linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vinay kharayat committed Oct 8, 2023
1 parent e4b9c00 commit 6663d84
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/app/components/eventTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useEffect, useState } from "react";
import IUniswap from "../interfaces/IUniswap";

export default function EventTable({ updateTableData }) {
export default function EventTable({
updateTableData,
}: {
updateTableData: IUniswap[];
}) {
useEffect(() => {
console.log("updateTableData", updateTableData);
}, [updateTableData]);
Expand Down
13 changes: 9 additions & 4 deletions src/app/components/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { mainnet, sepolia, useContractEvent, useContractRead } from "wagmi";
import getAbi from "../utils/getAbi";
import { setTimeout } from "timers";
import { formatEther } from "viem";
import IUniswap from "../interfaces/IUniswap";

export default function Form({ memoizedUpdateTableData }) {
export default function Form({
memoizedUpdateTableData,
}: {
memoizedUpdateTableData: (newData: IUniswap) => void;
}) {
const [tokenA, setTokenA] = useState<string>("");
const [tokenB, setTokenB] = useState<string>(
"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
Expand All @@ -23,7 +28,7 @@ export default function Form({ memoizedUpdateTableData }) {
const [chainId, setChainId] = useState<number>(mainnet.id);

const getPoolFunc = useContractRead({
address: uniswapFactoryAddress,
address: uniswapFactoryAddress as `0x${string}`,
abi: uniswapFactoryAbi,
functionName: "getPool",
args: [tokenA, tokenB, poolFee],
Expand Down Expand Up @@ -82,9 +87,9 @@ export default function Form({ memoizedUpdateTableData }) {
address: poolAddress,
abi: poolAbi,
eventName: event,
listener(log) {
listener(log: any[]) {
console.log("Event:", log);
const data = {
const data: IUniswap = {
id: log[0].logIndex,
poolAddress: log[0].address,
amountTokenA: formatEther(log[0].args.amount0, "wei"),
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/modals/howTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function HowToModal() {
</li>
<li className="list-item">Select the network type</li>
<li className="list-item">Select the pool fees</li>
<li className="list-item">Click on "Start listening" button</li>
<li className="list-item">
Click on <q>Start listening</q> button
</li>
</ol>
</div>
<div className="modal-action">
Expand Down
42 changes: 36 additions & 6 deletions src/app/components/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ export default function Navigation() {
className="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"
>
<li>
<a onClick={() => document.getElementById("how-to").showModal()}>
<a
onClick={() =>
(
document.getElementById("how-to") as HTMLDialogElement
).showModal()
}
>
How to
</a>
</li>
Expand All @@ -49,7 +55,11 @@ export default function Navigation() {
<li>
<a
onClick={() =>
document.getElementById("about-chain-event").showModal()
(
document.getElementById(
"about-chain-event"
) as HTMLDialogElement
).showModal()
}
>
About chain event
Expand All @@ -58,7 +68,11 @@ export default function Navigation() {

<li>
<a
onClick={() => document.getElementById("about-me").showModal()}
onClick={() =>
(
document.getElementById("about-me") as HTMLDialogElement
).showModal()
}
>
Contact
</a>
Expand All @@ -70,7 +84,13 @@ export default function Navigation() {
<div className="navbar-center hidden lg:flex">
<ul className="menu menu-horizontal px-1">
<li>
<a onClick={() => document.getElementById("how-to").showModal()}>
<a
onClick={() =>
(
document.getElementById("how-to") as HTMLDialogElement
).showModal()
}
>
How to
</a>
</li>
Expand All @@ -91,15 +111,25 @@ export default function Navigation() {
<li>
<a
onClick={() =>
document.getElementById("about-chain-event").showModal()
(
document.getElementById(
"about-chain-event"
) as HTMLDialogElement
).showModal()
}
>
About chain event
</a>
</li>

<li>
<a onClick={() => document.getElementById("about-me").showModal()}>
<a
onClick={() =>
(
document.getElementById("about-me") as HTMLDialogElement
).showModal()
}
>
Contact
</a>
</li>
Expand Down
9 changes: 5 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { useMemo, useState } from "react";
import Navigation from "./components/navigation";
import { configureChains, createConfig, mainnet } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import IUniswap from "./interfaces/IUniswap";

export default function Home() {
const [data, setData] = useState<Object[]>([]);
const [data, setData] = useState<IUniswap[]>([]);

const { chains, publicClient, webSocketPublicClient } = configureChains(
const { publicClient, webSocketPublicClient } = configureChains(
[mainnet, sepolia],
[publicProvider()]
);
Expand All @@ -22,8 +23,8 @@ export default function Home() {
webSocketPublicClient,
});

const memoizedUpdateTableData = useMemo(() => {
return (newData: Object) => {
const memoizedUpdateTableData: (newData: IUniswap) => void = useMemo(() => {
return (newData: IUniswap) => {
setData([...data, newData]);
};
}, [data]);
Expand Down

0 comments on commit 6663d84

Please sign in to comment.