diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 00000000..208f9a12
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,2 @@
+pnpm format:check
+pnpm lint
diff --git a/.husky/pre-push b/.husky/pre-push
new file mode 100644
index 00000000..d709394c
--- /dev/null
+++ b/.husky/pre-push
@@ -0,0 +1 @@
+pnpm typecheck
\ No newline at end of file
diff --git a/components/Approve/index.tsx b/components/Approve/index.tsx
index 9bc33665..2a0c586d 100644
--- a/components/Approve/index.tsx
+++ b/components/Approve/index.tsx
@@ -25,7 +25,7 @@ const Index = () => {
useHandleTransaction("approve", data, error, isPending, isSuccess, {
type: "approve",
- amount: MAXIMUM_VALUE_UINT256,
+ amount: BigInt(MAXIMUM_VALUE_UINT256),
});
return (
diff --git a/components/DelegatingView/index.tsx b/components/DelegatingView/index.tsx
index fe793fa8..80d75e68 100644
--- a/components/DelegatingView/index.tsx
+++ b/components/DelegatingView/index.tsx
@@ -66,7 +66,7 @@ const Index = ({ delegator, transcoders, protocol, currentRound }: Props) => {
useHandleTransaction("withdrawFees", data, error, isPending, isSuccess, {
recipient,
- amount,
+ amount: BigInt(amount),
});
const isMyAccount = checkAddressEquality(
diff --git a/components/DelegatingWidget/Delegate.tsx b/components/DelegatingWidget/Delegate.tsx
index 302e4cae..e2f639b6 100644
--- a/components/DelegatingWidget/Delegate.tsx
+++ b/components/DelegatingWidget/Delegate.tsx
@@ -2,13 +2,13 @@ import { bondingManager } from "@lib/api/abis/main/BondingManager";
import { livepeerToken } from "@lib/api/abis/main/LivepeerToken";
import { MAXIMUM_VALUE_UINT256 } from "@lib/utils";
import { Box, Button } from "@livepeer/design-system";
-import { parseEther } from "ethers/lib/utils";
import { useHandleTransaction } from "hooks";
import {
useBondingManagerAddress,
useLivepeerTokenAddress,
} from "hooks/useContracts";
import { useMemo, useState } from "react";
+import { parseEther } from "viem";
import { useSimulateContract, useWriteContract } from "wagmi";
import ProgressSteps from "../ProgressSteps";
@@ -54,12 +54,12 @@ const Delegate = ({
approveIsSuccess,
{
type: "bond",
- amount: MAXIMUM_VALUE_UINT256,
+ amount: BigInt(MAXIMUM_VALUE_UINT256),
}
);
const bondWithHintArgs = {
- amount: amount?.toString() ? parseEther(amount) : "0",
+ amount: amount?.toString() ? parseEther(amount) : BigInt(0),
to,
oldDelegateNewPosPrev,
oldDelegateNewPosNext,
diff --git a/components/DelegatingWidget/Footer.tsx b/components/DelegatingWidget/Footer.tsx
index 961ea1b2..17691e00 100644
--- a/components/DelegatingWidget/Footer.tsx
+++ b/components/DelegatingWidget/Footer.tsx
@@ -7,7 +7,6 @@ import {
} from "@lib/utils";
import { Box, Button } from "@livepeer/design-system";
import { AccountQueryResult, OrchestratorsSortedQueryResult } from "apollo";
-import { parseEther } from "ethers/lib/utils";
import {
StakingAction,
useAccountAddress,
@@ -15,6 +14,7 @@ import {
usePendingFeesAndStakeData,
} from "hooks";
import { useMemo } from "react";
+import { parseEther } from "viem";
import Delegate from "./Delegate";
import Footnote from "./Footnote";
diff --git a/components/DelegatingWidget/Undelegate.tsx b/components/DelegatingWidget/Undelegate.tsx
index 74c6d5d1..a93367e1 100644
--- a/components/DelegatingWidget/Undelegate.tsx
+++ b/components/DelegatingWidget/Undelegate.tsx
@@ -1,8 +1,8 @@
import { bondingManager } from "@lib/api/abis/main/BondingManager";
import { Button } from "@livepeer/design-system";
-import { parseEther } from "ethers/lib/utils";
import { useAccountAddress, useHandleTransaction } from "hooks";
import { useBondingManagerAddress } from "hooks/useContracts";
+import { parseEther } from "viem";
import { useSimulateContract, useWriteContract } from "wagmi";
const Undelegate = ({ amount, newPosPrev, newPosNext, disabled }) => {
diff --git a/components/DelegatingWidget/index.tsx b/components/DelegatingWidget/index.tsx
index 7961def1..813deaf6 100644
--- a/components/DelegatingWidget/index.tsx
+++ b/components/DelegatingWidget/index.tsx
@@ -67,7 +67,7 @@ const Index = ({
[isMyTranscoder, isDelegated]
);
const currentPendingStake = Number(
- fromWei(pendingFeesAndStake?.pendingStake ?? 0)
+ fromWei(pendingFeesAndStake?.pendingStake ?? "0")
);
return (
diff --git a/components/Drawer/index.tsx b/components/Drawer/index.tsx
index e8e60a58..228970ed 100644
--- a/components/Drawer/index.tsx
+++ b/components/Drawer/index.tsx
@@ -6,8 +6,8 @@ import Router, { useRouter } from "next/router";
import { useEffect } from "react";
import Account from "../Account";
-import Logo from "../Logo";
import LlamaswapModal from "../LlamaswapModal";
+import Logo from "../Logo";
const Index = ({
items = [],
diff --git a/components/HistoryView/index.tsx b/components/HistoryView/index.tsx
index 903dda8a..6ae06c70 100644
--- a/components/HistoryView/index.tsx
+++ b/components/HistoryView/index.tsx
@@ -39,20 +39,13 @@ const Index = () => {
);
const events = useMemo(
- () =>
- data?.transactions?.reduce(
- (res, { events: e }) => res.concat(e as any),
- []
- ) ?? [],
+ () => data?.transactions?.flatMap(({ events: e }) => e ?? []) ?? [],
[data]
);
const lastEventTimestamp = useMemo(
() =>
- Number(
- (events?.[(events?.length || 0) - 1] as any)?.transaction?.timestamp ??
- 0
- ),
+ Number(events?.[(events?.length || 0) - 1]?.transaction?.timestamp ?? 0),
[events]
);
@@ -61,9 +54,7 @@ const Index = () => {
const mergedEvents = useMemo(
() =>
[
- ...events.filter(
- (e) => (e as any)?.__typename !== "WinningTicketRedeemedEvent"
- ),
+ ...events.filter((e) => e?.__typename !== "WinningTicketRedeemedEvent"),
...(data?.winningTicketRedeemedEvents?.filter(
(e) => (e?.transaction?.timestamp ?? 0) > lastEventTimestamp
) ?? []),
@@ -110,7 +101,7 @@ const Index = () => {
variables: {
skip: data.transactions.length,
},
- updateQuery: (previousResult: any, { fetchMoreResult }: any) => {
+ updateQuery: (previousResult, { fetchMoreResult }) => {
if (!fetchMoreResult) {
return previousResult;
}
@@ -139,7 +130,7 @@ const Index = () => {
}}
>
- {mergedEvents.map((event: any, i: number) => renderSwitch(event, i))}
+ {mergedEvents.map((event, i: number) => renderSwitch(event, i))}
{loading && data.transactions.length >= 10 && (
{
export default Index;
-function renderSwitch(event: any, i: number) {
+function renderSwitch(event, i: number) {
switch (event.__typename) {
case "BondEvent":
return (
diff --git a/components/LlamaswapModal/index.tsx b/components/LlamaswapModal/index.tsx
index 43f89b20..a149fa4a 100644
--- a/components/LlamaswapModal/index.tsx
+++ b/components/LlamaswapModal/index.tsx
@@ -1,8 +1,4 @@
-import {
- Dialog,
- DialogContent,
- DialogTrigger,
-} from "@livepeer/design-system";
+import { Dialog, DialogContent, DialogTrigger } from "@livepeer/design-system";
const Index = ({ trigger, children }) => {
return (
diff --git a/components/PerformanceList/index.tsx b/components/PerformanceList/index.tsx
index 59e3d963..fede2324 100644
--- a/components/PerformanceList/index.tsx
+++ b/components/PerformanceList/index.tsx
@@ -11,6 +11,7 @@ import { useAllScoreData, useEnsData } from "hooks";
import Link from "next/link";
import numbro from "numbro";
import { useMemo } from "react";
+import { Column } from "react-table";
const EmptyData = () => ;
@@ -63,17 +64,22 @@ const PerformanceList = ({
//sort double values correctly. As such, we use a custom sort function to place 0 values after
//non-zero's and before null/undefined values.
const sortTypeFn = useMemo(
- () => (rowA: any, rowB: any, columnId: string) => {
- const a = rowA.values[columnId];
- const b = rowB.values[columnId];
- if (a === null || a === undefined) return -1;
- if (b === null || b === undefined) return 1;
- return a === b ? 0 : a > b ? 1 : -1;
- },
+ () =>
+ (
+ rowA: { values: Record },
+ rowB: { values: Record },
+ columnId: string
+ ) => {
+ const a = rowA.values[columnId];
+ const b = rowB.values[columnId];
+ if (a === null || a === undefined) return -1;
+ if (b === null || b === undefined) return 1;
+ return a === b ? 0 : a > b ? 1 : -1;
+ },
[]
);
- const columns: any = useMemo(
+ const columns: Column