Commit f5557a43 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

chore: upgrade type system (#2276)

* chore: upgrade type system

Upgrade types, typescript, and formatters.

* fix: ListsState tests
parent 5dfe44da
...@@ -76,7 +76,7 @@ export function useSearchInactiveTokenLists(search: string | undefined, minResul ...@@ -76,7 +76,7 @@ export function useSearchInactiveTokenLists(search: string | undefined, minResul
if (!list) continue if (!list) continue
for (const tokenInfo of list.tokens) { for (const tokenInfo of list.tokens) {
if (tokenInfo.chainId === chainId && tokenFilter(tokenInfo)) { if (tokenInfo.chainId === chainId && tokenFilter(tokenInfo)) {
const wrapped = new WrappedTokenInfo(tokenInfo, list) const wrapped: WrappedTokenInfo = new WrappedTokenInfo(tokenInfo, list)
if (!(wrapped.address in activeTokens) && !addressSet[wrapped.address]) { if (!(wrapped.address in activeTokens) && !addressSet[wrapped.address]) {
addressSet[wrapped.address] = true addressSet[wrapped.address] = true
result.push(wrapped) result.push(wrapped)
......
...@@ -47,10 +47,12 @@ const initialState: ListsState = { ...@@ -47,10 +47,12 @@ const initialState: ListsState = {
export default createReducer(initialState, (builder) => export default createReducer(initialState, (builder) =>
builder builder
.addCase(fetchTokenList.pending, (state, { payload: { requestId, url } }) => { .addCase(fetchTokenList.pending, (state, { payload: { requestId, url } }) => {
const current = state.byUrl[url]?.current ?? null
const pendingUpdate = state.byUrl[url]?.pendingUpdate ?? null
state.byUrl[url] = { state.byUrl[url] = {
current: null, current: current,
pendingUpdate: null, pendingUpdate: pendingUpdate,
...state.byUrl[url],
loadingRequestId: requestId, loadingRequestId: requestId,
error: null, error: null,
} }
...@@ -66,11 +68,10 @@ export default createReducer(initialState, (builder) => ...@@ -66,11 +68,10 @@ export default createReducer(initialState, (builder) =>
if (upgradeType === VersionUpgrade.NONE) return if (upgradeType === VersionUpgrade.NONE) return
if (loadingRequestId === null || loadingRequestId === requestId) { if (loadingRequestId === null || loadingRequestId === requestId) {
state.byUrl[url] = { state.byUrl[url] = {
...state.byUrl[url],
loadingRequestId: null,
error: null,
current: current, current: current,
pendingUpdate: tokenList, pendingUpdate: tokenList,
loadingRequestId: null,
error: null,
} }
} }
} else { } else {
...@@ -80,11 +81,10 @@ export default createReducer(initialState, (builder) => ...@@ -80,11 +81,10 @@ export default createReducer(initialState, (builder) =>
} }
state.byUrl[url] = { state.byUrl[url] = {
...state.byUrl[url],
loadingRequestId: null,
error: null,
current: tokenList, current: tokenList,
pendingUpdate: null, pendingUpdate: null,
loadingRequestId: null,
error: null,
} }
} }
}) })
...@@ -95,11 +95,10 @@ export default createReducer(initialState, (builder) => ...@@ -95,11 +95,10 @@ export default createReducer(initialState, (builder) =>
} }
state.byUrl[url] = { state.byUrl[url] = {
...state.byUrl[url],
loadingRequestId: null,
error: errorMessage,
current: null, current: null,
pendingUpdate: null, pendingUpdate: null,
loadingRequestId: null,
error: errorMessage,
} }
}) })
.addCase(addList, (state, { payload: url }) => { .addCase(addList, (state, { payload: url }) => {
...@@ -140,8 +139,8 @@ export default createReducer(initialState, (builder) => ...@@ -140,8 +139,8 @@ export default createReducer(initialState, (builder) =>
} }
state.byUrl[url] = { state.byUrl[url] = {
...state.byUrl[url], ...state.byUrl[url],
pendingUpdate: null,
current: state.byUrl[url].pendingUpdate, current: state.byUrl[url].pendingUpdate,
pendingUpdate: null,
} }
}) })
.addCase(updateVersion, (state) => { .addCase(updateVersion, (state) => {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"noImplicitAny": true, "noImplicitAny": true,
"noImplicitThis": true, "noImplicitThis": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"useUnknownInCatchVariables": false,
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment