refactor: upgrade @redux/toolkit

This commit is contained in:
kyranjamie
2023-01-16 14:02:47 +01:00
committed by kyranjamie
parent c61dc9f7c6
commit 5b3e8c0a38
5 changed files with 393 additions and 1008 deletions

View File

@@ -136,7 +136,7 @@
"@reach/rect": "0.15.3",
"@reach/utils": "0.15.3",
"@reach/visually-hidden": "0.15.2",
"@reduxjs/toolkit": "1.8.4",
"@reduxjs/toolkit": "1.9.1",
"@scure/base": "1.1.1",
"@scure/bip32": "1.1.1",
"@scure/bip39": "1.1.0",
@@ -200,7 +200,7 @@
"react-hot-toast": "2.0.0",
"react-icons": "4.3.1",
"react-lottie": "1.2.3",
"react-redux": "8.0.2",
"react-redux": "8.0.5",
"react-router-dom": "6.4.3",
"react-virtuoso": "2.19.1",
"redux-persist": "6.0.0",
@@ -222,7 +222,7 @@
"@emotion/cache": "11.10.5",
"@playwright/test": "1.28.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"@redux-devtools/cli": "1.0.7",
"@redux-devtools/cli": "2.0.0",
"@redux-devtools/remote": "0.7.5",
"@schemastore/web-manifest": "0.0.5",
"@sentry/webpack-plugin": "1.20.0",
@@ -232,9 +232,6 @@
"@stacks/stacks-blockchain-api-types": "0.65.0",
"@swc-node/jest": "1.5.6",
"@swc/core": "1.3.24",
"@testing-library/react": "12.0.0",
"@testing-library/react-hooks": "7.0.1",
"@testing-library/user-event": "13.1.9",
"@trivago/prettier-plugin-sort-imports": "3.4.0",
"@types/argon2-browser": "1.18.1",
"@types/chroma-js": "2.1.3",

View File

@@ -1,24 +0,0 @@
import { act, renderHook } from '@testing-library/react-hooks';
import { TEST_ACCOUNTS_WITH_ADDRESS } from '@tests-legacy/mocks';
import { ProviderWithTestWallet } from '@tests-legacy/state-utils';
import { useAtomValue } from 'jotai/utils';
import { accountsWithAddressState, softwareAccountsState } from '@app/store/accounts/accounts';
describe.skip('account state', () => {
it('wallet has correct amount of accounts state', async () => {
const { result } = renderHook(() => useAtomValue(softwareAccountsState), {
wrapper: ProviderWithTestWallet,
});
expect(result.current?.length).toBe(4);
});
it('all addresses are correct for test accounts (mainnet)', async () => {
const promise = Promise.resolve();
const { result } = renderHook(() => useAtomValue(accountsWithAddressState), {
wrapper: ProviderWithTestWallet,
});
expect(result.current).toEqual(TEST_ACCOUNTS_WITH_ADDRESS);
await act(() => promise);
});
});

View File

@@ -17,6 +17,7 @@ const initialState: Record<string, StxChainKeyState> = {
export const stxChainSlice = createSlice({
name: 'stxChain',
initialState,
reducers: {
switchAccount(state, action: PayloadAction<number>) {
state.default.currentAccountIndex = action.payload;
@@ -29,10 +30,11 @@ export const stxChainSlice = createSlice({
state.default.highestAccountIndex = action.payload;
},
},
extraReducers: {
[keySlice.actions.signOut.toString()]: state => {
extraReducers: builder => {
builder.addCase(keySlice.actions.signOut.toString(), state => {
state.default.highestAccountIndex = 0;
state.default.currentAccountIndex = 0;
},
});
},
});

View File

@@ -17,6 +17,7 @@ const initialState: InMemoryKeyState = {
export const inMemoryKeySlice = createSlice({
name: 'inMemoryKey',
initialState,
reducers: {
generateWalletKey(state, action: PayloadAction<string>) {
if (state.keys[defaultKeyId]) {
@@ -38,9 +39,10 @@ export const inMemoryKeySlice = createSlice({
state.keys = {};
},
},
extraReducers: {
[keySlice.actions.signOut.toString()](state) {
extraReducers: builder => {
builder.addCase(keySlice.actions.signOut.toString(), state => {
state.keys = {};
},
});
},
});

1352
yarn.lock

File diff suppressed because it is too large Load Diff