Skip to content

Commit 664f7f2

Browse files
committed
Remove selectedWalletId and selectedTokenId
Oh selectedTokenId, many may not know your name
1 parent 747dca9 commit 664f7f2

File tree

5 files changed

+3
-79
lines changed

5 files changed

+3
-79
lines changed

src/__tests__/reducers/__snapshots__/RootReducer.test.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ exports[`initialState 1`] = `
158158
"subcategories": [],
159159
"wallets": {
160160
"fioWallets": [],
161-
"selectedTokenId": null,
162-
"selectedWalletId": "",
163161
},
164162
},
165163
}

src/actions/WalletActions.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ export function selectWalletToken({
7676
const currencyCode = getCurrencyCode(wallet, tokenId)
7777
dispatch(updateMostRecentWalletsSelected(walletId, tokenId))
7878

79-
const currentWalletId = state.ui.wallets.selectedWalletId
80-
const currentWalletTokenId = state.ui.wallets.selectedTokenId
81-
8279
if (tokenId != null) {
8380
const { unactivatedTokenIds } = wallet
8481
if (
@@ -89,12 +86,7 @@ export function selectWalletToken({
8986
await dispatch(activateWalletTokens(navigation, wallet, [tokenId]))
9087
return false
9188
}
92-
if (walletId !== currentWalletId || tokenId !== currentWalletTokenId) {
93-
dispatch({
94-
type: 'UI/WALLETS/SELECT_WALLET',
95-
data: { walletId, tokenId }
96-
})
97-
}
89+
9890
return true
9991
}
10092

@@ -103,24 +95,14 @@ export function selectWalletToken({
10395
)
10496
if (isAccountActivationRequired) {
10597
// activation-required wallets need different path in case not activated yet
106-
if (
107-
alwaysActivate ||
108-
walletId !== currentWalletId ||
109-
tokenId !== currentWalletTokenId
110-
) {
98+
if (alwaysActivate) {
11199
return await dispatch(
112100
selectActivationRequiredWallet(navigation, walletId, currencyCode)
113101
)
114102
}
115103
return true
116104
}
117105

118-
if (walletId !== currentWalletId || tokenId !== currentWalletTokenId) {
119-
dispatch({
120-
type: 'UI/WALLETS/SELECT_WALLET',
121-
data: { walletId, tokenId }
122-
})
123-
}
124106
return true
125107
}
126108
}
@@ -139,10 +121,6 @@ function selectActivationRequiredWallet(
139121

140122
if (publicAddress !== '') {
141123
// already activated
142-
dispatch({
143-
type: 'UI/WALLETS/SELECT_WALLET',
144-
data: { walletId, tokenId: null }
145-
})
146124
return true
147125
} else {
148126
// not activated yet

src/reducers/scenes/WalletsReducer.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,9 @@ import { combineReducers, type Reducer } from 'redux'
44
import type { Action } from '../../types/reduxTypes'
55

66
export interface WalletsState {
7-
selectedWalletId: string
8-
selectedTokenId: EdgeTokenId
97
fioWallets: EdgeCurrencyWallet[]
108
}
119

12-
const selectedWalletId = (state = '', action: Action): string => {
13-
switch (action.type) {
14-
case 'UI/WALLETS/SELECT_WALLET': {
15-
return action.data.walletId
16-
}
17-
18-
case 'ACCOUNT_INIT_COMPLETE': {
19-
if (action.data == null) throw new TypeError('Invalid action')
20-
if (action.data.walletId === '') return state
21-
return action.data.walletId
22-
}
23-
24-
default:
25-
return state
26-
}
27-
}
28-
29-
const selectedTokenId = (
30-
state: EdgeTokenId = null,
31-
action: Action
32-
): EdgeTokenId => {
33-
switch (action.type) {
34-
case 'UI/WALLETS/SELECT_WALLET': {
35-
return action.data.tokenId
36-
}
37-
38-
case 'ACCOUNT_INIT_COMPLETE': {
39-
if (action.data == null) throw new TypeError('Invalid action')
40-
if (action.data.tokenId === '') return state
41-
return action.data.tokenId
42-
}
43-
44-
default:
45-
return state
46-
}
47-
}
48-
4910
const fioWallets: Reducer<WalletsState['fioWallets'], Action> = (
5011
state = [],
5112
action
@@ -62,7 +23,5 @@ const fioWallets: Reducer<WalletsState['fioWallets'], Action> = (
6223
}
6324

6425
export const wallets = combineReducers<WalletsState, Action>({
65-
selectedWalletId,
66-
selectedTokenId,
6726
fioWallets
6827
})

src/selectors/WalletSelectors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import type { GuiExchangeRates } from '../actions/ExchangeRateActions'
1010
import type { RootState } from '../types/reduxTypes'
1111
import { convertNativeToExchange, zeroString } from '../util/utils'
1212

13-
export function getSelectedCurrencyWallet(
14-
state: RootState
15-
): EdgeCurrencyWallet {
16-
return state.core.account.currencyWallets[state.ui.wallets.selectedWalletId]
17-
}
18-
1913
export const getActiveWalletCurrencyInfos = (
2014
currencyWallets: Record<string, EdgeCurrencyWallet>
2115
): EdgeCurrencyInfo[] => {

src/types/reduxActions.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import type {
44
EdgeContext,
55
EdgeCurrencyWallet,
66
EdgeDenomination,
7-
EdgeSwapPluginType,
8-
EdgeTokenId
7+
EdgeSwapPluginType
98
} from 'edge-core-js'
109

1110
import type { ExchangeInfo } from '../actions/ExchangeInfoActions'
@@ -159,10 +158,6 @@ export type Action =
159158
data: { pinLoginEnabled: boolean }
160159
}
161160
| { type: 'UI/SETTINGS/UPDATE_SETTINGS'; data: { settings: SettingsState } }
162-
| {
163-
type: 'UI/WALLETS/SELECT_WALLET'
164-
data: { tokenId: EdgeTokenId; walletId: string }
165-
}
166161
| { type: 'UI/SET_COUNTRY_CODE'; data: { countryCode: string | undefined } }
167162
| {
168163
type: 'UI/SET_NOTIFICATION_HEIGHT'

0 commit comments

Comments
 (0)