Skip to content

Commit e7e9bbe

Browse files
committed
chore(typecheck): running typecheck
1 parent eb75abc commit e7e9bbe

12 files changed

Lines changed: 127 additions & 91 deletions

File tree

components/ChainSelector.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ import { toKeyIndex } from 'util/string'
1212
import { Icon, Label } from 'components/ui'
1313

1414
interface ForkOption {
15-
label: string;
15+
label: string
1616
}
1717

18-
19-
type HandleForkChange = (option: ForkOption) => void;
20-
18+
type HandleForkChange = (option: ForkOption) => void
2119

2220
const useBuildForkActions = (
2321
forkOptions: ForkOption[],
24-
handleForkChange: HandleForkChange
22+
handleForkChange: HandleForkChange,
2523
) => {
2624
return useMemo(() => {
27-
const forkIds = forkOptions.map((option, index) => toKeyIndex('fork', index));
25+
const forkIds = forkOptions.map((option, index) =>
26+
toKeyIndex('fork', index),
27+
)
2828

2929
const forkActions = forkOptions.map((option, index) => ({
3030
id: toKeyIndex('fork', index),
@@ -34,7 +34,7 @@ const useBuildForkActions = (
3434
section: '',
3535
perform: () => handleForkChange(option),
3636
parent: 'fork',
37-
}));
37+
}))
3838

3939
return [
4040
{
@@ -46,12 +46,9 @@ const useBuildForkActions = (
4646
children: forkIds,
4747
},
4848
...forkActions,
49-
];
50-
}, [forkOptions, handleForkChange]);
51-
};
52-
53-
54-
49+
]
50+
}, [forkOptions, handleForkChange])
51+
}
5552

