Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency @reduxjs/toolkit to v2 #207

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@lingui/core": "4.7.0",
"@lingui/macro": "4.7.0",
"@lingui/react": "4.7.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/react-query": "^5.17.10",
"@tanstack/react-table": "8.11.6",
"@vercel/analytics": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/pool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@lingui/core": "4.7.0",
"@lingui/macro": "4.7.0",
"@lingui/react": "4.7.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/react-query": "^5.17.10",
"@tanstack/react-table": "8.11.6",
"@vercel/analytics": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/referrals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@lingui/core": "4.7.0",
"@lingui/macro": "4.7.0",
"@lingui/react": "4.7.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/react-query": "^5.17.10",
"@tanstack/react-table": "8.11.6",
"@vercel/analytics": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@lingui/core": "4.7.0",
"@lingui/macro": "4.7.0",
"@lingui/react": "4.7.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/react-query": "^5.17.10",
"@vercel/analytics": "^1.1.1",
"@zenlink-interface/amm": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@lingui/core": "4.7.0",
"@lingui/macro": "4.7.0",
"@lingui/react": "4.7.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@zenlink-interface/amm": "workspace:*",
"@zenlink-interface/chain": "workspace:*",
"@zenlink-interface/currency": "workspace:*",
Expand Down
10 changes: 5 additions & 5 deletions packages/redux/localstorage/hooks/useAllCustomTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ type UseCustomTokensReturn = [
type UseAllCustomTokens = (context: StorageContext) => UseCustomTokensReturn

export const useAllCustomTokens: UseAllCustomTokens = (context) => {
const { reducerPath, actions } = context
const { reducerPath } = context
const { customTokens } = useSelector((state: WithStorageState) => state[reducerPath])
const dispatch = useDispatch()

const addCustomToken = useCallback(
({ symbol, address, chainId, name, decimals }: TokenAsObject) => {
dispatch(actions.addCustomToken({ symbol, address, chainId, name, decimals }))
dispatch({ type: 'addCustomToken', payload: { symbol, address, chainId, name, decimals } })
},
[actions, dispatch],
[dispatch],
)

const removeCustomToken = useCallback(
({ address, chainId }: Pick<TokenAsObject, 'address' | 'chainId'>) => {
dispatch(actions.removeCustomToken({ address, chainId }))
dispatch({ type: 'removeCustomToken', payload: { address, chainId } })
},
[actions, dispatch],
[dispatch],
)

const tokens = useMemo(() => {
Expand Down
14 changes: 7 additions & 7 deletions packages/redux/localstorage/hooks/useCustomTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ type UseCustomTokensReturn = [
type UseCustomTokens = (context: StorageContext, chainId?: number) => UseCustomTokensReturn

export const useCustomTokens: UseCustomTokens = (context, chainId?: number) => {
const { reducerPath, actions } = context
const { reducerPath } = context
const { customTokens } = useSelector((state: WithStorageState) => state[reducerPath])
const dispatch = useDispatch()

const addCustomToken = useCallback(
({ symbol, address, chainId, name, decimals }: TokenAsObject) => {
dispatch(actions.addCustomToken({ symbol, address, chainId, name, decimals }))
dispatch({ type: 'addCustomToken', payload: { symbol, address, chainId, name, decimals } })
},
[actions, dispatch],
[dispatch],
)

const addCustomTokens = useCallback(
(tokens: TokenAsObject[]) => {
dispatch(actions.addCustomTokens(tokens))
dispatch({ type: 'addCustomTokens', payload: tokens })
},
[actions, dispatch],
[dispatch],
)

const removeCustomToken = useCallback(
({ address, chainId }: Pick<TokenAsObject, 'address' | 'chainId'>) => {
dispatch(actions.removeCustomToken({ address, chainId }))
dispatch({ type: 'removeCustomToken', payload: { address, chainId } })
},
[actions, dispatch],
[dispatch],
)

const tokens = useMemo(() => {
Expand Down
36 changes: 21 additions & 15 deletions packages/redux/localstorage/hooks/useNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type UseNotificationsReturn = [
type UseNotifications = (context: StorageContext, account: string | undefined) => UseNotificationsReturn

export const useNotifications: UseNotifications = (context, account) => {
const { reducerPath, actions } = context
const { reducerPath } = context
const dispatch = useDispatch()
const notifications = useSelector((state: WithStorageState) =>
Object.entries(state[reducerPath].notifications || {}).find(
Expand All @@ -42,59 +42,65 @@ export const useNotifications: UseNotifications = (context, account) => {
({ promise, ...rest }: NotificationData) => {
const { groupTimestamp } = rest
createToast({ ...rest, promise })
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({
type: 'createNotification',
payload: { account, notification: stringify(rest), timestamp: groupTimestamp },
})
},
[account, actions, dispatch],
[account, dispatch],
)

const createPendingNotification = useCallback(
(rest: NotificationData) => {
const { groupTimestamp } = rest
createPendingToast(rest)
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({
type: 'createNotification',
payload: { account, notification: stringify(rest), timestamp: groupTimestamp },
})
},
[account, actions, dispatch],
[account, dispatch],
)

const createSuccessNotification = useCallback(
(rest: NotificationData) => {
const { groupTimestamp } = rest
createSuccessToast(rest)
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({ type: 'createNotification', payload: { account, notification: stringify(rest), timestamp: groupTimestamp } })
},
[account, actions, dispatch],
[account, dispatch],
)

const createFailedNotification = useCallback(
(rest: NotificationData) => {
const { groupTimestamp } = rest
createFailedToast(rest)
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({ type: 'createNotification', payload: { account, notification: stringify(rest), timestamp: groupTimestamp } })
},
[account, actions, dispatch],
[account, dispatch],
)

const createInfoNotification = useCallback(
(rest: NotificationData) => {
const { groupTimestamp } = rest
createInfoToast(rest)
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({ type: 'createNotification', payload: { account, notification: stringify(rest), timestamp: groupTimestamp } })
},
[account, actions, dispatch],
[account, dispatch],
)

const createInlineNotification = useCallback(
({ promise, ...rest }: NotificationData) => {
const { groupTimestamp } = rest
createInlineToast({ ...rest, promise })
dispatch(actions.createNotification({ account, notification: stringify(rest), timestamp: groupTimestamp }))
dispatch({ type: 'createNotification', payload: { account, notification: stringify(rest), timestamp: groupTimestamp } })
},
[account, actions, dispatch],
[account, dispatch],
)

const clearNotifications = useCallback(() => {
dispatch(actions.clearNotifications({ account }))
}, [account, actions, dispatch])
dispatch({ type: 'clearNotifications', payload: { account } })
}, [account, dispatch])

return [
notifications || {},
Expand Down
54 changes: 27 additions & 27 deletions packages/redux/localstorage/hooks/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,99 +27,99 @@ type UseSettingsReturn = [
type UseSettings = (context: StorageContext) => UseSettingsReturn

export const useSettings: UseSettings = (context) => {
const { reducerPath, actions } = context
const { reducerPath } = context
const { ...settings } = useSelector((state: WithStorageState) => state[reducerPath])
const dispatch = useDispatch()

const updateAggregator = useCallback(
(aggregator: boolean) => {
dispatch(actions.updateAggregator({ aggregator }))
dispatch({ type: 'updateAggregator', payload: { aggregator } })
},
[actions, dispatch],
[dispatch],
)

const updateSlippageTolerance = useCallback(
(slippageTolerance: number) => {
dispatch(actions.updateSlippageTolerance({ slippageTolerance }))
dispatch({ type: 'updateSlippageTolerance', payload: { slippageTolerance } })
},
[actions, dispatch],
[dispatch],
)

const updateSlippageToleranceType = useCallback(
(slippageToleranceType: 'auto' | 'custom') => {
dispatch(actions.updateSlippageToleranceType({ slippageToleranceType }))
dispatch({ type: 'updateSlippageToleranceType', payload: { slippageToleranceType } })
},
[actions, dispatch],
[dispatch],
)

const updateMaxFeePerGas = useCallback(
(maxFeePerGas: number | string | undefined) => {
dispatch(actions.updateMaxFeePerGas({ maxFeePerGas }))
dispatch({ type: 'updateMaxFeePerGas', payload: { maxFeePerGas } })
},
[actions, dispatch],
[dispatch],
)

const updateMaxPriorityFeePerGas = useCallback(
(maxPriorityFeePerGas: number | string | undefined) => {
dispatch(actions.updateMaxPriorityFeePerGas({ maxPriorityFeePerGas }))
dispatch({ type: 'updateMaxPriorityFeePerGas', payload: { maxPriorityFeePerGas } })
},
[actions, dispatch],
[dispatch],
)

const updateGasPrice = useCallback(
(gasPrice: GasPrice) => {
dispatch(actions.updateGasPrice({ gasPrice }))
dispatch({ type: 'updateGasPrice', payload: { gasPrice } })
},
[actions, dispatch],
[dispatch],
)

const updateGasType = useCallback(
(gasType: 'preset' | 'custom') => {
dispatch(actions.updateGasType({ gasType }))
dispatch({ type: 'updateGasType', payload: { gasType } })
},
[actions, dispatch],
[dispatch],
)

const updateTransactionDeadline = useCallback(
(transactionDeadline: number) => {
dispatch(actions.updateTransactionDeadline({ transactionDeadline }))
dispatch({ type: 'updateTransactionDeadline', payload: { transactionDeadline } })
},
[actions, dispatch],
[dispatch],
)

const updateParachainId = useCallback(
(parachainId: ParachainId) => {
dispatch(actions.updateParachainId({ parachainId }))
dispatch({ type: 'updateParachainId', payload: { parachainId } })
},
[actions, dispatch],
[dispatch],
)

const updatePolkadotConnector = useCallback(
(polkadotConnector: string | undefined) => {
dispatch(actions.updatePolkadotConnector({ polkadotConnector }))
dispatch({ type: 'updatePolkadotConnector', payload: { polkadotConnector } })
},
[actions, dispatch],
[dispatch],
)

const updatePolkadotAddress = useCallback(
(polkadotAddress: string | undefined) => {
dispatch(actions.updatePolkadotAddress({ polkadotAddress }))
dispatch({ type: 'updatePolkadotAddress', payload: { polkadotAddress } })
},
[actions, dispatch],
[dispatch],
)

const updateUserLocale = useCallback(
(userLocale: string) => {
dispatch(actions.updateUserLocale({ userLocale }))
dispatch({ type: 'updateUserLocale', payload: { userLocale } })
},
[actions, dispatch],
[dispatch],
)

const updateHideAggregationSwapBanner = useCallback(
(hideAggregationSwapBanner: boolean) => {
dispatch(actions.updateHideAggregationSwapBanner({ hideAggregationSwapBanner }))
dispatch({ type: 'updateHideAggregationSwapBanner', payload: { hideAggregationSwapBanner } })
},
[actions, dispatch],
[dispatch],
)

const dynamicSettings = useDynamicObject(settings, {
Expand Down
4 changes: 2 additions & 2 deletions packages/redux/localstorage/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Middleware } from '@reduxjs/toolkit'
import type { Middleware, UnknownAction } from '@reduxjs/toolkit'
import stringify from 'fast-json-stable-stringify'

export const storageMiddleware: Middleware = store => next => (action) => {
const result = next(action)
if (action.type?.startsWith('storage/')) {
if ((action as UnknownAction).type?.startsWith('storage/')) {
const storageState = store.getState().storage
localStorage.setItem('userPreferences', stringify(storageState))
}
Expand Down
4 changes: 2 additions & 2 deletions packages/redux/localstorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"source": "./index.ts",
"peerDependencies": {
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@zenlink-interface/chain": "workspace:*",
"@zenlink-interface/currency": "workspace:*",
"react": "^18.2.0",
Expand All @@ -24,7 +24,7 @@
},
"dependencies": {},
"devDependencies": {
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.0.1",
"@types/node": "^20.11.0",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
Expand Down
2 changes: 1 addition & 1 deletion packages/redux/localstorage/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const reducers = {
}

export function createStorageSlice(reducerPath: string): Slice<StorageState> {
return createSlice<StorageState, typeof reducers>({
return createSlice({
name: reducerPath,
initialState,
reducers,
Expand Down
4 changes: 2 additions & 2 deletions packages/redux/token-lists/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyAction, CaseReducerActions, Reducer, SliceCaseReducers } from '@reduxjs/toolkit'
import type { CaseReducerActions, Reducer, SliceCaseReducers, UnknownAction } from '@reduxjs/toolkit'
import {
useActiveListNames as _useActiveListNames,
useAllLists as _useAllLists,
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface TokenListHooks {
// Inspired by RTK Query's createApi
export function createTokenLists(options?: TokenListsOptions): {
reducerPath: string
reducer: Reducer<TokenListsState, AnyAction>
reducer: Reducer<TokenListsState, UnknownAction>
actions: CaseReducerActions<SliceCaseReducers<any>, string>
hooks: TokenListHooks
Updater(props: Omit<UpdaterProps, 'context'>): JSX.Element
Expand Down
Loading
Loading