Skip to content

Commit

Permalink
refactor: Rename redux slice
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Feb 6, 2024
1 parent 2e27ff3 commit e271744
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { type RootState } from '@/store'
import { createSelector, createSlice, type PayloadAction } from '@reduxjs/toolkit'
import type { PredictedSafeProps } from '@safe-global/protocol-kit'

type UndeployedSafeSlice = { [address: string]: PredictedSafeProps }
type UndeployedSafesSlice = { [address: string]: PredictedSafeProps }

type UndeployedSafeState = { [chainId: string]: UndeployedSafeSlice }
type UndeployedSafesState = { [chainId: string]: UndeployedSafesSlice }

const initialState: UndeployedSafeState = {}
const initialState: UndeployedSafesState = {}

export const undeployedSafeSlice = createSlice({
name: 'undeployedSafe',
export const undeployedSafesSlice = createSlice({
name: 'undeployedSafes',
initialState,
reducers: {
addUndeployedSafe: (
Expand Down Expand Up @@ -38,10 +38,10 @@ export const undeployedSafeSlice = createSlice({
},
})

export const { removeUndeployedSafe, addUndeployedSafe } = undeployedSafeSlice.actions
export const { removeUndeployedSafe, addUndeployedSafe } = undeployedSafesSlice.actions

export const selectUndeployedSafes = (state: RootState): UndeployedSafeState => {
return state[undeployedSafeSlice.name]
export const selectUndeployedSafes = (state: RootState): UndeployedSafesState => {
return state[undeployedSafesSlice.name]
}

export const selectUndeployedSafe = createSelector(
Expand Down
2 changes: 1 addition & 1 deletion src/features/counterfactual/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NewSafeFormData } from '@/components/new-safe/create'
import { LATEST_SAFE_VERSION } from '@/config/constants'
import { AppRoutes } from '@/config/routes'
import { addUndeployedSafe } from '@/features/counterfactual/store/undeployedSafeSlice'
import { addUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice'
import type { AppDispatch } from '@/store'
import { addOrUpdateSafe } from '@/store/addedSafesSlice'
import { upsertAddressBookEntry } from '@/store/addressBookSlice'
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/coreSDK/useInitSafeCoreSDK.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafeSlice'
import { selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice'
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import useSafeInfo from '@/hooks/useSafeInfo'
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/loadables/useLoadSafeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafeSlice'
import { selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice'
import { getUndeployedSafeInfo } from '@/features/counterfactual/utils'
import { useAppSelector } from '@/store'
import { useEffect } from 'react'
Expand Down
6 changes: 3 additions & 3 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { safeAppsSlice } from './safeAppsSlice'
import { safeMessagesListener, safeMessagesSlice } from './safeMessagesSlice'
import { pendingSafeMessagesSlice } from './pendingSafeMessagesSlice'
import { batchSlice } from './batchSlice'
import { undeployedSafeSlice } from '@/features/counterfactual/store/undeployedSafeSlice'
import { undeployedSafesSlice } from '@/features/counterfactual/store/undeployedSafesSlice'

const rootReducer = combineReducers({
[chainsSlice.name]: chainsSlice.reducer,
Expand All @@ -50,7 +50,7 @@ const rootReducer = combineReducers({
[safeMessagesSlice.name]: safeMessagesSlice.reducer,
[pendingSafeMessagesSlice.name]: pendingSafeMessagesSlice.reducer,
[batchSlice.name]: batchSlice.reducer,
[undeployedSafeSlice.name]: undeployedSafeSlice.reducer,
[undeployedSafesSlice.name]: undeployedSafesSlice.reducer,
})

const persistedSlices: (keyof PreloadedState<RootState>)[] = [
Expand All @@ -63,7 +63,7 @@ const persistedSlices: (keyof PreloadedState<RootState>)[] = [
safeAppsSlice.name,
pendingSafeMessagesSlice.name,
batchSlice.name,
undeployedSafeSlice.name,
undeployedSafesSlice.name,
]

export const getPersistedState = () => {
Expand Down

0 comments on commit e271744

Please sign in to comment.