5653
const ChainOption = (props: any) => {
5754
const { data, children } = props
@@ -70,15 +67,21 @@ const ChainSelector = () => {
7067
const [forkValue, setForkValue] = useState(null)
7168
const router = useRouter()
7269

73-
const forkOptions = useMemo(() => forks.map((fork) => ({ value: fork.name, label: fork.name })), [forks])
70+
const forkOptions = useMemo(
71+
() => forks.map((fork) => ({ value: fork.name, label: fork.name })),
72+
[forks],
73+
)
7474

75-
const handleForkChange = useCallback((option: OnChangeValue<any, any>) => {
76-
setForkValue(option)
77-
onForkChange(option.value)
75+
const handleForkChange = useCallback(
76+
(option: OnChangeValue<any, any>) => {
77+
setForkValue(option)
78+
onForkChange(option.value)
7879

79-
router.query.fork = option.value
80-
router.push(router)
81-
}, [onForkChange, router])
80+
router.query.fork = option.value
81+
router.push(router)
82+
},
83+
[onForkChange, router],
84+
)
8285

8386
const actions = useBuildForkActions(forkOptions, handleForkChange)
8487

@@ -104,5 +107,4 @@ const ChainSelector = () => {
104107
)
105108
}
106109

107-
108110
export default ChainSelector

components/KBar/Results.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { useMemo } from 'react'
2+
23
import { KBarResults, useMatches } from 'kbar'
4+
35
import ResultItem from './ResultItem'
46

57
const NO_GROUP = 'none'
68

79
const Results = () => {
8-
const { results } = useMatches()
10+
const { results } = useMatches()
911

1012
const flattened = useMemo(() => {
1113
return results.reduce((acc: any[], curr: any) => {
1214
if (typeof curr === 'string') {
1315
acc.push(curr)
1416
} else {
15-
acc.push(curr.name)
16-
acc.push(...curr.actions)
17+
acc.push(curr.name)
18+
acc.push(...curr.actions)
1719
}
1820
return acc
1921
}, [])

components/Reference/Filters.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ type Props = {
1414
isTransactionType?: boolean
1515
}
1616

17-
const Filters = ({ onSetFilter, isPrecompiled = false, isTransactionType = false }: Props) => {
17+
const Filters = ({
18+
onSetFilter,
19+
isPrecompiled = false,
20+
isTransactionType = false,
21+
}: Props) => {
1822
const router = useRouter()
1923
const [searchKeyword, setSearchKeyword] = useState('')
2024
const [searchFilter, setSearchFilter] = useState({
@@ -24,11 +28,17 @@ const Filters = ({ onSetFilter, isPrecompiled = false, isTransactionType = false
2428

2529
const filterByOptions = useMemo(() => {
2630
if (isTransactionType) {
27-
28-
return [{ label: 'Type', value: 'type' }, { label: 'Name', value: 'name' }, { label: 'Description', value: 'description' }]
29-
} else {
3031
return [
31-
{ label: !isPrecompiled ? 'Opcode' : 'Address', value: 'opcodeOrAddress' },
32+
{ label: 'Type', value: 'type' },
33+
{ label: 'Name', value: 'name' },
34+
{ label: 'Description', value: 'description' },
35+
]
36+
} else {
37+
return [
38+
{
39+
label: !isPrecompiled ? 'Opcode' : 'Address',
40+
value: 'opcodeOrAddress',
41+
},
3242
{ label: 'Name', value: 'name' },
3343
{ label: 'Description', value: 'description' },
3444
]

components/Reference/Header.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ const ReferenceHeader = ({ isPrecompiled, isTransactionType }: Props) => {
1313
const { selectedFork } = useContext(EthereumContext)
1414

1515
let title = 'Instructions'
16-
if (isPrecompiled) title = 'Precompiled Contracts'
17-
if (isTransactionType) title = 'Transaction Types'
16+
if (isPrecompiled) {
17+
title = 'Precompiled Contracts'
18+
}
19+
if (isTransactionType) {
20+
title = 'Transaction Types'
21+
}
1822

1923
return (
2024
<H2 className="pb-8 md:pb-0 inline-flex items-center">

components/Reference/columns.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Row } from 'react-table'
2-
import { StackBox } from 'components/ui'
32

3+
import { StackBox } from 'components/ui'
44

55
// Possible fields are defined in `Opcodes.json`
66
type OpcodeRow = Row<Record<string, string | undefined>>
@@ -13,7 +13,7 @@ const filter = (rows: OpcodeRow[], id: string, filterValue: string) => {
1313
)
1414
}
1515

16-
const columns = (isPrecompiled: boolean, isTransactionType: boolean = false) => {
16+
const columns = (isPrecompiled: boolean, isTransactionType = false) => {
1717
if (isTransactionType) {
1818
return [
1919
{
@@ -44,12 +44,12 @@ const columns = (isPrecompiled: boolean, isTransactionType: boolean = false) =>
4444
key={index}
4545
className={`ml-2 py-1 px-3 leading-normal rounded-full text-2xs tracking-widest font-medium ${
4646
rollupName === 'optimism'
47-
? 'bg-red-500 text-white'
47+
? 'bg-red-500 text-white'
4848
: rollupName === 'base'
4949
? 'bg-blue-500 text-white'
5050
: rollupName === 'arbitrumOne'
5151
? 'bg-blue-300 text-white'
52-
: 'bg-gray-400 text-gray-800'
52+
: 'bg-gray-400 text-gray-800'
5353
}`}
5454
style={{ margin: '4px' }}
5555
>

components/Reference/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Link from 'next/link'
1414
import { useRouter } from 'next/router'
1515
import { useTable, useExpanded, useFilters, HeaderGroup } from 'react-table'
1616
import ReactTooltip from 'react-tooltip'
17-
import { IReferenceItem, IItemDocs, IGasDocs} from 'types'
17+
import { IReferenceItem, IItemDocs, IGasDocs } from 'types'
1818

1919
import {
2020
EthereumContext,
@@ -38,20 +38,23 @@ type CustomHeaderGroup = {
3838
const ReferenceTable = ({
3939
itemDocs,
4040
gasDocs,
41-
reference,
41+
reference,
4242
isPrecompiled = false,
4343
isTransactionType = false,
4444
}: {
4545
itemDocs: IItemDocs
4646
gasDocs: IGasDocs
47-
reference: IReferenceItem[]
47+
reference: IReferenceItem[]
4848
isPrecompiled?: boolean
4949
isTransactionType?: boolean
5050
}) => {
5151
const router = useRouter()
5252
const { forks, selectedFork, onForkChange } = useContext(EthereumContext)
5353
const data = useMemo(() => reference, [reference])
54-
const columns = useMemo(() => tableColumns(isPrecompiled, isTransactionType), [isPrecompiled, isTransactionType])
54+
const columns = useMemo(
55+
() => tableColumns(isPrecompiled, isTransactionType),
56+
[isPrecompiled, isTransactionType],
57+
)
5558
const rowRefs = useRef<HTMLTableRowElement[]>([])
5659
const [focusedOpcode, setFocusedOpcode] = useState<number | null>()
5760
const { width: screenWidth } = useWindowSize()
@@ -149,8 +152,15 @@ const ReferenceTable = ({
149152
return (
150153
<>
151154
<div className="flex flex-col md:flex-row md:items-center md:justify-between mb-4 md:mb-10">
152-
<Header isPrecompiled={isPrecompiled} isTransactionType={isTransactionType} />
153-
<Filters onSetFilter={setFilter} isPrecompiled={isPrecompiled} isTransactionType={isTransactionType}/>
155+
<Header
156+
isPrecompiled={isPrecompiled}
157+
isTransactionType={isTransactionType}
158+
/>
159+
<Filters
160+
onSetFilter={setFilter}
161+
isPrecompiled={isPrecompiled}
162+
isTransactionType={isTransactionType}
163+
/>
154164
</div>
155165

156166
<table {...getTableProps()} className="w-full table-fixed">

components/ThemeSelector.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ThemeSelector = () => {
1212
name: 'Select theme…',
1313
shortcut: ['t'],
1414
keywords: 'theme appearance',
15-
section: 'Preferences',
15+
section: 'Preferences',
1616
},
1717
{
1818
id: 'theme-light',
@@ -41,7 +41,6 @@ const ThemeSelector = () => {
4141
perform: () => setTheme('system'),
4242
parent: 'theme',
4343
},
44-
4544
]
4645

4746
useRegisterActions(actions, [actions])

components/ui/StackBox.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import React from 'react'
2+
23
import cn from 'classnames'
34

45
type Props = {
5-
value?: string
6+
value?: string
67
showEmpty?: boolean
78
isFullWidth?: boolean
89
className?: string
910
}
1011

1112
export const StackBox: React.FC<Props> = ({
12-
value = '',
13-
showEmpty = true,
13+
value = '',
14+
showEmpty = true,
1415
isFullWidth,
1516
className,
1617
}) => {
1718
if (!showEmpty && value.trim().length === 0) {
18-
return null
19+
return null
1920
}
2021

2122
const parts = value.split(/[^\\]\|/)

context/ethereumContext.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
IInstruction,
2323
IStorage,
2424
IExecutionState,
25-
IChain,
25+
IChain,
2626
} from 'types'
2727

2828
import { CURRENT_FORK, FORKS_WITH_TIMESTAMPS } from 'util/constants'
@@ -160,23 +160,24 @@ export const EthereumProvider: React.FC<{}> = ({ children }) => {
160160
}, [])
161161

162162
const loadTransactionTypes = () => {
163-
const typesTransactions: IReferenceItem[] = Object.entries(TranscationsMeta).map(([key, value]) => {
163+
const typesTransactions: IReferenceItem[] = Object.entries(
164+
TranscationsMeta,
165+
).map(([key, value]) => {
164166
return {
165-
opcodeOrAddress: key,
166-
name: value.name,
167-
input: '',
168-
output: '',
169-
description: value.description,
170-
staticFee: 0,
171-
minimumFee: 0,
172-
rollups: value.rollups,
167+
opcodeOrAddress: key,
168+
name: value.name,
169+
input: '',
170+
output: '',
171+
description: value.description,
172+
staticFee: 0,
173+
minimumFee: 0,
174+
rollups: value.rollups,
173175
transactionType: '',
174-
};
175-
});
176-
177-
setTransactionTypes(typesTransactions);
176+
}
177+
})
178+
179+
setTransactionTypes(typesTransactions)
178180
}
179-
180181

181182
/**
182183
* Initializes the EVM instance.

lib/useActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useRouter } from 'next/router'
2+
import { useTheme } from 'next-themes'
23

34
import { GITHUB_REPO_URL } from 'util/constants'
4-
import { useTheme } from 'next-themes'
55

66
import { Icon } from 'components/ui'
77

0 commit comments

Comments
 (0)