-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
118 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/hardwareWallet/store/actions/actions.js → ...reWallet/store/actions/accountsActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...dwareWallet/store/actions/actions.test.js → ...let/store/actions/accountsActions.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { IPC_MESSAGES } from '@libs/hwServer/constants'; | ||
|
||
const {DEVICE_LIST_CHANGED, DEVICE_UPDATE} = IPC_MESSAGES | ||
const actionTypes = { | ||
storeHWAccounts: 'STORE_HW_ACCOUNTS', | ||
removeHWAccounts: 'REMOVE_HW_ACCOUNTS', | ||
storeHWAccounts: 'HW_ACCOUNTS_ADD', | ||
removeHWAccounts: 'HW_ACCOUNTS_REMOVE', | ||
changeDevices: `HW_${DEVICE_LIST_CHANGED}`, | ||
deviceUpdate: `HW_${DEVICE_UPDATE}`, | ||
}; | ||
|
||
export default actionTypes; |
13 changes: 13 additions & 0 deletions
13
src/modules/hardwareWallet/store/actions/devicesActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { IPC_MESSAGES } from '@libs/hwServer/constants'; | ||
|
||
const { DEVICE_LIST_CHANGED, DEVICE_UPDATE } = IPC_MESSAGES; | ||
|
||
export const setHardwareWalletDevices = (devices) => ({ | ||
type: `HW_${DEVICE_LIST_CHANGED}`, | ||
devices, | ||
}); | ||
|
||
export const setCurrentDevice = ({device}) => ({ | ||
type: `HW_${DEVICE_UPDATE}`, | ||
device, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './accountsActions' | ||
export * from './devicesActions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/modules/hardwareWallet/store/reducers/acountsReducers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import actionTypes from '../actions/actionTypes'; | ||
|
||
const initAccounts = []; | ||
|
||
export const accounts = (state = initAccounts, {type, accounts: hwAccount= initAccounts}) => { | ||
switch (type) { | ||
case actionTypes.storeHWAccounts: | ||
return hwAccount; | ||
case actionTypes.removeHWAccounts: | ||
return initAccounts; | ||
default: | ||
return state; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/modules/hardwareWallet/store/reducers/currentDeviceReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import actionTypes from '@hardwareWallet/store/actions/actionTypes'; | ||
|
||
export const initialState = { | ||
status: 'disconnected', | ||
}; | ||
|
||
/** | ||
* | ||
* @param {Object} state | ||
* @param {Object} action | ||
*/ | ||
export const currentDevice = (state = initialState, action) => { | ||
const { type, device } = action; | ||
switch (type) { | ||
case actionTypes.deviceUpdate: { | ||
return device; | ||
} | ||
default: | ||
return state; | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/modules/hardwareWallet/store/reducers/devicesReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import actionTypes from '@hardwareWallet/store/actions/actionTypes'; | ||
|
||
export const initialState = []; | ||
|
||
/** | ||
* | ||
* @param {Object} state | ||
* @param {Object} action | ||
*/ | ||
export const devices = (state = initialState, action) => { | ||
const { type, devices: newDevices } = action; | ||
switch (type) { | ||
case actionTypes.changeDevices: { | ||
return newDevices; | ||
} | ||
default: | ||
return state; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { combineReducers } from 'redux'; | ||
import { accounts } from './acountsReducers'; | ||
import { currentDevice } from './currentDeviceReducer'; | ||
import { devices } from './devicesReducer'; | ||
|
||
export const hardwareWallet = combineReducers({ | ||
devices, | ||
currentDevice, | ||
accounts, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const selectHardwareDevices = (state) => state.hardwareWallet.devices; | ||
export const selectActiveHardwareDeviceId = (state) => state.hardwareWallet.currentDevice.deviceId; | ||
export const selectActiveHardwareDevice = (state) => state.hardwareWallet.currentDevice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters