Skip to content

Commit 7bfc5d6

Browse files
committed
feat: add return types for functions
1 parent ddff9a5 commit 7bfc5d6

21 files changed

+76
-131
lines changed

web/src/components/DisputeCard/DisputeInfo.tsx

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { Periods } from "consts/periods";
12
import React from "react";
23
import styled from "styled-components";
3-
import { Periods } from "consts/periods";
4-
import LawBalanceIcon from "svgs/icons/law-balance.svg";
54
import BookmarkIcon from "svgs/icons/bookmark.svg";
6-
import PileCoinsIcon from "svgs/icons/pile-coins.svg";
75
import CalendarIcon from "svgs/icons/calendar.svg";
6+
import LawBalanceIcon from "svgs/icons/law-balance.svg";
7+
import PileCoinsIcon from "svgs/icons/pile-coins.svg";
88
import Field from "../Field";
99

1010
const Container = styled.div`
@@ -13,7 +13,7 @@ const Container = styled.div`
1313
gap: 8px;
1414
`;
1515

16-
const getPeriodPhrase = (period: Periods) => {
16+
const getPeriodPhrase = (period: Periods): string => {
1717
switch (period) {
1818
case Periods.evidence:
1919
return "Voting Starts";
@@ -35,36 +35,14 @@ export interface IDisputeInfo {
3535
date?: number;
3636
}
3737

38-
const DisputeInfo: React.FC<IDisputeInfo> = ({
39-
courtId,
40-
court,
41-
category,
42-
rewards,
43-
period,
44-
date,
45-
}) => {
38+
const DisputeInfo: React.FC<IDisputeInfo> = ({ courtId, court, category, rewards, period, date }) => {
4639
return (
4740
<Container>
48-
{category && (
49-
<Field icon={BookmarkIcon} name="Category" value={category} />
50-
)}
51-
{court && courtId && (
52-
<Field
53-
icon={LawBalanceIcon}
54-
name="Court"
55-
value={court}
56-
link={`/courts/${courtId}`}
57-
/>
58-
)}
59-
{rewards && (
60-
<Field icon={PileCoinsIcon} name="Juror Rewards" value={rewards} />
61-
)}
41+
{category && <Field icon={BookmarkIcon} name="Category" value={category} />}
42+
{court && courtId && <Field icon={LawBalanceIcon} name="Court" value={court} link={`/courts/${courtId}`} />}
43+
{rewards && <Field icon={PileCoinsIcon} name="Juror Rewards" value={rewards} />}
6244
{typeof period !== "undefined" && date && (
63-
<Field
64-
icon={CalendarIcon}
65-
name={getPeriodPhrase(period)}
66-
value={new Date(date * 1000).toLocaleString()}
67-
/>
45+
<Field icon={CalendarIcon} name={getPeriodPhrase(period)} value={new Date(date * 1000).toLocaleString()} />
6846
)}
6947
</Container>
7048
);

web/src/components/DisputeCard/PeriodBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { Periods } from "consts/periods";
12
import React from "react";
23
import styled, { Theme } from "styled-components";
3-
import { Periods } from "consts/periods";
44

55
export interface IPeriodBanner {
66
id: number;
@@ -54,7 +54,7 @@ const Container = styled.div<Omit<IPeriodBanner, "id">>`
5454
}};
5555
`;
5656

57-
const getPeriodLabel = (period: Periods) => {
57+
const getPeriodLabel = (period: Periods): string => {
5858
switch (period) {
5959
case Periods.appeal:
6060
return "Crowdfunding Appeal";

web/src/hooks/queries/useAppealCost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import useSWRImmutable from "swr/immutable";
21
import { useConnectedContract } from "hooks/useConnectedContract";
2+
import useSWRImmutable from "swr/immutable";
33

44
export const useAppealCost = (disputeID?: string) => {
55
const KlerosCore = useConnectedContract("KlerosCore");

web/src/hooks/queries/useCasesQuery.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import useSWR from "swr";
21
import { gql } from "graphql-request";
32
import { CasesPageQuery } from "src/graphql/generated";
3+
import useSWR from "swr";
44
export type { CasesPageQuery };
55

66
const casesQuery = gql`
77
query CasesPage($skip: Int) {
8-
disputes(
9-
first: 3
10-
skip: $skip
11-
orderBy: lastPeriodChange
12-
orderDirection: desc
13-
) {
8+
disputes(first: 3, skip: $skip, orderBy: lastPeriodChange, orderDirection: desc) {
149
id
1510
arbitrated {
1611
id
@@ -30,7 +25,7 @@ const casesQuery = gql`
3025
}
3126
`;
3227

33-
export const useCasesQuery = (skip: number) => {
28+
export const useCasesQuery = (skip: number): { data: typeof result; error: any; isValidating: boolean } => {
3429
const { data, error, isValidating } = useSWR({
3530
query: casesQuery,
3631
variables: { skip: skip },

web/src/hooks/queries/useClassicAppealQuery.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import useSWR from "swr";
21
import { gql } from "graphql-request";
32
import { ClassicAppealQuery } from "src/graphql/generated";
3+
import useSWR from "swr";
44
export type { ClassicAppealQuery };
55

66
const classicAppealQuery = gql`
@@ -29,7 +29,9 @@ const classicAppealQuery = gql`
2929
}
3030
`;
3131

32-
export const useClassicAppealQuery = (id?: string | number) => {
32+
export const useClassicAppealQuery = (
33+
id?: string | number
34+
): { data: typeof result; error: any; isValidating: boolean } => {
3335
const { data, error, isValidating } = useSWR(() =>
3436
typeof id !== "undefined"
3537
? {

web/src/hooks/queries/useCourtDetails.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import useSWR from "swr";
21
import { gql } from "graphql-request";
32
import { CourtDetailsQuery } from "src/graphql/generated";
3+
import useSWR from "swr";
44
export type { CourtDetailsQuery };
55

66
const courtDetailsQuery = gql`
@@ -18,7 +18,7 @@ const courtDetailsQuery = gql`
1818
}
1919
`;
2020

21-
export const useCourtDetails = (id?: string) => {
21+
export const useCourtDetails = (id?: string): { data: typeof result; error: any; isValidating: boolean } => {
2222
const { data, error, isValidating } = useSWR(
2323
id
2424
? {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import useSWRImmutable from "swr/immutable";
21
import { gql } from "graphql-request";
32
import { CourtPolicyUriQuery } from "src/graphql/generated";
3+
import useSWRImmutable from "swr/immutable";
44
export type { CourtPolicyUriQuery };
55

66
const courtPolicyURIQuery = gql`
@@ -11,7 +11,7 @@ const courtPolicyURIQuery = gql`
1111
}
1212
`;
1313

14-
export const useCourtPolicyURI = (id?: string | number) => {
14+
export const useCourtPolicyURI = (id?: string | number): { data: typeof result; error: any; isValidating: boolean } => {
1515
const { data, error, isValidating } = useSWRImmutable(() =>
1616
typeof id !== "undefined"
1717
? {
@@ -20,8 +20,6 @@ export const useCourtPolicyURI = (id?: string | number) => {
2020
}
2121
: false
2222
);
23-
const result = data
24-
? (data.court.policy as CourtPolicyUriQuery.court.policy)
25-
: undefined;
23+
const result = data ? (data.court.policy as CourtPolicyUriQuery.court.policy) : undefined;
2624
return { data: result, error, isValidating };
2725
};

web/src/hooks/queries/useCourtTree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import useSWR from "swr";
21
import { gql } from "graphql-request";
32
import { CourtTreeQuery } from "src/graphql/generated";
3+
import useSWR from "swr";
44
export type { CourtTreeQuery };
55

66
const courtTreeQuery = gql`
@@ -32,7 +32,7 @@ const courtTreeQuery = gql`
3232
}
3333
`;
3434

35-
export const useCourtTree = () => {
35+
export const useCourtTree = (): { data: typeof result; error: any; isValidating: boolean } => {
3636
const { data, error, isValidating } = useSWR({
3737
query: courtTreeQuery,
3838
});

web/src/hooks/queries/useDisputeDetailsQuery.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import useSWR from "swr";
21
import { gql } from "graphql-request";
32
import { DisputeDetailsQuery } from "src/graphql/generated";
3+
import useSWR from "swr";
44
export type { DisputeDetailsQuery };
55

66
const disputeDetailsQuery = gql`
@@ -22,7 +22,9 @@ const disputeDetailsQuery = gql`
2222
}
2323
`;
2424

25-
export const useDisputeDetailsQuery = (id?: string | number) => {
25+
export const useDisputeDetailsQuery = (
26+
id?: string | number
27+
): { data: typeof result; error: any; isValidating: boolean } => {
2628
const { data, error, isValidating } = useSWR(() =>
2729
typeof id !== "undefined"
2830
? {

web/src/hooks/queries/useDisputeKitClassicMultipliers.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import useSWRImmutable from "swr/immutable";
21
import { BigNumber } from "ethers";
32
import { useConnectedContract } from "hooks/useConnectedContract";
3+
import useSWRImmutable from "swr/immutable";
44

55
export const useDisputeKitClassicMultipliers = () => {
66
const disputeKitClassic = useConnectedContract("DisputeKitClassic");
77
return useSWRImmutable(
88
() => (disputeKitClassic ? `Multipliers` : false),
99
async () => {
1010
if (!disputeKitClassic) return;
11-
const winner_stake_multiplier =
12-
await disputeKitClassic.WINNER_STAKE_MULTIPLIER();
13-
const loser_stake_multiplier =
14-
await disputeKitClassic.LOSER_STAKE_MULTIPLIER();
15-
const loser_appeal_period_multiplier =
16-
await disputeKitClassic.LOSER_APPEAL_PERIOD_MULTIPLIER();
11+
const winner_stake_multiplier = await disputeKitClassic.WINNER_STAKE_MULTIPLIER();
12+
const loser_stake_multiplier = await disputeKitClassic.LOSER_STAKE_MULTIPLIER();
13+
const loser_appeal_period_multiplier = await disputeKitClassic.LOSER_APPEAL_PERIOD_MULTIPLIER();
1714
return {
1815
winner_stake_multiplier,
1916
loser_stake_multiplier,

0 commit comments

Comments
 (0)